Skip to content

Commit

Permalink
filter returned denoms when displaying account balance
Browse files Browse the repository at this point in the history
  • Loading branch information
filipdjokic committed May 15, 2024
1 parent 271945a commit cd84dd0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/helpers/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ export async function fetchAccountBalances(address: string): Promise<AccountBala
const node_api = new NodeApi(REST_API);
const available_balance = await node_api.getAvailableBalance(address);

// Filter the balances to find the one with denom 'ncheq'
const ncheqBalance = available_balance.find(balance => balance.denom === 'ncheq');

let available_balance_in_ncheq = 0;
if (available_balance.length > 0) {
available_balance_in_ncheq = Number(available_balance[0]?.amount);
available_balance_in_ncheq = ncheqBalance ? Number(ncheqBalance.amount) : 0;;
}

const reward_balance_in_ncheq = await node_api.distributionGetRewards(address);
Expand Down

0 comments on commit cd84dd0

Please sign in to comment.