internal/ethapi: return ethapi.revertError from DoCall/DoEstimateGas even if a revert reason was not supplied

This commit is contained in:
Jared Wasinger 2025-03-22 13:32:34 +01:00
parent 624a5d8b23
commit a8c7e1f6ed

View file

@ -761,8 +761,7 @@ func (api *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockN
if err != nil { if err != nil {
return nil, err return nil, err
} }
// If the result contains a revert reason, try to unpack and return it. if errors.Is(result.Err, vm.ErrExecutionReverted) {
if len(result.Revert()) > 0 {
return nil, newRevertError(result.Revert()) return nil, newRevertError(result.Revert())
} }
return result.Return(), result.Err return result.Return(), result.Err
@ -842,7 +841,7 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
// Run the gas estimation and wrap any revertals into a custom return // Run the gas estimation and wrap any revertals into a custom return
estimate, revert, err := gasestimator.Estimate(ctx, call, opts, gasCap) estimate, revert, err := gasestimator.Estimate(ctx, call, opts, gasCap)
if err != nil { if err != nil {
if len(revert) > 0 { if errors.Is(err, vm.ErrExecutionReverted) {
return 0, newRevertError(revert) return 0, newRevertError(revert)
} }
return 0, err return 0, err