import {ZeroEx} from '0x.js'; import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import Divider from 'material-ui/Divider'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; import {colors} from 'material-ui/styles'; import { Table, TableBody, TableHeader, TableHeaderColumn, TableRow, TableRowColumn, } from 'material-ui/Table'; import * as moment from 'moment'; import * as React from 'react'; import {Blockchain} from 'ts/blockchain'; import {LifeCycleRaisedButton} from 'ts/components/ui/lifecycle_raised_button'; import {trackedTokenStorage} from 'ts/local_storage/tracked_token_storage'; import {Dispatcher} from 'ts/redux/dispatcher'; import { OutdatedWrappedEther, TokenByAddress, TokenStateByAddress, } from 'ts/types'; import {configs} from 'ts/utils/configs'; import {constants} from 'ts/utils/constants'; import {errorReporter} from 'ts/utils/error_reporter'; import {utils} from 'ts/utils/utils'; const PRECISION = 5; const DATE_FORMAT = 'D/M/YY'; const ICON_DIMENSION = 40; const ETHER_ICON_PATH = '/images/ether.png'; const OUTDATED_WETH_ICON_PATH = '/images/wrapped_eth_gray.png'; const ETHER_TOKEN_SYMBOL = 'WETH'; interface EthWrappersProps { networkId: number; blockchain: Blockchain; dispatcher: Dispatcher; tokenByAddress: TokenByAddress; tokenStateByAddress: TokenStateByAddress; userAddress: string; userEtherBalance: BigNumber; } interface EthWrappersState {} export class EthWrappers extends React.Component { constructor(props: EthWrappersProps) { super(props); this.state = {}; } public componentDidMount() { window.scrollTo(0, 0); } public render() { const tokens = _.values(this.props.tokenByAddress); const wethToken = _.find(tokens, {symbol: 'WETH'}); const wethState = this.props.tokenStateByAddress[wethToken.address]; const wethBalance = ZeroEx.toUnitAmount(wethState.balance, 18); return (

ETH Wrapper

Wrap ETH into an ERC20-compliant Ether token
ETH Token Balance {'ETH <-> WETH'}
Ether
{this.props.userEtherBalance.toFixed(PRECISION)} ETH
Wrapped Ether
{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.
WETH Version Balance {'WETH -> ETH'} {this.renderOutdatedWeths()}
); } private renderOutdatedWeths() { const rows = _.map(configs.outdatedWrappedEthers, (outdatedWETH: OutdatedWrappedEther) => { const timestampMsRange = outdatedWETH.timestampMsRangeByNetworkId[this.props.networkId]; const startMoment = moment(timestampMsRange.startTimestampMs); const endMoment = moment(timestampMsRange.endTimestampMs); return (
{startMoment.format(DATE_FORMAT)}-{endMoment.format(DATE_FORMAT)}
0 WETH
); }); return rows; } private async wrapEthAsync() { // TODO } private async unwrapEthAsync() { // TODO } } // tslint:disable:max-file-line-count