aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/token_balances.tsx
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-10 02:02:07 +0800
committerFabio Berger <me@fabioberger.com>2018-03-10 02:02:07 +0800
commit7ebebb5bd9e0b60aab8dfac22bc1663d3fc13285 (patch)
treef943b6a3aabfea45eadc222e9bbfc3a2ce2906e9 /packages/website/ts/components/token_balances.tsx
parent8f921a61da6b9976ea680df4fd51147bb78040d9 (diff)
downloaddexon-sol-tools-7ebebb5bd9e0b60aab8dfac22bc1663d3fc13285.tar
dexon-sol-tools-7ebebb5bd9e0b60aab8dfac22bc1663d3fc13285.tar.gz
dexon-sol-tools-7ebebb5bd9e0b60aab8dfac22bc1663d3fc13285.tar.bz2
dexon-sol-tools-7ebebb5bd9e0b60aab8dfac22bc1663d3fc13285.tar.lz
dexon-sol-tools-7ebebb5bd9e0b60aab8dfac22bc1663d3fc13285.tar.xz
dexon-sol-tools-7ebebb5bd9e0b60aab8dfac22bc1663d3fc13285.tar.zst
dexon-sol-tools-7ebebb5bd9e0b60aab8dfac22bc1663d3fc13285.zip
Create blockchainWatcher class and refactor Portal such that Ether amounts are always passed around as baseUnits
Diffstat (limited to 'packages/website/ts/components/token_balances.tsx')
-rw-r--r--packages/website/ts/components/token_balances.tsx17
1 files changed, 12 insertions, 5 deletions
diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx
index 7e7596fd7..3c285803b 100644
--- a/packages/website/ts/components/token_balances.tsx
+++ b/packages/website/ts/components/token_balances.tsx
@@ -79,7 +79,7 @@ interface TokenBalancesProps {
tokenByAddress: TokenByAddress;
trackedTokens: Token[];
userAddress: string;
- userEtherBalance: BigNumber;
+ userEtherBalanceInWei: BigNumber;
networkId: number;
lastForceTokenStateRefetch: number;
}
@@ -119,11 +119,14 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
this._isUnmounted = true;
}
public componentWillReceiveProps(nextProps: TokenBalancesProps) {
- if (nextProps.userEtherBalance !== this.props.userEtherBalance) {
+ if (nextProps.userEtherBalanceInWei !== this.props.userEtherBalanceInWei) {
if (this.state.isBalanceSpinnerVisible) {
- const receivedAmount = nextProps.userEtherBalance.minus(this.props.userEtherBalance);
+ const receivedAmountInWei = nextProps.userEtherBalanceInWei.minus(this.props.userEtherBalanceInWei);
+ const receivedAmountInEth = ZeroEx.toUnitAmount(receivedAmountInWei, constants.DECIMAL_PLACES_ETH);
const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
- this.props.dispatcher.showFlashMessage(`Received ${receivedAmount.toString(10)} ${networkName} Ether`);
+ this.props.dispatcher.showFlashMessage(
+ `Received ${receivedAmountInEth.toString(10)} ${networkName} Ether`,
+ );
}
this.setState({
isBalanceSpinnerVisible: false,
@@ -205,6 +208,10 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
token balances in order to execute trades.<br> \
Toggling sets an allowance for the<br> \
smart contract so you can start trading that token.';
+ const userEtherBalanceInEth = ZeroEx.toUnitAmount(
+ this.props.userEtherBalanceInWei,
+ constants.DECIMAL_PLACES_ETH,
+ );
return (
<div className="lg-px4 md-px4 sm-px1 pb2">
<h3>{isTestNetwork ? 'Test ether' : 'Ether'}</h3>
@@ -241,7 +248,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
<img style={{ width: ICON_DIMENSION, height: ICON_DIMENSION }} src={ETHER_ICON_PATH} />
</TableRowColumn>
<TableRowColumn>
- {this.props.userEtherBalance.toFixed(PRECISION)} ETH
+ {userEtherBalanceInEth.toFixed(PRECISION)} ETH
{this.state.isBalanceSpinnerVisible && (
<span className="pl1">
<i className="zmdi zmdi-spinner zmdi-hc-spin" />