Skip to content

Commit

Permalink
wasm server download via env
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraccaman committed Oct 27, 2023
1 parent 2138c96 commit 723c58f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions apps/src/lib/wasm_loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ pub enum Error {
#[serde(transparent)]
pub struct Checksums(pub HashMap<String, String>);

const S3_URL: &str = "https://namada-wasm-master.s3.eu-west-1.amazonaws.com";
/// Github URL prefix of released Namada network configs
pub const ENV_VAR_WASM_SERVER: &str = "NAMADA_NETWORK_CONFIGS_SERVER";
const DEFAULT_WASM_SERVER: &str = "https://artifacts.heliax.click/namada-wasm";

impl Checksums {
/// Read WASM checksums from the given path
Expand Down Expand Up @@ -101,6 +103,11 @@ impl Checksums {
}
}

fn wasm_url_prefix(wasm_name: &str) -> String {
std::env::var(ENV_VAR_WASM_SERVER)
.unwrap_or_else(|_| format!("{DEFAULT_WASM_SERVER}/{wasm_name}"))
}

/// Download all the pre-built wasms, or if they're already downloaded, verify
/// their checksums.
pub async fn pre_fetch_wasm(wasm_directory: impl AsRef<Path>) {
Expand Down Expand Up @@ -180,7 +187,7 @@ pub async fn pre_fetch_wasm(wasm_directory: impl AsRef<Path>) {
}
}

let url = format!("{}/{}", S3_URL, full_name);
let url = wasm_url_prefix(&full_name);
match download_wasm(url).await {
Ok(bytes) => {
if let Err(e) =
Expand Down Expand Up @@ -224,7 +231,7 @@ pub async fn pre_fetch_wasm(wasm_directory: impl AsRef<Path>) {
}
}

let url = format!("{}/{}", S3_URL, full_name);
let url = wasm_url_prefix(&full_name);
match download_wasm(url).await {
Ok(bytes) => {
if let Err(e) =
Expand Down

0 comments on commit 723c58f

Please sign in to comment.