forked from forks/go-ethereum
internal/ethapi: unified handling of errors in DoEstimateGas
This commit is contained in:
parent
693db4dc17
commit
5048fd1028
1 changed files with 7 additions and 10 deletions
|
|
@ -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{
|
return 0, result.Err
|
||||||
error: errors.New("always failing transaction"),
|
|
||||||
errData: revert,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 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)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue