Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/2064-wasm-download.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Define the wasm download endpoint via environemnt variable.
([\#2064](https://github.com/anoma/namada/pull/2064))
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