Correct checksum rpc address in gas method
This commit is contained in:
parent
0fe97f4741
commit
795c901d37
@ -9,7 +9,10 @@ from hexathon import (
|
|||||||
)
|
)
|
||||||
#from chainlib.eth.constant import ZERO_ADDRESS
|
#from chainlib.eth.constant import ZERO_ADDRESS
|
||||||
from chainlib.chain import ChainSpec
|
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 chainlib.connection import RPCConnection
|
||||||
from chainqueue.db.enum import StatusBits
|
from chainqueue.db.enum import StatusBits
|
||||||
from chainqueue.sql.tx import cache_tx_dict
|
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
|
:return: Signed raw transaction data list
|
||||||
:rtype: param txs, unchanged
|
:rtype: param txs, unchanged
|
||||||
"""
|
"""
|
||||||
|
rpc_format_address = None
|
||||||
if address != None:
|
if address != None:
|
||||||
if not is_checksum_address(address):
|
if not is_checksum_address(address):
|
||||||
raise ValueError('invalid address {}'.format(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)
|
txs.append(tx)
|
||||||
|
|
||||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||||
logg.debug('txs {} tx_hashes {}'.format(txs, tx_hashes))
|
|
||||||
|
|
||||||
addresspass = None
|
addresspass = None
|
||||||
if len(txs) == 0:
|
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']))
|
raise ValueError('txs passed to check gas must all have same sender; had {} got {}'.format(address, tx['from']))
|
||||||
addresspass.append(address)
|
addresspass.append(address)
|
||||||
|
|
||||||
|
rpc_format_address = add_0x(to_checksum_address(address))
|
||||||
|
|
||||||
queue = self.request.delivery_info.get('routing_key')
|
queue = self.request.delivery_info.get('routing_key')
|
||||||
|
|
||||||
conn = RPCConnection.connect(chain_spec)
|
conn = RPCConnection.connect(chain_spec)
|
||||||
|
|
||||||
gas_balance = 0
|
gas_balance = 0
|
||||||
try:
|
try:
|
||||||
o = balance(address)
|
o = balance(rpc_format_address)
|
||||||
r = conn.do(o)
|
r = conn.do(o)
|
||||||
conn.disconnect()
|
conn.disconnect()
|
||||||
gas_balance = abi_decode_single(ABIContractType.UINT256, r)
|
gas_balance = abi_decode_single(ABIContractType.UINT256, r)
|
||||||
|
@ -225,4 +225,4 @@ def test_callback_filter_filter(
|
|||||||
fltr.filter(eth_rpc, mockblock, tx, init_database)
|
fltr.filter(eth_rpc, mockblock, tx, init_database)
|
||||||
|
|
||||||
assert mock.results.get('transfer') != None
|
assert mock.results.get('transfer') != None
|
||||||
assert mock.results['transfer']['destination_token'] == foo_token
|
assert mock.results['transfer']['destination_token'] == strip_0x(foo_token)
|
||||||
|
@ -78,4 +78,4 @@ def test_filter_transferauth(
|
|||||||
|
|
||||||
c = ERC20(default_chain_spec)
|
c = ERC20(default_chain_spec)
|
||||||
approve = c.parse_approve_request(approve_tx['data'])
|
approve = c.parse_approve_request(approve_tx['data'])
|
||||||
assert approve[0] == agent_roles['BOB']
|
assert approve[0] == strip_0x(agent_roles['BOB'])
|
||||||
|
Loading…
Reference in New Issue
Block a user