eth-accounts-index

Accounts index evm contract tooling with permissioned writes
Log | Files | Refs

commit e4e1efa1a8a0ef6af9c6ee22d7953eaff3d362fb
parent 6432eeb6d3db0eb30f5aac2b12fbf3e8165f83e5
Author: nolash <dev@holbrook.no>
Date:   Fri, 30 Apr 2021 11:36:56 +0200

Add Owned, EIP165

Diffstat:
Apython/.gitignore | 7+++++++
Mpython/eth_accounts_index/data/AccountsIndex.bin | 4++--
Mpython/eth_accounts_index/data/AccountsIndex.json | 2+-
Mpython/tests/test_app.py | 2+-
Dsolidity/AccountsIndex.bin | 2--
Dsolidity/AccountsIndex.json | 1-
Msolidity/AccountsIndex.sol | 55++++++++++++++++++++++++++++++++++++++++++++++---------
7 files changed, 57 insertions(+), 16 deletions(-)

diff --git a/python/.gitignore b/python/.gitignore @@ -0,0 +1,7 @@ +build/ +dist/ +*.egg-info +__pycache__ +node_modules +*.pyc +gmon.out diff --git a/python/eth_accounts_index/data/AccountsIndex.bin b/python/eth_accounts_index/data/AccountsIndex.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060016002819055506106f7806100cb6000396000f3fe608060405234801561001057600080fd5b506004361061009a576000357c0100000000000000000000000000000000000000000000000000000000900480634c2ebc6b116100785780634c2ebc6b146101715780635ae06f7e146101c9578063da2824a814610223578063f2a40db81461027d5761009a565b806306661abd1461009f5780630a3b0a4f146100bd5780633ef2501314610117575b600080fd5b6100a76102d5565b6040518082815260200191505060405180910390f35b6100ff600480360360208110156100d357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506102db565b60405180821515815260200191505060405180910390f35b6101596004803603602081101561012d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061048c565b60405180821515815260200191505060405180910390f35b6101b36004803603602081101561018757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104d7565b6040518082815260200191505060405180910390f35b61020b600480360360208110156101df57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b6102656004803603602081101561023957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506105a3565b60405180821515815260200191505060405180910390f35b6102a96004803603602081101561029357600080fd5b8101908080359060200190929190505050610660565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60025481565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661033357600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461037f57600080fd5b6000829080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600254600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506002600081548092919060010191905055506001600254038273ffffffffffffffffffffffffffffffffffffffff167f5ed3bdd47b9af629827a8d129aa39c870b10c03f0153fe9ddb8e84b665061acd60405160405180910390a360019050919050565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60016020528060005260406000206000915090505481565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461054b57600080fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105ff57600080fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000818154811061066d57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff168156fea264697066735822122015b8d8e75596c6a573f6b345fd0d9e2ce7cb2ae5be362ccbe8e60c1db0871c3f64736f6c637827302e362e31322d646576656c6f702e323032312e312e382b636f6d6d69742e32376435313736350058 -\ No newline at end of file +608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600281905550610d4b806100cb6000396000f3fe608060405234801561001057600080fd5b50600436106100d1576000357c01000000000000000000000000000000000000000000000000000000009004806379ba50971161008e57806379ba5097146101d25780638da5cb5b146101f0578063da2824a81461020e578063e0db665b1461023e578063e2095c071461026e578063f2fde38b1461029e576100d1565b806301ffc9a7146100d657806306661abd146101065780630a3b0a4f146101245780630cbb0f83146101545780633ef25013146101725780635ae06f7e146101a2575b600080fd5b6100f060048036038101906100eb9190610ae0565b6102ce565b6040516100fd9190610b7a565b60405180910390f35b61010e610426565b60405161011b9190610b95565b60405180910390f35b61013e60048036038101906101399190610ab7565b61042c565b60405161014b9190610b7a565b60405180910390f35b61015c6105ec565b6040516101699190610b95565b60405180910390f35b61018c60048036038101906101879190610ab7565b6105f6565b6040516101999190610b7a565b60405180910390f35b6101bc60048036038101906101b79190610ab7565b610641565b6040516101c99190610b7a565b60405180910390f35b6101da6106f5565b6040516101e79190610b7a565b60405180910390f35b6101f861089c565b6040516102059190610b5f565b60405180910390f35b61022860048036038101906102239190610ab7565b6108c2565b6040516102359190610b7a565b60405180910390f35b61025860048036038101906102539190610ab7565b61097f565b6040516102659190610b95565b60405180910390f35b61028860048036038101906102839190610b09565b610997565b6040516102959190610b5f565b60405180910390f35b6102b860048036038101906102b39190610ab7565b6109d6565b6040516102c59190610b7a565b60405180910390f35b600063cbdb05c77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156103235760019050610421565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156103765760019050610421565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156103c95760019050610421565b6337a47be47c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561041c5760019050610421565b600090505b919050565b60025481565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661048457600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146104d057600080fd5b6000829080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600254600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506002600081548092919061058c90610c58565b919050555060016002546105a09190610bb0565b8273ffffffffffffffffffffffffffffffffffffffff167f5ed3bdd47b9af629827a8d129aa39c870b10c03f0153fe9ddb8e84b665061acd60405160405180910390a360019050919050565b6000600254905090565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461069d57600080fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461075257600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461091e57600080fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60016020528060005260406000206000915090505481565b600081815481106109a757600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a3257600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b600081359050610a8781610cd0565b92915050565b600081359050610a9c81610ce7565b92915050565b600081359050610ab181610cfe565b92915050565b600060208284031215610ac957600080fd5b6000610ad784828501610a78565b91505092915050565b600060208284031215610af257600080fd5b6000610b0084828501610a8d565b91505092915050565b600060208284031215610b1b57600080fd5b6000610b2984828501610aa2565b91505092915050565b610b3b81610be4565b82525050565b610b4a81610bf6565b82525050565b610b5981610c4e565b82525050565b6000602082019050610b746000830184610b32565b92915050565b6000602082019050610b8f6000830184610b41565b92915050565b6000602082019050610baa6000830184610b50565b92915050565b6000610bbb82610c4e565b9150610bc683610c4e565b925082821015610bd957610bd8610ca1565b5b828203905092915050565b6000610bef82610c2e565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610c6382610c4e565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610c9657610c95610ca1565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b610cd981610be4565b8114610ce457600080fd5b50565b610cf081610c02565b8114610cfb57600080fd5b50565b610d0781610c4e565b8114610d1257600080fd5b5056fea2646970667358221220c56f0a6472d523df4121387f28d200b09cbfd10338652250ac97b823e729ed2c64736f6c63430008030033 +\ No newline at end of file diff --git a/python/eth_accounts_index/data/AccountsIndex.json b/python/eth_accounts_index/data/AccountsIndex.json @@ -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"}] diff --git a/python/tests/test_app.py b/python/tests/test_app.py @@ -44,7 +44,7 @@ class Test(EthTesterCase): def setUp(self): super(Test, self).setUp() 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]) self.conn = RPCConnection.connect(self.chain_spec, 'default') r = self.conn.do(o) diff --git a/solidity/AccountsIndex.bin b/solidity/AccountsIndex.bin @@ -1 +0,0 @@ -608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060016002819055506106f7806100cb6000396000f3fe608060405234801561001057600080fd5b506004361061009a576000357c0100000000000000000000000000000000000000000000000000000000900480634c2ebc6b116100785780634c2ebc6b146101715780635ae06f7e146101c9578063da2824a814610223578063f2a40db81461027d5761009a565b806306661abd1461009f5780630a3b0a4f146100bd5780633ef2501314610117575b600080fd5b6100a76102d5565b6040518082815260200191505060405180910390f35b6100ff600480360360208110156100d357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506102db565b60405180821515815260200191505060405180910390f35b6101596004803603602081101561012d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061048c565b60405180821515815260200191505060405180910390f35b6101b36004803603602081101561018757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104d7565b6040518082815260200191505060405180910390f35b61020b600480360360208110156101df57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b6102656004803603602081101561023957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506105a3565b60405180821515815260200191505060405180910390f35b6102a96004803603602081101561029357600080fd5b8101908080359060200190929190505050610660565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60025481565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661033357600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461037f57600080fd5b6000829080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600254600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506002600081548092919060010191905055506001600254038273ffffffffffffffffffffffffffffffffffffffff167f5ed3bdd47b9af629827a8d129aa39c870b10c03f0153fe9ddb8e84b665061acd60405160405180910390a360019050919050565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60016020528060005260406000206000915090505481565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461054b57600080fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105ff57600080fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000818154811061066d57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff168156fea264697066735822122015b8d8e75596c6a573f6b345fd0d9e2ce7cb2ae5be362ccbe8e60c1db0871c3f64736f6c637827302e362e31322d646576656c6f702e323032312e312e382b636f6d6d69742e32376435313736350058 -\ No newline at end of file diff --git a/solidity/AccountsIndex.json b/solidity/AccountsIndex.json @@ -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"}] diff --git a/solidity/AccountsIndex.sol b/solidity/AccountsIndex.sol @@ -4,17 +4,19 @@ pragma solidity >0.6.11; contract CustodialAccountIndex { - address[] public accounts; - mapping(address => uint256) public accountsIndex; + address[] public entry; + mapping(address => uint256) public entryIndex; uint256 public count; 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 { owner = msg.sender; - accounts.push(address(0)); + entry.push(address(0)); count = 1; } @@ -32,15 +34,50 @@ contract CustodialAccountIndex { function add(address _account) external returns (bool) { require(writers[msg.sender]); - require(accountsIndex[_account] == 0); - accounts.push(_account); - accountsIndex[_account] = count; + require(entryIndex[_account] == 0); + entry.push(_account); + entryIndex[_account] = count; count++; emit AccountAdded(_account, count-1); return true; } 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; } }