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 | |
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')
-rw-r--r-- | packages/contracts/src/utils/formatters.ts | 16 | ||||
-rw-r--r-- | packages/contracts/src/utils/order_utils.ts | 16 | ||||
-rw-r--r-- | packages/contracts/src/utils/types.ts | 16 |
3 files changed, 22 insertions, 26 deletions
diff --git a/packages/contracts/src/utils/formatters.ts b/packages/contracts/src/utils/formatters.ts index c46d668bc..1035f2d7c 100644 --- a/packages/contracts/src/utils/formatters.ts +++ b/packages/contracts/src/utils/formatters.ts @@ -13,8 +13,8 @@ export const formatters = { takerAssetFillAmounts, }; _.forEach(signedOrders, signedOrder => { - const orderStruct = orderUtils.getOrderStruct(signedOrder); - batchFill.orders.push(orderStruct); + const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); + batchFill.orders.push(orderWithoutExchangeAddress); batchFill.signatures.push(signedOrder.signature); if (takerAssetFillAmounts.length < signedOrders.length) { batchFill.takerAssetFillAmounts.push(signedOrder.takerAssetAmount); @@ -29,8 +29,8 @@ export const formatters = { takerAssetFillAmount, }; _.forEach(signedOrders, signedOrder => { - const orderStruct = orderUtils.getOrderStruct(signedOrder); - marketSellOrders.orders.push(orderStruct); + const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); + marketSellOrders.orders.push(orderWithoutExchangeAddress); marketSellOrders.signatures.push(signedOrder.signature); }); return marketSellOrders; @@ -42,8 +42,8 @@ export const formatters = { makerAssetFillAmount, }; _.forEach(signedOrders, signedOrder => { - const orderStruct = orderUtils.getOrderStruct(signedOrder); - marketBuyOrders.orders.push(orderStruct); + const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); + marketBuyOrders.orders.push(orderWithoutExchangeAddress); marketBuyOrders.signatures.push(signedOrder.signature); }); return marketBuyOrders; @@ -53,8 +53,8 @@ export const formatters = { orders: [], }; _.forEach(signedOrders, signedOrder => { - const orderStruct = orderUtils.getOrderStruct(signedOrder); - batchCancel.orders.push(orderStruct); + const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); + batchCancel.orders.push(orderWithoutExchangeAddress); }); return batchCancel; }, 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, }; diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts index e4401bd92..9a0c95504 100644 --- a/packages/contracts/src/utils/types.ts +++ b/packages/contracts/src/utils/types.ts @@ -1,4 +1,4 @@ -import { AbiDefinition, ContractAbi, Order } from '@0xproject/types'; +import { AbiDefinition, ContractAbi, Order, OrderWithoutExchangeAddress } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; export interface ERC20BalancesByOwner { @@ -18,25 +18,25 @@ export interface SubmissionContractEventArgs { } export interface BatchFillOrders { - orders: Order[]; + orders: OrderWithoutExchangeAddress[]; signatures: string[]; takerAssetFillAmounts: BigNumber[]; } export interface MarketSellOrders { - orders: Order[]; + orders: OrderWithoutExchangeAddress[]; signatures: string[]; takerAssetFillAmount: BigNumber; } export interface MarketBuyOrders { - orders: Order[]; + orders: OrderWithoutExchangeAddress[]; signatures: string[]; makerAssetFillAmount: BigNumber; } export interface BatchCancelOrders { - orders: Order[]; + orders: OrderWithoutExchangeAddress[]; } export interface CancelOrdersBefore { @@ -143,13 +143,13 @@ export interface OrderInfo { } export interface CancelOrder { - order: Order; + order: OrderWithoutExchangeAddress; takerAssetCancelAmount: BigNumber; } export interface MatchOrder { - left: Order; - right: Order; + left: OrderWithoutExchangeAddress; + right: OrderWithoutExchangeAddress; leftSignature: string; rightSignature: string; } |