-
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 abi-decode, min-int #284
Conversation
cli/src/cast_opts.rs
Outdated
#[structopt(help = "the hex data you want to decode")] | ||
abi: String, | ||
hex_calldata: String, | ||
hex_output: String, |
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.
this should not be required? you just need function signature and calldata
Also, |
cast/src/lib.rs
Outdated
let func = foundry_utils::IntoFunction::into(sig); | ||
let mut decoded_input = Ok(vec![]); | ||
let mut decoded_output = Ok(vec![]); | ||
if let Some(mut x) = calldata { |
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.
It doesn't make much sense to pass both inputs and outputs to the same call I think? IMO only take 1 hex string and add a --output bool flag which will trigger decoding using the output instead of the input (vs doing both)
cli/Cargo.toml
Outdated
@@ -25,6 +25,7 @@ ansi_term = "0.12.1" | |||
rpassword = "5.0.1" | |||
tracing-subscriber = "0.2.20" | |||
tracing = "0.1.26" | |||
hex = "*" |
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.
Use a specific version, not *
cli/src/opts/cast.rs
Outdated
#[structopt(short = "c", help = "the encoded calladata, in hex format")] | ||
calldata: Option<String>, | ||
#[structopt(short = "o", help = "the encoded output, in hex format")] | ||
output: Option<String>, |
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.
As written above, I'd make this a boolean flag to trigger output decoding
cli/src/opts/cast.rs
Outdated
help = "the function signature you want to decode, in the format `<name>(<in-types>)(<out-types>)`" | ||
)] | ||
sig: String, | ||
#[structopt(short = "c", help = "the encoded calladata, in hex format")] |
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.
Make this a positional argument (remove the long/short). Also there's a typo in the doc "calldata"
cli/src/cast.rs
Outdated
Subcommands::AbiDecode { sig, calldata, output } => { | ||
let (input, output) = SimpleCast::abi_decode(sig, calldata, output); | ||
if let Ok(x) = input { | ||
println!("Calldata: {:?}", x); |
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.
Remove the "Calldata" part and pls use the Display impl, not the Debug
* chore: cherry pick commits * feat: abi-decode * chore: lint * chore: move abi-decode logic to SimpleCast impl * chore: add doc test for abi-decode * feat min --int, add doc output tst to abi_decode * chore: cargo fmt, clippy, Cargo.lock * chore: update README * chore: simplify abi-decode impl * feat(cast): --calldata-decode and adjust abi-decode cli cmd * chore: typo Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
seth abi-decode
andseth calldata-decode
into a single command)