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,
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<String>,
settings: Option<Settings>,
}
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 {
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<SolcConfig> {
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() })
}
}

View File

@ -385,10 +385,7 @@ impl<Artifacts: ArtifactOutput> ProjectBuilder<Artifacts> {
} = 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)?;