Create Balance component and make token symbols smaller than token amounts

This commit is contained in:
fragosti
2018-07-06 14:09:36 -07:00
parent 7418926ebb
commit 9669a4d121
7 changed files with 63 additions and 38 deletions

View File

@@ -381,9 +381,9 @@ export const utils = {
return trackedTokens;
},
getFormattedAmountFromToken(token: Token, tokenState: TokenState): string {
return utils.getFormattedAmount(tokenState.balance, token.decimals, token.symbol);
return utils.getFormattedAmount(tokenState.balance, token.decimals);
},
getFormattedAmount(amount: BigNumber, decimals: number, symbol: string): string {
getFormattedAmount(amount: BigNumber, decimals: number): string {
const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
// if the unit amount is less than 1, show the natural number of decimal places with a max of 4
// if the unit amount is greater than or equal to 1, show only 2 decimal places
@@ -392,7 +392,7 @@ export const utils = {
: 2;
const format = `0,0.${_.repeat('0', precision)}`;
const formattedAmount = numeral(unitAmount).format(format);
return `${formattedAmount} ${symbol}`;
return formattedAmount;
},
getUsdValueFormattedAmount(amount: BigNumber, decimals: number, price: BigNumber): string {
const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);