Skip to content
Open
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 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 api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions api/specs/algod.oas3.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
4 changes: 4 additions & 0 deletions crates/algod_client/src/models/application_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>,
/// \[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<String>,
}

impl AlgorandMsgpack for ApplicationParams {
Expand All @@ -78,6 +81,7 @@ impl ApplicationParams {
global_state_schema: None,
global_state: None,
version: None,
size_sponsor: None,
}
}

Expand Down
3 changes: 3 additions & 0 deletions crates/algokit_crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
49 changes: 49 additions & 0 deletions crates/algokit_http_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub struct HttpResponse {
pub headers: HashMap<String, String>,
}

#[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.
Expand All @@ -65,6 +66,21 @@ pub trait HttpClient: Send + Sync {
) -> Result<HttpResponse, HttpError>;
}

#[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<HashMap<String, String>>,
body: Option<Vec<u8>>,
headers: Option<HashMap<String, String>>,
) -> Result<HttpResponse, HttpError>;
}

#[cfg(feature = "default_client")]
pub struct DefaultHttpClient {
client: reqwest::Client,
Expand Down Expand Up @@ -112,6 +128,7 @@ impl DefaultHttpClient {
}

#[cfg(feature = "default_client")]
#[cfg(not(target_arch = "wasm32"))]
#[async_trait]
impl HttpClient for DefaultHttpClient {
async fn request(
Expand All @@ -121,6 +138,38 @@ impl HttpClient for DefaultHttpClient {
query: Option<HashMap<String, String>>,
body: Option<Vec<u8>>,
headers: Option<HashMap<String, String>>,
) -> Result<HttpResponse, HttpError> {
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<HashMap<String, String>>,
body: Option<Vec<u8>>,
headers: Option<HashMap<String, String>>,
) -> Result<HttpResponse, HttpError> {
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<HashMap<String, String>>,
body: Option<Vec<u8>>,
headers: Option<HashMap<String, String>>,
) -> Result<HttpResponse, HttpError> {
let url = format!("{}{}", self.base_url, path);
let method = reqwest::Method::from_bytes(method.as_str().as_bytes()).map_err(|e| {
Expand Down