From fbdc6bba6608a197521f9563bd05a6363329fdb2 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 21 May 2020 15:33:27 +0200 Subject: [PATCH] internal/ethapi: simplify logic --- accounts/abi/bind/backends/simulated.go | 4 ++-- internal/ethapi/api.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index c55b494485..78e14cc09d 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -361,7 +361,7 @@ func (b *SimulatedBackend) CallContract(ctx context.Context, call ethereum.CallM return nil, err } // If the result contains a revert reason, try to unpack and return it. - if res.Err != nil && len(res.Revert()) > 0 { + if len(res.Revert()) > 0 { reason, err := abi.UnpackRevert(res.Revert()) if err == nil { return nil, fmt.Errorf("execution reverted: %v", reason) @@ -381,7 +381,7 @@ func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call ethereu return nil, err } // If the result contains a revert reason, try to unpack and return it. - if res.Err != nil && len(res.Revert()) > 0 { + if len(res.Revert()) > 0 { reason, err := abi.UnpackRevert(res.Revert()) if err == nil { return nil, fmt.Errorf("execution reverted: %v", reason) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 563250ea1e..6611da650c 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -862,13 +862,13 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo return nil, fmt.Errorf("execution aborted (timeout = %v)", timeout) } // If the result contains a revert reason, try to unpack and return it. - if res.Err != nil && len(res.Revert()) > 0 { - reason, err := abi.UnpackRevert(res.Revert()) + if len(result.Revert()) > 0 { + reason, err := abi.UnpackRevert(result.Revert()) if err == nil { return nil, fmt.Errorf("execution reverted: %v", reason) } } - return result, res.Err + return result, result.Err } // Call executes the given transaction on the state for the given block number.