diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-30 03:20:41 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-30 03:20:41 +0800 |
commit | b1573fc6a779dbf20bbcd9216c70e2c211b4f8fe (patch) | |
tree | afa308490875413df786bdedb17bd6cc050e1206 | |
parent | cbe17aa44bb29c4ea1d84fb6584f30fac8d04e15 (diff) | |
download | dexon-sol-tools-b1573fc6a779dbf20bbcd9216c70e2c211b4f8fe.tar dexon-sol-tools-b1573fc6a779dbf20bbcd9216c70e2c211b4f8fe.tar.gz dexon-sol-tools-b1573fc6a779dbf20bbcd9216c70e2c211b4f8fe.tar.bz2 dexon-sol-tools-b1573fc6a779dbf20bbcd9216c70e2c211b4f8fe.tar.lz dexon-sol-tools-b1573fc6a779dbf20bbcd9216c70e2c211b4f8fe.tar.xz dexon-sol-tools-b1573fc6a779dbf20bbcd9216c70e2c211b4f8fe.tar.zst dexon-sol-tools-b1573fc6a779dbf20bbcd9216c70e2c211b4f8fe.zip |
Implement getProxyAuthorizedContractAddressesAsync
-rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 16 |
1 files changed, 16 insertions, 0 deletions
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 @@ -623,6 +623,18 @@ export class ExchangeWrapper extends ContractWrapper { } } /** + * 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<string[]> { + const exchangeContractAddresses = await this.getAvailableContractAddressesAsync(); + const proxyAuthorizedExchangeContractAddresses = _.filter( + exchangeContractAddresses, this._isExchangeContractAddressProxyAuthrizedAsync.bind(this)); + return proxyAuthorizedExchangeContractAddresses; + } + /** * Stops watching for all exchange events */ public async stopWatchingAllEventsAsync(): Promise<void> { @@ -631,6 +643,10 @@ export class ExchangeWrapper extends ContractWrapper { await Promise.all(stopWatchingPromises); this._exchangeLogEventEmitters = []; } + private async _isExchangeContractAddressProxyAuthrizedAsync(exchangeContractAddress: string): Promise<boolean> { + const isAuthorized = await this._proxyWrapper.isAuthorizedAsync(exchangeContractAddress); + return isAuthorized; + } private _wrapEventEmitter(event: ContractEventObj): ContractEventEmitter { const zeroExEvent = { watch: event.watch.bind(event), |