-
Notifications
You must be signed in to change notification settings - Fork 20.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ethclient: add RevertErrorData function and example #30669
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm
} | ||
fmt.Println("message:", message) | ||
|
||
// Output: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should test for the message here, otherwise the test only tests that the revert unpacking doesn't error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go checks the output of example functions. The comment here declares the expected output. If there is a mismatch, the example fails during go test
.
Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
This is done to make the RevertErrorData example code look better.
Here I'm adding a new helper function that extracts the revert reason of a contract call. Unfortunately, this aspect of the API is underspecified. See these spec issues for more detail: - ethereum/execution-apis#232 - ethereum/execution-apis#463 - ethereum/execution-apis#523 The function added here only works with Geth-like servers that return error code `3`. We will not be able to support all possible servers. However, if there is a specific server implementation that makes it possible to extract the same info, we could add it in the same function as well. --------- Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Here I'm adding a new helper function that extracts the revert reason of a contract call.
Unfortunately, this aspect of the API is underspecified. See these spec issues for more detail:
eth_call
underspecified return error message execution-apis#463eth_sendTransaction
,eth_sendRawTransaction
andeth_estimateGas
execution-apis#523The function added here only works with Geth-like servers that return error code
3
. We will not be able to support all possible servers. However, if there is a specific server implementation that makes it possible to extract the same info, we could add it in the same function as well.