Move to chainlib-eth

This commit is contained in:
nolash 2021-06-28 09:29:37 +02:00
parent 72223d0011
commit 3fd2f1d6b7
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
5 changed files with 26 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

@ -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

13
python/run_tests.sh Normal file
View File

@ -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

View File

@ -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