Skip to content
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
4 changes: 4 additions & 0 deletions crates/forge/src/cmd/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ impl CreateArgs {
compiler_version: Some(id.version.to_string()),
constructor_args,
constructor_args_path: None,
no_auto_detect: false,
use_solc: None,
num_of_optimizations: None,
etherscan: EtherscanOpts {
key: self.eth.etherscan.key.clone(),
Expand Down Expand Up @@ -418,6 +420,8 @@ impl CreateArgs {
compiler_version: Some(id.version.to_string()),
constructor_args,
constructor_args_path: None,
no_auto_detect: false,
use_solc: None,
num_of_optimizations,
etherscan: EtherscanOpts { key: self.eth.etherscan.key(), chain: Some(chain.into()) },
rpc: Default::default(),
Expand Down
2 changes: 2 additions & 0 deletions crates/script/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ impl VerifyBundle {
compiler_version: Some(version.to_string()),
constructor_args: Some(hex::encode(constructor_args)),
constructor_args_path: None,
no_auto_detect: false,
use_solc: None,
num_of_optimizations: self.num_of_optimizations,
etherscan: self.etherscan.clone(),
rpc: Default::default(),
Expand Down
33 changes: 33 additions & 0 deletions crates/verify/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ pub struct VerifyArgs {
#[arg(long)]
pub evm_version: Option<EvmVersion>,

/// Do not auto-detect the `solc` version.
#[arg(long, help_heading = "Compiler options")]
pub no_auto_detect: bool,

/// Specify the solc version, or a path to a local solc, to build with.
///
/// Valid values are in the format `x.y.z`, `solc:x.y.z` or `path/to/solc`.
#[arg(long = "use", help_heading = "Compiler options", value_name = "SOLC_VERSION")]
pub use_solc: Option<String>,

#[command(flatten)]
pub etherscan: EtherscanOpts,

Expand Down Expand Up @@ -194,6 +204,15 @@ impl figment::Provider for VerifyArgs {
dict.insert("via_ir".to_string(), figment::value::Value::serialize(self.via_ir)?);
}

if self.no_auto_detect {
dict.insert("auto_detect_solc".to_string(), figment::value::Value::serialize(false)?);
}

if let Some(ref solc) = self.use_solc {
let solc = solc.trim_start_matches("solc:");
dict.insert("solc".to_string(), figment::value::Value::serialize(solc)?);
}

if let Some(api_key) = &self.verifier.verifier_api_key {
dict.insert("etherscan_api_key".into(), api_key.as_str().into());
}
Expand Down Expand Up @@ -523,4 +542,18 @@ mod tests {
]);
assert!(args.via_ir);
}

#[test]
fn can_parse_new_compiler_flags() {
let args: VerifyArgs = VerifyArgs::parse_from([
"foundry-cli",
"0x0000000000000000000000000000000000000000",
"src/Domains.sol:Domains",
"--no-auto-detect",
"--use",
"0.8.23",
]);
assert!(args.no_auto_detect);
assert_eq!(args.use_solc.as_deref(), Some("0.8.23"));
}
}
Loading