aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/blockchain.ts
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 /packages/website/ts/blockchain.ts
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
Diffstat (limited to 'packages/website/ts/blockchain.ts')
-rw-r--r--packages/website/ts/blockchain.ts23
1 files changed, 22 insertions, 1 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) => {