aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/wallet
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-07 18:21:44 +0800
committerFabio Berger <me@fabioberger.com>2018-06-07 18:21:44 +0800
commit10478a6b2fd1f2a01597a88afde9cf582640a849 (patch)
tree3ebbb29656cf59b2547ec3c5a3c5b90ee6264483 /packages/website/ts/components/wallet
parentcf8fdd3a701f21bfc3b2ec8397fa65948f5cdc78 (diff)
parente0bc01eea1c20e0afda296f331c6a475e062b59c (diff)
downloaddexon-sol-tools-10478a6b2fd1f2a01597a88afde9cf582640a849.tar.gz
dexon-sol-tools-10478a6b2fd1f2a01597a88afde9cf582640a849.tar.zst
dexon-sol-tools-10478a6b2fd1f2a01597a88afde9cf582640a849.zip
Merge branch 'v2-prototype' into refactor/move-spawn-switch-to-utils
* v2-prototype: (66 commits) Run prettier Remove unused variable Fix linting issues Change shouldRenderHeader prop to shouldHideHeader Get build and tests to pass typo Apply prettier Update contracts tests after rebase Apply various fixes based on PR feedback Document debug_increaseTime method and fix typo in devnet README Use an enum for ProviderType in contracts/src/utils/web3_wrapper Update contracts package README Update relevant changelogs Remove global gas estimate buffer Add Async suffix to relevant assertions Fix linter errors Update package.json and yarn.lock Update more things to work with both Geth and Ganache Small fixes and cleanup Add additional gas to calls to fillOrderNoThrow ... # Conflicts: # packages/order-watcher/src/order_watcher/order_watcher.ts # packages/react-docs/src/components/type.tsx # packages/website/ts/components/ui/lifecycle_raised_button.tsx # packages/website/ts/components/wallet/wallet.tsx
Diffstat (limited to 'packages/website/ts/components/wallet')
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx50
-rw-r--r--packages/website/ts/components/wallet/wallet_disconnected_item.tsx1
-rw-r--r--packages/website/ts/components/wallet/wrap_ether_item.tsx1
3 files changed, 15 insertions, 37 deletions
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx
index 5ad7602a6..bc2ee227d 100644
--- a/packages/website/ts/components/wallet/wallet.tsx
+++ b/packages/website/ts/components/wallet/wallet.tsx
@@ -1,25 +1,15 @@
-import {
- constants as sharedConstants,
- EtherscanLinkSuffixes,
- Styles,
- utils as sharedUtils,
-} from '@0xproject/react-shared';
+import { EtherscanLinkSuffixes, Styles, utils as sharedUtils } from '@0xproject/react-shared';
import { BigNumber, errorUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import CircularProgress from 'material-ui/CircularProgress';
-import FlatButton from 'material-ui/FlatButton';
import FloatingActionButton from 'material-ui/FloatingActionButton';
import { ListItem } from 'material-ui/List';
import ActionAccountBalanceWallet from 'material-ui/svg-icons/action/account-balance-wallet';
import ContentAdd from 'material-ui/svg-icons/content/add';
import ContentRemove from 'material-ui/svg-icons/content/remove';
-import NavigationArrowDownward from 'material-ui/svg-icons/navigation/arrow-downward';
-import NavigationArrowUpward from 'material-ui/svg-icons/navigation/arrow-upward';
-import Close from 'material-ui/svg-icons/navigation/close';
import * as React from 'react';
import { Link } from 'react-router-dom';
-import ReactTooltip = require('react-tooltip');
import firstBy = require('thenby');
import { Blockchain } from 'ts/blockchain';
@@ -35,7 +25,6 @@ import { Dispatcher } from 'ts/redux/dispatcher';
import { colors } from 'ts/style/colors';
import { zIndex } from 'ts/style/z_index';
import {
- BalanceErrs,
BlockchainErrs,
ProviderType,
ScreenWidths,
@@ -135,7 +124,7 @@ const styles: Styles = {
const ETHER_ICON_PATH = '/images/ether.png';
const ICON_DIMENSION = 28;
-const TOKEN_AMOUNT_DISPLAY_PRECISION = 3;
+const TOKEN_AMOUNT_DISPLAY_PRECISION = 5;
const BODY_ITEM_KEY = 'BODY';
const HEADER_ITEM_KEY = 'HEADER';
const FOOTER_ITEM_KEY = 'FOOTER';
@@ -146,10 +135,8 @@ const NO_ALLOWANCE_TOGGLE_SPACE_WIDTH = 56;
const ACCOUNT_PATH = `${WebsitePaths.Portal}/account`;
export class Wallet extends React.Component<WalletProps, WalletState> {
- private _isUnmounted: boolean;
constructor(props: WalletProps) {
super(props);
- this._isUnmounted = false;
this.state = {
wrappedEtherDirection: undefined,
isHoveringSidebar: false,
@@ -183,7 +170,6 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
);
}
private _renderDisconnectedHeaderRows(): React.ReactElement<{}> {
- const userAddress = this.props.userAddress;
const primaryText = 'wallet';
return (
<StandardIconRow
@@ -448,14 +434,19 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
symbol: string,
isLoading: boolean = false,
): React.ReactNode {
- const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
- const formattedAmount = unitAmount.toPrecision(TOKEN_AMOUNT_DISPLAY_PRECISION);
- const result = `${formattedAmount} ${symbol}`;
- return (
- <PlaceHolder hideChildren={isLoading}>
- <div style={styles.amountLabel}>{result}</div>
- </PlaceHolder>
- );
+ if (isLoading) {
+ return (
+ <PlaceHolder hideChildren={isLoading}>
+ <div style={styles.amountLabel}>0.00 XXX</div>
+ </PlaceHolder>
+ );
+ } else {
+ const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
+ const precision = Math.min(TOKEN_AMOUNT_DISPLAY_PRECISION, unitAmount.decimalPlaces());
+ const formattedAmount = unitAmount.toFixed(precision);
+ const result = `${formattedAmount} ${symbol}`;
+ return <div style={styles.amountLabel}>{result}</div>;
+ }
}
private _renderValue(
amount: BigNumber,
@@ -510,17 +501,6 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
<IconButton iconName={buttonIconName} labelText={buttonLabel} onClick={onClick} color={colors.mediumBlue} />
);
}
- private _getInitialTrackedTokenStateByAddress(tokenAddresses: string[]): TokenStateByAddress {
- const trackedTokenStateByAddress: TokenStateByAddress = {};
- _.each(tokenAddresses, tokenAddress => {
- trackedTokenStateByAddress[tokenAddress] = {
- balance: new BigNumber(0),
- allowance: new BigNumber(0),
- isLoaded: false,
- };
- });
- return trackedTokenStateByAddress;
- }
private _openWrappedEtherActionRow(wrappedEtherDirection: Side): void {
this.setState({
wrappedEtherDirection,
diff --git a/packages/website/ts/components/wallet/wallet_disconnected_item.tsx b/packages/website/ts/components/wallet/wallet_disconnected_item.tsx
index e3b88dc54..1015dce29 100644
--- a/packages/website/ts/components/wallet/wallet_disconnected_item.tsx
+++ b/packages/website/ts/components/wallet/wallet_disconnected_item.tsx
@@ -1,6 +1,5 @@
import { Styles } from '@0xproject/react-shared';
import FlatButton from 'material-ui/FlatButton';
-import ActionAccountBalanceWallet from 'material-ui/svg-icons/action/account-balance-wallet';
import * as React from 'react';
import { colors } from 'ts/style/colors';
diff --git a/packages/website/ts/components/wallet/wrap_ether_item.tsx b/packages/website/ts/components/wallet/wrap_ether_item.tsx
index 50b64d05c..a5052735b 100644
--- a/packages/website/ts/components/wallet/wrap_ether_item.tsx
+++ b/packages/website/ts/components/wallet/wrap_ether_item.tsx
@@ -3,7 +3,6 @@ import { BigNumber, logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import FlatButton from 'material-ui/FlatButton';
-import { ListItem } from 'material-ui/List';
import * as React from 'react';
import { Blockchain } from 'ts/blockchain';