@nktkas/hyperliquid 0.17.2 → 0.17.4

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 (84) hide show
  1. package/README.md +41 -4
  2. package/{script/deps/jsr.io/@noble/hashes/1.7.1 → esm/deps/jsr.io/@noble/hashes/1.8.0}/src/_u64.d.ts +1 -1
  3. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts.map +1 -0
  4. package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/_u64.js +5 -4
  5. package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.d.ts.map +1 -1
  6. package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/sha3.d.ts +6 -5
  7. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts.map +1 -0
  8. package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/sha3.js +63 -52
  9. package/{script/deps/jsr.io/@noble/hashes/1.7.1 → esm/deps/jsr.io/@noble/hashes/1.8.0}/src/utils.d.ts +60 -19
  10. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/utils.js +94 -25
  12. package/{script/deps/jsr.io/@std/encoding/1.0.8 → esm/deps/jsr.io/@std/encoding/1.0.9}/_common16.d.ts +5 -3
  13. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_common16.d.ts.map +1 -1
  14. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_common16.js +9 -3
  15. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_common_detach.d.ts.map +1 -1
  16. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_types.d.ts.map +1 -1
  17. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/hex.d.ts.map +1 -1
  18. package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/hex.js +2 -2
  19. package/esm/src/clients/public.d.ts +85 -85
  20. package/esm/src/clients/public.d.ts.map +1 -1
  21. package/esm/src/clients/public.js +110 -110
  22. package/esm/src/signing.js +2 -2
  23. package/esm/src/transports/http/http_transport.d.ts +69 -8
  24. package/esm/src/transports/http/http_transport.d.ts.map +1 -1
  25. package/esm/src/transports/http/http_transport.js +65 -12
  26. package/esm/src/types/info/accounts.d.ts +1 -0
  27. package/esm/src/types/info/accounts.d.ts.map +1 -1
  28. package/esm/src/types/info/assets.d.ts +2 -0
  29. package/esm/src/types/info/assets.d.ts.map +1 -1
  30. package/package.json +1 -1
  31. package/{esm/deps/jsr.io/@noble/hashes/1.7.1 → script/deps/jsr.io/@noble/hashes/1.8.0}/src/_u64.d.ts +1 -1
  32. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts.map +1 -0
  33. package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/_u64.js +6 -5
  34. package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.d.ts.map +1 -1
  35. package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/sha3.d.ts +6 -5
  36. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts.map +1 -0
  37. package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/sha3.js +69 -58
  38. package/{esm/deps/jsr.io/@noble/hashes/1.7.1 → script/deps/jsr.io/@noble/hashes/1.8.0}/src/utils.d.ts +60 -19
  39. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts.map +1 -0
  40. package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/utils.js +111 -34
  41. package/{esm/deps/jsr.io/@std/encoding/1.0.8 → script/deps/jsr.io/@std/encoding/1.0.9}/_common16.d.ts +5 -3
  42. package/script/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_common16.d.ts.map +1 -1
  43. package/script/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_common16.js +11 -4
  44. package/script/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_common_detach.d.ts.map +1 -1
  45. package/script/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_types.d.ts.map +1 -1
  46. package/script/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/hex.d.ts.map +1 -1
  47. package/script/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/hex.js +1 -1
  48. package/script/src/clients/public.d.ts +85 -85
  49. package/script/src/clients/public.d.ts.map +1 -1
  50. package/script/src/clients/public.js +110 -110
  51. package/script/src/signing.js +3 -3
  52. package/script/src/transports/http/http_transport.d.ts +69 -8
  53. package/script/src/transports/http/http_transport.d.ts.map +1 -1
  54. package/script/src/transports/http/http_transport.js +65 -12
  55. package/script/src/types/info/accounts.d.ts +1 -0
  56. package/script/src/types/info/accounts.d.ts.map +1 -1
  57. package/script/src/types/info/assets.d.ts +2 -0
  58. package/script/src/types/info/assets.d.ts.map +1 -1
  59. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts +0 -23
  60. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts.map +0 -1
  61. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +0 -43
  62. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts.map +0 -1
  63. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts.map +0 -1
  64. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts.map +0 -1
  65. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts +0 -23
  66. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts.map +0 -1
  67. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +0 -59
  68. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts.map +0 -1
  69. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts.map +0 -1
  70. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts.map +0 -1
  71. /package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.d.ts +0 -0
  72. /package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.js +0 -0
  73. /package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_common_detach.d.ts +0 -0
  74. /package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_common_detach.js +0 -0
  75. /package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_types.d.ts +0 -0
  76. /package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_types.js +0 -0
  77. /package/esm/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/hex.d.ts +0 -0
  78. /package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.d.ts +0 -0
  79. /package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.js +0 -0
  80. /package/script/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_common_detach.d.ts +0 -0
  81. /package/script/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_common_detach.js +0 -0
  82. /package/script/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_types.d.ts +0 -0
  83. /package/script/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/_types.js +0 -0
  84. /package/script/deps/jsr.io/@std/encoding/{1.0.8 → 1.0.9}/hex.d.ts +0 -0
@@ -9,15 +9,21 @@
9
9
  if (v !== undefined) module.exports = v;
10
10
  }
11
11
  else if (typeof define === "function" && define.amd) {
12
- define(["require", "exports", "./crypto.js", "./_assert.js"], factory);
12
+ define(["require", "exports", "./crypto.js"], factory);
13
13
  }
14
14
  })(function (require, exports) {
15
15
  "use strict";
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Hash = exports.nextTick = exports.byteSwapIfBE = exports.isLE = void 0;
17
+ exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.Hash = exports.nextTick = exports.swap32IfBE = exports.byteSwapIfBE = exports.swap8IfBE = exports.isLE = void 0;
18
18
  exports.isBytes = isBytes;
19
+ exports.anumber = anumber;
20
+ exports.abytes = abytes;
21
+ exports.ahash = ahash;
22
+ exports.aexists = aexists;
23
+ exports.aoutput = aoutput;
19
24
  exports.u8 = u8;
20
25
  exports.u32 = u32;
26
+ exports.clean = clean;
21
27
  exports.createView = createView;
22
28
  exports.rotr = rotr;
23
29
  exports.rotl = rotl;
@@ -27,12 +33,14 @@
27
33
  exports.hexToBytes = hexToBytes;
28
34
  exports.asyncLoop = asyncLoop;
29
35
  exports.utf8ToBytes = utf8ToBytes;
36
+ exports.bytesToUtf8 = bytesToUtf8;
30
37
  exports.toBytes = toBytes;
38
+ exports.kdfInputToBytes = kdfInputToBytes;
31
39
  exports.concatBytes = concatBytes;
32
40
  exports.checkOpts = checkOpts;
33
- exports.wrapConstructor = wrapConstructor;
34
- exports.wrapConstructorWithOpts = wrapConstructorWithOpts;
35
- exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts;
41
+ exports.createHasher = createHasher;
42
+ exports.createOptHasher = createOptHasher;
43
+ exports.createXOFer = createXOFer;
36
44
  exports.randomBytes = randomBytes;
37
45
  // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
38
46
  // node.js versions earlier than v19 don't declare it in global scope.
@@ -41,20 +49,59 @@
41
49
  // Makes the utils un-importable in browsers without a bundler.
42
50
  // Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
43
51
  const crypto_js_1 = require("./crypto.js");
44
- const _assert_js_1 = require("./_assert.js");
45
- // export { isBytes } from './_assert.js';
46
- // We can't reuse isBytes from _assert, because somehow this causes huge perf issues
52
+ /** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
47
53
  function isBytes(a) {
48
54
  return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
49
55
  }
50
- // Cast array to different type
56
+ /** Asserts something is positive integer. */
57
+ function anumber(n) {
58
+ if (!Number.isSafeInteger(n) || n < 0)
59
+ throw new Error('positive integer expected, got ' + n);
60
+ }
61
+ /** Asserts something is Uint8Array. */
62
+ function abytes(b, ...lengths) {
63
+ if (!isBytes(b))
64
+ throw new Error('Uint8Array expected');
65
+ if (lengths.length > 0 && !lengths.includes(b.length))
66
+ throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
67
+ }
68
+ /** Asserts something is hash */
69
+ function ahash(h) {
70
+ if (typeof h !== 'function' || typeof h.create !== 'function')
71
+ throw new Error('Hash should be wrapped by utils.createHasher');
72
+ anumber(h.outputLen);
73
+ anumber(h.blockLen);
74
+ }
75
+ /** Asserts a hash instance has not been destroyed / finished */
76
+ function aexists(instance, checkFinished = true) {
77
+ if (instance.destroyed)
78
+ throw new Error('Hash instance has been destroyed');
79
+ if (checkFinished && instance.finished)
80
+ throw new Error('Hash#digest() has already been called');
81
+ }
82
+ /** Asserts output is properly-sized byte array */
83
+ function aoutput(out, instance) {
84
+ abytes(out);
85
+ const min = instance.outputLen;
86
+ if (out.length < min) {
87
+ throw new Error('digestInto() expects output buffer of length at least ' + min);
88
+ }
89
+ }
90
+ /** Cast u8 / u16 / u32 to u8. */
51
91
  function u8(arr) {
52
92
  return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
53
93
  }
94
+ /** Cast u8 / u16 / u32 to u32. */
54
95
  function u32(arr) {
55
96
  return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
56
97
  }
57
- // Cast array to view
98
+ /** Zeroize a byte array. Warning: JS provides no guarantees. */
99
+ function clean(...arrays) {
100
+ for (let i = 0; i < arrays.length; i++) {
101
+ arrays[i].fill(0);
102
+ }
103
+ }
104
+ /** Create DataView of an array for easy byte-level manipulation. */
58
105
  function createView(arr) {
59
106
  return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
60
107
  }
@@ -68,7 +115,7 @@
68
115
  }
69
116
  /** Is current platform little-endian? Most are. Big-Endian platform: IBM */
70
117
  exports.isLE = (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
71
- // The byte swap operation for uint32
118
+ /** The byte swap operation for uint32 */
72
119
  function byteSwap(word) {
73
120
  return (((word << 24) & 0xff000000) |
74
121
  ((word << 8) & 0xff0000) |
@@ -76,23 +123,36 @@
76
123
  ((word >>> 24) & 0xff));
77
124
  }
78
125
  /** Conditionally byte swap if on a big-endian platform */
79
- exports.byteSwapIfBE = exports.isLE
126
+ exports.swap8IfBE = exports.isLE
80
127
  ? (n) => n
81
128
  : (n) => byteSwap(n);
129
+ /** @deprecated */
130
+ exports.byteSwapIfBE = exports.swap8IfBE;
82
131
  /** In place byte swap for Uint32Array */
83
132
  function byteSwap32(arr) {
84
133
  for (let i = 0; i < arr.length; i++) {
85
134
  arr[i] = byteSwap(arr[i]);
86
135
  }
136
+ return arr;
87
137
  }
138
+ exports.swap32IfBE = exports.isLE
139
+ ? (u) => u
140
+ : byteSwap32;
141
+ // Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex
142
+ const hasHexBuiltin = /* @__PURE__ */ (() =>
143
+ // @ts-ignore
144
+ typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();
88
145
  // Array where index 0xf0 (240) is mapped to string 'f0'
89
146
  const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
90
147
  /**
91
- * Convert byte array to hex string.
148
+ * Convert byte array to hex string. Uses built-in function, when available.
92
149
  * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
93
150
  */
94
151
  function bytesToHex(bytes) {
95
- (0, _assert_js_1.abytes)(bytes);
152
+ abytes(bytes);
153
+ // @ts-ignore
154
+ if (hasHexBuiltin)
155
+ return bytes.toHex();
96
156
  // pre-caching improves the speed 6x
97
157
  let hex = '';
98
158
  for (let i = 0; i < bytes.length; i++) {
@@ -112,12 +172,15 @@
112
172
  return;
113
173
  }
114
174
  /**
115
- * Convert hex string to byte array.
175
+ * Convert hex string to byte array. Uses built-in function, when available.
116
176
  * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
117
177
  */
118
178
  function hexToBytes(hex) {
119
179
  if (typeof hex !== 'string')
120
180
  throw new Error('hex string expected, got ' + typeof hex);
181
+ // @ts-ignore
182
+ if (hasHexBuiltin)
183
+ return Uint8Array.fromHex(hex);
121
184
  const hl = hex.length;
122
185
  const al = hl / 2;
123
186
  if (hl % 2)
@@ -155,14 +218,21 @@
155
218
  }
156
219
  }
157
220
  /**
158
- * Convert JS string to byte array.
159
- * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
221
+ * Converts string to bytes using UTF8 encoding.
222
+ * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
160
223
  */
161
224
  function utf8ToBytes(str) {
162
225
  if (typeof str !== 'string')
163
- throw new Error('utf8ToBytes expected string, got ' + typeof str);
226
+ throw new Error('string expected');
164
227
  return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
165
228
  }
229
+ /**
230
+ * Converts bytes to string using UTF8 encoding.
231
+ * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'
232
+ */
233
+ function bytesToUtf8(bytes) {
234
+ return new TextDecoder().decode(bytes);
235
+ }
166
236
  /**
167
237
  * Normalizes (non-hex) string or Uint8Array to Uint8Array.
168
238
  * Warning: when Uint8Array is passed, it would NOT get copied.
@@ -171,17 +241,25 @@
171
241
  function toBytes(data) {
172
242
  if (typeof data === 'string')
173
243
  data = utf8ToBytes(data);
174
- (0, _assert_js_1.abytes)(data);
244
+ abytes(data);
175
245
  return data;
176
246
  }
177
247
  /**
178
- * Copies several Uint8Arrays into one.
248
+ * Helper for KDFs: consumes uint8array or string.
249
+ * When string is passed, does utf8 decoding, using TextDecoder.
179
250
  */
251
+ function kdfInputToBytes(data) {
252
+ if (typeof data === 'string')
253
+ data = utf8ToBytes(data);
254
+ abytes(data);
255
+ return data;
256
+ }
257
+ /** Copies several Uint8Arrays into one. */
180
258
  function concatBytes(...arrays) {
181
259
  let sum = 0;
182
260
  for (let i = 0; i < arrays.length; i++) {
183
261
  const a = arrays[i];
184
- (0, _assert_js_1.abytes)(a);
262
+ abytes(a);
185
263
  sum += a.length;
186
264
  }
187
265
  const res = new Uint8Array(sum);
@@ -192,22 +270,18 @@
192
270
  }
193
271
  return res;
194
272
  }
195
- /** For runtime check if class implements interface */
196
- class Hash {
197
- // Safe version that clones internal state
198
- clone() {
199
- return this._cloneInto();
200
- }
201
- }
202
- exports.Hash = Hash;
203
273
  function checkOpts(defaults, opts) {
204
274
  if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')
205
- throw new Error('Options should be object or undefined');
275
+ throw new Error('options should be object or undefined');
206
276
  const merged = Object.assign(defaults, opts);
207
277
  return merged;
208
278
  }
279
+ /** For runtime check if class implements interface */
280
+ class Hash {
281
+ }
282
+ exports.Hash = Hash;
209
283
  /** Wraps hash function, creating an interface on top of it */
210
- function wrapConstructor(hashCons) {
284
+ function createHasher(hashCons) {
211
285
  const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
212
286
  const tmp = hashCons();
213
287
  hashC.outputLen = tmp.outputLen;
@@ -215,7 +289,7 @@
215
289
  hashC.create = () => hashCons();
216
290
  return hashC;
217
291
  }
218
- function wrapConstructorWithOpts(hashCons) {
292
+ function createOptHasher(hashCons) {
219
293
  const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
220
294
  const tmp = hashCons({});
221
295
  hashC.outputLen = tmp.outputLen;
@@ -223,7 +297,7 @@
223
297
  hashC.create = (opts) => hashCons(opts);
224
298
  return hashC;
225
299
  }
226
- function wrapXOFConstructorWithOpts(hashCons) {
300
+ function createXOFer(hashCons) {
227
301
  const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
228
302
  const tmp = hashCons({});
229
303
  hashC.outputLen = tmp.outputLen;
@@ -231,6 +305,9 @@
231
305
  hashC.create = (opts) => hashCons(opts);
232
306
  return hashC;
233
307
  }
308
+ exports.wrapConstructor = createHasher;
309
+ exports.wrapConstructorWithOpts = createOptHasher;
310
+ exports.wrapXOFConstructorWithOpts = createXOFer;
234
311
  /** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
235
312
  function randomBytes(bytesLength = 32) {
236
313
  if (crypto_js_1.crypto && typeof crypto_js_1.crypto.getRandomValues === 'function') {
@@ -238,7 +315,7 @@
238
315
  }
239
316
  // Legacy Node.js compatibility
240
317
  if (crypto_js_1.crypto && typeof crypto_js_1.crypto.randomBytes === 'function') {
241
- return crypto_js_1.crypto.randomBytes(bytesLength);
318
+ return Uint8Array.from(crypto_js_1.crypto.randomBytes(bytesLength));
242
319
  }
243
320
  throw new Error('crypto.getRandomValues must be defined');
244
321
  }
@@ -1,5 +1,7 @@
1
1
  import type { Uint8Array_ } from "./_types.js";
2
2
  export type { Uint8Array_ };
3
+ export declare const alphabet: Uint8Array;
4
+ export declare const rAlphabet: Uint8Array;
3
5
  /**
4
6
  * Calculate the output size needed to encode a given input size for
5
7
  * {@linkcode encodeRawHex}.
@@ -10,12 +12,12 @@ export type { Uint8Array_ };
10
12
  * @example Basic Usage
11
13
  * ```ts
12
14
  * import { assertEquals } from "@std/assert";
13
- * import { calcMax } from "@std/encoding/unstable-hex";
15
+ * import { calcSizeHex } from "@std/encoding/unstable-hex";
14
16
  *
15
- * assertEquals(calcMax(1), 2);
17
+ * assertEquals(calcSizeHex(1), 2);
16
18
  * ```
17
19
  */
18
- export declare function calcMax(originalSize: number): number;
20
+ export declare function calcSizeHex(originalSize: number): number;
19
21
  export declare function encode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array): number;
20
22
  export declare function decode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array): number;
21
23
  //# sourceMappingURL=_common16.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_common16.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.8/_common16.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,GACnB,MAAM,CAOR;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,GACnB,MAAM,CAeR"}
1
+ {"version":3,"file":"_common16.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.9/_common16.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,eAAO,MAAM,QAAQ,YAA+C,CAAC;AACrE,eAAO,MAAM,SAAS,YAA+B,CAAC;AAMtD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,GACnB,MAAM,CAOR;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,GACnB,MAAM,CAeR"}
@@ -10,9 +10,16 @@
10
10
  })(function (require, exports) {
11
11
  "use strict";
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.calcMax = calcMax;
13
+ exports.rAlphabet = exports.alphabet = void 0;
14
+ exports.calcSizeHex = calcSizeHex;
14
15
  exports.encode = encode;
15
16
  exports.decode = decode;
17
+ exports.alphabet = new TextEncoder().encode("0123456789abcdef");
18
+ exports.rAlphabet = new Uint8Array(128).fill(16); // alphabet.Hex.length
19
+ exports.alphabet.forEach((byte, i) => exports.rAlphabet[byte] = i);
20
+ new TextEncoder()
21
+ .encode("ABCDEF")
22
+ .forEach((byte, i) => exports.rAlphabet[byte] = i + 10);
16
23
  /**
17
24
  * Calculate the output size needed to encode a given input size for
18
25
  * {@linkcode encodeRawHex}.
@@ -23,12 +30,12 @@
23
30
  * @example Basic Usage
24
31
  * ```ts
25
32
  * import { assertEquals } from "@std/assert";
26
- * import { calcMax } from "@std/encoding/unstable-hex";
33
+ * import { calcSizeHex } from "@std/encoding/unstable-hex";
27
34
  *
28
- * assertEquals(calcMax(1), 2);
35
+ * assertEquals(calcSizeHex(1), 2);
29
36
  * ```
30
37
  */
31
- function calcMax(originalSize) {
38
+ function calcSizeHex(originalSize) {
32
39
  return originalSize * 2;
33
40
  }
34
41
  function encode(buffer, i, o, alphabet) {
@@ -1 +1 @@
1
- {"version":3,"file":"_common_detach.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.8/_common_detach.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,GACd,CAAC,WAAW,EAAE,MAAM,CAAC,CAWvB"}
1
+ {"version":3,"file":"_common_detach.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.9/_common_detach.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,GACd,CAAC,WAAW,EAAE,MAAM,CAAC,CAWvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.8/_types.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.9/_types.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.8/hex.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAU5B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAWxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAKlD"}
1
+ {"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.9/hex.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAU5B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAWxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAKlD"}
@@ -69,7 +69,7 @@
69
69
  src = new Uint8Array(src).slice();
70
70
  else
71
71
  src = src.slice();
72
- const [output, i] = (0, _common_detach_js_1.detach)(src, (0, _common16_js_1.calcMax)(src.length));
72
+ const [output, i] = (0, _common_detach_js_1.detach)(src, (0, _common16_js_1.calcSizeHex)(src.length));
73
73
  (0, _common16_js_1.encode)(output, i, 0, alphabet);
74
74
  return new TextDecoder().decode(output);
75
75
  }
@@ -127,6 +127,24 @@ export declare class PublicClient<T extends IRequestTransport = IRequestTranspor
127
127
  * ```
128
128
  */
129
129
  allMids(signal?: AbortSignal): Promise<AllMids>;
130
+ /**
131
+ * Block details by block height.
132
+ * @param args - The parameters for the request.
133
+ * @param signal - An optional abort signal.
134
+ * @returns Block details response.
135
+ *
136
+ * @see null - no documentation
137
+ * @example
138
+ * ```ts
139
+ * import * as hl from "@nktkas/hyperliquid";
140
+ *
141
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
142
+ * const client = new hl.PublicClient({ transport });
143
+ *
144
+ * const { blockDetails } = await client.blockDetails({ height: 123 });
145
+ * ```
146
+ */
147
+ blockDetails(args: BlockDetailsParameters, signal?: AbortSignal): Promise<BlockDetailsResponse>;
130
148
  /**
131
149
  * Request candlestick snapshots.
132
150
  * @param args - The parameters for the request.
@@ -297,12 +315,12 @@ export declare class PublicClient<T extends IRequestTransport = IRequestTranspor
297
315
  */
298
316
  fundingHistory(args: FundingHistoryParameters, signal?: AbortSignal): Promise<FundingHistory[]>;
299
317
  /**
300
- * Request to check if a user is a VIP.
318
+ * Request user's historical orders.
301
319
  * @param args - The parameters for the request.
302
320
  * @param signal - An optional abort signal.
303
- * @returns Boolean indicating user's VIP status.
321
+ * @returns Array of user's historical orders.
304
322
  *
305
- * @see null - no documentation
323
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-historical-orders
306
324
  * @example
307
325
  * ```ts
308
326
  * import * as hl from "@nktkas/hyperliquid";
@@ -310,17 +328,17 @@ export declare class PublicClient<T extends IRequestTransport = IRequestTranspor
310
328
  * const transport = new hl.HttpTransport(); // or WebSocketTransport
311
329
  * const client = new hl.PublicClient({ transport });
312
330
  *
313
- * const isVip = await client.isVip({ user: "0x..." });
331
+ * const historicalOrders = await client.historicalOrders({ user: "0x..." });
314
332
  * ```
315
333
  */
316
- isVip(args: IsVipParameters, signal?: AbortSignal): Promise<boolean>;
334
+ historicalOrders(args: HistoricalOrdersParameters, signal?: AbortSignal): Promise<OrderStatus<FrontendOrder>[]>;
317
335
  /**
318
- * Request user's historical orders.
336
+ * Request to check if a user is a VIP.
319
337
  * @param args - The parameters for the request.
320
338
  * @param signal - An optional abort signal.
321
- * @returns Array of user's historical orders.
339
+ * @returns Boolean indicating user's VIP status.
322
340
  *
323
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-historical-orders
341
+ * @see null - no documentation
324
342
  * @example
325
343
  * ```ts
326
344
  * import * as hl from "@nktkas/hyperliquid";
@@ -328,10 +346,10 @@ export declare class PublicClient<T extends IRequestTransport = IRequestTranspor
328
346
  * const transport = new hl.HttpTransport(); // or WebSocketTransport
329
347
  * const client = new hl.PublicClient({ transport });
330
348
  *
331
- * const historicalOrders = await client.historicalOrders({ user: "0x..." });
349
+ * const isVip = await client.isVip({ user: "0x..." });
332
350
  * ```
333
351
  */
334
- historicalOrders(args: HistoricalOrdersParameters, signal?: AbortSignal): Promise<OrderStatus<FrontendOrder>[]>;
352
+ isVip(args: IsVipParameters, signal?: AbortSignal): Promise<boolean>;
335
353
  /**
336
354
  * Request L2 order book.
337
355
  * @param args - The parameters for the request.
@@ -457,12 +475,12 @@ export declare class PublicClient<T extends IRequestTransport = IRequestTranspor
457
475
  */
458
476
  orderStatus(args: OrderStatusParameters, signal?: AbortSignal): Promise<OrderLookup>;
459
477
  /**
460
- * Request portfolio.
478
+ * Request perpetuals at open interest cap.
461
479
  * @param args - The parameters for the request.
462
480
  * @param signal - An optional abort signal.
463
- * @returns Portfolio of a user.
481
+ * @returns Array of perpetuals at open interest caps.
464
482
  *
465
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-portfolio
483
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#query-perps-at-open-interest-caps
466
484
  * @example
467
485
  * ```ts
468
486
  * import * as hl from "@nktkas/hyperliquid";
@@ -470,17 +488,17 @@ export declare class PublicClient<T extends IRequestTransport = IRequestTranspor
470
488
  * const transport = new hl.HttpTransport(); // or WebSocketTransport
471
489
  * const client = new hl.PublicClient({ transport });
472
490
  *
473
- * const portfolio = await client.portfolio({ user: "0x..." });
491
+ * const perpsAtOpenInterestCap = await client.perpsAtOpenInterestCap();
474
492
  * ```
475
493
  */
476
- portfolio(args: PortfolioParameters, signal?: AbortSignal): Promise<PortfolioPeriods>;
494
+ perpsAtOpenInterestCap(signal?: AbortSignal): Promise<string[]>;
477
495
  /**
478
- * Request user's existence check before transfer.
496
+ * Request portfolio.
479
497
  * @param args - The parameters for the request.
480
498
  * @param signal - An optional abort signal.
481
- * @returns Pre-transfer user existence check result.
499
+ * @returns Portfolio of a user.
482
500
  *
483
- * @see null - no documentation
501
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-portfolio
484
502
  * @example
485
503
  * ```ts
486
504
  * import * as hl from "@nktkas/hyperliquid";
@@ -488,17 +506,16 @@ export declare class PublicClient<T extends IRequestTransport = IRequestTranspor
488
506
  * const transport = new hl.HttpTransport(); // or WebSocketTransport
489
507
  * const client = new hl.PublicClient({ transport });
490
508
  *
491
- * const preTransferCheck = await client.preTransferCheck({ user: "0x...", source: "0x..." });
509
+ * const portfolio = await client.portfolio({ user: "0x..." });
492
510
  * ```
493
511
  */
494
- preTransferCheck(args: PreTransferCheckParameters, signal?: AbortSignal): Promise<PreTransferCheck>;
512
+ portfolio(args: PortfolioParameters, signal?: AbortSignal): Promise<PortfolioPeriods>;
495
513
  /**
496
- * Request perpetuals at open interest cap.
497
- * @param args - The parameters for the request.
514
+ * Request predicted funding rates.
498
515
  * @param signal - An optional abort signal.
499
- * @returns Array of perpetuals at open interest caps.
516
+ * @returns Array of predicted funding rates.
500
517
  *
501
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#query-perps-at-open-interest-caps
518
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-predicted-funding-rates-for-different-venues
502
519
  * @example
503
520
  * ```ts
504
521
  * import * as hl from "@nktkas/hyperliquid";
@@ -506,16 +523,17 @@ export declare class PublicClient<T extends IRequestTransport = IRequestTranspor
506
523
  * const transport = new hl.HttpTransport(); // or WebSocketTransport
507
524
  * const client = new hl.PublicClient({ transport });
508
525
  *
509
- * const perpsAtOpenInterestCap = await client.perpsAtOpenInterestCap();
526
+ * const predictedFundings = await client.predictedFundings();
510
527
  * ```
511
528
  */
512
- perpsAtOpenInterestCap(signal?: AbortSignal): Promise<string[]>;
529
+ predictedFundings(signal?: AbortSignal): Promise<PredictedFunding[]>;
513
530
  /**
514
- * Request predicted funding rates.
531
+ * Request user's existence check before transfer.
532
+ * @param args - The parameters for the request.
515
533
  * @param signal - An optional abort signal.
516
- * @returns Array of predicted funding rates.
534
+ * @returns Pre-transfer user existence check result.
517
535
  *
518
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-predicted-funding-rates-for-different-venues
536
+ * @see null - no documentation
519
537
  * @example
520
538
  * ```ts
521
539
  * import * as hl from "@nktkas/hyperliquid";
@@ -523,10 +541,10 @@ export declare class PublicClient<T extends IRequestTransport = IRequestTranspor
523
541
  * const transport = new hl.HttpTransport(); // or WebSocketTransport
524
542
  * const client = new hl.PublicClient({ transport });
525
543
  *
526
- * const predictedFundings = await client.predictedFundings();
544
+ * const preTransferCheck = await client.preTransferCheck({ user: "0x...", source: "0x..." });
527
545
  * ```
528
546
  */
529
- predictedFundings(signal?: AbortSignal): Promise<PredictedFunding[]>;
547
+ preTransferCheck(args: PreTransferCheckParameters, signal?: AbortSignal): Promise<PreTransferCheck>;
530
548
  /**
531
549
  * Request user referral.
532
550
  * @param args - The parameters for the request.
@@ -669,6 +687,42 @@ export declare class PublicClient<T extends IRequestTransport = IRequestTranspor
669
687
  * ```
670
688
  */
671
689
  twapHistory(args: TwapHistoryParameters, signal?: AbortSignal): Promise<TwapHistory[]>;
690
+ /**
691
+ * Transaction details by transaction hash.
692
+ * @param args - The parameters for the request.
693
+ * @param signal - An optional abort signal.
694
+ * @returns Transaction details response.
695
+ *
696
+ * @see null - no documentation
697
+ * @example
698
+ * ```ts
699
+ * import * as hl from "@nktkas/hyperliquid";
700
+ *
701
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
702
+ * const client = new hl.PublicClient({ transport });
703
+ *
704
+ * const { tx } = await client.txDetails({ hash: "0x..." });
705
+ * ```
706
+ */
707
+ txDetails(args: TxDetailsParameters, signal?: AbortSignal): Promise<TxDetailsResponse>;
708
+ /**
709
+ * User details by user's address.
710
+ * @param args - The parameters for the request.
711
+ * @param signal - An optional abort signal.
712
+ * @returns User details response.
713
+ *
714
+ * @see null - no documentation
715
+ * @example
716
+ * ```ts
717
+ * import * as hl from "@nktkas/hyperliquid";
718
+ *
719
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
720
+ * const client = new hl.PublicClient({ transport });
721
+ *
722
+ * const { txs } = await client.userDetails({ user: "0x..." });
723
+ * ```
724
+ */
725
+ userDetails(args: UserDetailsParameters, signal?: AbortSignal): Promise<UserDetailsResponse>;
672
726
  /**
673
727
  * Request user fees.
674
728
  * @param args - The parameters for the request.
@@ -932,59 +986,5 @@ export declare class PublicClient<T extends IRequestTransport = IRequestTranspor
932
986
  * ```
933
987
  */
934
988
  vaultSummaries(signal?: AbortSignal): Promise<VaultSummary[]>;
935
- /**
936
- * Block details by block height.
937
- * @param args - The parameters for the request.
938
- * @param signal - An optional abort signal.
939
- * @returns Block details response.
940
- *
941
- * @see null - no documentation
942
- * @example
943
- * ```ts
944
- * import * as hl from "@nktkas/hyperliquid";
945
- *
946
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
947
- * const client = new hl.PublicClient({ transport });
948
- *
949
- * const { blockDetails } = await client.blockDetails({ height: 123 });
950
- * ```
951
- */
952
- blockDetails(args: BlockDetailsParameters, signal?: AbortSignal): Promise<BlockDetailsResponse>;
953
- /**
954
- * Transaction details by transaction hash.
955
- * @param args - The parameters for the request.
956
- * @param signal - An optional abort signal.
957
- * @returns Transaction details response.
958
- *
959
- * @see null - no documentation
960
- * @example
961
- * ```ts
962
- * import * as hl from "@nktkas/hyperliquid";
963
- *
964
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
965
- * const client = new hl.PublicClient({ transport });
966
- *
967
- * const { tx } = await client.txDetails({ hash: "0x..." });
968
- * ```
969
- */
970
- txDetails(args: TxDetailsParameters, signal?: AbortSignal): Promise<TxDetailsResponse>;
971
- /**
972
- * User details by user's address.
973
- * @param args - The parameters for the request.
974
- * @param signal - An optional abort signal.
975
- * @returns User details response.
976
- *
977
- * @see null - no documentation
978
- * @example
979
- * ```ts
980
- * import * as hl from "@nktkas/hyperliquid";
981
- *
982
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
983
- * const client = new hl.PublicClient({ transport });
984
- *
985
- * const { txs } = await client.userDetails({ user: "0x..." });
986
- * ```
987
- */
988
- userDetails(args: UserDetailsParameters, signal?: AbortSignal): Promise<UserDetailsResponse>;
989
989
  }
990
990
  //# sourceMappingURL=public.d.ts.map