diff options
author | Fabio Berger <me@fabioberger.com> | 2018-12-17 09:31:38 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-12-17 09:31:38 +0800 |
commit | 896c8d17c16c4f1e9670ab0747ae8934ce5400a5 (patch) | |
tree | 84cffb83e3d5e13d3bba68835fdfd96bd58a5182 /packages/order-watcher/src/order_watcher | |
parent | ee4185ab465c76b64b65efefb92e11b0ca4ecad4 (diff) | |
download | dexon-0x-contracts-896c8d17c16c4f1e9670ab0747ae8934ce5400a5.tar dexon-0x-contracts-896c8d17c16c4f1e9670ab0747ae8934ce5400a5.tar.gz dexon-0x-contracts-896c8d17c16c4f1e9670ab0747ae8934ce5400a5.tar.bz2 dexon-0x-contracts-896c8d17c16c4f1e9670ab0747ae8934ce5400a5.tar.lz dexon-0x-contracts-896c8d17c16c4f1e9670ab0747ae8934ce5400a5.tar.xz dexon-0x-contracts-896c8d17c16c4f1e9670ab0747ae8934ce5400a5.tar.zst dexon-0x-contracts-896c8d17c16c4f1e9670ab0747ae8934ce5400a5.zip |
Fix schemas and tests
Diffstat (limited to 'packages/order-watcher/src/order_watcher')
-rw-r--r-- | packages/order-watcher/src/order_watcher/order_watcher_websocket_server.ts | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/packages/order-watcher/src/order_watcher/order_watcher_websocket_server.ts b/packages/order-watcher/src/order_watcher/order_watcher_websocket_server.ts index f90961cc8..da5667db3 100644 --- a/packages/order-watcher/src/order_watcher/order_watcher_websocket_server.ts +++ b/packages/order-watcher/src/order_watcher/order_watcher_websocket_server.ts @@ -105,20 +105,22 @@ export class OrderWatcherWebSocketServer { private async _onMessageCallbackAsync(connection: WebSocket.connection, message: any): Promise<void> { let response: WebSocketResponse; - assert.doesConformToSchema('message', message, schemas.orderWatcherWebSocketUtf8MessageSchema); - const request: WebSocketRequest = JSON.parse(message.utf8Data); - assert.doesConformToSchema('request', request, schemas.orderWatcherWebSocketRequestSchema); - assert.isString(request.jsonrpc, JSON_RPC_VERSION); + let id: number | null = null; try { + assert.doesConformToSchema('message', message, schemas.orderWatcherWebSocketUtf8MessageSchema); + const request: WebSocketRequest = JSON.parse(message.utf8Data); + id = request.id; + assert.doesConformToSchema('request', request, schemas.orderWatcherWebSocketRequestSchema); + assert.isString(request.jsonrpc, JSON_RPC_VERSION); response = { - id: request.id, + id, jsonrpc: JSON_RPC_VERSION, method: request.method, result: await this._routeRequestAsync(request), }; } catch (err) { response = { - id: request.id, + id, jsonrpc: JSON_RPC_VERSION, method: null, error: err.toString(), |