contract-registry

Ethereum Smart Contract key-value registry
Log | Files | Refs

commit f939189f8eb30d68dde51d35ffb859b26cdafae2
parent 657137efb0279c007007307861d3804d353dbb51
Author: nolash <dev@holbrook.no>
Date:   Fri, 30 Apr 2021 13:11:22 +0200

Separate out interface

Diffstat:
Mpython/eth_contract_registry/__init__.py | 2+-
Mpython/eth_contract_registry/data/Registry.bin | 4++--
Mpython/eth_contract_registry/data/Registry.json | 2+-
Apython/eth_contract_registry/interface.py | 43+++++++++++++++++++++++++++++++++++++++++++
Mpython/eth_contract_registry/pytest/fixtures_registry.py | 6+++---
Mpython/eth_contract_registry/registry.py | 46++++++++++++----------------------------------
Mpython/gmon.out | 0
Mpython/tests/test_basic.py | 6++++--
Msolidity/Registry.sol | 14++++++++++++++
9 files changed, 80 insertions(+), 43 deletions(-)

diff --git a/python/eth_contract_registry/__init__.py b/python/eth_contract_registry/__init__.py @@ -1 +1 @@ -from .registry import Registry +from .interface import Registry diff --git a/python/eth_contract_registry/data/Registry.bin b/python/eth_contract_registry/data/Registry.bin @@ -1 +1 @@ -60806040523480156200001157600080fd5b5060405162000b8938038062000b898339818101604052810190620000379190620001c5565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060005b815181101562000104576001828281518110620000c0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190806001815401808255809150506001900390600052602060002001600090919091909150558080620000fb90620002ac565b9150506200007a565b505062000383565b6000620001236200011d8462000233565b6200020a565b905080838252602082019050828560208602820111156200014357600080fd5b60005b858110156200017757816200015c8882620001ae565b84526020840193506020830192505060018101905062000146565b5050509392505050565b600082601f8301126200019357600080fd5b8151620001a58482602086016200010c565b91505092915050565b600081519050620001bf8162000369565b92915050565b600060208284031215620001d857600080fd5b600082015167ffffffffffffffff811115620001f357600080fd5b620002018482850162000181565b91505092915050565b60006200021662000229565b905062000224828262000276565b919050565b6000604051905090565b600067ffffffffffffffff82111562000251576200025062000329565b5b602082029050602081019050919050565b6000819050919050565b6000819050919050565b620002818262000358565b810181811067ffffffffffffffff82111715620002a357620002a262000329565b5b80604052505050565b6000620002b9826200026c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415620002ef57620002ee620002fa565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b620003748162000262565b81146200038057600080fd5b50565b6107f680620003936000396000f3fe608060405234801561001057600080fd5b506004361061009a576000357c0100000000000000000000000000000000000000000000000000000000900480639648eca2116100785780639648eca21461011d578063bb34534c1461014d578063f0f86f711461017d578063f2fde38b146101ad5761009a565b806328f2d4da1461009f5780635deed44e146100cf5780638da5cb5b146100ff575b600080fd5b6100b960048036038101906100b4919061060a565b6101dd565b6040516100c69190610696565b60405180910390f35b6100e960048036038101906100e4919061057e565b610201565b6040516100f69190610696565b60405180910390f35b61010761021e565b6040516101149190610660565b60405180910390f35b6101376004803603810190610132919061057e565b610242565b6040516101449190610696565b60405180910390f35b6101676004803603810190610162919061057e565b61025f565b6040516101749190610660565b60405180910390f35b610197600480360381019061019291906105a7565b61029c565b6040516101a4919061067b565b60405180910390f35b6101c760048036038101906101c29190610555565b610472565b6040516101d4919061067b565b60405180910390f35b600181815481106101ed57600080fd5b906000526020600020016000915090505481565b600060046000838152602001908152602001600020549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060036000838152602001908152602001600020549050919050565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102f757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166002600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461036357600080fd5b6000805b6001805490508110156103d85786600182815481106103af577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015414156103c557600191505b80806103d090610703565b915050610367565b50806103e357600080fd5b846002600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508360036000888152602001908152602001600020819055508260046000868152602001908152602001600020819055506001915050949350505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104cd57600080fd5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b6000813590506105258161077b565b92915050565b60008135905061053a81610792565b92915050565b60008135905061054f816107a9565b92915050565b60006020828403121561056757600080fd5b600061057584828501610516565b91505092915050565b60006020828403121561059057600080fd5b600061059e8482850161052b565b91505092915050565b600080600080608085870312156105bd57600080fd5b60006105cb8782880161052b565b94505060206105dc87828801610516565b93505060406105ed8782880161052b565b92505060606105fe8782880161052b565b91505092959194509250565b60006020828403121561061c57600080fd5b600061062a84828501610540565b91505092915050565b61063c816106b1565b82525050565b61064b816106c3565b82525050565b61065a816106cf565b82525050565b60006020820190506106756000830184610633565b92915050565b60006020820190506106906000830184610642565b92915050565b60006020820190506106ab6000830184610651565b92915050565b60006106bc826106d9565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061070e826106f9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156107415761074061074c565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b610784816106b1565b811461078f57600080fd5b50565b61079b816106cf565b81146107a657600080fd5b50565b6107b2816106f9565b81146107bd57600080fd5b5056fea26469706673582212202898d5ed10ba7e08345b4c1bd9157618892bc47e48034196efd910944d2f3e3d64736f6c63430008030033 -\ No newline at end of file +60806040523480156200001157600080fd5b5060405162000d4a38038062000d4a8339818101604052810190620000379190620001c5565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060005b815181101562000104576001828281518110620000c0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190806001815401808255809150506001900390600052602060002001600090919091909150558080620000fb90620002ac565b9150506200007a565b505062000383565b6000620001236200011d8462000233565b6200020a565b905080838252602082019050828560208602820111156200014357600080fd5b60005b858110156200017757816200015c8882620001ae565b84526020840193506020830192505060018101905062000146565b5050509392505050565b600082601f8301126200019357600080fd5b8151620001a58482602086016200010c565b91505092915050565b600081519050620001bf8162000369565b92915050565b600060208284031215620001d857600080fd5b600082015167ffffffffffffffff811115620001f357600080fd5b620002018482850162000181565b91505092915050565b60006200021662000229565b905062000224828262000276565b919050565b6000604051905090565b600067ffffffffffffffff82111562000251576200025062000329565b5b602082029050602081019050919050565b6000819050919050565b6000819050919050565b620002818262000358565b810181811067ffffffffffffffff82111715620002a357620002a262000329565b5b80604052505050565b6000620002b9826200026c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415620002ef57620002ee620002fa565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b620003748162000262565b81146200038057600080fd5b50565b6109b780620003936000396000f3fe608060405234801561001057600080fd5b50600436106100a5576000357c0100000000000000000000000000000000000000000000000000000000900480639648eca2116100785780639648eca214610158578063bb34534c14610188578063f0f86f71146101b8578063f2fde38b146101e8576100a5565b806301ffc9a7146100aa57806328f2d4da146100da5780635deed44e1461010a5780638da5cb5b1461013a575b600080fd5b6100c460048036038101906100bf919061075f565b610218565b6040516100d191906107f9565b60405180910390f35b6100f460048036038101906100ef9190610788565b61031d565b6040516101019190610814565b60405180910390f35b610124600480360381019061011f91906106d3565b610341565b6040516101319190610814565b60405180910390f35b61014261035e565b60405161014f91906107de565b60405180910390f35b610172600480360381019061016d91906106d3565b610382565b60405161017f9190610814565b60405180910390f35b6101a2600480360381019061019d91906106d3565b61039f565b6040516101af91906107de565b60405180910390f35b6101d260048036038101906101cd91906106fc565b6103dc565b6040516101df91906107f9565b60405180910390f35b61020260048036038101906101fd91906106aa565b6105b2565b60405161020f91906107f9565b60405180910390f35b600063bb34534c7c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561026d5760019050610318565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156102c05760019050610318565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156103135760019050610318565b600090505b919050565b6001818154811061032d57600080fd5b906000526020600020016000915090505481565b600060046000838152602001908152602001600020549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060036000838152602001908152602001600020549050919050565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461043757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166002600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146104a357600080fd5b6000805b6001805490508110156105185786600182815481106104ef577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154141561050557600191505b8080610510906108ad565b9150506104a7565b508061052357600080fd5b846002600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508360036000888152602001908152602001600020819055508260046000868152602001908152602001600020819055506001915050949350505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461060d57600080fd5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b60008135905061066581610925565b92915050565b60008135905061067a8161093c565b92915050565b60008135905061068f81610953565b92915050565b6000813590506106a48161096a565b92915050565b6000602082840312156106bc57600080fd5b60006106ca84828501610656565b91505092915050565b6000602082840312156106e557600080fd5b60006106f38482850161066b565b91505092915050565b6000806000806080858703121561071257600080fd5b60006107208782880161066b565b945050602061073187828801610656565b93505060406107428782880161066b565b92505060606107538782880161066b565b91505092959194509250565b60006020828403121561077157600080fd5b600061077f84828501610680565b91505092915050565b60006020828403121561079a57600080fd5b60006107a884828501610695565b91505092915050565b6107ba8161082f565b82525050565b6107c981610841565b82525050565b6107d88161084d565b82525050565b60006020820190506107f360008301846107b1565b92915050565b600060208201905061080e60008301846107c0565b92915050565b600060208201905061082960008301846107cf565b92915050565b600061083a82610883565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006108b8826108a3565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156108eb576108ea6108f6565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b61092e8161082f565b811461093957600080fd5b50565b6109458161084d565b811461095057600080fd5b50565b61095c81610857565b811461096757600080fd5b50565b610973816108a3565b811461097e57600080fd5b5056fea26469706673582212209aec8f03f7dd2f0da35bbb26ca6174db7a60d79848dc0b74c76949c70d59711d64736f6c63430008030033 +\ No newline at end of file diff --git a/python/eth_contract_registry/data/Registry.json b/python/eth_contract_registry/data/Registry.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"bytes32[]","name":"_identifiers","type":"bytes32[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"chainOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_chain","type":"bytes32"}],"name":"configSumOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifiers","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"},{"internalType":"address","name":"_address","type":"address"},{"internalType":"bytes32","name":"_chainDescriptor","type":"bytes32"},{"internalType":"bytes32","name":"_chainConfig","type":"bytes32"}],"name":"set","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] +[{"inputs":[{"internalType":"bytes32[]","name":"_identifiers","type":"bytes32[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"chainOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_chain","type":"bytes32"}],"name":"configSumOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifiers","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"},{"internalType":"address","name":"_address","type":"address"},{"internalType":"bytes32","name":"_chainDescriptor","type":"bytes32"},{"internalType":"bytes32","name":"_chainConfig","type":"bytes32"}],"name":"set","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] diff --git a/python/eth_contract_registry/interface.py b/python/eth_contract_registry/interface.py @@ -0,0 +1,43 @@ +# external imports +from chainlib.jsonrpc import ( + jsonrpc_template, + ) +from chainlib.eth.contract import ( + ABIContractEncoder, + ABIContractType, + abi_decode_single, + ) +from chainlib.eth.tx import TxFactory +from hexathon import ( + add_0x, + ) +from chainlib.eth.constant import ( + ZERO_ADDRESS, + ) + +# local imports +from .encoding import ( + to_identifier, + ) + + +class Registry(TxFactory): + + def address_of(self, contract_address, identifier_string, sender_address=ZERO_ADDRESS): + o = jsonrpc_template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('addressOf') + enc.typ(ABIContractType.BYTES32) + identifier = to_identifier(identifier_string) + enc.bytes32(identifier) + data = add_0x(enc.encode()) + tx = self.template(sender_address, contract_address) + tx = self.set_code(tx, data) + o['params'].append(self.normalize(tx)) + return o + + + @classmethod + def parse_address_of(self, v): + return abi_decode_single(ABIContractType.ADDRESS, v) diff --git a/python/eth_contract_registry/pytest/fixtures_registry.py b/python/eth_contract_registry/pytest/fixtures_registry.py @@ -11,7 +11,7 @@ from chainlib.eth.tx import receipt from chainlib.eth.nonce import RPCNonceOracle # local imports -from eth_contract_registry.registry import Registry +from eth_contract_registry.registry import ContractRegistry from eth_contract_registry.encoding import to_identifier #logg = logging.getLogger(__name__) @@ -45,7 +45,7 @@ def registry( nonce_oracle = RPCNonceOracle(roles['CONTRACT_DEPLOYER'], eth_rpc) - builder = Registry(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) + builder = ContractRegistry(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) logg.info('registering identifiers {} in contract registry'.format(valid_identifiers)) (tx_hash_hex, o) = builder.constructor(roles['CONTRACT_DEPLOYER'], valid_identifiers) r = eth_rpc.do(o) @@ -56,7 +56,7 @@ def registry( registry_address = rcpt['contract_address'] - c = Registry(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) + c = ContractRegistry(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) chain_spec_identifier = to_identifier(str(default_chain_spec)) diff --git a/python/eth_contract_registry/registry.py b/python/eth_contract_registry/registry.py @@ -13,8 +13,6 @@ from chainlib.eth.contract import ( from chainlib.chain import ChainSpec from chainlib.eth.constant import ( ZERO_ADDRESS, - ZERO_CONTENT, - MAX_UINT, ) from chainlib.jsonrpc import ( jsonrpc_template, @@ -30,6 +28,7 @@ from .encoding import ( to_identifier, from_identifier_hex, ) +from .interface import Registry logg = logging.getLogger(__name__) @@ -37,7 +36,7 @@ moddir = os.path.dirname(__file__) datadir = os.path.join(moddir, 'data') -class Registry(TxFactory): +class ContractRegistry(Registry): default_chain_spec = None __chains_registry = {} @@ -45,30 +44,29 @@ class Registry(TxFactory): __abi = None __bytecode = None - - @staticmethod def abi(): - if Registry.__abi == None: + if ContractRegistry.__abi == None: f = open(os.path.join(datadir, 'Registry.json'), 'r') - Registry.__abi = json.load(f) + ContractRegistry.__abi = json.load(f) f.close() - return Registry.__abi + return ContractRegistry.__abi @staticmethod def bytecode(): - if Registry.__bytecode == None: + if ContractRegistry.__bytecode == None: f = open(os.path.join(datadir, 'Registry.bin')) - Registry.__bytecode = f.read() + ContractRegistry.__bytecode = f.read() f.close() - return Registry.__bytecode + return ContractRegistry.__bytecode @staticmethod def gas(code=None): return 1500000 + def constructor(self, sender_address, identifier_strings=[]): # TODO: handle arrays in chainlib encode instead enc = ABIContractEncoder() @@ -79,15 +77,15 @@ class Registry(TxFactory): data = enc.get_contents() tx = self.template(sender_address, None, use_nonce=True) - tx = self.set_code(tx, Registry.bytecode() + data) - logg.debug('bytecode {}\ndata {}\ntx {}'.format(Registry.bytecode(), data, tx)) + tx = self.set_code(tx, ContractRegistry.bytecode() + data) + logg.debug('bytecode {}\ndata {}\ntx {}'.format(ContractRegistry.bytecode(), data, tx)) return self.build(tx) @staticmethod def address(address=None): if address != None: - Registry.__address = address + ContractRegistry.__address = address return Registry.__address @@ -97,26 +95,6 @@ class Registry(TxFactory): raise NotImplementedError() - def address_of(self, contract_address, identifier_string, sender_address=ZERO_ADDRESS): - o = jsonrpc_template() - o['method'] = 'eth_call' - enc = ABIContractEncoder() - enc.method('addressOf') - enc.typ(ABIContractType.BYTES32) - identifier = to_identifier(identifier_string) - enc.bytes32(identifier) - data = add_0x(enc.encode()) - tx = self.template(sender_address, contract_address) - tx = self.set_code(tx, data) - o['params'].append(self.normalize(tx)) - return o - - - @classmethod - def parse_address_of(self, v): - return abi_decode_single(ABIContractType.ADDRESS, v) - - def set(self, contract_address, sender_address, identifier_string, address, chain_spec, chain_config_hash): enc = ABIContractEncoder() enc.method('set') diff --git a/python/gmon.out b/python/gmon.out Binary files differ. diff --git a/python/tests/test_basic.py b/python/tests/test_basic.py @@ -22,7 +22,8 @@ from hexathon import ( ) # local imports -from eth_contract_registry.registry import Registry +from eth_contract_registry import Registry +from eth_contract_registry.registry import ContractRegistry from eth_contract_registry.encoding import from_identifier_hex from eth_contract_registry.pytest.fixtures_registry import valid_identifiers @@ -46,7 +47,7 @@ def test_set( bogus_hash = add_0x(os.urandom(32).hex()) nonce_oracle = RPCNonceOracle(roles['CONTRACT_DEPLOYER'], eth_rpc) - builder = Registry(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) + builder = ContractRegistry(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) o = builder.address_of(registry, 'ContractRegistry', sender_address=eth_accounts[0]) r = eth_rpc.do(o) @@ -65,6 +66,7 @@ def test_set( rcpt = eth_rpc.do(o) assert rcpt['status'] == 1 + builder = Registry(default_chain_spec) o = builder.address_of(registry, 'FooContract', sender_address=eth_accounts[0]) r = eth_rpc.do(o) r = abi_decode_single(ABIContractType.ADDRESS, r) diff --git a/solidity/Registry.sol b/solidity/Registry.sol @@ -58,4 +58,18 @@ contract CICRegistry { function configSumOf(bytes32 _chain) public view returns (bytes32) { return chainConfigs[_chain]; } + + // Implements EIP 165 + function supportsInterface(bytes4 _sum) public pure returns (bool) { + if (_sum == 0xbb34534c) { // Registry + return true; + } + if (_sum == 0x01ffc9a7) { // EIP165 + return true; + } + if (_sum == 0x9493f8b2) { // EIP173 + return true; + } + return false; + } }