Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def rust_doc_comment(text: str, indent: int = 0) -> str:
if not text:
return ""

lines = text.strip().split("\n")
lines = text.strip().replace("\\[", "[").replace("\\]", "]").split("\n")
indent_str = " " * indent

if len(lines) == 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ impl {{ client_type }}Client {
pub fn new(http_client: Arc<dyn HttpClient>) -> Self {
Self { http_client }
}

{% endif %}
{% if impl_block == "rust" %}
/// Create a new {{ client_type }}Client for Algorand TestNet.
#[cfg(feature = "default_client")]
#[cfg_attr(feature = "ffi_uniffi", uniffi::constructor)]
pub fn testnet() -> Self {
let http_client = Arc::new(DefaultHttpClient::new(
{% if client_type == "Indexer" %}"https://testnet-idx.4160.nodely.dev"{% else %}"https://testnet-api.4160.nodely.dev"{% endif %}
Expand All @@ -84,7 +84,6 @@ impl {{ client_type }}Client {

/// Create a new {{ client_type }}Client for Algorand MainNet.
#[cfg(feature = "default_client")]
#[cfg_attr(feature = "ffi_uniffi", uniffi::constructor)]
pub fn mainnet() -> Self {
let http_client = Arc::new(DefaultHttpClient::new(
{% if client_type == "Indexer" %}"https://mainnet-idx.4160.nodely.dev"{% else %}"https://mainnet-api.4160.nodely.dev"{% endif %}
Expand All @@ -94,7 +93,6 @@ impl {{ client_type }}Client {

/// Create a new {{ client_type }}Client for a local localnet environment.
#[cfg(feature = "default_client")]
#[cfg_attr(feature = "ffi_uniffi", uniffi::constructor)]
pub fn localnet() -> Self {
let http_client = Arc::new(DefaultHttpClient::with_header(
{% if client_type == "Indexer" %}"http://localhost:8980"{% else %}"http://localhost:4001"{% endif %},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ description = "{{ custom_description or spec.info.description or spec.info.title
license = "MIT"
edition = "2024"

[lib]
name = "{{ package_name | snake_case }}"
crate-type = ["lib", "cdylib"]

[features]
default = ["default_client"]
default_client = ["algokit_http_client/default_client"]
Expand Down
4 changes: 4 additions & 0 deletions crates/algod_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ description = "API client for algod interaction."
license = "MIT"
edition = "2024"

[lib]
name = "algod_client"
crate-type = ["lib", "cdylib"]

[features]
default = ["default_client"]
default_client = ["algokit_http_client/default_client"]
Expand Down
66 changes: 31 additions & 35 deletions crates/algod_client/src/apis/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,6 @@ impl AlgodClient {
pub fn new(http_client: Arc<dyn HttpClient>) -> Self {
Self { http_client }
}

/// Create a new AlgodClient for Algorand TestNet.
#[cfg(feature = "default_client")]
#[cfg_attr(feature = "ffi_uniffi", uniffi::constructor)]
pub fn testnet() -> Self {
let http_client = Arc::new(DefaultHttpClient::new(
"https://testnet-api.4160.nodely.dev",
));
Self::new(http_client)
}

/// Create a new AlgodClient for Algorand MainNet.
#[cfg(feature = "default_client")]
#[cfg_attr(feature = "ffi_uniffi", uniffi::constructor)]
pub fn mainnet() -> Self {
let http_client = Arc::new(DefaultHttpClient::new(
"https://mainnet-api.4160.nodely.dev",
));
Self::new(http_client)
}

/// Create a new AlgodClient for a local localnet environment.
#[cfg(feature = "default_client")]
#[cfg_attr(feature = "ffi_uniffi", uniffi::constructor)]
pub fn localnet() -> Self {
let http_client = Arc::new(
DefaultHttpClient::with_header(
"http://localhost:4001",
"X-Algo-API-Token",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
)
.expect("Failed to create HTTP client with API token header"),
);
Self::new(http_client)
}
/// Returns OK if healthy.
pub async fn health_check(&self) -> Result<(), Error> {
let result = super::health_check::health_check(self.http_client.as_ref()).await;
Expand Down Expand Up @@ -686,6 +651,37 @@ impl AlgodClient {

#[cfg(not(feature = "ffi_uniffi"))]
impl AlgodClient {
/// Create a new AlgodClient for Algorand TestNet.
#[cfg(feature = "default_client")]
pub fn testnet() -> Self {
let http_client = Arc::new(DefaultHttpClient::new(
"https://testnet-api.4160.nodely.dev",
));
Self::new(http_client)
}

/// Create a new AlgodClient for Algorand MainNet.
#[cfg(feature = "default_client")]
pub fn mainnet() -> Self {
let http_client = Arc::new(DefaultHttpClient::new(
"https://mainnet-api.4160.nodely.dev",
));
Self::new(http_client)
}

/// Create a new AlgodClient for a local localnet environment.
#[cfg(feature = "default_client")]
pub fn localnet() -> Self {
let http_client = Arc::new(
DefaultHttpClient::with_header(
"http://localhost:4001",
"X-Algo-API-Token",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
)
.expect("Failed to create HTTP client with API token header"),
);
Self::new(http_client)
}
/// Get a list of assets held by an account, inclusive of asset params.
pub async fn account_assets_information(
&self,
Expand Down
24 changes: 12 additions & 12 deletions crates/algod_client/src/models/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct Account {
/// the account public key
#[serde(rename = "address")]
pub address: String,
/// \[algo\] total number of MicroAlgos in the account
/// [algo] total number of MicroAlgos in the account
#[serde(rename = "amount")]
pub amount: u64,
/// MicroAlgo balance required by the account.
Expand All @@ -46,7 +46,7 @@ pub struct Account {
/// specifies the amount of MicroAlgos in the account, without the pending rewards.
#[serde(rename = "amount-without-pending-rewards")]
pub amount_without_pending_rewards: u64,
/// \[appl\] applications local data stored in this account.
/// [appl] applications local data stored in this account.
///
/// Note the raw object uses `map[int] -> AppLocalState` for this type.
#[serde(rename = "apps-local-state", skip_serializing_if = "Option::is_none")]
Expand All @@ -56,40 +56,40 @@ pub struct Account {
pub total_apps_opted_in: u64,
#[serde(rename = "apps-total-schema", skip_serializing_if = "Option::is_none")]
pub apps_total_schema: Option<ApplicationStateSchema>,
/// \[teap\] the sum of all extra application program pages for this account.
/// [teap] the sum of all extra application program pages for this account.
#[serde(
rename = "apps-total-extra-pages",
skip_serializing_if = "Option::is_none"
)]
pub apps_total_extra_pages: Option<u64>,
/// \[asset\] assets held by this account.
/// [asset] assets held by this account.
///
/// Note the raw object uses `map[int] -> AssetHolding` for this type.
#[serde(rename = "assets", skip_serializing_if = "Option::is_none")]
pub assets: Option<Vec<AssetHolding>>,
/// The count of all assets that have been opted in, equivalent to the count of AssetHolding objects held by this account.
#[serde(rename = "total-assets-opted-in")]
pub total_assets_opted_in: u64,
/// \[appp\] parameters of applications created by this account including app global data.
/// [appp] parameters of applications created by this account including app global data.
///
/// Note: the raw account uses `map[int] -> AppParams` for this type.
#[serde(rename = "created-apps", skip_serializing_if = "Option::is_none")]
pub created_apps: Option<Vec<Application>>,
/// The count of all apps (AppParams objects) created by this account.
#[serde(rename = "total-created-apps")]
pub total_created_apps: u64,
/// \[apar\] parameters of assets created by this account.
/// [apar] parameters of assets created by this account.
///
/// Note: the raw account uses `map[int] -> Asset` for this type.
#[serde(rename = "created-assets", skip_serializing_if = "Option::is_none")]
pub created_assets: Option<Vec<Asset>>,
/// The count of all assets (AssetParams objects) created by this account.
#[serde(rename = "total-created-assets")]
pub total_created_assets: u64,
/// \[tbx\] The number of existing boxes created by this account's app.
/// [tbx] The number of existing boxes created by this account's app.
#[serde(rename = "total-boxes", skip_serializing_if = "Option::is_none")]
pub total_boxes: Option<u64>,
/// \[tbxb\] The total number of bytes used by this account's app's box keys and values.
/// [tbxb] The total number of bytes used by this account's app's box keys and values.
#[serde(rename = "total-box-bytes", skip_serializing_if = "Option::is_none")]
pub total_box_bytes: Option<u64>,
#[serde(rename = "participation", skip_serializing_if = "Option::is_none")]
Expand All @@ -100,16 +100,16 @@ pub struct Account {
/// amount of MicroAlgos of pending rewards in this account.
#[serde(rename = "pending-rewards")]
pub pending_rewards: u64,
/// \[ebase\] used as part of the rewards computation. Only applicable to accounts which are participating.
/// [ebase] used as part of the rewards computation. Only applicable to accounts which are participating.
#[serde(rename = "reward-base", skip_serializing_if = "Option::is_none")]
pub reward_base: Option<u64>,
/// \[ern\] total rewards of MicroAlgos the account has received, including pending rewards.
/// [ern] total rewards of MicroAlgos the account has received, including pending rewards.
#[serde(rename = "rewards")]
pub rewards: u64,
/// The round for which this information is relevant.
#[serde(rename = "round")]
pub round: u64,
/// \[onl\] delegation status of the account's MicroAlgos
/// [onl] delegation status of the account's MicroAlgos
/// * Offline - indicates that the associated account is delegated.
/// * Online - indicates that the associated account used as part of the delegation pool.
/// * NotParticipating - indicates that the associated account is neither a delegator nor a delegate.
Expand All @@ -121,7 +121,7 @@ pub struct Account {
/// * lsig
#[serde(rename = "sig-type", skip_serializing_if = "Option::is_none")]
pub sig_type: Option<String>,
/// \[spend\] the address against which signing should be checked. If empty, the address of the current account is used. This field can be updated in any transaction by setting the RekeyTo field.
/// [spend] the address against which signing should be checked. If empty, the address of the current account is used. This field can be updated in any transaction by setting the RekeyTo field.
#[serde(rename = "auth-addr", skip_serializing_if = "Option::is_none")]
pub auth_addr: Option<String>,
/// The round in which this account last proposed the block.
Expand Down
12 changes: 6 additions & 6 deletions crates/algod_client/src/models/account_participation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ use algokit_transact::AlgorandMsgpack;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "ffi_uniffi", derive(uniffi::Record))]
pub struct AccountParticipation {
/// \[sel\] Selection public key (if any) currently registered for this round.
/// [sel] Selection public key (if any) currently registered for this round.
#[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "selection-participation-key")]
pub selection_participation_key: Vec<u8>,
/// \[voteFst\] First round for which this participation is valid.
/// [voteFst] First round for which this participation is valid.
#[serde(rename = "vote-first-valid")]
pub vote_first_valid: u64,
/// \[voteKD\] Number of subkeys in each batch of participation keys.
/// [voteKD] Number of subkeys in each batch of participation keys.
#[serde(rename = "vote-key-dilution")]
pub vote_key_dilution: u64,
/// \[voteLst\] Last round for which this participation is valid.
/// [voteLst] Last round for which this participation is valid.
#[serde(rename = "vote-last-valid")]
pub vote_last_valid: u64,
/// \[vote\] root participation public key (if any) currently registered for this round.
/// [vote] root participation public key (if any) currently registered for this round.
#[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "vote-participation-key")]
pub vote_participation_key: Vec<u8>,
/// \[stprf\] Root of the state proof key (if any)
/// [stprf] Root of the state proof key (if any)
#[serde_as(as = "Option<serde_with::base64::Base64>")]
#[serde(rename = "state-proof-key", skip_serializing_if = "Option::is_none")]
pub state_proof_key: Option<Vec<u8>>,
Expand Down
2 changes: 1 addition & 1 deletion crates/algod_client/src/models/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::models::ApplicationParams;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "ffi_uniffi", derive(uniffi::Record))]
pub struct Application {
/// \[appidx\] application index.
/// [appidx] application index.
#[serde(rename = "id")]
pub id: u64,
#[serde(rename = "params")]
Expand Down
8 changes: 4 additions & 4 deletions crates/algod_client/src/models/application_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ pub struct ApplicationParams {
/// The address that created this application. This is the address where the parameters and global state for this application can be found.
#[serde(rename = "creator")]
pub creator: String,
/// \[approv\] approval program.
/// [approv] approval program.
#[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "approval-program")]
pub approval_program: Vec<u8>,
/// \[clearp\] approval program.
/// [clearp] approval program.
#[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "clear-state-program")]
pub clear_state_program: Vec<u8>,
/// \[epp\] the amount of extra program pages available to this app.
/// [epp] the amount of extra program pages available to this app.
#[serde(
rename = "extra-program-pages",
skip_serializing_if = "Option::is_none"
Expand All @@ -53,7 +53,7 @@ pub struct ApplicationParams {
pub global_state_schema: Option<ApplicationStateSchema>,
#[serde(rename = "global-state", skip_serializing_if = "Option::is_none")]
pub global_state: Option<TealKeyValueStore>,
/// \[v\] the number of updates to the application programs
/// [v] the number of updates to the application programs
#[serde(rename = "version", skip_serializing_if = "Option::is_none")]
pub version: Option<u64>,
}
Expand Down
4 changes: 2 additions & 2 deletions crates/algod_client/src/models/application_state_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ use algokit_transact::AlgorandMsgpack;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "ffi_uniffi", derive(uniffi::Record))]
pub struct ApplicationStateSchema {
/// \[nui\] num of uints.
/// [nui] num of uints.
#[serde(rename = "num-uint")]
pub num_uint: u32,
/// \[nbs\] num of byte slices.
/// [nbs] num of byte slices.
#[serde(rename = "num-byte-slice")]
pub num_byte_slice: u32,
}
Expand Down
4 changes: 2 additions & 2 deletions crates/algod_client/src/models/asset_holding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ use algokit_transact::AlgorandMsgpack;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "ffi_uniffi", derive(uniffi::Record))]
pub struct AssetHolding {
/// \[a\] number of units held.
/// [a] number of units held.
#[serde(rename = "amount")]
pub amount: u64,
/// Asset ID of the holding.
#[serde(rename = "asset-id")]
pub asset_id: u64,
/// \[f\] whether or not the holding is frozen.
/// [f] whether or not the holding is frozen.
#[serde(rename = "is-frozen")]
pub is_frozen: bool,
}
Expand Down
Loading
Loading