Use uuid as string for requestId

This commit is contained in:
fragosti 2018-08-16 16:51:55 -07:00
parent 89174cd63f
commit e079790f7f
3 changed files with 14 additions and 6 deletions

View File

@ -59,6 +59,7 @@
"lodash": "^4.17.5",
"query-string": "^5.0.1",
"sinon": "^4.0.0",
"uuid": "^3.3.2",
"websocket": "^1.0.25"
},
"devDependencies": {
@ -69,6 +70,7 @@
"@types/mocha": "^2.2.42",
"@types/query-string": "^5.0.1",
"@types/sinon": "^2.2.2",
"@types/uuid": "^3.4.3",
"@types/websocket": "^0.0.39",
"async-child-process": "^1.1.1",
"chai": "^4.0.1",

View File

@ -1,4 +1,5 @@
import * as _ from 'lodash';
import { v4 as uuid } from 'uuid';
import * as WebSocket from 'websocket';
import {
@ -50,11 +51,10 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
assert.isOrderbookChannelSubscriptionOpts('subscriptionOpts', subscriptionOpts);
assert.assert(this._client.readyState === WebSocket.w3cwebsocket.OPEN, 'WebSocket connection is closed');
this._subscriptionOptsList.push(subscriptionOpts);
// TODO: update requestId management to use UUIDs for v2
const subscribeMessage = {
type: 'subscribe',
channel: 'orderbook',
requestId: this._subscriptionOptsList.length - 1,
requestId: uuid(),
payload: subscriptionOpts,
};
this._client.send(JSON.stringify(subscribeMessage));

View File

@ -1258,6 +1258,12 @@
dependencies:
"@types/node" "*"
"@types/uuid@^3.4.3":
version "3.4.3"
resolved "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.3.tgz#121ace265f5569ce40f4f6d0ff78a338c732a754"
dependencies:
"@types/node" "*"
"@types/valid-url@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@types/valid-url/-/valid-url-1.0.2.tgz#60fa435ce24bfd5ba107b8d2a80796aeaf3a8f45"
@ -5256,9 +5262,9 @@ ethereumjs-wallet@~0.6.0:
utf8 "^3.0.0"
uuid "^3.3.2"
ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22:
version "3.0.18"
resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/b91342bd200d142af0165d6befddf783c8ae8447"
ethers@3.0.22:
version "3.0.22"
resolved "https://registry.npmjs.org/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436"
dependencies:
aes-js "3.0.0"
bn.js "^4.4.0"
@ -14072,7 +14078,7 @@ uuid@^2.0.1:
uuid@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
resolved "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
uvm@1.7.0:
version "1.7.0"