aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/contract_wrappers
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-23 01:53:04 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-24 05:13:36 +0800
commit4fe28ec53c4e84544c3c21853dff57c4c6a4e45d (patch)
tree4b44732136d006aa550bef0f8c4c60a980e18771 /packages/0x.js/src/contract_wrappers
parentefe8e07854ac5527725350e871dab370d022ae01 (diff)
downloaddexon-sol-tools-4fe28ec53c4e84544c3c21853dff57c4c6a4e45d.tar
dexon-sol-tools-4fe28ec53c4e84544c3c21853dff57c4c6a4e45d.tar.gz
dexon-sol-tools-4fe28ec53c4e84544c3c21853dff57c4c6a4e45d.tar.bz2
dexon-sol-tools-4fe28ec53c4e84544c3c21853dff57c4c6a4e45d.tar.lz
dexon-sol-tools-4fe28ec53c4e84544c3c21853dff57c4c6a4e45d.tar.xz
dexon-sol-tools-4fe28ec53c4e84544c3c21853dff57c4c6a4e45d.tar.zst
dexon-sol-tools-4fe28ec53c4e84544c3c21853dff57c4c6a4e45d.zip
Make zeroEx.exchange.getContractAddress non-async
Diffstat (limited to 'packages/0x.js/src/contract_wrappers')
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts19
1 files changed, 13 insertions, 6 deletions
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index 96b642a90..9ab03454c 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -664,7 +664,7 @@ export class ExchangeWrapper extends ContractWrapper {
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
- const exchangeContractAddress = await this.getContractAddressAsync();
+ const exchangeContractAddress = this.getContractAddress();
const subscriptionToken = this._subscribe<ArgsType>(
exchangeContractAddress, eventName, indexFilterValues, artifacts.ExchangeArtifact.abi, callback,
);
@@ -691,7 +691,7 @@ export class ExchangeWrapper extends ContractWrapper {
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, schemas.subscriptionOptsSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
- const exchangeContractAddress = await this.getContractAddressAsync();
+ const exchangeContractAddress = this.getContractAddress();
const logs = await this._getLogsAsync<ArgsType>(
exchangeContractAddress, eventName, subscriptionOpts, indexFilterValues, artifacts.ExchangeArtifact.abi,
);
@@ -702,10 +702,17 @@ export class ExchangeWrapper extends ContractWrapper {
* that the user-passed web3 provider is connected to.
* @returns The Ethereum address of the Exchange contract being used.
*/
- public async getContractAddressAsync(): Promise<string> {
- const exchangeInstance = await this._getExchangeContractAsync();
- const exchangeAddress = exchangeInstance.address;
- return exchangeAddress;
+ public getContractAddress(): string {
+ const networkId = this._web3Wrapper.getNetworkId();
+ if (_.isUndefined(this._contractAddressIfExists)) {
+ const contractAddress = artifacts.ExchangeArtifact.networks[networkId].address;
+ if (_.isUndefined(contractAddress)) {
+ throw new Error(ZeroExError.ExchangeContractDoesNotExist);
+ }
+ return contractAddress;
+ } else {
+ return this._contractAddressIfExists;
+ }
}
/**
* Checks if order is still fillable and throws an error otherwise. Useful for orderbook