diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-08-02 06:08:17 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-08-02 11:47:59 +0800 |
commit | 7c864b81e0d958560e098ebd8bd241385e4aadff (patch) | |
tree | 8bb4f31eb6f427ffdf91a1cb8516ec91ec4b773d /packages/order-utils/src/order_factory.ts | |
parent | 4f006fdc5c3cc24bb5d008f4c363d5225fe6728a (diff) | |
download | dexon-sol-tools-7c864b81e0d958560e098ebd8bd241385e4aadff.tar dexon-sol-tools-7c864b81e0d958560e098ebd8bd241385e4aadff.tar.gz dexon-sol-tools-7c864b81e0d958560e098ebd8bd241385e4aadff.tar.bz2 dexon-sol-tools-7c864b81e0d958560e098ebd8bd241385e4aadff.tar.lz dexon-sol-tools-7c864b81e0d958560e098ebd8bd241385e4aadff.tar.xz dexon-sol-tools-7c864b81e0d958560e098ebd8bd241385e4aadff.tar.zst dexon-sol-tools-7c864b81e0d958560e098ebd8bd241385e4aadff.zip |
Add createOrder with no signing to orderFactory
Diffstat (limited to 'packages/order-utils/src/order_factory.ts')
-rw-r--r-- | packages/order-utils/src/order_factory.ts | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/packages/order-utils/src/order_factory.ts b/packages/order-utils/src/order_factory.ts index 803cb82b1..4be7a1913 100644 --- a/packages/order-utils/src/order_factory.ts +++ b/packages/order-utils/src/order_factory.ts @@ -1,17 +1,17 @@ -import { ECSignature, SignedOrder } from '@0xproject/types'; +import { ECSignature, Order, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Provider } from 'ethereum-types'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; +import { constants } from './constants'; import { orderHashUtils } from './order_hash'; import { generatePseudoRandomSalt } from './salt'; import { ecSignOrderHashAsync } from './signature_utils'; import { MessagePrefixType } from './types'; export const orderFactory = { - async createSignedOrderAsync( - provider: Provider, + createOrder( makerAddress: string, takerAddress: string, senderAddress: string, @@ -24,10 +24,9 @@ export const orderFactory = { exchangeAddress: string, feeRecipientAddress: string, expirationTimeSecondsIfExists?: BigNumber, - ): Promise<SignedOrder> { - const defaultExpirationUnixTimestampSec = new BigNumber(2524604400); // Close to infinite + ): Order { const expirationTimeSeconds = _.isUndefined(expirationTimeSecondsIfExists) - ? defaultExpirationUnixTimestampSec + ? constants.INFINITE_TIMESTAMP_SEC : expirationTimeSecondsIfExists; const order = { makerAddress, @@ -44,6 +43,37 @@ export const orderFactory = { feeRecipientAddress, expirationTimeSeconds, }; + return order; + }, + async createSignedOrderAsync( + provider: Provider, + makerAddress: string, + takerAddress: string, + senderAddress: string, + makerFee: BigNumber, + takerFee: BigNumber, + makerAssetAmount: BigNumber, + makerAssetData: string, + takerAssetAmount: BigNumber, + takerAssetData: string, + exchangeAddress: string, + feeRecipientAddress: string, + expirationTimeSecondsIfExists?: BigNumber, + ): Promise<SignedOrder> { + const order = orderFactory.createOrder( + makerAddress, + takerAddress, + senderAddress, + makerFee, + takerFee, + makerAssetAmount, + makerAssetData, + takerAssetAmount, + takerAssetData, + exchangeAddress, + feeRecipientAddress, + expirationTimeSecondsIfExists, + ); const orderHash = orderHashUtils.getOrderHashHex(order); const messagePrefixOpts = { prefixType: MessagePrefixType.EthSign, |