diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-08-30 13:21:00 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-08-31 04:36:44 +0800 |
commit | 052824f4e30c6dce63f3b57591d0a5727c0bd4c2 (patch) | |
tree | 29a71233213fa1489ffe52e18e598c861e12f8c3 /packages/website/ts | |
parent | a6440b94f42012cf99287c9971728f3c5b71ce18 (diff) | |
download | dexon-0x-contracts-052824f4e30c6dce63f3b57591d0a5727c0bd4c2.tar dexon-0x-contracts-052824f4e30c6dce63f3b57591d0a5727c0bd4c2.tar.gz dexon-0x-contracts-052824f4e30c6dce63f3b57591d0a5727c0bd4c2.tar.bz2 dexon-0x-contracts-052824f4e30c6dce63f3b57591d0a5727c0bd4c2.tar.lz dexon-0x-contracts-052824f4e30c6dce63f3b57591d0a5727c0bd4c2.tar.xz dexon-0x-contracts-052824f4e30c6dce63f3b57591d0a5727c0bd4c2.tar.zst dexon-0x-contracts-052824f4e30c6dce63f3b57591d0a5727c0bd4c2.zip |
Token registry from old 0x version
Diffstat (limited to 'packages/website/ts')
-rw-r--r-- | packages/website/ts/blockchain.ts | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index 2e6c33d4e..c2d0551bf 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -1,3 +1,4 @@ +import { ZeroEx } from '0x.js'; import { BlockRange, ContractWrappers, @@ -76,6 +77,7 @@ export class Blockchain { public networkId: number; public nodeVersion: string; private _contractWrappers: ContractWrappers; + private _zeroEx: ZeroEx; private readonly _dispatcher: Dispatcher; private _web3Wrapper?: Web3Wrapper; private _blockchainWatcher?: BlockchainWatcher; @@ -223,11 +225,9 @@ export class Blockchain { } } public async isAddressInTokenRegistryAsync(tokenAddress: string): Promise<boolean> { - utils.assert(!_.isUndefined(this._contractWrappers), 'Contract Wrappers must be instantiated.'); - // need to get rid of token registry - // const tokenIfExists = await this._contractWrappers.tokenRegistry.getTokenIfExistsAsync(tokenAddress); - // return !_.isUndefined(tokenIfExists); - return false; + utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.'); + const tokenIfExists = await this._zeroEx.tokenRegistry.getTokenIfExistsAsync(tokenAddress); + return !_.isUndefined(tokenIfExists); } public getLedgerDerivationPathIfExists(): string { if (_.isUndefined(this._ledgerSubprovider)) { @@ -797,10 +797,8 @@ export class Blockchain { if (this.networkId === constants.NETWORK_ID_MAINNET) { tokenRegistryTokens = await backendClient.getTokenInfosAsync(); } else { - // get rid of token registry - // utils.assert(!_.isUndefined(this._contractWrappers), 'ContractWrappers must be instantiated.'); - // tokenRegistryTokens = await this._contractWrappers.tokenRegistry.getTokensAsync(); - tokenRegistryTokens = [] as ZeroExToken[]; + utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.'); + tokenRegistryTokens = await this._zeroEx.tokenRegistry.getTokensAsync(); } const tokenByAddress: TokenByAddress = {}; _.each(tokenRegistryTokens, (t: ZeroExToken) => { @@ -880,6 +878,11 @@ export class Blockchain { } else { this._contractWrappers = new ContractWrappers(provider, { networkId }); } + if (!_.isUndefined(this._zeroEx)) { + this._zeroEx.setProvider(provider, networkId); + } else { + this._zeroEx = new ZeroEx(provider, { networkId }); + } if (!_.isUndefined(this._blockchainWatcher)) { this._blockchainWatcher.destroy(); } |