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
This commit is contained in:
Georgios Konstantopoulos 2021-11-16 23:25:39 +00:00 committed by GitHub
parent a50ee2ed46
commit b3fed152a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 18 deletions

View File

@ -3,7 +3,7 @@ use crate::{
cache::SOLIDITY_FILES_CACHE_FILENAME, cache::SOLIDITY_FILES_CACHE_FILENAME,
error::Result, error::Result,
remappings::Remapping, remappings::Remapping,
CompilerOutput, Solc, CompilerOutput,
}; };
use ethers_core::{abi::Abi, types::Bytes}; use ethers_core::{abi::Abi, types::Bytes};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -177,8 +177,6 @@ impl ProjectPathsConfigBuilder {
/// The config to use when compiling the contracts /// The config to use when compiling the contracts
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct SolcConfig { pub struct SolcConfig {
/// Configured solc version
pub version: String,
/// How the file was compiled /// How the file was compiled
pub settings: Settings, pub settings: Settings,
} }
@ -199,16 +197,10 @@ impl SolcConfig {
#[derive(Default)] #[derive(Default)]
pub struct SolcConfigBuilder { pub struct SolcConfigBuilder {
version: Option<String>,
settings: Option<Settings>, settings: Option<Settings>,
} }
impl SolcConfigBuilder { impl SolcConfigBuilder {
pub fn version(mut self, version: impl Into<String>) -> Self {
self.version = Some(version.into());
self
}
pub fn settings(mut self, settings: Settings) -> Self { pub fn settings(mut self, settings: Settings) -> Self {
self.settings = Some(settings); self.settings = Some(settings);
self self
@ -218,11 +210,8 @@ impl SolcConfigBuilder {
/// ///
/// If no solc version is configured then it will be determined by calling `solc --version`. /// If no solc version is configured then it will be determined by calling `solc --version`.
pub fn build(self) -> Result<SolcConfig> { pub fn build(self) -> Result<SolcConfig> {
let Self { version, settings } = self; let Self { settings } = self;
let version = Ok(SolcConfig { settings: settings.unwrap_or_default() })
version.map(Ok).unwrap_or_else(|| Solc::default().version().map(|s| s.to_string()))?;
let settings = settings.unwrap_or_default();
Ok(SolcConfig { version, settings })
} }
} }

View File

@ -385,10 +385,7 @@ impl<Artifacts: ArtifactOutput> ProjectBuilder<Artifacts> {
} = self; } = self;
let solc = solc.unwrap_or_default(); let solc = solc.unwrap_or_default();
let solc_config = solc_config.map(Ok).unwrap_or_else(|| { let solc_config = solc_config.map(Ok).unwrap_or_else(|| SolcConfig::builder().build())?;
let version = solc.version()?;
SolcConfig::builder().version(version.to_string()).build()
})?;
let paths = paths.map(Ok).unwrap_or_else(ProjectPathsConfig::current_hardhat)?; let paths = paths.map(Ok).unwrap_or_else(ProjectPathsConfig::current_hardhat)?;