terra_rust_api/client/
auth.rs1use crate::auth_types::AuthAccount;
2use crate::errors::TerraRustAPIError;
3use crate::staking_types::{Validator, ValidatorDelegation, ValidatorUnbondingDelegation};
4use crate::{LCDResult, LCDResultVec, LCDTypeValue, Terra};
5
6pub struct Auth<'a> {
7 terra: &'a Terra,
8}
9impl Auth<'_> {
10 pub fn create(terra: &'_ Terra) -> Auth<'_> {
11 Auth { terra }
12 }
13 pub async fn account(
14 &self,
15 account_address: &str,
16 ) -> Result<LCDResult<LCDTypeValue<AuthAccount>>, TerraRustAPIError> {
17 self.terra
18 .send_cmd::<LCDResult<LCDTypeValue<AuthAccount>>>(
19 &format!("/auth/accounts/{}", account_address),
20 None,
21 )
22 .await
23 }
24 pub async fn validator_delegations(
26 &self,
27 account_address: &str,
28 ) -> Result<LCDResultVec<ValidatorDelegation>, TerraRustAPIError> {
29 self.terra
30 .send_cmd::<LCDResultVec<ValidatorDelegation>>(
31 &format!("/staking/delegators/{}/delegations", account_address),
32 None,
33 )
34 .await
35 }
36 pub async fn validator_unbonding_delegations(
38 &self,
39 account_address: &str,
40 ) -> Result<LCDResult<ValidatorUnbondingDelegation>, TerraRustAPIError> {
41 self.terra
42 .send_cmd::<LCDResult<ValidatorUnbondingDelegation>>(
43 &format!(
44 "/staking/delegators/{}/unbonding_delegations",
45 account_address
46 ),
47 None,
48 )
49 .await
50 }
51 pub async fn delegated_validators(
53 &self,
54 account_address: &str,
55 ) -> Result<LCDResult<Vec<Validator>>, TerraRustAPIError> {
56 self.terra
57 .send_cmd::<LCDResult<Vec<Validator>>>(
58 &format!("/staking/delegators/{}/validators", account_address),
59 None,
60 )
61 .await
62 }
63}