Prevent nonce advance on call for erc20 methods
This commit is contained in:
parent
b4531c22cc
commit
65af3c9e32
@ -52,6 +52,6 @@ class ERC20TxFactory(TxFactory):
|
||||
data += abi_encode('address', recipient_address).hex()
|
||||
data += abi_encode('uint256', value).hex()
|
||||
data = add_0x(data)
|
||||
tx = self.template(sender_address, contract_address)
|
||||
tx = self.template(sender_address, contract_address, use_nonce=True)
|
||||
tx = self.set_code(tx, data)
|
||||
return self.build(tx)
|
||||
|
@ -117,25 +117,26 @@ class TxFactory:
|
||||
return (tx_hash_hex, o)
|
||||
|
||||
|
||||
def template(self, sender, recipient):
|
||||
def template(self, sender, recipient, use_nonce=False):
|
||||
gas_price = MINIMUM_FEE_PRICE
|
||||
if self.gas_oracle != None:
|
||||
gas_price = self.gas_oracle.get()
|
||||
logg.debug('using gas price {}'.format(gas_price))
|
||||
nonce = 0
|
||||
if self.nonce_oracle != None:
|
||||
nonce = self.nonce_oracle.next()
|
||||
logg.debug('using nonce {} for address {}'.format(nonce, sender))
|
||||
return {
|
||||
o = {
|
||||
'from': sender,
|
||||
'to': recipient,
|
||||
'value': 0,
|
||||
'data': '0x',
|
||||
'nonce': nonce,
|
||||
'gasPrice': gas_price,
|
||||
'gas': MINIMUM_FEE_UNITS,
|
||||
'chainId': self.chain_id,
|
||||
}
|
||||
if self.nonce_oracle != None and use_nonce:
|
||||
nonce = self.nonce_oracle.next()
|
||||
logg.debug('using nonce {} for address {}'.format(nonce, sender))
|
||||
o['nonce'] = nonce
|
||||
return o
|
||||
|
||||
|
||||
def normalize(self, tx):
|
||||
|
Loading…
Reference in New Issue
Block a user