aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/order-utils')
-rw-r--r--packages/order-utils/CHANGELOG.json4
-rw-r--r--packages/order-utils/CHANGELOG.md8
-rw-r--r--packages/order-utils/package.json22
-rw-r--r--packages/order-utils/src/order_factory.ts39
4 files changed, 55 insertions, 18 deletions
diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json
index b6c284908..3e841c43c 100644
--- a/packages/order-utils/CHANGELOG.json
+++ b/packages/order-utils/CHANGELOG.json
@@ -1,12 +1,12 @@
[
{
- "timestamp": 1538475601,
"version": "1.0.7",
"changes": [
{
"note": "Dependencies updated"
}
- ]
+ ],
+ "timestamp": 1538693146
},
{
"version": "1.0.6",
diff --git a/packages/order-utils/CHANGELOG.md b/packages/order-utils/CHANGELOG.md
index 747c988a2..24598883a 100644
--- a/packages/order-utils/CHANGELOG.md
+++ b/packages/order-utils/CHANGELOG.md
@@ -5,7 +5,7 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
-## v1.0.7 - _October 2, 2018_
+## v1.0.7 - _October 4, 2018_
* Dependencies updated
@@ -52,7 +52,7 @@ CHANGELOG
* Make `sortFeeOrdersByFeeAdjustedRate` in `sortingUtils` generic (#997)
* Update `findFeeOrdersThatCoverFeesForTargetOrders` to round the the nearest integer when calculating required fees (#997)
-## v1.0.1-rc.3 - _August 14, 2018_
+## v1.0.1-rc.3 - _August 13, 2018_
* Update ecSignOrderHashAsync to return signature string with signature type byte. Removes messagePrefixOpts. (#914)
* Added a synchronous `createOrder` method in `orderFactory`, updated public interfaces to support some optional parameters (#936)
@@ -75,7 +75,7 @@ CHANGELOG
* Upgrade ethereumjs-abi dep including a fix so that addresses starting with 0 are properly decoded by `decodeERC20AssetData`
-## v1.0.0-rc.1 - _July 20, 2018_
+## v1.0.0-rc.1 - _July 19, 2018_
* Refactor to work with V2 of 0x protocol (#636)
* Export parseECSignature method (#684)
@@ -101,7 +101,7 @@ CHANGELOG
* Add orderStateUtils, a module for computing order state needed to decide if an order is still valid
-## v0.0.4 - _May 5, 2018_
+## v0.0.4 - _May 4, 2018_
* Dependencies updated
diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json
index 9fefdba5e..23ed9ca12 100644
--- a/packages/order-utils/package.json
+++ b/packages/order-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/order-utils",
- "version": "1.0.6",
+ "version": "1.0.7",
"engines": {
"node": ">=6.12"
},
@@ -39,8 +39,8 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md",
"devDependencies": {
- "@0xproject/dev-utils": "^1.0.11",
- "@0xproject/tslint-config": "^1.0.7",
+ "@0xproject/dev-utils": "^1.0.12",
+ "@0xproject/tslint-config": "^1.0.8",
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
"chai": "^4.0.1",
@@ -58,16 +58,16 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/assert": "^1.0.12",
- "@0xproject/base-contract": "^3.0.0",
- "@0xproject/json-schemas": "^1.0.5",
- "@0xproject/types": "^1.1.2",
- "@0xproject/typescript-typings": "^3.0.0",
- "@0xproject/utils": "^2.0.0",
- "@0xproject/web3-wrapper": "^3.0.2",
+ "@0xproject/assert": "^1.0.13",
+ "@0xproject/base-contract": "^3.0.1",
+ "@0xproject/json-schemas": "^1.0.7",
+ "@0xproject/types": "^1.1.4",
+ "@0xproject/typescript-typings": "^3.0.2",
+ "@0xproject/utils": "^2.0.2",
+ "@0xproject/web3-wrapper": "^3.0.3",
"@types/node": "*",
"bn.js": "^4.11.8",
- "ethereum-types": "^1.0.9",
+ "ethereum-types": "^1.0.11",
"ethereumjs-abi": "0.6.5",
"ethereumjs-util": "^5.1.1",
"ethers": "4.0.0-beta.14",
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;