diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-01-09 10:02:41 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-01-09 10:02:41 +0800 |
commit | 8019b1b8231cac24dfc6aa3bb2d5115eff11ee89 (patch) | |
tree | d270d71404bd3aab44c79dcadf16e348614e9214 /packages/contracts/util/formatters.ts | |
parent | 8fe81c9d090ce50496f3150602f19433e7aedd1e (diff) | |
parent | 7a56e83fa3ca02d796deba3359da480834a9f6ea (diff) | |
download | dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar.gz dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar.bz2 dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar.lz dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar.xz dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar.zst dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.zip |
Merge branch 'development' into refactor/httpClientJsonParsing
* development: (21 commits)
Update connect CHANGELOG
Changes to abi-gen after code review
Added constructor ABIs to abi-gen
Describe #295 in a CHANGELOG
Add #302 description to changelog
Fix formatting
Apply prettier config
Install prettier
Remove formatting esilnt rules
sendTransactionAsync should return txHash string
Added Event generation to abi-gen
Publish
Add dates to CHANGELOG entries
Update subproviders CHANGELOG
Support both personal_sign and eth_sign
Fix Ledger tests given change from `personal_sign` to `eth_sign`
Update subprovider to catch correct RPC method
Rename guide
Update contribution guide
Fix broken links in the abi-gen README
...
Diffstat (limited to 'packages/contracts/util/formatters.ts')
-rw-r--r-- | packages/contracts/util/formatters.ts | 82 |
1 files changed, 58 insertions, 24 deletions
diff --git a/packages/contracts/util/formatters.ts b/packages/contracts/util/formatters.ts index 0ad44481a..ab3558ee7 100644 --- a/packages/contracts/util/formatters.ts +++ b/packages/contracts/util/formatters.ts @@ -1,13 +1,15 @@ -import {BigNumber} from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import * as _ from 'lodash'; -import {Order} from './order'; -import {BatchCancelOrders, BatchFillOrders, FillOrdersUpTo} from './types'; +import { Order } from './order'; +import { BatchCancelOrders, BatchFillOrders, FillOrdersUpTo } from './types'; export const formatters = { - createBatchFill(orders: Order[], - shouldThrowOnInsufficientBalanceOrAllowance: boolean, - fillTakerTokenAmounts: BigNumber[] = []) { + createBatchFill( + orders: Order[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + fillTakerTokenAmounts: BigNumber[] = [], + ) { const batchFill: BatchFillOrders = { orderAddresses: [], orderValues: [], @@ -18,11 +20,21 @@ export const formatters = { s: [], }; _.forEach(orders, order => { - batchFill.orderAddresses.push([order.params.maker, order.params.taker, order.params.makerToken, - order.params.takerToken, order.params.feeRecipient]); - batchFill.orderValues.push([order.params.makerTokenAmount, order.params.takerTokenAmount, - order.params.makerFee, order.params.takerFee, - order.params.expirationTimestampInSec, order.params.salt]); + batchFill.orderAddresses.push([ + order.params.maker, + order.params.taker, + order.params.makerToken, + order.params.takerToken, + order.params.feeRecipient, + ]); + batchFill.orderValues.push([ + order.params.makerTokenAmount, + order.params.takerTokenAmount, + order.params.makerFee, + order.params.takerFee, + order.params.expirationTimestampInSec, + order.params.salt, + ]); batchFill.v.push(order.params.v); batchFill.r.push(order.params.r); batchFill.s.push(order.params.s); @@ -32,9 +44,11 @@ export const formatters = { }); return batchFill; }, - createFillUpTo(orders: Order[], - shouldThrowOnInsufficientBalanceOrAllowance: boolean, - fillTakerTokenAmount: BigNumber) { + createFillUpTo( + orders: Order[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + fillTakerTokenAmount: BigNumber, + ) { const fillUpTo: FillOrdersUpTo = { orderAddresses: [], orderValues: [], @@ -45,11 +59,21 @@ export const formatters = { s: [], }; orders.forEach(order => { - fillUpTo.orderAddresses.push([order.params.maker, order.params.taker, order.params.makerToken, - order.params.takerToken, order.params.feeRecipient]); - fillUpTo.orderValues.push([order.params.makerTokenAmount, order.params.takerTokenAmount, - order.params.makerFee, order.params.takerFee, - order.params.expirationTimestampInSec, order.params.salt]); + fillUpTo.orderAddresses.push([ + order.params.maker, + order.params.taker, + order.params.makerToken, + order.params.takerToken, + order.params.feeRecipient, + ]); + fillUpTo.orderValues.push([ + order.params.makerTokenAmount, + order.params.takerTokenAmount, + order.params.makerFee, + order.params.takerFee, + order.params.expirationTimestampInSec, + order.params.salt, + ]); fillUpTo.v.push(order.params.v); fillUpTo.r.push(order.params.r); fillUpTo.s.push(order.params.s); @@ -63,11 +87,21 @@ export const formatters = { cancelTakerTokenAmounts, }; orders.forEach(order => { - batchCancel.orderAddresses.push([order.params.maker, order.params.taker, order.params.makerToken, - order.params.takerToken, order.params.feeRecipient]); - batchCancel.orderValues.push([order.params.makerTokenAmount, order.params.takerTokenAmount, - order.params.makerFee, order.params.takerFee, - order.params.expirationTimestampInSec, order.params.salt]); + batchCancel.orderAddresses.push([ + order.params.maker, + order.params.taker, + order.params.makerToken, + order.params.takerToken, + order.params.feeRecipient, + ]); + batchCancel.orderValues.push([ + order.params.makerTokenAmount, + order.params.takerTokenAmount, + order.params.makerFee, + order.params.takerFee, + order.params.expirationTimestampInSec, + order.params.salt, + ]); if (cancelTakerTokenAmounts.length < orders.length) { batchCancel.cancelTakerTokenAmounts.push(order.params.takerTokenAmount); } |