Add id generator to interface methods

This commit is contained in:
nolash 2021-08-25 12:06:22 +02:00
parent 713d8338fa
commit c630627e98
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 13 additions and 12 deletions

View File

@ -15,9 +15,7 @@ from chainlib.eth.contract import (
abi_decode_single, abi_decode_single,
) )
from chainlib.eth.constant import ZERO_ADDRESS from chainlib.eth.constant import ZERO_ADDRESS
from chainlib.jsonrpc import ( from chainlib.jsonrpc import JSONRPCRequest
jsonrpc_template,
)
from chainlib.eth.error import RequestMismatchException from chainlib.eth.error import RequestMismatchException
from hexathon import ( from hexathon import (
add_0x, add_0x,
@ -45,8 +43,9 @@ class AccountsIndex(TxFactory):
return self.__single_address_method('add', contract_address, sender_address, address, tx_format) return self.__single_address_method('add', contract_address, sender_address, address, tx_format)
def have(self, contract_address, address, sender_address=ZERO_ADDRESS): def have(self, contract_address, address, sender_address=ZERO_ADDRESS, id_generator=None):
o = jsonrpc_template() j = JSONRPCRequest(id_generator)
o = j.template()
o['method'] = 'eth_call' o['method'] = 'eth_call'
enc = ABIContractEncoder() enc = ABIContractEncoder()
enc.method('have') enc.method('have')
@ -59,8 +58,9 @@ class AccountsIndex(TxFactory):
return o return o
def entry_count(self, contract_address, sender_address=ZERO_ADDRESS): def entry_count(self, contract_address, sender_address=ZERO_ADDRESS, id_generator=None):
o = jsonrpc_template() j = JSONRPCRequest(id_generator)
o = j.template()
o['method'] = 'eth_call' o['method'] = 'eth_call'
enc = ABIContractEncoder() enc = ABIContractEncoder()
enc.method('entryCount') enc.method('entryCount')
@ -71,12 +71,13 @@ class AccountsIndex(TxFactory):
return o return o
def count(self, contract_address, sender_address=ZERO_ADDRESS): def count(self, contract_address, sender_address=ZERO_ADDRESS, id_generator=None):
return self.entry_count(contract_address, sender_address=sender_address) return self.entry_count(contract_address, sender_address=sender_address, id_generator=id_generator)
def entry(self, contract_address, idx, sender_address=ZERO_ADDRESS): def entry(self, contract_address, idx, sender_address=ZERO_ADDRESS, id_generator=None):
o = jsonrpc_template() j = JSONRPCRequest(id_generator)
o = j.template()
o['method'] = 'eth_call' o['method'] = 'eth_call'
enc = ABIContractEncoder() enc = ABIContractEncoder()
enc.method('entry') enc.method('entry')

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = eth-accounts-index name = eth-accounts-index
version = 0.1.2a2 version = 0.1.2a3
description = Accounts index evm contract tooling with permissioned writes description = Accounts index evm contract tooling with permissioned writes
author = Louis Holbrook author = Louis Holbrook
author_email = dev@holbrook.no author_email = dev@holbrook.no