aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/util/formatters.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-07 20:41:30 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-02-07 20:41:30 +0800
commit568e4d33f29db2f5c0195585438e18ab4b2aea18 (patch)
tree4f2372dc040f4354d51cfb2229391cfd7c033264 /packages/contracts/util/formatters.ts
parentfd004032cb23998184a78ac4a0a486ef1bd04c25 (diff)
downloaddexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.gz
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.bz2
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.lz
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.xz
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.zst
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.zip
Use Order and SignedOrder type from 0x.js
Diffstat (limited to 'packages/contracts/util/formatters.ts')
-rw-r--r--packages/contracts/util/formatters.ts100
1 files changed, 50 insertions, 50 deletions
diff --git a/packages/contracts/util/formatters.ts b/packages/contracts/util/formatters.ts
index 6c225268e..8e0dfb09e 100644
--- a/packages/contracts/util/formatters.ts
+++ b/packages/contracts/util/formatters.ts
@@ -1,12 +1,12 @@
+import { SignedOrder } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import { SignedOrder } from './signed_order';
import { BatchCancelOrders, BatchFillOrders, FillOrdersUpTo } from './types';
export const formatters = {
createBatchFill(
- orders: SignedOrder[],
+ signedOrders: SignedOrder[],
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
fillTakerTokenAmounts: BigNumber[] = [],
) {
@@ -19,33 +19,33 @@ export const formatters = {
r: [],
s: [],
};
- _.forEach(orders, order => {
+ _.forEach(signedOrders, signedOrder => {
batchFill.orderAddresses.push([
- order.params.maker,
- order.params.taker,
- order.params.makerToken,
- order.params.takerToken,
- order.params.feeRecipient,
+ signedOrder.maker,
+ signedOrder.taker,
+ signedOrder.makerTokenAddress,
+ signedOrder.takerTokenAddress,
+ signedOrder.feeRecipient,
]);
batchFill.orderValues.push([
- order.params.makerTokenAmount,
- order.params.takerTokenAmount,
- order.params.makerFee,
- order.params.takerFee,
- order.params.expirationTimestampInSec,
- order.params.salt,
+ signedOrder.makerTokenAmount,
+ signedOrder.takerTokenAmount,
+ signedOrder.makerFee,
+ signedOrder.takerFee,
+ signedOrder.expirationUnixTimestampSec,
+ signedOrder.salt,
]);
- batchFill.v.push(order.params.v);
- batchFill.r.push(order.params.r);
- batchFill.s.push(order.params.s);
- if (fillTakerTokenAmounts.length < orders.length) {
- batchFill.fillTakerTokenAmounts.push(order.params.takerTokenAmount);
+ batchFill.v.push(signedOrder.ecSignature.v);
+ batchFill.r.push(signedOrder.ecSignature.r);
+ batchFill.s.push(signedOrder.ecSignature.s);
+ if (fillTakerTokenAmounts.length < signedOrders.length) {
+ batchFill.fillTakerTokenAmounts.push(signedOrder.takerTokenAmount);
}
});
return batchFill;
},
createFillUpTo(
- orders: SignedOrder[],
+ signedOrders: SignedOrder[],
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
fillTakerTokenAmount: BigNumber,
) {
@@ -58,52 +58,52 @@ export const formatters = {
r: [],
s: [],
};
- orders.forEach(order => {
+ signedOrders.forEach(signedOrder => {
fillUpTo.orderAddresses.push([
- order.params.maker,
- order.params.taker,
- order.params.makerToken,
- order.params.takerToken,
- order.params.feeRecipient,
+ signedOrder.maker,
+ signedOrder.taker,
+ signedOrder.makerTokenAddress,
+ signedOrder.takerTokenAddress,
+ signedOrder.feeRecipient,
]);
fillUpTo.orderValues.push([
- order.params.makerTokenAmount,
- order.params.takerTokenAmount,
- order.params.makerFee,
- order.params.takerFee,
- order.params.expirationTimestampInSec,
- order.params.salt,
+ signedOrder.makerTokenAmount,
+ signedOrder.takerTokenAmount,
+ signedOrder.makerFee,
+ signedOrder.takerFee,
+ signedOrder.expirationUnixTimestampSec,
+ signedOrder.salt,
]);
- fillUpTo.v.push(order.params.v);
- fillUpTo.r.push(order.params.r);
- fillUpTo.s.push(order.params.s);
+ fillUpTo.v.push(signedOrder.ecSignature.v);
+ fillUpTo.r.push(signedOrder.ecSignature.r);
+ fillUpTo.s.push(signedOrder.ecSignature.s);
});
return fillUpTo;
},
- createBatchCancel(orders: SignedOrder[], cancelTakerTokenAmounts: BigNumber[] = []) {
+ createBatchCancel(signedOrders: SignedOrder[], cancelTakerTokenAmounts: BigNumber[] = []) {
const batchCancel: BatchCancelOrders = {
orderAddresses: [],
orderValues: [],
cancelTakerTokenAmounts,
};
- orders.forEach(order => {
+ signedOrders.forEach(signedOrder => {
batchCancel.orderAddresses.push([
- order.params.maker,
- order.params.taker,
- order.params.makerToken,
- order.params.takerToken,
- order.params.feeRecipient,
+ signedOrder.maker,
+ signedOrder.taker,
+ signedOrder.makerTokenAddress,
+ signedOrder.takerTokenAddress,
+ signedOrder.feeRecipient,
]);
batchCancel.orderValues.push([
- order.params.makerTokenAmount,
- order.params.takerTokenAmount,
- order.params.makerFee,
- order.params.takerFee,
- order.params.expirationTimestampInSec,
- order.params.salt,
+ signedOrder.makerTokenAmount,
+ signedOrder.takerTokenAmount,
+ signedOrder.makerFee,
+ signedOrder.takerFee,
+ signedOrder.expirationUnixTimestampSec,
+ signedOrder.salt,
]);
- if (cancelTakerTokenAmounts.length < orders.length) {
- batchCancel.cancelTakerTokenAmounts.push(order.params.takerTokenAmount);
+ if (cancelTakerTokenAmounts.length < signedOrders.length) {
+ batchCancel.cancelTakerTokenAmounts.push(signedOrder.takerTokenAmount);
}
});
return batchCancel;