Skip to content

Commit

Permalink
Refactor getAccountBalance to return strings (#1666)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinbodnar committed May 17, 2021
1 parent 57c5d74 commit 3eba21e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/utils/account-with-lockup.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,23 +197,23 @@ async function getAccountBalance(limitedAccountData = false) {
return {
...balance,
balanceAvailable: balance.available,
available,
ownersBalance,
liquidOwnersBalance,
lockedAmount,
total: new BN(balance.total).add(new BN(lockedAmount)).add(new BN(ownersBalance)).add(stakedBalanceMainAccount).toString(),
totalBalance,
stakedBalanceLockup: stakedBalanceLockup,
available: available.toString(),
ownersBalance: ownersBalance.toString(),
liquidOwnersBalance: liquidOwnersBalance.toString(),
lockedAmount: lockedAmount.toString(),
total: new BN(balance.total).add(lockedAmount).add(ownersBalance).add(stakedBalanceMainAccount).toString(),
totalBalance: totalBalance.toString(),
stakedBalanceLockup: stakedBalanceLockup.toString(),
lockupAccountId,
stakedBalanceMainAccount
stakedBalanceMainAccount: stakedBalanceMainAccount.toString()
}
} catch (error) {
if (error.message.match(/ccount ".+" doesn't exist/) || error.message.includes('does not exist while viewing') || error.message.includes('cannot find contract code for account')) {
return {
...balance,
balanceAvailable: balance.available,
total: new BN(balance.total).add(stakedBalanceMainAccount).toString(),
stakedBalanceMainAccount,
stakedBalanceMainAccount: stakedBalanceMainAccount.toString(),

}
}
Expand Down

0 comments on commit 3eba21e

Please sign in to comment.