aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/wallet
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-07-03 07:00:34 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-07-03 07:08:02 +0800
commitbc7e8ff471d7abe8e65b30d1945f6a989d521f10 (patch)
treec644cd1c61783b0394534c7cd47fd28637ec46f8 /packages/website/ts/components/wallet
parent300c9f09b9ee129791a1f62881da0ee3c34ee0b5 (diff)
downloaddexon-sol-tools-bc7e8ff471d7abe8e65b30d1945f6a989d521f10.tar
dexon-sol-tools-bc7e8ff471d7abe8e65b30d1945f6a989d521f10.tar.gz
dexon-sol-tools-bc7e8ff471d7abe8e65b30d1945f6a989d521f10.tar.bz2
dexon-sol-tools-bc7e8ff471d7abe8e65b30d1945f6a989d521f10.tar.lz
dexon-sol-tools-bc7e8ff471d7abe8e65b30d1945f6a989d521f10.tar.xz
dexon-sol-tools-bc7e8ff471d7abe8e65b30d1945f6a989d521f10.tar.zst
dexon-sol-tools-bc7e8ff471d7abe8e65b30d1945f6a989d521f10.zip
Add better balance formatting rules for balances and usd values
Diffstat (limited to 'packages/website/ts/components/wallet')
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx20
1 files changed, 5 insertions, 15 deletions
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx
index 1f1e3598a..668a7a537 100644
--- a/packages/website/ts/components/wallet/wallet.tsx
+++ b/packages/website/ts/components/wallet/wallet.tsx
@@ -1,6 +1,5 @@
import { constants as sharedConstants, EtherscanLinkSuffixes, utils as sharedUtils } from '@0xproject/react-shared';
import { BigNumber, errorUtils } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import ActionAccountBalanceWallet from 'material-ui/svg-icons/action/account-balance-wallet';
@@ -83,7 +82,6 @@ const ICON_DIMENSION = 28;
const BODY_ITEM_KEY = 'BODY';
const HEADER_ITEM_KEY = 'HEADER';
const ETHER_ITEM_KEY = 'ETHER';
-const USD_DECIMAL_PLACES = 2;
const NO_ALLOWANCE_TOGGLE_SPACE_WIDTH = 56;
const ACCOUNT_PATH = `${WebsitePaths.Portal}/account`;
const PLACEHOLDER_COLOR = colors.grey300;
@@ -411,19 +409,11 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
price?: BigNumber,
isLoading: boolean = false,
): React.ReactNode {
- let result;
- if (!isLoading) {
- if (_.isUndefined(price)) {
- result = '--';
- } else {
- const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
- const value = unitAmount.mul(price);
- const formattedAmount = value.toFixed(USD_DECIMAL_PLACES);
- result = `$${formattedAmount}`;
- }
- } else {
- result = '$0.00';
- }
+ const result = !isLoading
+ ? _.isUndefined(price)
+ ? '--'
+ : utils.getUsdValueFormattedAmount(amount, decimals, price)
+ : '$0.00';
return (
<PlaceHolder hideChildren={isLoading} fillColor={PLACEHOLDER_COLOR}>
<Text fontSize="14px" fontColor={colors.darkGrey} lineHeight="1em">