aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/blockchain.ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-09-07 19:03:02 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-09-07 19:05:11 +0800
commit8131c5d6bcf80a9d55bd881efe418d2b9fe8d29f (patch)
tree6b84e2f36a60514af5cf63dbf2c4806b8ef08c12 /packages/website/ts/blockchain.ts
parentdf5779b6d1a81f85b91c57fd2948ded91c1a07d7 (diff)
downloaddexon-sol-tools-8131c5d6bcf80a9d55bd881efe418d2b9fe8d29f.tar
dexon-sol-tools-8131c5d6bcf80a9d55bd881efe418d2b9fe8d29f.tar.gz
dexon-sol-tools-8131c5d6bcf80a9d55bd881efe418d2b9fe8d29f.tar.bz2
dexon-sol-tools-8131c5d6bcf80a9d55bd881efe418d2b9fe8d29f.tar.lz
dexon-sol-tools-8131c5d6bcf80a9d55bd881efe418d2b9fe8d29f.tar.xz
dexon-sol-tools-8131c5d6bcf80a9d55bd881efe418d2b9fe8d29f.tar.zst
dexon-sol-tools-8131c5d6bcf80a9d55bd881efe418d2b9fe8d29f.zip
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) => {