aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-05 06:03:14 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-05 06:03:14 +0800
commit1e3ab76e9a6e4f50b105c62f7930408fae1cc661 (patch)
tree96df72933dd182f32b625fdb8099d40d5eba68e2 /packages/order-utils
parentba2ba628e815c996582c6ead81f657a14a00abd0 (diff)
parentab28e6af3507d7eea163e37730e68a101b525237 (diff)
downloaddexon-0x-contracts-1e3ab76e9a6e4f50b105c62f7930408fae1cc661.tar
dexon-0x-contracts-1e3ab76e9a6e4f50b105c62f7930408fae1cc661.tar.gz
dexon-0x-contracts-1e3ab76e9a6e4f50b105c62f7930408fae1cc661.tar.bz2
dexon-0x-contracts-1e3ab76e9a6e4f50b105c62f7930408fae1cc661.tar.lz
dexon-0x-contracts-1e3ab76e9a6e4f50b105c62f7930408fae1cc661.tar.xz
dexon-0x-contracts-1e3ab76e9a6e4f50b105c62f7930408fae1cc661.tar.zst
dexon-0x-contracts-1e3ab76e9a6e4f50b105c62f7930408fae1cc661.zip
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/instant/redux-styles-container
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;