Skip to content
Open
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
20 changes: 16 additions & 4 deletions crates/cast/src/cmd/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ pub struct StorageArgs {

#[command(flatten)]
build: BuildOpts,

/// Specify the solc version to compile with. Overrides detected version.
#[arg(long, value_parser = Version::parse)]
solc_version: Option<Version>,
}

impl_figment_convert_cast!(StorageArgs);
Expand Down Expand Up @@ -161,11 +165,19 @@ impl StorageArgs {
let mut project = etherscan_project(metadata, root_path)?;
add_storage_layout_output(&mut project);

project.compiler = if auto_detect {
SolcCompiler::AutoDetect
// Override solc version if provided
if let Some(solc_req) = self.solc_version {
// Use user-specified version
let solc = Solc::find_or_install(&solc_req)?;
project.compiler = SolcCompiler::Specific(solc);
} else {
SolcCompiler::Specific(Solc::find_or_install(&version)?)
};
// Auto-detect or use metadata version
project.compiler = if auto_detect {
SolcCompiler::AutoDetect
} else {
SolcCompiler::Specific(Solc::find_or_install(&version)?)
};
}

// Compile
let mut out = ProjectCompiler::new().quiet(true).compile(&project)?;
Expand Down
Loading