-
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): add string-decode to decode string #9237
Conversation
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
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.
sounds reasonable to me
wdyt @grandizzy
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.
makes sense, thank you! @jsvisa could you please also add a test, here's a sample:
foundry/crates/cast/tests/cli/main.rs
Lines 1403 to 1405 in 9d74675
casttest!(parse_units, |_prj, cmd| { | |
cmd.args(["parse-units", "1.5", "6"]).assert_success().stdout_eq(str![[r#" | |
1500000 |
Signed-off-by: jsvisa <delweng@gmail.com>
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.
Applied minor documentation fixes, proposed goal is reasonable + implementation LGTM
* feat(cast): add error-decode to decode error string Signed-off-by: jsvisa <delweng@gmail.com> * feat(cast): error-decode -> string-decode Signed-off-by: jsvisa <delweng@gmail.com> * add test case for string-decode Signed-off-by: jsvisa <delweng@gmail.com> * Apply suggestions from code review --------- Signed-off-by: jsvisa <delweng@gmail.com> Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
Motivation
When I'm debugging some transactions that we reverted, what I got from the tx's trace as below:
And this output is ABI-encode of
Error(string)
, so I think we can add a simple command to decode the ABI-string into human readable msg, for this case:$ ./target/release/cast string-decode 0x88c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000054753303235000000000000000000000000000000000000000000000000000000 "GS025"
Inspired from https://ethereum.stackexchange.com/a/77530
Solution