aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils/src
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-08-04 03:47:19 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-08-04 04:04:47 +0800
commit4f381ca1d9b6f8ecc232d0481d86f8ba695f7601 (patch)
treed39c5aec7bc28e782689046d2f0f44539f2f4d04 /packages/order-utils/src
parent82092ab50a73e15e167f387380cd75ac52581e88 (diff)
downloaddexon-sol-tools-4f381ca1d9b6f8ecc232d0481d86f8ba695f7601.tar
dexon-sol-tools-4f381ca1d9b6f8ecc232d0481d86f8ba695f7601.tar.gz
dexon-sol-tools-4f381ca1d9b6f8ecc232d0481d86f8ba695f7601.tar.bz2
dexon-sol-tools-4f381ca1d9b6f8ecc232d0481d86f8ba695f7601.tar.lz
dexon-sol-tools-4f381ca1d9b6f8ecc232d0481d86f8ba695f7601.tar.xz
dexon-sol-tools-4f381ca1d9b6f8ecc232d0481d86f8ba695f7601.tar.zst
dexon-sol-tools-4f381ca1d9b6f8ecc232d0481d86f8ba695f7601.zip
Update orderFactory interface
Diffstat (limited to 'packages/order-utils/src')
-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 = {