chore(): updates for pre-V5 deprecations

This commit is contained in:
tiagosiebler
2025-01-24 15:35:11 +00:00
parent 03169b324c
commit a4945d1caf
4 changed files with 27 additions and 134 deletions

View File

@@ -2,7 +2,10 @@
* Use type guards to narrow down types with minimal efforts.
*/
import { WebsocketSucceededTopicSubscriptionConfirmationEvent } from '../types';
import {
WebsocketSucceededTopicSubscriptionConfirmationEvent,
WebsocketTopicSubscriptionConfirmationEvent,
} from '../types';
import { WSAPIResponse, WS_API_Operations } from '../types/websockets/ws-api';
import {
WSAccountOrderEventV5,
@@ -10,7 +13,6 @@ import {
WSOrderbookEventV5,
WSPositionEventV5,
} from '../types/websockets/ws-events';
import { isTopicSubscriptionConfirmation } from './requestUtils';
/**
* Type guard to detect a V5 orderbook event (delta & snapshots)
@@ -120,3 +122,22 @@ export function isTopicSubscriptionSuccess(
if (!isTopicSubscriptionConfirmation(msg)) return false;
return msg.success === true;
}
export function isTopicSubscriptionConfirmation(
msg: unknown,
): msg is WebsocketTopicSubscriptionConfirmationEvent {
if (typeof msg !== 'object') {
return false;
}
if (!msg) {
return false;
}
if (typeof msg['op'] !== 'string') {
return false;
}
if (msg['op'] !== 'subscribe') {
return false;
}
return true;
}