@chainflip/utils 0.8.18 → 0.8.20

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.
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/addresses.ts
21
+ var addresses_exports = {};
22
+ __export(addresses_exports, {
23
+ FLIP_CONTRACT_ADDRESSES: () => FLIP_CONTRACT_ADDRESSES,
24
+ STATE_CHAIN_GATEWAY_ADDRESSES: () => STATE_CHAIN_GATEWAY_ADDRESSES
25
+ });
26
+ module.exports = __toCommonJS(addresses_exports);
27
+ var FLIP_CONTRACT_ADDRESSES = {
28
+ backspin: "0x10C6E9530F1C1AF873a391030a1D9E8ed0630D26",
29
+ sisyphos: "0xcD079EAB6B5443b545788Fd210C8800FEADd87fa",
30
+ perseverance: "0xdC27c60956cB065D19F08bb69a707E37b36d8086",
31
+ mainnet: "0x826180541412D574cf1336d22c0C0a287822678A"
32
+ };
33
+ var STATE_CHAIN_GATEWAY_ADDRESSES = {
34
+ backspin: "0xeEBe00Ac0756308ac4AaBfD76c05c4F3088B8883",
35
+ sisyphos: "0x1F7fE41C798cc7b1D34BdC8de2dDDA4a4bE744D9",
36
+ perseverance: "0xA34a967197Ee90BB7fb28e928388a573c5CFd099",
37
+ mainnet: "0x6995Ab7c4D7F4B03f467Cf4c8E920427d9621DBd"
38
+ };
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ FLIP_CONTRACT_ADDRESSES,
42
+ STATE_CHAIN_GATEWAY_ADDRESSES
43
+ });
@@ -0,0 +1,6 @@
1
+ import { ChainflipNetwork } from './chainflip.cjs';
2
+
3
+ declare const FLIP_CONTRACT_ADDRESSES: Record<ChainflipNetwork, `0x${string}`>;
4
+ declare const STATE_CHAIN_GATEWAY_ADDRESSES: Record<ChainflipNetwork, `0x${string}`>;
5
+
6
+ export { FLIP_CONTRACT_ADDRESSES, STATE_CHAIN_GATEWAY_ADDRESSES };
@@ -0,0 +1,6 @@
1
+ import { ChainflipNetwork } from './chainflip.js';
2
+
3
+ declare const FLIP_CONTRACT_ADDRESSES: Record<ChainflipNetwork, `0x${string}`>;
4
+ declare const STATE_CHAIN_GATEWAY_ADDRESSES: Record<ChainflipNetwork, `0x${string}`>;
5
+
6
+ export { FLIP_CONTRACT_ADDRESSES, STATE_CHAIN_GATEWAY_ADDRESSES };
@@ -0,0 +1,17 @@
1
+ // src/addresses.ts
2
+ var FLIP_CONTRACT_ADDRESSES = {
3
+ backspin: "0x10C6E9530F1C1AF873a391030a1D9E8ed0630D26",
4
+ sisyphos: "0xcD079EAB6B5443b545788Fd210C8800FEADd87fa",
5
+ perseverance: "0xdC27c60956cB065D19F08bb69a707E37b36d8086",
6
+ mainnet: "0x826180541412D574cf1336d22c0C0a287822678A"
7
+ };
8
+ var STATE_CHAIN_GATEWAY_ADDRESSES = {
9
+ backspin: "0xeEBe00Ac0756308ac4AaBfD76c05c4F3088B8883",
10
+ sisyphos: "0x1F7fE41C798cc7b1D34BdC8de2dDDA4a4bE744D9",
11
+ perseverance: "0xA34a967197Ee90BB7fb28e928388a573c5CFd099",
12
+ mainnet: "0x6995Ab7c4D7F4B03f467Cf4c8E920427d9621DBd"
13
+ };
14
+ export {
15
+ FLIP_CONTRACT_ADDRESSES,
16
+ STATE_CHAIN_GATEWAY_ADDRESSES
17
+ };
@@ -27,6 +27,7 @@ __export(chainflip_exports, {
27
27
  baseChainflipAssets: () => baseChainflipAssets,
28
28
  chainConstants: () => chainConstants,
29
29
  chainContractId: () => chainContractId,
30
+ chainflipAssetToPriceAssetMap: () => chainflipAssetToPriceAssetMap,
30
31
  chainflipAssets: () => chainflipAssets,
31
32
  chainflipChains: () => chainflipChains,
32
33
  chainflipEvmChains: () => chainflipEvmChains,
@@ -298,6 +299,21 @@ function getInternalAssets({
298
299
  destAsset: getInternalAsset({ asset: destAsset, chain: destChain }, assert)
299
300
  };
300
301
  }
302
+ var chainflipAssetToPriceAssetMap = {
303
+ Btc: "Btc",
304
+ Sol: "Sol",
305
+ Eth: "Eth",
306
+ ArbEth: "Eth",
307
+ Usdc: "Usdc",
308
+ ArbUsdc: "Usdc",
309
+ SolUsdc: "Usdc",
310
+ HubUsdc: "Usdc",
311
+ Usdt: "Usdt",
312
+ HubUsdt: "Usdt",
313
+ Dot: null,
314
+ Flip: null,
315
+ HubDot: null
316
+ };
301
317
  // Annotate the CommonJS export names for ESM import in node:
302
318
  0 && (module.exports = {
303
319
  addressTypes,
@@ -307,6 +323,7 @@ function getInternalAssets({
307
323
  baseChainflipAssets,
308
324
  chainConstants,
309
325
  chainContractId,
326
+ chainflipAssetToPriceAssetMap,
310
327
  chainflipAssets,
311
328
  chainflipChains,
312
329
  chainflipEvmChains,
@@ -222,5 +222,6 @@ declare function getInternalAssets(data: {
222
222
  srcAsset: ChainflipAsset | null;
223
223
  destAsset: ChainflipAsset | null;
224
224
  };
225
+ declare const chainflipAssetToPriceAssetMap: Record<ChainflipAsset, Exclude<PriceAsset, 'Usd'> | null>;
225
226
 
226
- export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseAssetAndChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type PriceAsset, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, priceAssets, readAssetValue, rpcAssets };
227
+ export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseAssetAndChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type PriceAsset, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssetToPriceAssetMap, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, priceAssets, readAssetValue, rpcAssets };
@@ -222,5 +222,6 @@ declare function getInternalAssets(data: {
222
222
  srcAsset: ChainflipAsset | null;
223
223
  destAsset: ChainflipAsset | null;
224
224
  };
225
+ declare const chainflipAssetToPriceAssetMap: Record<ChainflipAsset, Exclude<PriceAsset, 'Usd'> | null>;
225
226
 
226
- export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseAssetAndChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type PriceAsset, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, priceAssets, readAssetValue, rpcAssets };
227
+ export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseAssetAndChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type PriceAsset, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssetToPriceAssetMap, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, priceAssets, readAssetValue, rpcAssets };
package/dist/chainflip.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  baseChainflipAssets,
7
7
  chainConstants,
8
8
  chainContractId,
9
+ chainflipAssetToPriceAssetMap,
9
10
  chainflipAssets,
10
11
  chainflipChains,
11
12
  chainflipEvmChains,
@@ -17,7 +18,7 @@ import {
17
18
  priceAssets,
18
19
  readAssetValue,
19
20
  rpcAssets
20
- } from "./chunk-DR3WTOBQ.js";
21
+ } from "./chunk-QLABW6HJ.js";
21
22
  export {
22
23
  addressTypes,
23
24
  assetConstants,
@@ -26,6 +27,7 @@ export {
26
27
  baseChainflipAssets,
27
28
  chainConstants,
28
29
  chainContractId,
30
+ chainflipAssetToPriceAssetMap,
29
31
  chainflipAssets,
30
32
  chainflipChains,
31
33
  chainflipEvmChains,
@@ -257,6 +257,21 @@ function getInternalAssets({
257
257
  destAsset: getInternalAsset({ asset: destAsset, chain: destChain }, assert)
258
258
  };
259
259
  }
260
+ var chainflipAssetToPriceAssetMap = {
261
+ Btc: "Btc",
262
+ Sol: "Sol",
263
+ Eth: "Eth",
264
+ ArbEth: "Eth",
265
+ Usdc: "Usdc",
266
+ ArbUsdc: "Usdc",
267
+ SolUsdc: "Usdc",
268
+ HubUsdc: "Usdc",
269
+ Usdt: "Usdt",
270
+ HubUsdt: "Usdt",
271
+ Dot: null,
272
+ Flip: null,
273
+ HubDot: null
274
+ };
260
275
 
261
276
  export {
262
277
  chainflipAssets,
@@ -276,5 +291,6 @@ export {
276
291
  assetContractId,
277
292
  getInternalAsset,
278
293
  isValidAssetAndChain,
279
- getInternalAssets
294
+ getInternalAssets,
295
+ chainflipAssetToPriceAssetMap
280
296
  };
package/dist/ss58.cjs CHANGED
@@ -26,19 +26,27 @@ __export(ss58_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(ss58_exports);
28
28
 
29
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
29
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.0/node_modules/@noble/hashes/utils.js
30
30
  function isBytes(a) {
31
31
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
32
32
  }
33
- function anumber(n) {
34
- if (!Number.isSafeInteger(n) || n < 0)
35
- throw new Error("positive integer expected, got " + n);
33
+ function anumber(n, title = "") {
34
+ if (!Number.isSafeInteger(n) || n < 0) {
35
+ const prefix = title && `"${title}" `;
36
+ throw new Error(`${prefix}expected integer >0, got ${n}`);
37
+ }
36
38
  }
37
- function abytes(b, ...lengths) {
38
- if (!isBytes(b))
39
- throw new Error("Uint8Array expected");
40
- if (lengths.length > 0 && !lengths.includes(b.length))
41
- throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
39
+ function abytes(value, length, title = "") {
40
+ const bytes = isBytes(value);
41
+ const len = value?.length;
42
+ const needsLen = length !== void 0;
43
+ if (!bytes || needsLen && len !== length) {
44
+ const prefix = title && `"${title}" `;
45
+ const ofLen = needsLen ? ` of length ${length}` : "";
46
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
47
+ throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
48
+ }
49
+ return value;
42
50
  }
43
51
  function aexists(instance, checkFinished = true) {
44
52
  if (instance.destroyed)
@@ -47,10 +55,10 @@ function aexists(instance, checkFinished = true) {
47
55
  throw new Error("Hash#digest() has already been called");
48
56
  }
49
57
  function aoutput(out, instance) {
50
- abytes(out);
58
+ abytes(out, void 0, "digestInto() output");
51
59
  const min = instance.outputLen;
52
60
  if (out.length < min) {
53
- throw new Error("digestInto() expects output buffer of length at least " + min);
61
+ throw new Error('"digestInto() output" expected to be of length >=' + min);
54
62
  }
55
63
  }
56
64
  function u32(arr) {
@@ -73,29 +81,17 @@ function byteSwap32(arr) {
73
81
  return arr;
74
82
  }
75
83
  var swap32IfBE = isLE ? (u) => u : byteSwap32;
76
- function utf8ToBytes(str) {
77
- if (typeof str !== "string")
78
- throw new Error("string expected");
79
- return new Uint8Array(new TextEncoder().encode(str));
80
- }
81
- function toBytes(data) {
82
- if (typeof data === "string")
83
- data = utf8ToBytes(data);
84
- abytes(data);
85
- return data;
86
- }
87
- var Hash = class {
88
- };
89
- function createOptHasher(hashCons) {
90
- const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
91
- const tmp = hashCons({});
84
+ function createHasher(hashCons, info = {}) {
85
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
86
+ const tmp = hashCons(void 0);
92
87
  hashC.outputLen = tmp.outputLen;
93
88
  hashC.blockLen = tmp.blockLen;
94
89
  hashC.create = (opts) => hashCons(opts);
95
- return hashC;
90
+ Object.assign(hashC, info);
91
+ return Object.freeze(hashC);
96
92
  }
97
93
 
98
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_blake.js
94
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.0/node_modules/@noble/hashes/_blake.js
99
95
  var BSIGMA = /* @__PURE__ */ Uint8Array.from([
100
96
  0,
101
97
  1,
@@ -356,7 +352,7 @@ var BSIGMA = /* @__PURE__ */ Uint8Array.from([
356
352
  9
357
353
  ]);
358
354
 
359
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
355
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.0/node_modules/@noble/hashes/_u64.js
360
356
  var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
361
357
  var _32n = /* @__PURE__ */ BigInt(32);
362
358
  function fromBig(n, le = false) {
@@ -377,7 +373,7 @@ function add(Ah, Al, Bh, Bl) {
377
373
  var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
378
374
  var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
379
375
 
380
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/blake2.js
376
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.0/node_modules/@noble/hashes/blake2.js
381
377
  var B2B_IV = /* @__PURE__ */ Uint32Array.from([
382
378
  4089235720,
383
379
  1779033703,
@@ -441,19 +437,22 @@ function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) {
441
437
  throw new Error("outputLen bigger than keyLen");
442
438
  const { key, salt, personalization } = opts;
443
439
  if (key !== void 0 && (key.length < 1 || key.length > keyLen))
444
- throw new Error("key length must be undefined or 1.." + keyLen);
445
- if (salt !== void 0 && salt.length !== saltLen)
446
- throw new Error("salt must be undefined or " + saltLen);
447
- if (personalization !== void 0 && personalization.length !== persLen)
448
- throw new Error("personalization must be undefined or " + persLen);
440
+ throw new Error('"key" expected to be undefined or of length=1..' + keyLen);
441
+ if (salt !== void 0)
442
+ abytes(salt, saltLen, "salt");
443
+ if (personalization !== void 0)
444
+ abytes(personalization, persLen, "personalization");
449
445
  }
450
- var BLAKE2 = class extends Hash {
446
+ var _BLAKE2 = class {
447
+ buffer;
448
+ buffer32;
449
+ finished = false;
450
+ destroyed = false;
451
+ length = 0;
452
+ pos = 0;
453
+ blockLen;
454
+ outputLen;
451
455
  constructor(blockLen, outputLen) {
452
- super();
453
- this.finished = false;
454
- this.destroyed = false;
455
- this.length = 0;
456
- this.pos = 0;
457
456
  anumber(blockLen);
458
457
  anumber(outputLen);
459
458
  this.blockLen = blockLen;
@@ -463,7 +462,6 @@ var BLAKE2 = class extends Hash {
463
462
  }
464
463
  update(data) {
465
464
  aexists(this);
466
- data = toBytes(data);
467
465
  abytes(data);
468
466
  const { blockLen, buffer, buffer32 } = this;
469
467
  const len = data.length;
@@ -516,7 +514,7 @@ var BLAKE2 = class extends Hash {
516
514
  }
517
515
  _cloneInto(to) {
518
516
  const { buffer, length, finished, destroyed, outputLen, pos } = this;
519
- to || (to = new this.constructor({ dkLen: outputLen }));
517
+ to ||= new this.constructor({ dkLen: outputLen });
520
518
  to.set(...this.get());
521
519
  to.buffer.set(buffer);
522
520
  to.destroyed = destroyed;
@@ -530,36 +528,37 @@ var BLAKE2 = class extends Hash {
530
528
  return this._cloneInto();
531
529
  }
532
530
  };
533
- var BLAKE2b = class extends BLAKE2 {
531
+ var _BLAKE2b = class extends _BLAKE2 {
532
+ // Same as SHA-512, but LE
533
+ v0l = B2B_IV[0] | 0;
534
+ v0h = B2B_IV[1] | 0;
535
+ v1l = B2B_IV[2] | 0;
536
+ v1h = B2B_IV[3] | 0;
537
+ v2l = B2B_IV[4] | 0;
538
+ v2h = B2B_IV[5] | 0;
539
+ v3l = B2B_IV[6] | 0;
540
+ v3h = B2B_IV[7] | 0;
541
+ v4l = B2B_IV[8] | 0;
542
+ v4h = B2B_IV[9] | 0;
543
+ v5l = B2B_IV[10] | 0;
544
+ v5h = B2B_IV[11] | 0;
545
+ v6l = B2B_IV[12] | 0;
546
+ v6h = B2B_IV[13] | 0;
547
+ v7l = B2B_IV[14] | 0;
548
+ v7h = B2B_IV[15] | 0;
534
549
  constructor(opts = {}) {
535
550
  const olen = opts.dkLen === void 0 ? 64 : opts.dkLen;
536
551
  super(128, olen);
537
- this.v0l = B2B_IV[0] | 0;
538
- this.v0h = B2B_IV[1] | 0;
539
- this.v1l = B2B_IV[2] | 0;
540
- this.v1h = B2B_IV[3] | 0;
541
- this.v2l = B2B_IV[4] | 0;
542
- this.v2h = B2B_IV[5] | 0;
543
- this.v3l = B2B_IV[6] | 0;
544
- this.v3h = B2B_IV[7] | 0;
545
- this.v4l = B2B_IV[8] | 0;
546
- this.v4h = B2B_IV[9] | 0;
547
- this.v5l = B2B_IV[10] | 0;
548
- this.v5h = B2B_IV[11] | 0;
549
- this.v6l = B2B_IV[12] | 0;
550
- this.v6h = B2B_IV[13] | 0;
551
- this.v7l = B2B_IV[14] | 0;
552
- this.v7h = B2B_IV[15] | 0;
553
552
  checkBlake2Opts(olen, opts, 64, 16, 16);
554
553
  let { key, personalization, salt } = opts;
555
554
  let keyLength = 0;
556
555
  if (key !== void 0) {
557
- key = toBytes(key);
556
+ abytes(key, void 0, "key");
558
557
  keyLength = key.length;
559
558
  }
560
559
  this.v0l ^= this.outputLen | keyLength << 8 | 1 << 16 | 1 << 24;
561
560
  if (salt !== void 0) {
562
- salt = toBytes(salt);
561
+ abytes(salt, void 0, "salt");
563
562
  const slt = u32(salt);
564
563
  this.v4l ^= swap8IfBE(slt[0]);
565
564
  this.v4h ^= swap8IfBE(slt[1]);
@@ -567,7 +566,7 @@ var BLAKE2b = class extends BLAKE2 {
567
566
  this.v5h ^= swap8IfBE(slt[3]);
568
567
  }
569
568
  if (personalization !== void 0) {
570
- personalization = toBytes(personalization);
569
+ abytes(personalization, void 0, "personalization");
571
570
  const pers = u32(personalization);
572
571
  this.v6l ^= swap8IfBE(pers[0]);
573
572
  this.v6h ^= swap8IfBE(pers[1]);
@@ -658,7 +657,7 @@ var BLAKE2b = class extends BLAKE2 {
658
657
  this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
659
658
  }
660
659
  };
661
- var blake2b = /* @__PURE__ */ createOptHasher((opts) => new BLAKE2b(opts));
660
+ var blake2b = /* @__PURE__ */ createHasher((opts) => new _BLAKE2b(opts));
662
661
 
663
662
  // src/guard.ts
664
663
  var createIsGuard = (type) => (value) => typeof value === type;
@@ -795,6 +794,6 @@ var toPublicKey = (address) => bytesToHex(decode2(address).data);
795
794
  });
796
795
  /*! Bundled license information:
797
796
 
798
- @noble/hashes/esm/utils.js:
797
+ @noble/hashes/utils.js:
799
798
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
800
799
  */
package/dist/ss58.js CHANGED
@@ -11,19 +11,27 @@ import {
11
11
  } from "./chunk-ZHIKNZLU.js";
12
12
  import "./chunk-HBIFE4XN.js";
13
13
 
14
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
14
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.0/node_modules/@noble/hashes/utils.js
15
15
  function isBytes(a) {
16
16
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
17
17
  }
18
- function anumber(n) {
19
- if (!Number.isSafeInteger(n) || n < 0)
20
- throw new Error("positive integer expected, got " + n);
18
+ function anumber(n, title = "") {
19
+ if (!Number.isSafeInteger(n) || n < 0) {
20
+ const prefix = title && `"${title}" `;
21
+ throw new Error(`${prefix}expected integer >0, got ${n}`);
22
+ }
21
23
  }
22
- function abytes(b, ...lengths) {
23
- if (!isBytes(b))
24
- throw new Error("Uint8Array expected");
25
- if (lengths.length > 0 && !lengths.includes(b.length))
26
- throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
24
+ function abytes(value, length, title = "") {
25
+ const bytes = isBytes(value);
26
+ const len = value?.length;
27
+ const needsLen = length !== void 0;
28
+ if (!bytes || needsLen && len !== length) {
29
+ const prefix = title && `"${title}" `;
30
+ const ofLen = needsLen ? ` of length ${length}` : "";
31
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
32
+ throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
33
+ }
34
+ return value;
27
35
  }
28
36
  function aexists(instance, checkFinished = true) {
29
37
  if (instance.destroyed)
@@ -32,10 +40,10 @@ function aexists(instance, checkFinished = true) {
32
40
  throw new Error("Hash#digest() has already been called");
33
41
  }
34
42
  function aoutput(out, instance) {
35
- abytes(out);
43
+ abytes(out, void 0, "digestInto() output");
36
44
  const min = instance.outputLen;
37
45
  if (out.length < min) {
38
- throw new Error("digestInto() expects output buffer of length at least " + min);
46
+ throw new Error('"digestInto() output" expected to be of length >=' + min);
39
47
  }
40
48
  }
41
49
  function u32(arr) {
@@ -58,29 +66,17 @@ function byteSwap32(arr) {
58
66
  return arr;
59
67
  }
60
68
  var swap32IfBE = isLE ? (u) => u : byteSwap32;
61
- function utf8ToBytes(str) {
62
- if (typeof str !== "string")
63
- throw new Error("string expected");
64
- return new Uint8Array(new TextEncoder().encode(str));
65
- }
66
- function toBytes(data) {
67
- if (typeof data === "string")
68
- data = utf8ToBytes(data);
69
- abytes(data);
70
- return data;
71
- }
72
- var Hash = class {
73
- };
74
- function createOptHasher(hashCons) {
75
- const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
76
- const tmp = hashCons({});
69
+ function createHasher(hashCons, info = {}) {
70
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
71
+ const tmp = hashCons(void 0);
77
72
  hashC.outputLen = tmp.outputLen;
78
73
  hashC.blockLen = tmp.blockLen;
79
74
  hashC.create = (opts) => hashCons(opts);
80
- return hashC;
75
+ Object.assign(hashC, info);
76
+ return Object.freeze(hashC);
81
77
  }
82
78
 
83
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_blake.js
79
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.0/node_modules/@noble/hashes/_blake.js
84
80
  var BSIGMA = /* @__PURE__ */ Uint8Array.from([
85
81
  0,
86
82
  1,
@@ -341,7 +337,7 @@ var BSIGMA = /* @__PURE__ */ Uint8Array.from([
341
337
  9
342
338
  ]);
343
339
 
344
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
340
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.0/node_modules/@noble/hashes/_u64.js
345
341
  var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
346
342
  var _32n = /* @__PURE__ */ BigInt(32);
347
343
  function fromBig(n, le = false) {
@@ -362,7 +358,7 @@ function add(Ah, Al, Bh, Bl) {
362
358
  var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
363
359
  var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
364
360
 
365
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/blake2.js
361
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.0/node_modules/@noble/hashes/blake2.js
366
362
  var B2B_IV = /* @__PURE__ */ Uint32Array.from([
367
363
  4089235720,
368
364
  1779033703,
@@ -426,19 +422,22 @@ function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) {
426
422
  throw new Error("outputLen bigger than keyLen");
427
423
  const { key, salt, personalization } = opts;
428
424
  if (key !== void 0 && (key.length < 1 || key.length > keyLen))
429
- throw new Error("key length must be undefined or 1.." + keyLen);
430
- if (salt !== void 0 && salt.length !== saltLen)
431
- throw new Error("salt must be undefined or " + saltLen);
432
- if (personalization !== void 0 && personalization.length !== persLen)
433
- throw new Error("personalization must be undefined or " + persLen);
425
+ throw new Error('"key" expected to be undefined or of length=1..' + keyLen);
426
+ if (salt !== void 0)
427
+ abytes(salt, saltLen, "salt");
428
+ if (personalization !== void 0)
429
+ abytes(personalization, persLen, "personalization");
434
430
  }
435
- var BLAKE2 = class extends Hash {
431
+ var _BLAKE2 = class {
432
+ buffer;
433
+ buffer32;
434
+ finished = false;
435
+ destroyed = false;
436
+ length = 0;
437
+ pos = 0;
438
+ blockLen;
439
+ outputLen;
436
440
  constructor(blockLen, outputLen) {
437
- super();
438
- this.finished = false;
439
- this.destroyed = false;
440
- this.length = 0;
441
- this.pos = 0;
442
441
  anumber(blockLen);
443
442
  anumber(outputLen);
444
443
  this.blockLen = blockLen;
@@ -448,7 +447,6 @@ var BLAKE2 = class extends Hash {
448
447
  }
449
448
  update(data) {
450
449
  aexists(this);
451
- data = toBytes(data);
452
450
  abytes(data);
453
451
  const { blockLen, buffer, buffer32 } = this;
454
452
  const len = data.length;
@@ -501,7 +499,7 @@ var BLAKE2 = class extends Hash {
501
499
  }
502
500
  _cloneInto(to) {
503
501
  const { buffer, length, finished, destroyed, outputLen, pos } = this;
504
- to || (to = new this.constructor({ dkLen: outputLen }));
502
+ to ||= new this.constructor({ dkLen: outputLen });
505
503
  to.set(...this.get());
506
504
  to.buffer.set(buffer);
507
505
  to.destroyed = destroyed;
@@ -515,36 +513,37 @@ var BLAKE2 = class extends Hash {
515
513
  return this._cloneInto();
516
514
  }
517
515
  };
518
- var BLAKE2b = class extends BLAKE2 {
516
+ var _BLAKE2b = class extends _BLAKE2 {
517
+ // Same as SHA-512, but LE
518
+ v0l = B2B_IV[0] | 0;
519
+ v0h = B2B_IV[1] | 0;
520
+ v1l = B2B_IV[2] | 0;
521
+ v1h = B2B_IV[3] | 0;
522
+ v2l = B2B_IV[4] | 0;
523
+ v2h = B2B_IV[5] | 0;
524
+ v3l = B2B_IV[6] | 0;
525
+ v3h = B2B_IV[7] | 0;
526
+ v4l = B2B_IV[8] | 0;
527
+ v4h = B2B_IV[9] | 0;
528
+ v5l = B2B_IV[10] | 0;
529
+ v5h = B2B_IV[11] | 0;
530
+ v6l = B2B_IV[12] | 0;
531
+ v6h = B2B_IV[13] | 0;
532
+ v7l = B2B_IV[14] | 0;
533
+ v7h = B2B_IV[15] | 0;
519
534
  constructor(opts = {}) {
520
535
  const olen = opts.dkLen === void 0 ? 64 : opts.dkLen;
521
536
  super(128, olen);
522
- this.v0l = B2B_IV[0] | 0;
523
- this.v0h = B2B_IV[1] | 0;
524
- this.v1l = B2B_IV[2] | 0;
525
- this.v1h = B2B_IV[3] | 0;
526
- this.v2l = B2B_IV[4] | 0;
527
- this.v2h = B2B_IV[5] | 0;
528
- this.v3l = B2B_IV[6] | 0;
529
- this.v3h = B2B_IV[7] | 0;
530
- this.v4l = B2B_IV[8] | 0;
531
- this.v4h = B2B_IV[9] | 0;
532
- this.v5l = B2B_IV[10] | 0;
533
- this.v5h = B2B_IV[11] | 0;
534
- this.v6l = B2B_IV[12] | 0;
535
- this.v6h = B2B_IV[13] | 0;
536
- this.v7l = B2B_IV[14] | 0;
537
- this.v7h = B2B_IV[15] | 0;
538
537
  checkBlake2Opts(olen, opts, 64, 16, 16);
539
538
  let { key, personalization, salt } = opts;
540
539
  let keyLength = 0;
541
540
  if (key !== void 0) {
542
- key = toBytes(key);
541
+ abytes(key, void 0, "key");
543
542
  keyLength = key.length;
544
543
  }
545
544
  this.v0l ^= this.outputLen | keyLength << 8 | 1 << 16 | 1 << 24;
546
545
  if (salt !== void 0) {
547
- salt = toBytes(salt);
546
+ abytes(salt, void 0, "salt");
548
547
  const slt = u32(salt);
549
548
  this.v4l ^= swap8IfBE(slt[0]);
550
549
  this.v4h ^= swap8IfBE(slt[1]);
@@ -552,7 +551,7 @@ var BLAKE2b = class extends BLAKE2 {
552
551
  this.v5h ^= swap8IfBE(slt[3]);
553
552
  }
554
553
  if (personalization !== void 0) {
555
- personalization = toBytes(personalization);
554
+ abytes(personalization, void 0, "personalization");
556
555
  const pers = u32(personalization);
557
556
  this.v6l ^= swap8IfBE(pers[0]);
558
557
  this.v6h ^= swap8IfBE(pers[1]);
@@ -643,7 +642,7 @@ var BLAKE2b = class extends BLAKE2 {
643
642
  this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
644
643
  }
645
644
  };
646
- var blake2b = /* @__PURE__ */ createOptHasher((opts) => new BLAKE2b(opts));
645
+ var blake2b = /* @__PURE__ */ createHasher((opts) => new _BLAKE2b(opts));
647
646
 
648
647
  // src/ss58.ts
649
648
  var CHECKSUM_BYTE_LENGTH = 2;
@@ -713,6 +712,6 @@ export {
713
712
  };
714
713
  /*! Bundled license information:
715
714
 
716
- @noble/hashes/esm/utils.js:
715
+ @noble/hashes/utils.js:
717
716
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
718
717
  */
package/dist/tickMath.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  assetConstants
3
- } from "./chunk-DR3WTOBQ.js";
3
+ } from "./chunk-QLABW6HJ.js";
4
4
 
5
5
  // src/tickMath.ts
6
6
  import BigNumber from "bignumber.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/utils",
3
- "version": "0.8.18",
3
+ "version": "0.8.20",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -26,7 +26,7 @@
26
26
  }
27
27
  },
28
28
  "devDependencies": {
29
- "@noble/hashes": "^1.8.0",
29
+ "@noble/hashes": "^2.0.0",
30
30
  "@vitest/ui": "3.1.1"
31
31
  },
32
32
  "dependencies": {