aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/order-utils')
-rw-r--r--packages/order-utils/src/constants.ts1
-rw-r--r--packages/order-utils/src/order_factory.ts42
2 files changed, 22 insertions, 21 deletions
diff --git a/packages/order-utils/src/constants.ts b/packages/order-utils/src/constants.ts
index 92eb89d70..ea3f8b932 100644
--- a/packages/order-utils/src/constants.ts
+++ b/packages/order-utils/src/constants.ts
@@ -11,4 +11,5 @@ export const constants = {
SELECTOR_LENGTH: 4,
BASE_16: 16,
INFINITE_TIMESTAMP_SEC: new BigNumber(2524604400), // Close to infinite
+ ZERO_AMOUNT: new BigNumber(0),
};
diff --git a/packages/order-utils/src/order_factory.ts b/packages/order-utils/src/order_factory.ts
index 4be7a1913..444e5a0b2 100644
--- a/packages/order-utils/src/order_factory.ts
+++ b/packages/order-utils/src/order_factory.ts
@@ -13,21 +13,19 @@ import { MessagePrefixType } from './types';
export const orderFactory = {
createOrder(
makerAddress: string,
- takerAddress: string,
- senderAddress: string,
- makerFee: BigNumber,
- takerFee: BigNumber,
makerAssetAmount: BigNumber,
makerAssetData: string,
takerAssetAmount: BigNumber,
takerAssetData: string,
exchangeAddress: string,
- feeRecipientAddress: string,
- expirationTimeSecondsIfExists?: BigNumber,
+ takerAddress: string = constants.NULL_ADDRESS,
+ senderAddress: string = constants.NULL_ADDRESS,
+ makerFee: BigNumber = constants.ZERO_AMOUNT,
+ takerFee: BigNumber = constants.ZERO_AMOUNT,
+ feeRecipientAddress: string = constants.NULL_ADDRESS,
+ salt: BigNumber = generatePseudoRandomSalt(),
+ expirationTimeSeconds: BigNumber = constants.INFINITE_TIMESTAMP_SEC,
): Order {
- const expirationTimeSeconds = _.isUndefined(expirationTimeSecondsIfExists)
- ? constants.INFINITE_TIMESTAMP_SEC
- : expirationTimeSecondsIfExists;
const order = {
makerAddress,
takerAddress,
@@ -38,7 +36,7 @@ export const orderFactory = {
takerAssetAmount,
makerAssetData,
takerAssetData,
- salt: generatePseudoRandomSalt(),
+ salt,
exchangeAddress,
feeRecipientAddress,
expirationTimeSeconds,
@@ -48,31 +46,33 @@ export const orderFactory = {
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,
+ takerAddress?: string,
+ senderAddress?: string,
+ makerFee?: BigNumber,
+ takerFee?: BigNumber,
+ feeRecipientAddress?: string,
+ salt?: BigNumber,
+ expirationTimeSeconds?: BigNumber,
): Promise<SignedOrder> {
const order = orderFactory.createOrder(
makerAddress,
- takerAddress,
- senderAddress,
- makerFee,
- takerFee,
makerAssetAmount,
makerAssetData,
takerAssetAmount,
takerAssetData,
exchangeAddress,
+ takerAddress,
+ senderAddress,
+ makerFee,
+ takerFee,
feeRecipientAddress,
- expirationTimeSecondsIfExists,
+ salt,
+ expirationTimeSeconds,
);
const orderHash = orderHashUtils.getOrderHashHex(order);
const messagePrefixOpts = {