accounts/abi/bind: fix gas price suggestion with pre EIP-1559 clients (#23102)

This fixes transaction sending in the case where an app using go-ethereum v1.10.4
is talking to a pre-EIP-1559 RPC node. In this case, the eth_maxPriorityFeePerGas
endpoint is not available and we can only rely on eth_gasPrice.
This commit is contained in:
Pierre R 2021-06-29 17:57:29 +09:00 committed by GitHub
parent 35dbf7a8a3
commit 61f4b5aa89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -256,13 +256,10 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")
}
if opts.GasPrice == nil {
price, err := c.transactor.SuggestGasTipCap(ensureContext(opts.Context))
price, err := c.transactor.SuggestGasPrice(ensureContext(opts.Context))
if err != nil {
return nil, err
}
if head.BaseFee != nil {
price.Add(price, head.BaseFee)
}
opts.GasPrice = price
}
}