internal/ethapi: return revert reason for eth_call

This commit is contained in:
Marius van der Wijden 2020-05-14 13:32:45 +02:00 committed by Péter Szilágyi
parent 4b2ff1457a
commit fd70cfe87a
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
1 changed files with 8 additions and 0 deletions

View File

@ -861,6 +861,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
if evm.Cancelled() {
return nil, fmt.Errorf("execution aborted (timeout = %v)", timeout)
}
return result, err
}
@ -879,6 +880,13 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOr
if err != nil {
return nil, err
}
if result.Err != nil {
reason, err := abi.UnpackRevert(result.Revert())
if err != nil {
return result.Return(), err
}
return result.Return(), errors.New(reason)
}
return result.Return(), nil
}