aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/src/utils/formatters.ts16
-rw-r--r--packages/contracts/src/utils/order_utils.ts16
-rw-r--r--packages/contracts/src/utils/types.ts16
-rw-r--r--packages/contracts/test/exchange/transactions.ts12
-rw-r--r--packages/types/src/index.ts15
5 files changed, 43 insertions, 32 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;
}
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts
index 3f884a6c3..7ee194aa1 100644
--- a/packages/contracts/test/exchange/transactions.ts
+++ b/packages/contracts/test/exchange/transactions.ts
@@ -1,5 +1,6 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { AssetProxyId, Order, SignatureType, SignedOrder } from '@0xproject/types';
+import { assetProxyUtils } from '@0xproject/order-utils';
+import { AssetProxyId, Order, OrderWithoutExchangeAddress, SignatureType, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as ethUtil from 'ethereumjs-util';
@@ -9,7 +10,6 @@ import { DummyERC20TokenContract } from '../../src/contract_wrappers/generated/d
import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy';
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
import { artifacts } from '../../src/utils/artifacts';
-import { assetProxyUtils } from '@0xproject/order-utils';
import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
@@ -40,7 +40,7 @@ describe('Exchange transactions', () => {
let erc20Balances: ERC20BalancesByOwner;
let signedOrder: SignedOrder;
let signedTx: SignedTransaction;
- let order: Order;
+ let orderWithoutExchangeAddress: OrderWithoutExchangeAddress;
let orderFactory: OrderFactory;
let makerTransactionFactory: TransactionFactory;
let takerTransactionFactory: TransactionFactory;
@@ -111,11 +111,11 @@ describe('Exchange transactions', () => {
beforeEach(async () => {
erc20Balances = await erc20Wrapper.getBalancesAsync();
signedOrder = orderFactory.newSignedOrder();
- order = orderUtils.getOrderStruct(signedOrder);
+ orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder);
takerAssetFillAmount = signedOrder.takerAssetAmount.div(2);
const data = exchange.fillOrder.getABIEncodedTransactionData(
- order,
+ orderWithoutExchangeAddress,
takerAssetFillAmount,
signedOrder.signature,
);
@@ -179,7 +179,7 @@ describe('Exchange transactions', () => {
describe('cancelOrder', () => {
beforeEach(async () => {
- const data = exchange.cancelOrder.getABIEncodedTransactionData(order);
+ const data = exchange.cancelOrder.getABIEncodedTransactionData(orderWithoutExchangeAddress);
signedTx = makerTransactionFactory.newSignedTransaction(data);
});
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index 8ec82034d..f89c3c306 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -297,6 +297,21 @@ export interface Order {
expirationTimeSeconds: BigNumber;
}
+export interface OrderWithoutExchangeAddress {
+ senderAddress: string;
+ makerAddress: string;
+ takerAddress: string;
+ makerFee: BigNumber;
+ takerFee: BigNumber;
+ makerAssetAmount: BigNumber;
+ takerAssetAmount: BigNumber;
+ makerAssetData: string;
+ takerAssetData: string;
+ salt: BigNumber;
+ feeRecipientAddress: string;
+ expirationTimeSeconds: BigNumber;
+}
+
export interface SignedOrder extends Order {
signature: string;
}