From fe0dcf176502aa6915d07e91aa22020417987db7 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Fri, 18 Nov 2022 16:51:24 +0300 Subject: [PATCH] feat: add height param to balanceOf call * defaults to 'latest' --- python/eth_erc20/erc20.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/eth_erc20/erc20.py b/python/eth_erc20/erc20.py index 88c1eeb..851c86e 100644 --- a/python/eth_erc20/erc20.py +++ b/python/eth_erc20/erc20.py @@ -9,6 +9,7 @@ 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, @@ -26,7 +27,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=None): j = JSONRPCRequest(id_generator) o = j.template() o['method'] = 'eth_call' @@ -38,7 +39,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