From 3fd2f1d6b78bbb3f3f3d80da8502382ba352b2b6 Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 28 Jun 2021 09:29:37 +0200 Subject: [PATCH] Move to chainlib-eth --- python/eth_contract_registry/interface.py | 10 +++++----- python/eth_contract_registry/registry.py | 10 +++++----- python/requirements.txt | 4 ++-- python/run_tests.sh | 13 +++++++++++++ python/setup.cfg | 2 +- 5 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 python/run_tests.sh diff --git a/python/eth_contract_registry/interface.py b/python/eth_contract_registry/interface.py index 27fef9b..1f0f8d8 100644 --- a/python/eth_contract_registry/interface.py +++ b/python/eth_contract_registry/interface.py @@ -1,7 +1,5 @@ # external imports -from chainlib.jsonrpc import ( - jsonrpc_template, - ) +from chainlib.jsonrpc import JSONRPCRequest from chainlib.eth.contract import ( ABIContractEncoder, ABIContractType, @@ -23,8 +21,9 @@ from .encoding import ( class Registry(TxFactory): - def address_of(self, contract_address, identifier_string, sender_address=ZERO_ADDRESS): - o = jsonrpc_template() + def address_of(self, contract_address, identifier_string, sender_address=ZERO_ADDRESS, id_generator=None): + j = JSONRPCRequest(id_generator) + o = j.template() o['method'] = 'eth_call' enc = ABIContractEncoder() enc.method('addressOf') @@ -35,6 +34,7 @@ class Registry(TxFactory): tx = self.template(sender_address, contract_address) tx = self.set_code(tx, data) o['params'].append(self.normalize(tx)) + o = j.finalize(o) return o diff --git a/python/eth_contract_registry/registry.py b/python/eth_contract_registry/registry.py index 3ae8bdb..d85b65c 100644 --- a/python/eth_contract_registry/registry.py +++ b/python/eth_contract_registry/registry.py @@ -14,9 +14,7 @@ from chainlib.chain import ChainSpec from chainlib.eth.constant import ( ZERO_ADDRESS, ) -from chainlib.jsonrpc import ( - jsonrpc_template, - ) +from chainlib.jsonrpc import JSONRPCRequest from hexathon import ( even, add_0x, @@ -117,8 +115,9 @@ class ContractRegistry(Registry): return self.build(tx) - def identifier(self, contract_address, idx, sender_address=ZERO_ADDRESS): - o = jsonrpc_template() + def identifier(self, contract_address, idx, sender_address=ZERO_ADDRESS, id_generator=None): + j = JSONRPCRequest(id_generator) + o = j.template() o['method'] = 'eth_call' enc = ABIContractEncoder() enc.method('identifiers') @@ -128,6 +127,7 @@ class ContractRegistry(Registry): tx = self.template(sender_address, contract_address) tx = self.set_code(tx, data) o['params'].append(self.normalize(tx)) + o = j.finalize(o) return o diff --git a/python/requirements.txt b/python/requirements.txt index e7cf8a3..7dcc69a 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,3 +1,3 @@ confini~=0.3.6rc3 -crypto-dev-signer~=0.4.14b4 -chainlib~=0.0.3rc3 +crypto-dev-signer~=0.4.14b6 +chainlib-eth~=0.0.5a1 diff --git a/python/run_tests.sh b/python/run_tests.sh new file mode 100644 index 0000000..af7a316 --- /dev/null +++ b/python/run_tests.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e +set -x +#for f in `ls tests/*.py`; do + #python $f +# if [ $? -gt 0 ]; then +# exit 1 +# fi +#done +pytest -s -v -x ./tests +set +x +set +e diff --git a/python/setup.cfg b/python/setup.cfg index 5c9c176..7116953 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = eth-contract-registry -version = 0.5.5a3 +version = 0.5.6a1 description = Ethereum Smart Contract key-value registry author = Louis Holbrook author_email = dev@holbrook.no