From df6f3d7f1ecb6b7ebccd9e469ad188f3363ac799 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Mon, 12 Sep 2022 00:15:07 +0300 Subject: [PATCH] omit (#1686) --- ethers-solc/src/artifacts/mod.rs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/ethers-solc/src/artifacts/mod.rs b/ethers-solc/src/artifacts/mod.rs index c406caea..2e65f0c6 100644 --- a/ethers-solc/src/artifacts/mod.rs +++ b/ethers-solc/src/artifacts/mod.rs @@ -49,6 +49,7 @@ pub(crate) type VersionedSources = BTreeMap; pub(crate) type VersionedFilteredSources = BTreeMap; const SOLIDITY: &str = "Solidity"; +const YUL: &str = "Yul"; /// Input type `solc` expects #[derive(Clone, Debug, Serialize, Deserialize)] @@ -88,7 +89,7 @@ impl CompilerInput { } if !yul_sources.is_empty() { res.push(Self { - language: "Yul".to_string(), + language: YUL.to_string(), sources: yul_sources, settings: Default::default(), }); @@ -137,7 +138,19 @@ impl CompilerInput { /// Sets the settings for compilation #[must_use] - pub fn settings(mut self, settings: Settings) -> Self { + pub fn settings(mut self, mut settings: Settings) -> Self { + if self.is_yul() { + if !settings.remappings.is_empty() { + warn!("omitting remappings supplied for the yul sources"); + settings.remappings = vec![]; + } + if let Some(debug) = settings.debug.as_mut() { + if debug.revert_strings.is_some() { + warn!("omitting revertStrings supplied for the yul sources"); + debug.revert_strings = None; + } + } + } self.settings = settings; self } @@ -168,7 +181,11 @@ impl CompilerInput { #[must_use] pub fn with_remappings(mut self, remappings: Vec) -> Self { - self.settings.remappings = remappings; + if self.is_yul() { + warn!("omitting remappings supplied for the yul sources"); + } else { + self.settings.remappings = remappings; + } self } @@ -200,6 +217,12 @@ impl CompilerInput { self.settings = self.settings.with_base_path(base); self.strip_prefix(base) } + + /// The flag indicating whether the current [CompilerInput] is + /// constructed for the yul sources + pub fn is_yul(&self) -> bool { + self.language == YUL + } } /// A `CompilerInput` representation used for verify