Fix undefined ether balance
This commit is contained in:
@@ -20,7 +20,7 @@ interface EthWethConversionDialogProps {
|
||||
onCancelled: () => void;
|
||||
isOpen: boolean;
|
||||
token: Token;
|
||||
etherBalanceInWei: BigNumber;
|
||||
etherBalanceInWei?: BigNumber;
|
||||
lastForceTokenStateRefetch: number;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export class EthWethConversionDialog extends React.Component<
|
||||
<FlatButton key="convert" label="Convert" primary={true} onTouchTap={this._onConvertClick.bind(this)} />,
|
||||
];
|
||||
const title = this.props.direction === Side.Deposit ? 'Wrap ETH' : 'Unwrap WETH';
|
||||
return (
|
||||
return !_.isUndefined(this.props.etherBalanceInWei) ? (
|
||||
<Dialog
|
||||
title={title}
|
||||
titleStyle={{ fontWeight: 100 }}
|
||||
@@ -70,7 +70,7 @@ export class EthWethConversionDialog extends React.Component<
|
||||
>
|
||||
{this._renderConversionDialogBody()}
|
||||
</Dialog>
|
||||
);
|
||||
) : null;
|
||||
}
|
||||
private _renderConversionDialogBody(): React.ReactNode {
|
||||
const explanation =
|
||||
|
||||
@@ -18,7 +18,7 @@ interface EthWethConversionButtonProps {
|
||||
ethToken: Token;
|
||||
dispatcher: Dispatcher;
|
||||
blockchain: Blockchain;
|
||||
userEtherBalanceInWei?: BigNumber;
|
||||
userEtherBalanceInWei: BigNumber;
|
||||
isOutdatedWrappedEther: boolean;
|
||||
onConversionSuccessful?: () => void;
|
||||
isDisabled?: boolean;
|
||||
|
||||
@@ -97,10 +97,9 @@ export class EthWrappers extends React.Component<EthWrappersProps, EthWrappersSt
|
||||
EtherscanLinkSuffixes.Address,
|
||||
);
|
||||
const tokenLabel = this._renderToken('Wrapped Ether', etherToken.address, configs.ICON_URL_BY_SYMBOL.WETH);
|
||||
const userEtherBalanceInEth = Web3Wrapper.toUnitAmount(
|
||||
this.props.userEtherBalanceInWei,
|
||||
constants.DECIMAL_PLACES_ETH,
|
||||
);
|
||||
const userEtherBalanceInEth = !_.isUndefined(this.props.userEtherBalanceInWei)
|
||||
? Web3Wrapper.toUnitAmount(this.props.userEtherBalanceInWei, constants.DECIMAL_PLACES_ETH)
|
||||
: undefined;
|
||||
const rootClassName = this.props.isFullWidth ? 'clearfix' : 'clearfix lg-px4 md-px4 sm-px2';
|
||||
return (
|
||||
<div className={rootClassName} style={{ minHeight: 600 }}>
|
||||
@@ -148,7 +147,11 @@ export class EthWrappers extends React.Component<EthWrappersProps, EthWrappersSt
|
||||
</div>
|
||||
</TableRowColumn>
|
||||
<TableRowColumn>
|
||||
{userEtherBalanceInEth.toFixed(configs.AMOUNT_DISPLAY_PRECSION)} ETH
|
||||
{!_.isUndefined(userEtherBalanceInEth) ? (
|
||||
`${userEtherBalanceInEth.toFixed(configs.AMOUNT_DISPLAY_PRECSION)} ETH`
|
||||
) : (
|
||||
<i className="zmdi zmdi-spinner zmdi-hc-spin" />
|
||||
)}
|
||||
</TableRowColumn>
|
||||
<TableRowColumn>
|
||||
<EthWethConversionButton
|
||||
@@ -162,6 +165,7 @@ export class EthWrappers extends React.Component<EthWrappersProps, EthWrappersSt
|
||||
dispatcher={this.props.dispatcher}
|
||||
blockchain={this.props.blockchain}
|
||||
userEtherBalanceInWei={this.props.userEtherBalanceInWei}
|
||||
isDisabled={_.isUndefined(userEtherBalanceInEth)}
|
||||
/>
|
||||
</TableRowColumn>
|
||||
</TableRow>
|
||||
|
||||
Reference in New Issue
Block a user