Skip to content

Commit

Permalink
wallet-ext: use BigInt for coin balance
Browse files Browse the repository at this point in the history
  • Loading branch information
pchrysochoidis committed May 31, 2022
1 parent 91decc3 commit 0618fd1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion wallet/src/ui/app/components/coin-balance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import st from './CoinBalance.module.scss';

export type CoinProps = {
type: string;
balance: number;
balance: bigint;
};

function CoinBalance({ type, balance }: CoinProps) {
Expand Down
6 changes: 3 additions & 3 deletions wallet/src/ui/app/redux/slices/account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ export const accountBalancesSelector = createSelector(
const coinType = Coin.getCoinTypeArg(aCoin);
if (coinType) {
if (typeof acc[coinType] === 'undefined') {
acc[coinType] = 0;
acc[coinType] = BigInt(0);
}
acc[coinType] += aCoin.fields.balance;
acc[coinType] += Coin.getBalance(aCoin);
}
return acc;
}, {} as Record<string, number>);
}, {} as Record<string, bigint>);
}
);

Expand Down
4 changes: 4 additions & 0 deletions wallet/src/ui/app/redux/slices/sui-objects/Coin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ export class Coin {
public static getCoinSymbol(coinTypeArg: string) {
return coinTypeArg.substring(coinTypeArg.lastIndexOf(':') + 1);
}

public static getBalance(obj: SuiMoveObject) {
return BigInt(obj.fields.balance);
}
}

0 comments on commit 0618fd1

Please sign in to comment.