aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-09-05 02:55:08 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-09-05 02:55:08 +0800
commitf5237f79716fb9ab5f16a64445fb21ea715d70b8 (patch)
treeb05b201bedf699fb4ab858c46a8d4866f8c15335 /packages/website/ts/utils
parenta14450f367d1a1f651f85ac6b0ad710fc2785e83 (diff)
downloaddexon-sol-tools-f5237f79716fb9ab5f16a64445fb21ea715d70b8.tar
dexon-sol-tools-f5237f79716fb9ab5f16a64445fb21ea715d70b8.tar.gz
dexon-sol-tools-f5237f79716fb9ab5f16a64445fb21ea715d70b8.tar.bz2
dexon-sol-tools-f5237f79716fb9ab5f16a64445fb21ea715d70b8.tar.lz
dexon-sol-tools-f5237f79716fb9ab5f16a64445fb21ea715d70b8.tar.xz
dexon-sol-tools-f5237f79716fb9ab5f16a64445fb21ea715d70b8.tar.zst
dexon-sol-tools-f5237f79716fb9ab5f16a64445fb21ea715d70b8.zip
Use order parser utils from order utils
Diffstat (limited to 'packages/website/ts/utils')
-rw-r--r--packages/website/ts/utils/order_parser.ts33
-rw-r--r--packages/website/ts/utils/utils.ts2
2 files changed, 5 insertions, 30 deletions
diff --git a/packages/website/ts/utils/order_parser.ts b/packages/website/ts/utils/order_parser.ts
index 2e1d4d2f2..816200e3b 100644
--- a/packages/website/ts/utils/order_parser.ts
+++ b/packages/website/ts/utils/order_parser.ts
@@ -1,4 +1,5 @@
-import { BigNumber, logUtils } from '@0xproject/utils';
+import { orderParsingUtils } from '@0xproject/order-utils';
+import { logUtils } from '@0xproject/utils';
import * as _ from 'lodash';
import { portalOrderSchema } from 'ts/schemas/portal_order_schema';
@@ -29,7 +30,7 @@ export const orderParser = {
return undefined;
}
const signedOrder = _.get(order, 'signedOrder');
- const convertedSignedOrder = convertOrderStringFieldsToBigNumber(signedOrder);
+ const convertedSignedOrder = orderParsingUtils.convertOrderStringFieldsToBigNumber(signedOrder);
const result = {
...order,
signedOrder: convertedSignedOrder,
@@ -39,7 +40,7 @@ export const orderParser = {
parseJsonString(orderJson: string): PortalOrder {
const order = JSON.parse(orderJson);
const signedOrder = _.get(order, 'signedOrder');
- const convertedSignedOrder = convertOrderStringFieldsToBigNumber(signedOrder);
+ const convertedSignedOrder = orderParsingUtils.convertOrderStringFieldsToBigNumber(signedOrder);
const result = {
...order,
signedOrder: convertedSignedOrder,
@@ -47,29 +48,3 @@ export const orderParser = {
return result;
},
};
-
-// TODO: consolidate this function with that in typeConverters in @0xproject/connect
-function convertOrderStringFieldsToBigNumber(order: any): any {
- return convertStringsFieldsToBigNumbers(order, [
- 'makerAssetAmount',
- 'takerAssetAmount',
- 'makerFee',
- 'takerFee',
- 'expirationTimeSeconds',
- 'salt',
- ]);
-}
-
-// TODO: consolidate this function with that in typeConverters in @0xproject/connect
-function 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;
-}
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index eda0e513d..027810905 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -1,7 +1,7 @@
import { ContractWrappersError } from '@0xproject/contract-wrappers';
import { assetDataUtils, OrderError } from '@0xproject/order-utils';
import { constants as sharedConstants, Networks } from '@0xproject/react-shared';
-import { ECSignature, ExchangeContractErrs } from '@0xproject/types';
+import { ExchangeContractErrs } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as bowser from 'bowser';