From 68c240aa4d751511e6eecbd77fd9c2e4c11519f0 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 26 Sep 2017 11:44:33 +0200 Subject: Make getZRXTokenAddressAsync public --- src/contract_wrappers/exchange_wrapper.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 54d7f62d5..b6c82a5aa 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -637,7 +637,7 @@ export class ExchangeWrapper extends ContractWrapper { assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema); assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount); await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); - const zrxTokenAddress = await this._getZRXTokenAddressAsync(); + const zrxTokenAddress = await this.getZRXTokenAddressAsync(); await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync( signedOrder, fillTakerTokenAmount, takerAddress, zrxTokenAddress); } @@ -670,7 +670,7 @@ export class ExchangeWrapper extends ContractWrapper { assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema); assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount); await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); - const zrxTokenAddress = await this._getZRXTokenAddressAsync(); + const zrxTokenAddress = await this.getZRXTokenAddressAsync(); await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync( signedOrder, fillTakerTokenAmount, takerAddress, zrxTokenAddress); } @@ -708,6 +708,15 @@ export class ExchangeWrapper extends ContractWrapper { throw new Error(errMessage); } } + /** + * Returns an address of ZRX token used by the exchange contract. + * @return Address of ZRX token + */ + public async getZRXTokenAddressAsync(): Promise { + const exchangeInstance = await this._getExchangeContractAsync(); + const ZRXtokenAddress = await exchangeInstance.ZRX_TOKEN_CONTRACT.callAsync(); + return ZRXtokenAddress; + } private async _invalidateContractInstancesAsync(): Promise { await this.stopWatchingAllEventsAsync(); delete this._exchangeContractIfExists; @@ -745,11 +754,6 @@ export class ExchangeWrapper extends ContractWrapper { this._exchangeContractIfExists = contractInstance as ExchangeContract; return this._exchangeContractIfExists; } - private async _getZRXTokenAddressAsync(): Promise { - const exchangeInstance = await this._getExchangeContractAsync(); - const ZRXtokenAddress = await exchangeInstance.ZRX_TOKEN_CONTRACT.callAsync(); - return ZRXtokenAddress; - } private async _getTokenTransferProxyAddressAsync(): Promise { const exchangeInstance = await this._getExchangeContractAsync(); const tokenTransferProxyAddress = await exchangeInstance.TOKEN_TRANSFER_PROXY_CONTRACT.callAsync(); -- cgit From e347297aaaf314bc02c3e37d485e817bf5cf52a8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 26 Sep 2017 11:46:31 +0200 Subject: Document changes in CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61031c089..7c0d0cb88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +v0.17.0 - _September 26, 2017_ + * Made `zeroEx.exchange.getZRXTokenAddressAsync` public (#171) + v0.16.0 - _September 20, 2017_ ------------------------ * Added the ability to specify custom contract addresses to be used with 0x.js (#165) -- cgit From ee0adc8a7ed95db925cee4db7a16040883bec02b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 26 Sep 2017 11:55:15 +0200 Subject: Add a test for getZRXTokenAddressAsync --- test/exchange_wrapper_test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index f72e7f64f..9c0617671 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -591,4 +591,11 @@ describe('ExchangeWrapper', () => { expect(orderHash).to.equal(orderHashFromContract); }); }); + describe('#getZRXTokenAddressAsync', () => { + it('gets the same token as is in token registry', async () => { + const zrxAddress = await zeroEx.exchange.getZRXTokenAddressAsync(); + const zrxToken = tokenUtils.getProtocolTokenOrThrow(); + expect(zrxAddress).to.equal(zrxToken.address); + }); + }); }); -- cgit From 8a29f12a614f0024ee0e566a9444fb93a26be9cd Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 26 Sep 2017 15:02:12 +0200 Subject: Update comment --- src/contract_wrappers/exchange_wrapper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index b6c82a5aa..694f3b71b 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -709,7 +709,7 @@ export class ExchangeWrapper extends ContractWrapper { } } /** - * Returns an address of ZRX token used by the exchange contract. + * Returns the ZRX token address used by the exchange contract. * @return Address of ZRX token */ public async getZRXTokenAddressAsync(): Promise { -- cgit