Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ rand = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true }
ethers-core = { workspace = true }
18 changes: 18 additions & 0 deletions crates/cli/src/args.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use clap_cryo::Parser;
use color_print::cstr;
use colored::Colorize;
use ethers_core::utils::keccak256;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::{default::Default, path::PathBuf};
Expand Down Expand Up @@ -260,9 +261,26 @@ pub struct Args {
/// Event signature for log decoding
#[arg(long, value_name = "tracer", help_heading = "Dataset-specific Options")]
pub js_tracer: Option<String>,
/// Keep raw decoded columns like topic0, topic1, etc.
#[arg(long, help_heading = "Output Options")]
pub keep_raw_decoded: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong PR?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong PR?

hmmmm i'm not sure why this is here, i don't remember have written this, sorry btw

}

impl Args {
/// Converts each function signature in `function` to its corresponding Ethereum function selector
pub fn convert_to_selector_strings(&self) -> Option<Vec<String>> {
if let Some(function_signatures) = &self.function {
let mut selectors = Vec::new();
for signature in function_signatures {
let hash = keccak256(signature);
let selector_string = hex::encode(&hash[0..4]); // Convert to hex string
selectors.push(selector_string);
}
Some(selectors)
} else {
None
}
}
pub(crate) fn merge_with_precedence(self, other: Args) -> Self {
let default_struct = Args::default();

Expand Down
8 changes: 7 additions & 1 deletion crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ use eyre::Result;
#[allow(unreachable_code)]
#[allow(clippy::needless_return)]
async fn main() -> Result<()> {
let args = Args::parse();
let mut args = Args::parse();

// Convert function signatures to selectors
if let Some(selector_strings) = args.convert_to_selector_strings() {
args.function = Some(selector_strings);
}

match run::run(args).await {
Ok(Some(freeze_summary)) if freeze_summary.errored.is_empty() => Ok(()),
Ok(Some(_freeze_summary)) => std::process::exit(1),
Expand Down