internal/ethapi: simplify logic
This commit is contained in:
committed by
Péter Szilágyi
parent
024e5a74f2
commit
fbdc6bba66
@ -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, try to unpack and return it.
|
// 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())
|
reason, err := abi.UnpackRevert(res.Revert())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil, fmt.Errorf("execution reverted: %v", reason)
|
return nil, fmt.Errorf("execution reverted: %v", reason)
|
||||||
@ -381,7 +381,7 @@ func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call ethereu
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// If the result contains a revert reason, try to unpack and return it.
|
// 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())
|
reason, err := abi.UnpackRevert(res.Revert())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil, fmt.Errorf("execution reverted: %v", reason)
|
return nil, fmt.Errorf("execution reverted: %v", reason)
|
||||||
|
@ -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)
|
return nil, fmt.Errorf("execution aborted (timeout = %v)", timeout)
|
||||||
}
|
}
|
||||||
// If the result contains a revert reason, try to unpack and return it.
|
// If the result contains a revert reason, try to unpack and return it.
|
||||||
if res.Err != nil && len(res.Revert()) > 0 {
|
if len(result.Revert()) > 0 {
|
||||||
reason, err := abi.UnpackRevert(res.Revert())
|
reason, err := abi.UnpackRevert(result.Revert())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil, fmt.Errorf("execution reverted: %v", reason)
|
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.
|
// Call executes the given transaction on the state for the given block number.
|
||||||
|
Reference in New Issue
Block a user