aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-08-30 13:21:00 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-08-31 04:36:44 +0800
commit052824f4e30c6dce63f3b57591d0a5727c0bd4c2 (patch)
tree29a71233213fa1489ffe52e18e598c861e12f8c3 /packages
parenta6440b94f42012cf99287c9971728f3c5b71ce18 (diff)
downloaddexon-0x-contracts-052824f4e30c6dce63f3b57591d0a5727c0bd4c2.tar.gz
dexon-0x-contracts-052824f4e30c6dce63f3b57591d0a5727c0bd4c2.tar.zst
dexon-0x-contracts-052824f4e30c6dce63f3b57591d0a5727c0bd4c2.zip
Token registry from old 0x version
Diffstat (limited to 'packages')
-rw-r--r--packages/website/package.json1
-rw-r--r--packages/website/ts/blockchain.ts21
2 files changed, 13 insertions, 9 deletions
diff --git a/packages/website/package.json b/packages/website/package.json
index fff3dcb6c..8149c5c82 100644
--- a/packages/website/package.json
+++ b/packages/website/package.json
@@ -18,6 +18,7 @@
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
+ "0x.js": "^0.38.6",
"@0xproject/contract-wrappers": "^1.0.1-rc.5",
"@0xproject/order-utils": "^1.0.1-rc.6",
"@0xproject/react-docs": "^1.0.7",
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();
}