Skip to content

Commit

Permalink
client/rpc: use the new token balance method
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Jul 12, 2023
1 parent 9ed7177 commit 223753f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ pub async fn get_token_balance<C: namada::ledger::queries::Client + Sync>(
client: &C,
token: &Address,
owner: &Address,
) -> Option<token::Amount> {
) -> token::Amount {
namada::ledger::rpc::get_token_balance(client, token, owner).await
}

Expand Down
3 changes: 1 addition & 2 deletions apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,7 @@ where

let balance =
rpc::get_token_balance(client, &ctx.native_token, &proposal.author)
.await
.unwrap_or_default();
.await;
if balance
< token::Amount::from_uint(
governance_parameters.min_proposal_fund,
Expand Down
8 changes: 4 additions & 4 deletions shared/src/ledger/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use crate::types::governance::{ProposalVote, VotePower};
use crate::types::hash::Hash;
use crate::types::key::*;
use crate::types::storage::{BlockHeight, BlockResults, Epoch, PrefixValue};
use crate::types::token::balance_key;
use crate::types::{storage, token};

/// Query the status of a given transaction.
Expand Down Expand Up @@ -137,9 +136,10 @@ pub async fn get_token_balance<C: crate::ledger::queries::Client + Sync>(
client: &C,
token: &Address,
owner: &Address,
) -> Option<token::Amount> {
let balance_key = balance_key(token, owner);
query_storage_value(client, &balance_key).await
) -> token::Amount {
unwrap_client_response::<C, _>(
RPC.vp().token().balance(client, token, owner).await,
)
}

/// Get account's public key stored in its storage sub-space
Expand Down

0 comments on commit 223753f

Please sign in to comment.