@aboutcircles/sdk 0.1.29 → 0.1.30

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 (2) hide show
  1. package/dist/index.js +453 -389
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1019,7 +1019,7 @@ class Profiles {
1019
1019
  // ../invitations/dist/index.js
1020
1020
  var h8 = (J) => BigInt(J);
1021
1021
  var G$ = (J) => parseInt(J, 16);
1022
- var t0 = (J) => {
1022
+ var o0 = (J) => {
1023
1023
  if (J.startsWith("0x"))
1024
1024
  J = J.slice(2);
1025
1025
  if (J.length % 2 !== 0)
@@ -1029,14 +1029,14 @@ var t0 = (J) => {
1029
1029
  $[Q / 2] = parseInt(J.substr(Q, 2), 16);
1030
1030
  return $;
1031
1031
  };
1032
- function o0(J, $) {
1032
+ function t0(J, $) {
1033
1033
  if (typeof $ === "string" && $.startsWith("0x")) {
1034
1034
  let Q = $.slice(2);
1035
1035
  if (Q.length === 40)
1036
1036
  return $;
1037
1037
  if (Q.length === 64) {
1038
1038
  if (J.toLowerCase().includes("digest") || J.toLowerCase().includes("data") || J.toLowerCase().includes("bytes"))
1039
- return t0($);
1039
+ return o0($);
1040
1040
  try {
1041
1041
  return h8($);
1042
1042
  } catch {
@@ -1063,7 +1063,7 @@ function p$(J) {
1063
1063
  for (let [G, M3] of Object.entries(Q)) {
1064
1064
  if (["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash"].includes(G))
1065
1065
  continue;
1066
- Y[G] = o0(G, M3);
1066
+ Y[G] = t0(G, M3);
1067
1067
  }
1068
1068
  return Y;
1069
1069
  }
@@ -1145,6 +1145,7 @@ class DJ {
1145
1145
  websocketConnected = false;
1146
1146
  pendingResponses = {};
1147
1147
  subscriptionListeners = {};
1148
+ activeSubscriptions = [];
1148
1149
  reconnectAttempt = 0;
1149
1150
  initialBackoff = 2000;
1150
1151
  maxBackoff = 120000;
@@ -1213,11 +1214,26 @@ class DJ {
1213
1214
  if (this.websocketConnected)
1214
1215
  return;
1215
1216
  try {
1216
- await this.connect(), console.log("Reconnection successful");
1217
+ await this.connect(), console.log("Reconnection successful"), await this.resubscribeActive();
1217
1218
  } catch (J) {
1218
1219
  console.error("Reconnection attempt failed:", J), this.scheduleReconnect();
1219
1220
  }
1220
1221
  }
1222
+ async resubscribeActive() {
1223
+ if (this.activeSubscriptions.length === 0)
1224
+ return;
1225
+ let J = [...this.activeSubscriptions];
1226
+ this.activeSubscriptions = [];
1227
+ for (let $ of J)
1228
+ try {
1229
+ let Q = $.address ? { address: $.address } : {}, G = (await this.sendMessage("circles_subscribe", Q)).result, M3 = this.subscriptionListeners[$.id];
1230
+ if (M3)
1231
+ this.subscriptionListeners[G] = M3, delete this.subscriptionListeners[$.id];
1232
+ this.activeSubscriptions.push({ id: G, address: $.address });
1233
+ } catch (Q) {
1234
+ console.error("Failed to re-issue circles_subscribe after reconnect:", Q), this.activeSubscriptions.push($);
1235
+ }
1236
+ }
1221
1237
  sendMessage(J, $, Q = 5000) {
1222
1238
  if (!this.websocket || this.websocket.readyState !== WebSocket.OPEN)
1223
1239
  return Promise.reject(i2.connectionFailed(this.rpcUrl));
@@ -1238,7 +1254,7 @@ class DJ {
1238
1254
  this.subscriptionListeners[M3] = [];
1239
1255
  return this.subscriptionListeners[M3].push((Z) => {
1240
1256
  T$(Z).forEach((K) => Q.emit(K));
1241
- }), Q.property;
1257
+ }), this.activeSubscriptions.push({ id: M3, address: $ }), Q.property;
1242
1258
  }
1243
1259
  }
1244
1260
  var I$ = BigInt(4294967295);
@@ -1284,13 +1300,13 @@ function i$(J, $ = true) {
1284
1300
  if ($ && J.finished)
1285
1301
  throw Error("Hash#digest() has already been called");
1286
1302
  }
1287
- function t8(J, $) {
1303
+ function o8(J, $) {
1288
1304
  S$(J, undefined, "digestInto() output");
1289
1305
  let Q = $.outputLen;
1290
1306
  if (J.length < Q)
1291
1307
  throw Error('"digestInto() output" expected to be of length >=' + Q);
1292
1308
  }
1293
- function o8(J) {
1309
+ function t8(J) {
1294
1310
  return new Uint32Array(J.buffer, J.byteOffset, Math.floor(J.byteLength / 4));
1295
1311
  }
1296
1312
  function n$(...J) {
@@ -1306,7 +1322,7 @@ function $Q(J) {
1306
1322
  J[$] = JQ(J[$]);
1307
1323
  return J;
1308
1324
  }
1309
- var t$ = e0 ? (J) => J : $Q;
1325
+ var o$ = e0 ? (J) => J : $Q;
1310
1326
  function a8(J, $ = {}) {
1311
1327
  let Q = (G, M3) => J(M3).update(G).digest(), Y = J(undefined);
1312
1328
  return Q.outputLen = Y.outputLen, Q.blockLen = Y.blockLen, Q.create = (G) => J(G), Object.assign(Q, $), Object.freeze(Q);
@@ -1359,7 +1375,7 @@ function qQ(J, $ = 24) {
1359
1375
  n$(Q);
1360
1376
  }
1361
1377
 
1362
- class o$ {
1378
+ class t$ {
1363
1379
  state;
1364
1380
  pos = 0;
1365
1381
  posOut = 0;
@@ -1374,13 +1390,13 @@ class o$ {
1374
1390
  constructor(J, $, Q, Y = false, G = 24) {
1375
1391
  if (this.blockLen = J, this.suffix = $, this.outputLen = Q, this.enableXOF = Y, this.rounds = G, d$(Q, "outputLen"), !(0 < J && J < 200))
1376
1392
  throw Error("only keccak-f1600 function is supported");
1377
- this.state = new Uint8Array(200), this.state32 = o8(this.state);
1393
+ this.state = new Uint8Array(200), this.state32 = t8(this.state);
1378
1394
  }
1379
1395
  clone() {
1380
1396
  return this._cloneInto();
1381
1397
  }
1382
1398
  keccak() {
1383
- t$(this.state32), qQ(this.state32, this.rounds), t$(this.state32), this.posOut = 0, this.pos = 0;
1399
+ o$(this.state32), qQ(this.state32, this.rounds), o$(this.state32), this.posOut = 0, this.pos = 0;
1384
1400
  }
1385
1401
  update(J) {
1386
1402
  i$(this), S$(J);
@@ -1423,7 +1439,7 @@ class o$ {
1423
1439
  return d$(J), this.xofInto(new Uint8Array(J));
1424
1440
  }
1425
1441
  digestInto(J) {
1426
- if (t8(J, this), this.finished)
1442
+ if (o8(J, this), this.finished)
1427
1443
  throw Error("digest() was already called");
1428
1444
  return this.writeInto(J), this.destroy(), J;
1429
1445
  }
@@ -1435,10 +1451,10 @@ class o$ {
1435
1451
  }
1436
1452
  _cloneInto(J) {
1437
1453
  let { blockLen: $, suffix: Q, outputLen: Y, rounds: G, enableXOF: M3 } = this;
1438
- return J ||= new o$($, Q, Y, M3, G), J.state32.set(this.state32), J.pos = this.pos, J.posOut = this.posOut, J.finished = this.finished, J.rounds = G, J.suffix = Q, J.outputLen = Y, J.enableXOF = M3, J.destroyed = this.destroyed, J;
1454
+ return J ||= new t$($, Q, Y, M3, G), J.state32.set(this.state32), J.pos = this.pos, J.posOut = this.posOut, J.finished = this.finished, J.rounds = G, J.suffix = Q, J.outputLen = Y, J.enableXOF = M3, J.destroyed = this.destroyed, J;
1439
1455
  }
1440
1456
  }
1441
- var WQ = (J, $, Q, Y = {}) => a8(() => new o$($, J, Q), Y);
1457
+ var WQ = (J, $, Q, Y = {}) => a8(() => new t$($, J, Q), Y);
1442
1458
  var pJ = WQ(1, 136, 32);
1443
1459
  var Y0 = [];
1444
1460
  for (let J = 0;J < 256; J++)
@@ -1697,10 +1713,10 @@ function QJ(J, $) {
1697
1713
  function P2(J) {
1698
1714
  return J.toLowerCase();
1699
1715
  }
1700
- function LQ(J) {
1716
+ function CQ(J) {
1701
1717
  return RJ(J);
1702
1718
  }
1703
- function CQ(J) {
1719
+ function LQ(J) {
1704
1720
  if (typeof J !== "string")
1705
1721
  return false;
1706
1722
  let $ = J.replace("0x", "");
@@ -1709,8 +1725,8 @@ function CQ(J) {
1709
1725
  function A3(J) {
1710
1726
  if (J === null || J === undefined)
1711
1727
  return J;
1712
- if (CQ(J))
1713
- return LQ(J);
1728
+ if (LQ(J))
1729
+ return CQ(J);
1714
1730
  if (Array.isArray(J))
1715
1731
  return J.map(($) => A3($));
1716
1732
  if (typeof J === "object" && J !== null) {
@@ -2336,7 +2352,7 @@ class n2 {
2336
2352
  }
2337
2353
  var Z0 = [{ type: "function", name: "operateFlowMatrix", inputs: [{ name: "_flowVertices", type: "address[]" }, { name: "_flow", type: "tuple[]", components: [{ name: "streamSinkId", type: "uint16" }, { name: "amount", type: "uint192" }] }, { name: "_streams", type: "tuple[]", components: [{ name: "sourceCoordinate", type: "uint16" }, { name: "flowEdgeIds", type: "uint16[]" }, { name: "data", type: "bytes" }] }, { name: "_packedCoordinates", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isApprovedForAll", inputs: [{ name: "_account", type: "address" }, { name: "_operator", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "setApprovalForAll", inputs: [{ name: "_operator", type: "address" }, { name: "_approved", type: "bool" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "wrap", inputs: [{ name: "_avatar", type: "address" }, { name: "_amount", type: "uint256" }, { name: "_type", type: "uint8" }], outputs: [{ type: "address" }], stateMutability: "nonpayable" }, { type: "function", name: "trust", inputs: [{ name: "_trustReceiver", type: "address" }, { name: "_expiry", type: "uint96" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isTrusted", inputs: [{ name: "_truster", type: "address" }, { name: "_trustee", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "toTokenId", inputs: [{ name: "_avatar", type: "address" }], outputs: [{ type: "uint256" }], stateMutability: "pure" }, { type: "function", name: "safeTransferFrom", inputs: [{ name: "_from", type: "address" }, { name: "_to", type: "address" }, { name: "_id", type: "uint256" }, { name: "_value", type: "uint256" }, { name: "_data", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isHuman", inputs: [{ name: "_human", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "safeBatchTransferFrom", inputs: [{ name: "_from", type: "address" }, { name: "_to", type: "address" }, { name: "_ids", type: "uint256[]" }, { name: "_values", type: "uint256[]" }, { name: "_data", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }];
2338
2354
 
2339
- class LJ extends n2 {
2355
+ class CJ extends n2 {
2340
2356
  constructor(J) {
2341
2357
  super({ address: J.address, abi: Z0, rpcUrl: J.rpcUrl });
2342
2358
  }
@@ -2392,7 +2408,7 @@ class nJ extends n2 {
2392
2408
  }
2393
2409
  }
2394
2410
 
2395
- class tJ extends n2 {
2411
+ class oJ extends n2 {
2396
2412
  constructor(J) {
2397
2413
  super({ address: J.address, abi: J8, rpcUrl: J.rpcUrl });
2398
2414
  }
@@ -2405,7 +2421,7 @@ var Q8 = [{ type: "function", name: "claimInvite", inputs: [], outputs: [{ name:
2405
2421
  var Y8 = [{ type: "function", name: "isModuleEnabled", inputs: [{ name: "module", type: "address" }], outputs: [{ name: "", type: "bool" }], stateMutability: "view" }, { type: "function", name: "enableModule", inputs: [{ name: "module", type: "address" }], outputs: [], stateMutability: "nonpayable" }];
2406
2422
  var G8 = [{ type: "function", name: "trustInviter", inputs: [{ name: "inviter", type: "address" }], outputs: [], stateMutability: "nonpayable" }];
2407
2423
 
2408
- class oJ extends n2 {
2424
+ class tJ extends n2 {
2409
2425
  constructor(J) {
2410
2426
  super({ address: J.address, abi: $8, rpcUrl: J.rpcUrl });
2411
2427
  }
@@ -2632,7 +2648,7 @@ class M8 extends O$ {
2632
2648
  }
2633
2649
  var WJ = Uint32Array.from([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]);
2634
2650
  var IQ = Uint32Array.from([1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298]);
2635
- var CJ = new Uint32Array(64);
2651
+ var LJ = new Uint32Array(64);
2636
2652
 
2637
2653
  class N0 extends M8 {
2638
2654
  constructor(J = 32) {
@@ -2648,20 +2664,20 @@ class N0 extends M8 {
2648
2664
  }
2649
2665
  process(J, $) {
2650
2666
  for (let W = 0;W < 16; W++, $ += 4)
2651
- CJ[W] = J.getUint32($, false);
2667
+ LJ[W] = J.getUint32($, false);
2652
2668
  for (let W = 16;W < 64; W++) {
2653
- let V = CJ[W - 15], N3 = CJ[W - 2], O3 = MJ(V, 7) ^ MJ(V, 18) ^ V >>> 3, B3 = MJ(N3, 17) ^ MJ(N3, 19) ^ N3 >>> 10;
2654
- CJ[W] = B3 + CJ[W - 7] + O3 + CJ[W - 16] | 0;
2669
+ let V = LJ[W - 15], N3 = LJ[W - 2], O3 = MJ(V, 7) ^ MJ(V, 18) ^ V >>> 3, B3 = MJ(N3, 17) ^ MJ(N3, 19) ^ N3 >>> 10;
2670
+ LJ[W] = B3 + LJ[W - 7] + O3 + LJ[W - 16] | 0;
2655
2671
  }
2656
2672
  let { A: Q, B: Y, C: G, D: M3, E: Z, F: K, G: X, H: q } = this;
2657
2673
  for (let W = 0;W < 64; W++) {
2658
- let V = MJ(Z, 6) ^ MJ(Z, 11) ^ MJ(Z, 25), N3 = q + V + z0(Z, K, X) + IQ[W] + CJ[W] | 0, B3 = (MJ(Q, 2) ^ MJ(Q, 13) ^ MJ(Q, 22)) + V0(Q, Y, G) | 0;
2674
+ let V = MJ(Z, 6) ^ MJ(Z, 11) ^ MJ(Z, 25), N3 = q + V + z0(Z, K, X) + IQ[W] + LJ[W] | 0, B3 = (MJ(Q, 2) ^ MJ(Q, 13) ^ MJ(Q, 22)) + V0(Q, Y, G) | 0;
2659
2675
  q = X, X = K, K = Z, Z = M3 + N3 | 0, M3 = G, G = Y, Y = Q, Q = N3 + B3 | 0;
2660
2676
  }
2661
2677
  Q = Q + this.A | 0, Y = Y + this.B | 0, G = G + this.C | 0, M3 = M3 + this.D | 0, Z = Z + this.E | 0, K = K + this.F | 0, X = X + this.G | 0, q = q + this.H | 0, this.set(Q, Y, G, M3, Z, K, X, q);
2662
2678
  }
2663
2679
  roundClean() {
2664
- bJ(CJ);
2680
+ bJ(LJ);
2665
2681
  }
2666
2682
  destroy() {
2667
2683
  this.set(0, 0, 0, 0, 0, 0, 0, 0), bJ(this.buffer);
@@ -2728,15 +2744,15 @@ function R$(J) {
2728
2744
  let $ = J.toString(16);
2729
2745
  return $.length & 1 ? "0" + $ : $;
2730
2746
  }
2731
- function L0(J) {
2747
+ function C0(J) {
2732
2748
  if (typeof J !== "string")
2733
2749
  throw Error("hex string expected, got " + typeof J);
2734
2750
  return J === "" ? U8 : BigInt("0x" + J);
2735
2751
  }
2736
- var C0 = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
2752
+ var L0 = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
2737
2753
  var SQ = Array.from({ length: 256 }, (J, $) => $.toString(16).padStart(2, "0"));
2738
2754
  function J$(J) {
2739
- if (j8(J), C0)
2755
+ if (j8(J), L0)
2740
2756
  return J.toHex();
2741
2757
  let $ = "";
2742
2758
  for (let Q = 0;Q < J.length; Q++)
@@ -2753,10 +2769,10 @@ function O0(J) {
2753
2769
  return J - (UJ.a - 10);
2754
2770
  return;
2755
2771
  }
2756
- function L$(J) {
2772
+ function C$(J) {
2757
2773
  if (typeof J !== "string")
2758
2774
  throw Error("hex string expected, got " + typeof J);
2759
- if (C0)
2775
+ if (L0)
2760
2776
  return Uint8Array.fromHex(J);
2761
2777
  let $ = J.length, Q = $ / 2;
2762
2778
  if ($ % 2)
@@ -2773,13 +2789,13 @@ function L$(J) {
2773
2789
  return Y;
2774
2790
  }
2775
2791
  function jJ(J) {
2776
- return L0(J$(J));
2792
+ return C0(J$(J));
2777
2793
  }
2778
2794
  function z8(J) {
2779
- return j8(J), L0(J$(Uint8Array.from(J).reverse()));
2795
+ return j8(J), C0(J$(Uint8Array.from(J).reverse()));
2780
2796
  }
2781
2797
  function FJ(J, $) {
2782
- return L$(J.toString(16).padStart($ * 2, "0"));
2798
+ return C$(J.toString(16).padStart($ * 2, "0"));
2783
2799
  }
2784
2800
  function V8(J, $) {
2785
2801
  return FJ(J, $).reverse();
@@ -2788,7 +2804,7 @@ function $J(J, $, Q) {
2788
2804
  let Y;
2789
2805
  if (typeof $ === "string")
2790
2806
  try {
2791
- Y = L$($);
2807
+ Y = C$($);
2792
2808
  } catch (M3) {
2793
2809
  throw Error(J + " must be hex string or Uint8Array, cause: " + M3);
2794
2810
  }
@@ -2801,7 +2817,7 @@ function $J(J, $, Q) {
2801
2817
  throw Error(J + " of length " + Q + " expected, got " + G);
2802
2818
  return Y;
2803
2819
  }
2804
- function C$(...J) {
2820
+ function L$(...J) {
2805
2821
  let $ = 0;
2806
2822
  for (let Y = 0;Y < J.length; Y++) {
2807
2823
  let G = J[Y];
@@ -2853,7 +2869,7 @@ function B0(J, $, Q) {
2853
2869
  let O3 = Y.slice();
2854
2870
  N3.push(O3), V += Y.length;
2855
2871
  }
2856
- return C$(...N3);
2872
+ return L$(...N3);
2857
2873
  };
2858
2874
  return (V, N3) => {
2859
2875
  Z(), X(V);
@@ -2893,13 +2909,13 @@ function N8(J) {
2893
2909
  }
2894
2910
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2895
2911
  var s2 = BigInt(0);
2896
- var o3 = BigInt(1);
2912
+ var t2 = BigInt(1);
2897
2913
  var uJ = BigInt(2);
2898
2914
  var yQ = BigInt(3);
2899
2915
  var T0 = BigInt(4);
2900
2916
  var I0 = BigInt(5);
2901
2917
  var S0 = BigInt(8);
2902
- function t2(J, $) {
2918
+ function o3(J, $) {
2903
2919
  let Q = J % $;
2904
2920
  return Q >= s2 ? Q : $ + Q;
2905
2921
  }
@@ -2914,17 +2930,17 @@ function u$(J, $) {
2914
2930
  throw Error("invert: expected non-zero number");
2915
2931
  if ($ <= s2)
2916
2932
  throw Error("invert: expected positive modulus, got " + $);
2917
- let Q = t2(J, $), Y = $, G = s2, M3 = o3, Z = o3, K = s2;
2933
+ let Q = o3(J, $), Y = $, G = s2, M3 = t2, Z = t2, K = s2;
2918
2934
  while (Q !== s2) {
2919
2935
  let q = Y / Q, W = Y % Q, V = G - Z * q, N3 = M3 - K * q;
2920
2936
  Y = Q, Q = W, G = Z, M3 = K, Z = V, K = N3;
2921
2937
  }
2922
- if (Y !== o3)
2938
+ if (Y !== t2)
2923
2939
  throw Error("invert: does not exist");
2924
- return t2(G, $);
2940
+ return o3(G, $);
2925
2941
  }
2926
2942
  function _0(J, $) {
2927
- let Q = (J.ORDER + o3) / T0, Y = J.pow($, Q);
2943
+ let Q = (J.ORDER + t2) / T0, Y = J.pow($, Q);
2928
2944
  if (!J.eql(J.sqr(Y), $))
2929
2945
  throw Error("Cannot find square root");
2930
2946
  return Y;
@@ -2938,7 +2954,7 @@ function EQ(J, $) {
2938
2954
  function AQ(J) {
2939
2955
  if (J < BigInt(3))
2940
2956
  throw Error("sqrt is not defined for small field");
2941
- let $ = J - o3, Q = 0;
2957
+ let $ = J - t2, Q = 0;
2942
2958
  while ($ % uJ === s2)
2943
2959
  $ /= uJ, Q++;
2944
2960
  let Y = uJ, G = P$(J);
@@ -2947,7 +2963,7 @@ function AQ(J) {
2947
2963
  throw Error("Cannot find square root: probably non-prime P");
2948
2964
  if (Q === 1)
2949
2965
  return _0;
2950
- let M3 = G.pow(Y, $), Z = ($ + o3) / uJ;
2966
+ let M3 = G.pow(Y, $), Z = ($ + t2) / uJ;
2951
2967
  return function(X, q) {
2952
2968
  if (X.is0(q))
2953
2969
  return q;
@@ -2961,7 +2977,7 @@ function AQ(J) {
2961
2977
  while (!X.eql(D3, X.ONE))
2962
2978
  if (B3++, D3 = X.sqr(D3), B3 === W)
2963
2979
  throw Error("Cannot find square root");
2964
- let x3 = o3 << BigInt(W - B3 - 1), S3 = X.pow(V, x3);
2980
+ let x3 = t2 << BigInt(W - B3 - 1), S3 = X.pow(V, x3);
2965
2981
  W = B3, V = X.sqr(S3), N3 = X.mul(N3, V), O3 = X.mul(O3, S3);
2966
2982
  }
2967
2983
  return O3;
@@ -2986,13 +3002,13 @@ function wQ(J, $, Q) {
2986
3002
  throw Error("invalid exponent, negatives unsupported");
2987
3003
  if (Q === s2)
2988
3004
  return J.ONE;
2989
- if (Q === o3)
3005
+ if (Q === t2)
2990
3006
  return $;
2991
3007
  let Y = J.ONE, G = $;
2992
3008
  while (Q > s2) {
2993
- if (Q & o3)
3009
+ if (Q & t2)
2994
3010
  Y = J.mul(Y, G);
2995
- G = J.sqr(G), Q >>= o3;
3011
+ G = J.sqr(G), Q >>= t2;
2996
3012
  }
2997
3013
  return Y;
2998
3014
  }
@@ -3009,7 +3025,7 @@ function O8(J, $, Q = false) {
3009
3025
  }, M3), Y;
3010
3026
  }
3011
3027
  function H0(J, $) {
3012
- let Q = (J.ORDER - o3) / uJ, Y = J.pow($, Q), G = J.eql(Y, J.ONE), M3 = J.eql(Y, J.ZERO), Z = J.eql(Y, J.neg(J.ONE));
3028
+ let Q = (J.ORDER - t2) / uJ, Y = J.pow($, Q), G = J.eql(Y, J.ONE), M3 = J.eql(Y, J.ZERO), Z = J.eql(Y, J.neg(J.ONE));
3013
3029
  if (!G && !M3 && !Z)
3014
3030
  throw Error("invalid Legendre symbol result");
3015
3031
  return G ? 1 : M3 ? 0 : -1;
@@ -3026,11 +3042,11 @@ function P$(J, $, Q = false, Y = {}) {
3026
3042
  let { nBitLength: G, nByteLength: M3 } = R8(J, $);
3027
3043
  if (M3 > 2048)
3028
3044
  throw Error("invalid field: expected ORDER of <= 2048 bytes");
3029
- let Z, K = Object.freeze({ ORDER: J, isLE: Q, BITS: G, BYTES: M3, MASK: fJ(G), ZERO: s2, ONE: o3, create: (X) => t2(X, J), isValid: (X) => {
3045
+ let Z, K = Object.freeze({ ORDER: J, isLE: Q, BITS: G, BYTES: M3, MASK: fJ(G), ZERO: s2, ONE: t2, create: (X) => o3(X, J), isValid: (X) => {
3030
3046
  if (typeof X !== "bigint")
3031
3047
  throw Error("invalid field element: expected bigint, got " + typeof X);
3032
3048
  return s2 <= X && X < J;
3033
- }, is0: (X) => X === s2, isOdd: (X) => (X & o3) === o3, neg: (X) => t2(-X, J), eql: (X, q) => X === q, sqr: (X) => t2(X * X, J), add: (X, q) => t2(X + q, J), sub: (X, q) => t2(X - q, J), mul: (X, q) => t2(X * q, J), pow: (X, q) => wQ(K, X, q), div: (X, q) => t2(X * u$(q, J), J), sqrN: (X) => X * X, addN: (X, q) => X + q, subN: (X, q) => X - q, mulN: (X, q) => X * q, inv: (X) => u$(X, J), sqrt: Y.sqrt || ((X) => {
3049
+ }, is0: (X) => X === s2, isOdd: (X) => (X & t2) === t2, neg: (X) => o3(-X, J), eql: (X, q) => X === q, sqr: (X) => o3(X * X, J), add: (X, q) => o3(X + q, J), sub: (X, q) => o3(X - q, J), mul: (X, q) => o3(X * q, J), pow: (X, q) => wQ(K, X, q), div: (X, q) => o3(X * u$(q, J), J), sqrN: (X) => X * X, addN: (X, q) => X + q, subN: (X, q) => X - q, mulN: (X, q) => X * q, inv: (X) => u$(X, J), sqrt: Y.sqrt || ((X) => {
3034
3050
  if (!Z)
3035
3051
  Z = xQ(J);
3036
3052
  return Z(K, X);
@@ -3047,21 +3063,21 @@ function y0(J) {
3047
3063
  let $ = J.toString(2).length;
3048
3064
  return Math.ceil($ / 8);
3049
3065
  }
3050
- function L8(J) {
3066
+ function C8(J) {
3051
3067
  let $ = y0(J);
3052
3068
  return $ + Math.ceil($ / 2);
3053
3069
  }
3054
3070
  function E0(J, $, Q = false) {
3055
- let Y = J.length, G = y0($), M3 = L8($);
3071
+ let Y = J.length, G = y0($), M3 = C8($);
3056
3072
  if (Y < 16 || Y < M3 || Y > 1024)
3057
3073
  throw Error("expected " + M3 + "-1024 bytes of input, got " + Y);
3058
- let Z = Q ? z8(J) : jJ(J), K = t2(Z, $ - o3) + o3;
3074
+ let Z = Q ? z8(J) : jJ(J), K = o3(Z, $ - t2) + t2;
3059
3075
  return Q ? V8(K, G) : FJ(K, G);
3060
3076
  }
3061
3077
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3062
3078
  var A0 = BigInt(0);
3063
3079
  var T8 = BigInt(1);
3064
- function C8(J, $) {
3080
+ function L8(J, $) {
3065
3081
  let Q = $.negate();
3066
3082
  return J ? Q : $;
3067
3083
  }
@@ -3103,7 +3119,7 @@ function H8(J) {
3103
3119
  return w0.get(J) || 1;
3104
3120
  }
3105
3121
  function b0(J, $) {
3106
- return { constTimeNegate: C8, hasPrecomputes(Q) {
3122
+ return { constTimeNegate: L8, hasPrecomputes(Q) {
3107
3123
  return H8(Q) !== 1;
3108
3124
  }, unsafeLadder(Q, Y, G = J.ZERO) {
3109
3125
  let M3 = Q;
@@ -3127,9 +3143,9 @@ function b0(J, $) {
3127
3143
  for (let X = 0;X < K.windows; X++) {
3128
3144
  let { nextN: q, offset: W, isZero: V, isNeg: N3, isNegF: O3, offsetF: B3 } = x0(G, X, K);
3129
3145
  if (G = q, V)
3130
- Z = Z.add(C8(O3, Y[B3]));
3146
+ Z = Z.add(L8(O3, Y[B3]));
3131
3147
  else
3132
- M3 = M3.add(C8(N3, Y[W]));
3148
+ M3 = M3.add(L8(N3, Y[W]));
3133
3149
  }
3134
3150
  return { p: M3, f: Z };
3135
3151
  }, wNAFUnsafe(Q, Y, G, M3 = J.ZERO) {
@@ -3299,20 +3315,20 @@ var hG = BigInt(2);
3299
3315
  var _8 = BigInt(3);
3300
3316
  var fQ = BigInt(4);
3301
3317
  function vQ(J) {
3302
- let $ = gQ(J), { Fp: Q } = $, Y = P$($.n, $.nBitLength), G = $.toBytes || ((U, j, C3) => {
3318
+ let $ = gQ(J), { Fp: Q } = $, Y = P$($.n, $.nBitLength), G = $.toBytes || ((U, j, L2) => {
3303
3319
  let H = j.toAffine();
3304
- return C$(Uint8Array.from([4]), Q.toBytes(H.x), Q.toBytes(H.y));
3320
+ return L$(Uint8Array.from([4]), Q.toBytes(H.x), Q.toBytes(H.y));
3305
3321
  }), M3 = $.fromBytes || ((U) => {
3306
- let j = U.subarray(1), C3 = Q.fromBytes(j.subarray(0, Q.BYTES)), H = Q.fromBytes(j.subarray(Q.BYTES, 2 * Q.BYTES));
3307
- return { x: C3, y: H };
3322
+ let j = U.subarray(1), L2 = Q.fromBytes(j.subarray(0, Q.BYTES)), H = Q.fromBytes(j.subarray(Q.BYTES, 2 * Q.BYTES));
3323
+ return { x: L2, y: H };
3308
3324
  });
3309
3325
  function Z(U) {
3310
- let { a: j, b: C3 } = $, H = Q.sqr(U), w3 = Q.mul(H, U);
3311
- return Q.add(Q.add(w3, Q.mul(U, j)), C3);
3326
+ let { a: j, b: L2 } = $, H = Q.sqr(U), w3 = Q.mul(H, U);
3327
+ return Q.add(Q.add(w3, Q.mul(U, j)), L2);
3312
3328
  }
3313
3329
  function K(U, j) {
3314
- let C3 = Q.sqr(j), H = Z(U);
3315
- return Q.eql(C3, H);
3330
+ let L2 = Q.sqr(j), H = Z(U);
3331
+ return Q.eql(L2, H);
3316
3332
  }
3317
3333
  if (!K($.Gx, $.Gy))
3318
3334
  throw Error("bad curve params: generator point");
@@ -3323,22 +3339,22 @@ function vQ(J) {
3323
3339
  return v$(U, d3, $.n);
3324
3340
  }
3325
3341
  function V(U) {
3326
- let { allowedPrivateKeyLengths: j, nByteLength: C3, wrapPrivateKey: H, n: w3 } = $;
3342
+ let { allowedPrivateKeyLengths: j, nByteLength: L2, wrapPrivateKey: H, n: w3 } = $;
3327
3343
  if (j && typeof U !== "bigint") {
3328
3344
  if (rJ(U))
3329
3345
  U = J$(U);
3330
3346
  if (typeof U !== "string" || !j.includes(U.length))
3331
3347
  throw Error("invalid private key");
3332
- U = U.padStart(C3 * 2, "0");
3348
+ U = U.padStart(L2 * 2, "0");
3333
3349
  }
3334
3350
  let y3;
3335
3351
  try {
3336
- y3 = typeof U === "bigint" ? U : jJ($J("private key", U, C3));
3352
+ y3 = typeof U === "bigint" ? U : jJ($J("private key", U, L2));
3337
3353
  } catch (b3) {
3338
- throw Error("invalid private key, expected hex or " + C3 + " bytes, got " + typeof U);
3354
+ throw Error("invalid private key, expected hex or " + L2 + " bytes, got " + typeof U);
3339
3355
  }
3340
3356
  if (H)
3341
- y3 = t2(y3, w3);
3357
+ y3 = o3(y3, w3);
3342
3358
  return gJ("private key", y3, d3, w3), y3;
3343
3359
  }
3344
3360
  function N3(U) {
@@ -3346,13 +3362,13 @@ function vQ(J) {
3346
3362
  throw Error("ProjectivePoint expected");
3347
3363
  }
3348
3364
  let O3 = N8((U, j) => {
3349
- let { px: C3, py: H, pz: w3 } = U;
3365
+ let { px: L2, py: H, pz: w3 } = U;
3350
3366
  if (Q.eql(w3, Q.ONE))
3351
- return { x: C3, y: H };
3367
+ return { x: L2, y: H };
3352
3368
  let y3 = U.is0();
3353
3369
  if (j == null)
3354
3370
  j = y3 ? Q.ONE : Q.inv(w3);
3355
- let b3 = Q.mul(C3, j), _2 = Q.mul(H, j), k2 = Q.mul(w3, j);
3371
+ let b3 = Q.mul(L2, j), _2 = Q.mul(H, j), k2 = Q.mul(w3, j);
3356
3372
  if (y3)
3357
3373
  return { x: Q.ZERO, y: Q.ZERO };
3358
3374
  if (!Q.eql(k2, Q.ONE))
@@ -3364,10 +3380,10 @@ function vQ(J) {
3364
3380
  return;
3365
3381
  throw Error("bad point: ZERO");
3366
3382
  }
3367
- let { x: j, y: C3 } = U.toAffine();
3368
- if (!Q.isValid(j) || !Q.isValid(C3))
3383
+ let { x: j, y: L2 } = U.toAffine();
3384
+ if (!Q.isValid(j) || !Q.isValid(L2))
3369
3385
  throw Error("bad point: x or y not FE");
3370
- if (!K(j, C3))
3386
+ if (!K(j, L2))
3371
3387
  throw Error("bad point: equation left != right");
3372
3388
  if (!U.isTorsionFree())
3373
3389
  throw Error("bad point: not in prime-order subgroup");
@@ -3375,25 +3391,25 @@ function vQ(J) {
3375
3391
  });
3376
3392
 
3377
3393
  class D3 {
3378
- constructor(U, j, C3) {
3394
+ constructor(U, j, L2) {
3379
3395
  if (U == null || !Q.isValid(U))
3380
3396
  throw Error("x required");
3381
3397
  if (j == null || !Q.isValid(j) || Q.is0(j))
3382
3398
  throw Error("y required");
3383
- if (C3 == null || !Q.isValid(C3))
3399
+ if (L2 == null || !Q.isValid(L2))
3384
3400
  throw Error("z required");
3385
- this.px = U, this.py = j, this.pz = C3, Object.freeze(this);
3401
+ this.px = U, this.py = j, this.pz = L2, Object.freeze(this);
3386
3402
  }
3387
3403
  static fromAffine(U) {
3388
- let { x: j, y: C3 } = U || {};
3389
- if (!U || !Q.isValid(j) || !Q.isValid(C3))
3404
+ let { x: j, y: L2 } = U || {};
3405
+ if (!U || !Q.isValid(j) || !Q.isValid(L2))
3390
3406
  throw Error("invalid affine point");
3391
3407
  if (U instanceof D3)
3392
3408
  throw Error("projective point not allowed");
3393
3409
  let H = (w3) => Q.eql(w3, Q.ZERO);
3394
- if (H(j) && H(C3))
3410
+ if (H(j) && H(L2))
3395
3411
  return D3.ZERO;
3396
- return new D3(j, C3, Q.ONE);
3412
+ return new D3(j, L2, Q.ONE);
3397
3413
  }
3398
3414
  get x() {
3399
3415
  return this.toAffine().x;
@@ -3402,8 +3418,8 @@ function vQ(J) {
3402
3418
  return this.toAffine().y;
3403
3419
  }
3404
3420
  static normalizeZ(U) {
3405
- let j = O8(Q, U.map((C3) => C3.pz));
3406
- return U.map((C3, H) => C3.toAffine(j[H])).map(D3.fromAffine);
3421
+ let j = O8(Q, U.map((L2) => L2.pz));
3422
+ return U.map((L2, H) => L2.toAffine(j[H])).map(D3.fromAffine);
3407
3423
  }
3408
3424
  static fromHex(U) {
3409
3425
  let j = D3.fromAffine(M3($J("pointHex", U)));
@@ -3429,22 +3445,22 @@ function vQ(J) {
3429
3445
  }
3430
3446
  equals(U) {
3431
3447
  N3(U);
3432
- let { px: j, py: C3, pz: H } = this, { px: w3, py: y3, pz: b3 } = U, _2 = Q.eql(Q.mul(j, b3), Q.mul(w3, H)), k2 = Q.eql(Q.mul(C3, b3), Q.mul(y3, H));
3448
+ let { px: j, py: L2, pz: H } = this, { px: w3, py: y3, pz: b3 } = U, _2 = Q.eql(Q.mul(j, b3), Q.mul(w3, H)), k2 = Q.eql(Q.mul(L2, b3), Q.mul(y3, H));
3433
3449
  return _2 && k2;
3434
3450
  }
3435
3451
  negate() {
3436
3452
  return new D3(this.px, Q.neg(this.py), this.pz);
3437
3453
  }
3438
3454
  double() {
3439
- let { a: U, b: j } = $, C3 = Q.mul(j, _8), { px: H, py: w3, pz: y3 } = this, b3 = Q.ZERO, _2 = Q.ZERO, k2 = Q.ZERO, E3 = Q.mul(H, H), l3 = Q.mul(w3, w3), v2 = Q.mul(y3, y3), z = Q.mul(H, w3);
3440
- return z = Q.add(z, z), k2 = Q.mul(H, y3), k2 = Q.add(k2, k2), b3 = Q.mul(U, k2), _2 = Q.mul(C3, v2), _2 = Q.add(b3, _2), b3 = Q.sub(l3, _2), _2 = Q.add(l3, _2), _2 = Q.mul(b3, _2), b3 = Q.mul(z, b3), k2 = Q.mul(C3, k2), v2 = Q.mul(U, v2), z = Q.sub(E3, v2), z = Q.mul(U, z), z = Q.add(z, k2), k2 = Q.add(E3, E3), E3 = Q.add(k2, E3), E3 = Q.add(E3, v2), E3 = Q.mul(E3, z), _2 = Q.add(_2, E3), v2 = Q.mul(w3, y3), v2 = Q.add(v2, v2), E3 = Q.mul(v2, z), b3 = Q.sub(b3, E3), k2 = Q.mul(v2, l3), k2 = Q.add(k2, k2), k2 = Q.add(k2, k2), new D3(b3, _2, k2);
3455
+ let { a: U, b: j } = $, L2 = Q.mul(j, _8), { px: H, py: w3, pz: y3 } = this, b3 = Q.ZERO, _2 = Q.ZERO, k2 = Q.ZERO, E3 = Q.mul(H, H), l3 = Q.mul(w3, w3), v2 = Q.mul(y3, y3), z = Q.mul(H, w3);
3456
+ return z = Q.add(z, z), k2 = Q.mul(H, y3), k2 = Q.add(k2, k2), b3 = Q.mul(U, k2), _2 = Q.mul(L2, v2), _2 = Q.add(b3, _2), b3 = Q.sub(l3, _2), _2 = Q.add(l3, _2), _2 = Q.mul(b3, _2), b3 = Q.mul(z, b3), k2 = Q.mul(L2, k2), v2 = Q.mul(U, v2), z = Q.sub(E3, v2), z = Q.mul(U, z), z = Q.add(z, k2), k2 = Q.add(E3, E3), E3 = Q.add(k2, E3), E3 = Q.add(E3, v2), E3 = Q.mul(E3, z), _2 = Q.add(_2, E3), v2 = Q.mul(w3, y3), v2 = Q.add(v2, v2), E3 = Q.mul(v2, z), b3 = Q.sub(b3, E3), k2 = Q.mul(v2, l3), k2 = Q.add(k2, k2), k2 = Q.add(k2, k2), new D3(b3, _2, k2);
3441
3457
  }
3442
3458
  add(U) {
3443
3459
  N3(U);
3444
- let { px: j, py: C3, pz: H } = this, { px: w3, py: y3, pz: b3 } = U, _2 = Q.ZERO, k2 = Q.ZERO, E3 = Q.ZERO, l3 = $.a, v2 = Q.mul($.b, _8), z = Q.mul(j, w3), L2 = Q.mul(C3, y3), T3 = Q.mul(H, b3), F2 = Q.add(j, C3), I2 = Q.add(w3, y3);
3445
- F2 = Q.mul(F2, I2), I2 = Q.add(z, L2), F2 = Q.sub(F2, I2), I2 = Q.add(j, H);
3460
+ let { px: j, py: L2, pz: H } = this, { px: w3, py: y3, pz: b3 } = U, _2 = Q.ZERO, k2 = Q.ZERO, E3 = Q.ZERO, l3 = $.a, v2 = Q.mul($.b, _8), z = Q.mul(j, w3), C3 = Q.mul(L2, y3), T3 = Q.mul(H, b3), F2 = Q.add(j, L2), I2 = Q.add(w3, y3);
3461
+ F2 = Q.mul(F2, I2), I2 = Q.add(z, C3), F2 = Q.sub(F2, I2), I2 = Q.add(j, H);
3446
3462
  let R3 = Q.add(w3, b3);
3447
- return I2 = Q.mul(I2, R3), R3 = Q.add(z, T3), I2 = Q.sub(I2, R3), R3 = Q.add(C3, H), _2 = Q.add(y3, b3), R3 = Q.mul(R3, _2), _2 = Q.add(L2, T3), R3 = Q.sub(R3, _2), E3 = Q.mul(l3, I2), _2 = Q.mul(v2, T3), E3 = Q.add(_2, E3), _2 = Q.sub(L2, E3), E3 = Q.add(L2, E3), k2 = Q.mul(_2, E3), L2 = Q.add(z, z), L2 = Q.add(L2, z), T3 = Q.mul(l3, T3), I2 = Q.mul(v2, I2), L2 = Q.add(L2, T3), T3 = Q.sub(z, T3), T3 = Q.mul(l3, T3), I2 = Q.add(I2, T3), z = Q.mul(L2, I2), k2 = Q.add(k2, z), z = Q.mul(R3, I2), _2 = Q.mul(F2, _2), _2 = Q.sub(_2, z), z = Q.mul(F2, L2), E3 = Q.mul(R3, E3), E3 = Q.add(E3, z), new D3(_2, k2, E3);
3463
+ return I2 = Q.mul(I2, R3), R3 = Q.add(z, T3), I2 = Q.sub(I2, R3), R3 = Q.add(L2, H), _2 = Q.add(y3, b3), R3 = Q.mul(R3, _2), _2 = Q.add(C3, T3), R3 = Q.sub(R3, _2), E3 = Q.mul(l3, I2), _2 = Q.mul(v2, T3), E3 = Q.add(_2, E3), _2 = Q.sub(C3, E3), E3 = Q.add(C3, E3), k2 = Q.mul(_2, E3), C3 = Q.add(z, z), C3 = Q.add(C3, z), T3 = Q.mul(l3, T3), I2 = Q.mul(v2, I2), C3 = Q.add(C3, T3), T3 = Q.sub(z, T3), T3 = Q.mul(l3, T3), I2 = Q.add(I2, T3), z = Q.mul(C3, I2), k2 = Q.add(k2, z), z = Q.mul(R3, I2), _2 = Q.mul(F2, _2), _2 = Q.sub(_2, z), z = Q.mul(F2, C3), E3 = Q.mul(R3, E3), E3 = Q.add(E3, z), new D3(_2, k2, E3);
3448
3464
  }
3449
3465
  subtract(U) {
3450
3466
  return this.add(U.negate());
@@ -3456,8 +3472,8 @@ function vQ(J) {
3456
3472
  return f3.wNAFCached(this, U, D3.normalizeZ);
3457
3473
  }
3458
3474
  multiplyUnsafe(U) {
3459
- let { endo: j, n: C3 } = $;
3460
- gJ("scalar", U, VJ, C3);
3475
+ let { endo: j, n: L2 } = $;
3476
+ gJ("scalar", U, VJ, L2);
3461
3477
  let H = D3.ZERO;
3462
3478
  if (U === VJ)
3463
3479
  return H;
@@ -3480,8 +3496,8 @@ function vQ(J) {
3480
3496
  return E3 = new D3(Q.mul(E3.px, j.beta), E3.py, E3.pz), k2.add(E3);
3481
3497
  }
3482
3498
  multiply(U) {
3483
- let { endo: j, n: C3 } = $;
3484
- gJ("scalar", U, d3, C3);
3499
+ let { endo: j, n: L2 } = $;
3500
+ gJ("scalar", U, d3, L2);
3485
3501
  let H, w3;
3486
3502
  if (j) {
3487
3503
  let { k1neg: y3, k1: b3, k2neg: _2, k2 } = j.splitScalar(U), { p: E3, f: l3 } = this.wNAF(b3), { p: v2, f: z } = this.wNAF(k2);
@@ -3492,8 +3508,8 @@ function vQ(J) {
3492
3508
  }
3493
3509
  return D3.normalizeZ([H, w3])[0];
3494
3510
  }
3495
- multiplyAndAddUnsafe(U, j, C3) {
3496
- let H = D3.BASE, w3 = (b3, _2) => _2 === VJ || _2 === d3 || !b3.equals(H) ? b3.multiplyUnsafe(_2) : b3.multiply(_2), y3 = w3(this, j).add(w3(U, C3));
3511
+ multiplyAndAddUnsafe(U, j, L2) {
3512
+ let H = D3.BASE, w3 = (b3, _2) => _2 === VJ || _2 === d3 || !b3.equals(H) ? b3.multiplyUnsafe(_2) : b3.multiply(_2), y3 = w3(this, j).add(w3(U, L2));
3497
3513
  return y3.is0() ? undefined : y3;
3498
3514
  }
3499
3515
  toAffine(U) {
@@ -3533,20 +3549,20 @@ function uQ(J) {
3533
3549
  function v0(J) {
3534
3550
  let $ = uQ(J), { Fp: Q, n: Y, nByteLength: G, nBitLength: M3 } = $, Z = Q.BYTES + 1, K = 2 * Q.BYTES + 1;
3535
3551
  function X(z) {
3536
- return t2(z, Y);
3552
+ return o3(z, Y);
3537
3553
  }
3538
3554
  function q(z) {
3539
3555
  return u$(z, Y);
3540
3556
  }
3541
- let { ProjectivePoint: W, normPrivateKeyToScalar: V, weierstrassEquation: N3, isWithinCurveOrder: O3 } = vQ({ ...$, toBytes(z, L2, T3) {
3542
- let F2 = L2.toAffine(), I2 = Q.toBytes(F2.x), R3 = C$;
3557
+ let { ProjectivePoint: W, normPrivateKeyToScalar: V, weierstrassEquation: N3, isWithinCurveOrder: O3 } = vQ({ ...$, toBytes(z, C3, T3) {
3558
+ let F2 = C3.toAffine(), I2 = Q.toBytes(F2.x), R3 = L$;
3543
3559
  if (eJ("isCompressed", T3), T3)
3544
- return R3(Uint8Array.from([L2.hasEvenY() ? 2 : 3]), I2);
3560
+ return R3(Uint8Array.from([C3.hasEvenY() ? 2 : 3]), I2);
3545
3561
  else
3546
3562
  return R3(Uint8Array.from([4]), I2, Q.toBytes(F2.y));
3547
3563
  }, fromBytes(z) {
3548
- let L2 = z.length, T3 = z[0], F2 = z.subarray(1);
3549
- if (L2 === Z && (T3 === 2 || T3 === 3)) {
3564
+ let C3 = z.length, T3 = z[0], F2 = z.subarray(1);
3565
+ if (C3 === Z && (T3 === 2 || T3 === 3)) {
3550
3566
  let I2 = jJ(F2);
3551
3567
  if (!v$(I2, d3, Q.ORDER))
3552
3568
  throw Error("Point is not on curve");
@@ -3561,46 +3577,46 @@ function v0(J) {
3561
3577
  if ((T3 & 1) === 1 !== u2)
3562
3578
  g3 = Q.neg(g3);
3563
3579
  return { x: I2, y: g3 };
3564
- } else if (L2 === K && T3 === 4) {
3580
+ } else if (C3 === K && T3 === 4) {
3565
3581
  let I2 = Q.fromBytes(F2.subarray(0, Q.BYTES)), R3 = Q.fromBytes(F2.subarray(Q.BYTES, 2 * Q.BYTES));
3566
3582
  return { x: I2, y: R3 };
3567
3583
  } else {
3568
3584
  let I2 = Z, R3 = K;
3569
- throw Error("invalid Point, expected length of " + I2 + ", or uncompressed " + R3 + ", got " + L2);
3585
+ throw Error("invalid Point, expected length of " + I2 + ", or uncompressed " + R3 + ", got " + C3);
3570
3586
  }
3571
3587
  } });
3572
3588
  function B3(z) {
3573
- let L2 = Y >> d3;
3574
- return z > L2;
3589
+ let C3 = Y >> d3;
3590
+ return z > C3;
3575
3591
  }
3576
3592
  function D3(z) {
3577
3593
  return B3(z) ? X(-z) : z;
3578
3594
  }
3579
- let x3 = (z, L2, T3) => jJ(z.slice(L2, T3));
3595
+ let x3 = (z, C3, T3) => jJ(z.slice(C3, T3));
3580
3596
 
3581
3597
  class S3 {
3582
- constructor(z, L2, T3) {
3583
- if (gJ("r", z, d3, Y), gJ("s", L2, d3, Y), this.r = z, this.s = L2, T3 != null)
3598
+ constructor(z, C3, T3) {
3599
+ if (gJ("r", z, d3, Y), gJ("s", C3, d3, Y), this.r = z, this.s = C3, T3 != null)
3584
3600
  this.recovery = T3;
3585
3601
  Object.freeze(this);
3586
3602
  }
3587
3603
  static fromCompact(z) {
3588
- let L2 = G;
3589
- return z = $J("compactSignature", z, L2 * 2), new S3(x3(z, 0, L2), x3(z, L2, 2 * L2));
3604
+ let C3 = G;
3605
+ return z = $J("compactSignature", z, C3 * 2), new S3(x3(z, 0, C3), x3(z, C3, 2 * C3));
3590
3606
  }
3591
3607
  static fromDER(z) {
3592
- let { r: L2, s: T3 } = zJ.toSig($J("DER", z));
3593
- return new S3(L2, T3);
3608
+ let { r: C3, s: T3 } = zJ.toSig($J("DER", z));
3609
+ return new S3(C3, T3);
3594
3610
  }
3595
3611
  assertValidity() {}
3596
3612
  addRecoveryBit(z) {
3597
3613
  return new S3(this.r, this.s, z);
3598
3614
  }
3599
3615
  recoverPublicKey(z) {
3600
- let { r: L2, s: T3, recovery: F2 } = this, I2 = w3($J("msgHash", z));
3616
+ let { r: C3, s: T3, recovery: F2 } = this, I2 = w3($J("msgHash", z));
3601
3617
  if (F2 == null || ![0, 1, 2, 3].includes(F2))
3602
3618
  throw Error("recovery id invalid");
3603
- let R3 = F2 === 2 || F2 === 3 ? L2 + $.n : L2;
3619
+ let R3 = F2 === 2 || F2 === 3 ? C3 + $.n : C3;
3604
3620
  if (R3 >= Q.ORDER)
3605
3621
  throw Error("recovery id 2 or 3 invalid");
3606
3622
  let g3 = (F2 & 1) === 0 ? "02" : "03", u2 = W.fromHex(g3 + S8(R3, Q.BYTES)), c3 = q(R3), e2 = X(-I2 * c3), JJ = X(T3 * c3), NJ = W.BASE.multiplyAndAddUnsafe(u2, e2, JJ);
@@ -3615,13 +3631,13 @@ function v0(J) {
3615
3631
  return this.hasHighS() ? new S3(this.r, X(-this.s), this.recovery) : this;
3616
3632
  }
3617
3633
  toDERRawBytes() {
3618
- return L$(this.toDERHex());
3634
+ return C$(this.toDERHex());
3619
3635
  }
3620
3636
  toDERHex() {
3621
3637
  return zJ.hexFromSig(this);
3622
3638
  }
3623
3639
  toCompactRawBytes() {
3624
- return L$(this.toCompactHex());
3640
+ return C$(this.toCompactHex());
3625
3641
  }
3626
3642
  toCompactHex() {
3627
3643
  let z = G;
@@ -3631,17 +3647,17 @@ function v0(J) {
3631
3647
  let f3 = { isValidPrivateKey(z) {
3632
3648
  try {
3633
3649
  return V(z), true;
3634
- } catch (L2) {
3650
+ } catch (C3) {
3635
3651
  return false;
3636
3652
  }
3637
3653
  }, normPrivateKeyToScalar: V, randomPrivateKey: () => {
3638
- let z = L8($.n);
3654
+ let z = C8($.n);
3639
3655
  return E0($.randomBytes(z), $.n);
3640
- }, precompute(z = 8, L2 = W.BASE) {
3641
- return L2._setWindowSize(z), L2.multiply(BigInt(3)), L2;
3656
+ }, precompute(z = 8, C3 = W.BASE) {
3657
+ return C3._setWindowSize(z), C3.multiply(BigInt(3)), C3;
3642
3658
  } };
3643
- function U(z, L2 = true) {
3644
- return W.fromPrivateKey(z).toRawBytes(L2);
3659
+ function U(z, C3 = true) {
3660
+ return W.fromPrivateKey(z).toRawBytes(C3);
3645
3661
  }
3646
3662
  function j(z) {
3647
3663
  if (typeof z === "bigint")
@@ -3654,25 +3670,25 @@ function v0(J) {
3654
3670
  else
3655
3671
  return T3 === I2 || T3 === R3;
3656
3672
  }
3657
- function C3(z, L2, T3 = true) {
3673
+ function L2(z, C3, T3 = true) {
3658
3674
  if (j(z) === true)
3659
3675
  throw Error("first arg must be private key");
3660
- if (j(L2) === false)
3676
+ if (j(C3) === false)
3661
3677
  throw Error("second arg must be public key");
3662
- return W.fromHex(L2).multiply(V(z)).toRawBytes(T3);
3678
+ return W.fromHex(C3).multiply(V(z)).toRawBytes(T3);
3663
3679
  }
3664
3680
  let H = $.bits2int || function(z) {
3665
3681
  if (z.length > 8192)
3666
3682
  throw Error("input is too large");
3667
- let L2 = jJ(z), T3 = z.length * 8 - M3;
3668
- return T3 > 0 ? L2 >> BigInt(T3) : L2;
3683
+ let C3 = jJ(z), T3 = z.length * 8 - M3;
3684
+ return T3 > 0 ? C3 >> BigInt(T3) : C3;
3669
3685
  }, w3 = $.bits2int_modN || function(z) {
3670
3686
  return X(H(z));
3671
3687
  }, y3 = fJ(M3);
3672
3688
  function b3(z) {
3673
3689
  return gJ("num < 2^" + M3, z, VJ, y3), FJ(z, G);
3674
3690
  }
3675
- function _2(z, L2, T3 = k2) {
3691
+ function _2(z, C3, T3 = k2) {
3676
3692
  if (["recovered", "canonical"].some((BJ) => (BJ in T3)))
3677
3693
  throw Error("sign() legacy options not supported");
3678
3694
  let { hash: F2, randomBytes: I2 } = $, { lowS: R3, prehash: g3, extraEntropy: u2 } = T3;
@@ -3680,12 +3696,12 @@ function v0(J) {
3680
3696
  R3 = true;
3681
3697
  if (z = $J("msgHash", z), g0(T3), g3)
3682
3698
  z = $J("prehashed msgHash", F2(z));
3683
- let c3 = w3(z), e2 = V(L2), JJ = [b3(e2), b3(c3)];
3699
+ let c3 = w3(z), e2 = V(C3), JJ = [b3(e2), b3(c3)];
3684
3700
  if (u2 != null && u2 !== false) {
3685
3701
  let BJ = u2 === true ? I2(Q.BYTES) : u2;
3686
3702
  JJ.push($J("extraEntropy", BJ));
3687
3703
  }
3688
- let NJ = C$(...JJ), H$ = c3;
3704
+ let NJ = L$(...JJ), H$ = c3;
3689
3705
  function l$(BJ) {
3690
3706
  let hJ = H(BJ);
3691
3707
  if (!O3(hJ))
@@ -3704,14 +3720,14 @@ function v0(J) {
3704
3720
  return { seed: NJ, k2sig: l$ };
3705
3721
  }
3706
3722
  let k2 = { lowS: $.lowS, prehash: false }, E3 = { lowS: $.lowS, prehash: false };
3707
- function l3(z, L2, T3 = k2) {
3708
- let { seed: F2, k2sig: I2 } = _2(z, L2, T3), R3 = $;
3723
+ function l3(z, C3, T3 = k2) {
3724
+ let { seed: F2, k2sig: I2 } = _2(z, C3, T3), R3 = $;
3709
3725
  return B0(R3.hash.outputLen, R3.nByteLength, R3.hmac)(F2, I2);
3710
3726
  }
3711
3727
  W.BASE._setWindowSize(8);
3712
- function v2(z, L2, T3, F2 = E3) {
3728
+ function v2(z, C3, T3, F2 = E3) {
3713
3729
  let I2 = z;
3714
- L2 = $J("msgHash", L2), T3 = $J("publicKey", T3);
3730
+ C3 = $J("msgHash", C3), T3 = $J("publicKey", T3);
3715
3731
  let { lowS: R3, prehash: g3, format: u2 } = F2;
3716
3732
  if (g0(F2), "strict" in F2)
3717
3733
  throw Error("options.strict was renamed to lowS");
@@ -3744,13 +3760,13 @@ function v0(J) {
3744
3760
  if (R3 && JJ.hasHighS())
3745
3761
  return false;
3746
3762
  if (g3)
3747
- L2 = $.hash(L2);
3748
- let { r: H$, s: l$ } = JJ, BJ = w3(L2), hJ = q(l$), c$ = X(BJ * hJ), Q$ = X(H$ * hJ), HJ = W.BASE.multiplyAndAddUnsafe(NJ, c$, Q$)?.toAffine();
3763
+ C3 = $.hash(C3);
3764
+ let { r: H$, s: l$ } = JJ, BJ = w3(C3), hJ = q(l$), c$ = X(BJ * hJ), Q$ = X(H$ * hJ), HJ = W.BASE.multiplyAndAddUnsafe(NJ, c$, Q$)?.toAffine();
3749
3765
  if (!HJ)
3750
3766
  return false;
3751
3767
  return X(HJ.x) === H$;
3752
3768
  }
3753
- return { CURVE: $, getPublicKey: U, getSharedSecret: C3, sign: l3, verify: v2, ProjectivePoint: W, Signature: S3, utils: f3 };
3769
+ return { CURVE: $, getPublicKey: U, getSharedSecret: L2, sign: l3, verify: v2, ProjectivePoint: W, Signature: S3, utils: f3 };
3754
3770
  }
3755
3771
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3756
3772
  function mQ(J) {
@@ -3768,14 +3784,14 @@ var lQ = BigInt(1);
3768
3784
  var y8 = BigInt(2);
3769
3785
  var h0 = (J, $) => (J + $ / y8) / $;
3770
3786
  function cQ(J) {
3771
- let $ = l0, Q = BigInt(3), Y = BigInt(6), G = BigInt(11), M3 = BigInt(22), Z = BigInt(23), K = BigInt(44), X = BigInt(88), q = J * J * J % $, W = q * q * J % $, V = YJ(W, Q, $) * W % $, N3 = YJ(V, Q, $) * W % $, O3 = YJ(N3, y8, $) * q % $, B3 = YJ(O3, G, $) * O3 % $, D3 = YJ(B3, M3, $) * B3 % $, x3 = YJ(D3, K, $) * D3 % $, S3 = YJ(x3, X, $) * x3 % $, f3 = YJ(S3, K, $) * D3 % $, U = YJ(f3, Q, $) * W % $, j = YJ(U, Z, $) * B3 % $, C3 = YJ(j, Y, $) * q % $, H = YJ(C3, y8, $);
3787
+ let $ = l0, Q = BigInt(3), Y = BigInt(6), G = BigInt(11), M3 = BigInt(22), Z = BigInt(23), K = BigInt(44), X = BigInt(88), q = J * J * J % $, W = q * q * J % $, V = YJ(W, Q, $) * W % $, N3 = YJ(V, Q, $) * W % $, O3 = YJ(N3, y8, $) * q % $, B3 = YJ(O3, G, $) * O3 % $, D3 = YJ(B3, M3, $) * B3 % $, x3 = YJ(D3, K, $) * D3 % $, S3 = YJ(x3, X, $) * x3 % $, f3 = YJ(S3, K, $) * D3 % $, U = YJ(f3, Q, $) * W % $, j = YJ(U, Z, $) * B3 % $, L2 = YJ(j, Y, $) * q % $, H = YJ(L2, y8, $);
3772
3788
  if (!E8.eql(E8.sqr(H), J))
3773
3789
  throw Error("Cannot find square root");
3774
3790
  return H;
3775
3791
  }
3776
3792
  var E8 = P$(l0, undefined, undefined, { sqrt: cQ });
3777
3793
  var A8 = u0({ a: hQ, b: BigInt(7), Fp: E8, n: m0, Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"), Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"), h: BigInt(1), lowS: true, endo: { beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"), splitScalar: (J) => {
3778
- let $ = m0, Q = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), Y = -lQ * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), G = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), M3 = Q, Z = BigInt("0x100000000000000000000000000000000"), K = h0(M3 * J, $), X = h0(-Y * J, $), q = t2(J - K * Q - X * G, $), W = t2(-K * Y - X * M3, $), V = q > Z, N3 = W > Z;
3794
+ let $ = m0, Q = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), Y = -lQ * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), G = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), M3 = Q, Z = BigInt("0x100000000000000000000000000000000"), K = h0(M3 * J, $), X = h0(-Y * J, $), q = o3(J - K * Q - X * G, $), W = o3(-K * Y - X * M3, $), V = q > Z, N3 = W > Z;
3779
3795
  if (V)
3780
3796
  q = $ - q;
3781
3797
  if (N3)
@@ -3983,7 +3999,7 @@ class mJ {
3983
3999
  balance;
3984
4000
  group;
3985
4001
  constructor(J) {
3986
- this.config = J, this.hubV2 = new LJ({ address: J.v2HubAddress, rpcUrl: J.circlesRpcUrl }), this.liftERC20 = new w$({ address: J.liftERC20Address, rpcUrl: J.circlesRpcUrl }), this.rpcClient = new DJ(J.circlesRpcUrl), this.pathfinder = new qJ(this.rpcClient), this.balance = new EJ(this.rpcClient), this.group = new xJ(this.rpcClient);
4002
+ this.config = J, this.hubV2 = new CJ({ address: J.v2HubAddress, rpcUrl: J.circlesRpcUrl }), this.liftERC20 = new w$({ address: J.liftERC20Address, rpcUrl: J.circlesRpcUrl }), this.rpcClient = new DJ(J.circlesRpcUrl), this.pathfinder = new qJ(this.rpcClient), this.balance = new EJ(this.rpcClient), this.group = new xJ(this.rpcClient);
3987
4003
  }
3988
4004
  async buildFlowMatrixTx(J, $, Q, Y, G = false) {
3989
4005
  let M3 = J.toLowerCase(), Z = $.toLowerCase();
@@ -4000,8 +4016,8 @@ class mJ {
4000
4016
  throw a2.wrappedTokensRequired();
4001
4017
  let V = [], N3 = [];
4002
4018
  if (W) {
4003
- let f3 = await this._getTokenBalanceMap(M3), U = this._createDemurragedUnwrapCalls(q), { unwrapCalls: j, wrapCalls: C3 } = this._createInflationaryUnwrapAndWrapCalls(q, X, f3);
4004
- V = [...U, ...j], N3 = C3, K = F8(K, X);
4019
+ let f3 = await this._getTokenBalanceMap(M3), U = this._createDemurragedUnwrapCalls(q), { unwrapCalls: j, wrapCalls: L2 } = this._createInflationaryUnwrapAndWrapCalls(q, X, f3);
4020
+ V = [...U, ...j], N3 = L2, K = F8(K, X);
4005
4021
  }
4006
4022
  let O3 = x8(M3, Z, K.maxFlow, K.transfers), B3 = k8(O3, Y?.txData), D3 = this.hubV2.operateFlowMatrix(O3.flowVertices, O3.flowEdges, B3, O3.packedCoordinates), x3 = false;
4007
4023
  try {
@@ -4020,7 +4036,7 @@ class mJ {
4020
4036
  return [{ to: f3.to, data: f3.data, value: f3.value ?? 0n }];
4021
4037
  }
4022
4038
  if (O3.toLowerCase() === x3.toLowerCase() && x3 !== IJ) {
4023
- let S3 = new tJ({ address: O3, rpcUrl: this.config.circlesRpcUrl }), f3 = GJ.attoCirclesToAttoStaticCircles(K), U = S3.unwrap(f3);
4039
+ let S3 = new oJ({ address: O3, rpcUrl: this.config.circlesRpcUrl }), f3 = GJ.attoCirclesToAttoStaticCircles(K), U = S3.unwrap(f3);
4024
4040
  return [{ to: U.to, data: U.data, value: U.value ?? 0n }];
4025
4041
  }
4026
4042
  }
@@ -4057,7 +4073,7 @@ class mJ {
4057
4073
  x3.push({ to: c3.to, data: c3.data, value: c3.value ?? 0n }), R3 -= g3;
4058
4074
  }
4059
4075
  if (N3 > 0n && B3 && R3 > 0n) {
4060
- let g3 = GJ.attoCirclesToAttoStaticCircles(R3), u2 = g3 > N3 ? N3 : g3, e2 = new tJ({ address: B3, rpcUrl: this.config.circlesRpcUrl }).unwrap(u2);
4076
+ let g3 = GJ.attoCirclesToAttoStaticCircles(R3), u2 = g3 > N3 ? N3 : g3, e2 = new oJ({ address: B3, rpcUrl: this.config.circlesRpcUrl }).unwrap(u2);
4061
4077
  x3.push({ to: e2.to, data: e2.data, value: e2.value ?? 0n });
4062
4078
  }
4063
4079
  if (Z !== G) {
@@ -4066,7 +4082,7 @@ class mJ {
4066
4082
  }
4067
4083
  return x3;
4068
4084
  }
4069
- let U = !await this.hubV2.isTrusted(G, M3), j = BigInt(Math.floor(Date.now() / 1000) + 31536000), C3 = GJ.truncateToInt64(S3), H = S3 % GJ.FACTOR_1E12 !== 0n, w3 = GJ.blowUpToBigInt(H ? C3 + 1n : C3), y3;
4085
+ let U = !await this.hubV2.isTrusted(G, M3), j = BigInt(Math.floor(Date.now() / 1000) + 31536000), L2 = GJ.truncateToInt64(S3), H = S3 % GJ.FACTOR_1E12 !== 0n, w3 = GJ.blowUpToBigInt(H ? L2 + 1n : L2), y3;
4070
4086
  try {
4071
4087
  y3 = await this.pathfinder.findPath({ from: G, to: Z, targetFlow: w3, toTokens: [M3], useWrappedBalances: true, simulatedTrusts: U ? [{ truster: G, trustee: M3 }] : undefined });
4072
4088
  } catch (R3) {
@@ -4088,7 +4104,7 @@ class mJ {
4088
4104
  let R3 = await this._getTokenBalanceMap(G), g3 = this._createDemurragedUnwrapCalls(_2), { unwrapCalls: u2, wrapCalls: c3 } = this._createInflationaryUnwrapAndWrapCalls(_2, b3, R3);
4089
4105
  E3 = [...g3, ...u2], l3 = c3, y3 = F8(y3, b3);
4090
4106
  }
4091
- let v2 = x8(G, Z, y3.maxFlow, y3.transfers), z = k8(v2), L2 = this.hubV2.operateFlowMatrix(v2.flowVertices, v2.flowEdges, z, v2.packedCoordinates), T3 = { to: L2.to, data: L2.data, value: L2.value ?? 0n }, F2 = false;
4107
+ let v2 = x8(G, Z, y3.maxFlow, y3.transfers), z = k8(v2), C3 = this.hubV2.operateFlowMatrix(v2.flowVertices, v2.flowEdges, z, v2.packedCoordinates), T3 = { to: C3.to, data: C3.data, value: C3.value ?? 0n }, F2 = false;
4092
4108
  try {
4093
4109
  F2 = await this.hubV2.isApprovedForAll(G, G);
4094
4110
  } catch (R3) {
@@ -4125,7 +4141,7 @@ class mJ {
4125
4141
  let X = $.get(M3.toLowerCase()), q = Q.get(M3.toLowerCase()) || 0n;
4126
4142
  if (q === 0n)
4127
4143
  continue;
4128
- let V = new tJ({ address: M3, rpcUrl: this.config.circlesRpcUrl }).unwrap(q);
4144
+ let V = new oJ({ address: M3, rpcUrl: this.config.circlesRpcUrl }).unwrap(q);
4129
4145
  Y.push({ to: V.to, data: V.data, value: V.value ?? 0n });
4130
4146
  let N3 = X?.tokenOwner, O3 = GJ.attoStaticCirclesToAttoCircles(q) - Z;
4131
4147
  if (O3 > 0n) {
@@ -4168,7 +4184,7 @@ class g8 {
4168
4184
  constructor(J) {
4169
4185
  if (!J.referralsServiceUrl)
4170
4186
  throw new h2("referralsServiceUrl is required in config", { code: "INVITATION_MISSING_CONFIG", source: "INVITATIONS", context: { missingField: "referralsServiceUrl" } });
4171
- this.config = J, this.rpcClient = new DJ(J.circlesRpcUrl), this.pathfinder = new qJ(this.rpcClient), this.trust = new yJ(this.rpcClient), this.token = new AJ(this.rpcClient), this.hubV2 = new LJ({ address: J.v2HubAddress, rpcUrl: J.circlesRpcUrl }), this.referralsModule = new oJ({ address: J.referralsModuleAddress, rpcUrl: J.circlesRpcUrl }), this.invitationFarm = new aJ({ address: J.invitationFarmAddress, rpcUrl: J.circlesRpcUrl }), this.invitationModuleContract = new F$({ address: J.invitationModuleAddress, rpcUrl: J.circlesRpcUrl });
4187
+ this.config = J, this.rpcClient = new DJ(J.circlesRpcUrl), this.pathfinder = new qJ(this.rpcClient), this.trust = new yJ(this.rpcClient), this.token = new AJ(this.rpcClient), this.hubV2 = new CJ({ address: J.v2HubAddress, rpcUrl: J.circlesRpcUrl }), this.referralsModule = new tJ({ address: J.referralsModuleAddress, rpcUrl: J.circlesRpcUrl }), this.invitationFarm = new aJ({ address: J.invitationFarmAddress, rpcUrl: J.circlesRpcUrl }), this.invitationModuleContract = new F$({ address: J.invitationModuleAddress, rpcUrl: J.circlesRpcUrl });
4172
4188
  }
4173
4189
  async ensureInviterSetup(J) {
4174
4190
  let $ = J.toLowerCase(), Q = this.config.invitationModuleAddress, Y = [], G = new b$({ address: $, rpcUrl: this.config.circlesRpcUrl });
@@ -4270,18 +4286,18 @@ class g8 {
4270
4286
  return [];
4271
4287
  let O3 = this.config.invitationModuleAddress.toLowerCase(), B3 = N3.transfers.filter((j) => j.to.toLowerCase() === O3), D3 = [...new Set(B3.map((j) => j.tokenOwner.toLowerCase()))], x3 = await this.token.getTokenInfoBatch(D3), S3 = new Map;
4272
4288
  for (let j of x3) {
4273
- let C3 = j.tokenAddress ?? j.token;
4274
- if (C3 && j?.tokenOwner)
4275
- S3.set(C3.toLowerCase(), j.tokenOwner.toLowerCase());
4289
+ let L2 = j.tokenAddress ?? j.token;
4290
+ if (L2 && j?.tokenOwner)
4291
+ S3.set(L2.toLowerCase(), j.tokenOwner.toLowerCase());
4276
4292
  }
4277
4293
  let f3 = new Map;
4278
4294
  for (let j of B3) {
4279
- let C3 = j.tokenOwner.toLowerCase(), H = S3.get(C3) ?? C3;
4295
+ let L2 = j.tokenOwner.toLowerCase(), H = S3.get(L2) ?? L2;
4280
4296
  f3.set(H, (f3.get(H) ?? 0n) + j.value);
4281
4297
  }
4282
4298
  let U = [];
4283
- for (let [j, C3] of f3.entries()) {
4284
- let H = Number(C3 / p2);
4299
+ for (let [j, L2] of f3.entries()) {
4300
+ let H = Number(L2 / p2);
4285
4301
  if (H >= 1)
4286
4302
  U.push({ address: j, possibleInvites: H });
4287
4303
  }
@@ -4339,7 +4355,7 @@ class iQ {
4339
4355
  referralsModule;
4340
4356
  hubV2;
4341
4357
  constructor(J) {
4342
- this.referralsModuleAddress = J.referralsModuleAddress, this.invitations = new g8(J), this.invitationFarm = new aJ({ address: J.invitationFarmAddress, rpcUrl: J.circlesRpcUrl }), this.referralsModule = new oJ({ address: J.referralsModuleAddress, rpcUrl: J.circlesRpcUrl }), this.hubV2 = new LJ({ address: J.v2HubAddress, rpcUrl: J.circlesRpcUrl });
4358
+ this.referralsModuleAddress = J.referralsModuleAddress, this.invitations = new g8(J), this.invitationFarm = new aJ({ address: J.invitationFarmAddress, rpcUrl: J.circlesRpcUrl }), this.referralsModule = new tJ({ address: J.referralsModuleAddress, rpcUrl: J.circlesRpcUrl }), this.hubV2 = new CJ({ address: J.v2HubAddress, rpcUrl: J.circlesRpcUrl });
4343
4359
  }
4344
4360
  async getQuota(J) {
4345
4361
  return this.invitationFarm.inviterQuota(J);
@@ -4567,7 +4583,7 @@ class nQ {
4567
4583
 
4568
4584
  // ../rpc/dist/index.js
4569
4585
  var l3 = (J) => BigInt(J);
4570
- var I2 = (J) => parseInt(J, 16);
4586
+ var j = (J) => parseInt(J, 16);
4571
4587
  var OJ2 = (J) => {
4572
4588
  if (J.startsWith("0x"))
4573
4589
  J = J.slice(2);
@@ -4593,7 +4609,7 @@ function DJ2(J, Z) {
4593
4609
  }
4594
4610
  }
4595
4611
  try {
4596
- let Y = I2(Z);
4612
+ let Y = j(Z);
4597
4613
  if (Y < Number.MAX_SAFE_INTEGER)
4598
4614
  return Y;
4599
4615
  return l3(Z);
@@ -4608,7 +4624,7 @@ function DJ2(J, Z) {
4608
4624
  return Z;
4609
4625
  }
4610
4626
  function b3(J) {
4611
- let { event: Z, values: $ } = J, Y = { $event: Z, blockNumber: $.blockNumber ? I2($.blockNumber) : 0, timestamp: $.timestamp ? I2($.timestamp) : undefined, transactionIndex: $.transactionIndex ? I2($.transactionIndex) : 0, logIndex: $.logIndex ? I2($.logIndex) : 0, transactionHash: $.transactionHash };
4627
+ let { event: Z, values: $ } = J, Y = { $event: Z, blockNumber: $.blockNumber ? j($.blockNumber) : 0, timestamp: $.timestamp ? j($.timestamp) : undefined, transactionIndex: $.transactionIndex ? j($.transactionIndex) : 0, logIndex: $.logIndex ? j($.logIndex) : 0, transactionHash: $.transactionHash };
4612
4628
  for (let [W, G] of Object.entries($)) {
4613
4629
  if (["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash"].includes(W))
4614
4630
  continue;
@@ -4694,6 +4710,7 @@ class k2 {
4694
4710
  websocketConnected = false;
4695
4711
  pendingResponses = {};
4696
4712
  subscriptionListeners = {};
4713
+ activeSubscriptions = [];
4697
4714
  reconnectAttempt = 0;
4698
4715
  initialBackoff = 2000;
4699
4716
  maxBackoff = 120000;
@@ -4762,11 +4779,26 @@ class k2 {
4762
4779
  if (this.websocketConnected)
4763
4780
  return;
4764
4781
  try {
4765
- await this.connect(), console.log("Reconnection successful");
4782
+ await this.connect(), console.log("Reconnection successful"), await this.resubscribeActive();
4766
4783
  } catch (J) {
4767
4784
  console.error("Reconnection attempt failed:", J), this.scheduleReconnect();
4768
4785
  }
4769
4786
  }
4787
+ async resubscribeActive() {
4788
+ if (this.activeSubscriptions.length === 0)
4789
+ return;
4790
+ let J = [...this.activeSubscriptions];
4791
+ this.activeSubscriptions = [];
4792
+ for (let Z of J)
4793
+ try {
4794
+ let $ = Z.address ? { address: Z.address } : {}, W = (await this.sendMessage("circles_subscribe", $)).result, G = this.subscriptionListeners[Z.id];
4795
+ if (G)
4796
+ this.subscriptionListeners[W] = G, delete this.subscriptionListeners[Z.id];
4797
+ this.activeSubscriptions.push({ id: W, address: Z.address });
4798
+ } catch ($) {
4799
+ console.error("Failed to re-issue circles_subscribe after reconnect:", $), this.activeSubscriptions.push(Z);
4800
+ }
4801
+ }
4770
4802
  sendMessage(J, Z, $ = 5000) {
4771
4803
  if (!this.websocket || this.websocket.readyState !== WebSocket.OPEN)
4772
4804
  return Promise.reject(q.connectionFailed(this.rpcUrl));
@@ -4787,12 +4819,12 @@ class k2 {
4787
4819
  this.subscriptionListeners[G] = [];
4788
4820
  return this.subscriptionListeners[G].push((Q) => {
4789
4821
  H(Q).forEach((M3) => $.emit(M3));
4790
- }), $.property;
4822
+ }), this.activeSubscriptions.push({ id: G, address: Z }), $.property;
4791
4823
  }
4792
4824
  }
4793
4825
  var g3 = BigInt(4294967295);
4794
4826
  var d4 = BigInt(32);
4795
- function IJ2(J, Z = false) {
4827
+ function jJ2(J, Z = false) {
4796
4828
  if (Z)
4797
4829
  return { h: Number(J & g3), l: Number(J >> d4 & g3) };
4798
4830
  return { h: Number(J >> d4 & g3) | 0, l: Number(J & g3) | 0 };
@@ -4800,7 +4832,7 @@ function IJ2(J, Z = false) {
4800
4832
  function i3(J, Z = false) {
4801
4833
  let $ = J.length, Y = new Uint32Array($), W = new Uint32Array($);
4802
4834
  for (let G = 0;G < $; G++) {
4803
- let { h: Q, l: M3 } = IJ2(J[G], Z);
4835
+ let { h: Q, l: M3 } = jJ2(J[G], Z);
4804
4836
  [Y[G], W[G]] = [Q, M3];
4805
4837
  }
4806
4838
  return [Y, W];
@@ -4810,7 +4842,7 @@ var o4 = (J, Z, $) => Z << $ | J >>> 32 - $;
4810
4842
  var t3 = (J, Z, $) => Z << $ - 32 | J >>> 64 - $;
4811
4843
  var a3 = (J, Z, $) => J << $ - 32 | Z >>> 64 - $;
4812
4844
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4813
- function jJ2(J) {
4845
+ function IJ2(J) {
4814
4846
  return J instanceof Uint8Array || ArrayBuffer.isView(J) && J.constructor.name === "Uint8Array";
4815
4847
  }
4816
4848
  function f3(J, Z = "") {
@@ -4820,7 +4852,7 @@ function f3(J, Z = "") {
4820
4852
  }
4821
4853
  }
4822
4854
  function A4(J, Z, $ = "") {
4823
- let Y = jJ2(J), W = J?.length, G = Z !== undefined;
4855
+ let Y = IJ2(J), W = J?.length, G = Z !== undefined;
4824
4856
  if (!Y || G && W !== Z) {
4825
4857
  let Q = $ && `"${$}" `, M3 = G ? ` of length ${Z}` : "", F2 = Y ? `length=${W}` : `type=${typeof J}`;
4826
4858
  throw Error(Q + "expected Uint8Array" + M3 + ", got " + F2);
@@ -4861,7 +4893,7 @@ function e2(J, Z = {}) {
4861
4893
  return $.outputLen = Y.outputLen, $.blockLen = Y.blockLen, $.create = (W) => J(W), Object.assign($, Z), Object.freeze($);
4862
4894
  }
4863
4895
  var _J2 = BigInt(0);
4864
- var j = BigInt(1);
4896
+ var I2 = BigInt(1);
4865
4897
  var zJ2 = BigInt(2);
4866
4898
  var TJ2 = BigInt(7);
4867
4899
  var CJ2 = BigInt(256);
@@ -4869,28 +4901,28 @@ var EJ2 = BigInt(113);
4869
4901
  var $J2 = [];
4870
4902
  var YJ2 = [];
4871
4903
  var WJ2 = [];
4872
- for (let J = 0, Z = j, $ = 1, Y = 0;J < 24; J++) {
4904
+ for (let J = 0, Z = I2, $ = 1, Y = 0;J < 24; J++) {
4873
4905
  [$, Y] = [Y, (2 * $ + 3 * Y) % 5], $J2.push(2 * (5 * Y + $)), YJ2.push((J + 1) * (J + 2) / 2 % 64);
4874
4906
  let W = _J2;
4875
4907
  for (let G = 0;G < 7; G++)
4876
- if (Z = (Z << j ^ (Z >> TJ2) * EJ2) % CJ2, Z & zJ2)
4877
- W ^= j << (j << BigInt(G)) - j;
4908
+ if (Z = (Z << I2 ^ (Z >> TJ2) * EJ2) % CJ2, Z & zJ2)
4909
+ W ^= I2 << (I2 << BigInt(G)) - I2;
4878
4910
  WJ2.push(W);
4879
4911
  }
4880
4912
  var GJ2 = i3(WJ2, true);
4881
- var wJ2 = GJ2[0];
4882
- var BJ = GJ2[1];
4913
+ var BJ = GJ2[0];
4914
+ var SJ2 = GJ2[1];
4883
4915
  var JJ = (J, Z, $) => $ > 32 ? t3(J, Z, $) : n3(J, Z, $);
4884
4916
  var ZJ2 = (J, Z, $) => $ > 32 ? a3(J, Z, $) : o4(J, Z, $);
4885
- function SJ2(J, Z = 24) {
4917
+ function wJ2(J, Z = 24) {
4886
4918
  let $ = new Uint32Array(10);
4887
4919
  for (let Y = 24 - Z;Y < 24; Y++) {
4888
4920
  for (let Q = 0;Q < 10; Q++)
4889
4921
  $[Q] = J[Q] ^ J[Q + 10] ^ J[Q + 20] ^ J[Q + 30] ^ J[Q + 40];
4890
4922
  for (let Q = 0;Q < 10; Q += 2) {
4891
4923
  let M3 = (Q + 8) % 10, F2 = (Q + 2) % 10, O3 = $[F2], U = $[F2 + 1], UJ2 = JJ(O3, U, 1) ^ $[M3], NJ = ZJ2(O3, U, 1) ^ $[M3 + 1];
4892
- for (let S3 = 0;S3 < 50; S3 += 10)
4893
- J[Q + S3] ^= UJ2, J[Q + S3 + 1] ^= NJ;
4924
+ for (let w3 = 0;w3 < 50; w3 += 10)
4925
+ J[Q + w3] ^= UJ2, J[Q + w3 + 1] ^= NJ;
4894
4926
  }
4895
4927
  let W = J[2], G = J[3];
4896
4928
  for (let Q = 0;Q < 24; Q++) {
@@ -4903,7 +4935,7 @@ function SJ2(J, Z = 24) {
4903
4935
  for (let M3 = 0;M3 < 10; M3++)
4904
4936
  J[Q + M3] ^= ~$[(M3 + 2) % 10] & $[(M3 + 4) % 10];
4905
4937
  }
4906
- J[0] ^= wJ2[Y], J[1] ^= BJ[Y];
4938
+ J[0] ^= BJ[Y], J[1] ^= SJ2[Y];
4907
4939
  }
4908
4940
  h3($);
4909
4941
  }
@@ -4929,7 +4961,7 @@ class m3 {
4929
4961
  return this._cloneInto();
4930
4962
  }
4931
4963
  keccak() {
4932
- p3(this.state32), SJ2(this.state32, this.rounds), p3(this.state32), this.posOut = 0, this.pos = 0;
4964
+ p3(this.state32), wJ2(this.state32, this.rounds), p3(this.state32), this.posOut = 0, this.pos = 0;
4933
4965
  }
4934
4966
  update(J) {
4935
4967
  y3(this), A4(J);
@@ -5431,7 +5463,7 @@ class E3 {
5431
5463
  }
5432
5464
  }
5433
5465
 
5434
- class w3 {
5466
+ class B3 {
5435
5467
  client;
5436
5468
  constructor(J) {
5437
5469
  this.client = J;
@@ -5446,7 +5478,7 @@ class w3 {
5446
5478
  }
5447
5479
  }
5448
5480
 
5449
- class B3 {
5481
+ class S3 {
5450
5482
  client;
5451
5483
  constructor(J) {
5452
5484
  this.client = J;
@@ -5598,12 +5630,12 @@ class XJ {
5598
5630
  }
5599
5631
  get transaction() {
5600
5632
  if (!this._transaction)
5601
- this._transaction = new w3(this.client);
5633
+ this._transaction = new B3(this.client);
5602
5634
  return this._transaction;
5603
5635
  }
5604
5636
  get group() {
5605
5637
  if (!this._group)
5606
- this._group = new B3(this.client);
5638
+ this._group = new S3(this.client);
5607
5639
  return this._group;
5608
5640
  }
5609
5641
  get sdk() {
@@ -8616,31 +8648,31 @@ function Py(y4) {
8616
8648
  function qt(y4) {
8617
8649
  let t4 = new Uint8Array(y4.length * 2);
8618
8650
  return y4.forEach((u3, v3) => {
8619
- let s4 = u3 >> 8, b4 = u3 & 255, S3 = 2 * v3;
8620
- t4[S3] = s4, t4[S3 + 1] = b4;
8651
+ let s4 = u3 >> 8, b4 = u3 & 255, S4 = 2 * v3;
8652
+ t4[S4] = s4, t4[S4 + 1] = b4;
8621
8653
  }), Py(t4);
8622
8654
  }
8623
8655
  function jt(y4, t4, u3) {
8624
8656
  let v3 = new Set([t4.toLowerCase(), u3.toLowerCase()]);
8625
- y4.forEach((S3) => {
8626
- v3.add(S3.from.toLowerCase()), v3.add(S3.to.toLowerCase()), v3.add(S3.tokenOwner.toLowerCase());
8657
+ y4.forEach((S4) => {
8658
+ v3.add(S4.from.toLowerCase()), v3.add(S4.to.toLowerCase()), v3.add(S4.tokenOwner.toLowerCase());
8627
8659
  });
8628
- let s4 = [...v3].sort((S3, N10) => {
8629
- let h4 = BigInt(S3), U = BigInt(N10), K2 = h4 < U, D4 = h4 > U;
8660
+ let s4 = [...v3].sort((S4, N10) => {
8661
+ let h4 = BigInt(S4), U = BigInt(N10), K2 = h4 < U, D4 = h4 > U;
8630
8662
  return K2 ? -1 : D4 ? 1 : 0;
8631
8663
  }), b4 = {};
8632
- return s4.forEach((S3, N10) => {
8633
- b4[S3] = N10;
8664
+ return s4.forEach((S4, N10) => {
8665
+ b4[S4] = N10;
8634
8666
  }), { sorted: s4, idx: b4 };
8635
8667
  }
8636
8668
  function rt(y4, t4) {
8637
8669
  let u3 = new Set, v3 = [], s4 = null;
8638
- if (y4.forEach((b4, S3) => {
8670
+ if (y4.forEach((b4, S4) => {
8639
8671
  let N10 = b4.from.toLowerCase(), h4 = b4.to.toLowerCase();
8640
8672
  if (N10 === t4 && h4 === t4)
8641
- s4 = S3;
8673
+ s4 = S4;
8642
8674
  else if (h4 === t4)
8643
- v3.push(S3);
8675
+ v3.push(S4);
8644
8676
  }), s4 !== null)
8645
8677
  u3.add(s4);
8646
8678
  else
@@ -8648,7 +8680,7 @@ function rt(y4, t4) {
8648
8680
  return u3;
8649
8681
  }
8650
8682
  function Dy(y4, t4, u3, v3) {
8651
- let s4 = y4.toLowerCase(), b4 = t4.toLowerCase(), { sorted: S3, idx: N10 } = jt(v3, s4, b4), h4 = rt(v3, b4), U = v3.map((m4, H2) => {
8683
+ let s4 = y4.toLowerCase(), b4 = t4.toLowerCase(), { sorted: S4, idx: N10 } = jt(v3, s4, b4), h4 = rt(v3, b4), U = v3.map((m4, H2) => {
8652
8684
  return { streamSinkId: h4.has(H2) ? 1 : 0, amount: m4.value };
8653
8685
  });
8654
8686
  if (h4.size === 0)
@@ -8660,7 +8692,7 @@ function Dy(y4, t4, u3, v3) {
8660
8692
  let F2 = qt(_3), i4 = BigInt(u3), I3 = U.filter((m4) => m4.streamSinkId === 1).reduce((m4, H2) => m4 + BigInt(H2.amount.toString()), BigInt(0));
8661
8693
  if (I3 !== i4)
8662
8694
  throw Error(`Terminal sum ${I3} does not equal expected ${i4}`);
8663
- return { flowVertices: S3, flowEdges: U, streams: D4, packedCoordinates: F2, sourceCoordinate: N10[s4] };
8695
+ return { flowVertices: S4, flowEdges: U, streams: D4, packedCoordinates: F2, sourceCoordinate: N10[s4] };
8664
8696
  }
8665
8697
  function My(y4, t4) {
8666
8698
  let u3 = y4.streams.map((v3) => ({ sourceCoordinate: v3.sourceCoordinate, flowEdgeIds: v3.flowEdgeIds, data: v3.data instanceof Uint8Array ? Py(v3.data) : v3.data }));
@@ -8796,6 +8828,7 @@ class ay {
8796
8828
  websocketConnected = false;
8797
8829
  pendingResponses = {};
8798
8830
  subscriptionListeners = {};
8831
+ activeSubscriptions = [];
8799
8832
  reconnectAttempt = 0;
8800
8833
  initialBackoff = 2000;
8801
8834
  maxBackoff = 120000;
@@ -8837,10 +8870,10 @@ class ay {
8837
8870
  this.websocket = new WebSocket(u3), this.websocket.onopen = () => {
8838
8871
  console.log("WebSocket connected"), this.websocketConnected = true, this.reconnectAttempt = 0, y4();
8839
8872
  }, this.websocket.onmessage = (v3) => {
8840
- let s4 = JSON.parse(v3.data), { id: b4, method: S3, params: N10 } = s4;
8873
+ let s4 = JSON.parse(v3.data), { id: b4, method: S4, params: N10 } = s4;
8841
8874
  if (b4 !== undefined && this.pendingResponses[b4])
8842
8875
  this.pendingResponses[b4].resolve(s4), delete this.pendingResponses[b4];
8843
- if (S3 === "circles_subscription" && N10?.result)
8876
+ if (S4 === "circles_subscription" && N10?.result)
8844
8877
  Object.values(this.subscriptionListeners).forEach((h4) => {
8845
8878
  h4.forEach((U) => U(N10.result));
8846
8879
  });
@@ -8864,17 +8897,32 @@ class ay {
8864
8897
  if (this.websocketConnected)
8865
8898
  return;
8866
8899
  try {
8867
- await this.connect(), console.log("Reconnection successful");
8900
+ await this.connect(), console.log("Reconnection successful"), await this.resubscribeActive();
8868
8901
  } catch (y4) {
8869
8902
  console.error("Reconnection attempt failed:", y4), this.scheduleReconnect();
8870
8903
  }
8871
8904
  }
8905
+ async resubscribeActive() {
8906
+ if (this.activeSubscriptions.length === 0)
8907
+ return;
8908
+ let y4 = [...this.activeSubscriptions];
8909
+ this.activeSubscriptions = [];
8910
+ for (let t4 of y4)
8911
+ try {
8912
+ let u3 = t4.address ? { address: t4.address } : {}, v3 = (await this.sendMessage("circles_subscribe", u3)).result, s4 = this.subscriptionListeners[t4.id];
8913
+ if (s4)
8914
+ this.subscriptionListeners[v3] = s4, delete this.subscriptionListeners[t4.id];
8915
+ this.activeSubscriptions.push({ id: v3, address: t4.address });
8916
+ } catch (u3) {
8917
+ console.error("Failed to re-issue circles_subscribe after reconnect:", u3), this.activeSubscriptions.push(t4);
8918
+ }
8919
+ }
8872
8920
  sendMessage(y4, t4, u3 = 5000) {
8873
8921
  if (!this.websocket || this.websocket.readyState !== WebSocket.OPEN)
8874
8922
  return Promise.reject(A5.connectionFailed(this.rpcUrl));
8875
8923
  let v3 = this.requestId++, s4 = { jsonrpc: "2.0", method: y4, params: t4, id: v3 };
8876
- return new Promise((b4, S3) => {
8877
- this.pendingResponses[v3] = { resolve: b4, reject: S3 }, this.websocket.send(JSON.stringify(s4)), setTimeout(() => {
8924
+ return new Promise((b4, S4) => {
8925
+ this.pendingResponses[v3] = { resolve: b4, reject: S4 }, this.websocket.send(JSON.stringify(s4)), setTimeout(() => {
8878
8926
  if (this.pendingResponses[v3])
8879
8927
  this.pendingResponses[v3].reject(A5.timeout(y4, u3)), delete this.pendingResponses[v3];
8880
8928
  }, u3);
@@ -8888,8 +8936,8 @@ class ay {
8888
8936
  if (!this.subscriptionListeners[s4])
8889
8937
  this.subscriptionListeners[s4] = [];
8890
8938
  return this.subscriptionListeners[s4].push((b4) => {
8891
- tu(b4).forEach((S3) => u3.emit(S3));
8892
- }), u3.property;
8939
+ tu(b4).forEach((S4) => u3.emit(S4));
8940
+ }), this.activeSubscriptions.push({ id: s4, address: t4 }), u3.property;
8893
8941
  }
8894
8942
  }
8895
8943
  var r5 = BigInt(4294967295);
@@ -8902,8 +8950,8 @@ function uu(y4, t4 = false) {
8902
8950
  function vu(y4, t4 = false) {
8903
8951
  let u3 = y4.length, v3 = new Uint32Array(u3), s4 = new Uint32Array(u3);
8904
8952
  for (let b4 = 0;b4 < u3; b4++) {
8905
- let { h: S3, l: N10 } = uu(y4[b4], t4);
8906
- [v3[b4], s4[b4]] = [S3, N10];
8953
+ let { h: S4, l: N10 } = uu(y4[b4], t4);
8954
+ [v3[b4], s4[b4]] = [S4, N10];
8907
8955
  }
8908
8956
  return [v3, s4];
8909
8957
  }
@@ -8924,8 +8972,8 @@ function Yy(y4, t4 = "") {
8924
8972
  function Fy(y4, t4, u3 = "") {
8925
8973
  let v3 = hu(y4), s4 = y4?.length, b4 = t4 !== undefined;
8926
8974
  if (!v3 || b4 && s4 !== t4) {
8927
- let S3 = u3 && `"${u3}" `, N10 = b4 ? ` of length ${t4}` : "", h4 = v3 ? `length=${s4}` : `type=${typeof y4}`;
8928
- throw Error(S3 + "expected Uint8Array" + N10 + ", got " + h4);
8975
+ let S4 = u3 && `"${u3}" `, N10 = b4 ? ` of length ${t4}` : "", h4 = v3 ? `length=${s4}` : `type=${typeof y4}`;
8976
+ throw Error(S4 + "expected Uint8Array" + N10 + ", got " + h4);
8929
8977
  }
8930
8978
  return y4;
8931
8979
  }
@@ -8987,23 +9035,23 @@ var Gy = (y4, t4, u3) => u3 > 32 ? Nu(y4, t4, u3) : bu(y4, t4, u3);
8987
9035
  function Iu(y4, t4 = 24) {
8988
9036
  let u3 = new Uint32Array(10);
8989
9037
  for (let v3 = 24 - t4;v3 < 24; v3++) {
8990
- for (let S3 = 0;S3 < 10; S3++)
8991
- u3[S3] = y4[S3] ^ y4[S3 + 10] ^ y4[S3 + 20] ^ y4[S3 + 30] ^ y4[S3 + 40];
8992
- for (let S3 = 0;S3 < 10; S3 += 2) {
8993
- let N10 = (S3 + 8) % 10, h4 = (S3 + 2) % 10, U = u3[h4], K2 = u3[h4 + 1], D4 = ey(U, K2, 1) ^ u3[N10], _3 = Gy(U, K2, 1) ^ u3[N10 + 1];
9038
+ for (let S4 = 0;S4 < 10; S4++)
9039
+ u3[S4] = y4[S4] ^ y4[S4 + 10] ^ y4[S4 + 20] ^ y4[S4 + 30] ^ y4[S4 + 40];
9040
+ for (let S4 = 0;S4 < 10; S4 += 2) {
9041
+ let N10 = (S4 + 8) % 10, h4 = (S4 + 2) % 10, U = u3[h4], K2 = u3[h4 + 1], D4 = ey(U, K2, 1) ^ u3[N10], _3 = Gy(U, K2, 1) ^ u3[N10 + 1];
8994
9042
  for (let F2 = 0;F2 < 50; F2 += 10)
8995
- y4[S3 + F2] ^= D4, y4[S3 + F2 + 1] ^= _3;
9043
+ y4[S4 + F2] ^= D4, y4[S4 + F2 + 1] ^= _3;
8996
9044
  }
8997
9045
  let s4 = y4[2], b4 = y4[3];
8998
- for (let S3 = 0;S3 < 24; S3++) {
8999
- let N10 = Zy[S3], h4 = ey(s4, b4, N10), U = Gy(s4, b4, N10), K2 = oy[S3];
9046
+ for (let S4 = 0;S4 < 24; S4++) {
9047
+ let N10 = Zy[S4], h4 = ey(s4, b4, N10), U = Gy(s4, b4, N10), K2 = oy[S4];
9000
9048
  s4 = y4[K2], b4 = y4[K2 + 1], y4[K2] = h4, y4[K2 + 1] = U;
9001
9049
  }
9002
- for (let S3 = 0;S3 < 50; S3 += 10) {
9050
+ for (let S4 = 0;S4 < 50; S4 += 10) {
9003
9051
  for (let N10 = 0;N10 < 10; N10++)
9004
- u3[N10] = y4[S3 + N10];
9052
+ u3[N10] = y4[S4 + N10];
9005
9053
  for (let N10 = 0;N10 < 10; N10++)
9006
- y4[S3 + N10] ^= ~u3[(N10 + 2) % 10] & u3[(N10 + 4) % 10];
9054
+ y4[S4 + N10] ^= ~u3[(N10 + 2) % 10] & u3[(N10 + 4) % 10];
9007
9055
  }
9008
9056
  y4[0] ^= Eu[v3], y4[1] ^= Cu[v3];
9009
9057
  }
@@ -9038,7 +9086,7 @@ class _y {
9038
9086
  let { blockLen: t4, state: u3 } = this, v3 = y4.length;
9039
9087
  for (let s4 = 0;s4 < v3; ) {
9040
9088
  let b4 = Math.min(t4 - this.pos, v3 - s4);
9041
- for (let S3 = 0;S3 < b4; S3++)
9089
+ for (let S4 = 0;S4 < b4; S4++)
9042
9090
  u3[this.pos++] ^= y4[s4++];
9043
9091
  if (this.pos === t4)
9044
9092
  this.keccak();
@@ -9179,18 +9227,18 @@ class Jy {
9179
9227
  }
9180
9228
  async query(y4) {
9181
9229
  let t4 = await this.client.call("circles_query", [y4]), { columns: u3, rows: v3 } = t4, s4 = v3.map((b4) => {
9182
- let S3 = {};
9230
+ let S4 = {};
9183
9231
  return u3.forEach((N10, h4) => {
9184
- S3[N10] = b4[h4];
9185
- }), S3;
9232
+ S4[N10] = b4[h4];
9233
+ }), S4;
9186
9234
  });
9187
9235
  return L3(s4);
9188
9236
  }
9189
9237
  async tables() {
9190
9238
  return this.client.call("circles_tables", []);
9191
9239
  }
9192
- async events(y4 = null, t4 = null, u3 = null, v3 = null, s4 = null, b4 = false, S3 = 100, N10 = null) {
9193
- let h4 = await this.client.call("circles_events_paginated", [y4, t4, u3, v3, s4, b4, S3, N10]);
9240
+ async events(y4 = null, t4 = null, u3 = null, v3 = null, s4 = null, b4 = false, S4 = 100, N10 = null) {
9241
+ let h4 = await this.client.call("circles_events_paginated", [y4, t4, u3, v3, s4, b4, S4, N10]);
9194
9242
  return { events: L3(h4.events), hasMore: h4.hasMore, nextCursor: h4.nextCursor };
9195
9243
  }
9196
9244
  }
@@ -9224,8 +9272,8 @@ class z2 {
9224
9272
  let { columns: t4, rows: u3 } = y4;
9225
9273
  return u3.map((v3) => {
9226
9274
  let s4 = {};
9227
- return t4.forEach((b4, S3) => {
9228
- s4[b4] = v3[S3];
9275
+ return t4.forEach((b4, S4) => {
9276
+ s4[b4] = v3[S4];
9229
9277
  }), this.rowTransformer ? this.rowTransformer(s4) : s4;
9230
9278
  });
9231
9279
  }
@@ -9247,8 +9295,8 @@ class yt {
9247
9295
  let { columns: t4, rows: u3 } = y4;
9248
9296
  return u3.map((v3) => {
9249
9297
  let s4 = {};
9250
- return t4.forEach((b4, S3) => {
9251
- s4[b4] = v3[S3];
9298
+ return t4.forEach((b4, S4) => {
9299
+ s4[b4] = v3[S4];
9252
9300
  }), s4;
9253
9301
  });
9254
9302
  }
@@ -9390,11 +9438,11 @@ class tt {
9390
9438
  return this.V1_ACCURACY * this.V1_INFLATION_PCT_NUM ** y4 / this.V1_INFLATION_PCT_DEN ** y4;
9391
9439
  }
9392
9440
  static attoCrcToAttoCircles(y4, t4) {
9393
- let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S3 = this.v1InflateFactor(v3 + 1n);
9394
- return this.v1ToDemurrage(y4, b4, S3, s4, this.PERIOD_SEC);
9441
+ let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S4 = this.v1InflateFactor(v3 + 1n);
9442
+ return this.v1ToDemurrage(y4, b4, S4, s4, this.PERIOD_SEC);
9395
9443
  }
9396
9444
  static attoCirclesToAttoCrc(y4, t4) {
9397
- let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S3 = this.v1InflateFactor(v3 + 1n), N10 = b4 * (this.PERIOD_SEC - s4) + S3 * s4;
9445
+ let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S4 = this.v1InflateFactor(v3 + 1n), N10 = b4 * (this.PERIOD_SEC - s4) + S4 * s4;
9398
9446
  return y4 * 3n * this.V1_ACCURACY * this.PERIOD_SEC / N10;
9399
9447
  }
9400
9448
  static v1ToDemurrage(y4, t4, u3, v3, s4) {
@@ -9554,8 +9602,8 @@ class ht {
9554
9602
  this.client = y4;
9555
9603
  }
9556
9604
  async findGroups(y4 = 50, t4, u3) {
9557
- let v3 = t4 ? { nameStartsWith: t4.nameStartsWith, symbolStartsWith: t4.symbolStartsWith, ownerIn: t4.ownerIn?.map((S3) => P4(S3)) } : undefined, s4 = await this.client.call("circles_findGroups", [y4, v3 ?? null, u3 ?? null]), b4 = L3(s4.results).map((S3) => {
9558
- let N10 = S3;
9605
+ let v3 = t4 ? { nameStartsWith: t4.nameStartsWith, symbolStartsWith: t4.symbolStartsWith, ownerIn: t4.ownerIn?.map((S4) => P4(S4)) } : undefined, s4 = await this.client.call("circles_findGroups", [y4, v3 ?? null, u3 ?? null]), b4 = L3(s4.results).map((S4) => {
9606
+ let N10 = S4;
9559
9607
  if (!N10.owner && N10.mint)
9560
9608
  return { ...N10, owner: N10.mint };
9561
9609
  return N10;
@@ -9578,21 +9626,21 @@ class ht {
9578
9626
  if (t4.symbolStartsWith)
9579
9627
  v3.push({ Type: "FilterPredicate", FilterType: "Like", Column: "symbol", Value: t4.symbolStartsWith + "%" });
9580
9628
  if (t4.groupAddressIn && t4.groupAddressIn.length > 0) {
9581
- let b4 = t4.groupAddressIn.map((S3) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value: P4(S3) }));
9629
+ let b4 = t4.groupAddressIn.map((S4) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value: P4(S4) }));
9582
9630
  if (b4.length === 1)
9583
9631
  v3.push(b4[0]);
9584
9632
  else
9585
9633
  v3.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates: b4 });
9586
9634
  }
9587
9635
  if (t4.groupTypeIn && t4.groupTypeIn.length > 0) {
9588
- let b4 = t4.groupTypeIn.map((S3) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "type", Value: S3 }));
9636
+ let b4 = t4.groupTypeIn.map((S4) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "type", Value: S4 }));
9589
9637
  if (b4.length === 1)
9590
9638
  v3.push(b4[0]);
9591
9639
  else
9592
9640
  v3.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates: b4 });
9593
9641
  }
9594
9642
  if (t4.ownerIn && t4.ownerIn.length > 0) {
9595
- let b4 = t4.ownerIn.map((S3) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "owner", Value: P4(S3) }));
9643
+ let b4 = t4.ownerIn.map((S4) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "owner", Value: P4(S4) }));
9596
9644
  if (b4.length === 1)
9597
9645
  v3.push(b4[0]);
9598
9646
  else
@@ -9634,8 +9682,8 @@ class Ut {
9634
9682
  return L3(v3);
9635
9683
  }
9636
9684
  async getTransactionHistoryEnriched(y4, t4 = 0, u3 = null, v3 = 50, s4) {
9637
- let b4 = P4(y4), S3 = await this.client.call("circles_getTransactionHistoryEnriched", [b4, t4, u3, v3, s4 ?? null]);
9638
- return { hasMore: S3.hasMore, nextCursor: S3.nextCursor, results: L3(S3.results) };
9685
+ let b4 = P4(y4), S4 = await this.client.call("circles_getTransactionHistoryEnriched", [b4, t4, u3, v3, s4 ?? null]);
9686
+ return { hasMore: S4.hasMore, nextCursor: S4.nextCursor, results: L3(S4.results) };
9639
9687
  }
9640
9688
  async searchProfileByAddressOrName(y4, t4 = 20, u3, v3) {
9641
9689
  return this.client.call("circles_searchProfileByAddressOrName", v3 ? [y4, t4, u3 ?? null, v3] : [y4, t4, u3 ?? null]);
@@ -9821,11 +9869,11 @@ class Vu {
9821
9869
  return this.V1_ACCURACY * this.V1_INFLATION_PCT_NUM ** y4 / this.V1_INFLATION_PCT_DEN ** y4;
9822
9870
  }
9823
9871
  static attoCrcToAttoCircles(y4, t4) {
9824
- let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S3 = this.v1InflateFactor(v3 + 1n);
9825
- return this.v1ToDemurrage(y4, b4, S3, s4, this.PERIOD_SEC);
9872
+ let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S4 = this.v1InflateFactor(v3 + 1n);
9873
+ return this.v1ToDemurrage(y4, b4, S4, s4, this.PERIOD_SEC);
9826
9874
  }
9827
9875
  static attoCirclesToAttoCrc(y4, t4) {
9828
- let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S3 = this.v1InflateFactor(v3 + 1n), N10 = b4 * (this.PERIOD_SEC - s4) + S3 * s4;
9876
+ let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S4 = this.v1InflateFactor(v3 + 1n), N10 = b4 * (this.PERIOD_SEC - s4) + S4 * s4;
9829
9877
  return y4 * 3n * this.V1_ACCURACY * this.PERIOD_SEC / N10;
9830
9878
  }
9831
9879
  static v1ToDemurrage(y4, t4, u3, v3, s4) {
@@ -9866,7 +9914,7 @@ function iy(y4, t4) {
9866
9914
  }
9867
9915
  var Pt = (y4) => BigInt(y4);
9868
9916
  var $ = (y4) => parseInt(y4, 16);
9869
- var Wu = (y4) => {
9917
+ var wu = (y4) => {
9870
9918
  if (y4.startsWith("0x"))
9871
9919
  y4 = y4.slice(2);
9872
9920
  if (y4.length % 2 !== 0)
@@ -9876,14 +9924,14 @@ var Wu = (y4) => {
9876
9924
  t4[u3 / 2] = parseInt(y4.substr(u3, 2), 16);
9877
9925
  return t4;
9878
9926
  };
9879
- function wu(y4, t4) {
9927
+ function Qu(y4, t4) {
9880
9928
  if (typeof t4 === "string" && t4.startsWith("0x")) {
9881
9929
  let u3 = t4.slice(2);
9882
9930
  if (u3.length === 40)
9883
9931
  return t4;
9884
9932
  if (u3.length === 64) {
9885
9933
  if (y4.toLowerCase().includes("digest") || y4.toLowerCase().includes("data") || y4.toLowerCase().includes("bytes"))
9886
- return Wu(t4);
9934
+ return wu(t4);
9887
9935
  try {
9888
9936
  return Pt(t4);
9889
9937
  } catch {
@@ -9905,17 +9953,17 @@ function wu(y4, t4) {
9905
9953
  return false;
9906
9954
  return t4;
9907
9955
  }
9908
- function Qu(y4) {
9956
+ function Wu(y4) {
9909
9957
  let { event: t4, values: u3 } = y4, v3 = { $event: t4, blockNumber: u3.blockNumber ? $(u3.blockNumber) : 0, timestamp: u3.timestamp ? $(u3.timestamp) : undefined, transactionIndex: u3.transactionIndex ? $(u3.transactionIndex) : 0, logIndex: u3.logIndex ? $(u3.logIndex) : 0, transactionHash: u3.transactionHash };
9910
9958
  for (let [s4, b4] of Object.entries(u3)) {
9911
9959
  if (["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash"].includes(s4))
9912
9960
  continue;
9913
- v3[s4] = wu(s4, b4);
9961
+ v3[s4] = Qu(s4, b4);
9914
9962
  }
9915
9963
  return v3;
9916
9964
  }
9917
9965
  function lu(y4) {
9918
- return y4.map(Qu);
9966
+ return y4.map(Wu);
9919
9967
  }
9920
9968
 
9921
9969
  class Iy {
@@ -9992,6 +10040,7 @@ class xy {
9992
10040
  websocketConnected = false;
9993
10041
  pendingResponses = {};
9994
10042
  subscriptionListeners = {};
10043
+ activeSubscriptions = [];
9995
10044
  reconnectAttempt = 0;
9996
10045
  initialBackoff = 2000;
9997
10046
  maxBackoff = 120000;
@@ -10033,10 +10082,10 @@ class xy {
10033
10082
  this.websocket = new WebSocket(u3), this.websocket.onopen = () => {
10034
10083
  console.log("WebSocket connected"), this.websocketConnected = true, this.reconnectAttempt = 0, y4();
10035
10084
  }, this.websocket.onmessage = (v3) => {
10036
- let s4 = JSON.parse(v3.data), { id: b4, method: S3, params: N10 } = s4;
10085
+ let s4 = JSON.parse(v3.data), { id: b4, method: S4, params: N10 } = s4;
10037
10086
  if (b4 !== undefined && this.pendingResponses[b4])
10038
10087
  this.pendingResponses[b4].resolve(s4), delete this.pendingResponses[b4];
10039
- if (S3 === "circles_subscription" && N10?.result)
10088
+ if (S4 === "circles_subscription" && N10?.result)
10040
10089
  Object.values(this.subscriptionListeners).forEach((h4) => {
10041
10090
  h4.forEach((U) => U(N10.result));
10042
10091
  });
@@ -10060,17 +10109,32 @@ class xy {
10060
10109
  if (this.websocketConnected)
10061
10110
  return;
10062
10111
  try {
10063
- await this.connect(), console.log("Reconnection successful");
10112
+ await this.connect(), console.log("Reconnection successful"), await this.resubscribeActive();
10064
10113
  } catch (y4) {
10065
10114
  console.error("Reconnection attempt failed:", y4), this.scheduleReconnect();
10066
10115
  }
10067
10116
  }
10117
+ async resubscribeActive() {
10118
+ if (this.activeSubscriptions.length === 0)
10119
+ return;
10120
+ let y4 = [...this.activeSubscriptions];
10121
+ this.activeSubscriptions = [];
10122
+ for (let t4 of y4)
10123
+ try {
10124
+ let u3 = t4.address ? { address: t4.address } : {}, v3 = (await this.sendMessage("circles_subscribe", u3)).result, s4 = this.subscriptionListeners[t4.id];
10125
+ if (s4)
10126
+ this.subscriptionListeners[v3] = s4, delete this.subscriptionListeners[t4.id];
10127
+ this.activeSubscriptions.push({ id: v3, address: t4.address });
10128
+ } catch (u3) {
10129
+ console.error("Failed to re-issue circles_subscribe after reconnect:", u3), this.activeSubscriptions.push(t4);
10130
+ }
10131
+ }
10068
10132
  sendMessage(y4, t4, u3 = 5000) {
10069
10133
  if (!this.websocket || this.websocket.readyState !== WebSocket.OPEN)
10070
10134
  return Promise.reject(X2.connectionFailed(this.rpcUrl));
10071
10135
  let v3 = this.requestId++, s4 = { jsonrpc: "2.0", method: y4, params: t4, id: v3 };
10072
- return new Promise((b4, S3) => {
10073
- this.pendingResponses[v3] = { resolve: b4, reject: S3 }, this.websocket.send(JSON.stringify(s4)), setTimeout(() => {
10136
+ return new Promise((b4, S4) => {
10137
+ this.pendingResponses[v3] = { resolve: b4, reject: S4 }, this.websocket.send(JSON.stringify(s4)), setTimeout(() => {
10074
10138
  if (this.pendingResponses[v3])
10075
10139
  this.pendingResponses[v3].reject(X2.timeout(y4, u3)), delete this.pendingResponses[v3];
10076
10140
  }, u3);
@@ -10084,8 +10148,8 @@ class xy {
10084
10148
  if (!this.subscriptionListeners[s4])
10085
10149
  this.subscriptionListeners[s4] = [];
10086
10150
  return this.subscriptionListeners[s4].push((b4) => {
10087
- lu(b4).forEach((S3) => u3.emit(S3));
10088
- }), u3.property;
10151
+ lu(b4).forEach((S4) => u3.emit(S4));
10152
+ }), this.activeSubscriptions.push({ id: s4, address: t4 }), u3.property;
10089
10153
  }
10090
10154
  }
10091
10155
  var J = BigInt(4294967295);
@@ -10098,8 +10162,8 @@ function Ou(y4, t4 = false) {
10098
10162
  function Yu(y4, t4 = false) {
10099
10163
  let u3 = y4.length, v3 = new Uint32Array(u3), s4 = new Uint32Array(u3);
10100
10164
  for (let b4 = 0;b4 < u3; b4++) {
10101
- let { h: S3, l: N10 } = Ou(y4[b4], t4);
10102
- [v3[b4], s4[b4]] = [S3, N10];
10165
+ let { h: S4, l: N10 } = Ou(y4[b4], t4);
10166
+ [v3[b4], s4[b4]] = [S4, N10];
10103
10167
  }
10104
10168
  return [v3, s4];
10105
10169
  }
@@ -10120,8 +10184,8 @@ function Dt(y4, t4 = "") {
10120
10184
  function Ey(y4, t4, u3 = "") {
10121
10185
  let v3 = $u(y4), s4 = y4?.length, b4 = t4 !== undefined;
10122
10186
  if (!v3 || b4 && s4 !== t4) {
10123
- let S3 = u3 && `"${u3}" `, N10 = b4 ? ` of length ${t4}` : "", h4 = v3 ? `length=${s4}` : `type=${typeof y4}`;
10124
- throw Error(S3 + "expected Uint8Array" + N10 + ", got " + h4);
10187
+ let S4 = u3 && `"${u3}" `, N10 = b4 ? ` of length ${t4}` : "", h4 = v3 ? `length=${s4}` : `type=${typeof y4}`;
10188
+ throw Error(S4 + "expected Uint8Array" + N10 + ", got " + h4);
10125
10189
  }
10126
10190
  return y4;
10127
10191
  }
@@ -10183,23 +10247,23 @@ var mt = (y4, t4, u3) => u3 > 32 ? Gu(y4, t4, u3) : du(y4, t4, u3);
10183
10247
  function v02(y4, t4 = 24) {
10184
10248
  let u3 = new Uint32Array(10);
10185
10249
  for (let v3 = 24 - t4;v3 < 24; v3++) {
10186
- for (let S3 = 0;S3 < 10; S3++)
10187
- u3[S3] = y4[S3] ^ y4[S3 + 10] ^ y4[S3 + 20] ^ y4[S3 + 30] ^ y4[S3 + 40];
10188
- for (let S3 = 0;S3 < 10; S3 += 2) {
10189
- let N10 = (S3 + 8) % 10, h4 = (S3 + 2) % 10, U = u3[h4], K2 = u3[h4 + 1], D4 = _t(U, K2, 1) ^ u3[N10], _3 = mt(U, K2, 1) ^ u3[N10 + 1];
10250
+ for (let S4 = 0;S4 < 10; S4++)
10251
+ u3[S4] = y4[S4] ^ y4[S4 + 10] ^ y4[S4 + 20] ^ y4[S4 + 30] ^ y4[S4 + 40];
10252
+ for (let S4 = 0;S4 < 10; S4 += 2) {
10253
+ let N10 = (S4 + 8) % 10, h4 = (S4 + 2) % 10, U = u3[h4], K2 = u3[h4 + 1], D4 = _t(U, K2, 1) ^ u3[N10], _3 = mt(U, K2, 1) ^ u3[N10 + 1];
10190
10254
  for (let F2 = 0;F2 < 50; F2 += 10)
10191
- y4[S3 + F2] ^= D4, y4[S3 + F2 + 1] ^= _3;
10255
+ y4[S4 + F2] ^= D4, y4[S4 + F2 + 1] ^= _3;
10192
10256
  }
10193
10257
  let s4 = y4[2], b4 = y4[3];
10194
- for (let S3 = 0;S3 < 24; S3++) {
10195
- let N10 = Ct[S3], h4 = _t(s4, b4, N10), U = mt(s4, b4, N10), K2 = Et[S3];
10258
+ for (let S4 = 0;S4 < 24; S4++) {
10259
+ let N10 = Ct[S4], h4 = _t(s4, b4, N10), U = mt(s4, b4, N10), K2 = Et[S4];
10196
10260
  s4 = y4[K2], b4 = y4[K2 + 1], y4[K2] = h4, y4[K2 + 1] = U;
10197
10261
  }
10198
- for (let S3 = 0;S3 < 50; S3 += 10) {
10262
+ for (let S4 = 0;S4 < 50; S4 += 10) {
10199
10263
  for (let N10 = 0;N10 < 10; N10++)
10200
- u3[N10] = y4[S3 + N10];
10264
+ u3[N10] = y4[S4 + N10];
10201
10265
  for (let N10 = 0;N10 < 10; N10++)
10202
- y4[S3 + N10] ^= ~u3[(N10 + 2) % 10] & u3[(N10 + 4) % 10];
10266
+ y4[S4 + N10] ^= ~u3[(N10 + 2) % 10] & u3[(N10 + 4) % 10];
10203
10267
  }
10204
10268
  y4[0] ^= t02[v3], y4[1] ^= u02[v3];
10205
10269
  }
@@ -10234,7 +10298,7 @@ class Hy {
10234
10298
  let { blockLen: t4, state: u3 } = this, v3 = y4.length;
10235
10299
  for (let s4 = 0;s4 < v3; ) {
10236
10300
  let b4 = Math.min(t4 - this.pos, v3 - s4);
10237
- for (let S3 = 0;S3 < b4; S3++)
10301
+ for (let S4 = 0;S4 < b4; S4++)
10238
10302
  u3[this.pos++] ^= y4[s4++];
10239
10303
  if (this.pos === t4)
10240
10304
  this.keccak();
@@ -10314,18 +10378,18 @@ function U02(y4) {
10314
10378
  let t4 = y4.replace("0x", "");
10315
10379
  return t4.length === 40 && /^[0-9a-fA-F]{40}$/.test(t4);
10316
10380
  }
10317
- function W(y4) {
10381
+ function w3(y4) {
10318
10382
  if (y4 === null || y4 === undefined)
10319
10383
  return y4;
10320
10384
  if (U02(y4))
10321
10385
  return h02(y4);
10322
10386
  if (Array.isArray(y4))
10323
- return y4.map((t4) => W(t4));
10387
+ return y4.map((t4) => w3(t4));
10324
10388
  if (typeof y4 === "object" && y4 !== null) {
10325
10389
  let t4 = {};
10326
10390
  for (let u3 in y4)
10327
10391
  if (Object.prototype.hasOwnProperty.call(y4, u3))
10328
- t4[u3] = W(y4[u3]);
10392
+ t4[u3] = w3(y4[u3]);
10329
10393
  return t4;
10330
10394
  }
10331
10395
  return y4;
@@ -10360,7 +10424,7 @@ class Ay {
10360
10424
  }
10361
10425
  async findPath(y4) {
10362
10426
  let t4 = K02(y4), u3 = await this.client.call("circlesV2_findPath", [t4]), v3 = yy(u3);
10363
- return W(v3);
10427
+ return w3(v3);
10364
10428
  }
10365
10429
  async findMaxFlow(y4) {
10366
10430
  let t4 = await this.findPath({ ...y4, targetFlow: P02 });
@@ -10397,8 +10461,8 @@ class Cy {
10397
10461
  let { columns: t4, rows: u3 } = y4;
10398
10462
  return u3.map((v3) => {
10399
10463
  let s4 = {};
10400
- return t4.forEach((b4, S3) => {
10401
- s4[b4] = v3[S3];
10464
+ return t4.forEach((b4, S4) => {
10465
+ s4[b4] = v3[S4];
10402
10466
  }), this.rowTransformer ? this.rowTransformer(s4) : s4;
10403
10467
  });
10404
10468
  }
@@ -10511,11 +10575,11 @@ class At {
10511
10575
  return this.V1_ACCURACY * this.V1_INFLATION_PCT_NUM ** y4 / this.V1_INFLATION_PCT_DEN ** y4;
10512
10576
  }
10513
10577
  static attoCrcToAttoCircles(y4, t4) {
10514
- let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S3 = this.v1InflateFactor(v3 + 1n);
10515
- return this.v1ToDemurrage(y4, b4, S3, s4, this.PERIOD_SEC);
10578
+ let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S4 = this.v1InflateFactor(v3 + 1n);
10579
+ return this.v1ToDemurrage(y4, b4, S4, s4, this.PERIOD_SEC);
10516
10580
  }
10517
10581
  static attoCirclesToAttoCrc(y4, t4) {
10518
- let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S3 = this.v1InflateFactor(v3 + 1n), N10 = b4 * (this.PERIOD_SEC - s4) + S3 * s4;
10582
+ let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S4 = this.v1InflateFactor(v3 + 1n), N10 = b4 * (this.PERIOD_SEC - s4) + S4 * s4;
10519
10583
  return y4 * 3n * this.V1_ACCURACY * this.PERIOD_SEC / N10;
10520
10584
  }
10521
10585
  static v1ToDemurrage(y4, t4, u3, v3, s4) {
@@ -10535,7 +10599,7 @@ class Xy {
10535
10599
  }
10536
10600
  async getTokenBalances(y4) {
10537
10601
  let t4 = (await this.client.call("circles_getTokenBalances", [C4(y4)])).map((u3) => yy(u3));
10538
- return W(t4);
10602
+ return w3(t4);
10539
10603
  }
10540
10604
  }
10541
10605
 
@@ -10545,8 +10609,8 @@ class gy {
10545
10609
  this.client = y4;
10546
10610
  }
10547
10611
  async findGroups(y4 = 50, t4, u3) {
10548
- let v3 = t4 ? { nameStartsWith: t4.nameStartsWith, symbolStartsWith: t4.symbolStartsWith, ownerIn: t4.ownerIn?.map((S3) => C4(S3)) } : undefined, s4 = await this.client.call("circles_findGroups", [y4, v3 ?? null, u3 ?? null]), b4 = W(s4.results).map((S3) => {
10549
- let N10 = S3;
10612
+ let v3 = t4 ? { nameStartsWith: t4.nameStartsWith, symbolStartsWith: t4.symbolStartsWith, ownerIn: t4.ownerIn?.map((S4) => C4(S4)) } : undefined, s4 = await this.client.call("circles_findGroups", [y4, v3 ?? null, u3 ?? null]), b4 = w3(s4.results).map((S4) => {
10613
+ let N10 = S4;
10550
10614
  if (!N10.owner && N10.mint)
10551
10615
  return { ...N10, owner: N10.mint };
10552
10616
  return N10;
@@ -10555,11 +10619,11 @@ class gy {
10555
10619
  }
10556
10620
  async getGroupMemberships(y4, t4 = 50, u3) {
10557
10621
  let v3 = await this.client.call("circles_getGroupMemberships", [C4(y4), t4, u3 ?? null]);
10558
- return { hasMore: v3.hasMore, nextCursor: v3.nextCursor, results: W(v3.results) };
10622
+ return { hasMore: v3.hasMore, nextCursor: v3.nextCursor, results: w3(v3.results) };
10559
10623
  }
10560
10624
  async getGroupMembers(y4, t4 = 100, u3) {
10561
10625
  let v3 = await this.client.call("circles_getGroupMembers", [C4(y4), t4, u3 ?? null]);
10562
- return { hasMore: v3.hasMore, nextCursor: v3.nextCursor, results: W(v3.results) };
10626
+ return { hasMore: v3.hasMore, nextCursor: v3.nextCursor, results: w3(v3.results) };
10563
10627
  }
10564
10628
  getGroups(y4 = 50, t4, u3 = "DESC") {
10565
10629
  let v3 = [];
@@ -10569,21 +10633,21 @@ class gy {
10569
10633
  if (t4.symbolStartsWith)
10570
10634
  v3.push({ Type: "FilterPredicate", FilterType: "Like", Column: "symbol", Value: t4.symbolStartsWith + "%" });
10571
10635
  if (t4.groupAddressIn && t4.groupAddressIn.length > 0) {
10572
- let b4 = t4.groupAddressIn.map((S3) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value: C4(S3) }));
10636
+ let b4 = t4.groupAddressIn.map((S4) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value: C4(S4) }));
10573
10637
  if (b4.length === 1)
10574
10638
  v3.push(b4[0]);
10575
10639
  else
10576
10640
  v3.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates: b4 });
10577
10641
  }
10578
10642
  if (t4.groupTypeIn && t4.groupTypeIn.length > 0) {
10579
- let b4 = t4.groupTypeIn.map((S3) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "type", Value: S3 }));
10643
+ let b4 = t4.groupTypeIn.map((S4) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "type", Value: S4 }));
10580
10644
  if (b4.length === 1)
10581
10645
  v3.push(b4[0]);
10582
10646
  else
10583
10647
  v3.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates: b4 });
10584
10648
  }
10585
10649
  if (t4.ownerIn && t4.ownerIn.length > 0) {
10586
- let b4 = t4.ownerIn.map((S3) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "owner", Value: C4(S3) }));
10650
+ let b4 = t4.ownerIn.map((S4) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "owner", Value: C4(S4) }));
10587
10651
  if (b4.length === 1)
10588
10652
  v3.push(b4[0]);
10589
10653
  else
@@ -10595,15 +10659,15 @@ class gy {
10595
10659
  v3.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "treasury", Value: C4(t4.treasuryEquals) });
10596
10660
  }
10597
10661
  let s4 = v3.length > 1 ? [{ Type: "Conjunction", ConjunctionType: "And", Predicates: v3 }] : v3;
10598
- return new Cy(this.client, { namespace: "V_CrcV2", table: "Groups", sortOrder: u3, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "type", "owner", "mintPolicy", "mintHandler", "treasury", "service", "feeCollection", "memberCount", "name", "symbol", "cidV0Digest", "erc20WrapperDemurraged", "erc20WrapperStatic"], filter: s4, limit: y4 }, (b4) => W(b4));
10662
+ return new Cy(this.client, { namespace: "V_CrcV2", table: "Groups", sortOrder: u3, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "type", "owner", "mintPolicy", "mintHandler", "treasury", "service", "feeCollection", "memberCount", "name", "symbol", "cidV0Digest", "erc20WrapperDemurraged", "erc20WrapperStatic"], filter: s4, limit: y4 }, (b4) => w3(b4));
10599
10663
  }
10600
10664
  getGroupHolders(y4, t4 = 100) {
10601
10665
  let u3 = C4(y4);
10602
- return new Cy(this.client, { namespace: "V_Crc", table: "TokenBalances", sortOrder: "DESC", columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "token", "account", "balance", "lastChangedAt"], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "token", Value: u3 }], limit: t4 }, (v3) => W(v3));
10666
+ return new Cy(this.client, { namespace: "V_Crc", table: "TokenBalances", sortOrder: "DESC", columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "token", "account", "balance", "lastChangedAt"], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "token", Value: u3 }], limit: t4 }, (v3) => w3(v3));
10603
10667
  }
10604
10668
  }
10605
10669
 
10606
- class w4 {
10670
+ class Q {
10607
10671
  static ONE_64 = 1n << 64n;
10608
10672
  static GAMMA_64 = 18443079296116538654n;
10609
10673
  static BETA_64 = 18450409579521241655n;
@@ -10703,11 +10767,11 @@ class w4 {
10703
10767
  return this.V1_ACCURACY * this.V1_INFLATION_PCT_NUM ** y4 / this.V1_INFLATION_PCT_DEN ** y4;
10704
10768
  }
10705
10769
  static attoCrcToAttoCircles(y4, t4) {
10706
- let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S3 = this.v1InflateFactor(v3 + 1n);
10707
- return this.v1ToDemurrage(y4, b4, S3, s4, this.PERIOD_SEC);
10770
+ let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S4 = this.v1InflateFactor(v3 + 1n);
10771
+ return this.v1ToDemurrage(y4, b4, S4, s4, this.PERIOD_SEC);
10708
10772
  }
10709
10773
  static attoCirclesToAttoCrc(y4, t4) {
10710
- let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S3 = this.v1InflateFactor(v3 + 1n), N10 = b4 * (this.PERIOD_SEC - s4) + S3 * s4;
10774
+ let u3 = t4 - this.INFLATION_DAY_ZERO_UNIX, v3 = u3 / this.PERIOD_SEC, s4 = u3 % this.PERIOD_SEC, b4 = this.v1InflateFactor(v3), S4 = this.v1InflateFactor(v3 + 1n), N10 = b4 * (this.PERIOD_SEC - s4) + S4 * s4;
10711
10775
  return y4 * 3n * this.V1_ACCURACY * this.PERIOD_SEC / N10;
10712
10776
  }
10713
10777
  static v1ToDemurrage(y4, t4, u3, v3, s4) {
@@ -10728,8 +10792,8 @@ function D02(y4, t4 = false) {
10728
10792
  function M02(y4, t4 = false) {
10729
10793
  let u3 = y4.length, v3 = new Uint32Array(u3), s4 = new Uint32Array(u3);
10730
10794
  for (let b4 = 0;b4 < u3; b4++) {
10731
- let { h: S3, l: N10 } = D02(y4[b4], t4);
10732
- [v3[b4], s4[b4]] = [S3, N10];
10795
+ let { h: S4, l: N10 } = D02(y4[b4], t4);
10796
+ [v3[b4], s4[b4]] = [S4, N10];
10733
10797
  }
10734
10798
  return [v3, s4];
10735
10799
  }
@@ -10750,8 +10814,8 @@ function gt(y4, t4 = "") {
10750
10814
  function Ty(y4, t4, u3 = "") {
10751
10815
  let v3 = i02(y4), s4 = y4?.length, b4 = t4 !== undefined;
10752
10816
  if (!v3 || b4 && s4 !== t4) {
10753
- let S3 = u3 && `"${u3}" `, N10 = b4 ? ` of length ${t4}` : "", h4 = v3 ? `length=${s4}` : `type=${typeof y4}`;
10754
- throw Error(S3 + "expected Uint8Array" + N10 + ", got " + h4);
10817
+ let S4 = u3 && `"${u3}" `, N10 = b4 ? ` of length ${t4}` : "", h4 = v3 ? `length=${s4}` : `type=${typeof y4}`;
10818
+ throw Error(S4 + "expected Uint8Array" + N10 + ", got " + h4);
10755
10819
  }
10756
10820
  return y4;
10757
10821
  }
@@ -10770,7 +10834,7 @@ function E02(y4, t4) {
10770
10834
  function C02(y4) {
10771
10835
  return new Uint32Array(y4.buffer, y4.byteOffset, Math.floor(y4.byteLength / 4));
10772
10836
  }
10773
- function wt(...y4) {
10837
+ function Qt(...y4) {
10774
10838
  for (let t4 = 0;t4 < y4.length; t4++)
10775
10839
  y4[t4].fill(0);
10776
10840
  }
@@ -10794,11 +10858,11 @@ var g02 = BigInt(2);
10794
10858
  var f02 = BigInt(7);
10795
10859
  var T02 = BigInt(256);
10796
10860
  var p02 = BigInt(113);
10797
- var Qt = [];
10861
+ var Wt = [];
10798
10862
  var lt = [];
10799
10863
  var Ot = [];
10800
10864
  for (let y4 = 0, t4 = R4, u3 = 1, v3 = 0;y4 < 24; y4++) {
10801
- [u3, v3] = [v3, (2 * u3 + 3 * v3) % 5], Qt.push(2 * (5 * v3 + u3)), lt.push((y4 + 1) * (y4 + 2) / 2 % 64);
10865
+ [u3, v3] = [v3, (2 * u3 + 3 * v3) % 5], Wt.push(2 * (5 * v3 + u3)), lt.push((y4 + 1) * (y4 + 2) / 2 % 64);
10802
10866
  let s4 = X02;
10803
10867
  for (let b4 = 0;b4 < 7; b4++)
10804
10868
  if (t4 = (t4 << R4 ^ (t4 >> f02) * p02) % T02, t4 & g02)
@@ -10810,30 +10874,30 @@ var c02 = Yt[0];
10810
10874
  var V02 = Yt[1];
10811
10875
  var pt = (y4, t4, u3) => u3 > 32 ? m02(y4, t4, u3) : L02(y4, t4, u3);
10812
10876
  var ct = (y4, t4, u3) => u3 > 32 ? k02(y4, t4, u3) : _02(y4, t4, u3);
10813
- function W02(y4, t4 = 24) {
10877
+ function w02(y4, t4 = 24) {
10814
10878
  let u3 = new Uint32Array(10);
10815
10879
  for (let v3 = 24 - t4;v3 < 24; v3++) {
10816
- for (let S3 = 0;S3 < 10; S3++)
10817
- u3[S3] = y4[S3] ^ y4[S3 + 10] ^ y4[S3 + 20] ^ y4[S3 + 30] ^ y4[S3 + 40];
10818
- for (let S3 = 0;S3 < 10; S3 += 2) {
10819
- let N10 = (S3 + 8) % 10, h4 = (S3 + 2) % 10, U = u3[h4], K2 = u3[h4 + 1], D4 = pt(U, K2, 1) ^ u3[N10], _3 = ct(U, K2, 1) ^ u3[N10 + 1];
10880
+ for (let S4 = 0;S4 < 10; S4++)
10881
+ u3[S4] = y4[S4] ^ y4[S4 + 10] ^ y4[S4 + 20] ^ y4[S4 + 30] ^ y4[S4 + 40];
10882
+ for (let S4 = 0;S4 < 10; S4 += 2) {
10883
+ let N10 = (S4 + 8) % 10, h4 = (S4 + 2) % 10, U = u3[h4], K2 = u3[h4 + 1], D4 = pt(U, K2, 1) ^ u3[N10], _3 = ct(U, K2, 1) ^ u3[N10 + 1];
10820
10884
  for (let F2 = 0;F2 < 50; F2 += 10)
10821
- y4[S3 + F2] ^= D4, y4[S3 + F2 + 1] ^= _3;
10885
+ y4[S4 + F2] ^= D4, y4[S4 + F2 + 1] ^= _3;
10822
10886
  }
10823
10887
  let s4 = y4[2], b4 = y4[3];
10824
- for (let S3 = 0;S3 < 24; S3++) {
10825
- let N10 = lt[S3], h4 = pt(s4, b4, N10), U = ct(s4, b4, N10), K2 = Qt[S3];
10888
+ for (let S4 = 0;S4 < 24; S4++) {
10889
+ let N10 = lt[S4], h4 = pt(s4, b4, N10), U = ct(s4, b4, N10), K2 = Wt[S4];
10826
10890
  s4 = y4[K2], b4 = y4[K2 + 1], y4[K2] = h4, y4[K2 + 1] = U;
10827
10891
  }
10828
- for (let S3 = 0;S3 < 50; S3 += 10) {
10892
+ for (let S4 = 0;S4 < 50; S4 += 10) {
10829
10893
  for (let N10 = 0;N10 < 10; N10++)
10830
- u3[N10] = y4[S3 + N10];
10894
+ u3[N10] = y4[S4 + N10];
10831
10895
  for (let N10 = 0;N10 < 10; N10++)
10832
- y4[S3 + N10] ^= ~u3[(N10 + 2) % 10] & u3[(N10 + 4) % 10];
10896
+ y4[S4 + N10] ^= ~u3[(N10 + 2) % 10] & u3[(N10 + 4) % 10];
10833
10897
  }
10834
10898
  y4[0] ^= c02[v3], y4[1] ^= V02[v3];
10835
10899
  }
10836
- wt(u3);
10900
+ Qt(u3);
10837
10901
  }
10838
10902
 
10839
10903
  class cy {
@@ -10857,14 +10921,14 @@ class cy {
10857
10921
  return this._cloneInto();
10858
10922
  }
10859
10923
  keccak() {
10860
- Tt(this.state32), W02(this.state32, this.rounds), Tt(this.state32), this.posOut = 0, this.pos = 0;
10924
+ Tt(this.state32), w02(this.state32, this.rounds), Tt(this.state32), this.posOut = 0, this.pos = 0;
10861
10925
  }
10862
10926
  update(y4) {
10863
10927
  ft(this), Ty(y4);
10864
10928
  let { blockLen: t4, state: u3 } = this, v3 = y4.length;
10865
10929
  for (let s4 = 0;s4 < v3; ) {
10866
10930
  let b4 = Math.min(t4 - this.pos, v3 - s4);
10867
- for (let S3 = 0;S3 < b4; S3++)
10931
+ for (let S4 = 0;S4 < b4; S4++)
10868
10932
  u3[this.pos++] ^= y4[s4++];
10869
10933
  if (this.pos === t4)
10870
10934
  this.keccak();
@@ -10908,15 +10972,15 @@ class cy {
10908
10972
  return this.digestInto(new Uint8Array(this.outputLen));
10909
10973
  }
10910
10974
  destroy() {
10911
- this.destroyed = true, wt(this.state);
10975
+ this.destroyed = true, Qt(this.state);
10912
10976
  }
10913
10977
  _cloneInto(y4) {
10914
10978
  let { blockLen: t4, suffix: u3, outputLen: v3, rounds: s4, enableXOF: b4 } = this;
10915
10979
  return y4 ||= new cy(t4, u3, v3, b4, s4), y4.state32.set(this.state32), y4.pos = this.pos, y4.posOut = this.posOut, y4.finished = this.finished, y4.rounds = s4, y4.suffix = u3, y4.outputLen = v3, y4.enableXOF = b4, y4.destroyed = this.destroyed, y4;
10916
10980
  }
10917
10981
  }
10918
- var w02 = (y4, t4, u3, v3 = {}) => A02(() => new cy(t4, y4, u3), v3);
10919
- var nt = w02(1, 136, 32);
10982
+ var Q02 = (y4, t4, u3, v3 = {}) => A02(() => new cy(t4, y4, u3), v3);
10983
+ var nt = Q02(1, 136, 32);
10920
10984
  var dt = [];
10921
10985
  for (let y4 = 0;y4 < 256; y4++)
10922
10986
  dt[y4] = y4.toString(16).padStart(2, "0");
@@ -10929,8 +10993,8 @@ function et(y4) {
10929
10993
  var k3 = 64;
10930
10994
  var Vy = 32;
10931
10995
  var uy = (y4) => y4.startsWith("0x") ? y4.slice(2) : y4;
10932
- var Q = (y4) => y4.toString(16).padStart(k3, "0");
10933
- function Q02(y4) {
10996
+ var W = (y4) => y4.toString(16).padStart(k3, "0");
10997
+ function W02(y4) {
10934
10998
  let t4 = y4.toLowerCase().replace("0x", ""), u3 = et(nt(new TextEncoder().encode(t4))).slice(2), v3 = "0x";
10935
10999
  for (let s4 = 0;s4 < t4.length; s4++)
10936
11000
  v3 += parseInt(u3[s4], 16) >= 8 ? t4[s4].toUpperCase() : t4[s4];
@@ -10978,31 +11042,31 @@ function l4(y4, t4, u3) {
10978
11042
  return d02(y4, t4);
10979
11043
  }
10980
11044
  function Y02(y4, t4, u3) {
10981
- let v3 = y4.slice(0, y4.indexOf("[")), s4 = y4.endsWith("[]"), b4 = B4(v3, u3), S3;
11045
+ let v3 = y4.slice(0, y4.indexOf("[")), s4 = y4.endsWith("[]"), b4 = B4(v3, u3), S4;
10982
11046
  if (b4) {
10983
11047
  let N10 = t4.map((U) => l4(v3, U, u3)), h4 = t4.length * Vy;
10984
- S3 = N10.map((U) => {
11048
+ S4 = N10.map((U) => {
10985
11049
  let K2 = h4;
10986
- return h4 += U.length / 2, Q(K2);
11050
+ return h4 += U.length / 2, W(K2);
10987
11051
  }).join("") + N10.join("");
10988
11052
  } else
10989
- S3 = t4.map((N10) => l4(v3, N10, u3)).join("");
10990
- return s4 ? Q(t4.length) + S3 : S3;
11053
+ S4 = t4.map((N10) => l4(v3, N10, u3)).join("");
11054
+ return s4 ? W(t4.length) + S4 : S4;
10991
11055
  }
10992
11056
  function n02(y4, t4) {
10993
11057
  let u3 = Array.isArray(t4), v3 = [], s4 = [], b4 = [];
10994
- for (let S3 = 0;S3 < y4.length; S3++) {
10995
- let N10 = y4[S3], h4 = u3 ? t4[S3] : t4[N10.name || ""], U = B4(N10.type, N10.components);
11058
+ for (let S4 = 0;S4 < y4.length; S4++) {
11059
+ let N10 = y4[S4], h4 = u3 ? t4[S4] : t4[N10.name || ""], U = B4(N10.type, N10.components);
10996
11060
  if (b4.push(U), U)
10997
11061
  v3.push(""), s4.push(l4(N10.type, h4, N10.components));
10998
11062
  else
10999
11063
  v3.push(l4(N10.type, h4, N10.components));
11000
11064
  }
11001
11065
  if (s4.length > 0) {
11002
- let S3 = v3.reduce((U, K2, D4) => U + (b4[D4] ? Vy : K2.length / 2), 0), N10 = "", h4 = 0;
11066
+ let S4 = v3.reduce((U, K2, D4) => U + (b4[D4] ? Vy : K2.length / 2), 0), N10 = "", h4 = 0;
11003
11067
  for (let U = 0;U < y4.length; U++)
11004
11068
  if (b4[U])
11005
- N10 += Q(S3), S3 += s4[h4].length / 2, h4++;
11069
+ N10 += W(S4), S4 += s4[h4].length / 2, h4++;
11006
11070
  else
11007
11071
  N10 += v3[U];
11008
11072
  return N10 + s4.join("");
@@ -11013,10 +11077,10 @@ function d02(y4, t4) {
11013
11077
  if (y4 === "address")
11014
11078
  return uy(t4).toLowerCase().padStart(k3, "0");
11015
11079
  if (y4 === "bool")
11016
- return Q(t4 ? 1 : 0);
11080
+ return W(t4 ? 1 : 0);
11017
11081
  if (y4.startsWith("uint")) {
11018
11082
  let u3 = typeof t4 === "bigint" ? t4 : BigInt(t4);
11019
- return Q(u3);
11083
+ return W(u3);
11020
11084
  }
11021
11085
  if (y4.startsWith("int")) {
11022
11086
  let u3 = typeof t4 === "bigint" ? t4 : BigInt(t4);
@@ -11024,16 +11088,16 @@ function d02(y4, t4) {
11024
11088
  let v3 = y4 === "int" ? 256 : parseInt(y4.slice(3));
11025
11089
  u3 = (1n << BigInt(v3)) + u3;
11026
11090
  }
11027
- return Q(u3);
11091
+ return W(u3);
11028
11092
  }
11029
11093
  if (y4.startsWith("bytes") && y4 !== "bytes")
11030
11094
  return uy(t4).padEnd(k3, "0");
11031
11095
  if (y4 === "bytes") {
11032
- let u3 = uy(t4), v3 = Q(u3.length / 2), s4 = u3.padEnd(Math.ceil(u3.length / k3) * k3, "0");
11096
+ let u3 = uy(t4), v3 = W(u3.length / 2), s4 = u3.padEnd(Math.ceil(u3.length / k3) * k3, "0");
11033
11097
  return v3 + s4;
11034
11098
  }
11035
11099
  if (y4 === "string") {
11036
- let u3 = Array.from(new TextEncoder().encode(t4)).map((b4) => b4.toString(16).padStart(2, "0")).join(""), v3 = Q(u3.length / 2), s4 = u3.padEnd(Math.ceil(u3.length / k3) * k3, "0");
11100
+ let u3 = Array.from(new TextEncoder().encode(t4)).map((b4) => b4.toString(16).padStart(2, "0")).join(""), v3 = W(u3.length / 2), s4 = u3.padEnd(Math.ceil(u3.length / k3) * k3, "0");
11037
11101
  return v3 + s4;
11038
11102
  }
11039
11103
  throw Error(`Unsupported type: ${y4}`);
@@ -11055,9 +11119,9 @@ function e02(y4, t4, u3, v3) {
11055
11119
  }
11056
11120
  return { value: U, consumed: k3 };
11057
11121
  }
11058
- let S3 = y4.match(/\[(\d+)\]$/);
11059
- if (S3) {
11060
- let N10 = parseInt(S3[1]), h4 = [], U = 0;
11122
+ let S4 = y4.match(/\[(\d+)\]$/);
11123
+ if (S4) {
11124
+ let N10 = parseInt(S4[1]), h4 = [], U = 0;
11061
11125
  for (let K2 = 0;K2 < N10; K2++) {
11062
11126
  let D4 = a4(s4, t4, u3 + U, v3);
11063
11127
  h4.push(D4.value), U += D4.consumed;
@@ -11069,22 +11133,22 @@ function e02(y4, t4, u3, v3) {
11069
11133
  function G02(y4, t4, u3) {
11070
11134
  let v3 = [], s4 = u3;
11071
11135
  for (let b4 of y4) {
11072
- let S3 = a4(b4.type, t4, s4, b4.components);
11073
- v3.push(S3.value), s4 += S3.consumed;
11136
+ let S4 = a4(b4.type, t4, s4, b4.components);
11137
+ v3.push(S4.value), s4 += S4.consumed;
11074
11138
  }
11075
11139
  return { value: v3, consumed: s4 - u3 };
11076
11140
  }
11077
11141
  function $02(y4, t4, u3) {
11078
11142
  let v3 = t4.slice(u3, u3 + k3);
11079
11143
  if (y4 === "address")
11080
- return { value: Q02("0x" + v3.slice(24)), consumed: k3 };
11144
+ return { value: W02("0x" + v3.slice(24)), consumed: k3 };
11081
11145
  if (y4 === "bool")
11082
11146
  return { value: parseInt(v3, 16) !== 0, consumed: k3 };
11083
11147
  if (y4.startsWith("uint"))
11084
11148
  return { value: BigInt("0x" + v3), consumed: k3 };
11085
11149
  if (y4.startsWith("int")) {
11086
- let s4 = BigInt("0x" + v3), b4 = y4 === "int" ? 256 : parseInt(y4.slice(3)), S3 = 1n << BigInt(b4 - 1);
11087
- return { value: s4 >= S3 ? s4 - (1n << BigInt(b4)) : s4, consumed: k3 };
11150
+ let s4 = BigInt("0x" + v3), b4 = y4 === "int" ? 256 : parseInt(y4.slice(3)), S4 = 1n << BigInt(b4 - 1);
11151
+ return { value: s4 >= S4 ? s4 - (1n << BigInt(b4)) : s4, consumed: k3 };
11088
11152
  }
11089
11153
  if (y4.startsWith("bytes") && y4 !== "bytes") {
11090
11154
  let s4 = parseInt(y4.match(/^bytes(\d+)$/)[1]);
@@ -11095,23 +11159,23 @@ function $02(y4, t4, u3) {
11095
11159
  return { value: "0x" + t4.slice(s4 + k3, s4 + k3 + b4), consumed: k3 };
11096
11160
  }
11097
11161
  if (y4 === "string") {
11098
- let s4 = parseInt(v3, 16) * 2, b4 = parseInt(t4.slice(s4, s4 + k3), 16) * 2, S3 = t4.slice(s4 + k3, s4 + k3 + b4), N10 = new Uint8Array(S3.match(/.{2}/g)?.map((h4) => parseInt(h4, 16)) || []);
11162
+ let s4 = parseInt(v3, 16) * 2, b4 = parseInt(t4.slice(s4, s4 + k3), 16) * 2, S4 = t4.slice(s4 + k3, s4 + k3 + b4), N10 = new Uint8Array(S4.match(/.{2}/g)?.map((h4) => parseInt(h4, 16)) || []);
11099
11163
  return { value: new TextDecoder().decode(N10), consumed: k3 };
11100
11164
  }
11101
11165
  throw Error(`Unsupported type: ${y4}`);
11102
11166
  }
11103
- function Wt(y4) {
11167
+ function wt(y4) {
11104
11168
  let { abi: t4, functionName: u3, args: v3 = [] } = y4, s4 = t4.find((F2) => F2.type === "function" && F2.name === u3);
11105
11169
  if (!s4)
11106
11170
  throw Error(`Function "${u3}" not found in ABI`);
11107
- let b4 = O02(s4), S3 = s4.inputs || [];
11108
- if (S3.length === 0)
11171
+ let b4 = O02(s4), S4 = s4.inputs || [];
11172
+ if (S4.length === 0)
11109
11173
  return b4;
11110
- if (v3.length !== S3.length)
11111
- throw Error(`Expected ${S3.length} arguments, got ${v3.length}`);
11174
+ if (v3.length !== S4.length)
11175
+ throw Error(`Expected ${S4.length} arguments, got ${v3.length}`);
11112
11176
  let N10 = [], h4 = [], U = [];
11113
- for (let F2 = 0;F2 < S3.length; F2++) {
11114
- let i4 = S3[F2], I3 = i4.components, m4 = B4(i4.type, I3);
11177
+ for (let F2 = 0;F2 < S4.length; F2++) {
11178
+ let i4 = S4[F2], I3 = i4.components, m4 = B4(i4.type, I3);
11115
11179
  if (U.push(m4), m4)
11116
11180
  N10.push(""), h4.push(l4(i4.type, v3[F2], I3));
11117
11181
  else
@@ -11120,9 +11184,9 @@ function Wt(y4) {
11120
11184
  if (h4.length === 0)
11121
11185
  return b4 + N10.join("");
11122
11186
  let K2 = N10.reduce((F2, i4, I3) => F2 + (U[I3] ? Vy : i4.length / 2), 0), D4 = "", _3 = 0;
11123
- for (let F2 = 0;F2 < S3.length; F2++)
11187
+ for (let F2 = 0;F2 < S4.length; F2++)
11124
11188
  if (U[F2])
11125
- D4 += Q(K2), K2 += h4[_3].length / 2, _3++;
11189
+ D4 += W(K2), K2 += h4[_3].length / 2, _3++;
11126
11190
  else
11127
11191
  D4 += N10[F2];
11128
11192
  return b4 + D4 + h4.join("");
@@ -11134,12 +11198,12 @@ function R02(y4) {
11134
11198
  let b4 = s4.outputs || [];
11135
11199
  if (b4.length === 0)
11136
11200
  return;
11137
- let S3 = uy(v3);
11201
+ let S4 = uy(v3);
11138
11202
  if (b4.length === 1)
11139
- return a4(b4[0].type, S3, 0, b4[0].components).value;
11203
+ return a4(b4[0].type, S4, 0, b4[0].components).value;
11140
11204
  let N10 = [], h4 = 0;
11141
11205
  for (let U of b4) {
11142
- let K2 = a4(U.type, S3, h4, U.components);
11206
+ let K2 = a4(U.type, S4, h4, U.components);
11143
11207
  N10.push(K2.value), h4 += K2.consumed;
11144
11208
  }
11145
11209
  return N10;
@@ -11153,7 +11217,7 @@ class p4 {
11153
11217
  this.address = y4.address, this.abi = y4.abi, this.rpcUrl = y4.rpcUrl;
11154
11218
  }
11155
11219
  async read(y4, t4, u3) {
11156
- let v3 = Wt({ abi: this.abi, functionName: y4, args: t4 }), s4 = { to: this.address, data: v3, ...u3?.from && { from: u3.from } }, b4 = await (await fetch(this.rpcUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_call", params: [s4, "latest"] }) })).json();
11220
+ let v3 = wt({ abi: this.abi, functionName: y4, args: t4 }), s4 = { to: this.address, data: v3, ...u3?.from && { from: u3.from } }, b4 = await (await fetch(this.rpcUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_call", params: [s4, "latest"] }) })).json();
11157
11221
  if (b4.error)
11158
11222
  throw Error(`RPC Error: ${b4.error.message}`);
11159
11223
  if (!b4.result)
@@ -11161,7 +11225,7 @@ class p4 {
11161
11225
  return R02({ abi: this.abi, functionName: y4, data: b4.result });
11162
11226
  }
11163
11227
  encodeWrite(y4, t4) {
11164
- return Wt({ abi: this.abi, functionName: y4, args: t4 });
11228
+ return wt({ abi: this.abi, functionName: y4, args: t4 });
11165
11229
  }
11166
11230
  }
11167
11231
  var a0 = [{ type: "function", name: "operateFlowMatrix", inputs: [{ name: "_flowVertices", type: "address[]" }, { name: "_flow", type: "tuple[]", components: [{ name: "streamSinkId", type: "uint16" }, { name: "amount", type: "uint192" }] }, { name: "_streams", type: "tuple[]", components: [{ name: "sourceCoordinate", type: "uint16" }, { name: "flowEdgeIds", type: "uint16[]" }, { name: "data", type: "bytes" }] }, { name: "_packedCoordinates", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isApprovedForAll", inputs: [{ name: "_account", type: "address" }, { name: "_operator", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "setApprovalForAll", inputs: [{ name: "_operator", type: "address" }, { name: "_approved", type: "bool" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "wrap", inputs: [{ name: "_avatar", type: "address" }, { name: "_amount", type: "uint256" }, { name: "_type", type: "uint8" }], outputs: [{ type: "address" }], stateMutability: "nonpayable" }, { type: "function", name: "trust", inputs: [{ name: "_trustReceiver", type: "address" }, { name: "_expiry", type: "uint96" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isTrusted", inputs: [{ name: "_truster", type: "address" }, { name: "_trustee", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "toTokenId", inputs: [{ name: "_avatar", type: "address" }], outputs: [{ type: "uint256" }], stateMutability: "pure" }, { type: "function", name: "safeTransferFrom", inputs: [{ name: "_from", type: "address" }, { name: "_to", type: "address" }, { name: "_id", type: "uint256" }, { name: "_value", type: "uint256" }, { name: "_data", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isHuman", inputs: [{ name: "_human", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "safeBatchTransferFrom", inputs: [{ name: "_from", type: "address" }, { name: "_to", type: "address" }, { name: "_ids", type: "uint256[]" }, { name: "_values", type: "uint256[]" }, { name: "_data", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }];
@@ -11239,7 +11303,7 @@ var o02;
11239
11303
  y4.Standard = "Standard", y4.Custom = "Custom";
11240
11304
  })(o02 ||= {});
11241
11305
 
11242
- class Wy extends Error {
11306
+ class wy extends Error {
11243
11307
  name;
11244
11308
  code;
11245
11309
  source;
@@ -11264,7 +11328,7 @@ Context: ${JSON.stringify(this.context, null, 2)}`;
11264
11328
  }
11265
11329
  }
11266
11330
 
11267
- class x4 extends Wy {
11331
+ class x4 extends wy {
11268
11332
  constructor(y4, t4) {
11269
11333
  super("TransferError", y4, { ...t4, source: t4?.source || "TRANSFERS" });
11270
11334
  }
@@ -11301,14 +11365,14 @@ class $t {
11301
11365
  this.config = y4, this.hubV2 = new vy({ address: y4.v2HubAddress, rpcUrl: y4.circlesRpcUrl }), this.liftERC20 = new sy({ address: y4.liftERC20Address, rpcUrl: y4.circlesRpcUrl }), this.rpcClient = new xy(y4.circlesRpcUrl), this.pathfinder = new Ay(this.rpcClient), this.balance = new Xy(this.rpcClient), this.group = new gy(this.rpcClient);
11302
11366
  }
11303
11367
  async buildFlowMatrixTx(y4, t4, u3, v3, s4 = false) {
11304
- let b4 = y4.toLowerCase(), S3 = t4.toLowerCase();
11368
+ let b4 = y4.toLowerCase(), S4 = t4.toLowerCase();
11305
11369
  if (!u3.transfers || u3.transfers.length === 0)
11306
- throw x4.noPathFound(b4, S3);
11370
+ throw x4.noPathFound(b4, S4);
11307
11371
  let N10 = { ...u3 };
11308
11372
  if (s4 && v3?.toTokens?.length === 1) {
11309
11373
  let g4 = v3.toTokens[0].toLowerCase();
11310
11374
  if (u3.maxFlow > 0n)
11311
- N10.transfers.push({ from: S3, to: S3, tokenOwner: g4, value: u3.maxFlow });
11375
+ N10.transfers.push({ from: S4, to: S4, tokenOwner: g4, value: u3.maxFlow });
11312
11376
  }
11313
11377
  let h4 = await my(b4, this.config.circlesRpcUrl, N10), U = ky(N10, h4), K2 = Object.keys(U).length > 0;
11314
11378
  if (K2 && !v3?.useWrappedBalances)
@@ -11318,7 +11382,7 @@ class $t {
11318
11382
  let g4 = await this._getTokenBalanceMap(b4), c3 = this._createDemurragedUnwrapCalls(U), { unwrapCalls: by, wrapCalls: Z } = this._createInflationaryUnwrapAndWrapCalls(U, h4, g4);
11319
11383
  D4 = [...c3, ...by], _3 = Z, N10 = iy(N10, h4);
11320
11384
  }
11321
- let F2 = Dy(b4, S3, N10.maxFlow, N10.transfers), i4 = My(F2, v3?.txData), I3 = this.hubV2.operateFlowMatrix(F2.flowVertices, F2.flowEdges, i4, F2.packedCoordinates), m4 = false;
11385
+ let F2 = Dy(b4, S4, N10.maxFlow, N10.transfers), i4 = My(F2, v3?.txData), I3 = this.hubV2.operateFlowMatrix(F2.flowVertices, F2.flowEdges, i4, F2.packedCoordinates), m4 = false;
11322
11386
  try {
11323
11387
  m4 = await this.hubV2.isApprovedForAll(b4, b4);
11324
11388
  } catch (g4) {
@@ -11327,27 +11391,27 @@ class $t {
11327
11391
  return [...m4 ? [] : [this.hubV2.setApprovalForAll(b4, true)], ...D4, I3, ..._3];
11328
11392
  }
11329
11393
  async constructAdvancedTransfer(y4, t4, u3, v3, s4 = false) {
11330
- let b4 = y4.toLowerCase(), S3 = t4.toLowerCase(), N10 = BigInt(u3);
11331
- if (b4 === S3 && v3?.fromTokens?.length === 1 && v3?.toTokens?.length === 1) {
11394
+ let b4 = y4.toLowerCase(), S4 = t4.toLowerCase(), N10 = BigInt(u3);
11395
+ if (b4 === S4 && v3?.fromTokens?.length === 1 && v3?.toTokens?.length === 1) {
11332
11396
  let F2 = v3.fromTokens[0], i4 = v3.toTokens[0], [I3, m4] = await Promise.all([this.liftERC20.erc20Circles(o5.Demurrage, i4), this.liftERC20.erc20Circles(o5.Inflation, i4)]);
11333
11397
  if (F2.toLowerCase() === I3.toLowerCase() && I3 !== fy) {
11334
11398
  let g4 = new O3({ address: F2, rpcUrl: this.config.circlesRpcUrl }).unwrap(N10);
11335
11399
  return [{ to: g4.to, data: g4.data, value: g4.value ?? 0n }];
11336
11400
  }
11337
11401
  if (F2.toLowerCase() === m4.toLowerCase() && m4 !== fy) {
11338
- let H2 = new Y({ address: F2, rpcUrl: this.config.circlesRpcUrl }), g4 = w4.attoCirclesToAttoStaticCircles(N10), c3 = H2.unwrap(g4);
11402
+ let H2 = new Y({ address: F2, rpcUrl: this.config.circlesRpcUrl }), g4 = Q.attoCirclesToAttoStaticCircles(N10), c3 = H2.unwrap(g4);
11339
11403
  return [{ to: c3.to, data: c3.data, value: c3.value ?? 0n }];
11340
11404
  }
11341
11405
  }
11342
- let h4 = this._truncateToSixDecimals(N10), U = await this._getDefaultTokenExcludeList(S3, v3?.excludeFromTokens), { ...K2 } = v3 || {}, D4 = { ...K2, ...U ? { excludeFromTokens: U } : {} }, _3 = await this.pathfinder.findPath({ from: b4, to: S3, targetFlow: h4, ...D4 });
11406
+ let h4 = this._truncateToSixDecimals(N10), U = await this._getDefaultTokenExcludeList(S4, v3?.excludeFromTokens), { ...K2 } = v3 || {}, D4 = { ...K2, ...U ? { excludeFromTokens: U } : {} }, _3 = await this.pathfinder.findPath({ from: b4, to: S4, targetFlow: h4, ...D4 });
11343
11407
  if (!_3.transfers || _3.transfers.length === 0)
11344
- throw x4.noPathFound(b4, S3);
11408
+ throw x4.noPathFound(b4, S4);
11345
11409
  if (_3.maxFlow < h4)
11346
- throw x4.insufficientBalance(h4, _3.maxFlow, b4, S3);
11347
- return this.buildFlowMatrixTx(b4, S3, _3, v3, s4);
11410
+ throw x4.insufficientBalance(h4, _3.maxFlow, b4, S4);
11411
+ return this.buildFlowMatrixTx(b4, S4, _3, v3, s4);
11348
11412
  }
11349
11413
  async constructReplenish(y4, t4, u3, v3) {
11350
- let s4 = y4.toLowerCase(), b4 = t4.toLowerCase(), S3 = (v3 || y4).toLowerCase(), N10 = BigInt(u3), U = (await this.balance.getTokenBalances(s4)).filter((M3) => M3.tokenOwner.toLowerCase() === b4), K2 = 0n, D4 = 0n, _3 = 0n, F2 = null, i4 = null;
11414
+ let s4 = y4.toLowerCase(), b4 = t4.toLowerCase(), S4 = (v3 || y4).toLowerCase(), N10 = BigInt(u3), U = (await this.balance.getTokenBalances(s4)).filter((M3) => M3.tokenOwner.toLowerCase() === b4), K2 = 0n, D4 = 0n, _3 = 0n, F2 = null, i4 = null;
11351
11415
  for (let M3 of U)
11352
11416
  if (M3.isWrapped)
11353
11417
  if (M3.tokenType.includes("Demurrage"))
@@ -11356,10 +11420,10 @@ class $t {
11356
11420
  _3 = BigInt(M3.staticAttoCircles), i4 = M3.tokenAddress;
11357
11421
  else
11358
11422
  K2 = BigInt(M3.attoCircles);
11359
- let I3 = K2 + D4 + w4.attoStaticCirclesToAttoCircles(_3), m4 = [];
11423
+ let I3 = K2 + D4 + Q.attoStaticCirclesToAttoCircles(_3), m4 = [];
11360
11424
  if (K2 >= N10) {
11361
- if (console.log(`✓ Already have ${Number(K2) / 1000000000000000000} CRC unwrapped (target: ${Number(N10) / 1000000000000000000} CRC). No replenish needed.`), S3 !== s4) {
11362
- let M3 = await this.hubV2.toTokenId(b4), E4 = this.hubV2.safeTransferFrom(s4, S3, M3, N10);
11425
+ if (console.log(`✓ Already have ${Number(K2) / 1000000000000000000} CRC unwrapped (target: ${Number(N10) / 1000000000000000000} CRC). No replenish needed.`), S4 !== s4) {
11426
+ let M3 = await this.hubV2.toTokenId(b4), E4 = this.hubV2.safeTransferFrom(s4, S4, M3, N10);
11363
11427
  m4.push({ to: E4.to, data: E4.data, value: E4.value ?? 0n });
11364
11428
  }
11365
11429
  return m4;
@@ -11372,24 +11436,24 @@ class $t {
11372
11436
  m4.push({ to: V2.to, data: V2.data, value: V2.value ?? 0n }), M3 -= E4;
11373
11437
  }
11374
11438
  if (_3 > 0n && i4 && M3 > 0n) {
11375
- let E4 = w4.attoCirclesToAttoStaticCircles(M3), T4 = E4 > _3 ? _3 : E4, Ky = new Y({ address: i4, rpcUrl: this.config.circlesRpcUrl }).unwrap(T4);
11439
+ let E4 = Q.attoCirclesToAttoStaticCircles(M3), T4 = E4 > _3 ? _3 : E4, Ky = new Y({ address: i4, rpcUrl: this.config.circlesRpcUrl }).unwrap(T4);
11376
11440
  m4.push({ to: Ky.to, data: Ky.data, value: Ky.value ?? 0n });
11377
11441
  }
11378
- if (S3 !== s4) {
11379
- let E4 = await this.hubV2.toTokenId(b4), T4 = this.hubV2.safeTransferFrom(s4, S3, E4, N10);
11442
+ if (S4 !== s4) {
11443
+ let E4 = await this.hubV2.toTokenId(b4), T4 = this.hubV2.safeTransferFrom(s4, S4, E4, N10);
11380
11444
  m4.push({ to: T4.to, data: T4.data, value: T4.value ?? 0n });
11381
11445
  }
11382
11446
  return m4;
11383
11447
  }
11384
- let c3 = !await this.hubV2.isTrusted(s4, b4), by = BigInt(Math.floor(Date.now() / 1000) + 31536000), Z = w4.truncateToInt64(H2), Rt = H2 % w4.FACTOR_1E12 !== 0n, q2 = w4.blowUpToBigInt(Rt ? Z + 1n : Z), f4;
11448
+ let c3 = !await this.hubV2.isTrusted(s4, b4), by = BigInt(Math.floor(Date.now() / 1000) + 31536000), Z = Q.truncateToInt64(H2), Rt = H2 % Q.FACTOR_1E12 !== 0n, q2 = Q.blowUpToBigInt(Rt ? Z + 1n : Z), f4;
11385
11449
  try {
11386
- f4 = await this.pathfinder.findPath({ from: s4, to: S3, targetFlow: q2, toTokens: [b4], useWrappedBalances: true, simulatedTrusts: c3 ? [{ truster: s4, trustee: b4 }] : undefined });
11450
+ f4 = await this.pathfinder.findPath({ from: s4, to: S4, targetFlow: q2, toTokens: [b4], useWrappedBalances: true, simulatedTrusts: c3 ? [{ truster: s4, trustee: b4 }] : undefined });
11387
11451
  } catch (M3) {
11388
11452
  let E4 = Number(I3) / 1000000000000000000, T4 = Number(N10) / 1000000000000000000, V2 = Number(H2) / 1000000000000000000;
11389
11453
  throw new x4(`Insufficient tokens to replenish. Target: ${T4.toFixed(6)} CRC, Current unwrapped: ${Number(K2) / 1000000000000000000} CRC, Need: ${V2.toFixed(6)} CRC, Available (including all paths): ${E4.toFixed(6)} CRC. Cannot acquire the remaining ${(Number(H2 - (I3 - K2)) / 1000000000000000000).toFixed(6)} CRC.`, { code: "REPLENISH_INSUFFICIENT_TOKENS", source: "VALIDATION", context: { from: s4, tokenId: b4, target: N10.toString(), unwrapped: K2.toString(), deficit: H2.toString(), available: I3.toString(), targetCrc: T4, unwrappedCrc: Number(K2) / 1000000000000000000, deficitCrc: V2, availableCrc: E4 } });
11390
11454
  }
11391
11455
  if (!f4.transfers || f4.transfers.length === 0)
11392
- throw x4.noPathFound(s4, S3, `No path to acquire token ${b4}`);
11456
+ throw x4.noPathFound(s4, S4, `No path to acquire token ${b4}`);
11393
11457
  if (f4.maxFlow < q2) {
11394
11458
  let M3 = Number(f4.maxFlow) / 1000000000000000000, E4 = Number(q2) / 1000000000000000000;
11395
11459
  throw new x4(`Pathfinder can only provide ${M3.toFixed(6)} CRC of the ${E4.toFixed(6)} CRC deficit needed for token ${b4}.`, { code: "REPLENISH_INSUFFICIENT_PATH_FLOW", source: "PATHFINDING", context: { from: s4, tokenId: b4, deficit: q2.toString(), pathFlow: f4.maxFlow.toString(), deficitCrc: E4, pathFlowCrc: M3 } });
@@ -11398,14 +11462,14 @@ class $t {
11398
11462
  let M3 = this.hubV2.trust(b4, by);
11399
11463
  m4.push({ to: M3.to, data: M3.data, value: M3.value ?? 0n });
11400
11464
  }
11401
- let Sy = await my(s4, this.config.circlesRpcUrl, f4), Ny = ky(f4, Sy), at = Object.keys(Ny).length > 0, wy = [], hy = [];
11465
+ let Sy = await my(s4, this.config.circlesRpcUrl, f4), Ny = ky(f4, Sy), at = Object.keys(Ny).length > 0, Qy = [], hy = [];
11402
11466
  if (at) {
11403
11467
  let M3 = await this._getTokenBalanceMap(s4), E4 = this._createDemurragedUnwrapCalls(Ny), { unwrapCalls: T4, wrapCalls: V2 } = this._createInflationaryUnwrapAndWrapCalls(Ny, Sy, M3);
11404
- wy = [...E4, ...T4], hy = V2, f4 = iy(f4, Sy);
11468
+ Qy = [...E4, ...T4], hy = V2, f4 = iy(f4, Sy);
11405
11469
  }
11406
- let j2 = Dy(s4, S3, f4.maxFlow, f4.transfers), Bt = My(j2), Uy = this.hubV2.operateFlowMatrix(j2.flowVertices, j2.flowEdges, Bt, j2.packedCoordinates), ot = { to: Uy.to, data: Uy.data, value: Uy.value ?? 0n }, Qy = false;
11470
+ let j2 = Dy(s4, S4, f4.maxFlow, f4.transfers), Bt = My(j2), Uy = this.hubV2.operateFlowMatrix(j2.flowVertices, j2.flowEdges, Bt, j2.packedCoordinates), ot = { to: Uy.to, data: Uy.data, value: Uy.value ?? 0n }, Wy = false;
11407
11471
  try {
11408
- Qy = await this.hubV2.isApprovedForAll(s4, s4);
11472
+ Wy = await this.hubV2.isApprovedForAll(s4, s4);
11409
11473
  } catch (M3) {
11410
11474
  console.warn("Failed to check approval status, including approval transaction:", M3);
11411
11475
  }
@@ -11413,8 +11477,8 @@ class $t {
11413
11477
  let M3 = this.hubV2.trust(b4, 0n);
11414
11478
  hy.push({ to: M3.to, data: M3.data, value: M3.value ?? 0n });
11415
11479
  }
11416
- let Zt = Qy ? [] : [{ to: this.hubV2.setApprovalForAll(s4, true).to, data: this.hubV2.setApprovalForAll(s4, true).data, value: 0n }];
11417
- return m4.push(...Zt, ...wy, ot, ...hy), m4;
11480
+ let Zt = Wy ? [] : [{ to: this.hubV2.setApprovalForAll(s4, true).to, data: this.hubV2.setApprovalForAll(s4, true).data, value: 0n }];
11481
+ return m4.push(...Zt, ...Qy, ot, ...hy), m4;
11418
11482
  }
11419
11483
  async _getTokenBalanceMap(y4) {
11420
11484
  let t4 = await this.balance.getTokenBalances(y4), u3 = new Map;
@@ -11427,14 +11491,14 @@ class $t {
11427
11491
  for (let [u3, [v3, s4]] of Object.entries(y4)) {
11428
11492
  if (s4 !== "CrcV2_ERC20WrapperDeployed_Demurraged")
11429
11493
  continue;
11430
- let S3 = new O3({ address: u3, rpcUrl: this.config.circlesRpcUrl }).unwrap(v3);
11431
- t4.push({ to: S3.to, data: S3.data, value: S3.value ?? 0n });
11494
+ let S4 = new O3({ address: u3, rpcUrl: this.config.circlesRpcUrl }).unwrap(v3);
11495
+ t4.push({ to: S4.to, data: S4.data, value: S4.value ?? 0n });
11432
11496
  }
11433
11497
  return t4;
11434
11498
  }
11435
11499
  _createInflationaryUnwrapAndWrapCalls(y4, t4, u3) {
11436
11500
  let v3 = [], s4 = [];
11437
- for (let [b4, [S3, N10]] of Object.entries(y4)) {
11501
+ for (let [b4, [S4, N10]] of Object.entries(y4)) {
11438
11502
  if (N10 !== "CrcV2_ERC20WrapperDeployed_Inflationary")
11439
11503
  continue;
11440
11504
  let h4 = t4.get(b4.toLowerCase()), U = u3.get(b4.toLowerCase()) || 0n;
@@ -11442,7 +11506,7 @@ class $t {
11442
11506
  continue;
11443
11507
  let D4 = new Y({ address: b4, rpcUrl: this.config.circlesRpcUrl }).unwrap(U);
11444
11508
  v3.push({ to: D4.to, data: D4.data, value: D4.value ?? 0n });
11445
- let _3 = h4?.tokenOwner, F2 = w4.attoStaticCirclesToAttoCircles(U) - S3;
11509
+ let _3 = h4?.tokenOwner, F2 = Q.attoStaticCirclesToAttoCircles(U) - S4;
11446
11510
  if (F2 > 0n) {
11447
11511
  let i4 = this.hubV2.wrap(_3, F2, o5.Inflation);
11448
11512
  s4.push({ to: i4.to, data: i4.data, value: i4.value ?? 0n });