@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"}
|
|
@@ -47,7 +47,7 @@ class SubscriptionClient {
|
|
|
47
47
|
const channel = params.coin.startsWith("@") ? "activeSpotAssetCtx" : "activeAssetCtx";
|
|
48
48
|
const payload = { type: "activeAssetCtx", ...params };
|
|
49
49
|
return this.transport.subscribe(channel, payload, (e) => {
|
|
50
|
-
if (e.detail.coin ===
|
|
50
|
+
if (e.detail.coin === payload.coin) {
|
|
51
51
|
listener(e.detail);
|
|
52
52
|
}
|
|
53
53
|
});
|
|
@@ -76,7 +76,7 @@ class SubscriptionClient {
|
|
|
76
76
|
activeAssetData(params, listener) {
|
|
77
77
|
const payload = { type: "activeAssetData", ...params };
|
|
78
78
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
79
|
-
if (e.detail.coin ===
|
|
79
|
+
if (e.detail.coin === payload.coin && e.detail.user === payload.user.toLowerCase()) {
|
|
80
80
|
listener(e.detail);
|
|
81
81
|
}
|
|
82
82
|
});
|
|
@@ -89,6 +89,20 @@ class SubscriptionClient {
|
|
|
89
89
|
listener(e.detail);
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
+
assetCtxs(params_or_listener, maybeListener) {
|
|
93
|
+
const params = typeof params_or_listener === "function" ? {} : params_or_listener;
|
|
94
|
+
const listener = typeof params_or_listener === "function" ? params_or_listener : maybeListener;
|
|
95
|
+
const payload = {
|
|
96
|
+
type: "assetCtxs",
|
|
97
|
+
...params,
|
|
98
|
+
dex: params.dex ?? "",
|
|
99
|
+
};
|
|
100
|
+
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
101
|
+
if (e.detail.dex === payload.dex) {
|
|
102
|
+
listener(e.detail);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
92
106
|
/**
|
|
93
107
|
* Subscribe to best bid and offer updates for a specific asset.
|
|
94
108
|
* @param params - Subscription-specific parameters.
|
|
@@ -113,7 +127,7 @@ class SubscriptionClient {
|
|
|
113
127
|
bbo(params, listener) {
|
|
114
128
|
const payload = { type: "bbo", ...params };
|
|
115
129
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
116
|
-
if (e.detail.coin ===
|
|
130
|
+
if (e.detail.coin === payload.coin) {
|
|
117
131
|
listener(e.detail);
|
|
118
132
|
}
|
|
119
133
|
});
|
|
@@ -142,7 +156,40 @@ class SubscriptionClient {
|
|
|
142
156
|
candle(params, listener) {
|
|
143
157
|
const payload = { type: "candle", ...params };
|
|
144
158
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
145
|
-
if (e.detail.s ===
|
|
159
|
+
if (e.detail.s === payload.coin && e.detail.i === payload.interval) {
|
|
160
|
+
listener(e.detail);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Subscribe to clearinghouse state updates for a specific user.
|
|
166
|
+
* @param params - Subscription-specific parameters.
|
|
167
|
+
* @param listener - A callback function to be called when the event is received.
|
|
168
|
+
* @returns A request-promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
169
|
+
*
|
|
170
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
171
|
+
*
|
|
172
|
+
* @see null
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
176
|
+
*
|
|
177
|
+
* const transport = new hl.WebSocketTransport();
|
|
178
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
179
|
+
*
|
|
180
|
+
* const sub = await subsClient.clearinghouseState({ user: "0x..." }, (data) => {
|
|
181
|
+
* console.log(data);
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
clearinghouseState(params, listener) {
|
|
186
|
+
const payload = {
|
|
187
|
+
type: "clearinghouseState",
|
|
188
|
+
...params,
|
|
189
|
+
dex: params.dex ?? "",
|
|
190
|
+
};
|
|
191
|
+
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
192
|
+
if (e.detail.user === payload.user.toLowerCase() && e.detail.dex === payload.dex) {
|
|
146
193
|
listener(e.detail);
|
|
147
194
|
}
|
|
148
195
|
});
|
|
@@ -230,7 +277,7 @@ class SubscriptionClient {
|
|
|
230
277
|
mantissa: params.mantissa ?? null,
|
|
231
278
|
};
|
|
232
279
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
233
|
-
if (e.detail.coin ===
|
|
280
|
+
if (e.detail.coin === payload.coin) {
|
|
234
281
|
listener(e.detail);
|
|
235
282
|
}
|
|
236
283
|
});
|
|
@@ -262,6 +309,39 @@ class SubscriptionClient {
|
|
|
262
309
|
listener(e.detail);
|
|
263
310
|
});
|
|
264
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Subscribe to open orders updates for a specific user.
|
|
314
|
+
* @param params - Subscription-specific parameters.
|
|
315
|
+
* @param listener - A callback function to be called when the event is received.
|
|
316
|
+
* @returns A request-promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
317
|
+
*
|
|
318
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
319
|
+
*
|
|
320
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
321
|
+
* @example
|
|
322
|
+
* ```ts
|
|
323
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
324
|
+
*
|
|
325
|
+
* const transport = new hl.WebSocketTransport();
|
|
326
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
327
|
+
*
|
|
328
|
+
* const sub = await subsClient.openOrders({ user: "0x..." }, (data) => {
|
|
329
|
+
* console.log(data);
|
|
330
|
+
* });
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
openOrders(params, listener) {
|
|
334
|
+
const payload = {
|
|
335
|
+
type: "openOrders",
|
|
336
|
+
...params,
|
|
337
|
+
dex: params.dex ?? "",
|
|
338
|
+
};
|
|
339
|
+
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
340
|
+
if (e.detail.user === payload.user.toLowerCase() && e.detail.dex === payload.dex) {
|
|
341
|
+
listener(e.detail);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
265
345
|
/**
|
|
266
346
|
* Subscribe to order status updates for a specific user.
|
|
267
347
|
* @param params - Subscription-specific parameters.
|
|
@@ -313,7 +393,7 @@ class SubscriptionClient {
|
|
|
313
393
|
trades(params, listener) {
|
|
314
394
|
const payload = { type: "trades", ...params };
|
|
315
395
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
316
|
-
if (e.detail[0]?.coin ===
|
|
396
|
+
if (e.detail[0]?.coin === payload.coin) {
|
|
317
397
|
listener(e.detail);
|
|
318
398
|
}
|
|
319
399
|
});
|
|
@@ -374,7 +454,7 @@ class SubscriptionClient {
|
|
|
374
454
|
aggregateByTime: params.aggregateByTime ?? false,
|
|
375
455
|
};
|
|
376
456
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
377
|
-
if (e.detail.user ===
|
|
457
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
378
458
|
listener(e.detail);
|
|
379
459
|
}
|
|
380
460
|
});
|
|
@@ -403,7 +483,7 @@ class SubscriptionClient {
|
|
|
403
483
|
userFundings(params, listener) {
|
|
404
484
|
const payload = { type: "userFundings", ...params };
|
|
405
485
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
406
|
-
if (e.detail.user ===
|
|
486
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
407
487
|
listener(e.detail);
|
|
408
488
|
}
|
|
409
489
|
});
|
|
@@ -435,7 +515,7 @@ class SubscriptionClient {
|
|
|
435
515
|
...params,
|
|
436
516
|
};
|
|
437
517
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
438
|
-
if (e.detail.user ===
|
|
518
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
439
519
|
listener(e.detail);
|
|
440
520
|
}
|
|
441
521
|
});
|
|
@@ -464,7 +544,7 @@ class SubscriptionClient {
|
|
|
464
544
|
userTwapHistory(params, listener) {
|
|
465
545
|
const payload = { type: "userTwapHistory", ...params };
|
|
466
546
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
467
|
-
if (e.detail.user ===
|
|
547
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
468
548
|
listener(e.detail);
|
|
469
549
|
}
|
|
470
550
|
});
|
|
@@ -493,7 +573,7 @@ class SubscriptionClient {
|
|
|
493
573
|
userTwapSliceFills(params, listener) {
|
|
494
574
|
const payload = { type: "userTwapSliceFills", ...params };
|
|
495
575
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
496
|
-
if (e.detail.user ===
|
|
576
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
497
577
|
listener(e.detail);
|
|
498
578
|
}
|
|
499
579
|
});
|
|
@@ -522,7 +602,7 @@ class SubscriptionClient {
|
|
|
522
602
|
webData2(params, listener) {
|
|
523
603
|
const payload = { type: "webData2", ...params };
|
|
524
604
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
525
|
-
if (e.detail.user ===
|
|
605
|
+
if (e.detail.user === payload.user.toLowerCase()) {
|
|
526
606
|
listener(e.detail);
|
|
527
607
|
}
|
|
528
608
|
});
|
|
@@ -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",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* ```ts
|
|
8
8
|
* import { actionSorter, signL1Action } from "@nktkas/hyperliquid/signing";
|
|
9
9
|
*
|
|
10
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
10
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
11
11
|
*
|
|
12
12
|
* const action = actionSorter.cancel({
|
|
13
13
|
* type: "cancel",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* ```ts
|
|
33
33
|
* import { actionSorter, signUserSignedAction, userSignedActionEip712Types } from "@nktkas/hyperliquid/signing";
|
|
34
34
|
*
|
|
35
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
35
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
36
36
|
*
|
|
37
37
|
* const action = actionSorter.approveAgent({
|
|
38
38
|
* type: "approveAgent",
|
|
@@ -178,7 +178,7 @@ function toUint64Bytes(n) {
|
|
|
178
178
|
* ```ts
|
|
179
179
|
* import { actionSorter, signL1Action } from "@nktkas/hyperliquid/signing";
|
|
180
180
|
*
|
|
181
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
181
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
182
182
|
*
|
|
183
183
|
* const action = actionSorter.cancel({
|
|
184
184
|
* type: "cancel",
|
|
@@ -230,7 +230,7 @@ async function signL1Action(args) {
|
|
|
230
230
|
* ```ts
|
|
231
231
|
* import { actionSorter, signUserSignedAction, userSignedActionEip712Types } from "@nktkas/hyperliquid/signing";
|
|
232
232
|
*
|
|
233
|
-
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
233
|
+
* const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
234
234
|
*
|
|
235
235
|
* const action = actionSorter.approveAgent({
|
|
236
236
|
* type: "approveAgent",
|
|
@@ -107,7 +107,7 @@ class HttpTransport {
|
|
|
107
107
|
return body;
|
|
108
108
|
}
|
|
109
109
|
catch (error) {
|
|
110
|
-
if (error instanceof
|
|
110
|
+
if (error instanceof base_js_1.TransportError)
|
|
111
111
|
throw error; // Re-throw known errors
|
|
112
112
|
throw new HttpRequestError(undefined, { cause: error });
|
|
113
113
|
}
|
|
@@ -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"}
|
|
@@ -98,6 +98,10 @@ class WebSocketAsyncRequest {
|
|
|
98
98
|
// Reject the request if the signal is aborted
|
|
99
99
|
if (signal?.aborted)
|
|
100
100
|
return Promise.reject(signal.reason);
|
|
101
|
+
// or if the WebSocket connection is permanently closed
|
|
102
|
+
if (this.socket.reconnectAbortController.signal.aborted) {
|
|
103
|
+
return Promise.reject(this.socket.reconnectAbortController.signal.reason);
|
|
104
|
+
}
|
|
101
105
|
// Create a request
|
|
102
106
|
let id;
|
|
103
107
|
let request;
|
|
@@ -81,7 +81,7 @@ class WebSocketTransport {
|
|
|
81
81
|
}, combinedSignal);
|
|
82
82
|
}
|
|
83
83
|
catch (error) {
|
|
84
|
-
if (error instanceof
|
|
84
|
+
if (error instanceof base_js_1.TransportError)
|
|
85
85
|
throw error; // Re-throw known errors
|
|
86
86
|
throw new WebSocketRequestError(`Unknown error while making a WebSocket request: ${error}`, { cause: error });
|
|
87
87
|
}
|
|
@@ -135,7 +135,7 @@ class WebSocketTransport {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
catch (error) {
|
|
138
|
-
if (error instanceof
|
|
138
|
+
if (error instanceof base_js_1.TransportError)
|
|
139
139
|
throw error; // Re-throw known errors
|
|
140
140
|
throw new WebSocketRequestError(`Unknown error while unsubscribing from a WebSocket channel: ${error}`, { cause: error });
|
|
141
141
|
}
|
|
@@ -153,7 +153,7 @@ class WebSocketTransport {
|
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
catch (error) {
|
|
156
|
-
if (error instanceof
|
|
156
|
+
if (error instanceof base_js_1.TransportError)
|
|
157
157
|
throw error; // Re-throw known errors
|
|
158
158
|
throw new WebSocketRequestError(`Unknown error while subscribing to a WebSocket channel: ${error}`, { cause: error });
|
|
159
159
|
}
|