@chainflip/utils 0.4.10 → 0.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/consts.cjs CHANGED
@@ -143,7 +143,8 @@ var GENESIS_LP_ACCOUNT_IDS = [
143
143
  // backspin
144
144
  "cFPdef3hF5zEwbWUG6ZaCJ3X7mTvEeAog7HxZ8QyFcCgDVGDM",
145
145
  "cFMzM1G4He5k3Aa58X6d8yo8hRxiMVd92qrXMu1zKBXCqqTxi",
146
- "cFL8fmgKZcchhtLagBH2GKfsuWxBqUaD5CYE1m7DFb8DBSLJ1"
146
+ "cFL8fmgKZcchhtLagBH2GKfsuWxBqUaD5CYE1m7DFb8DBSLJ1",
147
+ "cFJt3kyUdXvaoarfxJDLrFmHFqkXUgnVZ4zqqDLLTRjbJosmK"
147
148
  ];
148
149
  // Annotate the CommonJS export names for ESM import in node:
149
150
  0 && (module.exports = {
package/dist/consts.js CHANGED
@@ -110,7 +110,8 @@ var GENESIS_LP_ACCOUNT_IDS = [
110
110
  // backspin
111
111
  "cFPdef3hF5zEwbWUG6ZaCJ3X7mTvEeAog7HxZ8QyFcCgDVGDM",
112
112
  "cFMzM1G4He5k3Aa58X6d8yo8hRxiMVd92qrXMu1zKBXCqqTxi",
113
- "cFL8fmgKZcchhtLagBH2GKfsuWxBqUaD5CYE1m7DFb8DBSLJ1"
113
+ "cFL8fmgKZcchhtLagBH2GKfsuWxBqUaD5CYE1m7DFb8DBSLJ1",
114
+ "cFJt3kyUdXvaoarfxJDLrFmHFqkXUgnVZ4zqqDLLTRjbJosmK"
114
115
  ];
115
116
  export {
116
117
  CHAINFLIP_BLOCKS_PER_YEAR,
package/dist/ss58.cjs CHANGED
@@ -26,37 +26,37 @@ __export(ss58_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(ss58_exports);
28
28
 
29
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/_assert.js
30
- function number(n) {
29
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.1/node_modules/@noble/hashes/esm/_assert.js
30
+ function anumber(n) {
31
31
  if (!Number.isSafeInteger(n) || n < 0)
32
- throw new Error(`positive integer expected, not ${n}`);
32
+ throw new Error("positive integer expected, got " + n);
33
33
  }
34
34
  function isBytes(a) {
35
- return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
35
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
36
36
  }
37
- function bytes(b, ...lengths) {
37
+ function abytes(b, ...lengths) {
38
38
  if (!isBytes(b))
39
39
  throw new Error("Uint8Array expected");
40
40
  if (lengths.length > 0 && !lengths.includes(b.length))
41
- throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
41
+ throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
42
42
  }
43
- function exists(instance, checkFinished = true) {
43
+ function aexists(instance, checkFinished = true) {
44
44
  if (instance.destroyed)
45
45
  throw new Error("Hash instance has been destroyed");
46
46
  if (checkFinished && instance.finished)
47
47
  throw new Error("Hash#digest() has already been called");
48
48
  }
49
- function output(out, instance) {
50
- bytes(out);
49
+ function aoutput(out, instance) {
50
+ abytes(out);
51
51
  const min = instance.outputLen;
52
52
  if (out.length < min) {
53
- throw new Error(`digestInto() expects output buffer of length at least ${min}`);
53
+ throw new Error("digestInto() expects output buffer of length at least " + min);
54
54
  }
55
55
  }
56
56
 
57
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/utils.js
57
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.1/node_modules/@noble/hashes/esm/utils.js
58
58
  var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
59
- var isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
59
+ var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
60
60
  var byteSwap = (word) => word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
61
61
  var byteSwapIfBE = isLE ? (n) => n : (n) => byteSwap(n);
62
62
  function byteSwap32(arr) {
@@ -66,13 +66,13 @@ function byteSwap32(arr) {
66
66
  }
67
67
  function utf8ToBytes(str) {
68
68
  if (typeof str !== "string")
69
- throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
69
+ throw new Error("utf8ToBytes expected string, got " + typeof str);
70
70
  return new Uint8Array(new TextEncoder().encode(str));
71
71
  }
72
72
  function toBytes(data) {
73
73
  if (typeof data === "string")
74
74
  data = utf8ToBytes(data);
75
- bytes(data);
75
+ abytes(data);
76
76
  return data;
77
77
  }
78
78
  var Hash = class {
@@ -81,7 +81,6 @@ var Hash = class {
81
81
  return this._cloneInto();
82
82
  }
83
83
  };
84
- var toStr = {}.toString;
85
84
  function wrapConstructorWithOpts(hashCons) {
86
85
  const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
87
86
  const tmp = hashCons({});
@@ -91,7 +90,7 @@ function wrapConstructorWithOpts(hashCons) {
91
90
  return hashC;
92
91
  }
93
92
 
94
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/_blake.js
93
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.1/node_modules/@noble/hashes/esm/_blake.js
95
94
  var SIGMA = /* @__PURE__ */ new Uint8Array([
96
95
  0,
97
96
  1,
@@ -295,21 +294,22 @@ var BLAKE = class extends Hash {
295
294
  this.pos = 0;
296
295
  this.finished = false;
297
296
  this.destroyed = false;
298
- number(blockLen);
299
- number(outputLen);
300
- number(keyLen);
297
+ anumber(blockLen);
298
+ anumber(outputLen);
299
+ anumber(keyLen);
301
300
  if (outputLen < 0 || outputLen > keyLen)
302
301
  throw new Error("outputLen bigger than keyLen");
303
302
  if (opts.key !== void 0 && (opts.key.length < 1 || opts.key.length > keyLen))
304
- throw new Error(`key must be up 1..${keyLen} byte long or undefined`);
303
+ throw new Error("key length must be undefined or 1.." + keyLen);
305
304
  if (opts.salt !== void 0 && opts.salt.length !== saltLen)
306
- throw new Error(`salt must be ${saltLen} byte long or undefined`);
305
+ throw new Error("salt must be undefined or " + saltLen);
307
306
  if (opts.personalization !== void 0 && opts.personalization.length !== persLen)
308
- throw new Error(`personalization must be ${persLen} byte long or undefined`);
309
- this.buffer32 = u32(this.buffer = new Uint8Array(blockLen));
307
+ throw new Error("personalization must be undefined or " + persLen);
308
+ this.buffer = new Uint8Array(blockLen);
309
+ this.buffer32 = u32(this.buffer);
310
310
  }
311
311
  update(data) {
312
- exists(this);
312
+ aexists(this);
313
313
  const { blockLen, buffer, buffer32 } = this;
314
314
  data = toBytes(data);
315
315
  const len = data.length;
@@ -346,8 +346,8 @@ var BLAKE = class extends Hash {
346
346
  return this;
347
347
  }
348
348
  digestInto(out) {
349
- exists(this);
350
- output(out, this);
349
+ aexists(this);
350
+ aoutput(out, this);
351
351
  const { pos, buffer32 } = this;
352
352
  this.finished = true;
353
353
  this.buffer.subarray(pos).fill(0);
@@ -380,7 +380,7 @@ var BLAKE = class extends Hash {
380
380
  }
381
381
  };
382
382
 
383
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/_u64.js
383
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.1/node_modules/@noble/hashes/esm/_u64.js
384
384
  var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
385
385
  var _32n = /* @__PURE__ */ BigInt(32);
386
386
  function fromBig(n, le = false) {
@@ -446,7 +446,7 @@ var u64 = {
446
446
  };
447
447
  var u64_default = u64;
448
448
 
449
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/blake2b.js
449
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.1/node_modules/@noble/hashes/esm/blake2b.js
450
450
  var B2B_IV = /* @__PURE__ */ new Uint32Array([
451
451
  4089235720,
452
452
  1779033703,
@@ -644,21 +644,21 @@ function assert(condition, message = "assertion failed", Constructor = Error) {
644
644
 
645
645
  // src/bytes.ts
646
646
  var bytesToHex = (input) => {
647
- const bytes2 = new Uint8Array(input);
648
- return `0x${Array.from(bytes2).map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
647
+ const bytes = new Uint8Array(input);
648
+ return `0x${Array.from(bytes).map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
649
649
  };
650
650
  var hexToBytes = (input) => {
651
651
  assert(/^0x[\da-f]*$/i.test(input) && input.length % 2 === 0, "Invalid hex string");
652
652
  const hex = input.slice(2);
653
- const bytes2 = new Uint8Array(hex.length / 2);
653
+ const bytes = new Uint8Array(hex.length / 2);
654
654
  for (let i = 0; i < hex.length; i += 2) {
655
- bytes2[i / 2] = Number.parseInt(hex.slice(i, i + 2), 16);
655
+ bytes[i / 2] = Number.parseInt(hex.slice(i, i + 2), 16);
656
656
  }
657
- return bytes2;
657
+ return bytes;
658
658
  };
659
- var convertBase = (bytes2, fromBase, toBase) => {
659
+ var convertBase = (bytes, fromBase, toBase) => {
660
660
  const result = [];
661
- for (const byte of bytes2) {
661
+ for (const byte of bytes) {
662
662
  let carry = byte;
663
663
  for (let i = 0; i < result.length; i += 1) {
664
664
  carry += result[i] * fromBase;
@@ -671,23 +671,23 @@ var convertBase = (bytes2, fromBase, toBase) => {
671
671
  }
672
672
  }
673
673
  let leadingZeros = 0;
674
- while (bytes2[leadingZeros] === 0) {
674
+ while (bytes[leadingZeros] === 0) {
675
675
  leadingZeros += 1;
676
676
  result.push(0);
677
677
  }
678
678
  return result.reverse();
679
679
  };
680
- var encodeBytesWithCharset = (bytes2, charset2) => convertBase(bytes2, 256, charset2.length).map((charCode) => charset2.charAt(charCode)).join("");
680
+ var encodeBytesWithCharset = (bytes, charset2) => convertBase(bytes, 256, charset2.length).map((charCode) => charset2.charAt(charCode)).join("");
681
681
  var decodeBytesWithCharset = (input, charset2) => {
682
682
  assert(new RegExp(`^[${charset2}]*$`).test(input), "Invalid input");
683
683
  const charMap = Object.fromEntries([...charset2].map((char, index) => [char, index]));
684
- const bytes2 = input.split("").map((char) => charMap[char]);
685
- return new Uint8Array(convertBase(bytes2, charset2.length, 256));
684
+ const bytes = input.split("").map((char) => charMap[char]);
685
+ return new Uint8Array(convertBase(bytes, charset2.length, 256));
686
686
  };
687
687
 
688
688
  // src/base58.ts
689
689
  var charset = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
690
- var encode = (bytes2) => encodeBytesWithCharset(bytes2, charset);
690
+ var encode = (bytes) => encodeBytesWithCharset(bytes, charset);
691
691
  var decode = (input) => decodeBytesWithCharset(input, charset);
692
692
 
693
693
  // src/ss58.ts
package/dist/ss58.js CHANGED
@@ -11,37 +11,37 @@ import {
11
11
  } from "./chunk-ZHIKNZLU.js";
12
12
  import "./chunk-HBIFE4XN.js";
13
13
 
14
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/_assert.js
15
- function number(n) {
14
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.1/node_modules/@noble/hashes/esm/_assert.js
15
+ function anumber(n) {
16
16
  if (!Number.isSafeInteger(n) || n < 0)
17
- throw new Error(`positive integer expected, not ${n}`);
17
+ throw new Error("positive integer expected, got " + n);
18
18
  }
19
19
  function isBytes(a) {
20
- return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
20
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
21
21
  }
22
- function bytes(b, ...lengths) {
22
+ function abytes(b, ...lengths) {
23
23
  if (!isBytes(b))
24
24
  throw new Error("Uint8Array expected");
25
25
  if (lengths.length > 0 && !lengths.includes(b.length))
26
- throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
26
+ throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
27
27
  }
28
- function exists(instance, checkFinished = true) {
28
+ function aexists(instance, checkFinished = true) {
29
29
  if (instance.destroyed)
30
30
  throw new Error("Hash instance has been destroyed");
31
31
  if (checkFinished && instance.finished)
32
32
  throw new Error("Hash#digest() has already been called");
33
33
  }
34
- function output(out, instance) {
35
- bytes(out);
34
+ function aoutput(out, instance) {
35
+ abytes(out);
36
36
  const min = instance.outputLen;
37
37
  if (out.length < min) {
38
- throw new Error(`digestInto() expects output buffer of length at least ${min}`);
38
+ throw new Error("digestInto() expects output buffer of length at least " + min);
39
39
  }
40
40
  }
41
41
 
42
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/utils.js
42
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.1/node_modules/@noble/hashes/esm/utils.js
43
43
  var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
44
- var isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
44
+ var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
45
45
  var byteSwap = (word) => word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
46
46
  var byteSwapIfBE = isLE ? (n) => n : (n) => byteSwap(n);
47
47
  function byteSwap32(arr) {
@@ -51,13 +51,13 @@ function byteSwap32(arr) {
51
51
  }
52
52
  function utf8ToBytes(str) {
53
53
  if (typeof str !== "string")
54
- throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
54
+ throw new Error("utf8ToBytes expected string, got " + typeof str);
55
55
  return new Uint8Array(new TextEncoder().encode(str));
56
56
  }
57
57
  function toBytes(data) {
58
58
  if (typeof data === "string")
59
59
  data = utf8ToBytes(data);
60
- bytes(data);
60
+ abytes(data);
61
61
  return data;
62
62
  }
63
63
  var Hash = class {
@@ -66,7 +66,6 @@ var Hash = class {
66
66
  return this._cloneInto();
67
67
  }
68
68
  };
69
- var toStr = {}.toString;
70
69
  function wrapConstructorWithOpts(hashCons) {
71
70
  const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
72
71
  const tmp = hashCons({});
@@ -76,7 +75,7 @@ function wrapConstructorWithOpts(hashCons) {
76
75
  return hashC;
77
76
  }
78
77
 
79
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/_blake.js
78
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.1/node_modules/@noble/hashes/esm/_blake.js
80
79
  var SIGMA = /* @__PURE__ */ new Uint8Array([
81
80
  0,
82
81
  1,
@@ -280,21 +279,22 @@ var BLAKE = class extends Hash {
280
279
  this.pos = 0;
281
280
  this.finished = false;
282
281
  this.destroyed = false;
283
- number(blockLen);
284
- number(outputLen);
285
- number(keyLen);
282
+ anumber(blockLen);
283
+ anumber(outputLen);
284
+ anumber(keyLen);
286
285
  if (outputLen < 0 || outputLen > keyLen)
287
286
  throw new Error("outputLen bigger than keyLen");
288
287
  if (opts.key !== void 0 && (opts.key.length < 1 || opts.key.length > keyLen))
289
- throw new Error(`key must be up 1..${keyLen} byte long or undefined`);
288
+ throw new Error("key length must be undefined or 1.." + keyLen);
290
289
  if (opts.salt !== void 0 && opts.salt.length !== saltLen)
291
- throw new Error(`salt must be ${saltLen} byte long or undefined`);
290
+ throw new Error("salt must be undefined or " + saltLen);
292
291
  if (opts.personalization !== void 0 && opts.personalization.length !== persLen)
293
- throw new Error(`personalization must be ${persLen} byte long or undefined`);
294
- this.buffer32 = u32(this.buffer = new Uint8Array(blockLen));
292
+ throw new Error("personalization must be undefined or " + persLen);
293
+ this.buffer = new Uint8Array(blockLen);
294
+ this.buffer32 = u32(this.buffer);
295
295
  }
296
296
  update(data) {
297
- exists(this);
297
+ aexists(this);
298
298
  const { blockLen, buffer, buffer32 } = this;
299
299
  data = toBytes(data);
300
300
  const len = data.length;
@@ -331,8 +331,8 @@ var BLAKE = class extends Hash {
331
331
  return this;
332
332
  }
333
333
  digestInto(out) {
334
- exists(this);
335
- output(out, this);
334
+ aexists(this);
335
+ aoutput(out, this);
336
336
  const { pos, buffer32 } = this;
337
337
  this.finished = true;
338
338
  this.buffer.subarray(pos).fill(0);
@@ -365,7 +365,7 @@ var BLAKE = class extends Hash {
365
365
  }
366
366
  };
367
367
 
368
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/_u64.js
368
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.1/node_modules/@noble/hashes/esm/_u64.js
369
369
  var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
370
370
  var _32n = /* @__PURE__ */ BigInt(32);
371
371
  function fromBig(n, le = false) {
@@ -431,7 +431,7 @@ var u64 = {
431
431
  };
432
432
  var u64_default = u64;
433
433
 
434
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/blake2b.js
434
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.1/node_modules/@noble/hashes/esm/blake2b.js
435
435
  var B2B_IV = /* @__PURE__ */ new Uint32Array([
436
436
  4089235720,
437
437
  1779033703,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/utils",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -19,7 +19,7 @@
19
19
  }
20
20
  },
21
21
  "devDependencies": {
22
- "@noble/hashes": "^1.5.0",
22
+ "@noble/hashes": "^1.6.1",
23
23
  "@vitest/ui": "2.1.5"
24
24
  },
25
25
  "dependencies": {