Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[forge] verify-contract: support --via-ir flag #6781

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/forge/bin/cmd/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ impl CreateArgs {
libraries: vec![],
root: None,
verifier: self.verifier.clone(),
via_ir: self.opts.via_ir,
show_standard_json_input: self.show_standard_json_input,
};

Expand Down Expand Up @@ -335,6 +336,7 @@ impl CreateArgs {
libraries: vec![],
root: None,
verifier: self.verifier,
via_ir: self.opts.via_ir,
show_standard_json_input: self.show_standard_json_input,
};
println!("Waiting for {} to detect contract deployment...", verify.verifier.verifier);
Expand Down
5 changes: 5 additions & 0 deletions crates/forge/bin/cmd/script/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct VerifyBundle {
pub etherscan: EtherscanOpts,
pub retry: RetryArgs,
pub verifier: VerifierArgs,
pub via_ir: bool,
}

impl VerifyBundle {
Expand All @@ -44,13 +45,16 @@ impl VerifyBundle {
config_path: if config_path.exists() { Some(config_path) } else { None },
};

let via_ir = config.via_ir;

VerifyBundle {
num_of_optimizations,
known_contracts,
etherscan: Default::default(),
project_paths,
retry,
verifier,
via_ir,
}
}

Expand Down Expand Up @@ -109,6 +113,7 @@ impl VerifyBundle {
libraries: libraries.to_vec(),
root: None,
verifier: self.verifier.clone(),
via_ir: self.via_ir,
show_standard_json_input: false,
};

Expand Down
18 changes: 18 additions & 0 deletions crates/forge/bin/cmd/verify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ pub struct VerifyArgs {

#[clap(flatten)]
pub verifier: VerifierArgs,

/// Use the Yul intermediate representation compilation pipeline.
#[clap(long)]
pub via_ir: bool,
}

impl_figment_convert!(VerifyArgs);
Expand All @@ -129,6 +133,9 @@ impl figment::Provider for VerifyArgs {
figment::value::Value::serialize(optimizer_runs)?,
);
}
if self.via_ir {
dict.insert("via_ir".to_string(), figment::value::Value::serialize(self.via_ir)?);
}
Ok(figment::value::Map::from([(Config::selected_profile(), dict)]))
}
}
Expand Down Expand Up @@ -238,4 +245,15 @@ mod tests {
assert!(is_host_only(&Url::parse("https://blockscout.net/").unwrap()));
assert!(is_host_only(&Url::parse("https://blockscout.net").unwrap()));
}

#[test]
fn can_parse_verify_contract() {
let args: VerifyArgs = VerifyArgs::parse_from([
"foundry-cli",
"0x0000000000000000000000000000000000000000",
"src/Domains.sol:Domains",
"--via-ir",
]);
assert!(args.via_ir);
}
}
Loading