eth-accounts-index

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

commit a30614efede626c82e0d03d68c5caaa98ca29fcc
parent 2579abaf3fa5cac099ce7fd85ac070633c5fe374
Author: lash <dev@holbrook.no>
Date:   Sun, 12 Feb 2023 06:07:14 +0000

Add deactivation test

Diffstat:
Mpython/eth_accounts_index/data/AccountsIndex.bin | 4++--
Mpython/eth_accounts_index/data/AccountsIndex.json | 2+-
Mpython/eth_accounts_index/interface.py | 24+++++++++++++++++++++---
Mpython/tests/test_app.py | 90++++++++++++++++++++++++-------------------------------------------------------
Msolidity/AccountsIndex.sol | 39+++++++++------------------------------
5 files changed, 60 insertions(+), 99 deletions(-)

diff --git a/python/eth_accounts_index/data/AccountsIndex.bin b/python/eth_accounts_index/data/AccountsIndex.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061151a806100c56000396000f3fe608060405234801561001057600080fd5b5060043610610107576000357c0100000000000000000000000000000000000000000000000000000000900480635ae06f7e116100a9578063da2824a811610083578063da2824a8146102c8578063e0db665b146102f8578063e2095c0714610328578063f2fde38b1461035857610107565b80635ae06f7e1461024a5780638da5cb5b1461027a5780639f8a13d71461029857610107565b80631c5a9d9c116100e55780631c5a9d9c1461018a57806329092d0e146101ba5780633ea053eb146101ea5780633ef250131461021a57610107565b806301ffc9a71461010c5780630a3b0a4f1461013c5780630cbb0f831461016c575b600080fd5b6101266004803603810190610121919061119e565b610388565b60405161013391906111e6565b60405180910390f35b6101566004803603810190610151919061125f565b6104dc565b60405161016391906111e6565b60405180910390f35b6101746106f6565b60405161018191906112af565b60405180910390f35b6101a4600480360381019061019f919061125f565b61070e565b6040516101b191906111e6565b60405180910390f35b6101d460048036038101906101cf919061125f565b6108b1565b6040516101e191906111e6565b60405180910390f35b61020460048036038101906101ff919061125f565b610a6f565b60405161021191906111e6565b60405180910390f35b610234600480360381019061022f919061125f565b610c64565b60405161024191906111e6565b60405180910390f35b610264600480360381019061025f919061125f565b610caf565b60405161027191906111e6565b60405180910390f35b610282610d63565b60405161028f91906112d9565b60405180910390f35b6102b260048036038101906102ad919061125f565b610d89565b6040516102bf91906111e6565b60405180910390f35b6102e260048036038101906102dd919061125f565b610e7c565b6040516102ef91906111e6565b60405180910390f35b610312600480360381019061030d919061125f565b610f39565b60405161031f919061130d565b60405180910390f35b610342600480360381019061033d9190611354565b610f51565b60405161034f91906112d9565b60405180910390f35b610372600480360381019061036d919061125f565b610ffc565b60405161037f91906111e6565b60405180910390f35b600063cbdb05c77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036103dc57600190506104d7565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361042e57600190506104d7565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361048057600190506104d7565b6380c84bd67c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104d257600190506104d7565b600090505b919050565b600080600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661053557600080fd5b6000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461058157600080fd5b700100000000000000000000000000000000600180549050106105a357600080fd5b60018054905090506001839080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060016000808282829054906101000a900467ffffffffffffffff1661067791906113b0565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550803373ffffffffffffffffffffffffffffffffffffffff167f236dcd75b06b7c701a8061d7978d8131ca139a814b90c45d7c6a9467482ee796856040516106e491906112d9565b60405180910390a36001915050919050565b60008054906101000a900467ffffffffffffffff1681565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661076657600080fd5b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180156107fe57506801000000000000000080600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205416145b61080757600080fd5b6041600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254908060020a8204915050925050819055503373ffffffffffffffffffffffffffffffffffffffff167fa27913ebf7f29594798a64cfe7cabb550ef9670075e217c2f4c1e532a899baea836040516108a491906112d9565b60405180910390a2919050565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168061093657508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61093f57600080fd5b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541161098b57600080fd5b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600160008054906101000a900467ffffffffffffffff166109f191906113ec565b6000806101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055503373ffffffffffffffffffffffffffffffffffffffff167f14c03038f91513ea128893e8d0865b80359ca07b96f819269baebe06732bb4ad83604051610a5e91906112d9565b60405180910390a260019050919050565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610ac757600080fd5b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118015610b605750600068010000000000000000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205416145b610b6957600080fd5b6041600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282549060020a029250508190555068010000000000000000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825417925050819055503373ffffffffffffffffffffffffffffffffffffffff167f5e0504df353b1d59607f86d088afd2819ce3e6013ba1bbdb1dd9072ea3b30d4583604051610c5791906112d9565b60405180910390a2919050565b600080600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d0b57600080fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003073ffffffffffffffffffffffffffffffffffffffff16633ef25013836040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610de091906112d9565b602060405180830381865afa158015610dfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e219190611454565b8015610e75575068010000000000000000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b9050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ed857600080fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60026020528060005260406000206000915090505481565b60008060018084610f629190611481565b81548110610f7357610f726114b5565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610ff15780915050610ff7565b60009150505b919050565b600080600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461105957600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905082600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61117b81611146565b811461118657600080fd5b50565b60008135905061119881611172565b92915050565b6000602082840312156111b4576111b3611141565b5b60006111c284828501611189565b91505092915050565b60008115159050919050565b6111e0816111cb565b82525050565b60006020820190506111fb60008301846111d7565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061122c82611201565b9050919050565b61123c81611221565b811461124757600080fd5b50565b60008135905061125981611233565b92915050565b60006020828403121561127557611274611141565b5b60006112838482850161124a565b91505092915050565b600067ffffffffffffffff82169050919050565b6112a98161128c565b82525050565b60006020820190506112c460008301846112a0565b92915050565b6112d381611221565b82525050565b60006020820190506112ee60008301846112ca565b92915050565b6000819050919050565b611307816112f4565b82525050565b600060208201905061132260008301846112fe565b92915050565b611331816112f4565b811461133c57600080fd5b50565b60008135905061134e81611328565b92915050565b60006020828403121561136a57611369611141565b5b60006113788482850161133f565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006113bb8261128c565b91506113c68361128c565b9250828201905067ffffffffffffffff8111156113e6576113e5611381565b5b92915050565b60006113f78261128c565b91506114028361128c565b9250828203905067ffffffffffffffff81111561142257611421611381565b5b92915050565b611431816111cb565b811461143c57600080fd5b50565b60008151905061144e81611428565b92915050565b60006020828403121561146a57611469611141565b5b60006114788482850161143f565b91505092915050565b600061148c826112f4565b9150611497836112f4565b92508282019050808211156114af576114ae611381565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfea26469706673582212205b46ef32f225583b891fe552ec57ef96b8e14fd624278da6aab866396ce2d27564736f6c63430008110033 -\ No newline at end of file +608060405234801561001057600080fd5b5033600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611108806100616000396000f3fe608060405234801561001057600080fd5b50600436106100ec576000357c0100000000000000000000000000000000000000000000000000000000900480635ae06f7e116100a9578063da2824a811610083578063da2824a81461027d578063e0db665b146102ad578063e2095c07146102dd578063f2fde38b1461030d576100ec565b80635ae06f7e146101ff5780638da5cb5b1461022f5780639f8a13d71461024d576100ec565b806301ffc9a7146100f15780630a3b0a4f146101215780630cbb0f83146101515780631c5a9d9c1461016f5780633ea053eb1461019f5780633ef25013146101cf575b600080fd5b61010b60048036038101906101069190610ed4565b61033d565b6040516101189190610f1c565b60405180910390f35b61013b60048036038101906101369190610f95565b610491565b6040516101489190610f1c565b60405180910390f35b610159610660565b6040516101669190610fdb565b60405180910390f35b61018960048036038101906101849190610f95565b61066c565b6040516101969190610f1c565b60405180910390f35b6101b960048036038101906101b49190610f95565b61080f565b6040516101c69190610f1c565b60405180910390f35b6101e960048036038101906101e49190610f95565b610a04565b6040516101f69190610f1c565b60405180910390f35b61021960048036038101906102149190610f95565b610a4f565b6040516102269190610f1c565b60405180910390f35b610237610b03565b6040516102449190611005565b60405180910390f35b61026760048036038101906102629190610f95565b610b29565b6040516102749190610f1c565b60405180910390f35b61029760048036038101906102929190610f95565b610c1e565b6040516102a49190610f1c565b60405180910390f35b6102c760048036038101906102c29190610f95565b610cdb565b6040516102d49190610fdb565b60405180910390f35b6102f760048036038101906102f2919061104c565b610cf3565b6040516103049190611005565b60405180910390f35b61032760048036038101906103229190610f95565b610d32565b6040516103349190610f1c565b60405180910390f35b600063cbdb05c77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610391576001905061048c565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036103e3576001905061048c565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610435576001905061048c565b6380c84bd67c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610487576001905061048c565b600090505b919050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166104ea57600080fd5b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461053657600080fd5b7001000000000000000000000000000000006000805490501061055857600080fd5b60008054905090506000839080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550803373ffffffffffffffffffffffffffffffffffffffff167f236dcd75b06b7c701a8061d7978d8131ca139a814b90c45d7c6a9467482ee7968560405161064e9190611005565b60405180910390a36001915050919050565b60008080549050905090565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166106c457600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411801561075c57506801000000000000000080600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205416145b61076557600080fd5b6041600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254908060020a8204915050925050819055503373ffffffffffffffffffffffffffffffffffffffff167fa27913ebf7f29594798a64cfe7cabb550ef9670075e217c2f4c1e532a899baea836040516108029190611005565b60405180910390a2919050565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661086757600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180156109005750600068010000000000000000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205416145b61090957600080fd5b6041600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282549060020a029250508190555068010000000000000000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825417925050819055503373ffffffffffffffffffffffffffffffffffffffff167f5e0504df353b1d59607f86d088afd2819ce3e6013ba1bbdb1dd9072ea3b30d45836040516109f79190611005565b60405180910390a2919050565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610aab57600080fd5b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003073ffffffffffffffffffffffffffffffffffffffff16633ef25013836040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610b809190611005565b602060405180830381865afa158015610b9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc191906110a5565b8015610c1757506801000000000000000080600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541614155b9050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c7a57600080fd5b6001600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60016020528060005260406000206000915090505481565b60008181548110610d0357600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d8f57600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905082600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610eb181610e7c565b8114610ebc57600080fd5b50565b600081359050610ece81610ea8565b92915050565b600060208284031215610eea57610ee9610e77565b5b6000610ef884828501610ebf565b91505092915050565b60008115159050919050565b610f1681610f01565b82525050565b6000602082019050610f316000830184610f0d565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610f6282610f37565b9050919050565b610f7281610f57565b8114610f7d57600080fd5b50565b600081359050610f8f81610f69565b92915050565b600060208284031215610fab57610faa610e77565b5b6000610fb984828501610f80565b91505092915050565b6000819050919050565b610fd581610fc2565b82525050565b6000602082019050610ff06000830184610fcc565b92915050565b610fff81610f57565b82525050565b600060208201905061101a6000830184610ff6565b92915050565b61102981610fc2565b811461103457600080fd5b50565b60008135905061104681611020565b92915050565b60006020828403121561106257611061610e77565b5b600061107084828501611037565b91505092915050565b61108281610f01565b811461108d57600080fd5b50565b60008151905061109f81611079565b92915050565b6000602082840312156110bb576110ba610e77565b5b60006110c984828501611090565b9150509291505056fea26469706673582212209f9d8ccc0c0479677dcd5270b2cf70eb51f100f7c462f4703c4b57ccf4a3a1e564736f6c63430008110033 +\ 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":"_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"}] +[{"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"}] diff --git a/python/eth_accounts_index/interface.py b/python/eth_accounts_index/interface.py @@ -41,8 +41,11 @@ 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 have(self, contract_address, address, sender_address=ZERO_ADDRESS, id_generator=None): j = JSONRPCRequest(id_generator) @@ -58,7 +61,22 @@ class AccountsIndex(TxFactory): o['params'].append(self.normalize(tx)) return o - def entry_count(self, contract_address, sender_address=ZERO_ADDRESS, id_generator=None): + def is_active(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('isActive') + 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 entry_count(self, contract_address, sender_address=ZERO_ADDRESS, id_generator=None): j = JSONRPCRequest(id_generator) o = j.template() o['method'] = 'eth_call' diff --git a/python/tests/test_app.py b/python/tests/test_app.py @@ -128,12 +128,7 @@ class Test(EthTesterCase): self.assertEqual(count, 2) - #registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1]) - #registry.add(self.w3.eth.accounts[2]) - - #self.assertFalse(registry.have(self.w3.eth.accounts[3])) - - def test_5_remove(self): + def test_5_deactivate(self): nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) c = AccountsIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) @@ -157,70 +152,39 @@ class Test(EthTesterCase): count = c.parse_entry_count(r) self.assertEqual(count, 2) - (tx_hash, o) = c.remove(self.address, self.accounts[0], a) + (tx_hash, o) = c.deactivate(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) count = c.parse_entry_count(r) - self.assertEqual(count, 1) + self.assertEqual(count, 2) + o = c.have(self.address, a, sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 1) + + o = c.is_active(self.address, a, sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 0) + + (tx_hash, o) = c.activate(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.have(self.address, a, sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 1) + + o = c.is_active(self.address, a, sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 1) -# TODO: reinstate all tests -# def test_access(self): -# registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1]) -# registry.add(self.w3.eth.accounts[2]) -# self.eth_tester.mine_block() -# self.assertEqual(registry.count(), 2) -# -# # account 2 does not have access -# registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[2]) -# registry.add(self.w3.eth.accounts[2]) -# self.eth_tester.mine_block() -# self.assertEqual(registry.count(), 2) -# -# # after this account 2 has access -# registry.contract.functions.addWriter(self.w3.eth.accounts[2]).transact() -# registry.add(self.w3.eth.accounts[3]) -# self.eth_tester.mine_block() -# self.assertEqual(registry.count(), 3) -# -# # after this account 2 no longer has access -# registry.contract.functions.deleteWriter(self.w3.eth.accounts[2]).transact() -# registry.add(self.w3.eth.accounts[3]) -# self.eth_tester.mine_block() -# self.assertEqual(registry.count(), 3) -# -# - -# def test_no_duplicates(self): -# registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1]) -# tx_hash = registry.add(self.w3.eth.accounts[2]) -# self.eth_tester.mine_block() -# tx_hash = registry.add(self.w3.eth.accounts[3]) -# self.eth_tester.mine_block() -# # BUG: eth_tester does not detect the duplicate here, but does in the test.py file in the solidity folder -# #self.assertRaises(Exception): -# tx_hash = registry.add(self.w3.eth.accounts[2]) -# self.eth_tester.mine_block() -# -# -# def test_list(self): -# registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1]) -# -# for i in range(2, 10): -# registry.add(self.w3.eth.accounts[i]) -# -# self.assertEqual(registry.count(), 9) -# -# accounts_reverse = [] -# for i in range(9, 1, -1): -# accounts_reverse.append(self.w3.eth.accounts[i]) -# -# accounts_list = registry.last(8) -# for i in range(8): -# self.assertEqual(accounts_list[i], accounts_reverse[i]) -# if __name__ == '__main__': unittest.main() diff --git a/solidity/AccountsIndex.sol b/solidity/AccountsIndex.sol @@ -6,8 +6,7 @@ pragma solidity >0.6.12; contract CustodialAccountIndex { uint256 constant blockedField = 1 << 64; - uint64 public entryCount; - address[] entryList; + address[] public entry; mapping(address => uint256) public entryIndex; mapping(address => bool) writers; address public owner; @@ -21,7 +20,10 @@ contract CustodialAccountIndex { constructor() public { owner = msg.sender; - entryList.push(address(0)); + } + + function entryCount() external returns (uint256) { + return entry.length; } function addWriter(address _writer) public returns (bool) { @@ -42,11 +44,10 @@ contract CustodialAccountIndex { require(writers[msg.sender]); require(entryIndex[_account] == 0); - require(entryList.length < (1 << 128)); - i = entryList.length; - entryList.push(_account); + require(entry.length < (1 << 128)); + i = entry.length; + entry.push(_account); entryIndex[_account] = i; - entryCount += 1; emit AddressAdded(msg.sender, i, _account); return true; } @@ -71,24 +72,13 @@ contract CustodialAccountIndex { } // 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; - } - - // Implements AccountsIndex function have(address _account) external view returns (bool) { return entryIndex[_account] > 0; } // Implements AccountsIndex function isActive(address _account) external view returns (bool) { - return this.have(_account) && entryIndex[_account] != blockedField; + return this.have(_account) && entryIndex[_account] & blockedField != blockedField; } // Implements EIP173 @@ -102,17 +92,6 @@ contract CustodialAccountIndex { 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