aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancesco Agosti <francesco.agosti93@gmail.com>2018-09-07 22:12:50 +0800
committerGitHub <noreply@github.com>2018-09-07 22:12:50 +0800
commit45b68832aa3eb5c09db33140468ab737114be9e3 (patch)
treecf3adc90e447e96d410a592db7e21155abb17986
parentdf5779b6d1a81f85b91c57fd2948ded91c1a07d7 (diff)
parent6dfcaaf88941222c11a6d0b57aded6e4b07ae537 (diff)
downloaddexon-sol-tools-45b68832aa3eb5c09db33140468ab737114be9e3.tar
dexon-sol-tools-45b68832aa3eb5c09db33140468ab737114be9e3.tar.gz
dexon-sol-tools-45b68832aa3eb5c09db33140468ab737114be9e3.tar.bz2
dexon-sol-tools-45b68832aa3eb5c09db33140468ab737114be9e3.tar.lz
dexon-sol-tools-45b68832aa3eb5c09db33140468ab737114be9e3.tar.xz
dexon-sol-tools-45b68832aa3eb5c09db33140468ab737114be9e3.tar.zst
dexon-sol-tools-45b68832aa3eb5c09db33140468ab737114be9e3.zip
Merge pull request #1064 from 0xProject/patch/website/new-token-addresses
[website] Fix minting for new tokens on testnets
-rw-r--r--packages/website/ts/blockchain.ts23
-rw-r--r--packages/website/ts/components/token_balances.tsx18
-rw-r--r--packages/website/ts/utils/configs.ts27
-rw-r--r--packages/website/ts/utils/constants.ts1
-rw-r--r--packages/website/ts/utils/token_address_overrides.ts24
5 files changed, 52 insertions, 41 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index a976f915f..d3f2f3f7b 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -27,6 +27,7 @@ import * as _ from 'lodash';
import * as moment from 'moment';
import * as React from 'react';
import contract = require('truffle-contract');
+import { tokenAddressOverrides } from 'ts/utils/token_address_overrides';
import { BlockchainWatcher } from 'ts/blockchain_watcher';
import { AssetSendCompleted } from 'ts/components/flash_messages/asset_send_completed';
@@ -223,7 +224,13 @@ export class Blockchain {
public async isAddressInTokenRegistryAsync(tokenAddress: string): Promise<boolean> {
utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.');
const tokenIfExists = await this._zeroEx.tokenRegistry.getTokenIfExistsAsync(tokenAddress);
- return !_.isUndefined(tokenIfExists);
+ // HACK: Override token addresses on testnets
+ const tokenSymbolToAddressOverrides = tokenAddressOverrides[this.networkId];
+ let isTokenAddressInOverrides = false;
+ if (!_.isUndefined(tokenSymbolToAddressOverrides)) {
+ isTokenAddressInOverrides = _.keys(tokenSymbolToAddressOverrides).includes(tokenAddress);
+ }
+ return !_.isUndefined(tokenIfExists) || isTokenAddressInOverrides;
}
public getLedgerDerivationPathIfExists(): string {
if (_.isUndefined(this._ledgerSubprovider)) {
@@ -771,6 +778,20 @@ export class Blockchain {
} else {
utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.');
tokenRegistryTokens = await this._zeroEx.tokenRegistry.getTokensAsync();
+ const tokenSymbolToAddressOverrides = tokenAddressOverrides[this.networkId];
+ if (!_.isUndefined(tokenAddressOverrides)) {
+ // HACK: Override token addresses on testnets
+ tokenRegistryTokens = _.map(tokenRegistryTokens, (token: ZeroExToken) => {
+ const overrideIfExists = tokenSymbolToAddressOverrides[token.symbol];
+ if (!_.isUndefined(overrideIfExists)) {
+ return {
+ ...token,
+ address: overrideIfExists,
+ };
+ }
+ return token;
+ });
+ }
}
const tokenByAddress: TokenByAddress = {};
_.each(tokenRegistryTokens, (t: ZeroExToken) => {
diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx
index 7e7a8d1fa..5965ad9bd 100644
--- a/packages/website/ts/components/token_balances.tsx
+++ b/packages/website/ts/components/token_balances.tsx
@@ -337,14 +337,8 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
const isMintable =
(_.includes(configs.SYMBOLS_OF_MINTABLE_KOVAN_TOKENS, token.symbol) &&
this.props.networkId === sharedConstants.NETWORK_ID_BY_NAME[Networks.Kovan]) ||
- (_.includes(configs.SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS, token.symbol) &&
- _.includes(
- [
- sharedConstants.NETWORK_ID_BY_NAME[Networks.Rinkeby],
- sharedConstants.NETWORK_ID_BY_NAME[Networks.Ropsten],
- ],
- this.props.networkId,
- ));
+ (_.includes(configs.SYMBOLS_OF_MINTABLE_ROPSTEN_TOKENS, token.symbol) &&
+ this.props.networkId === sharedConstants.NETWORK_ID_BY_NAME[Networks.Ropsten]);
return (
<TableRow key={token.address} style={{ height: TOKEN_TABLE_ROW_HEIGHT }}>
<TableRowColumn colSpan={tokenColSpan}>
@@ -392,14 +386,6 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
onClickAsyncFn={this._onMintTestTokensAsync.bind(this, token)}
/>
)}
- {token.symbol === ZRX_TOKEN_SYMBOL && (
- <LifeCycleRaisedButton
- labelReady="Request"
- labelLoading="Sending..."
- labelComplete="Sent!"
- onClickAsyncFn={this._faucetRequestAsync.bind(this, false)}
- />
- )}
</TableRowColumn>
)}
{this.props.screenWidth !== ScreenWidths.Sm && (
diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts
index a1c64f9cb..7b74eccfb 100644
--- a/packages/website/ts/utils/configs.ts
+++ b/packages/website/ts/utils/configs.ts
@@ -18,7 +18,7 @@ export const configs = {
DOMAIN_PRODUCTION: '0xproject.com',
GOOGLE_ANALYTICS_ID: 'UA-98720122-1',
LAST_LOCAL_STORAGE_FILL_CLEARANCE_DATE: '2017-11-22',
- LAST_LOCAL_STORAGE_TRACKED_TOKEN_CLEARANCE_DATE: '2018-7-5',
+ LAST_LOCAL_STORAGE_TRACKED_TOKEN_CLEARANCE_DATE: '2018-9-7',
OUTDATED_WRAPPED_ETHERS: [
{
42: {
@@ -44,27 +44,6 @@ export const configs = {
[3]: [`https://ropsten.infura.io/${INFURA_API_KEY}`],
[4]: [`https://rinkeby.infura.io/${INFURA_API_KEY}`],
} as PublicNodeUrlsByNetworkId,
- SYMBOLS_OF_MINTABLE_KOVAN_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'],
- SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS: [
- 'TKN0',
- 'TKN1',
- 'TKN2',
- 'TKN3',
- 'TKN4',
- 'TKN5',
- 'TKN6',
- 'TKN7',
- 'TKN8',
- 'TKN9',
- 'TKN10',
- 'TKN11',
- 'TKN12',
- 'TKN13',
- 'TKN14',
- 'TKN15',
- 'TKN16',
- 'TKN17',
- 'TKN18',
- 'TKN19',
- ],
+ SYMBOLS_OF_MINTABLE_KOVAN_TOKENS: ['ZRX', 'MKR', 'MLN', 'GNT', 'DGD', 'REP'],
+ SYMBOLS_OF_MINTABLE_ROPSTEN_TOKENS: ['ZRX', 'MKR', 'MLN', 'GNT', 'DGD', 'REP'],
};
diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts
index 005d17823..23d419907 100644
--- a/packages/website/ts/utils/constants.ts
+++ b/packages/website/ts/utils/constants.ts
@@ -24,6 +24,7 @@ export const constants = {
NETWORK_ID_MAINNET: 1,
NETWORK_ID_KOVAN: 42,
NETWORK_ID_TESTRPC: 50,
+ NETWORK_ID_ROPSTEN: 3,
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
PROVIDER_NAME_LEDGER: 'Ledger',
PROVIDER_NAME_METAMASK: 'MetaMask',
diff --git a/packages/website/ts/utils/token_address_overrides.ts b/packages/website/ts/utils/token_address_overrides.ts
new file mode 100644
index 000000000..8353358bc
--- /dev/null
+++ b/packages/website/ts/utils/token_address_overrides.ts
@@ -0,0 +1,24 @@
+import { ObjectMap } from 'ts/types';
+import { constants } from 'ts/utils/constants';
+
+// Map of networkId -> tokenSymbol -> tokenAddress
+export type TokenOverrides = ObjectMap<ObjectMap<string>>;
+
+export const tokenAddressOverrides: TokenOverrides = {
+ [constants.NETWORK_ID_KOVAN]: {
+ ZRX: '0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa',
+ REP: '0x8cb3971b8eb709c14616bd556ff6683019e90d9c',
+ DGD: '0xa4f468c9c692eb6b4b8b06270dae7a2cfeedcde9',
+ GNT: '0x31fb614e223706f15d0d3c5f4b08bdf0d5c78623',
+ MKR: '0x7b6b10caa9e8e9552ba72638ea5b47c25afea1f3',
+ MLN: '0x17e394d1df6ce29d042195ea38411a98ff3ead94',
+ },
+ [constants.NETWORK_ID_ROPSTEN]: {
+ ZRX: '0xff67881f8d12f372d91baae9752eb3631ff0ed00',
+ REP: '0xb0b443fe0e8a04c4c85e8fda9c5c1ccc057d6653',
+ DGD: '0xc4895a5aafa2708d6bc1294e20ec839aad156b1d',
+ GNT: '0x7f8acc55a359ca4517c30510566ac35b800f7cac',
+ MKR: '0x06732516acd125b6e83c127752ed5f027e1b276e',
+ MLN: '0x823ebe83d39115536274a8617e00a1ff3544fd63',
+ },
+};