diff options
author | Fabio Berger <me@fabioberger.com> | 2018-05-31 05:45:20 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-05-31 05:45:20 +0800 |
commit | 9200ed2216688410a95175bab460d262fc52a591 (patch) | |
tree | 82677b3cc9be709458d1c40eeac9e2057db1c28d /packages/contracts/src/utils/order_utils.ts | |
parent | e1f7dd1372d2639a5f72705b089bb2250a2fe361 (diff) | |
download | dexon-sol-tools-9200ed2216688410a95175bab460d262fc52a591.tar dexon-sol-tools-9200ed2216688410a95175bab460d262fc52a591.tar.gz dexon-sol-tools-9200ed2216688410a95175bab460d262fc52a591.tar.bz2 dexon-sol-tools-9200ed2216688410a95175bab460d262fc52a591.tar.lz dexon-sol-tools-9200ed2216688410a95175bab460d262fc52a591.tar.xz dexon-sol-tools-9200ed2216688410a95175bab460d262fc52a591.tar.zst dexon-sol-tools-9200ed2216688410a95175bab460d262fc52a591.zip |
Introduce OrderWithoutExchangeAddress type since this is what get's sent to the smart contracts
Diffstat (limited to 'packages/contracts/src/utils/order_utils.ts')
-rw-r--r-- | packages/contracts/src/utils/order_utils.ts | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/packages/contracts/src/utils/order_utils.ts b/packages/contracts/src/utils/order_utils.ts index dd7a04cb6..0d0329aa1 100644 --- a/packages/contracts/src/utils/order_utils.ts +++ b/packages/contracts/src/utils/order_utils.ts @@ -1,4 +1,4 @@ -import { Order, SignedOrder } from '@0xproject/types'; +import { Order, OrderWithoutExchangeAddress, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import ethUtil = require('ethereumjs-util'); @@ -7,7 +7,7 @@ import { CancelOrder, MatchOrder } from './types'; export const orderUtils = { createFill: (signedOrder: SignedOrder, takerAssetFillAmount?: BigNumber) => { const fill = { - order: orderUtils.getOrderStruct(signedOrder), + order: orderUtils.getOrderWithoutExchangeAddress(signedOrder), takerAssetFillAmount: takerAssetFillAmount || signedOrder.takerAssetAmount, signature: signedOrder.signature, }; @@ -15,15 +15,12 @@ export const orderUtils = { }, createCancel(signedOrder: SignedOrder, takerAssetCancelAmount?: BigNumber): CancelOrder { const cancel = { - order: orderUtils.getOrderStruct(signedOrder), + order: orderUtils.getOrderWithoutExchangeAddress(signedOrder), takerAssetCancelAmount: takerAssetCancelAmount || signedOrder.takerAssetAmount, }; return cancel; }, - // TODO: This seems redundant... it currently returns a deep copy w/o signature. - // Question: Should we still have a separate OrderStruct type that simply doesn't - // include the exchangeAddress? Seems like we need to for batch ops... - getOrderStruct(signedOrder: SignedOrder): Order { + getOrderWithoutExchangeAddress(signedOrder: SignedOrder): OrderWithoutExchangeAddress { const orderStruct = { senderAddress: signedOrder.senderAddress, makerAddress: signedOrder.makerAddress, @@ -37,14 +34,13 @@ export const orderUtils = { salt: signedOrder.salt, makerAssetData: signedOrder.makerAssetData, takerAssetData: signedOrder.takerAssetData, - exchangeAddress: signedOrder.exchangeAddress, }; return orderStruct; }, createMatchOrders(signedOrderLeft: SignedOrder, signedOrderRight: SignedOrder): MatchOrder { const fill = { - left: orderUtils.getOrderStruct(signedOrderLeft), - right: orderUtils.getOrderStruct(signedOrderRight), + left: orderUtils.getOrderWithoutExchangeAddress(signedOrderLeft), + right: orderUtils.getOrderWithoutExchangeAddress(signedOrderRight), leftSignature: signedOrderLeft.signature, rightSignature: signedOrderRight.signature, }; |