accounts/abi/bind: fix error handling in baseFee query (#23781)

This fixes a panic that occurs when HeaderByNumber() returns an error.
This commit is contained in:
KibGzr 2021-10-21 16:40:35 +07:00 committed by GitHub
parent 3ce9f6d96f
commit b6fb18479c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -370,7 +370,7 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
rawTx, err = c.createLegacyTx(opts, contract, input) rawTx, err = c.createLegacyTx(opts, contract, input)
} else { } else {
// Only query for basefee if gasPrice not specified // Only query for basefee if gasPrice not specified
if head, errHead := c.transactor.HeaderByNumber(ensureContext(opts.Context), nil); err != nil { if head, errHead := c.transactor.HeaderByNumber(ensureContext(opts.Context), nil); errHead != nil {
return nil, errHead return nil, errHead
} else if head.BaseFee != nil { } else if head.BaseFee != nil {
rawTx, err = c.createDynamicTx(opts, contract, input, head) rawTx, err = c.createDynamicTx(opts, contract, input, head)