renegade_sdk/renegade_wallet_client/actions/
get_balance_by_mint.rs

1//! Gets the balance of a given mint in the account
2
3use alloy::primitives::Address;
4use renegade_external_api::{
5    http::balance::{GET_BALANCE_BY_MINT_ROUTE, GetBalanceByMintResponse},
6    types::ApiBalance,
7};
8
9use crate::{RenegadeClientError, actions::construct_http_path, client::RenegadeClient};
10
11impl RenegadeClient {
12    /// Get the account's balance for a given mint
13    pub async fn get_balance_by_mint(
14        &self,
15        mint: Address,
16    ) -> Result<ApiBalance, RenegadeClientError> {
17        let path = construct_http_path!(GET_BALANCE_BY_MINT_ROUTE, "account_id" => self.get_account_id(), "mint" => mint);
18
19        let GetBalanceByMintResponse { balance } = self.relayer_client.get(&path).await?;
20        Ok(balance)
21    }
22}