Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/__tests__/utils/wallet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import utils from '../../utils';
const {formatBalance, shortenAddress, shortenBalance} = utils.wallet;

describe('formatBalance', () => {
it('should format balance to 5 digits precision', () => {
expect(formatBalance(1.222243232)).toEqual(1.22224);
expect(formatBalance(3000.232143123212)).toEqual(3000.23214);
expect(formatBalance(10.000000001)).toEqual(10);
it('should format balance as string', () => {
expect(formatBalance(1.222243232)).toEqual('1.222243232');
expect(formatBalance(3000.232143123212)).toEqual('3000.232143123212');
expect(formatBalance(10.000000001)).toEqual('10.000000001');
});

it('should handle exponential balances', () => {
Expand Down
6 changes: 1 addition & 5 deletions src/utils/wallet.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
export const formatBalance = balance => {
if (typeof balance === 'number') {
balance = fromExponential(balance);
return typeof balance === 'string' ? balance : parseFloat(balance.toFixed(5));
}
return 'N/A';
return typeof balance === 'number' ? String(fromExponential(balance)) : 'N/A';
};

export const shortenBalance = balance => {
Expand Down