diff --git a/src/cli.rs b/src/cli.rs index b1c95ce..dd8119c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -141,6 +141,10 @@ pub struct MutateParams { #[serde(default = "default_solc_optimize")] pub solc_optimize: bool, + /// Run solc with the `--evm-version` flag + #[arg(long)] + pub solc_evm_version: Option, + /// Specify function names to mutate #[arg(long, num_args(1..))] pub functions: Option>, diff --git a/src/compile.rs b/src/compile.rs index c266265..bd0cfee 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -20,6 +20,7 @@ static INCLUDEPATH: &str = "--include-path"; static BASEPATH: &str = "--base-path"; static OPTIMIZE: &str = "--optimize"; static DOT_JSON: &str = ".json"; +static EVM_VERSION: &str = "--evm-version"; /// Compilation configurations. This exists across compilations of individual /// files @@ -33,6 +34,7 @@ pub struct Solc { include_path: Option, remappings: Option>, optimize: bool, + evm_version: Option, } impl Solc { @@ -45,6 +47,7 @@ impl Solc { include_path: None, remappings: None, optimize: false, + evm_version: None, } } @@ -52,13 +55,6 @@ impl Solc { &self.output_directory } - pub fn basepath(&self) -> Option<&String> { - match &self.basepath { - Some(bp) => Some(bp), - None => None, - } - } - pub fn with_basepath(&mut self, basepath: String) -> &Self { self.basepath = Some(basepath); self @@ -83,6 +79,11 @@ impl Solc { self.optimize = optimize; self } + + pub fn with_evm_version(&mut self, evm_version: String) -> &Self { + self.evm_version = Some(evm_version); + self + } } impl Solc { @@ -320,6 +321,11 @@ impl Solc { flags.push(OPTIMIZE.into()); } + if let Some(evm_version) = &self.evm_version { + flags.push(EVM_VERSION.into()); + flags.push(evm_version.clone()); + } + flags } } diff --git a/src/mutator.rs b/src/mutator.rs index 6d05831..82571b5 100644 --- a/src/mutator.rs +++ b/src/mutator.rs @@ -75,6 +75,10 @@ impl From<&MutateParams> for Mutator { .into(), ); solc.with_optimize(value.solc_optimize); + + if let Some(evm_version) = value.solc_evm_version.clone() { + solc.with_evm_version(evm_version); + } if let Some(basepath) = value.solc_base_path.clone() { solc.with_basepath(basepath); }