Skip to content

Commit

Permalink
Merge pull request #73 from roynalnaruto/chore/solc-v0.8.18
Browse files Browse the repository at this point in the history
v0.8.18 support
  • Loading branch information
roynalnaruto committed Feb 2, 2023
2 parents 6759f45 + 6a30fcf commit 775643b
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 42 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "svm-rs"
version = "0.2.19"
version = "0.2.20"
edition = "2018"
authors = ["Rohit Narurkar <rohit.narurkar@protonmail.com>"]
license = "MIT OR Apache-2.0"
Expand Down
7 changes: 6 additions & 1 deletion list/linux-aarch64.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@
{
"version": "0.8.17",
"sha256": "e905b3d7f785f660f3c573c1641f42d11be0b4daae79c37e23b72fa2df808098"
},
{
"version": "0.8.18",
"sha256": "d0bb39a5fbcac77b315ea0d9cf48c6882de5b6bcb716be2197355722f24f2ee8"
}
],
"releases": {
Expand Down Expand Up @@ -246,6 +250,7 @@
"0.8.14": "solc-v0.8.14",
"0.8.15": "solc-v0.8.15",
"0.8.16": "solc-v0.8.16",
"0.8.17": "solc-v0.8.17"
"0.8.17": "solc-v0.8.17",
"0.8.18": "solc-v0.8.18"
}
}
17 changes: 7 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl Drop for LockFile {

/// Returns the lockfile to use for a specific file
fn lock_file_path(version: &Version) -> PathBuf {
SVM_HOME.join(format!(".lock-solc-{}", version))
SVM_HOME.join(format!(".lock-solc-{version}"))
}

#[cfg(test)]
Expand All @@ -403,8 +403,7 @@ mod tests {
assert_eq!(
artifact_url(Platform::LinuxAarch64, &version, artifact).unwrap(),
Url::parse(&format!(
"https://github.com/nikitastupin/solc/raw/bd9079b31dd4cb06a98cd3c76b3c3d3ab956de5e/linux/aarch64/{}",
artifact
"https://github.com/nikitastupin/solc/raw/01a11efffb8111db0637d4b47a8360bb66979d82/linux/aarch64/{artifact}"
))
.unwrap(),
)
Expand Down Expand Up @@ -436,9 +435,8 @@ mod tests {
async fn test_version() {
let version = "0.8.10".parse().unwrap();
install(&version).await.unwrap();
let solc_path =
version_path(version.to_string().as_str()).join(&format!("solc-{}", version));
let output = Command::new(&solc_path)
let solc_path = version_path(version.to_string().as_str()).join(format!("solc-{version}"));
let output = Command::new(solc_path)
.arg("--version")
.stdin(Stdio::piped())
.stderr(Stdio::piped())
Expand All @@ -456,9 +454,8 @@ mod tests {
fn blocking_test_version() {
let version = "0.8.10".parse().unwrap();
blocking_install(&version).unwrap();
let solc_path =
version_path(version.to_string().as_str()).join(&format!("solc-{}", version));
let output = Command::new(&solc_path)
let solc_path = version_path(version.to_string().as_str()).join(format!("solc-{version}"));
let output = Command::new(solc_path)
.arg("--version")
.stdin(Stdio::piped())
.stderr(Stdio::piped())
Expand Down Expand Up @@ -493,7 +490,7 @@ mod tests {
// ensures we can download the latest native solc for apple silicon
#[tokio::test(flavor = "multi_thread")]
async fn can_download_latest_native_apple_silicon() {
let latest: Version = "0.8.15".parse().unwrap();
let latest: Version = "0.8.18".parse().unwrap();

let artifacts = all_releases(Platform::MacOsAarch64).await.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl FromStr for Platform {
"macosx-amd64" => Ok(Platform::MacOsAmd64),
"macosx-aarch64" => Ok(Platform::MacOsAarch64),
"windows-amd64" => Ok(Platform::WindowsAmd64),
s => Err(format!("unsupported platform {}", s)),
s => Err(format!("unsupported platform {s}")),
}
}
}
Expand Down
26 changes: 11 additions & 15 deletions src/releases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static OLD_SOLC_RELEASES: Lazy<Releases> = Lazy::new(|| {
});

static LINUX_AARCH64_URL_PREFIX: &str =
"https://github.com/nikitastupin/solc/raw/bd9079b31dd4cb06a98cd3c76b3c3d3ab956de5e/linux/aarch64";
"https://github.com/nikitastupin/solc/raw/01a11efffb8111db0637d4b47a8360bb66979d82/linux/aarch64";

static LINUX_AARCH64_RELEASES: Lazy<Releases> = Lazy::new(|| {
serde_json::from_str(include_str!("../list/linux-aarch64.json"))
Expand All @@ -35,10 +35,10 @@ static LINUX_AARCH64_RELEASES: Lazy<Releases> = Lazy::new(|| {
static MACOS_AARCH64_NATIVE: Lazy<Version> = Lazy::new(|| Version::new(0, 8, 5));

static MACOS_AARCH64_URL_PREFIX: &str =
"https://github.com/roynalnaruto/solc-builds/raw/ff4ea8a7bbde4488428de69f2c40a7fc56184f5e/macosx/aarch64";
"https://github.com/roynalnaruto/solc-builds/raw/33fe42fdb907265ea6f543d1eba18ffe9a05fa6f/macosx/aarch64";

static MACOS_AARCH64_RELEASES_URL: &str =
"https://github.com/roynalnaruto/solc-builds/raw/ff4ea8a7bbde4488428de69f2c40a7fc56184f5e/macosx/aarch64/list.json";
"https://github.com/roynalnaruto/solc-builds/raw/33fe42fdb907265ea6f543d1eba18ffe9a05fa6f/macosx/aarch64/list.json";

/// Defines the struct that the JSON-formatted release list can be deserialized into.
///
Expand Down Expand Up @@ -148,7 +148,7 @@ pub fn blocking_all_releases(platform: Platform) -> Result<Releases, SolcVmError
return Ok(releases);
}

let releases = reqwest::blocking::get(format!("{}/{}/list.json", SOLC_RELEASES_URL, platform))?
let releases = reqwest::blocking::get(format!("{SOLC_RELEASES_URL}/{platform}/list.json"))?
.json::<Releases>()?;
Ok(unified_releases(releases, platform))
}
Expand Down Expand Up @@ -189,7 +189,7 @@ pub async fn all_releases(platform: Platform) -> Result<Releases, SolcVmError> {
return Ok(releases);
}

let releases = get(format!("{}/{}/list.json", SOLC_RELEASES_URL, platform))
let releases = get(format!("{SOLC_RELEASES_URL}/{platform}/list.json"))
.await?
.json::<Releases>()
.await?;
Expand Down Expand Up @@ -220,16 +220,14 @@ pub fn artifact_url(
&& version.ge(&OLD_VERSION_MIN)
{
return Ok(Url::parse(&format!(
"{}/{}",
OLD_SOLC_RELEASES_DOWNLOAD_PREFIX, artifact
"{OLD_SOLC_RELEASES_DOWNLOAD_PREFIX}/{artifact}"
))?);
}

if platform == Platform::LinuxAarch64 {
if LINUX_AARCH64_RELEASES.releases.contains_key(version) {
return Ok(Url::parse(&format!(
"{}/{}",
LINUX_AARCH64_URL_PREFIX, artifact
"{LINUX_AARCH64_URL_PREFIX}/{artifact}"
))?);
} else {
return Err(SolcVmError::UnsupportedVersion(
Expand All @@ -249,8 +247,7 @@ pub fn artifact_url(
if platform == Platform::MacOsAarch64 {
if version.ge(&MACOS_AARCH64_NATIVE) {
return Ok(Url::parse(&format!(
"{}/{}",
MACOS_AARCH64_URL_PREFIX, artifact
"{MACOS_AARCH64_URL_PREFIX}/{artifact}"
))?);
} else {
return Ok(Url::parse(&format!(
Expand All @@ -263,8 +260,7 @@ pub fn artifact_url(
}

Ok(Url::parse(&format!(
"{}/{}/{}",
SOLC_RELEASES_URL, platform, artifact
"{SOLC_RELEASES_URL}/{platform}/{artifact}"
))?)
}

Expand All @@ -280,8 +276,8 @@ mod tests {

#[test]
fn test_linux_aarch64() {
assert_eq!(LINUX_AARCH64_RELEASES.releases.len(), 49);
assert_eq!(LINUX_AARCH64_RELEASES.builds.len(), 49);
assert_eq!(LINUX_AARCH64_RELEASES.releases.len(), 50);
assert_eq!(LINUX_AARCH64_RELEASES.builds.len(), 50);
}

#[tokio::test]
Expand Down
6 changes: 3 additions & 3 deletions src/svm/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async fn handle_install(version: Version) -> anyhow::Result<()> {
let current_version = svm_lib::current_version()?;

if installed_versions.contains(&version) {
println!("Solc {} is already installed", version);
println!("Solc {version} is already installed");
let input: String = Input::new()
.with_prompt("Would you like to set it as the global version?")
.with_initial_text("Y")
Expand All @@ -89,7 +89,7 @@ async fn handle_install(version: Version) -> anyhow::Result<()> {
} else if all_versions.contains(&version) {
let spinner = print::installing_version(&version);
svm_lib::install(&version).await?;
spinner.finish_with_message(format!("Downloaded Solc: {}", version));
spinner.finish_with_message(format!("Downloaded Solc: {version}"));
if current_version.is_none() {
svm_lib::use_version(&version)?;
print::set_global_version(&version);
Expand All @@ -109,7 +109,7 @@ async fn handle_use(version: Version) -> anyhow::Result<()> {
svm_lib::use_version(&version)?;
print::set_global_version(&version);
} else if all_versions.contains(&version) {
println!("Solc {} is not installed", version);
println!("Solc {version} is not installed");
let input: String = Input::new()
.with_prompt("Would you like to install it?")
.with_initial_text("Y")
Expand Down
11 changes: 4 additions & 7 deletions src/svm/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn available_versions(versions: Vec<Version>) {
pub fn installing_version(version: &Version) -> ProgressBar {
let spinner = ProgressBar::new_spinner();
spinner.enable_steady_tick(120);
spinner.set_message(format!("Downloading Solc {}", version));
spinner.set_message(format!("Downloading Solc {version}"));
spinner.set_style(
ProgressStyle::default_spinner()
.tick_strings(&[
Expand All @@ -53,16 +53,13 @@ pub fn installing_version(version: &Version) -> ProgressBar {
}

pub fn unsupported_version(version: &Version) {
println!(
"{}",
style(format!("Version: {} unsupported", version)).red()
);
println!("{}", style(format!("Version: {version} unsupported")).red());
}

pub fn set_global_version(version: &Version) {
ProgressBar::new_spinner().finish_with_message(format!("Global version set: {}", version));
ProgressBar::new_spinner().finish_with_message(format!("Global version set: {version}"));
}

pub fn version_not_found(version: &Version) {
println!("{}", style(format!("Version: {} not found", version)).red());
println!("{}", style(format!("Version: {version} not found")).red());
}
4 changes: 2 additions & 2 deletions svm-builds/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "svm-rs-builds"
version = "0.1.11"
version = "0.1.12"
edition = "2021"
authors = ["Matthias Seitz <matthias.seitz@outlook.de>", "Rohit Narurkar <rohit.narurkar@protonmail.com>"]
license = "MIT OR Apache-2.0"
Expand All @@ -14,7 +14,7 @@ build = "build.rs"

[build-dependencies]
build_const = "0.2.2"
svm = { package = "svm-rs", version = "0.2.19", path = "..", features = ["blocking"]}
svm = { package = "svm-rs", version = "0.2.20", path = "..", features = ["blocking"]}
semver = { version = "1.0.4", default-features = false, features = ["std", "serde"] }
hex = "0.4.3"
serde_json = "1.0.79"
Expand Down

0 comments on commit 775643b

Please sign in to comment.