Skip to content

Commit

Permalink
Code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pawurb committed Oct 4, 2024
1 parent fc1715a commit aa0bca6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/cast/bin/cmd/creation_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl CreationCodeArgs {
let config = Config::from(&rpc);
let provider = utils::get_provider(&config)?;

let bytecode = fetch_creation_code(contract, client, &Arc::new(provider)).await?;
let bytecode = fetch_creation_code(contract, client, provider).await?;

if disassemble {
print!("{}", format_operations(disassemble_bytes(bytecode.into())?)?);
Expand All @@ -54,10 +54,12 @@ impl CreationCodeArgs {
}

/// Fetches the creation code of a contract from Etherscan and RPC.
///
/// If present, constructor arguments are appended to the end of the bytecode.
async fn fetch_creation_code(
contract: Address,
client: Client,
provider: &Arc<RetryProvider>,
provider: RetryProvider,
) -> Result<Bytes> {
let creation_data = client.contract_creation_data(contract).await?;
let creation_tx_hash = creation_data.transaction_hash;
Expand All @@ -72,7 +74,9 @@ async fn fetch_creation_code(
// Extract creation code from tx traces
let mut creation_bytecode = None;

let traces = provider.trace_transaction(creation_tx_hash).await?;
let traces = provider.trace_transaction(creation_tx_hash).await.map_err(|e| {
eyre::eyre!("Could not fetch traces for transaction {}: {}", creation_tx_hash, e)
})?;

for trace in traces {
if let Some(TraceOutput::Create(CreateOutput { address, code: _, gas_used: _ })) =
Expand Down

0 comments on commit aa0bca6

Please sign in to comment.