Skip to content

Commit

Permalink
Remove unneeded clone
Browse files Browse the repository at this point in the history
  • Loading branch information
pawurb committed Nov 11, 2024
1 parent 83559eb commit 6f50c3c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 4 additions & 3 deletions crates/cast/bin/cmd/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ impl ArtifactArgs {
let config = Config::from(&rpc);
let provider = utils::get_provider(&config)?;

let abi = if let Some(abi_path) = abi_path.clone() {
load_abi_from_file(&abi_path, None)?
let abi = if let Some(ref abi_path) = abi_path {
load_abi_from_file(abi_path, None)?
} else {
fetch_abi_from_etherscan(contract, &etherscan).await?
};
Expand All @@ -67,7 +67,8 @@ impl ArtifactArgs {

let bytecode = fetch_creation_code(contract, client, provider).await?;
let bytecode =
parse_code_output(bytecode, contract, &etherscan, abi_path, true, false).await?;
parse_code_output(bytecode, contract, &etherscan, abi_path.as_deref(), true, false)
.await?;

let artifact = json!({
"abi": abi,
Expand Down
16 changes: 11 additions & 5 deletions crates/cast/bin/cmd/creation_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ impl CreationCodeArgs {

let bytecode = fetch_creation_code(contract, client, provider).await?;

let bytecode =
parse_code_output(bytecode, contract, &etherscan, abi_path, without_args, only_args)
.await?;
let bytecode = parse_code_output(
bytecode,
contract,
&etherscan,
abi_path.as_deref(),
without_args,
only_args,
)
.await?;

if disassemble {
let _ = sh_println!("{}", SimpleCast::disassemble(&bytecode)?);
Expand All @@ -81,7 +87,7 @@ pub async fn parse_code_output(
bytecode: Bytes,
contract: Address,
etherscan: &EtherscanOpts,
abi_path: Option<String>,
abi_path: Option<&str>,
without_args: bool,
only_args: bool,
) -> Result<Bytes> {
Expand All @@ -90,7 +96,7 @@ pub async fn parse_code_output(
}

let abi = if let Some(abi_path) = abi_path {
load_abi_from_file(&abi_path, None)?
load_abi_from_file(abi_path, None)?
} else {
fetch_abi_from_etherscan(contract, etherscan).await?
};
Expand Down

0 comments on commit 6f50c3c

Please sign in to comment.