Skip to content
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

Merged
merged 11 commits into from
Dec 26, 2021
Merged

Conversation

odyslam
Copy link
Contributor

@odyslam odyslam commented Dec 22, 2021

  • min-int
  • abi-decode (combines seth abi-decode and seth calldata-decode into a single command)

@odyslam odyslam mentioned this pull request Dec 23, 2021
#[structopt(help = "the hex data you want to decode")]
abi: String,
hex_calldata: String,
hex_output: String,
Copy link
Member

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

cli/src/cast.rs Outdated Show resolved Hide resolved
cli/src/cast_opts.rs Outdated Show resolved Hide resolved
cli/src/cast_opts.rs Outdated Show resolved Hide resolved
cli/src/cast.rs Outdated Show resolved Hide resolved
@gakonst
Copy link
Member

gakonst commented Dec 23, 2021

Also, max_int won't be necessary given that it was done in #285

@odyslam odyslam changed the title feat: cast parity PR feat: cast abi-decode, min-int Dec 24, 2021
@odyslam odyslam marked this pull request as ready for review December 25, 2021 16:55
@odyslam odyslam requested a review from gakonst December 25, 2021 16:55
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 {
Copy link
Member

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 = "*"
Copy link
Member

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 *

#[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>,
Copy link
Member

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

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")]
Copy link
Member

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);
Copy link
Member

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

@gakonst gakonst merged commit a1dd429 into foundry-rs:master Dec 26, 2021
clifton pushed a commit to clifton/foundry that referenced this pull request Dec 27, 2021
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants