aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts')
-rw-r--r--packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts26
1 files changed, 14 insertions, 12 deletions
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 f81845af9..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
@@ -1,18 +1,20 @@
import * as _ from 'lodash';
+
+import {artifacts} from '../artifacts';
+import {TokenTransferProxyContract, ZeroExError} from '../types';
import {Web3Wrapper} from '../web3_wrapper';
+
import {ContractWrapper} from './contract_wrapper';
-import {artifacts} from '../artifacts';
-import {TokenTransferProxyContract} from '../types';
/**
* This class includes the functionality related to interacting with the TokenTransferProxy contract.
*/
export class TokenTransferProxyWrapper extends ContractWrapper {
private _tokenTransferProxyContractIfExists?: TokenTransferProxyContract;
- private _tokenTransferProxyContractAddressFetcher: () => Promise<string>;
- constructor(web3Wrapper: Web3Wrapper, tokenTransferProxyContractAddressFetcher: () => Promise<string>) {
+ private _contractAddressIfExists?: string;
+ constructor(web3Wrapper: Web3Wrapper, contractAddressIfExists?: string) {
super(web3Wrapper);
- this._tokenTransferProxyContractAddressFetcher = tokenTransferProxyContractAddressFetcher;
+ this._contractAddressIfExists = contractAddressIfExists;
}
/**
* Check if the Exchange contract address is authorized by the TokenTransferProxy contract.
@@ -38,10 +40,11 @@ export class TokenTransferProxyWrapper extends ContractWrapper {
* that the user-passed web3 provider is connected to.
* @returns The Ethereum address of the TokenTransferProxy contract being used.
*/
- public async getContractAddressAsync(): Promise<string> {
- const proxyInstance = await this._getTokenTransferProxyContractAsync();
- const proxyAddress = proxyInstance.address;
- return proxyAddress;
+ public getContractAddress(): string {
+ const contractAddress = this._getContractAddress(
+ artifacts.TokenTransferProxyArtifact, this._contractAddressIfExists,
+ );
+ return contractAddress;
}
private _invalidateContractInstance(): void {
delete this._tokenTransferProxyContractIfExists;
@@ -50,11 +53,10 @@ export class TokenTransferProxyWrapper extends ContractWrapper {
if (!_.isUndefined(this._tokenTransferProxyContractIfExists)) {
return this._tokenTransferProxyContractIfExists;
}
- const contractAddress = await this._tokenTransferProxyContractAddressFetcher();
const contractInstance = await this._instantiateContractIfExistsAsync<TokenTransferProxyContract>(
- artifacts.TokenTransferProxyArtifact, contractAddress,
+ artifacts.TokenTransferProxyArtifact, this._contractAddressIfExists,
);
- this._tokenTransferProxyContractIfExists = contractInstance as TokenTransferProxyContract;
+ this._tokenTransferProxyContractIfExists = contractInstance;
return this._tokenTransferProxyContractIfExists;
}
}