Skip to content

Commit d4e91c8

Browse files
authored
feat(cast): allow some more stdin inputs (#9442)
1 parent 168b239 commit d4e91c8

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

crates/cast/bin/args.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ pub enum CastSubcommand {
422422
#[command(visible_alias = "ca")]
423423
ComputeAddress {
424424
/// The deployer address.
425-
address: Option<String>,
425+
address: Option<Address>,
426426

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

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

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

757-
/// Disassemble bytecodes into individual opcodes.
757+
/// Disassemble bytecodes.
758758
#[arg(long, short)]
759759
disassemble: bool,
760760

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

10361036
/// Resolve the function signatures for the extracted selectors using https://openchain.xyz
10371037
#[arg(long, short)]

crates/cast/bin/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,16 @@ async fn main_args(args: CastArgs) -> Result<()> {
380380
let config = Config::from(&rpc);
381381
let provider = utils::get_provider(&config)?;
382382

383-
let address: Address = stdin::unwrap_line(address)?.parse()?;
383+
let address = stdin::unwrap_line(address)?;
384384
let computed = Cast::new(provider).compute_address(address, nonce).await?;
385385
sh_println!("Computed Address: {}", computed.to_checksum(None))?
386386
}
387387
CastSubcommand::Disassemble { bytecode } => {
388+
let bytecode = stdin::unwrap_line(bytecode)?;
388389
sh_println!("{}", SimpleCast::disassemble(&hex::decode(bytecode)?)?)?
389390
}
390391
CastSubcommand::Selectors { bytecode, resolve } => {
392+
let bytecode = stdin::unwrap_line(bytecode)?;
391393
let functions = SimpleCast::extract_functions(&bytecode)?;
392394
let max_args_len = functions.iter().map(|r| r.1.len()).max().unwrap_or(0);
393395
let max_mutability_len = functions.iter().map(|r| r.2.len()).max().unwrap_or(0);

0 commit comments

Comments
 (0)