@nktkas/hyperliquid 0.13.1 → 0.13.2

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 (183) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +33 -17
  3. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
  4. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
  5. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.js +2 -0
  6. package/esm/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.d.ts +3 -1
  7. package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
  8. package/esm/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.js +1 -1
  9. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts +9 -0
  10. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.js +2 -0
  12. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts.map +1 -1
  13. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.js +1 -1
  14. package/{script/deps/jsr.io/@std/encoding/1.0.6 → esm/deps/jsr.io/@std/encoding/1.0.7}/hex.d.ts +3 -1
  15. package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
  16. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/hex.js +1 -1
  17. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +9 -0
  18. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.js +2 -0
  20. package/esm/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.d.ts +3 -1
  21. package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +1 -0
  22. package/esm/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.js +2 -2
  23. package/esm/mod.d.ts +1 -0
  24. package/esm/mod.d.ts.map +1 -1
  25. package/esm/src/clients/event.d.ts +57 -16
  26. package/esm/src/clients/event.d.ts.map +1 -1
  27. package/esm/src/clients/event.js +72 -16
  28. package/esm/src/clients/public.d.ts +241 -49
  29. package/esm/src/clients/public.d.ts.map +1 -1
  30. package/esm/src/clients/public.js +243 -47
  31. package/esm/src/clients/wallet.d.ts +120 -51
  32. package/esm/src/clients/wallet.d.ts.map +1 -1
  33. package/esm/src/clients/wallet.js +192 -58
  34. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts +27 -21
  35. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -1
  36. package/esm/src/transports/websocket/hyperliquid_event_target.js +37 -0
  37. package/esm/src/transports/websocket/websocket_request_dispatcher.js +3 -3
  38. package/esm/src/transports/websocket/websocket_transport.d.ts +7 -10
  39. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  40. package/esm/src/transports/websocket/websocket_transport.js +41 -35
  41. package/esm/src/types/exchange/common.d.ts +6 -6
  42. package/esm/src/types/exchange/common.d.ts.map +1 -1
  43. package/esm/src/types/exchange/requests.d.ts +131 -64
  44. package/esm/src/types/exchange/requests.d.ts.map +1 -1
  45. package/esm/src/types/exchange/responses.d.ts +7 -7
  46. package/esm/src/types/exchange/responses.d.ts.map +1 -1
  47. package/esm/src/types/explorer/common.d.ts +15 -15
  48. package/esm/src/types/explorer/common.d.ts.map +1 -1
  49. package/esm/src/types/explorer/requests.d.ts +19 -6
  50. package/esm/src/types/explorer/requests.d.ts.map +1 -1
  51. package/esm/src/types/explorer/responses.d.ts +9 -2
  52. package/esm/src/types/explorer/responses.d.ts.map +1 -1
  53. package/esm/src/types/info/accounts.d.ts +189 -124
  54. package/esm/src/types/info/accounts.d.ts.map +1 -1
  55. package/esm/src/types/info/assets.d.ts +82 -78
  56. package/esm/src/types/info/assets.d.ts.map +1 -1
  57. package/esm/src/types/info/delegations.d.ts +117 -0
  58. package/esm/src/types/info/delegations.d.ts.map +1 -0
  59. package/esm/src/types/info/delegations.js +1 -0
  60. package/esm/src/types/info/orders.d.ts +67 -67
  61. package/esm/src/types/info/orders.d.ts.map +1 -1
  62. package/esm/src/types/info/requests.d.ts +128 -63
  63. package/esm/src/types/info/requests.d.ts.map +1 -1
  64. package/esm/src/types/info/vaults.d.ts +41 -84
  65. package/esm/src/types/info/vaults.d.ts.map +1 -1
  66. package/esm/src/types/subscriptions/common.d.ts +3 -0
  67. package/esm/src/types/subscriptions/common.d.ts.map +1 -1
  68. package/esm/src/types/subscriptions/requests.d.ts +10 -0
  69. package/esm/src/types/subscriptions/requests.d.ts.map +1 -1
  70. package/esm/src/utils/key_sort.d.ts +2 -2
  71. package/esm/src/utils/key_sort.d.ts.map +1 -1
  72. package/esm/src/utils/signing.d.ts +1 -1
  73. package/esm/src/utils/signing.js +2 -2
  74. package/package.json +1 -1
  75. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +13 -3
  76. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +23 -13
  77. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +55 -45
  78. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.js +97 -87
  79. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.js +14 -4
  80. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.js +288 -278
  81. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.js +238 -228
  82. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
  83. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
  84. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.js +13 -0
  85. package/script/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.d.ts +3 -1
  86. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
  87. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.js +45 -0
  88. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts +9 -0
  89. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts.map +1 -0
  90. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.js +13 -0
  91. package/script/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts.map +1 -1
  92. package/script/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.js +39 -0
  93. package/{esm/deps/jsr.io/@std/encoding/1.0.6 → script/deps/jsr.io/@std/encoding/1.0.7}/hex.d.ts +3 -1
  94. package/script/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
  95. package/script/deps/jsr.io/@std/encoding/1.0.7/hex.js +123 -0
  96. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +9 -0
  97. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +1 -0
  98. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.js +13 -0
  99. package/script/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.d.ts +3 -1
  100. package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +1 -0
  101. package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.js +250 -0
  102. package/script/mod.d.ts +1 -0
  103. package/script/mod.d.ts.map +1 -1
  104. package/script/mod.js +23 -13
  105. package/script/src/clients/event.d.ts +57 -16
  106. package/script/src/clients/event.d.ts.map +1 -1
  107. package/script/src/clients/event.js +551 -485
  108. package/script/src/clients/public.d.ts +241 -49
  109. package/script/src/clients/public.d.ts.map +1 -1
  110. package/script/src/clients/public.js +914 -708
  111. package/script/src/clients/wallet.d.ts +120 -51
  112. package/script/src/clients/wallet.d.ts.map +1 -1
  113. package/script/src/clients/wallet.js +1121 -977
  114. package/script/src/transports/base.js +25 -15
  115. package/script/src/transports/http/http_transport.js +174 -164
  116. package/script/src/transports/websocket/hyperliquid_event_target.d.ts +27 -21
  117. package/script/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -1
  118. package/script/src/transports/websocket/hyperliquid_event_target.js +80 -33
  119. package/script/src/transports/websocket/reconnecting_websocket.js +364 -354
  120. package/script/src/transports/websocket/websocket_request_dispatcher.js +196 -186
  121. package/script/src/transports/websocket/websocket_transport.d.ts +7 -10
  122. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  123. package/script/src/transports/websocket/websocket_transport.js +236 -220
  124. package/script/src/types/common.js +12 -2
  125. package/script/src/types/exchange/common.d.ts +6 -6
  126. package/script/src/types/exchange/common.d.ts.map +1 -1
  127. package/script/src/types/exchange/common.js +12 -2
  128. package/script/src/types/exchange/requests.d.ts +131 -64
  129. package/script/src/types/exchange/requests.d.ts.map +1 -1
  130. package/script/src/types/exchange/requests.js +12 -2
  131. package/script/src/types/exchange/responses.d.ts +7 -7
  132. package/script/src/types/exchange/responses.d.ts.map +1 -1
  133. package/script/src/types/exchange/responses.js +12 -2
  134. package/script/src/types/explorer/common.d.ts +15 -15
  135. package/script/src/types/explorer/common.d.ts.map +1 -1
  136. package/script/src/types/explorer/common.js +12 -2
  137. package/script/src/types/explorer/requests.d.ts +19 -6
  138. package/script/src/types/explorer/requests.d.ts.map +1 -1
  139. package/script/src/types/explorer/requests.js +12 -2
  140. package/script/src/types/explorer/responses.d.ts +9 -2
  141. package/script/src/types/explorer/responses.d.ts.map +1 -1
  142. package/script/src/types/explorer/responses.js +12 -2
  143. package/script/src/types/info/accounts.d.ts +189 -124
  144. package/script/src/types/info/accounts.d.ts.map +1 -1
  145. package/script/src/types/info/accounts.js +12 -2
  146. package/script/src/types/info/assets.d.ts +82 -78
  147. package/script/src/types/info/assets.d.ts.map +1 -1
  148. package/script/src/types/info/assets.js +12 -2
  149. package/script/src/types/info/delegations.d.ts +117 -0
  150. package/script/src/types/info/delegations.d.ts.map +1 -0
  151. package/script/src/types/info/delegations.js +12 -0
  152. package/script/src/types/info/orders.d.ts +67 -67
  153. package/script/src/types/info/orders.d.ts.map +1 -1
  154. package/script/src/types/info/orders.js +12 -2
  155. package/script/src/types/info/requests.d.ts +128 -63
  156. package/script/src/types/info/requests.d.ts.map +1 -1
  157. package/script/src/types/info/requests.js +12 -2
  158. package/script/src/types/info/vaults.d.ts +41 -84
  159. package/script/src/types/info/vaults.d.ts.map +1 -1
  160. package/script/src/types/info/vaults.js +12 -2
  161. package/script/src/types/subscriptions/common.d.ts +3 -0
  162. package/script/src/types/subscriptions/common.d.ts.map +1 -1
  163. package/script/src/types/subscriptions/common.js +12 -2
  164. package/script/src/types/subscriptions/requests.d.ts +10 -0
  165. package/script/src/types/subscriptions/requests.d.ts.map +1 -1
  166. package/script/src/types/subscriptions/requests.js +12 -2
  167. package/script/src/utils/key_sort.d.ts +2 -2
  168. package/script/src/utils/key_sort.d.ts.map +1 -1
  169. package/script/src/utils/key_sort.js +133 -123
  170. package/script/src/utils/signing.d.ts +1 -1
  171. package/script/src/utils/signing.js +172 -162
  172. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +0 -1
  173. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +0 -1
  174. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +0 -1
  175. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +0 -1
  176. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.js +0 -35
  177. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +0 -29
  178. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +0 -1
  179. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.js +0 -113
  180. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +0 -1
  181. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.js +0 -240
  182. /package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts +0 -0
  183. /package/script/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts +0 -0
@@ -0,0 +1,39 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ (function (factory) {
3
+ if (typeof module === "object" && typeof module.exports === "object") {
4
+ var v = factory(require, exports);
5
+ if (v !== undefined) module.exports = v;
6
+ }
7
+ else if (typeof define === "function" && define.amd) {
8
+ define(["require", "exports"], factory);
9
+ }
10
+ })(function (require, exports) {
11
+ "use strict";
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.validateBinaryLike = validateBinaryLike;
14
+ const encoder = new TextEncoder();
15
+ function getTypeName(value) {
16
+ const type = typeof value;
17
+ if (type !== "object") {
18
+ return type;
19
+ }
20
+ else if (value === null) {
21
+ return "null";
22
+ }
23
+ else {
24
+ return value?.constructor?.name ?? "object";
25
+ }
26
+ }
27
+ function validateBinaryLike(source) {
28
+ if (typeof source === "string") {
29
+ return encoder.encode(source);
30
+ }
31
+ else if (source instanceof Uint8Array) {
32
+ return source;
33
+ }
34
+ else if (source instanceof ArrayBuffer) {
35
+ return new Uint8Array(source);
36
+ }
37
+ throw new TypeError(`Cannot validate the input as it must be a Uint8Array, a string, or an ArrayBuffer: received a value of the type ${getTypeName(source)}`);
38
+ }
39
+ });
@@ -1,3 +1,5 @@
1
+ import type { Uint8Array_ } from "./_types.js";
2
+ export type { Uint8Array_ };
1
3
  /**
2
4
  * Converts data into a hex-encoded string.
3
5
  *
@@ -33,5 +35,5 @@ export declare function encodeHex(src: string | Uint8Array | ArrayBuffer): strin
33
35
  * );
34
36
  * ```
35
37
  */
36
- export declare function decodeHex(src: string): Uint8Array;
38
+ export declare function decodeHex(src: string): Uint8Array_;
37
39
  //# sourceMappingURL=hex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.7/hex.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AA4B5B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAUxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAiBlD"}
@@ -0,0 +1,123 @@
1
+ // Copyright 2009 The Go Authors. All rights reserved.
2
+ // https://github.com/golang/go/blob/master/LICENSE
3
+ // Copyright 2018-2025 the Deno authors. MIT license.
4
+ // This module is browser compatible.
5
+ (function (factory) {
6
+ if (typeof module === "object" && typeof module.exports === "object") {
7
+ var v = factory(require, exports);
8
+ if (v !== undefined) module.exports = v;
9
+ }
10
+ else if (typeof define === "function" && define.amd) {
11
+ define(["require", "exports", "./_validate_binary_like.js"], factory);
12
+ }
13
+ })(function (require, exports) {
14
+ "use strict";
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.encodeHex = encodeHex;
17
+ exports.decodeHex = decodeHex;
18
+ /**
19
+ * Port of the Go
20
+ * {@link https://github.com/golang/go/blob/go1.12.5/src/encoding/hex/hex.go | encoding/hex}
21
+ * library.
22
+ *
23
+ * ```ts
24
+ * import {
25
+ * decodeHex,
26
+ * encodeHex,
27
+ * } from "@std/encoding/hex";
28
+ * import { assertEquals } from "@std/assert";
29
+ *
30
+ * assertEquals(encodeHex("abc"), "616263");
31
+ *
32
+ * assertEquals(
33
+ * decodeHex("616263"),
34
+ * new TextEncoder().encode("abc"),
35
+ * );
36
+ * ```
37
+ *
38
+ * @module
39
+ */
40
+ const _validate_binary_like_js_1 = require("./_validate_binary_like.js");
41
+ const hexTable = new TextEncoder().encode("0123456789abcdef");
42
+ const textEncoder = new TextEncoder();
43
+ const textDecoder = new TextDecoder();
44
+ function errInvalidByte(byte) {
45
+ return new TypeError(`Invalid byte '${String.fromCharCode(byte)}'`);
46
+ }
47
+ function errLength(len) {
48
+ return new RangeError(`Cannot decode the hex string as the input length should be even: length is ${len}`);
49
+ }
50
+ /** Converts a hex character into its value. */
51
+ function fromHexChar(byte) {
52
+ // '0' <= byte && byte <= '9'
53
+ if (48 <= byte && byte <= 57)
54
+ return byte - 48;
55
+ // 'a' <= byte && byte <= 'f'
56
+ if (97 <= byte && byte <= 102)
57
+ return byte - 97 + 10;
58
+ // 'A' <= byte && byte <= 'F'
59
+ if (65 <= byte && byte <= 70)
60
+ return byte - 65 + 10;
61
+ throw errInvalidByte(byte);
62
+ }
63
+ /**
64
+ * Converts data into a hex-encoded string.
65
+ *
66
+ * @param src The data to encode.
67
+ *
68
+ * @returns The hex-encoded string.
69
+ *
70
+ * @example Usage
71
+ * ```ts
72
+ * import { encodeHex } from "@std/encoding/hex";
73
+ * import { assertEquals } from "@std/assert";
74
+ *
75
+ * assertEquals(encodeHex("abc"), "616263");
76
+ * ```
77
+ */
78
+ function encodeHex(src) {
79
+ const u8 = (0, _validate_binary_like_js_1.validateBinaryLike)(src);
80
+ const dst = new Uint8Array(u8.length * 2);
81
+ for (let i = 0; i < u8.length; i++) {
82
+ const v = u8[i];
83
+ dst[i * 2] = hexTable[v >> 4];
84
+ dst[i * 2 + 1] = hexTable[v & 0x0f];
85
+ }
86
+ return textDecoder.decode(dst);
87
+ }
88
+ /**
89
+ * Decodes the given hex-encoded string. If the input is malformed, an error is
90
+ * thrown.
91
+ *
92
+ * @param src The hex-encoded string to decode.
93
+ *
94
+ * @returns The decoded data.
95
+ *
96
+ * @example Usage
97
+ * ```ts
98
+ * import { decodeHex } from "@std/encoding/hex";
99
+ * import { assertEquals } from "@std/assert";
100
+ *
101
+ * assertEquals(
102
+ * decodeHex("616263"),
103
+ * new TextEncoder().encode("abc"),
104
+ * );
105
+ * ```
106
+ */
107
+ function decodeHex(src) {
108
+ const u8 = textEncoder.encode(src);
109
+ const dst = new Uint8Array(u8.length / 2);
110
+ for (let i = 0; i < dst.length; i++) {
111
+ const a = fromHexChar(u8[i * 2]);
112
+ const b = fromHexChar(u8[i * 2 + 1]);
113
+ dst[i] = (a << 4) | b;
114
+ }
115
+ if (u8.length % 2 === 1) {
116
+ // Check for invalid char before reporting bad length,
117
+ // since the invalid char (if present) is an earlier problem.
118
+ fromHexChar(u8[dst.length * 2]);
119
+ throw errLength(u8.length);
120
+ }
121
+ return dst;
122
+ }
123
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Proxy type of {@code Uint8Array<ArrayBuffer} or {@code Uint8Array} in TypeScript 5.7 or below respectively.
3
+ *
4
+ * This type is internal utility type and should not be used directly.
5
+ *
6
+ * @internal @private
7
+ */
8
+ export type Uint8Array_ = ReturnType<Uint8Array["slice"]>;
9
+ //# sourceMappingURL=_types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/msgpack/1.0.3/_types.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ (function (factory) {
3
+ if (typeof module === "object" && typeof module.exports === "object") {
4
+ var v = factory(require, exports);
5
+ if (v !== undefined) module.exports = v;
6
+ }
7
+ else if (typeof define === "function" && define.amd) {
8
+ define(["require", "exports"], factory);
9
+ }
10
+ })(function (require, exports) {
11
+ "use strict";
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ });
@@ -1,3 +1,5 @@
1
+ import type { Uint8Array_ } from "./_types.js";
2
+ export type { Uint8Array_ };
1
3
  /**
2
4
  * Value types that can be encoded to MessagePack.
3
5
  */
@@ -33,5 +35,5 @@ export interface ValueMap {
33
35
  * @param object Value to encode to MessagePack binary format.
34
36
  * @returns Encoded MessagePack binary data.
35
37
  */
36
- export declare function encode(object: ValueType): Uint8Array;
38
+ export declare function encode(object: ValueType): Uint8Array_;
37
39
  //# sourceMappingURL=encode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/msgpack/1.0.3/encode.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,UAAU,GACV,SAAS,SAAS,EAAE,GACpB,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,sBAAsB;IACtB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACrC;AAeD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,CAIrD"}
@@ -0,0 +1,250 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ (function (factory) {
4
+ if (typeof module === "object" && typeof module.exports === "object") {
5
+ var v = factory(require, exports);
6
+ if (v !== undefined) module.exports = v;
7
+ }
8
+ else if (typeof define === "function" && define.amd) {
9
+ define(["require", "exports", "../../bytes/1.0.5/concat.js"], factory);
10
+ }
11
+ })(function (require, exports) {
12
+ "use strict";
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.encode = encode;
15
+ const concat_js_1 = require("../../bytes/1.0.5/concat.js");
16
+ const FOUR_BITS = 16;
17
+ const FIVE_BITS = 32;
18
+ const SEVEN_BITS = 128;
19
+ const EIGHT_BITS = 256;
20
+ const FIFTEEN_BITS = 32768;
21
+ const SIXTEEN_BITS = 65536;
22
+ const THIRTY_ONE_BITS = 2147483648;
23
+ const THIRTY_TWO_BITS = 4294967296;
24
+ const SIXTY_THREE_BITS = 9223372036854775808n;
25
+ const SIXTY_FOUR_BITS = 18446744073709551616n;
26
+ const encoder = new TextEncoder();
27
+ /**
28
+ * Encode a value to {@link https://msgpack.org/ | MessagePack} binary format.
29
+ *
30
+ * @example Usage
31
+ * ```ts
32
+ * import { encode } from "@std/msgpack/encode";
33
+ * import { assertEquals } from "@std/assert";
34
+ *
35
+ * const obj = {
36
+ * str: "deno",
37
+ * arr: [1, 2, 3],
38
+ * map: {
39
+ * foo: "bar"
40
+ * }
41
+ * }
42
+ *
43
+ * const encoded = encode(obj);
44
+ *
45
+ * assertEquals(encoded.length, 31);
46
+ * ```
47
+ *
48
+ * @param object Value to encode to MessagePack binary format.
49
+ * @returns Encoded MessagePack binary data.
50
+ */
51
+ function encode(object) {
52
+ const byteParts = [];
53
+ encodeSlice(object, byteParts);
54
+ return (0, concat_js_1.concat)(byteParts);
55
+ }
56
+ function encodeFloat64(num) {
57
+ const dataView = new DataView(new ArrayBuffer(9));
58
+ dataView.setFloat64(1, num);
59
+ dataView.setUint8(0, 0xcb);
60
+ return new Uint8Array(dataView.buffer);
61
+ }
62
+ function encodeNumber(num) {
63
+ if (!Number.isInteger(num)) { // float 64
64
+ return encodeFloat64(num);
65
+ }
66
+ if (num < 0) {
67
+ if (num >= -FIVE_BITS) { // negative fixint
68
+ return new Uint8Array([num]);
69
+ }
70
+ if (num >= -SEVEN_BITS) { // int 8
71
+ return new Uint8Array([0xd0, num]);
72
+ }
73
+ if (num >= -FIFTEEN_BITS) { // int 16
74
+ const dataView = new DataView(new ArrayBuffer(3));
75
+ dataView.setInt16(1, num);
76
+ dataView.setUint8(0, 0xd1);
77
+ return new Uint8Array(dataView.buffer);
78
+ }
79
+ if (num >= -THIRTY_ONE_BITS) { // int 32
80
+ const dataView = new DataView(new ArrayBuffer(5));
81
+ dataView.setInt32(1, num);
82
+ dataView.setUint8(0, 0xd2);
83
+ return new Uint8Array(dataView.buffer);
84
+ }
85
+ // float 64
86
+ return encodeFloat64(num);
87
+ }
88
+ // if the number fits within a positive fixint, use it
89
+ if (num <= 0x7f) {
90
+ return new Uint8Array([num]);
91
+ }
92
+ if (num < EIGHT_BITS) { // uint8
93
+ return new Uint8Array([0xcc, num]);
94
+ }
95
+ if (num < SIXTEEN_BITS) { // uint16
96
+ const dataView = new DataView(new ArrayBuffer(3));
97
+ dataView.setUint16(1, num);
98
+ dataView.setUint8(0, 0xcd);
99
+ return new Uint8Array(dataView.buffer);
100
+ }
101
+ if (num < THIRTY_TWO_BITS) { // uint32
102
+ const dataView = new DataView(new ArrayBuffer(5));
103
+ dataView.setUint32(1, num);
104
+ dataView.setUint8(0, 0xce);
105
+ return new Uint8Array(dataView.buffer);
106
+ }
107
+ // float 64
108
+ return encodeFloat64(num);
109
+ }
110
+ function encodeSlice(object, byteParts) {
111
+ if (object === null) {
112
+ byteParts.push(new Uint8Array([0xc0]));
113
+ return;
114
+ }
115
+ if (object === false) {
116
+ byteParts.push(new Uint8Array([0xc2]));
117
+ return;
118
+ }
119
+ if (object === true) {
120
+ byteParts.push(new Uint8Array([0xc3]));
121
+ return;
122
+ }
123
+ if (typeof object === "number") {
124
+ byteParts.push(encodeNumber(object));
125
+ return;
126
+ }
127
+ if (typeof object === "bigint") {
128
+ if (object < 0) {
129
+ if (object < -SIXTY_THREE_BITS) {
130
+ throw new Error("Cannot safely encode bigint larger than 64 bits");
131
+ }
132
+ const dataView = new DataView(new ArrayBuffer(9));
133
+ dataView.setBigInt64(1, object);
134
+ dataView.setUint8(0, 0xd3);
135
+ byteParts.push(new Uint8Array(dataView.buffer));
136
+ return;
137
+ }
138
+ if (object >= SIXTY_FOUR_BITS) {
139
+ throw new Error("Cannot safely encode bigint larger than 64 bits");
140
+ }
141
+ const dataView = new DataView(new ArrayBuffer(9));
142
+ dataView.setBigUint64(1, object);
143
+ dataView.setUint8(0, 0xcf);
144
+ byteParts.push(new Uint8Array(dataView.buffer));
145
+ return;
146
+ }
147
+ if (typeof object === "string") {
148
+ const encoded = encoder.encode(object);
149
+ const len = encoded.length;
150
+ if (len < FIVE_BITS) { // fixstr
151
+ byteParts.push(new Uint8Array([0xa0 | len]));
152
+ }
153
+ else if (len < EIGHT_BITS) { // str 8
154
+ byteParts.push(new Uint8Array([0xd9, len]));
155
+ }
156
+ else if (len < SIXTEEN_BITS) { // str 16
157
+ const dataView = new DataView(new ArrayBuffer(3));
158
+ dataView.setUint16(1, len);
159
+ dataView.setUint8(0, 0xda);
160
+ byteParts.push(new Uint8Array(dataView.buffer));
161
+ }
162
+ else if (len < THIRTY_TWO_BITS) { // str 32
163
+ const dataView = new DataView(new ArrayBuffer(5));
164
+ dataView.setUint32(1, len);
165
+ dataView.setUint8(0, 0xdb);
166
+ byteParts.push(new Uint8Array(dataView.buffer));
167
+ }
168
+ else {
169
+ throw new Error("Cannot safely encode string with size larger than 32 bits");
170
+ }
171
+ byteParts.push(encoded);
172
+ return;
173
+ }
174
+ if (object instanceof Uint8Array) {
175
+ if (object.length < EIGHT_BITS) { // bin 8
176
+ byteParts.push(new Uint8Array([0xc4, object.length]));
177
+ }
178
+ else if (object.length < SIXTEEN_BITS) { // bin 16
179
+ const dataView = new DataView(new ArrayBuffer(3));
180
+ dataView.setUint16(1, object.length);
181
+ dataView.setUint8(0, 0xc5);
182
+ byteParts.push(new Uint8Array(dataView.buffer));
183
+ }
184
+ else if (object.length < THIRTY_TWO_BITS) { // bin 32
185
+ const dataView = new DataView(new ArrayBuffer(5));
186
+ dataView.setUint32(1, object.length);
187
+ dataView.setUint8(0, 0xc6);
188
+ byteParts.push(new Uint8Array(dataView.buffer));
189
+ }
190
+ else {
191
+ throw new Error("Cannot safely encode Uint8Array with size larger than 32 bits");
192
+ }
193
+ byteParts.push(object);
194
+ return;
195
+ }
196
+ if (Array.isArray(object)) {
197
+ if (object.length < FOUR_BITS) { // fixarray
198
+ byteParts.push(new Uint8Array([0x90 | object.length]));
199
+ }
200
+ else if (object.length < SIXTEEN_BITS) { // array 16
201
+ const dataView = new DataView(new ArrayBuffer(3));
202
+ dataView.setUint16(1, object.length);
203
+ dataView.setUint8(0, 0xdc);
204
+ byteParts.push(new Uint8Array(dataView.buffer));
205
+ }
206
+ else if (object.length < THIRTY_TWO_BITS) { // array 32
207
+ const dataView = new DataView(new ArrayBuffer(5));
208
+ dataView.setUint32(1, object.length);
209
+ dataView.setUint8(0, 0xdd);
210
+ byteParts.push(new Uint8Array(dataView.buffer));
211
+ }
212
+ else {
213
+ throw new Error("Cannot safely encode array with size larger than 32 bits");
214
+ }
215
+ for (const obj of object) {
216
+ encodeSlice(obj, byteParts);
217
+ }
218
+ return;
219
+ }
220
+ // If object is a plain object
221
+ const prototype = Object.getPrototypeOf(object);
222
+ if (prototype === null || prototype === Object.prototype) {
223
+ const numKeys = Object.keys(object).length;
224
+ if (numKeys < FOUR_BITS) { // fixarray
225
+ byteParts.push(new Uint8Array([0x80 | numKeys]));
226
+ }
227
+ else if (numKeys < SIXTEEN_BITS) { // map 16
228
+ const dataView = new DataView(new ArrayBuffer(3));
229
+ dataView.setUint16(1, numKeys);
230
+ dataView.setUint8(0, 0xde);
231
+ byteParts.push(new Uint8Array(dataView.buffer));
232
+ }
233
+ else if (numKeys < THIRTY_TWO_BITS) { // map 32
234
+ const dataView = new DataView(new ArrayBuffer(5));
235
+ dataView.setUint32(1, numKeys);
236
+ dataView.setUint8(0, 0xdf);
237
+ byteParts.push(new Uint8Array(dataView.buffer));
238
+ }
239
+ else {
240
+ throw new Error("Cannot safely encode map with size larger than 32 bits");
241
+ }
242
+ for (const [key, value] of Object.entries(object)) {
243
+ encodeSlice(key, byteParts);
244
+ encodeSlice(value, byteParts);
245
+ }
246
+ return;
247
+ }
248
+ throw new Error("Cannot safely encode value into messagepack");
249
+ }
250
+ });
package/script/mod.d.ts CHANGED
@@ -15,6 +15,7 @@ export type * from "./src/types/explorer/requests.js";
15
15
  export type * from "./src/types/explorer/responses.js";
16
16
  export type * from "./src/types/info/accounts.js";
17
17
  export type * from "./src/types/info/assets.js";
18
+ export type * from "./src/types/info/delegations.js";
18
19
  export type * from "./src/types/info/orders.js";
19
20
  export type * from "./src/types/info/requests.js";
20
21
  export type * from "./src/types/info/vaults.js";
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,yCAAyC,CAAC;AAExD,cAAc,mDAAmD,CAAC;AAClE,YAAY,EACR,qBAAqB,EACrB,4BAA4B,GAC/B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4DAA4D,CAAC;AAGnG,mBAAmB,uBAAuB,CAAC;AAE3C,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,kCAAkC,CAAC;AACtD,mBAAmB,mCAAmC,CAAC;AAEvD,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,kCAAkC,CAAC;AACtD,mBAAmB,mCAAmC,CAAC;AAEvD,mBAAmB,8BAA8B,CAAC;AAClD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,8BAA8B,CAAC;AAClD,mBAAmB,4BAA4B,CAAC;AAEhD,mBAAmB,qCAAqC,CAAC;AACzD,mBAAmB,uCAAuC,CAAC;AAG3D,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,yCAAyC,CAAC;AAExD,cAAc,mDAAmD,CAAC;AAClE,YAAY,EACR,qBAAqB,EACrB,4BAA4B,GAC/B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4DAA4D,CAAC;AAGnG,mBAAmB,uBAAuB,CAAC;AAE3C,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,kCAAkC,CAAC;AACtD,mBAAmB,mCAAmC,CAAC;AAEvD,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,kCAAkC,CAAC;AACtD,mBAAmB,mCAAmC,CAAC;AAEvD,mBAAmB,8BAA8B,CAAC;AAClD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,iCAAiC,CAAC;AACrD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,8BAA8B,CAAC;AAClD,mBAAmB,4BAA4B,CAAC;AAEhD,mBAAmB,qCAAqC,CAAC;AACzD,mBAAmB,uCAAuC,CAAC;AAG3D,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC"}
package/script/mod.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
2
  if (k2 === undefined) k2 = k;
4
3
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -13,15 +12,26 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
12
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
13
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
14
  };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.WebSocketRequestError = void 0;
18
- // Clients
19
- __exportStar(require("./src/clients/event.js"), exports);
20
- __exportStar(require("./src/clients/public.js"), exports);
21
- __exportStar(require("./src/clients/wallet.js"), exports);
22
- // Transports
23
- __exportStar(require("./src/transports/base.js"), exports);
24
- __exportStar(require("./src/transports/http/http_transport.js"), exports);
25
- __exportStar(require("./src/transports/websocket/websocket_transport.js"), exports);
26
- var websocket_request_dispatcher_js_1 = require("./src/transports/websocket/websocket_request_dispatcher.js");
27
- Object.defineProperty(exports, "WebSocketRequestError", { enumerable: true, get: function () { return websocket_request_dispatcher_js_1.WebSocketRequestError; } });
15
+ (function (factory) {
16
+ if (typeof module === "object" && typeof module.exports === "object") {
17
+ var v = factory(require, exports);
18
+ if (v !== undefined) module.exports = v;
19
+ }
20
+ else if (typeof define === "function" && define.amd) {
21
+ define(["require", "exports", "./src/clients/event.js", "./src/clients/public.js", "./src/clients/wallet.js", "./src/transports/base.js", "./src/transports/http/http_transport.js", "./src/transports/websocket/websocket_transport.js", "./src/transports/websocket/websocket_request_dispatcher.js"], factory);
22
+ }
23
+ })(function (require, exports) {
24
+ "use strict";
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.WebSocketRequestError = void 0;
27
+ // Clients
28
+ __exportStar(require("./src/clients/event.js"), exports);
29
+ __exportStar(require("./src/clients/public.js"), exports);
30
+ __exportStar(require("./src/clients/wallet.js"), exports);
31
+ // Transports
32
+ __exportStar(require("./src/transports/base.js"), exports);
33
+ __exportStar(require("./src/transports/http/http_transport.js"), exports);
34
+ __exportStar(require("./src/transports/websocket/websocket_transport.js"), exports);
35
+ var websocket_request_dispatcher_js_1 = require("./src/transports/websocket/websocket_request_dispatcher.js");
36
+ Object.defineProperty(exports, "WebSocketRequestError", { enumerable: true, get: function () { return websocket_request_dispatcher_js_1.WebSocketRequestError; } });
37
+ });