-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(cast): cast send tries to decode custom errors #8860
base: master
Are you sure you want to change the base?
Conversation
Thinking it solves #8603 as well |
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.
Thanks for your PR! LGTM
Confirming previously:
cast send 0x5FbDB2315678afecb367f032d93F642f64180aa3 "setValue(uint256)" 101 --private-key=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Error:
server returned an error response: error code 3: execution reverted: custom error 0x7a0e1985: ed, data: "0x7a0e198500000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000064"
cast send 0x5FbDB2315678afecb367f032d93F642f64180aa3 "setValue(uint256)" 101 --private-key=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Error:
Reverted with custom error:
Possible methods:
- ValueTooHigh(uint256,uint256)
------------
[000]: 0000000000000000000000000000000000000000000000000000000000000065
[020]: 0000000000000000000000000000000000000000000000000000000000000064
Context:
- server returned an error response: error code 3: execution reverted: custom error 0x7a0e1985: ed, data: "0x7a0e198500000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000064"
You can try in Sepolia at https://sepolia.etherscan.io/address/0xbabec3df164f14672c08aa277af9936532c283ba (verified for debugging) UnknownError (not uploaded in OpenChain Signatures)
KnownError (uploaded in OpenChain Signatures)
|
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 would worth adding a test similar with this one which starts anvil
foundry/crates/cast/tests/cli/main.rs
Lines 1290 to 1294 in ccabf8b
casttest!(send_eip7702, async |_prj, cmd| { | |
let (_api, handle) = | |
anvil::spawn(NodeConfig::test().with_hardfork(Some(EthereumHardfork::PragueEOF.into()))) | |
.await; | |
let endpoint = handle.http_endpoint(); |
, deploys contract, calls a fn that always revert with a custom error and make sure output is expected
foundry/crates/cast/tests/cli/main.rs
Lines 1308 to 1312 in ccabf8b
cmd.cast_fuse() | |
.args(["code", "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "--rpc-url", &endpoint]) | |
.assert_success() | |
.stdout_eq(str![[r#" | |
0xef010070997970c51812dc3a010c7d01b50e0d17dc79c8 |
Since #8603 is mentioned, I see in issue description that reporter says custom error used to be displayed in old version of cast, so wonder if it's not only a regression and could avoid fetching signatures from openchain...
Sounds good, will add
Yep, that was eventually fixed. The addition to fetch signatures from openchain I added to make those more readable when possible. It's opinionated of course, but I think it improves the ux. |
88b9ddc
to
62e596f
Compare
@grandizzy any idea why my test keeps failing? Seems like something is missing and I cannot figure it out |
you can run test with SNAPSHOTS=override but since that's not relevant for test you could just redact as .stderr_eq(str![[r#"
Error:
Reverted with custom error:
Possible methods:
- ValueTooHigh(uint256,uint256)
------------
[000]: 0000000000000000000000000000000000000000000000000000000000000065
[020]: 0000000000000000000000000000000000000000000000000000000000000064
...
"#]]); |
7d04af4
to
8bbfbb6
Compare
Fixed, thanks @grandizzy |
8bbfbb6
to
7845009
Compare
798c8f9
to
7cde6d1
Compare
7a0ce4d
to
9e05f8a
Compare
9e05f8a
to
c6acc83
Compare
Co-authored-by: Howard [email protected]
Motivation
Even though issue #8606 is partially solved, this would be an improvement over the UX. Only applies this for custom errors
Nightly cast send:
Our PR:
Solution
Using pretty_calldata to decode the custom error.