chore(): updates for pre-V5 deprecations
This commit is contained in:
@@ -51,8 +51,6 @@ interface SignedRequestContext {
|
||||
timestamp?: number;
|
||||
api_key?: string;
|
||||
recv_window?: number;
|
||||
// spot v1 is diff from the rest...
|
||||
recvWindow?: number;
|
||||
}
|
||||
|
||||
interface SignedRequest<T> {
|
||||
@@ -72,7 +70,7 @@ interface UnsignedRequest<T> {
|
||||
recvWindow?: number;
|
||||
}
|
||||
|
||||
type SignMethod = 'v2auth' | 'v5auth';
|
||||
type SignMethod = 'v5auth';
|
||||
|
||||
export default abstract class BaseRestClient {
|
||||
private timeOffset: number | null = null;
|
||||
@@ -443,40 +441,6 @@ export default abstract class BaseRestClient {
|
||||
return res;
|
||||
}
|
||||
|
||||
// spot/v2 derivatives
|
||||
if (signMethod === 'v2auth') {
|
||||
res.originalParams.api_key = key;
|
||||
res.originalParams.timestamp = timestamp;
|
||||
|
||||
// Optional, set to 5000 by default. Increase if timestamp/recv_window errors are seen.
|
||||
if (recvWindow) {
|
||||
res.originalParams.recv_window = recvWindow;
|
||||
}
|
||||
const sortProperties = true;
|
||||
const encodeValues = false;
|
||||
|
||||
res.serializedParams = serializeParams(
|
||||
res.originalParams,
|
||||
strictParamValidation,
|
||||
sortProperties,
|
||||
encodeValues,
|
||||
);
|
||||
res.sign = await this.signMessage(
|
||||
res.serializedParams,
|
||||
this.secret,
|
||||
'hex',
|
||||
'SHA-256',
|
||||
);
|
||||
|
||||
// @ts-ignore
|
||||
res.paramsWithSign = {
|
||||
...res.originalParams,
|
||||
sign: res.sign,
|
||||
};
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { APIRateLimit } from '../types';
|
||||
import {
|
||||
WebsocketSucceededTopicSubscriptionConfirmationEvent,
|
||||
WebsocketTopicSubscriptionConfirmationEvent,
|
||||
} from '../types/websockets/ws-confirmations';
|
||||
import { WSAPIResponse, WS_API_Operations } from '../types/websockets/ws-api';
|
||||
|
||||
export interface RestClientOptions {
|
||||
/** Your API key */
|
||||
@@ -188,25 +183,6 @@ export function isWsPong(msg: any): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export const APIID = 'bybitapinode';
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user