Skip to content

Commit

Permalink
add sig identifier to cast run (foundry-rs#2047)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshieDo authored Jun 21, 2022
1 parent 103b12a commit 8b33ded
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
5 changes: 4 additions & 1 deletion cli/src/cmd/cast/run.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{cmd::Cmd, utils, utils::consume_config_rpc_url};
use cast::trace::CallTraceDecoder;
use cast::trace::{identifier::SignaturesIdentifier, CallTraceDecoder};
use clap::Parser;
use ethers::{
abi::Address,
Expand Down Expand Up @@ -163,6 +163,9 @@ impl RunArgs {

let mut decoder = CallTraceDecoderBuilder::new().with_labels(labeled_addresses).build();

decoder
.add_signature_identifier(SignaturesIdentifier::new(Config::foundry_cache_dir())?);

for (_, trace) in &mut result.traces {
decoder.identify(trace, &etherscan_identifier);
}
Expand Down
18 changes: 11 additions & 7 deletions evm/src/trace/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,17 @@ impl CallTraceNode {
if let Some(tokens) =
funcs.iter().find_map(|func| func.decode_output(&bytes[..]).ok())
{
self.trace.output = RawOrDecodedReturnData::Decoded(
tokens
.iter()
.map(|token| utils::label(token, labels))
.collect::<Vec<_>>()
.join(", "),
);
// Functions coming from an external database do not have any outputs
// specified, and will lead to returning an empty list of tokens.
if !tokens.is_empty() {
self.trace.output = RawOrDecodedReturnData::Decoded(
tokens
.iter()
.map(|token| utils::label(token, labels))
.collect::<Vec<_>>()
.join(", "),
);
}
}
} else if let Ok(decoded_error) =
foundry_utils::decode_revert(&bytes[..], Some(errors))
Expand Down

0 comments on commit 8b33ded

Please sign in to comment.