aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/utils/formatters.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src/utils/formatters.ts')
-rw-r--r--packages/contracts/src/utils/formatters.ts116
1 files changed, 49 insertions, 67 deletions
diff --git a/packages/contracts/src/utils/formatters.ts b/packages/contracts/src/utils/formatters.ts
index 48c77fea1..4f6116f06 100644
--- a/packages/contracts/src/utils/formatters.ts
+++ b/packages/contracts/src/utils/formatters.ts
@@ -1,38 +1,30 @@
-import { SignedOrder } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import { BatchCancelOrders, BatchFillOrders, MarketFillOrders } from './types';
+import { BatchCancelOrders, BatchFillOrders, MarketFillOrders, SignedOrder } from './types';
export const formatters = {
createBatchFill(signedOrders: SignedOrder[], takerTokenFillAmounts: BigNumber[] = []) {
const batchFill: BatchFillOrders = {
- orderAddresses: [],
- orderValues: [],
+ orders: [],
+ signatures: [],
takerTokenFillAmounts,
- v: [],
- r: [],
- s: [],
};
_.forEach(signedOrders, signedOrder => {
- batchFill.orderAddresses.push([
- signedOrder.maker,
- signedOrder.taker,
- signedOrder.makerTokenAddress,
- signedOrder.takerTokenAddress,
- signedOrder.feeRecipient,
- ]);
- batchFill.orderValues.push([
- signedOrder.makerTokenAmount,
- signedOrder.takerTokenAmount,
- signedOrder.makerFee,
- signedOrder.takerFee,
- signedOrder.expirationUnixTimestampSec,
- signedOrder.salt,
- ]);
- batchFill.v.push(signedOrder.ecSignature.v);
- batchFill.r.push(signedOrder.ecSignature.r);
- batchFill.s.push(signedOrder.ecSignature.s);
+ batchFill.orders.push({
+ makerAddress: signedOrder.makerAddress,
+ takerAddress: signedOrder.takerAddress,
+ makerTokenAddress: signedOrder.makerTokenAddress,
+ takerTokenAddress: signedOrder.takerTokenAddress,
+ feeRecipientAddress: signedOrder.feeRecipientAddress,
+ makerTokenAmount: signedOrder.makerTokenAmount,
+ takerTokenAmount: signedOrder.takerTokenAmount,
+ makerFeeAmount: signedOrder.makerFeeAmount,
+ takerFeeAmount: signedOrder.takerFeeAmount,
+ expirationTimeSeconds: signedOrder.expirationTimeSeconds,
+ salt: signedOrder.salt,
+ });
+ batchFill.signatures.push(signedOrder.signature);
if (takerTokenFillAmounts.length < signedOrders.length) {
batchFill.takerTokenFillAmounts.push(signedOrder.takerTokenAmount);
}
@@ -41,57 +33,47 @@ export const formatters = {
},
createMarketFillOrders(signedOrders: SignedOrder[], takerTokenFillAmount: BigNumber) {
const marketFillOrders: MarketFillOrders = {
- orderAddresses: [],
- orderValues: [],
+ orders: [],
+ signatures: [],
takerTokenFillAmount,
- v: [],
- r: [],
- s: [],
};
- signedOrders.forEach(signedOrder => {
- marketFillOrders.orderAddresses.push([
- signedOrder.maker,
- signedOrder.taker,
- signedOrder.makerTokenAddress,
- signedOrder.takerTokenAddress,
- signedOrder.feeRecipient,
- ]);
- marketFillOrders.orderValues.push([
- signedOrder.makerTokenAmount,
- signedOrder.takerTokenAmount,
- signedOrder.makerFee,
- signedOrder.takerFee,
- signedOrder.expirationUnixTimestampSec,
- signedOrder.salt,
- ]);
- marketFillOrders.v.push(signedOrder.ecSignature.v);
- marketFillOrders.r.push(signedOrder.ecSignature.r);
- marketFillOrders.s.push(signedOrder.ecSignature.s);
+ _.forEach(signedOrders, signedOrder => {
+ marketFillOrders.orders.push({
+ makerAddress: signedOrder.makerAddress,
+ takerAddress: signedOrder.takerAddress,
+ makerTokenAddress: signedOrder.makerTokenAddress,
+ takerTokenAddress: signedOrder.takerTokenAddress,
+ feeRecipientAddress: signedOrder.feeRecipientAddress,
+ makerTokenAmount: signedOrder.makerTokenAmount,
+ takerTokenAmount: signedOrder.takerTokenAmount,
+ makerFeeAmount: signedOrder.makerFeeAmount,
+ takerFeeAmount: signedOrder.takerFeeAmount,
+ expirationTimeSeconds: signedOrder.expirationTimeSeconds,
+ salt: signedOrder.salt,
+ });
+ marketFillOrders.signatures.push(signedOrder.signature);
});
return marketFillOrders;
},
createBatchCancel(signedOrders: SignedOrder[], takerTokenCancelAmounts: BigNumber[] = []) {
const batchCancel: BatchCancelOrders = {
- orderAddresses: [],
- orderValues: [],
+ orders: [],
takerTokenCancelAmounts,
};
- signedOrders.forEach(signedOrder => {
- batchCancel.orderAddresses.push([
- signedOrder.maker,
- signedOrder.taker,
- signedOrder.makerTokenAddress,
- signedOrder.takerTokenAddress,
- signedOrder.feeRecipient,
- ]);
- batchCancel.orderValues.push([
- signedOrder.makerTokenAmount,
- signedOrder.takerTokenAmount,
- signedOrder.makerFee,
- signedOrder.takerFee,
- signedOrder.expirationUnixTimestampSec,
- signedOrder.salt,
- ]);
+ _.forEach(signedOrders, signedOrder => {
+ batchCancel.orders.push({
+ makerAddress: signedOrder.makerAddress,
+ takerAddress: signedOrder.takerAddress,
+ makerTokenAddress: signedOrder.makerTokenAddress,
+ takerTokenAddress: signedOrder.takerTokenAddress,
+ feeRecipientAddress: signedOrder.feeRecipientAddress,
+ makerTokenAmount: signedOrder.makerTokenAmount,
+ takerTokenAmount: signedOrder.takerTokenAmount,
+ makerFeeAmount: signedOrder.makerFeeAmount,
+ takerFeeAmount: signedOrder.takerFeeAmount,
+ expirationTimeSeconds: signedOrder.expirationTimeSeconds,
+ salt: signedOrder.salt,
+ });
if (takerTokenCancelAmounts.length < signedOrders.length) {
batchCancel.takerTokenCancelAmounts.push(signedOrder.takerTokenAmount);
}