aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-13 19:29:02 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-13 19:29:02 +0800
commit52dc6b77104792852eb7cdffb4a088b35b46f2be (patch)
tree2b50d2ad0f9f7a724a633d1572454254cf731c04
parent72318314c66147b008d5ceedc02f8b8530960a9e (diff)
downloaddexon-sol-tools-52dc6b77104792852eb7cdffb4a088b35b46f2be.tar
dexon-sol-tools-52dc6b77104792852eb7cdffb4a088b35b46f2be.tar.gz
dexon-sol-tools-52dc6b77104792852eb7cdffb4a088b35b46f2be.tar.bz2
dexon-sol-tools-52dc6b77104792852eb7cdffb4a088b35b46f2be.tar.lz
dexon-sol-tools-52dc6b77104792852eb7cdffb4a088b35b46f2be.tar.xz
dexon-sol-tools-52dc6b77104792852eb7cdffb4a088b35b46f2be.tar.zst
dexon-sol-tools-52dc6b77104792852eb7cdffb4a088b35b46f2be.zip
Add getContractAddressAsync and tests
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts9
-rw-r--r--test/exchange_wrapper_test.ts7
2 files changed, 16 insertions, 0 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index a08901004..74b8d25c1 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -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);
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index deb76447e..f9cf9651f 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -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);
+ });
+ });
});