mirror of
git://holbrook.no/eth-accounts-index
synced 2024-11-22 09:06:46 +01:00
Add Owned, EIP165
This commit is contained in:
parent
6432eeb6d3
commit
e4e1efa1a8
7
python/.gitignore
vendored
Normal file
7
python/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
build/
|
||||||
|
dist/
|
||||||
|
*.egg-info
|
||||||
|
__pycache__
|
||||||
|
node_modules
|
||||||
|
*.pyc
|
||||||
|
gmon.out
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
|||||||
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addedAccount","type":"address"},{"indexed":true,"internalType":"uint256","name":"accountIndex","type":"uint256"}],"name":"AccountAdded","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"accounts","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accountsIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"deleteWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
|
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addedAccount","type":"address"},{"indexed":true,"internalType":"uint256","name":"accountIndex","type":"uint256"}],"name":"AccountAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"deleteWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"entryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"entryIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
|
||||||
|
@ -44,7 +44,7 @@ class Test(EthTesterCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(Test, self).setUp()
|
super(Test, self).setUp()
|
||||||
nonce_oracle = TestNonceOracle(self.accounts[0])
|
nonce_oracle = TestNonceOracle(self.accounts[0])
|
||||||
self.o = AccountRegistry(signer=self.signer, nonce_oracle=nonce_oracle)
|
self.o = AccountRegistry(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
(tx_hash, o) = self.o.constructor(self.accounts[0])
|
(tx_hash, o) = self.o.constructor(self.accounts[0])
|
||||||
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
||||||
r = self.conn.do(o)
|
r = self.conn.do(o)
|
||||||
|
@ -1 +0,0 @@
|
|||||||
608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060016002819055506106f7806100cb6000396000f3fe608060405234801561001057600080fd5b506004361061009a576000357c0100000000000000000000000000000000000000000000000000000000900480634c2ebc6b116100785780634c2ebc6b146101715780635ae06f7e146101c9578063da2824a814610223578063f2a40db81461027d5761009a565b806306661abd1461009f5780630a3b0a4f146100bd5780633ef2501314610117575b600080fd5b6100a76102d5565b6040518082815260200191505060405180910390f35b6100ff600480360360208110156100d357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506102db565b60405180821515815260200191505060405180910390f35b6101596004803603602081101561012d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061048c565b60405180821515815260200191505060405180910390f35b6101b36004803603602081101561018757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104d7565b6040518082815260200191505060405180910390f35b61020b600480360360208110156101df57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b6102656004803603602081101561023957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506105a3565b60405180821515815260200191505060405180910390f35b6102a96004803603602081101561029357600080fd5b8101908080359060200190929190505050610660565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60025481565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661033357600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461037f57600080fd5b6000829080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600254600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506002600081548092919060010191905055506001600254038273ffffffffffffffffffffffffffffffffffffffff167f5ed3bdd47b9af629827a8d129aa39c870b10c03f0153fe9ddb8e84b665061acd60405160405180910390a360019050919050565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60016020528060005260406000206000915090505481565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461054b57600080fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105ff57600080fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000818154811061066d57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff168156fea264697066735822122015b8d8e75596c6a573f6b345fd0d9e2ce7cb2ae5be362ccbe8e60c1db0871c3f64736f6c637827302e362e31322d646576656c6f702e323032312e312e382b636f6d6d69742e32376435313736350058
|
|
@ -1 +0,0 @@
|
|||||||
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addedAccount","type":"address"},{"indexed":true,"internalType":"uint256","name":"accountIndex","type":"uint256"}],"name":"AccountAdded","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"accounts","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accountsIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"deleteWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
|
|
@ -4,17 +4,19 @@ pragma solidity >0.6.11;
|
|||||||
|
|
||||||
contract CustodialAccountIndex {
|
contract CustodialAccountIndex {
|
||||||
|
|
||||||
address[] public accounts;
|
address[] public entry;
|
||||||
mapping(address => uint256) public accountsIndex;
|
mapping(address => uint256) public entryIndex;
|
||||||
uint256 public count;
|
uint256 public count;
|
||||||
mapping(address => bool) writers;
|
mapping(address => bool) writers;
|
||||||
address owner;
|
address public owner;
|
||||||
|
address newOwner;
|
||||||
|
|
||||||
event AccountAdded(address indexed addedAccount, uint256 indexed accountIndex);
|
event AccountAdded(address indexed addedAccount, uint256 indexed accountIndex); // AccountsIndex
|
||||||
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173
|
||||||
|
|
||||||
constructor() public {
|
constructor() public {
|
||||||
owner = msg.sender;
|
owner = msg.sender;
|
||||||
accounts.push(address(0));
|
entry.push(address(0));
|
||||||
count = 1;
|
count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,15 +34,50 @@ contract CustodialAccountIndex {
|
|||||||
|
|
||||||
function add(address _account) external returns (bool) {
|
function add(address _account) external returns (bool) {
|
||||||
require(writers[msg.sender]);
|
require(writers[msg.sender]);
|
||||||
require(accountsIndex[_account] == 0);
|
require(entryIndex[_account] == 0);
|
||||||
accounts.push(_account);
|
entry.push(_account);
|
||||||
accountsIndex[_account] = count;
|
entryIndex[_account] = count;
|
||||||
count++;
|
count++;
|
||||||
emit AccountAdded(_account, count-1);
|
emit AccountAdded(_account, count-1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function have(address _account) external view returns (bool) {
|
function have(address _account) external view returns (bool) {
|
||||||
return accountsIndex[_account] > 0;
|
return entryIndex[_account] > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function entryCount() public returns (uint256) {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
function transferOwnership(address _newOwner) public returns (bool) {
|
||||||
|
require(msg.sender == owner);
|
||||||
|
newOwner = _newOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
function acceptOwnership() public returns (bool) {
|
||||||
|
address oldOwner;
|
||||||
|
|
||||||
|
require(msg.sender == newOwner);
|
||||||
|
oldOwner = owner;
|
||||||
|
owner = newOwner;
|
||||||
|
newOwner = address(0);
|
||||||
|
emit OwnershipTransferred(oldOwner, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
function supportsInterface(bytes4 _sum) public pure returns (bool) {
|
||||||
|
if (_sum == 0xcbdb05c7) { // AccountsIndex
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (_sum == 0x01ffc9a7) { // EIP165
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (_sum == 0x9493f8b2) { // EIP173
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (_sum == 0x37a47be4) { // OwnedAccepter
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user