From 918315e89f3408124d2e78bbd1acb58ed42d1766 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 7 Jun 2017 12:40:58 +0200 Subject: Implement fillOrKill & tests --- src/0x.js.ts | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'src/0x.js.ts') 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 { - 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 -- cgit v1.2.3 From 951d15b3cad954d995402e9379547fd2de90227f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 7 Jun 2017 17:22:30 +0200 Subject: Spacing fix --- src/0x.js.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/0x.js.ts') diff --git a/src/0x.js.ts b/src/0x.js.ts index 7be6922fc..20bd2c985 100644 --- a/src/0x.js.ts +++ b/src/0x.js.ts @@ -130,8 +130,7 @@ 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 { - assert.doesConformToSchema('order', - SchemaValidator.convertToJSONSchemaCompatibleObject(order as object), + assert.doesConformToSchema('order', SchemaValidator.convertToJSONSchemaCompatibleObject(order as object), orderSchema); const exchangeContractAddr = await this.getExchangeAddressAsync(); -- cgit v1.2.3 From bc441015b672c310bd4b4a67fcf9a98e28793883 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 7 Jun 2017 17:23:59 +0200 Subject: add `hex` to function and variable name for clarity --- src/0x.js.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/0x.js.ts') diff --git a/src/0x.js.ts b/src/0x.js.ts index 20bd2c985..8f1178b2a 100644 --- a/src/0x.js.ts +++ b/src/0x.js.ts @@ -134,8 +134,8 @@ export class ZeroEx { orderSchema); const exchangeContractAddr = await this.getExchangeAddressAsync(); - const orderHash = utils.getOrderHashHex(order, exchangeContractAddr); - return orderHash; + const orderHashHex = utils.getOrderHashHex(order, exchangeContractAddr); + return orderHashHex; } /** * Signs an orderHash and returns it's elliptic curve signature -- cgit v1.2.3