aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-10-05 05:49:25 +0800
committerGitHub <noreply@github.com>2018-10-05 05:49:25 +0800
commitab28e6af3507d7eea163e37730e68a101b525237 (patch)
treea08c4bf3cd54a34ecb76ac8e19a51228bf25da97 /packages/order-utils
parent2da7626b5356f7b0ec809719f1b9da14b2969a07 (diff)
parent63d97f4c8837dcf8d17afc494dcd8b1ba10fee16 (diff)
downloaddexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar.gz
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar.bz2
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar.lz
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar.xz
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.tar.zst
dexon-sol-tools-ab28e6af3507d7eea163e37730e68a101b525237.zip
Merge pull request #1113 from 0xProject/feature/asset-buyer/tests
[asset-buyer] Rework min / max rate calc and add tests
Diffstat (limited to 'packages/order-utils')
-rw-r--r--packages/order-utils/src/order_factory.ts39
1 files changed, 38 insertions, 1 deletions
diff --git a/packages/order-utils/src/order_factory.ts b/packages/order-utils/src/order_factory.ts
index 46a69ae4d..b1292903a 100644
--- a/packages/order-utils/src/order_factory.ts
+++ b/packages/order-utils/src/order_factory.ts
@@ -8,8 +8,21 @@ import { orderHashUtils } from './order_hash';
import { generatePseudoRandomSalt } from './salt';
import { signatureUtils } from './signature_utils';
import { CreateOrderOpts } from './types';
-
export const orderFactory = {
+ createOrderFromPartial(partialOrder: Partial<Order>): Order {
+ const defaultOrder = generateEmptyOrder();
+ return {
+ ...defaultOrder,
+ ...partialOrder,
+ };
+ },
+ createSignedOrderFromPartial(partialSignedOrder: Partial<SignedOrder>): SignedOrder {
+ const defaultOrder = generateEmptySignedOrder();
+ return {
+ ...defaultOrder,
+ ...partialSignedOrder,
+ };
+ },
createOrder(
makerAddress: string,
makerAssetAmount: BigNumber,
@@ -69,6 +82,30 @@ export const orderFactory = {
},
};
+function generateEmptySignedOrder(): SignedOrder {
+ return {
+ ...generateEmptyOrder(),
+ signature: constants.NULL_BYTES,
+ };
+}
+function generateEmptyOrder(): Order {
+ return {
+ senderAddress: constants.NULL_ADDRESS,
+ makerAddress: constants.NULL_ADDRESS,
+ takerAddress: constants.NULL_ADDRESS,
+ makerFee: constants.ZERO_AMOUNT,
+ takerFee: constants.ZERO_AMOUNT,
+ makerAssetAmount: constants.ZERO_AMOUNT,
+ takerAssetAmount: constants.ZERO_AMOUNT,
+ makerAssetData: constants.NULL_BYTES,
+ takerAssetData: constants.NULL_BYTES,
+ salt: generatePseudoRandomSalt(),
+ exchangeAddress: constants.NULL_ADDRESS,
+ feeRecipientAddress: constants.NULL_ADDRESS,
+ expirationTimeSeconds: constants.INFINITE_TIMESTAMP_SEC,
+ };
+}
+
function generateDefaultCreateOrderOpts(): {
takerAddress: string;
senderAddress: string;