eth-accounts-index

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

commit 9a8fb621131b3f80b1e47fafba7a1f2f0416e7de
parent a30614efede626c82e0d03d68c5caaa98ca29fcc
Author: lash <dev@holbrook.no>
Date:   Sun, 12 Feb 2023 07:51:58 +0000

Add time added

Diffstat:
Mpython/CHANGELOG | 2++
Mpython/eth_accounts_index/data/AccountsIndex.bin | 4++--
Mpython/eth_accounts_index/data/AccountsIndex.json | 2+-
Mpython/eth_accounts_index/interface.py | 22+++++++++++++++++++++-
Mpython/setup.cfg | 2+-
Mpython/setup.py | 7-------
Mpython/tests/test_app.py | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msolidity/AccountsIndex.sol | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
8 files changed, 156 insertions(+), 28 deletions(-)

diff --git a/python/CHANGELOG b/python/CHANGELOG @@ -1,6 +1,8 @@ * 0.3.3 - Rename cli script from deploy to publish - Refactor cli scripts to use current chainlib setup + - Add time added entry + - Add activate and deactivate option * 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 @@ -608060405234801561001057600080fd5b5033600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611108806100616000396000f3fe608060405234801561001057600080fd5b50600436106100ec576000357c0100000000000000000000000000000000000000000000000000000000900480635ae06f7e116100a9578063da2824a811610083578063da2824a81461027d578063e0db665b146102ad578063e2095c07146102dd578063f2fde38b1461030d576100ec565b80635ae06f7e146101ff5780638da5cb5b1461022f5780639f8a13d71461024d576100ec565b806301ffc9a7146100f15780630a3b0a4f146101215780630cbb0f83146101515780631c5a9d9c1461016f5780633ea053eb1461019f5780633ef25013146101cf575b600080fd5b61010b60048036038101906101069190610ed4565b61033d565b6040516101189190610f1c565b60405180910390f35b61013b60048036038101906101369190610f95565b610491565b6040516101489190610f1c565b60405180910390f35b610159610660565b6040516101669190610fdb565b60405180910390f35b61018960048036038101906101849190610f95565b61066c565b6040516101969190610f1c565b60405180910390f35b6101b960048036038101906101b49190610f95565b61080f565b6040516101c69190610f1c565b60405180910390f35b6101e960048036038101906101e49190610f95565b610a04565b6040516101f69190610f1c565b60405180910390f35b61021960048036038101906102149190610f95565b610a4f565b6040516102269190610f1c565b60405180910390f35b610237610b03565b6040516102449190611005565b60405180910390f35b61026760048036038101906102629190610f95565b610b29565b6040516102749190610f1c565b60405180910390f35b61029760048036038101906102929190610f95565b610c1e565b6040516102a49190610f1c565b60405180910390f35b6102c760048036038101906102c29190610f95565b610cdb565b6040516102d49190610fdb565b60405180910390f35b6102f760048036038101906102f2919061104c565b610cf3565b6040516103049190611005565b60405180910390f35b61032760048036038101906103229190610f95565b610d32565b6040516103349190610f1c565b60405180910390f35b600063cbdb05c77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610391576001905061048c565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036103e3576001905061048c565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610435576001905061048c565b6380c84bd67c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610487576001905061048c565b600090505b919050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166104ea57600080fd5b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461053657600080fd5b7001000000000000000000000000000000006000805490501061055857600080fd5b60008054905090506000839080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550803373ffffffffffffffffffffffffffffffffffffffff167f236dcd75b06b7c701a8061d7978d8131ca139a814b90c45d7c6a9467482ee7968560405161064e9190611005565b60405180910390a36001915050919050565b60008080549050905090565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166106c457600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411801561075c57506801000000000000000080600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205416145b61076557600080fd5b6041600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254908060020a8204915050925050819055503373ffffffffffffffffffffffffffffffffffffffff167fa27913ebf7f29594798a64cfe7cabb550ef9670075e217c2f4c1e532a899baea836040516108029190611005565b60405180910390a2919050565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661086757600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180156109005750600068010000000000000000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205416145b61090957600080fd5b6041600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282549060020a029250508190555068010000000000000000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825417925050819055503373ffffffffffffffffffffffffffffffffffffffff167f5e0504df353b1d59607f86d088afd2819ce3e6013ba1bbdb1dd9072ea3b30d45836040516109f79190611005565b60405180910390a2919050565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610aab57600080fd5b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003073ffffffffffffffffffffffffffffffffffffffff16633ef25013836040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610b809190611005565b602060405180830381865afa158015610b9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc191906110a5565b8015610c1757506801000000000000000080600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541614155b9050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c7a57600080fd5b6001600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60016020528060005260406000206000915090505481565b60008181548110610d0357600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d8f57600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905082600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610eb181610e7c565b8114610ebc57600080fd5b50565b600081359050610ece81610ea8565b92915050565b600060208284031215610eea57610ee9610e77565b5b6000610ef884828501610ebf565b91505092915050565b60008115159050919050565b610f1681610f01565b82525050565b6000602082019050610f316000830184610f0d565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610f6282610f37565b9050919050565b610f7281610f57565b8114610f7d57600080fd5b50565b600081359050610f8f81610f69565b92915050565b600060208284031215610fab57610faa610e77565b5b6000610fb984828501610f80565b91505092915050565b6000819050919050565b610fd581610fc2565b82525050565b6000602082019050610ff06000830184610fcc565b92915050565b610fff81610f57565b82525050565b600060208201905061101a6000830184610ff6565b92915050565b61102981610fc2565b811461103457600080fd5b50565b60008135905061104681611020565b92915050565b60006020828403121561106257611061610e77565b5b600061107084828501611037565b91505092915050565b61108281610f01565b811461108d57600080fd5b50565b60008151905061109f81611079565b92915050565b6000602082840312156110bb576110ba610e77565b5b60006110c984828501611090565b9150509291505056fea26469706673582212209f9d8ccc0c0479677dcd5270b2cf70eb51f100f7c462f4703c4b57ccf4a3a1e564736f6c63430008110033 -\ No newline at end of file +608060405234801561001057600080fd5b5033600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611654806100c36000396000f3fe608060405234801561001057600080fd5b5060043610610112576000357c0100000000000000000000000000000000000000000000000000000000900480635ae06f7e116100b4578063da2824a811610083578063da2824a814610303578063e0db665b14610333578063e2095c0714610363578063f2fde38b1461039357610112565b80635ae06f7e146102555780637c67a3e2146102855780638da5cb5b146102b55780639f8a13d7146102d357610112565b80631c5a9d9c116100f05780631c5a9d9c1461019557806329092d0e146101c55780633ea053eb146101f55780633ef250131461022557610112565b806301ffc9a7146101175780630a3b0a4f146101475780630cbb0f8314610177575b600080fd5b610131600480360381019061012c919061132b565b6103c3565b60405161013e9190611373565b60405180910390f35b610161600480360381019061015c91906113ec565b610517565b60405161016e9190611373565b60405180910390f35b61017f6106f9565b60405161018c9190611432565b60405180910390f35b6101af60048036038101906101aa91906113ec565b610712565b6040516101bc9190611373565b60405180910390f35b6101df60048036038101906101da91906113ec565b6108bd565b6040516101ec9190611373565b60405180910390f35b61020f600480360381019061020a91906113ec565b610b96565b60405161021c9190611373565b60405180910390f35b61023f600480360381019061023a91906113ec565b610d9f565b60405161024c9190611373565b60405180910390f35b61026f600480360381019061026a91906113ec565b610dea565b60405161027c9190611373565b60405180910390f35b61029f600480360381019061029a91906113ec565b610e9e565b6040516102ac9190611432565b60405180910390f35b6102bd610f3e565b6040516102ca919061145c565b60405180910390f35b6102ed60048036038101906102e891906113ec565b610f64565b6040516102fa9190611373565b60405180910390f35b61031d600480360381019061031891906113ec565b611061565b60405161032a9190611373565b60405180910390f35b61034d600480360381019061034891906113ec565b61111e565b60405161035a9190611432565b60405180910390f35b61037d600480360381019061037891906114a3565b611136565b60405161038a919061145c565b60405180910390f35b6103ad60048036038101906103a891906113ec565b611189565b6040516103ba9190611373565b60405180910390f35b600063cbdb05c77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104175760019050610512565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104695760019050610512565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104bb5760019050610512565b6380c84bd67c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361050d5760019050610512565b600090505b919050565b6000806000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661057257600080fd5b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146105be57600080fd5b68010000000000000000600080549050106105d857600080fd5b60008054905091506000849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508167ffffffffffffffff1690506040429060020a028117905080600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167f0e0a4bee74426fd0767a5c0887f18db17207090abad67f13ae982a18a000e3d7856040516106e6919061145c565b60405180910390a2600192505050919050565b6000600160008054905061070d91906114ff565b905090565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661076a57600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411801561080a575070010000000000000000000000000000000080600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205416145b61081357600080fd5b6081600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254908060020a8204915050925050819055503373ffffffffffffffffffffffffffffffffffffffff167fa27913ebf7f29594798a64cfe7cabb550ef9670075e217c2f4c1e532a899baea836040516108b0919061145c565b60405180910390a2919050565b6000806000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661091857600080fd5b3073ffffffffffffffffffffffffffffffffffffffff16633ef25013856040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040161096d919061145c565b602060405180830381865afa15801561098a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ae919061155f565b6109b757600080fd5b60016000805490506109c991906114ff565b9050600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054915080821015610ab15760008181548110610a2957610a2861158c565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660008381548110610a6857610a6761158c565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b6000805480610ac357610ac26115bb565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590556000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167f14c03038f91513ea128893e8d0865b80359ca07b96f819269baebe06732bb4ad85604051610b83919061145c565b60405180910390a2600192505050919050565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610bee57600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118015610c8f57506000700100000000000000000000000000000000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205416145b610c9857600080fd5b6081600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282549060020a0292505081905550700100000000000000000000000000000000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825417925050819055503373ffffffffffffffffffffffffffffffffffffffff167f5e0504df353b1d59607f86d088afd2819ce3e6013ba1bbdb1dd9072ea3b30d4583604051610d8e919061145c565b60405180910390a260019050919050565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e4657600080fd5b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411610eeb57600080fd5b6040600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054908060020a82049150509050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003073ffffffffffffffffffffffffffffffffffffffff16633ef25013836040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610fbb919061145c565b602060405180830381865afa158015610fd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffc919061155f565b801561105a575070010000000000000000000000000000000080600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541614155b9050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110bd57600080fd5b6001600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60016020528060005260406000206000915090505481565b60008060018361114691906115ea565b815481106111575761115661158c565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600080600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146111e657600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905082600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b611308816112d3565b811461131357600080fd5b50565b600081359050611325816112ff565b92915050565b600060208284031215611341576113406112ce565b5b600061134f84828501611316565b91505092915050565b60008115159050919050565b61136d81611358565b82525050565b60006020820190506113886000830184611364565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006113b98261138e565b9050919050565b6113c9816113ae565b81146113d457600080fd5b50565b6000813590506113e6816113c0565b92915050565b600060208284031215611402576114016112ce565b5b6000611410848285016113d7565b91505092915050565b6000819050919050565b61142c81611419565b82525050565b60006020820190506114476000830184611423565b92915050565b611456816113ae565b82525050565b6000602082019050611471600083018461144d565b92915050565b61148081611419565b811461148b57600080fd5b50565b60008135905061149d81611477565b92915050565b6000602082840312156114b9576114b86112ce565b5b60006114c78482850161148e565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061150a82611419565b915061151583611419565b925082820390508181111561152d5761152c6114d0565b5b92915050565b61153c81611358565b811461154757600080fd5b50565b60008151905061155981611533565b92915050565b600060208284031215611575576115746112ce565b5b60006115838482850161154a565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60006115f582611419565b915061160083611419565b9250828201905080821115611618576116176114d0565b5b9291505056fea26469706673582212209c1443ebed4cc4b3af08cb3adb2d1354f28708dd724905e67cf353956f369f7464736f6c63430008110033 +\ 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":"_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":"","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":[{"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":"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":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":"_i","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","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":[{"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":"_account","type":"address"}],"name":"time","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","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/interface.py b/python/eth_accounts_index/interface.py @@ -41,12 +41,32 @@ class AccountsIndex(TxFactory): def add(self, contract_address, sender_address, address, tx_format=TxFormat.JSONRPC): return self.__single_address_method('add', contract_address, sender_address, address, tx_format) + def remove(self, contract_address, sender_address, address, tx_format=TxFormat.JSONRPC): + return self.__single_address_method('remove', contract_address, sender_address, address, tx_format) + def activate(self, contract_address, sender_address, address, tx_format=TxFormat.JSONRPC): return self.__single_address_method('activate', contract_address, sender_address, address, tx_format) def deactivate(self, contract_address, sender_address, address, tx_format=TxFormat.JSONRPC): return self.__single_address_method('deactivate', contract_address, sender_address, address, tx_format) + + def time(self, contract_address, address, sender_address=ZERO_ADDRESS, id_generator=None): + j = JSONRPCRequest(id_generator) + o = j.template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('time') + enc.typ(ABIContractType.ADDRESS) + enc.address(address) + data = add_0x(enc.get()) + tx = self.template(sender_address, contract_address) + tx = self.set_code(tx, data) + o['params'].append(self.normalize(tx)) + return o + + + def have(self, contract_address, address, sender_address=ZERO_ADDRESS, id_generator=None): j = JSONRPCRequest(id_generator) o = j.template() @@ -90,7 +110,7 @@ class AccountsIndex(TxFactory): def count(self, contract_address, sender_address=ZERO_ADDRESS, id_generator=None): return self.entry_count(contract_address, sender_address=sender_address, id_generator=id_generator) - + def entry(self, contract_address, idx, sender_address=ZERO_ADDRESS, id_generator=None): j = JSONRPCRequest(id_generator) o = j.template() diff --git a/python/setup.cfg b/python/setup.cfg @@ -4,7 +4,7 @@ version = 0.3.3 description = Accounts index evm contract tooling with permissioned writes author = Louis Holbrook author_email = dev@holbrook.no -url = https://gitlab.com/cicnet/eth-accounts-index +url = https://holbrook.no/src/eth-accounts-index keywords = ethereum classifiers = diff --git a/python/setup.py b/python/setup.py @@ -20,13 +20,6 @@ f.close() setup( - package_data={ - '': [ - 'data/*.abi.json', - 'data/*.bin', - ], - }, - include_package_data=True, install_requires=requirements, tests_require=test_requirements, ) diff --git a/python/tests/test_app.py b/python/tests/test_app.py @@ -18,6 +18,10 @@ from chainlib.eth.contract import ( abi_decode_single, ABIContractType, ) +from chainlib.eth.block import ( + block_latest, + block_by_number, + ) # local imports from eth_accounts_index.registry import AccountRegistry @@ -186,5 +190,77 @@ class Test(EthTesterCase): self.assertEqual(int(r, 16), 1) + def test_6_remove(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) + c = AccountsIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + b = os.urandom(20) + a = to_checksum_address(b.hex()) + (tx_hash, o) = c.add(self.address, self.accounts[0], a) + r = self.conn.do(o) + + o = c.entry_count(self.address, sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 1) + + (tx_hash, o) = c.remove(self.address, self.accounts[0], a) + r = self.conn.do(o) + o = receipt(r) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + o = c.entry_count(self.address, sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 0) + + addrs = [] + for i in range(8): + b = os.urandom(20) + addrs.append(to_checksum_address(b.hex())) + (tx_hash, o) = c.add(self.address, self.accounts[0], addrs[i]) + r = self.conn.do(o) + o = receipt(tx_hash) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + o = c.entry_count(self.address, sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 8) + + (tx_hash, o) = c.remove(self.address, self.accounts[0], addrs[4]) + r = self.conn.do(o) + o = receipt(r) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + r = [] + for i in range(7): + o = c.entry(self.address, i, sender_address=self.accounts[0]) + r.append(self.conn.do(o)) + + self.assertEqual(len(r), 7) + self.assertNotIn(addrs[4], r) + + + def test_7_time(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) + c = AccountsIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + b = os.urandom(20) + a = to_checksum_address(b.hex()) + (tx_hash, o) = c.add(self.address, self.accounts[0], a) + self.conn.do(o) + + o = block_latest() + r = self.conn.do(o) + o = block_by_number(r) + r = self.conn.do(o) + t = r['timestamp'] + + o = c.time(self.address, a, sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(t, int(r, 16)) + + if __name__ == '__main__': unittest.main() diff --git a/solidity/AccountsIndex.sol b/solidity/AccountsIndex.sol @@ -5,14 +5,14 @@ pragma solidity >0.6.12; contract CustodialAccountIndex { - uint256 constant blockedField = 1 << 64; - address[] public entry; + uint256 constant blockedField = 1 << 128; + address[] entryList; mapping(address => uint256) public entryIndex; mapping(address => bool) writers; address public owner; address newOwner; - event AddressAdded(address indexed _executor, uint256 indexed _accountIndex, address _account); // AccountsIndex + event AddressAdded(address indexed _executor, address _account); // AccountsIndex event AddressActive(address indexed _executor, address _account); event AddressInactive(address indexed _executor, address _account); event AddressRemoved(address indexed _executor, address _account); @@ -20,10 +20,11 @@ contract CustodialAccountIndex { constructor() public { owner = msg.sender; + entryList.push(address(0)); } function entryCount() external returns (uint256) { - return entry.length; + return entryList.length - 1; } function addWriter(address _writer) public returns (bool) { @@ -41,25 +42,38 @@ contract CustodialAccountIndex { // Implements AccountsIndex function add(address _account) external returns (bool) { uint256 i; + uint256 _entry; require(writers[msg.sender]); require(entryIndex[_account] == 0); - require(entry.length < (1 << 128)); - i = entry.length; - entry.push(_account); - entryIndex[_account] = i; - emit AddressAdded(msg.sender, i, _account); + require(entryList.length < (1 << 64)); + i = entryList.length; + entryList.push(_account); + _entry = uint64(i); + _entry |= block.timestamp << 64; + entryIndex[_account] = _entry; + emit AddressAdded(msg.sender, _account); return true; } // Implements AccountsIndex - // Deactivate account, without removing the entry. The entry will still be part of the entry count. - function deactivate(address _account) external returns (bool) { + function remove(address _account) external returns (bool) { + uint256 i; + uint256 l; + require(writers[msg.sender]); - require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == 0); - entryIndex[_account] <<= 65; - entryIndex[_account] |= blockedField; - emit AddressInactive(msg.sender, _account); + require(this.have(_account)); + + l = entryList.length - 1; + + i = entryIndex[_account]; + if (i < l) { + entryList[i] = entryList[l]; + } + entryList.pop(); + entryIndex[_account] = 0; + emit AddressRemoved(msg.sender, _account); + return true; } // Implements AccountsIndex @@ -67,11 +81,34 @@ contract CustodialAccountIndex { function activate(address _account) external returns (bool) { require(writers[msg.sender]); require(entryIndex[_account] > 0 && entryIndex[_account] & blockedField == blockedField); - entryIndex[_account] >>= 65; + entryIndex[_account] >>= 129; emit AddressActive(msg.sender, _account); } // Implements AccountsIndex + // 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] <<= 129; + entryIndex[_account] |= blockedField; + emit AddressInactive(msg.sender, _account); + return true; + } + + // Implements AccountsIndex + function entry(uint256 _i) external returns (address) { + return entryList[_i + 1]; + } + + // Implements AccountsIndex + function time(address _account) external returns (uint256) { + require(entryIndex[_account] > 0); + return entryIndex[_account] >> 64; + } + + + // Implements AccountsIndex function have(address _account) external view returns (bool) { return entryIndex[_account] > 0; }