internal/ethapi: unified handling of errors in DoEstimateGas
This commit is contained in:
committed by
Péter Szilágyi
parent
693db4dc17
commit
5048fd1028
@ -999,19 +999,16 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
|
|||||||
}
|
}
|
||||||
if failed {
|
if failed {
|
||||||
if result != nil && result.Err != vm.ErrOutOfGas {
|
if result != nil && result.Err != vm.ErrOutOfGas {
|
||||||
var revert string
|
|
||||||
if len(result.Revert()) > 0 {
|
if len(result.Revert()) > 0 {
|
||||||
ret, err := abi.UnpackRevert(result.Revert())
|
reason, err := abi.UnpackRevert(result.Revert())
|
||||||
if err != nil {
|
if err == nil {
|
||||||
revert = hexutil.Encode(result.Revert())
|
return 0, &revertError{
|
||||||
} else {
|
error: errors.New("execution reverted"),
|
||||||
revert = ret
|
errData: reason,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0, revertError{
|
|
||||||
error: errors.New("always failing transaction"),
|
|
||||||
errData: revert,
|
|
||||||
}
|
}
|
||||||
|
return 0, result.Err
|
||||||
}
|
}
|
||||||
// Otherwise, the specified gas cap is too low
|
// Otherwise, the specified gas cap is too low
|
||||||
return 0, fmt.Errorf("gas required exceeds allowance (%d)", cap)
|
return 0, fmt.Errorf("gas required exceeds allowance (%d)", cap)
|
||||||
|
Reference in New Issue
Block a user