diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-25 22:12:46 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-30 23:01:37 +0800 |
commit | 1e9147b8bb45a251eefdead23573a9e8d68fc34b (patch) | |
tree | 5c1f1c4aa80b2ece8c22b36659064cfb9e902b8a /packages/contracts/util | |
parent | 2f65fadeaabf350c5fa6d2e822dc211f0632ae2e (diff) | |
download | dexon-sol-tools-1e9147b8bb45a251eefdead23573a9e8d68fc34b.tar.gz dexon-sol-tools-1e9147b8bb45a251eefdead23573a9e8d68fc34b.tar.zst dexon-sol-tools-1e9147b8bb45a251eefdead23573a9e8d68fc34b.zip |
Normalize the dependencies
Diffstat (limited to 'packages/contracts/util')
-rw-r--r-- | packages/contracts/util/exchange_wrapper.ts | 16 | ||||
-rw-r--r-- | packages/contracts/util/formatters.ts | 12 | ||||
-rw-r--r-- | packages/contracts/util/order.ts | 7 | ||||
-rw-r--r-- | packages/contracts/util/order_factory.ts | 2 |
4 files changed, 17 insertions, 20 deletions
diff --git a/packages/contracts/util/exchange_wrapper.ts b/packages/contracts/util/exchange_wrapper.ts index 84123c5f4..7a07239f5 100644 --- a/packages/contracts/util/exchange_wrapper.ts +++ b/packages/contracts/util/exchange_wrapper.ts @@ -1,4 +1,4 @@ -import { ExchangeContractEventArgs, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js'; +import { TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import * as Web3 from 'web3'; @@ -108,9 +108,14 @@ export class ExchangeWrapper { public async batchFillOrKillOrdersAsync( orders: Order[], from: string, - opts: { fillTakerTokenAmounts?: BigNumber[] } = {}, + opts: { fillTakerTokenAmounts?: BigNumber[]; shouldThrowOnInsufficientBalanceOrAllowance?: boolean } = {}, ): Promise<TransactionReceiptWithDecodedLogs> { - const params = formatters.createBatchFill(orders, undefined, opts.fillTakerTokenAmounts); + const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance; + const params = formatters.createBatchFill( + orders, + shouldThrowOnInsufficientBalanceOrAllowance, + opts.fillTakerTokenAmounts, + ); const txHash = await this._exchange.batchFillOrKillOrders( params.orderAddresses, params.orderValues, @@ -128,10 +133,7 @@ export class ExchangeWrapper { public async fillOrdersUpToAsync( orders: Order[], from: string, - opts: { - fillTakerTokenAmount?: BigNumber; - shouldThrowOnInsufficientBalanceOrAllowance?: boolean; - } = {}, + opts: { fillTakerTokenAmount: BigNumber; shouldThrowOnInsufficientBalanceOrAllowance?: boolean }, ): Promise<TransactionReceiptWithDecodedLogs> { const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance; const params = formatters.createFillUpTo( diff --git a/packages/contracts/util/formatters.ts b/packages/contracts/util/formatters.ts index 0d0ef6df4..e16fe8d45 100644 --- a/packages/contracts/util/formatters.ts +++ b/packages/contracts/util/formatters.ts @@ -35,9 +35,9 @@ export const formatters = { order.params.expirationTimestampInSec, order.params.salt, ]); - batchFill.v.push(order.params.v); - batchFill.r.push(order.params.r); - batchFill.s.push(order.params.s); + batchFill.v.push(order.params.v as number); + batchFill.r.push(order.params.r as string); + batchFill.s.push(order.params.s as string); if (fillTakerTokenAmounts.length < orders.length) { batchFill.fillTakerTokenAmounts.push(order.params.takerTokenAmount); } @@ -74,9 +74,9 @@ export const formatters = { order.params.expirationTimestampInSec, order.params.salt, ]); - fillUpTo.v.push(order.params.v); - fillUpTo.r.push(order.params.r); - fillUpTo.s.push(order.params.s); + fillUpTo.v.push(order.params.v as number); + fillUpTo.r.push(order.params.r as string); + fillUpTo.s.push(order.params.s as string); }); return fillUpTo; }, diff --git a/packages/contracts/util/order.ts b/packages/contracts/util/order.ts index 702b2312c..57bb2bcbf 100644 --- a/packages/contracts/util/order.ts +++ b/packages/contracts/util/order.ts @@ -1,16 +1,11 @@ -import { BigNumber, promisify } from '@0xproject/utils'; +import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import ethUtil = require('ethereumjs-util'); import * as _ from 'lodash'; -import Web3 = require('web3'); import { crypto } from './crypto'; import { OrderParams } from './types'; -// In order to benefit from type-safety, we re-assign the global web3 instance injected by Truffle -// with type `any` to a variable of type `Web3`. -const web3: Web3 = (global as any).web3; - export class Order { public params: OrderParams; private _web3Wrapper: Web3Wrapper; diff --git a/packages/contracts/util/order_factory.ts b/packages/contracts/util/order_factory.ts index fa12889ca..2b50f13e8 100644 --- a/packages/contracts/util/order_factory.ts +++ b/packages/contracts/util/order_factory.ts @@ -13,7 +13,7 @@ export class OrderFactory { this._defaultOrderParams = defaultOrderParams; this._web3Wrapper = web3Wrapper; } - public async newSignedOrderAsync(customOrderParams: OptionalOrderParams = {}) { + public async newSignedOrderAsync(customOrderParams: OptionalOrderParams = {}): Promise<Order> { const randomExpiration = new BigNumber(Math.floor((Date.now() + Math.random() * 100000000000) / 1000)); const orderParams: OrderParams = _.assign( {}, |