pub struct WalletsBalanceClient { /* private fields */ }Expand description
Client for balance operations
Implementations§
Source§impl WalletsBalanceClient
impl WalletsBalanceClient
Sourcepub fn new(client: Client, app_id: String, base_url: String) -> Self
pub fn new(client: Client, app_id: String, base_url: String) -> Self
Create a new client instance
Sourcepub async fn get<'a>(
&'a self,
wallet_id: &'a str,
asset: &'a GetWalletBalanceAsset,
chain: &'a GetWalletBalanceChain,
include_currency: Option<GetWalletBalanceIncludeCurrency>,
) -> Result<ResponseValue<GetWalletBalanceResponse>, Error<()>>
pub async fn get<'a>( &'a self, wallet_id: &'a str, asset: &'a GetWalletBalanceAsset, chain: &'a GetWalletBalanceChain, include_currency: Option<GetWalletBalanceIncludeCurrency>, ) -> Result<ResponseValue<GetWalletBalanceResponse>, Error<()>>
Get balance
Get the balance of a wallet by wallet ID.
Sends a GET request to /v1/wallets/{wallet_id}/balance
Examples found in repository?
examples/wallet_balance.rs (lines 51-56)
30async fn main() -> Result<()> {
31 tracing_subscriber::fmt()
32 .with_env_filter(
33 EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
34 )
35 .init();
36
37 // Get wallet ID from environment and initialize client
38 let wallet_id =
39 std::env::var("PRIVY_WALLET_ID").expect("PRIVY_WALLET_ID environment variable not set");
40 let client = PrivyClient::new_from_env()?;
41
42 tracing::info!(
43 "initialized privy client from environment, wallet_id: {}",
44 wallet_id
45 );
46
47 // Get SOL balance on Solana
48 let balance = client
49 .wallets()
50 .balance()
51 .get(
52 &wallet_id,
53 &GetWalletBalanceAsset::String(GetWalletBalanceAssetString::Sol),
54 &GetWalletBalanceChain::String(GetWalletBalanceChainString::Solana),
55 Some(GetWalletBalanceIncludeCurrency::Usd),
56 )
57 .await?;
58
59 tracing::info!("got wallet balance: {:?}", balance);
60
61 Ok(())
62}Trait Implementations§
Source§impl Clone for WalletsBalanceClient
impl Clone for WalletsBalanceClient
Source§fn clone(&self) -> WalletsBalanceClient
fn clone(&self) -> WalletsBalanceClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WalletsBalanceClient
impl !RefUnwindSafe for WalletsBalanceClient
impl Send for WalletsBalanceClient
impl Sync for WalletsBalanceClient
impl Unpin for WalletsBalanceClient
impl !UnwindSafe for WalletsBalanceClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more