eth-accounts-index

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

commit 1493f7d860c024ece145bffcb2d402001bf554e2
parent 6dd8e9b55ec95a6d04921d35dca420d7d00b7d35
Author: nolash <dev@holbrook.no>
Date:   Thu, 13 May 2021 17:55:05 +0200

Repair token count

Diffstat:
Mpython/eth_accounts_index/data/AccountsIndex.bin | 4++--
Mpython/eth_accounts_index/interface.py | 5+++++
Mpython/setup.cfg | 2+-
Mpython/tests/test_app.py | 47++++++++++++++++++++++++++++++++++++-----------
Msolidity/AccountsIndex.sol | 2+-
5 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/python/eth_accounts_index/data/AccountsIndex.bin b/python/eth_accounts_index/data/AccountsIndex.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600281905550610d0a806100cb6000396000f3fe608060405234801561001057600080fd5b50600436106100bb576000357c01000000000000000000000000000000000000000000000000000000009004806379ba50971161008357806379ba50971461019e5780638da5cb5b146101bc578063da2824a8146101da578063e2095c071461020a578063f2fde38b1461023a576100bb565b806301ffc9a7146100c05780630a3b0a4f146100f05780630cbb0f83146101205780633ef250131461013e5780635ae06f7e1461016e575b600080fd5b6100da60048036038101906100d59190610a92565b61026a565b6040516100e79190610b2c565b60405180910390f35b61010a60048036038101906101059190610a69565b6103c2565b6040516101179190610b2c565b60405180910390f35b610128610570565b6040516101359190610b47565b60405180910390f35b61015860048036038101906101539190610a69565b610586565b6040516101659190610b2c565b60405180910390f35b61018860048036038101906101839190610a69565b6105d1565b6040516101959190610b2c565b60405180910390f35b6101a6610685565b6040516101b39190610b2c565b60405180910390f35b6101c461082c565b6040516101d19190610b11565b60405180910390f35b6101f460048036038101906101ef9190610a69565b610852565b6040516102019190610b2c565b60405180910390f35b610224600480360381019061021f9190610abb565b61090f565b6040516102319190610b11565b60405180910390f35b610254600480360381019061024f9190610a69565b610988565b6040516102619190610b2c565b60405180910390f35b600063cbdb05c77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156102bf57600190506103bd565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561031257600190506103bd565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561036557600190506103bd565b6337a47be47c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156103b857600190506103bd565b600090505b919050565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661041a57600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461046657600080fd5b600080549050600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000829080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060016000805490506105249190610bb8565b8273ffffffffffffffffffffffffffffffffffffffff167f9cc987676e7d63379f176ea50df0ae8d2d9d1141d1231d4ce15b5965f73c943060405160405180910390a360019050919050565b600060016002546105819190610bb8565b905090565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461062d57600080fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106e257600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146108ae57600080fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60008060018361091f9190610b62565b81548110610956577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109e457600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b600081359050610a3981610c8f565b92915050565b600081359050610a4e81610ca6565b92915050565b600081359050610a6381610cbd565b92915050565b600060208284031215610a7b57600080fd5b6000610a8984828501610a2a565b91505092915050565b600060208284031215610aa457600080fd5b6000610ab284828501610a3f565b91505092915050565b600060208284031215610acd57600080fd5b6000610adb84828501610a54565b91505092915050565b610aed81610bec565b82525050565b610afc81610bfe565b82525050565b610b0b81610c56565b82525050565b6000602082019050610b266000830184610ae4565b92915050565b6000602082019050610b416000830184610af3565b92915050565b6000602082019050610b5c6000830184610b02565b92915050565b6000610b6d82610c56565b9150610b7883610c56565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610bad57610bac610c60565b5b828201905092915050565b6000610bc382610c56565b9150610bce83610c56565b925082821015610be157610be0610c60565b5b828203905092915050565b6000610bf782610c36565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b610c9881610bec565b8114610ca357600080fd5b50565b610caf81610c0a565b8114610cba57600080fd5b50565b610cc681610c56565b8114610cd157600080fd5b5056fea2646970667358221220c0f3c01b327641a05481cc30637312f68ef9ef0442d90958770fe80e0c88087564736f6c63430008030033 -\ No newline at end of file +608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600281905550610d0d806100cb6000396000f3fe608060405234801561001057600080fd5b50600436106100bb576000357c01000000000000000000000000000000000000000000000000000000009004806379ba50971161008357806379ba50971461019e5780638da5cb5b146101bc578063da2824a8146101da578063e2095c071461020a578063f2fde38b1461023a576100bb565b806301ffc9a7146100c05780630a3b0a4f146100f05780630cbb0f83146101205780633ef250131461013e5780635ae06f7e1461016e575b600080fd5b6100da60048036038101906100d59190610a95565b61026a565b6040516100e79190610b2f565b60405180910390f35b61010a60048036038101906101059190610a6c565b6103c2565b6040516101179190610b2f565b60405180910390f35b610128610570565b6040516101359190610b4a565b60405180910390f35b61015860048036038101906101539190610a6c565b610589565b6040516101659190610b2f565b60405180910390f35b61018860048036038101906101839190610a6c565b6105d4565b6040516101959190610b2f565b60405180910390f35b6101a6610688565b6040516101b39190610b2f565b60405180910390f35b6101c461082f565b6040516101d19190610b14565b60405180910390f35b6101f460048036038101906101ef9190610a6c565b610855565b6040516102019190610b2f565b60405180910390f35b610224600480360381019061021f9190610abe565b610912565b6040516102319190610b14565b60405180910390f35b610254600480360381019061024f9190610a6c565b61098b565b6040516102619190610b2f565b60405180910390f35b600063cbdb05c77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156102bf57600190506103bd565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561031257600190506103bd565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561036557600190506103bd565b6337a47be47c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156103b857600190506103bd565b600090505b919050565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661041a57600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461046657600080fd5b600080549050600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000829080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060016000805490506105249190610bbb565b8273ffffffffffffffffffffffffffffffffffffffff167f9cc987676e7d63379f176ea50df0ae8d2d9d1141d1231d4ce15b5965f73c943060405160405180910390a360019050919050565b600060016000805490506105849190610bbb565b905090565b600080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461063057600080fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905560019050919050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106e557600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146108b157600080fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000806001836109229190610b65565b81548110610959577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109e757600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b600081359050610a3c81610c92565b92915050565b600081359050610a5181610ca9565b92915050565b600081359050610a6681610cc0565b92915050565b600060208284031215610a7e57600080fd5b6000610a8c84828501610a2d565b91505092915050565b600060208284031215610aa757600080fd5b6000610ab584828501610a42565b91505092915050565b600060208284031215610ad057600080fd5b6000610ade84828501610a57565b91505092915050565b610af081610bef565b82525050565b610aff81610c01565b82525050565b610b0e81610c59565b82525050565b6000602082019050610b296000830184610ae7565b92915050565b6000602082019050610b446000830184610af6565b92915050565b6000602082019050610b5f6000830184610b05565b92915050565b6000610b7082610c59565b9150610b7b83610c59565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610bb057610baf610c63565b5b828201905092915050565b6000610bc682610c59565b9150610bd183610c59565b925082821015610be457610be3610c63565b5b828203905092915050565b6000610bfa82610c39565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b610c9b81610bef565b8114610ca657600080fd5b50565b610cb281610c0d565b8114610cbd57600080fd5b50565b610cc981610c59565b8114610cd457600080fd5b5056fea2646970667358221220f89a905a7d1b34f4616c7c88e97c0a10642a027985406572ad4e4db2604c0a6e64736f6c63430008030033 +\ No newline at end of file diff --git a/python/eth_accounts_index/interface.py b/python/eth_accounts_index/interface.py @@ -95,6 +95,11 @@ class AccountsIndex(TxFactory): @classmethod + def parse_entry_count(self, v): + return abi_decode_single(ABIContractType.UINT256, v) + + + @classmethod def parse_have(self, v): return abi_decode_single(ABIContractType.BOOLEAN, v) diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = eth-accounts-index -version = 0.0.11a11 +version = 0.0.11a12 description = Accounts index evm contract tooling with permissioned writes author = Louis Holbrook author_email = dev@holbrook.no diff --git a/python/tests/test_app.py b/python/tests/test_app.py @@ -97,12 +97,44 @@ class Test(EthTesterCase): nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) c = AccountsIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash, o) = c.add(self.address, self.accounts[0], a, tx_format=TxFormat.RLP_SIGNED) - #r = self.conn.do(o) - #self.assertEqual(tx_hash, r) + (tx_hash, o) = c.add(self.address, self.accounts[0], a) #, tx_format=TxFormat.RLP_SIGNED) + r = self.conn.do(o) + self.assertEqual(tx_hash, r) logg.debug('o {}'.format(o)) + def test_4_indices(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) + c = AccountsIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + 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, 0) + + 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) + + b = os.urandom(20) + aa = to_checksum_address(b.hex()) + (tx_hash, o) = c.add(self.address, self.accounts[0], aa) + r = self.conn.do(o) + + 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, 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])) + + + # TODO: reinstate all tests # def test_access(self): # registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1]) @@ -129,14 +161,7 @@ class Test(EthTesterCase): # self.assertEqual(registry.count(), 3) # # -# def test_indices(self): -# registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1]) -# registry.add(self.w3.eth.accounts[2]) -# -# self.assertTrue(registry.have(self.w3.eth.accounts[2])) -# self.assertFalse(registry.have(self.w3.eth.accounts[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]) diff --git a/solidity/AccountsIndex.sol b/solidity/AccountsIndex.sol @@ -54,7 +54,7 @@ contract CustodialAccountIndex { // Implements AccountsIndex function entryCount() public returns (uint256) { - return count - 1; + return entries.length - 1; } // Implements EIP173