From b3fed152a44ecdcc92cf457a5d873d04eddbec33 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Tue, 16 Nov 2021 23:25:39 +0000 Subject: [PATCH] fix(solc): do not unnecessarily query for solc version (#586) The parameter is not used in any useful way currently, and it prevents us from using clean installations of SVM which do not have an instantiated /Users/gakonst/.svm directory --- ethers-solc/src/config.rs | 17 +++-------------- ethers-solc/src/lib.rs | 5 +---- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/ethers-solc/src/config.rs b/ethers-solc/src/config.rs index c58998f2..2be7a541 100644 --- a/ethers-solc/src/config.rs +++ b/ethers-solc/src/config.rs @@ -3,7 +3,7 @@ use crate::{ cache::SOLIDITY_FILES_CACHE_FILENAME, error::Result, remappings::Remapping, - CompilerOutput, Solc, + CompilerOutput, }; use ethers_core::{abi::Abi, types::Bytes}; use serde::{Deserialize, Serialize}; @@ -177,8 +177,6 @@ impl ProjectPathsConfigBuilder { /// The config to use when compiling the contracts #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] pub struct SolcConfig { - /// Configured solc version - pub version: String, /// How the file was compiled pub settings: Settings, } @@ -199,16 +197,10 @@ impl SolcConfig { #[derive(Default)] pub struct SolcConfigBuilder { - version: Option, settings: Option, } impl SolcConfigBuilder { - pub fn version(mut self, version: impl Into) -> Self { - self.version = Some(version.into()); - self - } - pub fn settings(mut self, settings: Settings) -> Self { self.settings = Some(settings); self @@ -218,11 +210,8 @@ impl SolcConfigBuilder { /// /// If no solc version is configured then it will be determined by calling `solc --version`. pub fn build(self) -> Result { - let Self { version, settings } = self; - let version = - version.map(Ok).unwrap_or_else(|| Solc::default().version().map(|s| s.to_string()))?; - let settings = settings.unwrap_or_default(); - Ok(SolcConfig { version, settings }) + let Self { settings } = self; + Ok(SolcConfig { settings: settings.unwrap_or_default() }) } } diff --git a/ethers-solc/src/lib.rs b/ethers-solc/src/lib.rs index d6132555..1f4c02c1 100644 --- a/ethers-solc/src/lib.rs +++ b/ethers-solc/src/lib.rs @@ -385,10 +385,7 @@ impl ProjectBuilder { } = self; let solc = solc.unwrap_or_default(); - let solc_config = solc_config.map(Ok).unwrap_or_else(|| { - let version = solc.version()?; - SolcConfig::builder().version(version.to_string()).build() - })?; + let solc_config = solc_config.map(Ok).unwrap_or_else(|| SolcConfig::builder().build())?; let paths = paths.map(Ok).unwrap_or_else(ProjectPathsConfig::current_hardhat)?;