diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-08-21 02:42:29 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-08-21 02:42:29 +0800 |
commit | 075e3a41c876797907e3ad98f20940e32e8d0762 (patch) | |
tree | d1f9db70ee1a56b500a3293a9ee962fd08f7abec /packages/connect/src/utils | |
parent | f2d1d953553adfa59f0a39bf2cf98817fae0a4ff (diff) | |
download | dexon-sol-tools-075e3a41c876797907e3ad98f20940e32e8d0762.tar dexon-sol-tools-075e3a41c876797907e3ad98f20940e32e8d0762.tar.gz dexon-sol-tools-075e3a41c876797907e3ad98f20940e32e8d0762.tar.bz2 dexon-sol-tools-075e3a41c876797907e3ad98f20940e32e8d0762.tar.lz dexon-sol-tools-075e3a41c876797907e3ad98f20940e32e8d0762.tar.xz dexon-sol-tools-075e3a41c876797907e3ad98f20940e32e8d0762.tar.zst dexon-sol-tools-075e3a41c876797907e3ad98f20940e32e8d0762.zip |
Update websocket for SRA v2
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); |