aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/order-utils')
-rw-r--r--packages/order-utils/CHANGELOG.json10
-rw-r--r--packages/order-utils/CHANGELOG.md4
-rw-r--r--packages/order-utils/package.json28
-rw-r--r--packages/order-utils/src/index.ts1
-rw-r--r--packages/order-utils/src/parsing_utils.ts27
5 files changed, 56 insertions, 14 deletions
diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json
index f28306f78..2beb7a297 100644
--- a/packages/order-utils/CHANGELOG.json
+++ b/packages/order-utils/CHANGELOG.json
@@ -1,5 +1,15 @@
[
{
+ "version": "1.0.1",
+ "changes": [
+ {
+ "note": "Export `orderParsingUtils`",
+ "pr": 1044
+ }
+ ],
+ "timestamp": 1536142250
+ },
+ {
"version": "1.0.1-rc.6",
"changes": [
{
diff --git a/packages/order-utils/CHANGELOG.md b/packages/order-utils/CHANGELOG.md
index c367e4cd8..5b5cc2925 100644
--- a/packages/order-utils/CHANGELOG.md
+++ b/packages/order-utils/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.1 - _September 5, 2018_
+
+ * Export `orderParsingUtils` (#1044)
+
## v1.0.1-rc.6 - _August 27, 2018_
* Fix missing `BlockParamLiteral` type import issue
diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json
index 7d2caa0e8..c6794bcf2 100644
--- a/packages/order-utils/package.json
+++ b/packages/order-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/order-utils",
- "version": "1.0.1-rc.6",
+ "version": "1.0.1",
"engines": {
"node": ">=6.12"
},
@@ -9,9 +9,9 @@
"types": "lib/src/index.d.ts",
"scripts": {
"build": "yarn pre_build && tsc -b",
- "pre_build": "run-s update_artifacts_v2_beta generate_contract_wrappers",
+ "pre_build": "run-s update_artifacts generate_contract_wrappers",
"generate_contract_wrappers": "abi-gen --abis 'lib/src/artifacts/@(Exchange|IWallet|IValidator|DummyERC20Token|ERC20Proxy|ERC20Token).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers",
- "update_artifacts_v2_beta": "for i in ${npm_package_config_contracts_v2_beta}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-beta-testnet/$i.json lib/src/artifacts; done;",
+ "update_artifacts": "for i in ${npm_package_config_contracts_v2}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json lib/src/artifacts; done;",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s build test",
"test:circleci": "yarn test:coverage",
@@ -23,7 +23,7 @@
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
- "contracts_v2_beta": "IWallet IValidator Exchange ERC20Proxy ERC20Token DummyERC20Token",
+ "contracts_v2": "IWallet IValidator Exchange ERC20Proxy ERC20Token DummyERC20Token",
"postpublish": {
"assets": []
}
@@ -38,8 +38,8 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md",
"devDependencies": {
- "@0xproject/dev-utils": "^1.0.6",
- "@0xproject/tslint-config": "^1.0.6",
+ "@0xproject/dev-utils": "^1.0.7",
+ "@0xproject/tslint-config": "^1.0.7",
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
"chai": "^4.0.1",
@@ -57,16 +57,16 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/assert": "^1.0.7",
- "@0xproject/base-contract": "^2.0.1",
- "@0xproject/json-schemas": "^1.0.1-rc.6",
- "@0xproject/types": "^1.0.1-rc.6",
- "@0xproject/typescript-typings": "^1.0.5",
- "@0xproject/utils": "^1.0.7",
- "@0xproject/web3-wrapper": "^2.0.1",
+ "@0xproject/assert": "^1.0.8",
+ "@0xproject/base-contract": "^2.0.2",
+ "@0xproject/json-schemas": "^1.0.1",
+ "@0xproject/types": "^1.0.1",
+ "@0xproject/typescript-typings": "^2.0.0",
+ "@0xproject/utils": "^1.0.8",
+ "@0xproject/web3-wrapper": "^2.0.2",
"@types/node": "^8.0.53",
"bn.js": "^4.11.8",
- "ethereum-types": "^1.0.5",
+ "ethereum-types": "^1.0.6",
"ethereumjs-abi": "0.6.5",
"ethereumjs-util": "^5.1.1",
"ethers": "3.0.22",
diff --git a/packages/order-utils/src/index.ts b/packages/order-utils/src/index.ts
index 354299304..1553647c6 100644
--- a/packages/order-utils/src/index.ts
+++ b/packages/order-utils/src/index.ts
@@ -6,6 +6,7 @@ export { eip712Utils } from './eip712_utils';
export { marketUtils } from './market_utils';
export { rateUtils } from './rate_utils';
export { sortingUtils } from './sorting_utils';
+export { orderParsingUtils } from './parsing_utils';
export { OrderStateUtils } from './order_state_utils';
export { AbstractBalanceAndProxyAllowanceFetcher } from './abstract/abstract_balance_and_proxy_allowance_fetcher';
diff --git a/packages/order-utils/src/parsing_utils.ts b/packages/order-utils/src/parsing_utils.ts
new file mode 100644
index 000000000..232c54b7b
--- /dev/null
+++ b/packages/order-utils/src/parsing_utils.ts
@@ -0,0 +1,27 @@
+import { BigNumber } from '@0xproject/utils';
+import * as _ from 'lodash';
+
+export const orderParsingUtils = {
+ convertStringsFieldsToBigNumbers(obj: any, fields: string[]): any {
+ const result = _.assign({}, obj);
+ _.each(fields, field => {
+ _.update(result, field, (value: string) => {
+ if (_.isUndefined(value)) {
+ throw new Error(`Could not find field '${field}' while converting string fields to BigNumber.`);
+ }
+ return new BigNumber(value);
+ });
+ });
+ return result;
+ },
+ convertOrderStringFieldsToBigNumber(order: any): any {
+ return orderParsingUtils.convertStringsFieldsToBigNumbers(order, [
+ 'makerAssetAmount',
+ 'takerAssetAmount',
+ 'makerFee',
+ 'takerFee',
+ 'expirationTimeSeconds',
+ 'salt',
+ ]);
+ },
+};