aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-12-18 06:09:16 +0800
committerFabio Berger <me@fabioberger.com>2017-12-18 06:09:16 +0800
commit95dfac6f9bbf8cf0de2038cfbd4eabb53b979fcd (patch)
treec8a23c458ee89da3fac0cc522db6214cbf7be546
parentb2256679bef6c39ee5889f12838d1c2e9d4dd832 (diff)
downloaddexon-sol-tools-95dfac6f9bbf8cf0de2038cfbd4eabb53b979fcd.tar
dexon-sol-tools-95dfac6f9bbf8cf0de2038cfbd4eabb53b979fcd.tar.gz
dexon-sol-tools-95dfac6f9bbf8cf0de2038cfbd4eabb53b979fcd.tar.bz2
dexon-sol-tools-95dfac6f9bbf8cf0de2038cfbd4eabb53b979fcd.tar.lz
dexon-sol-tools-95dfac6f9bbf8cf0de2038cfbd4eabb53b979fcd.tar.xz
dexon-sol-tools-95dfac6f9bbf8cf0de2038cfbd4eabb53b979fcd.tar.zst
dexon-sol-tools-95dfac6f9bbf8cf0de2038cfbd4eabb53b979fcd.zip
Make it such that Wrapped Ether page works on networks without any outdated WETH tokens
-rw-r--r--packages/website/ts/components/eth_wrappers.tsx30
1 files changed, 19 insertions, 11 deletions
diff --git a/packages/website/ts/components/eth_wrappers.tsx b/packages/website/ts/components/eth_wrappers.tsx
index a6a1df751..3ffb05ce0 100644
--- a/packages/website/ts/components/eth_wrappers.tsx
+++ b/packages/website/ts/components/eth_wrappers.tsx
@@ -246,8 +246,11 @@ export class EthWrappers extends React.Component<EthWrappersProps, EthWrappersSt
private renderOutdatedWeths(etherToken: Token, etherTokenState: TokenState) {
const rows = _.map(configs.outdatedWrappedEthers,
(outdatedWETHByNetworkId: OutdatedWrappedEtherByNetworkId) => {
- const outdatedWETH = outdatedWETHByNetworkId[this.props.networkId];
- const timestampMsRange = outdatedWETH.timestampMsRange;
+ 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);
@@ -258,20 +261,20 @@ export class EthWrappers extends React.Component<EthWrappersProps, EthWrappersSt
}
const outdatedEtherToken = {
...etherToken,
- address: outdatedWETH.address,
+ address: outdatedWETHIfExists.address,
};
- const isStateLoaded = this.state.outdatedWETHAddressToIsStateLoaded[outdatedWETH.address];
- const outdatedEtherTokenState = this.state.outdatedWETHStateByAddress[outdatedWETH.address];
+ const isStateLoaded = this.state.outdatedWETHAddressToIsStateLoaded[outdatedWETHIfExists.address];
+ const outdatedEtherTokenState = this.state.outdatedWETHStateByAddress[outdatedWETHIfExists.address];
const balanceInEthIfExists = isStateLoaded ?
ZeroEx.toUnitAmount(outdatedEtherTokenState.balance, 18).toFixed(PRECISION) :
undefined;
- const onConversionSuccessful = this.onOutdatedConversionSuccessfulAsync.bind(this, outdatedWETH.address);
+ const onConversionSuccessful = this.onOutdatedConversionSuccessfulAsync.bind(this, outdatedWETHIfExists.address);
const etherscanUrl = utils.getEtherScanLinkIfExists(
- outdatedWETH.address, this.props.networkId, EtherscanLinkSuffixes.address,
+ outdatedWETHIfExists.address, this.props.networkId, EtherscanLinkSuffixes.address,
);
const tokenLabel = this.renderToken(dateRange, outdatedEtherToken.address, OUTDATED_WETH_ICON_PATH);
return (
- <TableRow key={`weth-${outdatedWETH.address}`}>
+ <TableRow key={`weth-${outdatedWETHIfExists.address}`}>
<TableRowColumn className="py1">
{this.renderTokenLink(tokenLabel, etherscanUrl)}
</TableRowColumn>
@@ -378,9 +381,14 @@ export class EthWrappers extends React.Component<EthWrappersProps, EthWrappersSt
});
}
private getOutdatedWETHAddresses(): string[] {
- const outdatedWETHAddresses = _.map(configs.outdatedWrappedEthers, outdatedWrappedEther => {
- return outdatedWrappedEther[this.props.networkId].address;
- });
+ const outdatedWETHAddresses = _.compact(_.map(configs.outdatedWrappedEthers, 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