aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-23 23:41:05 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-24 05:15:00 +0800
commit34beee1edcd59b0f78c3dcce51cf847291ae06b4 (patch)
tree4befed4f518ec6d1d285b52e429db8c44a22ad46 /packages/0x.js/src
parent7bc6a7b23f655a62a71f5d28e3aadcd245f856b8 (diff)
downloaddexon-sol-tools-34beee1edcd59b0f78c3dcce51cf847291ae06b4.tar
dexon-sol-tools-34beee1edcd59b0f78c3dcce51cf847291ae06b4.tar.gz
dexon-sol-tools-34beee1edcd59b0f78c3dcce51cf847291ae06b4.tar.bz2
dexon-sol-tools-34beee1edcd59b0f78c3dcce51cf847291ae06b4.tar.lz
dexon-sol-tools-34beee1edcd59b0f78c3dcce51cf847291ae06b4.tar.xz
dexon-sol-tools-34beee1edcd59b0f78c3dcce51cf847291ae06b4.tar.zst
dexon-sol-tools-34beee1edcd59b0f78c3dcce51cf847291ae06b4.zip
Refactor getContractAddress to contractWrapper
Diffstat (limited to 'packages/0x.js/src')
-rw-r--r--packages/0x.js/src/contract_wrappers/contract_wrapper.ts2
-rw-r--r--packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts14
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts14
-rw-r--r--packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts14
-rw-r--r--packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts14
5 files changed, 17 insertions, 41 deletions
diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
index 2b99cfe4c..522b40d52 100644
--- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
@@ -141,7 +141,7 @@ export class ContractWrapper {
// We need to coerce to Block type cause Web3.Block includes types for mempool blocks
if (!_.isUndefined(this._blockAndLogStreamer)) {
// If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined
- await this._blockAndLogStreamer.reconcileNewBlock(latestBlock as any as Block);
+ this._blockAndLogStreamer.reconcileNewBlock(latestBlock as any as Block);
}
} catch (err) {
const filterTokens = _.keys(this._filterCallbacks);
diff --git a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
index 0ac21cb78..7a3f2bc52 100644
--- a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
@@ -70,16 +70,10 @@ export class EtherTokenWrapper extends ContractWrapper {
* @return The Wrapped Ether token contract address
*/
public getContractAddress(): string {
- const networkId = this._web3Wrapper.getNetworkId();
- if (_.isUndefined(this._contractAddressIfExists)) {
- const contractAddress = artifacts.EtherTokenArtifact.networks[networkId].address;
- if (_.isUndefined(contractAddress)) {
- throw new Error(ZeroExError.ExchangeContractDoesNotExist);
- }
- return contractAddress;
- } else {
- return this._contractAddressIfExists;
- }
+ const contractAddress = this._getContractAddress(
+ artifacts.EtherTokenArtifact, this._contractAddressIfExists,
+ );
+ return contractAddress;
}
private _invalidateContractInstance(): void {
delete this._etherTokenContractIfExists;
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index b35219b24..883cc0f49 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -830,16 +830,10 @@ export class ExchangeWrapper extends ContractWrapper {
* @return Address of ZRX token
*/
public getZRXTokenAddress(): string {
- const networkId = this._web3Wrapper.getNetworkId();
- if (_.isUndefined(this._zrxContractAddressIfExists)) {
- const zrxTokenAddress = artifacts.ZRXArtifact.networks[networkId].address;
- if (_.isUndefined(zrxTokenAddress)) {
- throw new Error(ZeroExError.ZRXContractDoesNotExist);
- }
- return zrxTokenAddress;
- } else {
- return this._zrxContractAddressIfExists;
- }
+ const contractAddress = this._getContractAddress(
+ artifacts.ZRXArtifact, this._zrxContractAddressIfExists,
+ );
+ return contractAddress;
}
private async _invalidateContractInstancesAsync(): Promise<void> {
this.unsubscribeAll();
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 468e58350..35337fa35 100644
--- a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts
@@ -104,16 +104,10 @@ export class TokenRegistryWrapper extends ContractWrapper {
* @returns The Ethereum address of the TokenRegistry contract being used.
*/
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;
- }
+ const contractAddress = this._getContractAddress(
+ artifacts.TokenRegistryArtifact, this._contractAddressIfExists,
+ );
+ return contractAddress;
}
private _invalidateContractInstance(): void {
delete this._tokenRegistryContractIfExists;
diff --git a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts
index 33adc0a9b..c3df7d3eb 100644
--- a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts
@@ -41,16 +41,10 @@ export class TokenTransferProxyWrapper extends ContractWrapper {
* @returns The Ethereum address of the TokenTransferProxy contract being used.
*/
public getContractAddress(): string {
- const networkId = this._web3Wrapper.getNetworkId();
- if (_.isUndefined(this._contractAddressIfExists)) {
- const contractAddress = artifacts.TokenTransferProxyArtifact.networks[networkId].address;
- if (_.isUndefined(contractAddress)) {
- throw new Error(ZeroExError.ExchangeContractDoesNotExist);
- }
- return contractAddress;
- } else {
- return this._contractAddressIfExists;
- }
+ const contractAddress = this._getContractAddress(
+ artifacts.TokenTransferProxyArtifact, this._contractAddressIfExists,
+ );
+ return contractAddress;
}
private _invalidateContractInstance(): void {
delete this._tokenTransferProxyContractIfExists;