From e744e4cd989bd3ae1070c59f7baa8097f18b8b06 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 22 Dec 2017 15:05:32 +0100 Subject: Apply prettier config --- packages/website/ts/components/eth_wrappers.tsx | 268 +++++++++++------------- 1 file changed, 122 insertions(+), 146 deletions(-) (limited to 'packages/website/ts/components/eth_wrappers.tsx') diff --git a/packages/website/ts/components/eth_wrappers.tsx b/packages/website/ts/components/eth_wrappers.tsx index 934df9176..fe733ea76 100644 --- a/packages/website/ts/components/eth_wrappers.tsx +++ b/packages/website/ts/components/eth_wrappers.tsx @@ -1,21 +1,14 @@ -import {ZeroEx} from '0x.js'; +import { ZeroEx } from '0x.js'; import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import Divider from 'material-ui/Divider'; -import { - Table, - TableBody, - TableHeader, - TableHeaderColumn, - TableRow, - TableRowColumn, -} from 'material-ui/Table'; +import { Table, TableBody, TableHeader, TableHeaderColumn, TableRow, TableRowColumn } from 'material-ui/Table'; import * as moment from 'moment'; import * as React from 'react'; import ReactTooltip = require('react-tooltip'); -import {Blockchain} from 'ts/blockchain'; -import {EthWethConversionButton} from 'ts/components/eth_weth_conversion_button'; -import {Dispatcher} from 'ts/redux/dispatcher'; +import { Blockchain } from 'ts/blockchain'; +import { EthWethConversionButton } from 'ts/components/eth_weth_conversion_button'; +import { Dispatcher } from 'ts/redux/dispatcher'; import { EtherscanLinkSuffixes, OutdatedWrappedEtherByNetworkId, @@ -25,10 +18,10 @@ import { TokenState, TokenStateByAddress, } from 'ts/types'; -import {colors} from 'ts/utils/colors'; -import {configs} from 'ts/utils/configs'; -import {constants} from 'ts/utils/constants'; -import {utils} from 'ts/utils/utils'; +import { colors } from 'ts/utils/colors'; +import { configs } from 'ts/utils/configs'; +import { constants } from 'ts/utils/constants'; +import { utils } from 'ts/utils/utils'; const PRECISION = 5; const DATE_FORMAT = 'D/M/YY'; @@ -83,24 +76,22 @@ export class EthWrappers extends React.Component +

ETH Wrapper

-
- +
+
About Wrapped ETH
@@ -112,14 +103,9 @@ export class EthWrappers extends React.Component
-
- Wrap ETH into an ERC20-compliant Ether token. 1 ETH = 1 WETH. -
+
Wrap ETH into an ERC20-compliant Ether token. 1 ETH = 1 WETH.
- +
ETH Token @@ -134,13 +120,13 @@ export class EthWrappers extends React.Component
-
+
ETH
@@ -164,9 +150,7 @@ export class EthWrappers extends React.Component {this._renderTokenLink(tokenLabel, etherscanUrl)} - - {wethBalance.toFixed(PRECISION)} WETH - + {wethBalance.toFixed(PRECISION)} WETH

Outdated WETH

-
+
The{' '} - + canonical WETH - contract is updated when necessary. - Unwrap outdated WETH in order to
 retrieve your ETH and move it - to the updated WETH token. + {' '} + contract is updated when necessary. Unwrap outdated WETH in order to
 retrieve your ETH and move + it to the updated WETH token.
-
+
WETH Version @@ -230,90 +208,94 @@ export class EthWrappers extends React.Component -
{leftSymbol}
+
+
{leftSymbol}
- +
-
{rightSymbol}
+
{rightSymbol}
); } private _renderOutdatedWeths(etherToken: Token, etherTokenState: TokenState) { - const rows = _.map(configs.OUTDATED_WRAPPED_ETHERS, - (outdatedWETHByNetworkId: OutdatedWrappedEtherByNetworkId) => { - const outdatedWETHIfExists = outdatedWETHByNetworkId[this.props.networkId]; - if (_.isUndefined(outdatedWETHIfExists)) { - return null; // noop - } - const timestampMsRange = outdatedWETHIfExists.timestampMsRange; - let dateRange: string; - if (!_.isUndefined(timestampMsRange)) { - const startMoment = moment(timestampMsRange.startTimestampMs); - const endMoment = moment(timestampMsRange.endTimestampMs); - dateRange = `${startMoment.format(DATE_FORMAT)}-${endMoment.format(DATE_FORMAT)}`; - } else { - dateRange = '-'; - } - const outdatedEtherToken = { - ...etherToken, - address: outdatedWETHIfExists.address, - }; - const isStateLoaded = this.state.outdatedWETHAddressToIsStateLoaded[outdatedWETHIfExists.address]; - const outdatedEtherTokenState = this.state.outdatedWETHStateByAddress[outdatedWETHIfExists.address]; - const balanceInEthIfExists = isStateLoaded ? - ZeroEx.toUnitAmount( - outdatedEtherTokenState.balance, constants.DECIMAL_PLACES_ETH, - ).toFixed(PRECISION) : - undefined; - const onConversionSuccessful = this._onOutdatedConversionSuccessfulAsync.bind( - this, outdatedWETHIfExists.address, - ); - const etherscanUrl = utils.getEtherScanLinkIfExists( - outdatedWETHIfExists.address, this.props.networkId, EtherscanLinkSuffixes.Address, - ); - const tokenLabel = this._renderToken(dateRange, outdatedEtherToken.address, OUTDATED_WETH_ICON_PATH); - return ( - - - {this._renderTokenLink(tokenLabel, etherscanUrl)} - - - {isStateLoaded ? - `${balanceInEthIfExists} WETH` : - - } - - - - - - ); - }); + const rows = _.map( + configs.OUTDATED_WRAPPED_ETHERS, + (outdatedWETHByNetworkId: OutdatedWrappedEtherByNetworkId) => { + const outdatedWETHIfExists = outdatedWETHByNetworkId[this.props.networkId]; + if (_.isUndefined(outdatedWETHIfExists)) { + return null; // noop + } + const timestampMsRange = outdatedWETHIfExists.timestampMsRange; + let dateRange: string; + if (!_.isUndefined(timestampMsRange)) { + const startMoment = moment(timestampMsRange.startTimestampMs); + const endMoment = moment(timestampMsRange.endTimestampMs); + dateRange = `${startMoment.format(DATE_FORMAT)}-${endMoment.format(DATE_FORMAT)}`; + } else { + dateRange = '-'; + } + const outdatedEtherToken = { + ...etherToken, + address: outdatedWETHIfExists.address, + }; + const isStateLoaded = this.state.outdatedWETHAddressToIsStateLoaded[outdatedWETHIfExists.address]; + const outdatedEtherTokenState = this.state.outdatedWETHStateByAddress[outdatedWETHIfExists.address]; + const balanceInEthIfExists = isStateLoaded + ? ZeroEx.toUnitAmount(outdatedEtherTokenState.balance, constants.DECIMAL_PLACES_ETH).toFixed( + PRECISION, + ) + : undefined; + const onConversionSuccessful = this._onOutdatedConversionSuccessfulAsync.bind( + this, + outdatedWETHIfExists.address, + ); + const etherscanUrl = utils.getEtherScanLinkIfExists( + outdatedWETHIfExists.address, + this.props.networkId, + EtherscanLinkSuffixes.Address, + ); + const tokenLabel = this._renderToken(dateRange, outdatedEtherToken.address, OUTDATED_WETH_ICON_PATH); + return ( + + + {this._renderTokenLink(tokenLabel, etherscanUrl)} + + + {isStateLoaded ? ( + `${balanceInEthIfExists} WETH` + ) : ( + + )} + + + + + + ); + }, + ); return rows; } private _renderTokenLink(tokenLabel: React.ReactNode, etherscanUrl: string) { return ( - {_.isUndefined(etherscanUrl) ? - tokenLabel : - + {_.isUndefined(etherscanUrl) ? ( + tokenLabel + ) : ( + {tokenLabel} - } + )} ); } @@ -321,18 +303,9 @@ export class EthWrappers extends React.Component - -
- + +
+ {name} {address} @@ -348,7 +321,8 @@ export class EthWrappers extends React.Component { - const outdatedWrappedEtherIfExists = outdatedWrappedEtherByNetwork[this.props.networkId]; - if (_.isUndefined(outdatedWrappedEtherIfExists)) { - return undefined; - } - const address = outdatedWrappedEtherIfExists.address; - return address; - })); + const outdatedWETHAddresses = _.compact( + _.map(configs.OUTDATED_WRAPPED_ETHERS, outdatedWrappedEtherByNetwork => { + const outdatedWrappedEtherIfExists = outdatedWrappedEtherByNetwork[this.props.networkId]; + if (_.isUndefined(outdatedWrappedEtherIfExists)) { + return undefined; + } + const address = outdatedWrappedEtherIfExists.address; + return address; + }), + ); return outdatedWETHAddresses; } } // tslint:disable:max-file-line-count -- cgit v1.2.3