Make invalidateContractInstancesAsync private on exchange and token

This commit is contained in:
Leonid Logvinov
2017-07-04 11:12:56 -07:00
parent 43bebf6d61
commit 4ebf046cea
3 changed files with 10 additions and 10 deletions

View File

@@ -168,9 +168,9 @@ export class ZeroEx {
*/
public async setProviderAsync(provider: Web3Provider) {
this._web3Wrapper.setProvider(provider);
await this.exchange.invalidateContractInstancesAsync();
await (this.exchange as any)._invalidateContractInstancesAsync();
this.tokenRegistry.invalidateContractInstance();
await this.token.invalidateContractInstancesAsync();
await (this.token as any)._invalidateContractInstancesAsync();
this.proxy.invalidateContractInstance();
}
/**

View File

@@ -92,10 +92,6 @@ export class ExchangeWrapper extends ContractWrapper {
this._exchangeLogEventEmitters = [];
this._exchangeContractByAddress = {};
}
public async invalidateContractInstancesAsync(): Promise<void> {
await this.stopWatchingAllEventsAsync();
this._exchangeContractByAddress = {};
}
/**
* Returns the unavailable takerAmount of an order. Unavailable amount is defined as the total
* amount that has been filled or cancelled. The remaining takerAmount can be calculated by
@@ -658,6 +654,10 @@ export class ExchangeWrapper extends ContractWrapper {
await Promise.all(stopWatchingPromises);
this._exchangeLogEventEmitters = [];
}
private async _invalidateContractInstancesAsync(): Promise<void> {
await this.stopWatchingAllEventsAsync();
this._exchangeContractByAddress = {};
}
private async _isExchangeContractAddressProxyAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> {
const isAuthorized = await this._proxyWrapper.isAuthorizedAsync(exchangeContractAddress);
return isAuthorized;

View File

@@ -36,10 +36,6 @@ export class TokenWrapper extends ContractWrapper {
this._tokenContractsByAddress = {};
this._tokenLogEventEmitters = [];
}
public async invalidateContractInstancesAsync(): Promise<void> {
await this.stopWatchingAllEventsAsync();
this._tokenContractsByAddress = {};
}
/**
* Retrieves an owner's ERC20 token balance.
* @param tokenAddress The hex encoded contract Ethereum address where the ERC20 token is deployed.
@@ -236,6 +232,10 @@ export class TokenWrapper extends ContractWrapper {
await Promise.all(stopWatchingPromises);
this._tokenLogEventEmitters = [];
}
private async _invalidateContractInstancesAsync(): Promise<void> {
await this.stopWatchingAllEventsAsync();
this._tokenContractsByAddress = {};
}
private async _getTokenContractAsync(tokenAddress: string): Promise<TokenContract> {
let tokenContract = this._tokenContractsByAddress[tokenAddress];
if (!_.isUndefined(tokenContract)) {