diff options
author | Francesco Agosti <francesco.agosti93@gmail.com> | 2018-09-05 03:37:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-05 03:37:53 +0800 |
commit | 01210c291c23aae19d201557118f39a8bd970ca0 (patch) | |
tree | a93ff78321eda2b98a15669a458622ec79deba1a /packages/connect/src | |
parent | a5859c6cee0729cf493afa4ff192469cd781fa2b (diff) | |
parent | 6eb980abe2900d179f796bfdae4d79544f447952 (diff) | |
download | dexon-sol-tools-01210c291c23aae19d201557118f39a8bd970ca0.tar dexon-sol-tools-01210c291c23aae19d201557118f39a8bd970ca0.tar.gz dexon-sol-tools-01210c291c23aae19d201557118f39a8bd970ca0.tar.bz2 dexon-sol-tools-01210c291c23aae19d201557118f39a8bd970ca0.tar.lz dexon-sol-tools-01210c291c23aae19d201557118f39a8bd970ca0.tar.xz dexon-sol-tools-01210c291c23aae19d201557118f39a8bd970ca0.tar.zst dexon-sol-tools-01210c291c23aae19d201557118f39a8bd970ca0.zip |
Merge pull request #1044 from 0xProject/feature/website/update-portal-v2
[website] Update portal for v2
Diffstat (limited to 'packages/connect/src')
-rw-r--r-- | packages/connect/src/utils/relayer_response_json_parsers.ts | 5 | ||||
-rw-r--r-- | packages/connect/src/utils/type_converters.ts | 26 |
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) }; }, }; |