From 5c40c466f6e9f690afa86f23dd5ba240691dceb8 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 14 Aug 2018 14:59:53 -0700 Subject: Update json-schemas, update HTTPClient types --- packages/connect/src/utils/orderbook_channel_message_parser.ts | 10 ++-------- packages/connect/src/utils/relayer_response_json_parsers.ts | 8 ++++---- 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'packages/connect/src/utils') diff --git a/packages/connect/src/utils/orderbook_channel_message_parser.ts b/packages/connect/src/utils/orderbook_channel_message_parser.ts index ca739e587..986209c54 100644 --- a/packages/connect/src/utils/orderbook_channel_message_parser.ts +++ b/packages/connect/src/utils/orderbook_channel_message_parser.ts @@ -6,7 +6,7 @@ import { OrdersChannelMessage, OrdersChannelMessageTypes } from '../types'; import { relayerResponseJsonParsers } from './relayer_response_json_parsers'; -export const orderbookChannelMessageParser = { +export const ordersChannelMessageParser = { parse(utf8Data: string): OrdersChannelMessage { // parse the message const messageObj = JSON.parse(utf8Data); @@ -19,14 +19,8 @@ export const orderbookChannelMessageParser = { assert.assert(!_.isUndefined(requestId), `Message is missing a requestId parameter: ${utf8Data}`); assert.isNumber('requestId', requestId); switch (type) { - case OrdersChannelMessageTypes.Snapshot: { - assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelSnapshotSchema); - const orderbookJson = messageObj.payload; - const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(orderbookJson); - return _.assign(messageObj, { payload: orderbook }); - } case OrdersChannelMessageTypes.Update: { - assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelUpdateSchema); + assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrdersChannelUpdateSchema); const orderJson = messageObj.payload; const order = relayerResponseJsonParsers.parseOrderJson(orderJson); return _.assign(messageObj, { payload: order }); diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index 55f787820..6463aefb0 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -2,13 +2,13 @@ import { assert } from '@0xproject/assert'; import { schemas } from '@0xproject/json-schemas'; import { SignedOrder } from '@0xproject/types'; -import { OrderConfigResponse, OrderbookResponse, TokenPairsItem } from '../types'; +import { AssetPairsItem, OrderbookResponse, OrderConfigResponse } from '../types'; import { typeConverters } from './type_converters'; export const relayerResponseJsonParsers = { - parseTokenPairsJson(json: any): TokenPairsItem[] { - assert.doesConformToSchema('assetDataPairs', json, schemas.relayerApiTokenPairsResponseSchema); + parseAssetDataPairsJson(json: any): AssetPairsItem[] { + assert.doesConformToSchema('assetDataPairs', json, schemas.relayerApiAssetDataPairsResponseSchema); return json.map((assetDataPair: any) => { return typeConverters.convertStringsFieldsToBigNumbers(assetDataPair, [ 'assetDataA.minAmount', @@ -27,7 +27,7 @@ export const relayerResponseJsonParsers = { return typeConverters.convertOrderStringFieldsToBigNumber(json); }, parseOrderbookResponseJson(json: any): OrderbookResponse { - assert.doesConformToSchema('orderBook', json, schemas.relayerApiOrderBookResponseSchema); + assert.doesConformToSchema('orderBook', json, schemas.relayerApiOrdersResponseSchema); return typeConverters.convertOrderbookStringFieldsToBigNumber(json); }, parseOrderConfigResponseJson(json: any): OrderConfigResponse { -- cgit v1.2.3