diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-23 03:15:48 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-24 05:13:37 +0800 |
commit | c72745b0b27218a2a11529a90e0789f9e1b81d69 (patch) | |
tree | 338ea06e0718abbc008eda4f0f00f007251f85d4 /packages/0x.js/src | |
parent | 8935146240838fc84c9b73308908119f9567e6b3 (diff) | |
download | dexon-0x-contracts-c72745b0b27218a2a11529a90e0789f9e1b81d69.tar dexon-0x-contracts-c72745b0b27218a2a11529a90e0789f9e1b81d69.tar.gz dexon-0x-contracts-c72745b0b27218a2a11529a90e0789f9e1b81d69.tar.bz2 dexon-0x-contracts-c72745b0b27218a2a11529a90e0789f9e1b81d69.tar.lz dexon-0x-contracts-c72745b0b27218a2a11529a90e0789f9e1b81d69.tar.xz dexon-0x-contracts-c72745b0b27218a2a11529a90e0789f9e1b81d69.tar.zst dexon-0x-contracts-c72745b0b27218a2a11529a90e0789f9e1b81d69.zip |
Make zeroEx.tokenRegistry.getContractAddress non-async
Diffstat (limited to 'packages/0x.js/src')
-rw-r--r-- | packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts index 2cc5a9aa0..ae561f0d2 100644 --- a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import {Web3Wrapper} from '../web3_wrapper'; import {assert} from '../utils/assert'; -import {Token, TokenRegistryContract, TokenMetadata} from '../types'; +import {Token, TokenRegistryContract, TokenMetadata, ZeroExError} from '../types'; import {constants} from '../utils/constants'; import {ContractWrapper} from './contract_wrapper'; import {artifacts} from '../artifacts'; @@ -89,10 +89,17 @@ export class TokenRegistryWrapper extends ContractWrapper { * that the user-passed web3 provider is connected to. * @returns The Ethereum address of the TokenRegistry contract being used. */ - public async getContractAddressAsync(): Promise<string> { - const tokenRegistryInstance = await this._getTokenRegistryContractAsync(); - const tokenRegistryAddress = tokenRegistryInstance.address; - return tokenRegistryAddress; + public getContractAddress(): string { + const networkId = this._web3Wrapper.getNetworkId(); + if (_.isUndefined(this._contractAddressIfExists)) { + const contractAddress = artifacts.TokenRegistryArtifact.networks[networkId].address; + if (_.isUndefined(contractAddress)) { + throw new Error(ZeroExError.ExchangeContractDoesNotExist); + } + return contractAddress; + } else { + return this._contractAddressIfExists; + } } private _createTokenFromMetadata(metadata: TokenMetadata): Token|undefined { if (metadata[0] === constants.NULL_ADDRESS) { |