diff options
Diffstat (limited to 'packages/connect/src/utils')
-rw-r--r-- | packages/connect/src/utils/orders_channel_message_parser.ts (renamed from packages/connect/src/utils/orderbook_channel_message_parser.ts) | 10 | ||||
-rw-r--r-- | packages/connect/src/utils/relayer_response_json_parsers.ts | 5 |
2 files changed, 9 insertions, 6 deletions
diff --git a/packages/connect/src/utils/orderbook_channel_message_parser.ts b/packages/connect/src/utils/orders_channel_message_parser.ts index 97d8f2d6a..1b6cda17b 100644 --- a/packages/connect/src/utils/orderbook_channel_message_parser.ts +++ b/packages/connect/src/utils/orders_channel_message_parser.ts @@ -15,15 +15,15 @@ export const ordersChannelMessageParser = { assert.assert(!_.isUndefined(type), `Message is missing a type parameter: ${utf8Data}`); assert.isString('type', type); // ensure we have a request id for the resulting message - const requestId: number = _.get(messageObj, 'requestId'); + const requestId: string = _.get(messageObj, 'requestId'); assert.assert(!_.isUndefined(requestId), `Message is missing a requestId parameter: ${utf8Data}`); - assert.isNumber('requestId', requestId); + assert.isString('requestId', requestId); switch (type) { case OrdersChannelMessageTypes.Update: { assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrdersChannelUpdateSchema); - const orderJson = messageObj.payload; - const order = relayerResponseJsonParsers.parseAPIOrderJson(orderJson); - return _.assign(messageObj, { payload: order }); + const ordersJson = messageObj.payload; + const orders = relayerResponseJsonParsers.parseAPIOrdersJson(ordersJson); + return _.assign(messageObj, { payload: orders }); } default: { return { diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index 2b2e1efe7..dff854dfb 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -22,7 +22,10 @@ export const relayerResponseJsonParsers = { }, parseOrdersJson(json: any): OrdersResponse { assert.doesConformToSchema('relayerApiOrdersResponse', json, schemas.relayerApiOrdersResponseSchema); - return { ...json, records: json.records.map(relayerResponseJsonParsers.parseAPIOrderJson.bind(relayerResponseJsonParsers)) }; + return { ...json, records: relayerResponseJsonParsers.parseAPIOrdersJson(json.records) }; + }, + parseAPIOrdersJson(json: any): APIOrder[] { + return json.map(relayerResponseJsonParsers.parseAPIOrderJson.bind(relayerResponseJsonParsers)); }, parseAPIOrderJson(json: any): APIOrder { assert.doesConformToSchema('relayerApiOrder', json, schemas.relayerApiOrderSchema); |