accounts/abi/bind/backends: added revert reason logic to simulated backend
This commit is contained in:
parent
6d13d42e71
commit
23312e0716
|
@ -360,6 +360,14 @@ func (b *SimulatedBackend) CallContract(ctx context.Context, call ethereum.CallM
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// If the result contains a revert reason, unpack and return it.
|
||||||
|
if res.Err != nil {
|
||||||
|
reason, err := abi.UnpackRevert(res.Revert())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("execution reverted: %v", reason)
|
||||||
|
}
|
||||||
return res.Return(), nil
|
return res.Return(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,6 +381,14 @@ func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call ethereu
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// If the result contains a revert reason, unpack and return it.
|
||||||
|
if res.Err != nil {
|
||||||
|
reason, err := abi.UnpackRevert(res.Revert())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("execution reverted: %v", reason)
|
||||||
|
}
|
||||||
return res.Return(), nil
|
return res.Return(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue