Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pawurb committed Oct 10, 2024
1 parent de63657 commit fd6ee4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions crates/cast/bin/cmd/creation_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use foundry_config::Config;

use super::{creation_code::fetch_creation_code, interface::fetch_abi_from_etherscan};

/// CLI arguments for `cast creation-code`.
/// CLI arguments for `cast creation-args`.
#[derive(Parser)]
pub struct CreationArgsArgs {
/// An Ethereum address, for which the bytecode will be fetched.
Expand Down Expand Up @@ -46,6 +46,7 @@ impl CreationArgsArgs {
}
}

/// Fetches the constructor arguments values and types from the creation bytecode and ABI.
async fn parse_creation_args(
bytecode: Bytes,
contract: Address,
Expand All @@ -60,13 +61,11 @@ async fn parse_creation_args(
}

let constructor = abi.constructor.unwrap();

if constructor.inputs.is_empty() {
return Err(eyre::eyre!("No constructor arguments found."));
}

let args_size = constructor.inputs.len() * 32;

let args_bytes = Bytes::from(bytecode[bytecode.len() - args_size..].to_vec());

let display_args: Vec<String> = args_bytes
Expand Down
5 changes: 2 additions & 3 deletions crates/cast/bin/cmd/creation_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ impl CreationCodeArgs {
}
}

/// Parses the creation bytecode to return either the bytecode, or bytecoe without constructor
/// arguments or only the constructor arguments.
async fn parse_code_output(
bytecode: Bytes,
contract: Address,
Expand All @@ -92,7 +94,6 @@ async fn parse_code_output(
}

let constructor = abi.constructor.unwrap();

if constructor.inputs.is_empty() {
if only_args {
return Err(eyre::eyre!("No constructor arguments found."));
Expand All @@ -114,8 +115,6 @@ async fn parse_code_output(
}

/// Fetches the creation code of a contract from Etherscan and RPC.
///
/// If present, constructor arguments are appended to the end of the bytecode.
pub async fn fetch_creation_code(
contract: Address,
client: Client,
Expand Down

0 comments on commit fd6ee4e

Please sign in to comment.