From b1573fc6a779dbf20bbcd9216c70e2c211b4f8fe Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 29 Jun 2017 12:20:41 -0700 Subject: Implement getProxyAuthorizedContractAddressesAsync --- src/contract_wrappers/exchange_wrapper.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/contract_wrappers/exchange_wrapper.ts') diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index c4dfb4318..1dd83b763 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -622,6 +622,18 @@ export class ExchangeWrapper extends ContractWrapper { return exchangeAddresses; } } + /** + * Returns the ethereum addresses of all available exchange contracts + * on the network that the provided web3 instance is connected to + * that are currently authorized on the Proxy contract + * @return The ethereum addresses of all available and authorized exchange contract. + */ + public async getProxyAuthorizedContractAddressesAsync(): Promise { + const exchangeContractAddresses = await this.getAvailableContractAddressesAsync(); + const proxyAuthorizedExchangeContractAddresses = _.filter( + exchangeContractAddresses, this._isExchangeContractAddressProxyAuthrizedAsync.bind(this)); + return proxyAuthorizedExchangeContractAddresses; + } /** * Stops watching for all exchange events */ @@ -631,6 +643,10 @@ export class ExchangeWrapper extends ContractWrapper { await Promise.all(stopWatchingPromises); this._exchangeLogEventEmitters = []; } + private async _isExchangeContractAddressProxyAuthrizedAsync(exchangeContractAddress: string): Promise { + const isAuthorized = await this._proxyWrapper.isAuthorizedAsync(exchangeContractAddress); + return isAuthorized; + } private _wrapEventEmitter(event: ContractEventObj): ContractEventEmitter { const zeroExEvent = { watch: event.watch.bind(event), -- cgit v1.2.3