Skip to content

Commit 9e79f54

Browse files
authored
fix(forge vb): bail when args expected but none provided (#8764)
fix(forge vb): bail when args are expected but none are provided
1 parent 0d83028 commit 9e79f54

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

crates/verify/src/bytecode.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ impl VerifyBytecodeArgs {
209209
check_explorer_args(source_code.clone())?
210210
};
211211

212+
// This fails only when the contract expects constructor args but NONE were provided OR
213+
// retrieved from explorer (in case of predeploys).
214+
crate::utils::check_args_len(&artifact, &constructor_args)?;
215+
212216
if maybe_predeploy {
213217
if !self.json {
214218
println!(

crates/verify/src/utils.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,21 @@ pub fn check_explorer_args(source_code: ContractMetadata) -> Result<Bytes, eyre:
307307
}
308308
}
309309

310+
pub fn check_args_len(
311+
artifact: &CompactContractBytecode,
312+
args: &Bytes,
313+
) -> Result<(), eyre::ErrReport> {
314+
if let Some(constructor) = artifact.abi.as_ref().and_then(|abi| abi.constructor()) {
315+
if !constructor.inputs.is_empty() && args.len() == 0 {
316+
eyre::bail!(
317+
"Contract expects {} constructor argument(s), but none were provided",
318+
constructor.inputs.len()
319+
);
320+
}
321+
}
322+
Ok(())
323+
}
324+
310325
pub async fn get_tracing_executor(
311326
fork_config: &mut Config,
312327
fork_blk_num: u64,

0 commit comments

Comments
 (0)