mirror of
git://holbrook.no/eth-contract-registry
synced 2026-05-14 17:08:42 +02:00
Move to chainlib-eth
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user