Add getContractAddressAsync and tests

This commit is contained in:
Leonid Logvinov
2017-06-13 13:29:02 +02:00
parent 72318314c6
commit 52dc6b7710
2 changed files with 16 additions and 0 deletions

View File

@@ -543,6 +543,15 @@ export class ExchangeWrapper extends ContractWrapper {
logEventObj.watch(callback);
this._exchangeLogEventObjs.push(logEventObj);
}
/**
* Returns the ethereum address of the current exchange contract
* on the network that the provided web3 instance is connected to
* @return The ethereum address of the current exchange contract.
*/
public async getContractAddressAsync(): Promise<string> {
const exchangeContract = await this._getExchangeContractAsync();
return exchangeContract.address;
}
private async _isValidSignatureUsingContractCallAsync(dataHex: string, ecSignature: ECSignature,
signerAddressHex: string): Promise<boolean> {
assert.isHexString('dataHex', dataHex);

View File

@@ -22,6 +22,7 @@ import {
} from '../src';
import {FillScenarios} from './utils/fill_scenarios';
import {TokenUtils} from './utils/token_utils';
import {assert} from '../src/utils/assert';
chaiSetup.configure();
const expect = chai.expect;
@@ -709,4 +710,10 @@ describe('ExchangeWrapper', () => {
expect(orderHash).to.equal(orderHashFromContract);
});
});
describe('#getContractAddressAsync', () => {
it('returns the exchange contract address', async () => {
const exchangeAddress = await zeroEx.exchange.getContractAddressAsync();
assert.isETHAddressHex('exchangeAddress', exchangeAddress);
});
});
});