From aa0bca63b2e2fc204a854657e35893f6cd037511 Mon Sep 17 00:00:00 2001 From: pawurb Date: Fri, 4 Oct 2024 17:31:16 +0200 Subject: [PATCH] Code review fixes --- crates/cast/bin/cmd/creation_code.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/cast/bin/cmd/creation_code.rs b/crates/cast/bin/cmd/creation_code.rs index d8c9b440474ce..383a53d173ab2 100644 --- a/crates/cast/bin/cmd/creation_code.rs +++ b/crates/cast/bin/cmd/creation_code.rs @@ -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())?)?); @@ -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, + provider: RetryProvider, ) -> Result { let creation_data = client.contract_creation_data(contract).await?; let creation_tx_hash = creation_data.transaction_hash; @@ -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: _ })) =