diff --git a/Cargo.lock b/Cargo.lock index 922d7876..b6330404 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1216,10 +1216,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/api/package.json b/api/package.json index 058b3258..89546ce4 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 804c5fb0..d896aeed 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/src/models/application_params.rs b/crates/algod_client/src/models/application_params.rs index fe18cb0f..61503464 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, } } diff --git a/crates/algokit_crypto/Cargo.toml b/crates/algokit_crypto/Cargo.toml index da1cdbd7..3fa95fd5 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 99b70545..008cdcaa 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,38 @@ 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| {