From 6ed44934dc0d95b893ac95488cb7d7e64f1a037b Mon Sep 17 00:00:00 2001 From: Michael J Feher Date: Thu, 26 Feb 2026 21:01:32 -0500 Subject: [PATCH 1/3] feat: wasm32 http client --- Cargo.lock | 5 +++ crates/algod_client/Cargo.toml | 3 ++ crates/algokit_crypto/Cargo.toml | 3 ++ crates/algokit_http_client/src/lib.rs | 47 +++++++++++++++++++++++++++ 4 files changed, 58 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 922d78764..bf7fd7492 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,6 +34,7 @@ dependencies = [ "algokit_transact", "algokit_transact_ffi", "base64 0.22.1", + "getrandom 0.2.15", "rmp-serde", "rmpv", "serde", @@ -1205,8 +1206,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -1216,10 +1219,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi", "wasip2", "wasip3", + "wasm-bindgen", ] [[package]] diff --git a/crates/algod_client/Cargo.toml b/crates/algod_client/Cargo.toml index 7e95b2b31..9977af96d 100644 --- a/crates/algod_client/Cargo.toml +++ b/crates/algod_client/Cargo.toml @@ -44,6 +44,9 @@ snafu = { workspace = true } base64 = "^0.22" uuid = { version = "^1.0", features = ["v4"] } +[target.'cfg(target_arch = "wasm32")'.dependencies] +getrandom = { version = "0.2.15", features = ["js"] } + [dev-dependencies] tokio = { version = "1.0", features = ["full"] } tokio-test = "^0.4" \ No newline at end of file diff --git a/crates/algokit_crypto/Cargo.toml b/crates/algokit_crypto/Cargo.toml index da1cdbd7e..3fa95fd59 100644 --- a/crates/algokit_crypto/Cargo.toml +++ b/crates/algokit_crypto/Cargo.toml @@ -17,5 +17,8 @@ zeroize = { version = "1.8", features = ["derive"] } getrandom = "0.4.1" async-trait = "0.1.89" +[target.'cfg(target_arch = "wasm32")'.dependencies] +getrandom = { version = "0.4.1", features = ["wasm_js"] } + [dev-dependencies] tokio = { version = "1.49.0", features = ["macros", "rt"] } diff --git a/crates/algokit_http_client/src/lib.rs b/crates/algokit_http_client/src/lib.rs index 99b70545c..8dc3fe276 100644 --- a/crates/algokit_http_client/src/lib.rs +++ b/crates/algokit_http_client/src/lib.rs @@ -48,6 +48,7 @@ pub struct HttpResponse { pub headers: HashMap, } +#[cfg(not(target_arch = "wasm32"))] #[cfg_attr(feature = "ffi_uniffi", uniffi::export(with_foreign))] #[async_trait] /// This trait must be implemented by any HTTP client that is used by our Rust crates. @@ -65,6 +66,21 @@ pub trait HttpClient: Send + Sync { ) -> Result; } +#[cfg(target_arch = "wasm32")] +#[async_trait(?Send)] +/// This trait must be implemented by any HTTP client that is used by our Rust crates. +/// It is assumed the implementing type will provide the hostname, port, headers, etc. as needed for each request. +pub trait HttpClient { + async fn request( + &self, + http_method: HttpMethod, + path: String, + query: Option>, + body: Option>, + headers: Option>, + ) -> Result; +} + #[cfg(feature = "default_client")] pub struct DefaultHttpClient { client: reqwest::Client, @@ -112,6 +128,7 @@ impl DefaultHttpClient { } #[cfg(feature = "default_client")] +#[cfg(not(target_arch = "wasm32"))] #[async_trait] impl HttpClient for DefaultHttpClient { async fn request( @@ -121,6 +138,36 @@ impl HttpClient for DefaultHttpClient { query: Option>, body: Option>, headers: Option>, + ) -> Result { + self.perform_request(method, path, query, body, headers).await + } +} + +#[cfg(feature = "default_client")] +#[cfg(target_arch = "wasm32")] +#[async_trait(?Send)] +impl HttpClient for DefaultHttpClient { + async fn request( + &self, + method: HttpMethod, + path: String, + query: Option>, + body: Option>, + headers: Option>, + ) -> Result { + self.perform_request(method, path, query, body, headers).await + } +} + +#[cfg(feature = "default_client")] +impl DefaultHttpClient { + async fn perform_request( + &self, + method: HttpMethod, + path: String, + query: Option>, + body: Option>, + headers: Option>, ) -> Result { let url = format!("{}{}", self.base_url, path); let method = reqwest::Method::from_bytes(method.as_str().as_bytes()).map_err(|e| { From 1887c937d0215c74cc4d542015f45b282a1b8605 Mon Sep 17 00:00:00 2001 From: Michael J Feher Date: Fri, 27 Feb 2026 19:32:28 -0500 Subject: [PATCH 2/3] chore: fix lint errors --- crates/algokit_http_client/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/algokit_http_client/src/lib.rs b/crates/algokit_http_client/src/lib.rs index 8dc3fe276..008cdcaa4 100644 --- a/crates/algokit_http_client/src/lib.rs +++ b/crates/algokit_http_client/src/lib.rs @@ -139,7 +139,8 @@ impl HttpClient for DefaultHttpClient { body: Option>, headers: Option>, ) -> Result { - self.perform_request(method, path, query, body, headers).await + self.perform_request(method, path, query, body, headers) + .await } } @@ -155,7 +156,8 @@ impl HttpClient for DefaultHttpClient { body: Option>, headers: Option>, ) -> Result { - self.perform_request(method, path, query, body, headers).await + self.perform_request(method, path, query, body, headers) + .await } } From 412ebb187cf057a798061b185a9b5402c905d0a8 Mon Sep 17 00:00:00 2001 From: Michael J Feher Date: Fri, 27 Feb 2026 19:41:26 -0500 Subject: [PATCH 3/3] chore: update specs to latest --- Cargo.lock | 3 --- api/package.json | 2 +- api/specs/algod.oas3.json | 5 +++++ crates/algod_client/Cargo.toml | 3 --- crates/algod_client/src/models/application_params.rs | 4 ++++ 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bf7fd7492..b6330404f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,7 +34,6 @@ dependencies = [ "algokit_transact", "algokit_transact_ffi", "base64 0.22.1", - "getrandom 0.2.15", "rmp-serde", "rmpv", "serde", @@ -1206,10 +1205,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi", - "wasm-bindgen", ] [[package]] diff --git a/api/package.json b/api/package.json index 058b32583..89546ce43 100644 --- a/api/package.json +++ b/api/package.json @@ -5,7 +5,7 @@ "private": true, "scripts": { "convert-openapi": "tsx scripts/convert-openapi.ts", - "gen:ts": "cargo api generate-ts-all" + "gen:ts": "cargo api generate-all" }, "devDependencies": { "@apidevtools/swagger-parser": "^11.0.0", diff --git a/api/specs/algod.oas3.json b/api/specs/algod.oas3.json index 804c5fb03..d896aeed1 100644 --- a/api/specs/algod.oas3.json +++ b/api/specs/algod.oas3.json @@ -5509,6 +5509,11 @@ "type": "integer", "description": "\\[v\\] the number of updates to the application programs", "x-algokit-bigint": true + }, + "size-sponsor": { + "type": "string", + "description": "\\[ss\\] the account responsible for extra pages and global state MBR", + "x-algorand-format": "Address" } }, "description": "Stores the global information associated with an application." diff --git a/crates/algod_client/Cargo.toml b/crates/algod_client/Cargo.toml index 9977af96d..7e95b2b31 100644 --- a/crates/algod_client/Cargo.toml +++ b/crates/algod_client/Cargo.toml @@ -44,9 +44,6 @@ snafu = { workspace = true } base64 = "^0.22" uuid = { version = "^1.0", features = ["v4"] } -[target.'cfg(target_arch = "wasm32")'.dependencies] -getrandom = { version = "0.2.15", features = ["js"] } - [dev-dependencies] tokio = { version = "1.0", features = ["full"] } tokio-test = "^0.4" \ No newline at end of file diff --git a/crates/algod_client/src/models/application_params.rs b/crates/algod_client/src/models/application_params.rs index fe18cb0f2..615034647 100644 --- a/crates/algod_client/src/models/application_params.rs +++ b/crates/algod_client/src/models/application_params.rs @@ -56,6 +56,9 @@ pub struct ApplicationParams { /// \[v\] the number of updates to the application programs #[serde(rename = "version", skip_serializing_if = "Option::is_none")] pub version: Option, + /// \[ss\] the account responsible for extra pages and global state MBR + #[serde(rename = "size-sponsor", skip_serializing_if = "Option::is_none")] + pub size_sponsor: Option, } impl AlgorandMsgpack for ApplicationParams { @@ -78,6 +81,7 @@ impl ApplicationParams { global_state_schema: None, global_state: None, version: None, + size_sponsor: None, } }