@nktkas/hyperliquid 0.13.0

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.
Files changed (145) hide show
  1. package/CONTRIBUTING.md +59 -0
  2. package/LICENSE +21 -0
  3. package/README.md +363 -0
  4. package/SECURITY.md +7 -0
  5. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +2 -0
  6. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +1 -0
  7. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +1 -0
  8. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +95 -0
  9. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +1 -0
  10. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +10 -0
  11. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts +23 -0
  12. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts.map +1 -0
  13. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +43 -0
  14. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts +55 -0
  15. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts.map +1 -0
  16. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.js +65 -0
  17. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts +2 -0
  18. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.js +1 -0
  20. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts +52 -0
  21. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts.map +1 -0
  22. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.js +283 -0
  23. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts +120 -0
  24. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts.map +1 -0
  25. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/utils.js +211 -0
  26. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts +19 -0
  27. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +1 -0
  28. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.js +32 -0
  29. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts +2 -0
  30. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts.map +1 -0
  31. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +26 -0
  32. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts +37 -0
  33. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +1 -0
  34. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.js +109 -0
  35. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts +37 -0
  36. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +1 -0
  37. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.js +237 -0
  38. package/esm/mod.d.ts +24 -0
  39. package/esm/mod.d.ts.map +1 -0
  40. package/esm/mod.js +9 -0
  41. package/esm/package.json +3 -0
  42. package/esm/src/clients/event.d.ts +374 -0
  43. package/esm/src/clients/event.d.ts.map +1 -0
  44. package/esm/src/clients/event.js +490 -0
  45. package/esm/src/clients/public.d.ts +695 -0
  46. package/esm/src/clients/public.d.ts.map +1 -0
  47. package/esm/src/clients/public.js +704 -0
  48. package/esm/src/clients/wallet.d.ts +682 -0
  49. package/esm/src/clients/wallet.d.ts.map +1 -0
  50. package/esm/src/clients/wallet.js +984 -0
  51. package/esm/src/transports/base.d.ts +55 -0
  52. package/esm/src/transports/base.d.ts.map +1 -0
  53. package/esm/src/transports/base.js +14 -0
  54. package/esm/src/transports/http/http_transport.d.ts +78 -0
  55. package/esm/src/transports/http/http_transport.d.ts.map +1 -0
  56. package/esm/src/transports/http/http_transport.js +170 -0
  57. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts +66 -0
  58. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -0
  59. package/esm/src/transports/websocket/hyperliquid_event_target.js +33 -0
  60. package/esm/src/transports/websocket/reconnecting_websocket.d.ts +160 -0
  61. package/esm/src/transports/websocket/reconnecting_websocket.d.ts.map +1 -0
  62. package/esm/src/transports/websocket/reconnecting_websocket.js +370 -0
  63. package/esm/src/transports/websocket/websocket_request_dispatcher.d.ts +63 -0
  64. package/esm/src/transports/websocket/websocket_request_dispatcher.d.ts.map +1 -0
  65. package/esm/src/transports/websocket/websocket_request_dispatcher.js +201 -0
  66. package/esm/src/transports/websocket/websocket_transport.d.ts +117 -0
  67. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -0
  68. package/esm/src/transports/websocket/websocket_transport.js +233 -0
  69. package/esm/src/utils/key_sort.d.ts +21 -0
  70. package/esm/src/utils/key_sort.d.ts.map +1 -0
  71. package/esm/src/utils/key_sort.js +124 -0
  72. package/esm/src/utils/signing.d.ts +109 -0
  73. package/esm/src/utils/signing.d.ts.map +1 -0
  74. package/esm/src/utils/signing.js +164 -0
  75. package/package.json +34 -0
  76. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +2 -0
  77. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +1 -0
  78. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +17 -0
  79. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +95 -0
  80. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +1 -0
  81. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +14 -0
  82. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts +23 -0
  83. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts.map +1 -0
  84. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +49 -0
  85. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts +55 -0
  86. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts.map +1 -0
  87. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.js +88 -0
  88. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts +2 -0
  89. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts.map +1 -0
  90. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.js +4 -0
  91. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts +52 -0
  92. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts.map +1 -0
  93. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.js +288 -0
  94. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts +120 -0
  95. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts.map +1 -0
  96. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.js +235 -0
  97. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts +19 -0
  98. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +1 -0
  99. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.js +35 -0
  100. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts +2 -0
  101. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts.map +1 -0
  102. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +29 -0
  103. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts +37 -0
  104. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +1 -0
  105. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.js +113 -0
  106. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts +37 -0
  107. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +1 -0
  108. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.js +240 -0
  109. package/script/mod.d.ts +24 -0
  110. package/script/mod.d.ts.map +1 -0
  111. package/script/mod.js +27 -0
  112. package/script/package.json +3 -0
  113. package/script/src/clients/event.d.ts +374 -0
  114. package/script/src/clients/event.d.ts.map +1 -0
  115. package/script/src/clients/event.js +494 -0
  116. package/script/src/clients/public.d.ts +695 -0
  117. package/script/src/clients/public.d.ts.map +1 -0
  118. package/script/src/clients/public.js +708 -0
  119. package/script/src/clients/wallet.d.ts +682 -0
  120. package/script/src/clients/wallet.d.ts.map +1 -0
  121. package/script/src/clients/wallet.js +989 -0
  122. package/script/src/transports/base.d.ts +55 -0
  123. package/script/src/transports/base.d.ts.map +1 -0
  124. package/script/src/transports/base.js +18 -0
  125. package/script/src/transports/http/http_transport.d.ts +78 -0
  126. package/script/src/transports/http/http_transport.d.ts.map +1 -0
  127. package/script/src/transports/http/http_transport.js +175 -0
  128. package/script/src/transports/websocket/hyperliquid_event_target.d.ts +66 -0
  129. package/script/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -0
  130. package/script/src/transports/websocket/hyperliquid_event_target.js +37 -0
  131. package/script/src/transports/websocket/reconnecting_websocket.d.ts +160 -0
  132. package/script/src/transports/websocket/reconnecting_websocket.d.ts.map +1 -0
  133. package/script/src/transports/websocket/reconnecting_websocket.js +374 -0
  134. package/script/src/transports/websocket/websocket_request_dispatcher.d.ts +63 -0
  135. package/script/src/transports/websocket/websocket_request_dispatcher.d.ts.map +1 -0
  136. package/script/src/transports/websocket/websocket_request_dispatcher.js +206 -0
  137. package/script/src/transports/websocket/websocket_transport.d.ts +117 -0
  138. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -0
  139. package/script/src/transports/websocket/websocket_transport.js +237 -0
  140. package/script/src/utils/key_sort.d.ts +21 -0
  141. package/script/src/utils/key_sort.d.ts.map +1 -0
  142. package/script/src/utils/key_sort.js +127 -0
  143. package/script/src/utils/signing.d.ts +109 -0
  144. package/script/src/utils/signing.d.ts.map +1 -0
  145. package/script/src/utils/signing.js +172 -0
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Interface representing a REST transport.
3
+ * Handles communication with Hyperliquid API endpoints.
4
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint | Info endpoint}
5
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint | Exchange endpoint}
6
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/post-requests | Websocket post requests}
7
+ */
8
+ export interface IRequestTransport {
9
+ /**
10
+ * Sends a request to the Hyperliquid API.
11
+ * @param endpoint - The API endpoint to send the request to.
12
+ * @param payload - The payload to send with the request.
13
+ * @param signal - An ptional abort signal.
14
+ * @returns A promise that resolves with parsed JSON response body.
15
+ */
16
+ request(endpoint: "info" | "action" | "explorer", payload: unknown, signal?: AbortSignal): Promise<unknown>;
17
+ }
18
+ /**
19
+ * Interface representing an event subscription transport.
20
+ * Handles WebSocket subscriptions for real-time updates.
21
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Websocket subscriptions}
22
+ */
23
+ export interface ISubscriptionTransport {
24
+ /**
25
+ * Subscribes to a Hyperliquid event channel.
26
+ * @param channel - The event channel to listen to.
27
+ * @param payload - The payload to send with the subscription request.
28
+ * @param listener - The function to call when the event is dispatched.
29
+ * @param signal - An optional abort signal for canceling the subscription request.
30
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
31
+ */
32
+ subscribe(channel: string, payload: unknown, listener: (data: CustomEvent) => void, signal?: AbortSignal): Promise<Subscription>;
33
+ }
34
+ /**
35
+ * Controls event subscription lifecycle.
36
+ */
37
+ export interface Subscription {
38
+ /**
39
+ * Unsubscribes from the event and sends an unsubscribe request to the server.
40
+ * @param signal - An optional abort signal for canceling the unsubscribe request.
41
+ */
42
+ unsubscribe(signal?: AbortSignal): Promise<void>;
43
+ }
44
+ /**
45
+ * Base class for all transport-related errors.
46
+ */
47
+ export declare class TransportError extends Error {
48
+ /**
49
+ * Creates a new transport error.
50
+ * @param message - The error message.
51
+ * @param options - Additional error options.
52
+ */
53
+ constructor(message?: string, options?: ErrorOptions);
54
+ }
55
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/src/transports/base.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/G;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACnC;;;;;;;OAOG;IACH,SAAS,CACL,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,EACrC,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,YAAY,CAAC,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACrC;;;;OAIG;gBACS,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIvD"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Base class for all transport-related errors.
3
+ */
4
+ export class TransportError extends Error {
5
+ /**
6
+ * Creates a new transport error.
7
+ * @param message - The error message.
8
+ * @param options - Additional error options.
9
+ */
10
+ constructor(message, options) {
11
+ super(message, options);
12
+ this.name = "TransportError";
13
+ }
14
+ }
@@ -0,0 +1,78 @@
1
+ import { type IRequestTransport, TransportError } from "../base.js";
2
+ type MaybePromise<T> = T | Promise<T>;
3
+ /**
4
+ * Error thrown when an HTTP response is deemed invalid:
5
+ * - Non-200 status code
6
+ * - Unexpected content type
7
+ */
8
+ export declare class HttpRequestError extends TransportError {
9
+ response: Response;
10
+ responseBody?: string | undefined;
11
+ /**
12
+ * Creates a new HTTP request error.
13
+ * @param response - The failed HTTP response.
14
+ * @param responseBody - The raw response body content, if available.
15
+ */
16
+ constructor(response: Response, responseBody?: string | undefined);
17
+ }
18
+ /**
19
+ * Configuration options for the HTTP transport layer.
20
+ */
21
+ export interface HttpTransportOptions {
22
+ /**
23
+ * Base URL for API endpoints.
24
+ * - Mainnet: `https://api.hyperliquid.xyz`
25
+ * - Testnet: `https://api.hyperliquid-testnet.xyz`
26
+ * @defaultValue `https://api.hyperliquid.xyz`
27
+ */
28
+ url?: string | URL;
29
+ /**
30
+ * Request timeout in ms.
31
+ * Set to `null` to disable.
32
+ * @defaultValue `10_000`
33
+ */
34
+ timeout?: number | null;
35
+ /** A custom {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/RequestInit | RequestInit} that is merged with a fetch request. */
36
+ fetchOptions?: Omit<RequestInit, "body" | "method">;
37
+ /**
38
+ * A callback function that is called before the request is sent.
39
+ * @param request - An original request to send.
40
+ * @returns If returned a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/Request/Request | Request}, it will replace the original request.
41
+ */
42
+ onRequest?: (request: Request) => MaybePromise<Request | void | null | undefined>;
43
+ /**
44
+ * A callback function that is called after the response is received.
45
+ * @param response - An original response to process.
46
+ * @returns If returned a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/Response/Response | Response}, it will replace the original response.
47
+ */
48
+ onResponse?: (response: Response) => MaybePromise<Response | void | null | undefined>;
49
+ }
50
+ /**
51
+ * HTTP implementation of the REST transport interface.
52
+ */
53
+ export declare class HttpTransport implements IRequestTransport, HttpTransportOptions {
54
+ url: string | URL;
55
+ timeout: number | null;
56
+ fetchOptions: Omit<RequestInit, "body" | "method">;
57
+ onRequest?: (request: Request) => MaybePromise<Request | void | null | undefined>;
58
+ onResponse?: (response: Response) => MaybePromise<Response | void | null | undefined>;
59
+ /** Mapping of endpoint types to their API paths. */
60
+ protected _endpointPaths: Record<"info" | "action" | "explorer", string>;
61
+ /**
62
+ * Creates a new HTTP transport instance.
63
+ * @param options - Configuration options for the HTTP transport layer.
64
+ */
65
+ constructor(options?: HttpTransportOptions);
66
+ /**
67
+ * Sends a request to the Hyperliquid API via fetch.
68
+ * @param endpoint - The API endpoint to send the request to.
69
+ * @param payload - The payload to send with the request.
70
+ * @param signal - An optional abort signal.
71
+ * @returns A promise that resolves with parsed JSON response body.
72
+ * @throws {HttpRequestError} - Thrown when an HTTP response is deemed invalid.
73
+ * @throws May throw {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch#exceptions | fetch errors}.
74
+ */
75
+ request(endpoint: "info" | "action" | "explorer", payload: unknown, signal?: AbortSignal): Promise<unknown>;
76
+ }
77
+ export {};
78
+ //# sourceMappingURL=http_transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http_transport.d.ts","sourceRoot":"","sources":["../../../../src/src/transports/http/http_transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEpE,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,cAAc;IAM7B,QAAQ,EAAE,QAAQ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IAEF;;;OAGG;gBACS,OAAO,CAAC,EAAE,oBAAoB;IAQ1C;;;;;;;;OAQG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;CA6CpH"}
@@ -0,0 +1,170 @@
1
+ import { TransportError } from "../base.js";
2
+ /**
3
+ * Error thrown when an HTTP response is deemed invalid:
4
+ * - Non-200 status code
5
+ * - Unexpected content type
6
+ */
7
+ export class HttpRequestError extends TransportError {
8
+ /**
9
+ * Creates a new HTTP request error.
10
+ * @param response - The failed HTTP response.
11
+ * @param responseBody - The raw response body content, if available.
12
+ */
13
+ constructor(response, responseBody) {
14
+ super(`HTTP request failed. Status: ${response.status}. Body: ${responseBody}`);
15
+ Object.defineProperty(this, "response", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: response
20
+ });
21
+ Object.defineProperty(this, "responseBody", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: responseBody
26
+ });
27
+ this.name = "HttpRequestError";
28
+ }
29
+ }
30
+ /**
31
+ * HTTP implementation of the REST transport interface.
32
+ */
33
+ export class HttpTransport {
34
+ /**
35
+ * Creates a new HTTP transport instance.
36
+ * @param options - Configuration options for the HTTP transport layer.
37
+ */
38
+ constructor(options) {
39
+ Object.defineProperty(this, "url", {
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true,
43
+ value: void 0
44
+ });
45
+ Object.defineProperty(this, "timeout", {
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true,
49
+ value: void 0
50
+ });
51
+ Object.defineProperty(this, "fetchOptions", {
52
+ enumerable: true,
53
+ configurable: true,
54
+ writable: true,
55
+ value: void 0
56
+ });
57
+ Object.defineProperty(this, "onRequest", {
58
+ enumerable: true,
59
+ configurable: true,
60
+ writable: true,
61
+ value: void 0
62
+ });
63
+ Object.defineProperty(this, "onResponse", {
64
+ enumerable: true,
65
+ configurable: true,
66
+ writable: true,
67
+ value: void 0
68
+ });
69
+ /** Mapping of endpoint types to their API paths. */
70
+ Object.defineProperty(this, "_endpointPaths", {
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true,
74
+ value: {
75
+ info: "/info",
76
+ action: "/exchange",
77
+ explorer: "/explorer",
78
+ }
79
+ });
80
+ this.url = options?.url ?? "https://api.hyperliquid.xyz";
81
+ this.timeout = options?.timeout === undefined ? 10_000 : options.timeout;
82
+ this.fetchOptions = options?.fetchOptions ?? {};
83
+ this.onRequest = options?.onRequest;
84
+ this.onResponse = options?.onResponse;
85
+ }
86
+ /**
87
+ * Sends a request to the Hyperliquid API via fetch.
88
+ * @param endpoint - The API endpoint to send the request to.
89
+ * @param payload - The payload to send with the request.
90
+ * @param signal - An optional abort signal.
91
+ * @returns A promise that resolves with parsed JSON response body.
92
+ * @throws {HttpRequestError} - Thrown when an HTTP response is deemed invalid.
93
+ * @throws May throw {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch#exceptions | fetch errors}.
94
+ */
95
+ async request(endpoint, payload, signal) {
96
+ // Construct a Request
97
+ const url = new URL(this._endpointPaths[endpoint], this.url);
98
+ const init = mergeRequestInit({
99
+ body: JSON.stringify(payload),
100
+ headers: {
101
+ "Accept-Encoding": "gzip, deflate, br, zstd",
102
+ "Connection": "keep-alive",
103
+ "Content-Type": "application/json",
104
+ },
105
+ keepalive: true,
106
+ method: "POST",
107
+ signal: this.timeout ? AbortSignal.timeout(this.timeout) : undefined,
108
+ }, this.fetchOptions, { signal });
109
+ let request = new Request(url, init);
110
+ // Call the onRequest callback, if provided
111
+ if (this.onRequest) {
112
+ const customRequest = await this.onRequest(request);
113
+ if (customRequest instanceof Request)
114
+ request = customRequest;
115
+ }
116
+ // Send the Request and wait for a Response
117
+ let response = await fetch(request);
118
+ // Call the onResponse callback, if provided
119
+ if (this.onResponse) {
120
+ const customResponse = await this.onResponse(response);
121
+ if (customResponse instanceof Response)
122
+ response = customResponse;
123
+ }
124
+ // Validate the Response
125
+ if (!response.ok || !response.headers.get("Content-Type")?.includes("application/json")) {
126
+ // Unload the response body to prevent memory leaks
127
+ const body = await response.text().catch(() => undefined);
128
+ throw new HttpRequestError(response, body);
129
+ }
130
+ // Parse and return the response body
131
+ return await response.json();
132
+ }
133
+ }
134
+ /**
135
+ * Merges multiple `HeadersInit` objects into one.
136
+ * @param inits - A list of `HeadersInit` objects to merge.
137
+ * @returns A new `Headers` object that contains all headers from the input objects.
138
+ */
139
+ function mergeHeadersInit(...inits) {
140
+ if (inits.length === 0 || inits.length === 1) {
141
+ return new Headers(inits[0]);
142
+ }
143
+ const merged = new Headers();
144
+ for (const headers of inits) {
145
+ const entries = Symbol.iterator in headers ? headers : Object.entries(headers);
146
+ for (const [key, value] of entries) {
147
+ merged.set(key, value);
148
+ }
149
+ }
150
+ return merged;
151
+ }
152
+ /**
153
+ * Merges multiple `RequestInit` objects into one.
154
+ * @param inits - A list of `RequestInit` objects to merge.
155
+ * @returns A new `RequestInit` object that contains all properties from the input objects.
156
+ */
157
+ function mergeRequestInit(...inits) {
158
+ const merged = inits.reduce((acc, init) => ({ ...acc, ...init }), {});
159
+ const headersList = inits.map((init) => init.headers)
160
+ .filter((headers) => typeof headers === "object");
161
+ if (headersList.length > 0) {
162
+ merged.headers = mergeHeadersInit(...headersList);
163
+ }
164
+ const signals = inits.map((init) => init.signal)
165
+ .filter((signal) => signal instanceof AbortSignal);
166
+ if (signals.length > 0) {
167
+ merged.signal = signals.length > 1 ? AbortSignal.any(signals) : signals[0];
168
+ }
169
+ return merged;
170
+ }
@@ -0,0 +1,66 @@
1
+ import { TypedEventTarget } from "../../../deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js";
2
+ /**
3
+ * Base system events and dynamic channel events for Hyperliquid WebSocket API.
4
+ */
5
+ export interface HyperliquidEventMap {
6
+ /** Subscription created/removed event */
7
+ subscriptionResponse: CustomEvent<{
8
+ /** Type of subscription operation */
9
+ method: "subscribe" | "unsubscribe";
10
+ /** Original subscription request */
11
+ subscription: unknown;
12
+ }>;
13
+ /** Response to post request event */
14
+ post: CustomEvent<{
15
+ /** Unique request identifier */
16
+ id: number;
17
+ /** Server response */
18
+ response:
19
+ /** Response containing requested information */
20
+ {
21
+ /** Indicates that this is an informational response */
22
+ type: "info";
23
+ /** Contains the information data */
24
+ payload: {
25
+ /** Type of information being returned */
26
+ type: string;
27
+ /** Information specific data */
28
+ data: unknown;
29
+ };
30
+ }
31
+ /** Response containing action result */
32
+ | {
33
+ /** Indicates that this is an action response */
34
+ type: "action";
35
+ /** Contains the action result data */
36
+ payload: {
37
+ /** Response status indicating success or failure of the action */
38
+ status: "ok" | "err";
39
+ /** Success data or error message */
40
+ response: {
41
+ /** Type of operation */
42
+ type: string;
43
+ /** Specific data for the operation */
44
+ data?: unknown;
45
+ } | string;
46
+ };
47
+ };
48
+ }>;
49
+ /** Error response for message event */
50
+ error: CustomEvent<string>;
51
+ /** Pong response event */
52
+ pong: CustomEvent<undefined>;
53
+ /** Subscribed channel events */
54
+ [key: string]: CustomEvent<unknown>;
55
+ }
56
+ /**
57
+ * A class that listens to WebSocket messages and dispatches them as Hyperliquid typed events.
58
+ */
59
+ export declare class HyperliquidEventTarget extends TypedEventTarget<HyperliquidEventMap> {
60
+ /**
61
+ * Creates a new Hyperliquid event target.
62
+ * @param socket - The WebSocket to listen to.
63
+ */
64
+ constructor(socket: WebSocket);
65
+ }
66
+ //# sourceMappingURL=hyperliquid_event_target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperliquid_event_target.d.ts","sourceRoot":"","sources":["../../../../src/src/transports/websocket/hyperliquid_event_target.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oEAAoE,CAAC;AAYtG;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,yCAAyC;IACzC,oBAAoB,EAAE,WAAW,CAAC;QAC9B,qCAAqC;QACrC,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;QACpC,oCAAoC;QACpC,YAAY,EAAE,OAAO,CAAC;KACzB,CAAC,CAAC;IAEH,qCAAqC;IACrC,IAAI,EAAE,WAAW,CAAC;QACd,gCAAgC;QAChC,EAAE,EAAE,MAAM,CAAC;QACX,sBAAsB;QACtB,QAAQ;QACJ,gDAAgD;QAC9C;YACE,uDAAuD;YACvD,IAAI,EAAE,MAAM,CAAC;YACb,oCAAoC;YACpC,OAAO,EAAE;gBACL,yCAAyC;gBACzC,IAAI,EAAE,MAAM,CAAC;gBACb,gCAAgC;gBAChC,IAAI,EAAE,OAAO,CAAC;aACjB,CAAC;SACL;QACD,wCAAwC;WACtC;YACE,gDAAgD;YAChD,IAAI,EAAE,QAAQ,CAAC;YACf,sCAAsC;YACtC,OAAO,EAAE;gBACL,kEAAkE;gBAClE,MAAM,EAAE,IAAI,GAAG,KAAK,CAAC;gBACrB,oCAAoC;gBACpC,QAAQ,EACF;oBACE,wBAAwB;oBACxB,IAAI,EAAE,MAAM,CAAC;oBACb,sCAAsC;oBACtC,IAAI,CAAC,EAAE,OAAO,CAAC;iBAClB,GACC,MAAM,CAAC;aAChB,CAAC;SACL,CAAC;KACT,CAAC,CAAC;IAEH,uCAAuC;IACvC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAE3B,0BAA0B;IAC1B,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAE7B,gCAAgC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;CACvC;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,gBAAgB,CAAC,mBAAmB,CAAC;IAC7E;;;OAGG;gBACS,MAAM,EAAE,SAAS;CAahC"}
@@ -0,0 +1,33 @@
1
+ import { TypedEventTarget } from "../../../deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js";
2
+ /**
3
+ * A class that listens to WebSocket messages and dispatches them as Hyperliquid typed events.
4
+ */
5
+ export class HyperliquidEventTarget extends TypedEventTarget {
6
+ /**
7
+ * Creates a new Hyperliquid event target.
8
+ * @param socket - The WebSocket to listen to.
9
+ */
10
+ constructor(socket) {
11
+ super();
12
+ socket.addEventListener("message", (event) => {
13
+ try {
14
+ const msg = JSON.parse(event.data);
15
+ if (isHyperliquidMsg(msg)) {
16
+ this.dispatchEvent(new CustomEvent(msg.channel, { detail: msg.data }));
17
+ }
18
+ }
19
+ catch {
20
+ // Ignore JSON parsing errors
21
+ }
22
+ });
23
+ }
24
+ }
25
+ /**
26
+ * Type guard for Hyperliquid messages.
27
+ * @param value - The value to check.
28
+ * @returns True if the value is a Hyperliquid message.
29
+ */
30
+ function isHyperliquidMsg(value) {
31
+ return typeof value === "object" && value !== null &&
32
+ "channel" in value && typeof value.channel === "string";
33
+ }
@@ -0,0 +1,160 @@
1
+ type MaybePromise<T> = T | Promise<T>;
2
+ /**
3
+ * Configuration options for the `ReconnectingWebSocket`.
4
+ */
5
+ export interface ReconnectingWebSocketOptions {
6
+ /**
7
+ * Maximum number of reconnection attempts.
8
+ * @defaultValue `3`
9
+ */
10
+ maxRetries?: number;
11
+ /**
12
+ * Maximum time in ms to wait for a connection to open.
13
+ * Set to `null` to disable.
14
+ * @defaultValue `10_000`
15
+ */
16
+ connectionTimeout?: number | null;
17
+ /**
18
+ * Delay between reconnection attempts in ms.
19
+ * May be a number or a function that returns a number.
20
+ * @param attempt - The current attempt number.
21
+ * @defaultValue `(attempt) => Math.min(~~(1 << attempt) * 150, 10_000)` - Exponential backoff (max 10s)
22
+ */
23
+ connectionDelay?: number | ((attempt: number) => MaybePromise<number>);
24
+ /**
25
+ * Custom logic to determine if reconnection is required.
26
+ * @param event - The close event that occurred during the connection.
27
+ * @returns A boolean indicating if reconnection should be attempted.
28
+ * @defaultValue `() => true` - Always reconnect
29
+ */
30
+ shouldReconnect?: (event: CloseEvent) => MaybePromise<boolean>;
31
+ /**
32
+ * Message buffering strategy between reconnection attempts.
33
+ * @defaultValue `new FIFOMessageBuffer()`
34
+ */
35
+ messageBuffer?: MessageBufferStrategy;
36
+ /**
37
+ * Custom WebSocket constructor to use.
38
+ * @defaultValue `new WebSocket(url, protocols)`
39
+ */
40
+ WebSocketConstructor?: typeof WebSocket;
41
+ }
42
+ /**
43
+ * Message buffer strategy interface.
44
+ */
45
+ export interface MessageBufferStrategy {
46
+ /** Array of buffered messages. */
47
+ messages: (string | ArrayBufferLike | Blob | ArrayBufferView)[];
48
+ /**
49
+ * Add a message to the buffer.
50
+ * @param data - The message to buffer.
51
+ */
52
+ push(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
53
+ /**
54
+ * Get and remove the next message from the buffer.
55
+ * @returns The next message or `undefined` if no more messages are available.
56
+ */
57
+ shift(): (string | ArrayBufferLike | Blob | ArrayBufferView) | undefined;
58
+ /** Clear all buffered messages. */
59
+ clear(): void;
60
+ }
61
+ /**
62
+ * A WebSocket that automatically reconnects when disconnected.
63
+ * Fully compatible with standard WebSocket API.
64
+ */
65
+ export declare class ReconnectingWebSocket implements WebSocket {
66
+ /** Controller for handling connection termination */
67
+ protected terminationController: AbortController;
68
+ /** WebSocket protocols */
69
+ protected protocols?: string | string[];
70
+ /** The underlying WebSocket instance */
71
+ protected socket: WebSocket;
72
+ /** Current number of reconnection attempts */
73
+ protected reconnectCount: number;
74
+ /** Array of registered event listeners */
75
+ protected eventListeners: {
76
+ type: string;
77
+ listener: EventListenerOrEventListenerObject;
78
+ options?: boolean | AddEventListenerOptions;
79
+ listenerProxy: EventListenerOrEventListenerObject;
80
+ }[];
81
+ /** Configuration options */
82
+ reconnectOptions: Required<ReconnectingWebSocketOptions>;
83
+ /** An AbortSignal that is triggered when the connection is permanently closed */
84
+ readonly terminationSignal: AbortSignal;
85
+ /**
86
+ * Creates a new reconnecting WebSocket.
87
+ * @param url - The WebSocket URL to connect to.
88
+ * @param protocols - The WebSocket protocols to use.
89
+ * @param options - The configuration options.
90
+ */
91
+ constructor(url: string | URL, protocols?: string | string[], options?: ReconnectingWebSocketOptions);
92
+ /**
93
+ * Creates a WebSocket connection with timeout.
94
+ * @param url - The WebSocket URL to connect to.
95
+ * @param protocols - The WebSocket protocols to use.
96
+ * @param timeout - The connection timeout in ms.
97
+ * @returns A new WebSocket instance.
98
+ */
99
+ protected connectWithTimeout(url: string | URL, protocols: string | string[] | undefined, timeout: number): WebSocket;
100
+ /**
101
+ * Initializes the internal event listeners for the WebSocket.
102
+ */
103
+ protected initEventListeners(): void;
104
+ /**
105
+ * Clean up internal resources.
106
+ * @param reason - The reason for cleanup.
107
+ */
108
+ protected cleanup(reason: unknown): void;
109
+ /**
110
+ * Check if two event listeners are the same (just like EventTarget).
111
+ * @param a - First event listener configuration.
112
+ * @param b - Second event listener configuration.
113
+ * @returns True if the listeners match.
114
+ */
115
+ protected isListenerMatch(a: {
116
+ type: string;
117
+ listener: EventListenerOrEventListenerObject;
118
+ options?: boolean | AddEventListenerOptions;
119
+ }, b: {
120
+ type: string;
121
+ listener: EventListenerOrEventListenerObject;
122
+ options?: boolean | AddEventListenerOptions;
123
+ }): boolean;
124
+ get url(): string;
125
+ get readyState(): number;
126
+ get bufferedAmount(): number;
127
+ get extensions(): string;
128
+ get protocol(): string;
129
+ get binaryType(): BinaryType;
130
+ set binaryType(value: BinaryType);
131
+ readonly CLOSED: 3;
132
+ readonly CLOSING: 2;
133
+ readonly CONNECTING: 0;
134
+ readonly OPEN: 1;
135
+ static readonly CLOSED: 3;
136
+ static readonly CLOSING: 2;
137
+ static readonly CONNECTING: 0;
138
+ static readonly OPEN: 1;
139
+ get onclose(): ((this: WebSocket, ev: CloseEvent) => any) | null;
140
+ set onclose(value: ((this: WebSocket, ev: CloseEvent) => any) | null);
141
+ get onerror(): ((this: WebSocket, ev: Event) => any) | null;
142
+ set onerror(value: ((this: WebSocket, ev: Event) => any) | null);
143
+ get onmessage(): ((this: WebSocket, ev: MessageEvent<any>) => any) | null;
144
+ set onmessage(value: ((this: WebSocket, ev: MessageEvent<any>) => any) | null);
145
+ get onopen(): ((this: WebSocket, ev: Event) => any) | null;
146
+ set onopen(value: ((this: WebSocket, ev: Event) => any) | null);
147
+ /**
148
+ * @param permanently - If true, the connection will be permanently closed. Default is true.
149
+ */
150
+ close(code?: number, reason?: string, permanently?: boolean): void;
151
+ /**
152
+ * @note If the connection is not open, the data will be buffered and sent when the connection is established.
153
+ */
154
+ send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
155
+ addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: ReconnectingWebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
156
+ removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: ReconnectingWebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
157
+ dispatchEvent(event: Event): boolean;
158
+ }
159
+ export {};
160
+ //# sourceMappingURL=reconnecting_websocket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconnecting_websocket.d.ts","sourceRoot":"","sources":["../../../../src/src/transports/websocket/reconnecting_websocket.ts"],"names":[],"mappings":"AAEA,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,4BAA4B;IACzC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAElC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvE;;;;;OAKG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,YAAY,CAAC,OAAO,CAAC,CAAC;IAE/D;;;OAGG;IACH,aAAa,CAAC,EAAE,qBAAqB,CAAC;IAEtC;;;OAGG;IACH,oBA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