aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect/src
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/connect/src
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/connect/src')
-rw-r--r--packages/connect/src/utils/relayer_response_json_parsers.ts5
-rw-r--r--packages/connect/src/utils/type_converters.ts26
2 files changed, 5 insertions, 26 deletions
diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts
index ebd877b70..bc31f231d 100644
--- a/packages/connect/src/utils/relayer_response_json_parsers.ts
+++ b/packages/connect/src/utils/relayer_response_json_parsers.ts
@@ -1,5 +1,6 @@
import { assert } from '@0xproject/assert';
import { schemas } from '@0xproject/json-schemas';
+import { orderParsingUtils } from '@0xproject/order-utils';
import {
APIOrder,
@@ -19,7 +20,7 @@ export const relayerResponseJsonParsers = {
},
parseAssetPairsItemsJson(json: any): AssetPairsItem[] {
return json.map((assetDataPair: any) => {
- return typeConverters.convertStringsFieldsToBigNumbers(assetDataPair, [
+ return orderParsingUtils.convertStringsFieldsToBigNumbers(assetDataPair, [
'assetDataA.minAmount',
'assetDataA.maxAmount',
'assetDataB.minAmount',
@@ -44,6 +45,6 @@ export const relayerResponseJsonParsers = {
},
parseOrderConfigResponseJson(json: any): OrderConfigResponse {
assert.doesConformToSchema('orderConfigResponse', json, schemas.relayerApiOrderConfigResponseSchema);
- return typeConverters.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']);
+ return orderParsingUtils.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']);
},
};
diff --git a/packages/connect/src/utils/type_converters.ts b/packages/connect/src/utils/type_converters.ts
index 4b211a0b2..d57ea00e5 100644
--- a/packages/connect/src/utils/type_converters.ts
+++ b/packages/connect/src/utils/type_converters.ts
@@ -1,4 +1,4 @@
-import { BigNumber } from '@0xproject/utils';
+import { orderParsingUtils } from '@0xproject/order-utils';
import * as _ from 'lodash';
import { APIOrder } from '../types';
@@ -21,28 +21,6 @@ export const typeConverters = {
};
},
convertAPIOrderStringFieldsToBigNumber(apiOrder: any): APIOrder {
- return { ...apiOrder, order: typeConverters.convertOrderStringFieldsToBigNumber(apiOrder.order) };
- },
- convertOrderStringFieldsToBigNumber(order: any): any {
- return typeConverters.convertStringsFieldsToBigNumbers(order, [
- 'makerAssetAmount',
- 'takerAssetAmount',
- 'makerFee',
- 'takerFee',
- 'expirationTimeSeconds',
- 'salt',
- ]);
- },
- 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;
+ return { ...apiOrder, order: orderParsingUtils.convertOrderStringFieldsToBigNumber(apiOrder.order) };
},
};