Skip to content

Commit 7b7ea21

Browse files
authored
Merge pull request #52 from tiagosiebler/fixobupdateparser
feat(v1.1.9): bump audit dependency. fix ws parsing for new ob update event, fix comment for unhandled events. remove unreachable return.
2 parents f028145 + 8ac7e9d commit 7b7ea21

File tree

3 files changed

+45
-139
lines changed

3 files changed

+45
-139
lines changed

package-lock.json

Lines changed: 38 additions & 131 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gateio-api",
3-
"version": "1.1.8",
3+
"version": "1.1.9",
44
"description": "Complete & robust Node.js SDK for Gate.io's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.",
55
"scripts": {
66
"clean": "rm -rf dist/*",

src/WebsocketClient.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ export class WebsocketClient extends BaseWebsocketClient<WsKey> {
310310

311311
const promiseRef = [eventChannel, requestId].join('_');
312312

313-
const eventAction = parsed.event || parsed.action || parsed?.header.data;
313+
const eventAction =
314+
parsed.event || parsed.action || parsed?.header?.data || parsed.channel;
314315

315316
if (eventType === 'api') {
316317
const isError = eventStatusCode !== '200';
@@ -390,7 +391,8 @@ export class WebsocketClient extends BaseWebsocketClient<WsKey> {
390391

391392
// Most events use "event: 'update'" for topic updates
392393
// The legacy "futures.order_book" topic uses "all" for this field
393-
if (['update', 'all'].includes(eventAction)) {
394+
// 'futures.obu' is used for the orderbook v2 event. Oddly in a different structure than the other topics.
395+
if (['update', 'all', 'futures.obu'].includes(eventAction)) {
394396
results.push({
395397
eventType: 'update',
396398
event: parsed,
@@ -417,13 +419,12 @@ export class WebsocketClient extends BaseWebsocketClient<WsKey> {
417419
}
418420

419421
this.logger.error(
420-
`!! Unhandled string event type "${eventAction}. Defaulting to "update" channel...`,
422+
`!! Unhandled string event type "${eventAction}". Defaulting to "update" channel...`,
421423
parsed,
422424
);
423425
} else {
424-
// TODO: test meee
425426
this.logger.error(
426-
`!! Unhandled non-string event type "${eventAction}. Defaulting to "update" channel...`,
427+
`!! Unhandled non-string event type "${eventAction}". Defaulting to "update" channel...`,
427428
parsed,
428429
);
429430
}
@@ -483,8 +484,6 @@ export class WebsocketClient extends BaseWebsocketClient<WsKey> {
483484
default:
484485
throw neverGuard(wsKey, `Unhandled WsKey "${wsKey}"`);
485486
}
486-
487-
return false;
488487
}
489488

490489
/**

0 commit comments

Comments
 (0)