@nktkas/hyperliquid 0.24.1 → 0.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -102
- package/esm/src/clients/exchange.d.ts +41 -41
- package/esm/src/clients/exchange.js +40 -40
- package/esm/src/clients/info.d.ts +63 -57
- package/esm/src/clients/info.d.ts.map +1 -1
- package/esm/src/clients/info.js +60 -92
- package/esm/src/clients/subscription.d.ts +104 -31
- package/esm/src/clients/subscription.d.ts.map +1 -1
- package/esm/src/clients/subscription.js +92 -12
- package/esm/src/signing/mod.d.ts +4 -4
- package/esm/src/signing/mod.js +4 -4
- package/esm/src/transports/http/http_transport.js +1 -1
- package/esm/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
- package/esm/src/transports/websocket/_websocket_async_request.js +4 -0
- package/esm/src/transports/websocket/websocket_transport.js +3 -3
- package/esm/src/types/info/requests.d.ts +6 -0
- package/esm/src/types/info/requests.d.ts.map +1 -1
- package/esm/src/types/subscriptions/requests.d.ts +11 -0
- package/esm/src/types/subscriptions/requests.d.ts.map +1 -1
- package/esm/src/types/subscriptions/responses.d.ts +25 -0
- package/esm/src/types/subscriptions/responses.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/src/clients/exchange.d.ts +41 -41
- package/script/src/clients/exchange.js +40 -40
- package/script/src/clients/info.d.ts +63 -57
- package/script/src/clients/info.d.ts.map +1 -1
- package/script/src/clients/info.js +60 -92
- package/script/src/clients/subscription.d.ts +104 -31
- package/script/src/clients/subscription.d.ts.map +1 -1
- package/script/src/clients/subscription.js +92 -12
- package/script/src/signing/mod.d.ts +4 -4
- package/script/src/signing/mod.js +4 -4
- package/script/src/transports/http/http_transport.js +1 -1
- package/script/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
- package/script/src/transports/websocket/_websocket_async_request.js +4 -0
- package/script/src/transports/websocket/websocket_transport.js +3 -3
- package/script/src/types/info/requests.d.ts +6 -0
- package/script/src/types/info/requests.d.ts.map +1 -1
- package/script/src/types/subscriptions/requests.d.ts +11 -0
- package/script/src/types/subscriptions/requests.d.ts.map +1 -1
- package/script/src/types/subscriptions/responses.d.ts +25 -0
- package/script/src/types/subscriptions/responses.d.ts.map +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ISubscriptionTransport, Subscription } from "../transports/base.js";
|
|
2
|
-
import type { ActiveAssetData, ActiveAssetDataRequest, AllMidsRequest, Book, Candle, L2BookRequest, Order, OrderStatus, TxDetails, UserFillsRequest, UserTwapSliceFillsRequest, WsActiveAssetCtx, WsActiveAssetCtxRequest, WsActiveSpotAssetCtx, WsAllMids, WsBbo, WsBboRequest, WsBlockDetails, WsCandleRequest, WsNotification, WsNotificationRequest, WsOrderUpdatesRequest, WsTrade, WsTradesRequest, WsUserEvent, WsUserEventsRequest, WsUserFills, WsUserFundings, WsUserFundingsRequest, WsUserNonFundingLedgerUpdates, WsUserNonFundingLedgerUpdatesRequest, WsUserTwapHistory, WsUserTwapHistoryRequest, WsUserTwapSliceFills, WsWebData2, WsWebData2Request } from "../types/mod.js";
|
|
2
|
+
import type { ActiveAssetData, ActiveAssetDataRequest, AllMidsRequest, Book, Candle, ClearinghouseStateRequest, L2BookRequest, OpenOrdersRequest, Order, OrderStatus, TxDetails, UserFillsRequest, UserTwapSliceFillsRequest, WsActiveAssetCtx, WsActiveAssetCtxRequest, WsActiveSpotAssetCtx, WsAllMids, WsAssetCtxs, WsAssetCtxsRequest, WsBbo, WsBboRequest, WsBlockDetails, WsCandleRequest, WsClearinghouseState, WsNotification, WsNotificationRequest, WsOpenOrders, WsOrderUpdatesRequest, WsTrade, WsTradesRequest, WsUserEvent, WsUserEventsRequest, WsUserFills, WsUserFundings, WsUserFundingsRequest, WsUserNonFundingLedgerUpdates, WsUserNonFundingLedgerUpdatesRequest, WsUserTwapHistory, WsUserTwapHistoryRequest, WsUserTwapSliceFills, WsWebData2, WsWebData2Request } from "../types/mod.js";
|
|
3
3
|
/** @see https://github.com/microsoft/TypeScript/issues/13923#issuecomment-2191862501 */
|
|
4
4
|
type DeepImmutable<T> = {
|
|
5
5
|
readonly [K in keyof T]: DeepImmutable<T[K]>;
|
|
@@ -10,37 +10,43 @@ export interface SubscriptionClientParameters<T extends ISubscriptionTransport =
|
|
|
10
10
|
transport: T;
|
|
11
11
|
}
|
|
12
12
|
/** Subscription parameters for the {@linkcode SubscriptionClient.activeAssetCtx} method. */
|
|
13
|
-
export type
|
|
13
|
+
export type WsActiveAssetCtxParameters = Omit<WsActiveAssetCtxRequest, "type">;
|
|
14
14
|
/** Subscription parameters for the {@linkcode SubscriptionClient.activeAssetData} method. */
|
|
15
|
-
export type
|
|
15
|
+
export type WsActiveAssetDataParameters = Omit<ActiveAssetDataRequest, "type">;
|
|
16
16
|
/** Subscription parameters for the {@linkcode SubscriptionClient.allMids} method. */
|
|
17
17
|
export type WsAllMidsParameters = Omit<AllMidsRequest, "type">;
|
|
18
|
+
/** Subscription parameters for the {@linkcode SubscriptionClient.assetCtxs} method. */
|
|
19
|
+
export type WsAssetCtxsParameters = Omit<WsAssetCtxsRequest, "type">;
|
|
18
20
|
/** Subscription parameters for the {@linkcode SubscriptionClient.bbo} method. */
|
|
19
|
-
export type
|
|
21
|
+
export type WsBboParameters = Omit<WsBboRequest, "type">;
|
|
20
22
|
/** Subscription parameters for the {@linkcode SubscriptionClient.candle} method. */
|
|
21
|
-
export type
|
|
23
|
+
export type WsCandleParameters = Omit<WsCandleRequest, "type">;
|
|
24
|
+
/** Subscription parameters for the {@linkcode SubscriptionClient.clearinghouseState} method. */
|
|
25
|
+
export type WsClearinghouseStateParameters = Omit<ClearinghouseStateRequest, "type">;
|
|
22
26
|
/** Subscription parameters for the {@linkcode SubscriptionClient.l2Book} method. */
|
|
23
|
-
export type
|
|
27
|
+
export type WsL2BookParameters = Omit<L2BookRequest, "type">;
|
|
24
28
|
/** Subscription parameters for the {@linkcode SubscriptionClient.notification} method. */
|
|
25
|
-
export type
|
|
29
|
+
export type WsNotificationParameters = Omit<WsNotificationRequest, "type">;
|
|
30
|
+
/** Subscription parameters for the {@linkcode SubscriptionClient.openOrders} method. */
|
|
31
|
+
export type WsOpenOrdersParameters = Omit<OpenOrdersRequest, "type">;
|
|
26
32
|
/** Subscription parameters for the {@linkcode SubscriptionClient.orderUpdates} method. */
|
|
27
|
-
export type
|
|
33
|
+
export type WsOrderUpdatesParameters = Omit<WsOrderUpdatesRequest, "type">;
|
|
28
34
|
/** Subscription parameters for the {@linkcode SubscriptionClient.trades} method. */
|
|
29
|
-
export type
|
|
35
|
+
export type WsTradesParameters = Omit<WsTradesRequest, "type">;
|
|
30
36
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userEvents} method. */
|
|
31
|
-
export type
|
|
37
|
+
export type WsUserEventsParameters = Omit<WsUserEventsRequest, "type">;
|
|
32
38
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userFills} method. */
|
|
33
|
-
export type
|
|
39
|
+
export type WsUserFillsParameters = Omit<UserFillsRequest, "type">;
|
|
34
40
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userFundings} method. */
|
|
35
|
-
export type
|
|
41
|
+
export type WsUserFundingsParameters = Omit<WsUserFundingsRequest, "type">;
|
|
36
42
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userNonFundingLedgerUpdates} method. */
|
|
37
|
-
export type
|
|
43
|
+
export type WsUserNonFundingLedgerUpdatesParameters = Omit<WsUserNonFundingLedgerUpdatesRequest, "type">;
|
|
38
44
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userTwapHistory} method. */
|
|
39
|
-
export type
|
|
45
|
+
export type WsUserTwapHistoryParameters = Omit<WsUserTwapHistoryRequest, "type">;
|
|
40
46
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userTwapSliceFills} method. */
|
|
41
|
-
export type
|
|
47
|
+
export type WsUserTwapSliceFillsParameters = Omit<UserTwapSliceFillsRequest, "type">;
|
|
42
48
|
/** Subscription parameters for the {@linkcode SubscriptionClient.webData2} method. */
|
|
43
|
-
export type
|
|
49
|
+
export type WsWebData2Parameters = Omit<WsWebData2Request, "type">;
|
|
44
50
|
/**
|
|
45
51
|
* Subscription client for subscribing to various Hyperliquid events.
|
|
46
52
|
* @typeParam T The type of transport used to connect to the Hyperliquid Websocket API.
|
|
@@ -81,7 +87,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
81
87
|
* });
|
|
82
88
|
* ```
|
|
83
89
|
*/
|
|
84
|
-
activeAssetCtx(params: DeepImmutable<
|
|
90
|
+
activeAssetCtx(params: DeepImmutable<WsActiveAssetCtxParameters>, listener: (data: WsActiveAssetCtx | WsActiveSpotAssetCtx) => void): Promise<Subscription>;
|
|
85
91
|
/**
|
|
86
92
|
* Subscribe to trading data updates for a specific asset and user.
|
|
87
93
|
* @param params - Subscription-specific parameters.
|
|
@@ -103,7 +109,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
103
109
|
* });
|
|
104
110
|
* ```
|
|
105
111
|
*/
|
|
106
|
-
activeAssetData(params: DeepImmutable<
|
|
112
|
+
activeAssetData(params: DeepImmutable<WsActiveAssetDataParameters>, listener: (data: ActiveAssetData) => void): Promise<Subscription>;
|
|
107
113
|
/**
|
|
108
114
|
* Subscribe to mid prices for all actively traded assets.
|
|
109
115
|
* @param params - An optional subscription-specific parameters.
|
|
@@ -127,6 +133,29 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
127
133
|
*/
|
|
128
134
|
allMids(listener: (data: WsAllMids) => void): Promise<Subscription>;
|
|
129
135
|
allMids(params: DeepImmutable<WsAllMidsParameters>, listener: (data: WsAllMids) => void): Promise<Subscription>;
|
|
136
|
+
/**
|
|
137
|
+
* Subscribe to asset contexts for all perpetual assets.
|
|
138
|
+
* @param params - An optional subscription-specific parameters.
|
|
139
|
+
* @param listener - A callback function to be called when the event is received.
|
|
140
|
+
* @returns A request-promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
141
|
+
*
|
|
142
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
143
|
+
*
|
|
144
|
+
* @see null
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
148
|
+
*
|
|
149
|
+
* const transport = new hl.WebSocketTransport();
|
|
150
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
151
|
+
*
|
|
152
|
+
* const sub = await subsClient.assetCtxs((data) => {
|
|
153
|
+
* console.log(data);
|
|
154
|
+
* });
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
assetCtxs(listener: (data: WsAssetCtxs) => void): Promise<Subscription>;
|
|
158
|
+
assetCtxs(params: DeepImmutable<WsAssetCtxsParameters>, listener: (data: WsAssetCtxs) => void): Promise<Subscription>;
|
|
130
159
|
/**
|
|
131
160
|
* Subscribe to best bid and offer updates for a specific asset.
|
|
132
161
|
* @param params - Subscription-specific parameters.
|
|
@@ -148,7 +177,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
148
177
|
* });
|
|
149
178
|
* ```
|
|
150
179
|
*/
|
|
151
|
-
bbo(params: DeepImmutable<
|
|
180
|
+
bbo(params: DeepImmutable<WsBboParameters>, listener: (data: WsBbo) => void): Promise<Subscription>;
|
|
152
181
|
/**
|
|
153
182
|
* Subscribe to candlestick data updates for a specific asset.
|
|
154
183
|
* @param params - Subscription-specific parameters.
|
|
@@ -170,7 +199,29 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
170
199
|
* });
|
|
171
200
|
* ```
|
|
172
201
|
*/
|
|
173
|
-
candle(params: DeepImmutable<
|
|
202
|
+
candle(params: DeepImmutable<WsCandleParameters>, listener: (data: Candle) => void): Promise<Subscription>;
|
|
203
|
+
/**
|
|
204
|
+
* Subscribe to clearinghouse state updates for a specific user.
|
|
205
|
+
* @param params - Subscription-specific parameters.
|
|
206
|
+
* @param listener - A callback function to be called when the event is received.
|
|
207
|
+
* @returns A request-promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
208
|
+
*
|
|
209
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
210
|
+
*
|
|
211
|
+
* @see null
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
215
|
+
*
|
|
216
|
+
* const transport = new hl.WebSocketTransport();
|
|
217
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
218
|
+
*
|
|
219
|
+
* const sub = await subsClient.clearinghouseState({ user: "0x..." }, (data) => {
|
|
220
|
+
* console.log(data);
|
|
221
|
+
* });
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
clearinghouseState(params: DeepImmutable<WsClearinghouseStateParameters>, listener: (data: WsClearinghouseState) => void): Promise<Subscription>;
|
|
174
225
|
/**
|
|
175
226
|
* Subscribe to explorer block updates.
|
|
176
227
|
* @param listener - A callback function to be called when the event is received.
|
|
@@ -236,7 +287,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
236
287
|
* });
|
|
237
288
|
* ```
|
|
238
289
|
*/
|
|
239
|
-
l2Book(params: DeepImmutable<
|
|
290
|
+
l2Book(params: DeepImmutable<WsL2BookParameters>, listener: (data: Book) => void): Promise<Subscription>;
|
|
240
291
|
/**
|
|
241
292
|
* Subscribe to notification updates for a specific user.
|
|
242
293
|
* @param params - Subscription-specific parameters.
|
|
@@ -258,7 +309,29 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
258
309
|
* });
|
|
259
310
|
* ```
|
|
260
311
|
*/
|
|
261
|
-
notification(params: DeepImmutable<
|
|
312
|
+
notification(params: DeepImmutable<WsNotificationParameters>, listener: (data: WsNotification) => void): Promise<Subscription>;
|
|
313
|
+
/**
|
|
314
|
+
* Subscribe to open orders updates for a specific user.
|
|
315
|
+
* @param params - Subscription-specific parameters.
|
|
316
|
+
* @param listener - A callback function to be called when the event is received.
|
|
317
|
+
* @returns A request-promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
318
|
+
*
|
|
319
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
320
|
+
*
|
|
321
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
322
|
+
* @example
|
|
323
|
+
* ```ts
|
|
324
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
325
|
+
*
|
|
326
|
+
* const transport = new hl.WebSocketTransport();
|
|
327
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
328
|
+
*
|
|
329
|
+
* const sub = await subsClient.openOrders({ user: "0x..." }, (data) => {
|
|
330
|
+
* console.log(data);
|
|
331
|
+
* });
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
openOrders(params: DeepImmutable<WsOpenOrdersParameters>, listener: (data: WsOpenOrders) => void): Promise<Subscription>;
|
|
262
335
|
/**
|
|
263
336
|
* Subscribe to order status updates for a specific user.
|
|
264
337
|
* @param params - Subscription-specific parameters.
|
|
@@ -280,7 +353,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
280
353
|
* });
|
|
281
354
|
* ```
|
|
282
355
|
*/
|
|
283
|
-
orderUpdates(params: DeepImmutable<
|
|
356
|
+
orderUpdates(params: DeepImmutable<WsOrderUpdatesParameters>, listener: (data: OrderStatus<Order>[]) => void): Promise<Subscription>;
|
|
284
357
|
/**
|
|
285
358
|
* Subscribe to real-time trade updates for a specific asset.
|
|
286
359
|
* @param params - Subscription-specific parameters.
|
|
@@ -302,7 +375,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
302
375
|
* });
|
|
303
376
|
* ```
|
|
304
377
|
*/
|
|
305
|
-
trades(params: DeepImmutable<
|
|
378
|
+
trades(params: DeepImmutable<WsTradesParameters>, listener: (data: WsTrade[]) => void): Promise<Subscription>;
|
|
306
379
|
/**
|
|
307
380
|
* Subscribe to non-order events for a specific user.
|
|
308
381
|
* @param params - Subscription-specific parameters.
|
|
@@ -325,7 +398,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
325
398
|
* });
|
|
326
399
|
* ```
|
|
327
400
|
*/
|
|
328
|
-
userEvents(params: DeepImmutable<
|
|
401
|
+
userEvents(params: DeepImmutable<WsUserEventsParameters>, listener: (data: WsUserEvent) => void): Promise<Subscription>;
|
|
329
402
|
/**
|
|
330
403
|
* Subscribe to trade fill updates for a specific user.
|
|
331
404
|
* @param params - Subscription-specific parameters.
|
|
@@ -347,7 +420,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
347
420
|
* });
|
|
348
421
|
* ```
|
|
349
422
|
*/
|
|
350
|
-
userFills(params: DeepImmutable<
|
|
423
|
+
userFills(params: DeepImmutable<WsUserFillsParameters>, listener: (data: WsUserFills) => void): Promise<Subscription>;
|
|
351
424
|
/**
|
|
352
425
|
* Subscribe to funding payment updates for a specific user.
|
|
353
426
|
* @param params - Subscription-specific parameters.
|
|
@@ -369,7 +442,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
369
442
|
* });
|
|
370
443
|
* ```
|
|
371
444
|
*/
|
|
372
|
-
userFundings(params: DeepImmutable<
|
|
445
|
+
userFundings(params: DeepImmutable<WsUserFundingsParameters>, listener: (data: WsUserFundings) => void): Promise<Subscription>;
|
|
373
446
|
/**
|
|
374
447
|
* Subscribe to non-funding ledger updates for a specific user.
|
|
375
448
|
* @param params - Subscription-specific parameters.
|
|
@@ -391,7 +464,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
391
464
|
* });
|
|
392
465
|
* ```
|
|
393
466
|
*/
|
|
394
|
-
userNonFundingLedgerUpdates(params: DeepImmutable<
|
|
467
|
+
userNonFundingLedgerUpdates(params: DeepImmutable<WsUserNonFundingLedgerUpdatesParameters>, listener: (data: WsUserNonFundingLedgerUpdates) => void): Promise<Subscription>;
|
|
395
468
|
/**
|
|
396
469
|
* Subscribe to TWAP order history updates for a specific user.
|
|
397
470
|
* @param params - Subscription-specific parameters.
|
|
@@ -413,7 +486,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
413
486
|
* });
|
|
414
487
|
* ```
|
|
415
488
|
*/
|
|
416
|
-
userTwapHistory(params: DeepImmutable<
|
|
489
|
+
userTwapHistory(params: DeepImmutable<WsUserTwapHistoryParameters>, listener: (data: WsUserTwapHistory) => void): Promise<Subscription>;
|
|
417
490
|
/**
|
|
418
491
|
* Subscribe to TWAP execution updates for a specific user.
|
|
419
492
|
* @param params - Subscription-specific parameters.
|
|
@@ -435,7 +508,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
435
508
|
* });
|
|
436
509
|
* ```
|
|
437
510
|
*/
|
|
438
|
-
userTwapSliceFills(params: DeepImmutable<
|
|
511
|
+
userTwapSliceFills(params: DeepImmutable<WsUserTwapSliceFillsParameters>, listener: (data: WsUserTwapSliceFills) => void): Promise<Subscription>;
|
|
439
512
|
/**
|
|
440
513
|
* Subscribe to comprehensive user and market data updates.
|
|
441
514
|
* @param params - Subscription-specific parameters.
|
|
@@ -457,7 +530,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
457
530
|
* });
|
|
458
531
|
* ```
|
|
459
532
|
*/
|
|
460
|
-
webData2(params: DeepImmutable<
|
|
533
|
+
webData2(params: DeepImmutable<WsWebData2Parameters>, listener: (data: WsWebData2) => void): Promise<Subscription>;
|
|
461
534
|
[Symbol.asyncDispose](): Promise<void>;
|
|
462
535
|
}
|
|
463
536
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/src/clients/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EACR,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,IAAI,EACJ,MAAM,EACN,aAAa,EACb,KAAK,EACL,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,yBAAyB,EACzB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,SAAS,EACT,KAAK,EACL,YAAY,EACZ,cAAc,EACd,eAAe,
|
|
1
|
+
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/src/clients/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EACR,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,IAAI,EACJ,MAAM,EACN,yBAAyB,EACzB,aAAa,EACb,iBAAiB,EACjB,KAAK,EACL,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,yBAAyB,EACzB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,KAAK,EACL,YAAY,EACZ,cAAc,EACd,eAAe,EACf,oBAAoB,EAGpB,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,OAAO,EACP,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,6BAA6B,EAC7B,oCAAoC,EACpC,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,UAAU,EACV,iBAAiB,EACpB,MAAM,iBAAiB,CAAC;AAEzB,wFAAwF;AACxF,KAAK,aAAa,CAAC,CAAC,IAAI;IACpB,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,qEAAqE;AACrE,MAAM,WAAW,4BAA4B,CAAC,CAAC,SAAS,sBAAsB,GAAG,sBAAs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AC,qBAAqB,CAAC,EAC5C,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GACtC,OAAO,CAAC,YAAY,CAAC;IAaxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,CACR,MAAM,EAAE,aAAa,CAAC,wBAAwB,CAAC,EAC/C,QAAQ,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GACzC,OAAO,CAAC,YAAY,CAAC;IASxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,2BAA2B,CACvB,MAAM,EAAE,aAAa,CAAC,uCAAuC,CAAC,EAC9D,QAAQ,EAAE,CAAC,IAAI,EAAE,6BAA6B,KAAK,IAAI,GACxD,OAAO,CAAC,YAAY,CAAC;IAYxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,eAAe,CACX,MAAM,EAAE,aAAa,CAAC,2BAA2B,CAAC,EAClD,QAAQ,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,GAC5C,OAAO,CAAC,YAAY,CAAC;IASxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,kBAAkB,CACd,MAAM,EAAE,aAAa,CAAC,8BAA8B,CAAC,EACrD,QAAQ,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,GAC/C,OAAO,CAAC,YAAY,CAAC;IASxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,CACJ,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,EAC3C,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GACrC,OAAO,CAAC,YAAY,CAAC;IASlB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/C"}
|
|
@@ -44,7 +44,7 @@ export class SubscriptionClient {
|
|
|
44
44
|
const channel = params.coin.startsWith("@") ? "activeSpotAssetCtx" : "activeAssetCtx";
|
|
45
45
|
const payload = { type: "activeAssetCtx", ...params };
|
|
46
46
|
return this.transport.subscribe(channel, payload, (e) => {
|
|
47
|
-
if (e.detail.coin ===
|
|
47
|
+
if (e.detail.coin === payload.coin) {
|
|
48
48
|
listener(e.detail);
|
|
49
49
|
}
|
|
50
50
|
});
|
|
@@ -73,7 +73,7 @@ export class SubscriptionClient {
|
|
|
73
73
|
activeAssetData(params, listener) {
|
|
74
74
|
const payload = { type: "activeAssetData", ...params };
|
|
75
75
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
76
|
-
if (e.detail.coin ===
|
|
76
|
+
if (e.detail.coin === payload.coin && e.detail.user === payload.user.toLowerCase()) {
|
|
77
77
|
listener(e.detail);
|
|
78
78
|
}
|
|
79
79
|
});
|
|
@@ -86,6 +86,20 @@ export class SubscriptionClient {
|
|
|
86
86
|
listener(e.detail);
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
+
assetCtxs(params_or_listener, maybeListener) {
|
|
90
|
+
const params = typeof params_or_listener === "function" ? {} : params_or_listener;
|
|
91
|
+
const listener = typeof params_or_listener === "function" ? params_or_listener : maybeListener;
|
|
92
|
+
const payload = {
|
|
93
|
+
type: "assetCtxs",
|
|
94
|
+
...params,
|
|
95
|
+
dex: params.dex ?? "",
|
|
96
|
+
};
|
|
97
|
+
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
98
|
+
if (e.detail.dex === payload.dex) {
|
|
99
|
+
listener(e.detail);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
89
103
|
/**
|
|
90
104
|
* Subscribe to best bid and offer updates for a specific asset.
|
|
91
105
|
* @param params - Subscription-specific parameters.
|
|
@@ -110,7 +124,7 @@ export class SubscriptionClient {
|
|
|
110
124
|
bbo(params, listener) {
|
|
111
125
|
const payload = { type: "bbo", ...params };
|
|
112
126
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
113
|
-
if (e.detail.coin ===
|
|
127
|
+
if (e.detail.coin === payload.coin) {
|
|
114
128
|
listener(e.detail);
|
|
115
129
|
}
|
|
116
130
|
});
|
|
@@ -139,7 +153,40 @@ export class SubscriptionClient {
|
|
|
139
153
|
candle(params, listener) {
|
|
140
154
|
const payload = { type: "candle", ...params };
|
|
141
155
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
142
|
-
if (e.detail.s ===
|
|
156
|
+
if (e.detail.s === payload.coin && e.detail.i === payload.interval) {
|
|
157
|
+
listener(e.detail);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Subscribe to clearinghouse state updates for a specific user.
|
|
163
|
+
* @param params - Subscription-specific parameters.
|
|
164
|
+
* @param listener - A callback function to be called when the event is received.
|
|
165
|
+
* @returns A request-promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
166
|
+
*
|
|
167
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
168
|
+
*
|
|
169
|
+
* @see null
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
173
|
+
*
|
|
174
|
+
* const transport = new hl.WebSocketTransport();
|
|
175
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
176
|
+
*
|
|
177
|
+
* const sub = await subsClient.clearinghouseState({ user: "0x..." }, (data) => {
|
|
178
|
+
* console.log(data);
|
|
179
|
+
* });
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
clearinghouseState(params, listener) {
|
|
183
|
+
const payload = {
|
|
184
|
+
type: "clearinghouseState",
|
|
185
|
+
...params,
|
|
186
|
+
dex: params.dex ?? "",
|
|
187
|
+
};
|
|
188
|
+
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
189
|
+
if (e.detail.user === payload.user.toLowerCase() && e.detail.dex === payload.dex) {
|
|
143
190
|
listener(e.detail);
|
|
144
191
|
}
|
|
145
192
|
});
|
|
@@ -227,7 +274,7 @@ export class SubscriptionClient {
|
|
|
227
274
|
mantissa: params.mantissa ?? null,
|
|
228
275
|
};
|
|
229
276
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
230
|
-
if (e.detail.coin ===
|
|
277
|
+
if (e.detail.coin === payload.coin) {
|
|
231
278
|
listener(e.detail);
|
|
232
279
|
}
|
|
233
280
|
});
|
|
@@ -259,6 +306,39 @@ export class SubscriptionClient {
|
|
|
259
306
|
listener(e.detail);
|
|
260
307
|
});
|
|
261
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* Subscribe to open orders updates for a specific user.
|
|
311
|
+
* @param params - Subscription-specific parameters.
|
|
312
|
+
* @param listener - A callback function to be called when the event is received.
|
|
313
|
+
* @returns A request-promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
314
|
+
*
|
|
315
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
316
|
+
*
|
|
317
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
318
|
+
* @example
|
|
319
|
+
* ```ts
|
|
320
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
321
|
+
*
|
|
322
|
+
* const transport = new hl.WebSocketTransport();
|
|
323
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
324
|
+
*
|
|
325
|
+
* const sub = await subsClient.openOrders({ user: "0x..." }, (data) => {
|
|
326
|
+
* console.log(data);
|
|
327
|
+
* });
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
openOrders(params, listener) {
|
|
331
|
+
const payload = {
|
|
332
|
+
type: "openOrders",
|
|
333
|
+
...params,
|
|
334
|
+
dex: params.dex ?? "",
|
|
335
|
+
};
|
|
336
|
+
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
337
|
+
if (e.detail.user === payload.user.toLowerCase() && e.detail.dex === payload.dex) {
|
|
338
|
+
listener(e.detail);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
262
342
|
/**
|
|
263
343
|
* Subscribe to order status updates for a specific user.
|
|
264
344
|
* @param params - Subscription-specific parameters.
|
|
@@ -310,7 +390,7 @@ export class SubscriptionClient {
|
|
|
310
390
|
trades(params, listener) {
|
|
311
391
|
const payload = { type: "trades", ...params };
|
|
312
392
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
313
|
-
if (e.detail[0]?.coin ===
|
|
393
|
+
if (e.detail[0]?.coin === payload.coin) {
|
|
314
394
|
listener(e.detail);
|
|
315
395
|
}
|
|
316
396
|
});
|
|
@@ -371,7 +451,7 @@ export class SubscriptionClient {
|
|
|
371
451
|
aggregateByTime: params.aggregateByTime ?? false,
|
|
372
452
|
};
|
|
373
453
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
374
|
-
if (e.detail.user ===
|
|
454
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
375
455
|
listener(e.detail);
|
|
376
456
|
}
|
|
377
457
|
});
|
|
@@ -400,7 +480,7 @@ export class SubscriptionClient {
|
|
|
400
480
|
userFundings(params, listener) {
|
|
401
481
|
const payload = { type: "userFundings", ...params };
|
|
402
482
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
403
|
-
if (e.detail.user ===
|
|
483
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
404
484
|
listener(e.detail);
|
|
405
485
|
}
|
|
406
486
|
});
|
|
@@ -432,7 +512,7 @@ export class SubscriptionClient {
|
|
|
432
512
|
...params,
|
|
433
513
|
};
|
|
434
514
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
435
|
-
if (e.detail.user ===
|
|
515
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
436
516
|
listener(e.detail);
|
|
437
517
|
}
|
|
438
518
|
});
|
|
@@ -461,7 +541,7 @@ export class SubscriptionClient {
|
|
|
461
541
|
userTwapHistory(params, listener) {
|
|
462
542
|
const payload = { type: "userTwapHistory", ...params };
|
|
463
543
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
464
|
-
if (e.detail.user ===
|
|
544
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
465
545
|
listener(e.detail);
|
|
466
546
|
}
|
|
467
547
|
});
|
|
@@ -490,7 +570,7 @@ export class SubscriptionClient {
|
|
|
490
570
|
userTwapSliceFills(params, listener) {
|
|
491
571
|
const payload = { type: "userTwapSliceFills", ...params };
|
|
492
572
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
493
|
-
if (e.detail.user ===
|
|
573
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
494
574
|
listener(e.detail);
|
|
495
575
|
}
|
|
496
576
|
});
|
|
@@ -519,7 +599,7 @@ export class SubscriptionClient {
|
|
|
519
599
|
webData2(params, listener) {
|
|
520
600
|
const payload = { type: "webData2", ...params };
|
|
521
601
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
522
|
-
if (e.detail.user ===
|
|
602
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
523
603
|
listener(e.detail);
|
|
524
604
|
}
|
|
525
605
|
});
|
package/esm/src/signing/mod.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* ```ts
|
|
7
7
|
* import { actionSorter, signL1Action } from "@nktkas/hyperliquid/signing";
|
|
8
8
|
*
|
|
9
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
9
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
10
10
|
*
|
|
11
11
|
* const action = actionSorter.cancel({
|
|
12
12
|
* type: "cancel",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* ```ts
|
|
32
32
|
* import { actionSorter, signUserSignedAction, userSignedActionEip712Types } from "@nktkas/hyperliquid/signing";
|
|
33
33
|
*
|
|
34
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
34
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
35
35
|
*
|
|
36
36
|
* const action = actionSorter.approveAgent({
|
|
37
37
|
* type: "approveAgent",
|
|
@@ -153,7 +153,7 @@ export declare function createL1ActionHash(args: {
|
|
|
153
153
|
* ```ts
|
|
154
154
|
* import { actionSorter, signL1Action } from "@nktkas/hyperliquid/signing";
|
|
155
155
|
*
|
|
156
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
156
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
157
157
|
*
|
|
158
158
|
* const action = actionSorter.cancel({
|
|
159
159
|
* type: "cancel",
|
|
@@ -194,7 +194,7 @@ export declare function signL1Action(args: {
|
|
|
194
194
|
* ```ts
|
|
195
195
|
* import { actionSorter, signUserSignedAction, userSignedActionEip712Types } from "@nktkas/hyperliquid/signing";
|
|
196
196
|
*
|
|
197
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
197
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
198
198
|
*
|
|
199
199
|
* const action = actionSorter.approveAgent({
|
|
200
200
|
* type: "approveAgent",
|
package/esm/src/signing/mod.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* ```ts
|
|
7
7
|
* import { actionSorter, signL1Action } from "@nktkas/hyperliquid/signing";
|
|
8
8
|
*
|
|
9
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
9
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
10
10
|
*
|
|
11
11
|
* const action = actionSorter.cancel({
|
|
12
12
|
* type: "cancel",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* ```ts
|
|
32
32
|
* import { actionSorter, signUserSignedAction, userSignedActionEip712Types } from "@nktkas/hyperliquid/signing";
|
|
33
33
|
*
|
|
34
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
34
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
35
35
|
*
|
|
36
36
|
* const action = actionSorter.approveAgent({
|
|
37
37
|
* type: "approveAgent",
|
|
@@ -168,7 +168,7 @@ function toUint64Bytes(n) {
|
|
|
168
168
|
* ```ts
|
|
169
169
|
* import { actionSorter, signL1Action } from "@nktkas/hyperliquid/signing";
|
|
170
170
|
*
|
|
171
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
171
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
172
172
|
*
|
|
173
173
|
* const action = actionSorter.cancel({
|
|
174
174
|
* type: "cancel",
|
|
@@ -220,7 +220,7 @@ export async function signL1Action(args) {
|
|
|
220
220
|
* ```ts
|
|
221
221
|
* import { actionSorter, signUserSignedAction, userSignedActionEip712Types } from "@nktkas/hyperliquid/signing";
|
|
222
222
|
*
|
|
223
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
223
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
224
224
|
*
|
|
225
225
|
* const action = actionSorter.approveAgent({
|
|
226
226
|
* type: "approveAgent",
|
|
@@ -103,7 +103,7 @@ export class HttpTransport {
|
|
|
103
103
|
return body;
|
|
104
104
|
}
|
|
105
105
|
catch (error) {
|
|
106
|
-
if (error instanceof
|
|
106
|
+
if (error instanceof TransportError)
|
|
107
107
|
throw error; // Re-throw known errors
|
|
108
108
|
throw new HttpRequestError(undefined, { cause: error });
|
|
109
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_websocket_async_request.d.ts","sourceRoot":"","sources":["../../../../src/src/transports/websocket/_websocket_async_request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAuB,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAkBlG;;;GAGG;AACH,qBAAa,qBAAqB;IAgBlB,SAAS,CAAC,MAAM,EAAE,qBAAqB;IAfnD,SAAS,CAAC,MAAM,EAAE,MAAM,CAAK;IAC7B,SAAS,CAAC,KAAK,EAAE;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QAEpB,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;QAE/B,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;KAClC,EAAE,CAAM;IACT,eAAe,EAAE,MAAM,CAAK;IAE5B;;;;OAIG;gBACmB,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,sBAAsB;IAqFrF;;;OAGG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAC5D,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"_websocket_async_request.d.ts","sourceRoot":"","sources":["../../../../src/src/transports/websocket/_websocket_async_request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAuB,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAkBlG;;;GAGG;AACH,qBAAa,qBAAqB;IAgBlB,SAAS,CAAC,MAAM,EAAE,qBAAqB;IAfnD,SAAS,CAAC,MAAM,EAAE,MAAM,CAAK;IAC7B,SAAS,CAAC,KAAK,EAAE;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QAEpB,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;QAE/B,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;KAClC,EAAE,CAAM;IACT,eAAe,EAAE,MAAM,CAAK;IAE5B;;;;OAIG;gBACmB,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,sBAAsB;IAqFrF;;;OAGG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAC5D,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAiDlH,6DAA6D;IAC7D,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;CAK7C"}
|
|
@@ -95,6 +95,10 @@ export class WebSocketAsyncRequest {
|
|
|
95
95
|
// Reject the request if the signal is aborted
|
|
96
96
|
if (signal?.aborted)
|
|
97
97
|
return Promise.reject(signal.reason);
|
|
98
|
+
// or if the WebSocket connection is permanently closed
|
|
99
|
+
if (this.socket.reconnectAbortController.signal.aborted) {
|
|
100
|
+
return Promise.reject(this.socket.reconnectAbortController.signal.reason);
|
|
101
|
+
}
|
|
98
102
|
// Create a request
|
|
99
103
|
let id;
|
|
100
104
|
let request;
|
|
@@ -77,7 +77,7 @@ export class WebSocketTransport {
|
|
|
77
77
|
}, combinedSignal);
|
|
78
78
|
}
|
|
79
79
|
catch (error) {
|
|
80
|
-
if (error instanceof
|
|
80
|
+
if (error instanceof TransportError)
|
|
81
81
|
throw error; // Re-throw known errors
|
|
82
82
|
throw new WebSocketRequestError(`Unknown error while making a WebSocket request: ${error}`, { cause: error });
|
|
83
83
|
}
|
|
@@ -131,7 +131,7 @@ export class WebSocketTransport {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
catch (error) {
|
|
134
|
-
if (error instanceof
|
|
134
|
+
if (error instanceof TransportError)
|
|
135
135
|
throw error; // Re-throw known errors
|
|
136
136
|
throw new WebSocketRequestError(`Unknown error while unsubscribing from a WebSocket channel: ${error}`, { cause: error });
|
|
137
137
|
}
|
|
@@ -149,7 +149,7 @@ export class WebSocketTransport {
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
catch (error) {
|
|
152
|
-
if (error instanceof
|
|
152
|
+
if (error instanceof TransportError)
|
|
153
153
|
throw error; // Re-throw known errors
|
|
154
154
|
throw new WebSocketRequestError(`Unknown error while subscribing to a WebSocket channel: ${error}`, { cause: error });
|
|
155
155
|
}
|