eth-erc20

ERC20 interface and example giftable token contract
Log | Files | Refs | LICENSE

commit 5e7e539bb94ee01953aaf61722755b95961026e7
parent a87fbb13bcd93242e8e92c0b5372e24fb2e67fdf
Author: Mohammed Sohail <sohailsameja@gmail.com>
Date:   Mon, 21 Nov 2022 15:49:34 +0300

feat: add height param to balanceOf call

* defaults to 'latest'

Diffstat:
Mpython/eth_erc20/erc20.py | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/python/eth_erc20/erc20.py b/python/eth_erc20/erc20.py @@ -9,12 +9,14 @@ from chainlib.eth.contract import ( ABIContractType, abi_decode_single, ) +from chainlib.eth.jsonrpc import to_blockheight_param from chainlib.eth.error import RequestMismatchException from chainlib.eth.tx import ( TxFactory, TxFormat, ) from chainlib.jsonrpc import JSONRPCRequest +from chainlib.block import BlockSpec from hexathon import ( add_0x, strip_0x, @@ -26,7 +28,7 @@ logg = logging.getLogger() class ERC20(TxFactory): - def balance_of(self, contract_address, address, sender_address=ZERO_ADDRESS, id_generator=None): + def balance_of(self, contract_address, address, sender_address=ZERO_ADDRESS, id_generator=None, height=BlockSpec.LATEST): j = JSONRPCRequest(id_generator) o = j.template() o['method'] = 'eth_call' @@ -38,7 +40,8 @@ class ERC20(TxFactory): tx = self.template(sender_address, contract_address) tx = self.set_code(tx, data) o['params'].append(self.normalize(tx)) - o['params'].append('latest') + height = to_blockheight_param(height) + o['params'].append(height) o = j.finalize(o) return o