Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
add getAccountSpendableBalance helper
Browse files Browse the repository at this point in the history
  • Loading branch information
gre committed Nov 26, 2020
1 parent 51730c4 commit eea04f8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/account/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ export const getAccountName = (account: AccountLike): string => {
}
};

export const getAccountSpendableBalance = (account: AccountLike): BigNumber => {
switch (account.type) {
case "Account":
case "TokenAccount":
return account.spendableBalance;
case "ChildAccount":
return account.balance;
default:
throw new Error("invalid account.type=" + account.type);
}
};

export const isAccountEmpty = (a: AccountLike): boolean => {
if (
a.type === "Account" &&
Expand Down

1 comment on commit eea04f8

@vercel
Copy link

@vercel vercel bot commented on eea04f8 Nov 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.