diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-09-05 02:55:08 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-09-05 02:55:08 +0800 |
commit | f5237f79716fb9ab5f16a64445fb21ea715d70b8 (patch) | |
tree | b05b201bedf699fb4ab858c46a8d4866f8c15335 /packages/connect | |
parent | a14450f367d1a1f651f85ac6b0ad710fc2785e83 (diff) | |
download | dexon-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')
-rw-r--r-- | packages/connect/package.json | 1 | ||||
-rw-r--r-- | packages/connect/src/utils/relayer_response_json_parsers.ts | 5 | ||||
-rw-r--r-- | packages/connect/src/utils/type_converters.ts | 26 |
3 files changed, 6 insertions, 26 deletions
diff --git a/packages/connect/package.json b/packages/connect/package.json index 543852350..04daaea97 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -45,6 +45,7 @@ "dependencies": { "@0xproject/assert": "^1.0.7", "@0xproject/json-schemas": "^1.0.1-rc.6", + "@0xproject/order-utils": "^1.0.1-rc.6", "@0xproject/types": "^1.0.1-rc.6", "@0xproject/typescript-typings": "^1.0.5", "@0xproject/utils": "^1.0.7", 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) }; }, }; |