diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-11 19:49:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-11 19:49:15 +0800 |
commit | 870ba445b85aec8331059ebdc80e8d37d73bf9cf (patch) | |
tree | 6b29441ee2831f3bc22bf289b9e2bad667199b5b /packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx | |
parent | 0aad2ee005c0d6d530dd870ec1dd38399359a3c4 (diff) | |
parent | caaa70f6302b0d84d43ca93ab014e0cf37886c0a (diff) | |
download | dexon-sol-tools-870ba445b85aec8331059ebdc80e8d37d73bf9cf.tar dexon-sol-tools-870ba445b85aec8331059ebdc80e8d37d73bf9cf.tar.gz dexon-sol-tools-870ba445b85aec8331059ebdc80e8d37d73bf9cf.tar.bz2 dexon-sol-tools-870ba445b85aec8331059ebdc80e8d37d73bf9cf.tar.lz dexon-sol-tools-870ba445b85aec8331059ebdc80e8d37d73bf9cf.tar.xz dexon-sol-tools-870ba445b85aec8331059ebdc80e8d37d73bf9cf.tar.zst dexon-sol-tools-870ba445b85aec8331059ebdc80e8d37d73bf9cf.zip |
Merge pull request #444 from 0xProject/dedupWeb3Wrapper
Remove custom web3Wrapper from website
Diffstat (limited to 'packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx')
-rw-r--r-- | packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx index 5c61f0d57..d1bdb447f 100644 --- a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx +++ b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx @@ -1,5 +1,7 @@ +import { ZeroEx } from '0x.js'; import { colors } from '@0xproject/react-shared'; import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import * as React from 'react'; @@ -7,6 +9,7 @@ import { Blockchain } from 'ts/blockchain'; import { EthAmountInput } from 'ts/components/inputs/eth_amount_input'; import { TokenAmountInput } from 'ts/components/inputs/token_amount_input'; import { Side, Token } from 'ts/types'; +import { constants } from 'ts/utils/constants'; interface EthWethConversionDialogProps { blockchain: Blockchain; @@ -17,7 +20,7 @@ interface EthWethConversionDialogProps { onCancelled: () => void; isOpen: boolean; token: Token; - etherBalance: BigNumber; + etherBalanceInWei: BigNumber; lastForceTokenStateRefetch: number; } @@ -75,6 +78,7 @@ export class EthWethConversionDialog extends React.Component< ? 'Convert your Ether into a tokenized, tradable form.' : "Convert your Wrapped Ether back into it's native form."; const isWrappedVersion = this.props.direction === Side.Receive; + const etherBalanceInEth = ZeroEx.toUnitAmount(this.props.etherBalanceInWei, constants.DECIMAL_PLACES_ETH); return ( <div> <div className="pb2">{explanation}</div> @@ -103,7 +107,7 @@ export class EthWethConversionDialog extends React.Component< /> ) : ( <EthAmountInput - balance={this.props.etherBalance} + balance={etherBalanceInEth} amount={this.state.value} onChange={this._onValueChange.bind(this)} shouldCheckBalance={true} @@ -182,8 +186,9 @@ export class EthWethConversionDialog extends React.Component< this.props.onCancelled(); } private async _fetchEthTokenBalanceAsync() { + const userAddressIfExists = _.isEmpty(this.props.userAddress) ? undefined : this.props.userAddress; const [balance] = await this.props.blockchain.getTokenBalanceAndAllowanceAsync( - this.props.userAddress, + userAddressIfExists, this.props.token.address, ); if (!this._isUnmounted) { |