aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-08 18:03:14 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-08 18:03:14 +0800
commit464e761053e1f84a05dbc6af2512effafa8d6350 (patch)
treebc1d9fc14206b2241d907f78224b139afcd08aad
parentc6645f9f4f470323086d9004cf603a68091d71a3 (diff)
downloaddexon-sol-tools-464e761053e1f84a05dbc6af2512effafa8d6350.tar
dexon-sol-tools-464e761053e1f84a05dbc6af2512effafa8d6350.tar.gz
dexon-sol-tools-464e761053e1f84a05dbc6af2512effafa8d6350.tar.bz2
dexon-sol-tools-464e761053e1f84a05dbc6af2512effafa8d6350.tar.lz
dexon-sol-tools-464e761053e1f84a05dbc6af2512effafa8d6350.tar.xz
dexon-sol-tools-464e761053e1f84a05dbc6af2512effafa8d6350.tar.zst
dexon-sol-tools-464e761053e1f84a05dbc6af2512effafa8d6350.zip
Add getOrderHashHexUsingContractCallAsync
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts6
-rw-r--r--test/exchange_wrapper_test.ts22
2 files changed, 28 insertions, 0 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index d144d8aad..9cb2332fe 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -342,6 +342,12 @@ export class ExchangeWrapper extends ContractWrapper {
const orderHashHex = utils.getOrderHashHex(order, exchangeInstance.address);
return orderHashHex;
}
+ private async getOrderHashHexUsingContractCallAsync(order: Order|SignedOrder): Promise<string> {
+ const exchangeInstance = await this.getExchangeContractAsync();
+ const [orderAddresses, orderValues] = ExchangeWrapper.getOrderAddressesAndValues(order);
+ const orderHashHex = await exchangeInstance.getOrderHash.call(orderAddresses, orderValues);
+ return orderHashHex;
+ }
private async stopWatchingExchangeLogEventsAsync() {
const stopWatchingPromises = _.map(this.exchangeLogEventObjs, logEventObj => {
return promisify(logEventObj.stopWatching, logEventObj)();
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index 08936f1d2..6fef91946 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -661,4 +661,26 @@ describe('ExchangeWrapper', () => {
})();
});
});
+ describe('#getOrderHashHexUsingContractCallAsync', () => {
+ let makerTokenAddress: string;
+ let takerTokenAddress: string;
+ let makerAddress: string;
+ let takerAddress: string;
+ const fillableAmount = new BigNumber(5);
+ before(async () => {
+ [, makerAddress, takerAddress] = userAddresses;
+ const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
+ makerTokenAddress = makerToken.address;
+ takerTokenAddress = takerToken.address;
+ });
+ it('get\'s the same hash as the local function', async () => {
+ const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ );
+ const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder);
+ const orderHashFromContract = await (zeroEx.exchange as any)
+ .getOrderHashHexUsingContractCallAsync(signedOrder);
+ expect(orderHash).to.equal(orderHashFromContract);
+ });
+ });
});