aboutsummaryrefslogtreecommitdiffstats
path: root/src/0x.js.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-07 18:40:58 +0800
committerFabio Berger <me@fabioberger.com>2017-06-07 18:40:58 +0800
commit918315e89f3408124d2e78bbd1acb58ed42d1766 (patch)
tree40a6066c47e3643afd4f5fabde9fe7f260ea6f5a /src/0x.js.ts
parent8ec3bec5b3de726fbf2cc828e179ac2ed1029d9f (diff)
downloaddexon-sol-tools-918315e89f3408124d2e78bbd1acb58ed42d1766.tar
dexon-sol-tools-918315e89f3408124d2e78bbd1acb58ed42d1766.tar.gz
dexon-sol-tools-918315e89f3408124d2e78bbd1acb58ed42d1766.tar.bz2
dexon-sol-tools-918315e89f3408124d2e78bbd1acb58ed42d1766.tar.lz
dexon-sol-tools-918315e89f3408124d2e78bbd1acb58ed42d1766.tar.xz
dexon-sol-tools-918315e89f3408124d2e78bbd1acb58ed42d1766.tar.zst
dexon-sol-tools-918315e89f3408124d2e78bbd1acb58ed42d1766.zip
Implement fillOrKill & tests
Diffstat (limited to 'src/0x.js.ts')
-rw-r--r--src/0x.js.ts27
1 files changed, 4 insertions, 23 deletions
diff --git a/src/0x.js.ts b/src/0x.js.ts
index 0f437e039..6d66c9d86 100644
--- a/src/0x.js.ts
+++ b/src/0x.js.ts
@@ -4,7 +4,6 @@ import {bigNumberConfigs} from './bignumber_config';
import * as ethUtil from 'ethereumjs-util';
import contract = require('truffle-contract');
import * as Web3 from 'web3';
-import * as ethABI from 'ethereumjs-abi';
import findVersions = require('find-versions');
import compareVersions = require('compare-versions');
import {Web3Wrapper} from './web3_wrapper';
@@ -16,8 +15,7 @@ import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper';
import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper';
import {ecSignatureSchema} from './schemas/ec_signature_schema';
import {TokenWrapper} from './contract_wrappers/token_wrapper';
-import {SolidityTypes, ECSignature, ZeroExError} from './types';
-import {Order, SignedOrder} from './types';
+import {SolidityTypes, ECSignature, ZeroExError, Order, SignedOrder} from './types';
import {orderSchema} from './schemas/order_schemas';
import * as ExchangeArtifacts from './artifacts/Exchange.json';
@@ -132,30 +130,13 @@ export class ZeroEx {
* Computes the orderHash for a given order and returns it as a hex encoded string.
*/
public async getOrderHashHexAsync(order: Order|SignedOrder): Promise<string> {
- const exchangeContractAddr = await this.getExchangeAddressAsync();
assert.doesConformToSchema('order',
SchemaValidator.convertToJSONSchemaCompatibleObject(order as object),
orderSchema);
- const orderParts = [
- {value: exchangeContractAddr, type: SolidityTypes.address},
- {value: order.maker, type: SolidityTypes.address},
- {value: order.taker, type: SolidityTypes.address},
- {value: order.makerTokenAddress, type: SolidityTypes.address},
- {value: order.takerTokenAddress, type: SolidityTypes.address},
- {value: order.feeRecipient, type: SolidityTypes.address},
- {value: utils.bigNumberToBN(order.makerTokenAmount), type: SolidityTypes.uint256},
- {value: utils.bigNumberToBN(order.takerTokenAmount), type: SolidityTypes.uint256},
- {value: utils.bigNumberToBN(order.makerFee), type: SolidityTypes.uint256},
- {value: utils.bigNumberToBN(order.takerFee), type: SolidityTypes.uint256},
- {value: utils.bigNumberToBN(order.expirationUnixTimestampSec), type: SolidityTypes.uint256},
- {value: utils.bigNumberToBN(order.salt), type: SolidityTypes.uint256},
- ];
- const types = _.map(orderParts, o => o.type);
- const values = _.map(orderParts, o => o.value);
- const hashBuff = ethABI.soliditySHA3(types, values);
- const hashHex = ethUtil.bufferToHex(hashBuff);
- return hashHex;
+ const exchangeContractAddr = await this.getExchangeAddressAsync();
+ const orderHash = utils.getOrderHashHex(order, exchangeContractAddr);
+ return orderHash;
}
/**
* Signs an orderHash and returns it's elliptic curve signature