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): allow some more stdin inputs #9442

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions crates/cast/bin/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ pub enum CastSubcommand {
#[command(visible_alias = "ca")]
ComputeAddress {
/// The deployer address.
address: Option<String>,
address: Option<Address>,

/// The nonce of the deployer address.
#[arg(long)]
Expand All @@ -432,11 +432,11 @@ pub enum CastSubcommand {
rpc: RpcOpts,
},

/// Disassembles hex encoded bytecode into individual / human readable opcodes
/// Disassembles a hex-encoded bytecode into a human-readable representation.
#[command(visible_alias = "da")]
Disassemble {
/// The hex encoded bytecode.
bytecode: String,
/// The hex-encoded bytecode.
bytecode: Option<String>,
},

/// Build and sign a transaction.
Expand Down Expand Up @@ -754,7 +754,7 @@ pub enum CastSubcommand {
#[arg(value_parser = NameOrAddress::from_str)]
who: NameOrAddress,

/// Disassemble bytecodes into individual opcodes.
/// Disassemble bytecodes.
#[arg(long, short)]
disassemble: bool,

Expand Down Expand Up @@ -1030,8 +1030,8 @@ pub enum CastSubcommand {
/// Extracts function selectors and arguments from bytecode
#[command(visible_alias = "sel")]
Selectors {
/// The hex encoded bytecode.
bytecode: String,
/// The hex-encoded bytecode.
bytecode: Option<String>,

/// Resolve the function signatures for the extracted selectors using https://openchain.xyz
#[arg(long, short)]
Expand Down
4 changes: 3 additions & 1 deletion crates/cast/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,16 @@ async fn main_args(args: CastArgs) -> Result<()> {
let config = Config::from(&rpc);
let provider = utils::get_provider(&config)?;

let address: Address = stdin::unwrap_line(address)?.parse()?;
let address = stdin::unwrap_line(address)?;
let computed = Cast::new(provider).compute_address(address, nonce).await?;
sh_println!("Computed Address: {}", computed.to_checksum(None))?
}
CastSubcommand::Disassemble { bytecode } => {
let bytecode = stdin::unwrap_line(bytecode)?;
sh_println!("{}", SimpleCast::disassemble(&hex::decode(bytecode)?)?)?
}
CastSubcommand::Selectors { bytecode, resolve } => {
let bytecode = stdin::unwrap_line(bytecode)?;
let functions = SimpleCast::extract_functions(&bytecode)?;
let max_args_len = functions.iter().map(|r| r.1.len()).max().unwrap_or(0);
let max_mutability_len = functions.iter().map(|r| r.2.len()).max().unwrap_or(0);
Expand Down