Correct checksum rpc address in gas method

This commit is contained in:
nolash 2021-10-02 18:27:09 +02:00
parent 0fe97f4741
commit 795c901d37
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 10 additions and 5 deletions

View File

@ -9,7 +9,10 @@ from hexathon import (
)
#from chainlib.eth.constant import ZERO_ADDRESS
from chainlib.chain import ChainSpec
from chainlib.eth.address import is_checksum_address
from chainlib.eth.address import (
is_checksum_address,
to_checksum_address,
)
from chainlib.connection import RPCConnection
from chainqueue.db.enum import StatusBits
from chainqueue.sql.tx import cache_tx_dict
@ -179,6 +182,7 @@ def check_gas(self, tx_hashes_hex, chain_spec_dict, txs_hex=[], address=None, ga
:return: Signed raw transaction data list
:rtype: param txs, unchanged
"""
rpc_format_address = None
if address != None:
if not is_checksum_address(address):
raise ValueError('invalid address {}'.format(address))
@ -195,7 +199,6 @@ def check_gas(self, tx_hashes_hex, chain_spec_dict, txs_hex=[], address=None, ga
txs.append(tx)
chain_spec = ChainSpec.from_dict(chain_spec_dict)
logg.debug('txs {} tx_hashes {}'.format(txs, tx_hashes))
addresspass = None
if len(txs) == 0:
@ -211,13 +214,15 @@ def check_gas(self, tx_hashes_hex, chain_spec_dict, txs_hex=[], address=None, ga
raise ValueError('txs passed to check gas must all have same sender; had {} got {}'.format(address, tx['from']))
addresspass.append(address)
rpc_format_address = add_0x(to_checksum_address(address))
queue = self.request.delivery_info.get('routing_key')
conn = RPCConnection.connect(chain_spec)
gas_balance = 0
try:
o = balance(address)
o = balance(rpc_format_address)
r = conn.do(o)
conn.disconnect()
gas_balance = abi_decode_single(ABIContractType.UINT256, r)

View File

@ -225,4 +225,4 @@ def test_callback_filter_filter(
fltr.filter(eth_rpc, mockblock, tx, init_database)
assert mock.results.get('transfer') != None
assert mock.results['transfer']['destination_token'] == foo_token
assert mock.results['transfer']['destination_token'] == strip_0x(foo_token)

View File

@ -78,4 +78,4 @@ def test_filter_transferauth(
c = ERC20(default_chain_spec)
approve = c.parse_approve_request(approve_tx['data'])
assert approve[0] == agent_roles['BOB']
assert approve[0] == strip_0x(agent_roles['BOB'])