accounts-index

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

commit 2579abaf3fa5cac099ce7fd85ac070633c5fe374
parent 69fe24e593068f6ea4795f36ab91f79790d03b2e
Author: lash <dev@holbrook.no>
Date:   Sun, 12 Feb 2023 05:47:47 +0000

Differentiate between deactivate and remove in smart contract, reinstate indexed list

Diffstat:
Mpython/CHANGELOG | 1+
Mpython/eth_accounts_index/data/AccountsIndex.bin | 4++--
Mpython/eth_accounts_index/data/AccountsIndex.json | 2+-
Mpython/eth_accounts_index/runnable/add.py | 78++++++++++++++++++++++++++++++++++++++++++++++++------------------------------
Mpython/eth_accounts_index/runnable/list.py | 71++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
Mpython/eth_accounts_index/runnable/publish.py | 57+++++++++++++++++++++++++++++++++++++--------------------
Dpython/eth_accounts_index/runnable/writer.py | 86-------------------------------------------------------------------------------
Mpython/setup.cfg | 1-
Msolidity/AccountsIndex.sol | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
9 files changed, 202 insertions(+), 177 deletions(-)

diff --git a/python/CHANGELOG b/python/CHANGELOG @@ -1,5 +1,6 @@ * 0.3.3 - Rename cli script from deploy to publish + - Refactor cli scripts to use current chainlib setup * 0.3.2 - Add remove option * 0.3.0 diff --git a/python/eth_accounts_index/data/AccountsIndex.bin b/python/eth_accounts_index/data/AccountsIndex.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b5033600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610d5b806100616000396000f3fe608060405234801561001057600080fd5b50600436106100c6576000357c0100000000000000000000000000000000000000000000000000000000900480635ae06f7e1161008e5780635ae06f7e146101a957806379ba5097146101d95780638da5cb5b146101f7578063da2824a814610215578063e0db665b14610245578063f2fde38b14610275576100c6565b806301ffc9a7146100cb5780630a3b0a4f146100fb5780630cbb0f831461012b57806329092d0e146101495780633ef2501314610179575b600080fd5b6100e560048036038101906100e09190610b42565b6102a5565b6040516100f29190610b8a565b60405180910390f35b61011560048036038101906101109190610c03565b61044b565b6040516101229190610b8a565b60405180910390f35b610133610595565b6040516101409190610c49565b60405180910390f35b610163600480360381019061015e9190610c03565b61059b565b6040516101709190610b8a565b60405180910390f35b610193600480360381019061018e9190610c03565b6106a2565b6040516101a09190610b8a565b60405180910390f35b6101c360048036038101906101be9190610c03565b6106ed565b6040516101d09190610b8a565b60405180910390f35b6101e16107a1565b6040516101ee9190610b8a565b60405180910390f35b6101ff610948565b60405161020c9190610c73565b60405180910390f35b61022f600480360381019061022a9190610c03565b61096e565b60405161023c9190610b8a565b60405180910390f35b61025f600480360381019061025a9190610c03565b610a2b565b60405161026c9190610c49565b60405180910390f35b61028f600480360381019061028a9190610c03565b610a43565b60405161029c9190610b8a565b60405180910390f35b600063cbdb05c77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102f95760019050610446565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361034b5760019050610446565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361039d5760019050610446565b6337a47be47c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036103ef5760019050610446565b6380c84bd67c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104415760019050610446565b600090505b919050565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166104a357600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146104ef57600080fd5b42600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060016000546105429190610cbd565b600081905550428273ffffffffffffffffffffffffffffffffffffffff167f9cc987676e7d63379f176ea50df0ae8d2d9d1141d1231d4ce15b5965f73c943060405160405180910390a360019050919050565b60005481565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166105f357600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541161063f57600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060016000546106939190610cf1565b60008190555060019050919050565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461074957600080fd5b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b600080600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146107fe57600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109ca57600080fd5b6001600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60016020528060005260406000206000915090505481565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a9f57600080fd5b81600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610b1f81610aea565b8114610b2a57600080fd5b50565b600081359050610b3c81610b16565b92915050565b600060208284031215610b5857610b57610ae5565b5b6000610b6684828501610b2d565b91505092915050565b60008115159050919050565b610b8481610b6f565b82525050565b6000602082019050610b9f6000830184610b7b565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610bd082610ba5565b9050919050565b610be081610bc5565b8114610beb57600080fd5b50565b600081359050610bfd81610bd7565b92915050565b600060208284031215610c1957610c18610ae5565b5b6000610c2784828501610bee565b91505092915050565b6000819050919050565b610c4381610c30565b82525050565b6000602082019050610c5e6000830184610c3a565b92915050565b610c6d81610bc5565b82525050565b6000602082019050610c886000830184610c64565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610cc882610c30565b9150610cd383610c30565b9250828201905080821115610ceb57610cea610c8e565b5b92915050565b6000610cfc82610c30565b9150610d0783610c30565b9250828203905081811115610d1f57610d1e610c8e565b5b9291505056fea264697066735822122060f30e498959b8c3252850982d3f5cabfd6da86504a40fee4fac988889cae30164736f6c63430008120033 -\ No newline at end of file +608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061151a806100c56000396000f3fe608060405234801561001057600080fd5b5060043610610107576000357c0100000000000000000000000000000000000000000000000000000000900480635ae06f7e116100a9578063da2824a811610083578063da2824a8146102c8578063e0db665b146102f8578063e2095c0714610328578063f2fde38b1461035857610107565b80635ae06f7e1461024a5780638da5cb5b1461027a5780639f8a13d71461029857610107565b80631c5a9d9c116100e55780631c5a9d9c1461018a57806329092d0e146101ba5780633ea053eb146101ea5780633ef250131461021a57610107565b806301ffc9a71461010c5780630a3b0a4f1461013c5780630cbb0f831461016c575b600080fd5b6101266004803603810190610121919061119e565b610388565b60405161013391906111e6565b60405180910390f35b6101566004803603810190610151919061125f565b6104dc565b60405161016391906111e6565b60405180910390f35b6101746106f6565b60405161018191906112af565b60405180910390f35b6101a4600480360381019061019f919061125f565b61070e565b6040516101b191906111e6565b60405180910390f35b6101d460048036038101906101cf919061125f565b6108b1565b6040516101e191906111e6565b60405180910390f35b61020460048036038101906101ff919061125f565b610a6f565b60405161021191906111e6565b60405180910390f35b610234600480360381019061022f919061125f565b610c64565b60405161024191906111e6565b60405180910390f35b610264600480360381019061025f919061125f565b610caf565b60405161027191906111e6565b60405180910390f35b610282610d63565b60405161028f91906112d9565b60405180910390f35b6102b260048036038101906102ad919061125f565b610d89565b6040516102bf91906111e6565b60405180910390f35b6102e260048036038101906102dd919061125f565b610e7c565b6040516102ef91906111e6565b60405180910390f35b610312600480360381019061030d919061125f565b610f39565b60405161031f919061130d565b60405180910390f35b610342600480360381019061033d9190611354565b610f51565b60405161034f91906112d9565b60405180910390f35b610372600480360381019061036d919061125f565b610ffc565b60405161037f91906111e6565b60405180910390f35b600063cbdb05c77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036103dc57600190506104d7565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361042e57600190506104d7565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361048057600190506104d7565b6380c84bd67c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104d257600190506104d7565b600090505b919050565b600080600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661053557600080fd5b6000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461058157600080fd5b700100000000000000000000000000000000600180549050106105a357600080fd5b60018054905090506001839080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060016000808282829054906101000a900467ffffffffffffffff1661067791906113b0565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550803373ffffffffffffffffffffffffffffffffffffffff167f236dcd75b06b7c701a8061d7978d8131ca139a814b90c45d7c6a9467482ee796856040516106e491906112d9565b60405180910390a36001915050919050565b60008054906101000a900467ffffffffffffffff1681565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661076657600080fd5b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180156107fe57506801000000000000000080600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205416145b61080757600080fd5b6041600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254908060020a8204915050925050819055503373ffffffffffffffffffffffffffffffffffffffff167fa27913ebf7f29594798a64cfe7cabb550ef9670075e217c2f4c1e532a899baea836040516108a491906112d9565b60405180910390a2919050565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168061093657508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61093f57600080fd5b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541161098b57600080fd5b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600160008054906101000a900467ffffffffffffffff166109f191906113ec565b6000806101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055503373ffffffffffffffffffffffffffffffffffffffff167f14c03038f91513ea128893e8d0865b80359ca07b96f819269baebe06732bb4ad83604051610a5e91906112d9565b60405180910390a260019050919050565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610ac757600080fd5b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118015610b605750600068010000000000000000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205416145b610b6957600080fd5b6041600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282549060020a029250508190555068010000000000000000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825417925050819055503373ffffffffffffffffffffffffffffffffffffffff167f5e0504df353b1d59607f86d088afd2819ce3e6013ba1bbdb1dd9072ea3b30d4583604051610c5791906112d9565b60405180910390a2919050565b600080600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d0b57600080fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003073ffffffffffffffffffffffffffffffffffffffff16633ef25013836040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610de091906112d9565b602060405180830381865afa158015610dfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e219190611454565b8015610e75575068010000000000000000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b9050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ed857600080fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60026020528060005260406000206000915090505481565b60008060018084610f629190611481565b81548110610f7357610f726114b5565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610ff15780915050610ff7565b60009150505b919050565b600080600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461105957600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905082600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61117b81611146565b811461118657600080fd5b50565b60008135905061119881611172565b92915050565b6000602082840312156111b4576111b3611141565b5b60006111c284828501611189565b91505092915050565b60008115159050919050565b6111e0816111cb565b82525050565b60006020820190506111fb60008301846111d7565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061122c82611201565b9050919050565b61123c81611221565b811461124757600080fd5b50565b60008135905061125981611233565b92915050565b60006020828403121561127557611274611141565b5b60006112838482850161124a565b91505092915050565b600067ffffffffffffffff82169050919050565b6112a98161128c565b82525050565b60006020820190506112c460008301846112a0565b92915050565b6112d381611221565b82525050565b60006020820190506112ee60008301846112ca565b92915050565b6000819050919050565b611307816112f4565b82525050565b600060208201905061132260008301846112fe565b92915050565b611331816112f4565b811461133c57600080fd5b50565b60008135905061134e81611328565b92915050565b60006020828403121561136a57611369611141565b5b60006113788482850161133f565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006113bb8261128c565b91506113c68361128c565b9250828201905067ffffffffffffffff8111156113e6576113e5611381565b5b92915050565b60006113f78261128c565b91506114028361128c565b9250828203905067ffffffffffffffff81111561142257611421611381565b5b92915050565b611431816111cb565b811461143c57600080fd5b50565b60008151905061144e81611428565b92915050565b60006020828403121561146a57611469611141565b5b60006114788482850161143f565b91505092915050565b600061148c826112f4565b9150611497836112f4565b92508282019050808211156114af576114ae611381565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfea26469706673582212205b46ef32f225583b891fe552ec57ef96b8e14fd624278da6aab866396ce2d27564736f6c63430008110033 +\ 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":"AddressAdded","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":[{"internalType":"address","name":"_writer","type":"address"}],"name":"deleteWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"entryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"address","name":"_account","type":"address"}],"name":"remove","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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"}] +[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressActive","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":true,"internalType":"uint256","name":"_accountIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressInactive","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_executor","type":"address"},{"indexed":false,"internalType":"address","name":"_account","type":"address"}],"name":"AddressRemoved","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":[{"internalType":"address","name":"_account","type":"address"}],"name":"activate","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":[{"internalType":"address","name":"_account","type":"address"}],"name":"deactivate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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":"_idx","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"entryCount","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","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":[{"internalType":"address","name":"_account","type":"address"}],"name":"isActive","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":"address","name":"_account","type":"address"}],"name":"remove","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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/eth_accounts_index/runnable/add.py b/python/eth_accounts_index/runnable/add.py @@ -18,6 +18,18 @@ from chainlib.chain import ChainSpec from chainlib.eth.connection import EthHTTPConnection from chainlib.eth.tx import receipt from chainlib.eth.address import to_checksum_address +from chainlib.eth.cli.arg import ( + Arg, + ArgFlag, + process_args, + ) +from chainlib.eth.cli.config import ( + Config, + process_config, + ) +from chainlib.eth.cli.log import process_log +from chainlib.eth.settings import process_settings +from chainlib.settings import ChainSettings # local imports from eth_accounts_index.registry import AccountRegistry @@ -25,46 +37,52 @@ from eth_accounts_index.registry import AccountRegistry logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() -arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.EXEC -argparser = chainlib.eth.cli.ArgumentParser(arg_flags) -argparser.add_positional('address', type=str, help='Address to add to registry') -args = argparser.parse_args() - -extra_args = { - 'address': None, - } -config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=AccountRegistry.gas()) - -wallet = chainlib.eth.cli.Wallet() -wallet.from_config(config) -rpc = chainlib.eth.cli.Rpc(wallet=wallet) -conn = rpc.connect_by_config(config) +def process_config_local(config, arg, args, flags): + address = to_checksum_address(config.get('_POSARG')) + config.add(address, '_ADDRESS') + return config -chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC')) +arg_flags = ArgFlag() +arg = Arg(arg_flags) +flags = arg_flags.STD_WRITE | arg_flags.EXEC -def main(): - signer = rpc.get_signer() - signer_address = rpc.get_sender_address() +argparser = chainlib.eth.cli.ArgumentParser() +argparser = process_args(argparser, arg, flags) +argparser.add_argument('address', type=str, help='Address to add to registry') +args = argparser.parse_args() - gas_oracle = rpc.get_gas_oracle() - nonce_oracle = rpc.get_nonce_oracle() +logg = process_log(args, logg) - subject_address = to_checksum_address(config.get('_ADDRESS')) - if not config.true('_UNSAFE') and subject_address != add_0x(config.get('_ADDRESS')): - raise ValueError('invalid checksum address for subject_address') +config = Config() +config = process_config(config, arg, args, flags, positional_name='address') +config = process_config_local(config, arg, args, flags) +logg.debug('config loaded:\n{}'.format(config)) - contract_address = to_checksum_address(config.get('_EXEC_ADDRESS')) - if not config.true('_UNSAFE') and contract_address != add_0x(config.get('_EXEC_ADDRESS')): - raise ValueError('invalid checksum address for contract') +settings = ChainSettings() +settings = process_settings(settings, config) +logg.debug('settings loaded:\n{}'.format(settings)) - c = AccountRegistry(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.add(contract_address, signer_address, subject_address) - if config.get('_RPC_SEND'): +def main(): + conn = settings.get('CONN') + c = AccountRegistry( + settings.get('CHAIN_SPEC'), + signer=settings.get('SIGNER'), + gas_oracle=settings.get('FEE_ORACLE'), + nonce_oracle=settings.get('NONCE_ORACLE'), + ) + + (tx_hash_hex, o) = c.add( + settings.get('EXEC'), + settings.get('SENDER_ADDRESS'), + config.get('_ADDRESS'), + ) + + if settings.get('RPC_SEND'): conn.do(o) - if config.get('_WAIT'): + if config.true('_WAIT'): r = conn.wait(tx_hash_hex) if r['status'] == 0: sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you') diff --git a/python/eth_accounts_index/runnable/list.py b/python/eth_accounts_index/runnable/list.py @@ -19,6 +19,19 @@ from chainlib.eth.connection import EthHTTPConnection from chainlib.eth.tx import receipt from chainlib.eth.constant import ZERO_CONTENT from chainlib.error import JSONRPCException +from chainlib.eth.cli.arg import ( + Arg, + ArgFlag, + process_args, + ) +from chainlib.eth.cli.config import ( + Config, + process_config, + ) +from chainlib.eth.cli.log import process_log +from chainlib.eth.settings import process_settings +from chainlib.settings import ChainSettings +from chainlib.eth.address import to_checksum_address # local imports from eth_accounts_index import AccountsIndex @@ -27,23 +40,34 @@ from eth_accounts_index.registry import AccountRegistry logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() -arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.EXEC -argparser = chainlib.eth.cli.ArgumentParser(arg_flags) -argparser.add_positional('address', required=False, type=str, help='Check only whether given address is in registry') -args = argparser.parse_args() -extra_args = { - 'address': None, - } -config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=AccountRegistry.gas()) +def process_config_local(config, arg, args, flags): + address = config.get('_POSARG') + if address != None: + address = to_checksum_address(address) + config.add(address, '_ADDRESS') + return config + + +arg_flags = ArgFlag() +arg = Arg(arg_flags) +flags = arg_flags.STD_READ | arg_flags.EXEC + +argparser = chainlib.eth.cli.ArgumentParser() +argparser = process_args(argparser, arg, flags) +argparser.add_argument('address', type=str, help='Address to add to registry') +args = argparser.parse_args() -wallet = chainlib.eth.cli.Wallet() -wallet.from_config(config) +logg = process_log(args, logg) -rpc = chainlib.eth.cli.Rpc(wallet=wallet) -conn = rpc.connect_by_config(config) +config = Config() +config = process_config(config, arg, args, flags, positional_name='address') +config = process_config_local(config, arg, args, flags) +logg.debug('config loaded:\n{}'.format(config)) -chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC')) +settings = ChainSettings() +settings = process_settings(settings, config) +logg.debug('settings loaded:\n{}'.format(settings)) def out_element(e, w=sys.stdout): @@ -71,13 +95,26 @@ def ls(ifc, conn, contract_address, w=sys.stdout): def main(): + conn = settings.get('CONN') address = config.get('_ADDRESS') - contract_address = config.get('_EXEC_ADDRESS') - c = AccountsIndex(chain_spec) + c = AccountsIndex( + settings.get('CHAIN_SPEC') + ) if address != None: - element(c, conn, contract_address, address, w=sys.stdout) + element( + c, + conn, + settings.get('EXEC'), + address, + w=sys.stdout, + ) else: - ls(c, conn, contract_address, w=sys.stdout) + ls( + c, + conn, + settings.get('EXEC'), + w=sys.stdout, + ) if __name__ == '__main__': diff --git a/python/eth_accounts_index/runnable/publish.py b/python/eth_accounts_index/runnable/publish.py @@ -8,8 +8,6 @@ # standard imports import sys import os -import json -import argparse import logging # external imports @@ -17,6 +15,18 @@ import chainlib.eth.cli from chainlib.chain import ChainSpec from chainlib.eth.connection import EthHTTPConnection from chainlib.eth.tx import receipt +from chainlib.eth.cli.arg import ( + Arg, + ArgFlag, + process_args, + ) +from chainlib.eth.cli.config import ( + Config, + process_config, + ) +from chainlib.eth.cli.log import process_log +from chainlib.eth.settings import process_settings +from chainlib.settings import ChainSettings # local imports from eth_accounts_index.registry import AccountRegistry @@ -24,35 +34,42 @@ from eth_accounts_index.registry import AccountRegistry logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() -arg_flags = chainlib.eth.cli.argflag_std_write -argparser = chainlib.eth.cli.ArgumentParser(arg_flags) -args = argparser.parse_args() +arg_flags = ArgFlag() +arg = Arg(arg_flags) +flags = arg_flags.STD_WRITE -config = chainlib.eth.cli.Config.from_args(args, arg_flags, default_fee_limit=AccountRegistry.gas()) +argparser = chainlib.eth.cli.ArgumentParser() +argparser = process_args(argparser, arg, flags) +args = argparser.parse_args() -wallet = chainlib.eth.cli.Wallet() -wallet.from_config(config) +logg = process_log(args, logg) -rpc = chainlib.eth.cli.Rpc(wallet=wallet) -conn = rpc.connect_by_config(config) +config = Config() +config = process_config(config, arg, args, flags) +logg.debug('config loaded:\n{}'.format(config)) -chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC')) +settings = ChainSettings() +settings = process_settings(settings, config) +logg.debug('settings loaded:\n{}'.format(settings)) def main(): - signer = rpc.get_signer() - signer_address = rpc.get_sender_address() - - gas_oracle = rpc.get_gas_oracle() - nonce_oracle = rpc.get_nonce_oracle() + conn = settings.get('CONN') - c = AccountRegistry(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle) + c = AccountRegistry( + settings.get('CHAIN_SPEC'), + signer=settings.get('SIGNER'), + gas_oracle=settings.get('FEE_ORACLE'), + nonce_oracle=settings.get('NONCE_ORACLE'), + ) - (tx_hash_hex, o) = c.constructor(signer_address) + (tx_hash_hex, o) = c.constructor( + settings.get('SENDER_ADDRESS'), + ) - if config.get('_RPC_SEND'): + if settings.get('RPC_SEND'): conn.do(o) - if config.get('_WAIT'): + if config.true('_WAIT'): r = conn.wait(tx_hash_hex) if r['status'] == 0: sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you') diff --git a/python/eth_accounts_index/runnable/writer.py b/python/eth_accounts_index/runnable/writer.py @@ -1,86 +0,0 @@ -"""Adds/removes writers to accounts index - -.. moduleauthor:: Louis Holbrook <dev@holbrook.no> -.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 - -""" - -# standard imports -import os -import json -import argparse -import logging -import sys - -# external imports -import chainlib.eth.cli -from chainlib.chain import ChainSpec -from chainlib.eth.connection import EthHTTPConnection -from chainlib.eth.tx import receipt -from chainlib.eth.address import to_checksum_address -from hexathon import add_0x - -# local imports -from eth_accounts_index.registry import AccountRegistry - -logging.basicConfig(level=logging.WARNING) -logg = logging.getLogger() - -arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.EXEC -argparser = chainlib.eth.cli.ArgumentParser(arg_flags) -argparser.add_argument('--rm', action='store_true', help='Delete entry') -argparser.add_positional('address', type=str, help='Update writer array with this address') -args = argparser.parse_args() - -extra_args = { - 'rm': None, - 'address': None, - } -config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=AccountRegistry.gas()) - -wallet = chainlib.eth.cli.Wallet() -wallet.from_config(config) - -rpc = chainlib.eth.cli.Rpc(wallet=wallet) -conn = rpc.connect_by_config(config) - -chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC')) - - -def main(): - signer = rpc.get_signer() - signer_address = rpc.get_sender_address() - - gas_oracle = rpc.get_gas_oracle() - nonce_oracle = rpc.get_nonce_oracle() - - c = AccountRegistry(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle) - - subject_address = to_checksum_address(config.get('_ADDRESS')) - if not config.true('_UNSAFE') and subject_address != add_0x(config.get('_ADDRESS')): - raise ValueError('invalid checksum address for subject_address') - - - contract_address = to_checksum_address(config.get('_EXEC_ADDRESS')) - if not config.true('_UNSAFE') and contract_address != add_0x(config.get('_EXEC_ADDRESS')): - raise ValueError('invalid checksum address for contract') - - if config.get('_RM'): - (tx_hash_hex, o) = c.delete_writer(contract_address, signer_address, subject_address) - else: - (tx_hash_hex, o) = c.add_writer(contract_address, signer_address, subject_address) - if config.get('_RPC_SEND'): - conn.do(o) - if config.get('_WAIT'): - r = conn.wait(tx_hash_hex) - if r['status'] == 0: - sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you') - sys.exit(1) - - print(tx_hash_hex) - else: - print(o) - - -if __name__ == '__main__': - main() diff --git a/python/setup.cfg b/python/setup.cfg @@ -42,5 +42,4 @@ testing = console_scripts = eth-accounts-index-publish = eth_accounts_index.runnable.publish:main eth-accounts-index-add = eth_accounts_index.runnable.add:main - eth-accounts-index-writer = eth_accounts_index.runnable.writer:main eth-accounts-index-list = eth_accounts_index.runnable.list:main diff --git a/solidity/AccountsIndex.sol b/solidity/AccountsIndex.sol @@ -1,21 +1,27 @@ -pragma solidity >0.6.11; +pragma solidity >0.6.12; // SPDX-License-Identifier: GPL-3.0-or-later -// File-Version: 1 +// File-Version: 2 contract CustodialAccountIndex { - uint256 public entryCount; + uint256 constant blockedField = 1 << 64; + uint64 public entryCount; + address[] entryList; mapping(address => uint256) public entryIndex; mapping(address => bool) writers; address public owner; address newOwner; - event AddressAdded(address indexed addedAccount, uint256 indexed accountIndex); // AccountsIndex + event AddressAdded(address indexed _executor, uint256 indexed _accountIndex, address _account); // AccountsIndex + event AddressActive(address indexed _executor, address _account); + event AddressInactive(address indexed _executor, address _account); + event AddressRemoved(address indexed _executor, address _account); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173 constructor() public { owner = msg.sender; + entryList.push(address(0)); } function addWriter(address _writer) public returns (bool) { @@ -32,20 +38,46 @@ contract CustodialAccountIndex { // Implements AccountsIndex function add(address _account) external returns (bool) { + uint256 i; + require(writers[msg.sender]); require(entryIndex[_account] == 0); - entryIndex[_account] = block.timestamp; - entryCount = entryCount + 1; - emit AddressAdded(_account, block.timestamp); + require(entryList.length < (1 << 128)); + i = entryList.length; + entryList.push(_account); + entryIndex[_account] = i; + entryCount += 1; + emit AddressAdded(msg.sender, i, _account); return true; } // Implements AccountsIndex - function remove(address _account) external returns (bool) { + // Deactivate account, without removing the entry. The entry will still be part of the entry count. + function deactivate(address _account) external returns (bool) { + require(writers[msg.sender]); + require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == 0); + entryIndex[_account] <<= 65; + entryIndex[_account] |= blockedField; + emit AddressInactive(msg.sender, _account); + } + + // Implements AccountsIndex + // Activate previously deactivated account. Will not affect the entry count. + function activate(address _account) external returns (bool) { require(writers[msg.sender]); + require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == blockedField); + entryIndex[_account] >>= 65; + emit AddressActive(msg.sender, _account); + } + + // Implements AccountsIndex + // (An account can remove itself). + function remove(address _account) external returns (bool) { + require(writers[msg.sender] || msg.sender == _account); require(entryIndex[_account] > 0); entryIndex[_account] = 0; entryCount = entryCount - 1; + emit AddressRemoved(msg.sender, _account); return true; } @@ -54,23 +86,33 @@ contract CustodialAccountIndex { return entryIndex[_account] > 0; } + // Implements AccountsIndex + function isActive(address _account) external view returns (bool) { + return this.have(_account) && entryIndex[_account] != blockedField; + } + // Implements EIP173 function transferOwnership(address _newOwner) public returns (bool) { + address oldOwner; require(msg.sender == owner); - newOwner = _newOwner; - } - // Implements OwnedAccepter - function acceptOwnership() public returns (bool) { - address oldOwner; + oldOwner = owner; + owner = _newOwner; - require(msg.sender == newOwner); - oldOwner = owner; - owner = newOwner; - newOwner = address(0); emit OwnershipTransferred(oldOwner, owner); } + // Implements AccountsIndex + function entry(uint256 _idx) public returns(address) { + address r; + + r = entryList[_idx + 1]; + if (entryIndex[r] > 0) { + return r; + } + return address(0); + } + // Implements EIP165 function supportsInterface(bytes4 _sum) public pure returns (bool) { if (_sum == 0xcbdb05c7) { // AccountsIndex @@ -82,9 +124,6 @@ contract CustodialAccountIndex { if (_sum == 0x9493f8b2) { // EIP173 return true; } - if (_sum == 0x37a47be4) { // OwnedAccepter - return true; - } if (_sum == 0x80c84bd6) { // Writer return true; }