diff options
Diffstat (limited to 'packages/connect/src/utils')
-rw-r--r-- | packages/connect/src/utils/orderbook_channel_message_parser.ts | 10 | ||||
-rw-r--r-- | packages/connect/src/utils/relayer_response_json_parsers.ts | 8 |
2 files changed, 6 insertions, 12 deletions
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 { |