diff options
author | Fabio Berger <me@fabioberger.com> | 2018-05-30 07:58:30 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-05-30 07:58:30 +0800 |
commit | 4874d55d03918b47967024777194d88a5f2bc1fc (patch) | |
tree | 4a53834e9424a8b33aa7d0edaf13de11f2e807a3 /packages/contracts/src/utils/order_factory.ts | |
parent | 10faa474950a902af943b3c51f3703491afa6520 (diff) | |
download | dexon-sol-tools-4874d55d03918b47967024777194d88a5f2bc1fc.tar.gz dexon-sol-tools-4874d55d03918b47967024777194d88a5f2bc1fc.tar.zst dexon-sol-tools-4874d55d03918b47967024777194d88a5f2bc1fc.zip |
Initial refactor of order-utils. Move many utils from contracts into this package.
Diffstat (limited to 'packages/contracts/src/utils/order_factory.ts')
-rw-r--r-- | packages/contracts/src/utils/order_factory.ts | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/packages/contracts/src/utils/order_factory.ts b/packages/contracts/src/utils/order_factory.ts index f704c26ec..59fc663f4 100644 --- a/packages/contracts/src/utils/order_factory.ts +++ b/packages/contracts/src/utils/order_factory.ts @@ -1,22 +1,21 @@ import { generatePseudoRandomSalt } from '@0xproject/order-utils'; -import { SignedOrder, UnsignedOrder } from '@0xproject/types'; +import { orderHashUtils } from '@0xproject/order-utils'; +import { Order, SignatureType, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import { constants } from './constants'; -import { orderUtils } from './order_utils'; import { signingUtils } from './signing_utils'; -import { SignatureType } from './types'; export class OrderFactory { - private _defaultOrderParams: Partial<UnsignedOrder>; + private _defaultOrderParams: Partial<Order>; private _privateKey: Buffer; - constructor(privateKey: Buffer, defaultOrderParams: Partial<UnsignedOrder>) { + constructor(privateKey: Buffer, defaultOrderParams: Partial<Order>) { this._defaultOrderParams = defaultOrderParams; this._privateKey = privateKey; } public newSignedOrder( - customOrderParams: Partial<UnsignedOrder> = {}, + customOrderParams: Partial<Order> = {}, signatureType: SignatureType = SignatureType.Ecrecover, ): SignedOrder { const randomExpiration = new BigNumber(Math.floor((Date.now() + Math.random() * 100000000000) / 1000)); @@ -27,8 +26,8 @@ export class OrderFactory { takerAddress: constants.NULL_ADDRESS, ...this._defaultOrderParams, ...customOrderParams, - } as any) as UnsignedOrder; - const orderHashBuff = orderUtils.getOrderHashBuff(order); + } as any) as Order; + const orderHashBuff = orderHashUtils.getOrderHashBuff(order); const signature = signingUtils.signMessage(orderHashBuff, this._privateKey, signatureType); const signedOrder = { ...order, |