internal/ethapi: check if require reason can be unpacked

This commit is contained in:
Marius van der Wijden
2020-05-15 10:06:23 +02:00
committed by Péter Szilágyi
parent 05eb3d5f0f
commit 92bee6b037
2 changed files with 3 additions and 3 deletions

View File

@ -361,7 +361,7 @@ func (b *SimulatedBackend) CallContract(ctx context.Context, call ethereum.CallM
return nil, err return nil, err
} }
// If the result contains a revert reason, unpack and return it. // If the result contains a revert reason, unpack and return it.
if res.Err != nil { if res.Err != nil && len(res.Revert()) > 0 {
reason, err := abi.UnpackRevert(res.Revert()) reason, err := abi.UnpackRevert(res.Revert())
if err != nil { if err != nil {
return nil, err return nil, err
@ -382,7 +382,7 @@ func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call ethereu
return nil, err return nil, err
} }
// If the result contains a revert reason, unpack and return it. // If the result contains a revert reason, unpack and return it.
if res.Err != nil { if res.Err != nil && len(res.Revert()) > 0 {
reason, err := abi.UnpackRevert(res.Revert()) reason, err := abi.UnpackRevert(res.Revert())
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -862,7 +862,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
return nil, fmt.Errorf("execution aborted (timeout = %v)", timeout) return nil, fmt.Errorf("execution aborted (timeout = %v)", timeout)
} }
// If the result contains a revert reason, unpack and return it. // If the result contains a revert reason, unpack and return it.
if result.Err != nil { if result.Err != nil && len(result.Revert()) > 0 {
reason, err := abi.UnpackRevert(result.Revert()) reason, err := abi.UnpackRevert(result.Revert())
if err != nil { if err != nil {
return nil, err return nil, err