refactor(solc): bump svm-rs and use returned install path (#1034)
* chore(deps): bump svm-rs * refactor: use solc install path directly * style: use if elese over option
This commit is contained in:
parent
f6d123241e
commit
24236997a9
|
@ -3576,7 +3576,7 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
|
|||
[[package]]
|
||||
name = "svm-rs"
|
||||
version = "0.2.9"
|
||||
source = "git+https://github.com/roynalnaruto/svm-rs#ae79a29f5bde08f1991f981456253fa5b6859047"
|
||||
source = "git+https://github.com/roynalnaruto/svm-rs#37d0095eeac73546c507b706c51e8f901541a7c1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if 1.0.0",
|
||||
|
|
|
@ -348,34 +348,35 @@ impl Solc {
|
|||
Ok(version)
|
||||
}
|
||||
|
||||
/// Installs the provided version of Solc in the machine under the svm dir
|
||||
/// Installs the provided version of Solc in the machine under the svm dir and returns the
|
||||
/// [Solc] instance pointing to the installation.
|
||||
///
|
||||
/// # Example
|
||||
/// ```no_run
|
||||
/// # async fn run() -> Result<(), Box<dyn std::error::Error>> {
|
||||
/// use ethers_solc::{Solc, ISTANBUL_SOLC};
|
||||
/// Solc::install(&ISTANBUL_SOLC).await.unwrap();
|
||||
/// let solc = Solc::find_svm_installed_version(&ISTANBUL_SOLC.to_string());
|
||||
/// let solc = Solc::install(&ISTANBUL_SOLC).await.unwrap();
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
#[cfg(feature = "svm")]
|
||||
pub async fn install(version: &Version) -> std::result::Result<(), svm::SolcVmError> {
|
||||
pub async fn install(version: &Version) -> std::result::Result<Self, svm::SolcVmError> {
|
||||
tracing::trace!("installing solc version \"{}\"", version);
|
||||
crate::report::solc_installation_start(version);
|
||||
let result = svm::install(version).await;
|
||||
crate::report::solc_installation_success(version);
|
||||
result
|
||||
result.map(Solc::new)
|
||||
}
|
||||
|
||||
/// Blocking version of `Self::install`
|
||||
#[cfg(all(feature = "svm", feature = "async"))]
|
||||
pub fn blocking_install(version: &Version) -> std::result::Result<(), svm::SolcVmError> {
|
||||
pub fn blocking_install(version: &Version) -> std::result::Result<Self, svm::SolcVmError> {
|
||||
tracing::trace!("blocking installing solc version \"{}\"", version);
|
||||
crate::report::solc_installation_start(version);
|
||||
match svm::blocking_install(version) {
|
||||
Ok(_) => {
|
||||
Ok(path) => {
|
||||
crate::report::solc_installation_success(version);
|
||||
Ok(())
|
||||
Ok(Solc::new(path))
|
||||
}
|
||||
Err(err) => {
|
||||
crate::report::solc_installation_error(version, &err.to_string());
|
||||
|
|
|
@ -627,19 +627,22 @@ impl VersionedSources {
|
|||
|
||||
let mut sources_by_version = std::collections::BTreeMap::new();
|
||||
for (version, sources) in self.inner {
|
||||
if !version.is_installed() {
|
||||
let solc = if !version.is_installed() {
|
||||
if self.offline {
|
||||
return Err(SolcError::msg(format!(
|
||||
"missing solc \"{}\" installation in offline mode",
|
||||
version
|
||||
)))
|
||||
} else {
|
||||
Solc::blocking_install(version.as_ref())?;
|
||||
// install missing solc
|
||||
Solc::blocking_install(version.as_ref())?
|
||||
}
|
||||
}
|
||||
let solc = Solc::find_svm_installed_version(version.to_string())?.ok_or_else(|| {
|
||||
} else {
|
||||
// find installed svm
|
||||
Solc::find_svm_installed_version(version.to_string())?.ok_or_else(|| {
|
||||
SolcError::msg(format!("solc \"{}\" should have been installed", version))
|
||||
})?;
|
||||
})?
|
||||
};
|
||||
|
||||
if self.offline {
|
||||
tracing::trace!(
|
||||
|
|
Loading…
Reference in New Issue