Skip to content

Commit 0369ceb

Browse files
committed
refactor(forge): address review comments on verify-bytecode no-explorer PR
1 parent 72dd0f6 commit 0369ceb

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

crates/verify/src/bytecode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl VerifyBytecodeArgs {
287287
};
288288

289289
// Obtain Etherscan compilation metadata.
290-
let etherscan_metadata = source_code.as_ref().map(|source| source.items.first().unwrap());
290+
let etherscan_metadata = source_code.as_ref().and_then(|source| source.items.first());
291291

292292
// The EVM version to verify against: the explorer-reported version when available,
293293
// otherwise the local project configuration.
@@ -321,7 +321,7 @@ impl VerifyBytecodeArgs {
321321
provided.into()
322322
} else if let Some(source_code) = &source_code {
323323
// If no constructor args were provided, try to retrieve them from the explorer.
324-
check_explorer_args(source_code.clone())?
324+
check_explorer_args(source_code)?
325325
} else {
326326
Bytes::new()
327327
};
@@ -369,7 +369,7 @@ impl VerifyBytecodeArgs {
369369
.await?;
370370

371371
evm_env.block_env.set_number(U256::from(deploy_block));
372-
let genesis_block = provider.get_block(deploy_block.into()).full().await?;
372+
let deploy_block_info = provider.get_block(deploy_block.into()).full().await?;
373373

374374
// Setup genesis tx_env and evm_evm.
375375
let deployer = Address::with_last_byte(0x1);
@@ -381,7 +381,7 @@ impl VerifyBytecodeArgs {
381381
tx_env.set_gas_limit(evm_env.block_env.gas_limit());
382382
tx_env.set_gas_price(evm_env.block_env.basefee() as u128);
383383

384-
if let Some(ref block) = genesis_block {
384+
if let Some(ref block) = deploy_block_info {
385385
configure_env_block::<FEN>(&mut evm_env, block, config.networks);
386386
tx_env.set_gas_limit(block.header().gas_limit());
387387
tx_env.set_gas_price(block.header().base_fee_per_gas().unwrap_or_default() as u128);

crates/verify/src/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub fn print_result(
103103
res: Option<VerificationType>,
104104
bytecode_type: BytecodeType,
105105
json_results: &mut Vec<JsonResult>,
106-
etherscan_config: Option<&Metadata>,
106+
etherscan_metadata: Option<&Metadata>,
107107
config: &Config,
108108
) {
109109
if let Some(res) = res {
@@ -121,8 +121,8 @@ pub fn print_result(
121121
let _ = sh_err!(
122122
"{bytecode_type:?} code did not match - this may be due to varying compiler settings"
123123
);
124-
if let Some(etherscan_config) = etherscan_config {
125-
let mismatches = find_mismatch_in_settings(etherscan_config, config);
124+
if let Some(etherscan_metadata) = etherscan_metadata {
125+
let mismatches = find_mismatch_in_settings(etherscan_metadata, config);
126126
for mismatch in mismatches {
127127
let _ = sh_eprintln!("{}", mismatch.red().bold());
128128
}
@@ -241,7 +241,7 @@ pub fn check_and_encode_args(
241241
}
242242
}
243243

244-
pub fn check_explorer_args(source_code: ContractMetadata) -> Result<Bytes, eyre::ErrReport> {
244+
pub fn check_explorer_args(source_code: &ContractMetadata) -> Result<Bytes, eyre::ErrReport> {
245245
if let Some(args) = source_code.items.first() {
246246
Ok(args.constructor_arguments.clone())
247247
} else {

0 commit comments

Comments
 (0)