@bestinslot/wallet-kit 0.13.6 → 0.13.7

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.
@@ -1,12 +1,12 @@
1
- import { h as yn, U as Ir, V as Mo, X as Wo, Y as Go, G as B, e as Wt, l as Kr, Z as Ks, _ as Rr, O as Xe, f as Zn, H as Ut, $ as ze, a0 as J, a1 as ce, a2 as Xs, a3 as zs, a4 as Ho, a5 as Xr, a6 as Ft, a7 as me, a8 as $n, a9 as Yt, aa as Pn, ab as Js, d as tn, D as bn, ac as Vo, ad as zr, ae as Ln, af as js, k as Pe, ag as Zo, ah as Yo, ai as Ko, aj as Xo, ak as zo, al as Qs, am as Jo, an as ti, ao as ei, ap as ni, aq as ri, p as jo } from "./mint-C_wN10-d.js";
2
- async function Vf(e, t, n, r, s, i) {
3
- const o = yn();
1
+ import { i as gn, X as Ir, Y as Do, Z as Mo, _ as Wo, I as B, f as Wt, n as Kr, $ as Ks, a0 as Rr, a1 as K, Q as Xe, h as Zn, J as Ut, a2 as ze, a3 as J, a4 as ce, a5 as Xs, a6 as zs, a7 as Go, a8 as Xr, a9 as Ft, aa as me, ab as $n, ac as Yt, ad as Pn, ae as Js, e as yn, F as bn, af as Ho, ag as zr, ah as Ln, ai as js, m as Pe, aj as Vo, ak as Zo, al as Yo, am as Ko, an as Xo, ao as Qs, ap as zo, aq as ti, ar as ei, as as ni, r as Jo } from "./mint-D4wMHU5r.js";
2
+ async function Hf(e, t, n, r, s, i) {
3
+ const o = gn();
4
4
  if (!o)
5
5
  throw new Error("No wallet connected");
6
6
  const a = Ir(o.provider);
7
7
  if (t.isOpReturn) {
8
8
  if (!i || i === "ordinals")
9
- return await Mo(
9
+ return await Do(
10
10
  e,
11
11
  t,
12
12
  r,
@@ -15,7 +15,7 @@ async function Vf(e, t, n, r, s, i) {
15
15
  a
16
16
  );
17
17
  if (i === "payment")
18
- return await Wo(
18
+ return await Mo(
19
19
  e,
20
20
  t,
21
21
  r,
@@ -25,10 +25,10 @@ async function Vf(e, t, n, r, s, i) {
25
25
  );
26
26
  }
27
27
  if (!i || i === "ordinals")
28
- return await Go(e, t, r, n, s, a);
28
+ return await Wo(e, t, r, n, s, a);
29
29
  throw new Error(`Unsupported wallet type: ${i}`);
30
30
  }
31
- function si(e) {
31
+ function ri(e) {
32
32
  return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
33
33
  }
34
34
  function Je(e, t = "") {
@@ -38,7 +38,7 @@ function Je(e, t = "") {
38
38
  }
39
39
  }
40
40
  function ft(e, t, n = "") {
41
- const r = si(e), s = e?.length, i = t !== void 0;
41
+ const r = ri(e), s = e?.length, i = t !== void 0;
42
42
  if (!r || i && s !== t) {
43
43
  const o = n && `"${n}" `, a = i ? ` of length ${t}` : "", c = r ? `length=${s}` : `type=${typeof e}`;
44
44
  throw new Error(o + "expected Uint8Array" + a + ", got " + c);
@@ -56,13 +56,13 @@ function Fn(e, t = !0) {
56
56
  if (t && e.finished)
57
57
  throw new Error("Hash#digest() has already been called");
58
58
  }
59
- function Qo(e, t) {
59
+ function jo(e, t) {
60
60
  ft(e, void 0, "digestInto() output");
61
61
  const n = t.outputLen;
62
62
  if (e.length < n)
63
63
  throw new Error('"digestInto() output" expected to be of length >=' + n);
64
64
  }
65
- function un(...e) {
65
+ function cn(...e) {
66
66
  for (let t = 0; t < e.length; t++)
67
67
  e[t].fill(0);
68
68
  }
@@ -72,13 +72,13 @@ function lr(e) {
72
72
  function Ht(e, t) {
73
73
  return e << 32 - t | e >>> t;
74
74
  }
75
- const ii = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", ta = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
76
- function ln(e) {
77
- if (ft(e), ii)
75
+ const si = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Qo = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
76
+ function un(e) {
77
+ if (ft(e), si)
78
78
  return e.toHex();
79
79
  let t = "";
80
80
  for (let n = 0; n < e.length; n++)
81
- t += ta[e[n]];
81
+ t += Qo[e[n]];
82
82
  return t;
83
83
  }
84
84
  const ne = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
@@ -93,7 +93,7 @@ function Jr(e) {
93
93
  function Un(e) {
94
94
  if (typeof e != "string")
95
95
  throw new Error("hex string expected, got " + typeof e);
96
- if (ii)
96
+ if (si)
97
97
  return Uint8Array.fromHex(e);
98
98
  const t = e.length, n = t / 2;
99
99
  if (t % 2)
@@ -122,17 +122,17 @@ function ht(...e) {
122
122
  }
123
123
  return n;
124
124
  }
125
- function ea(e, t = {}) {
125
+ function ta(e, t = {}) {
126
126
  const n = (s, i) => e(i).update(s).digest(), r = e(void 0);
127
127
  return n.outputLen = r.outputLen, n.blockLen = r.blockLen, n.create = (s) => e(s), Object.assign(n, t), Object.freeze(n);
128
128
  }
129
- function oi(e = 32) {
129
+ function ii(e = 32) {
130
130
  const t = typeof globalThis == "object" ? globalThis.crypto : null;
131
131
  if (typeof t?.getRandomValues != "function")
132
132
  throw new Error("crypto.getRandomValues must be defined");
133
133
  return t.getRandomValues(new Uint8Array(e));
134
134
  }
135
- const na = (e) => ({
135
+ const ea = (e) => ({
136
136
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, e])
137
137
  });
138
138
  const Nr = /* @__PURE__ */ BigInt(0), qn = /* @__PURE__ */ BigInt(1);
@@ -143,9 +143,9 @@ function jr(e, t = "") {
143
143
  }
144
144
  return e;
145
145
  }
146
- function ra(e) {
146
+ function na(e) {
147
147
  if (typeof e == "bigint") {
148
- if (!sa(e))
148
+ if (!ra(e))
149
149
  throw new Error("positive bigint expected, got " + e);
150
150
  } else
151
151
  Je(e);
@@ -157,28 +157,28 @@ function je(e, t = "") {
157
157
  throw new Error(n + "expected safe integer, got type=" + typeof e);
158
158
  }
159
159
  }
160
- function ai(e) {
160
+ function oi(e) {
161
161
  if (typeof e != "string")
162
162
  throw new Error("hex string expected, got " + typeof e);
163
163
  return e === "" ? Nr : BigInt("0x" + e);
164
164
  }
165
165
  function Kt(e) {
166
- return ai(ln(e));
166
+ return oi(un(e));
167
167
  }
168
- function ci(e) {
169
- return ai(ln(li(ft(e)).reverse()));
168
+ function ai(e) {
169
+ return oi(un(ui(ft(e)).reverse()));
170
170
  }
171
171
  function mt(e, t) {
172
- Je(t), e = ra(e);
172
+ Je(t), e = na(e);
173
173
  const n = Un(e.toString(16).padStart(t * 2, "0"));
174
174
  if (n.length !== t)
175
175
  throw new Error("number too large");
176
176
  return n;
177
177
  }
178
- function ui(e, t) {
178
+ function ci(e, t) {
179
179
  return mt(e, t).reverse();
180
180
  }
181
- function li(e) {
181
+ function ui(e) {
182
182
  return Uint8Array.from(e);
183
183
  }
184
184
  function Yn(e) {
@@ -189,14 +189,14 @@ function Yn(e) {
189
189
  return r;
190
190
  });
191
191
  }
192
- const sa = (e) => typeof e == "bigint" && Nr <= e;
192
+ const ra = (e) => typeof e == "bigint" && Nr <= e;
193
193
  function Dn(e) {
194
194
  let t;
195
195
  for (t = 0; e > Nr; e >>= qn, t += 1)
196
196
  ;
197
197
  return t;
198
198
  }
199
- function ia(e, t) {
199
+ function sa(e, t) {
200
200
  return e >> BigInt(t) & qn;
201
201
  }
202
202
  const mn = (e) => (qn << BigInt(e)) - qn;
@@ -227,7 +227,7 @@ function xr(e) {
227
227
  return t.set(n, i), i;
228
228
  };
229
229
  }
230
- const Ct = /* @__PURE__ */ BigInt(0), Tt = /* @__PURE__ */ BigInt(1), ke = /* @__PURE__ */ BigInt(2), fi = /* @__PURE__ */ BigInt(3), di = /* @__PURE__ */ BigInt(4), pi = /* @__PURE__ */ BigInt(5), oa = /* @__PURE__ */ BigInt(7), hi = /* @__PURE__ */ BigInt(8), aa = /* @__PURE__ */ BigInt(9), wi = /* @__PURE__ */ BigInt(16);
230
+ const Ct = /* @__PURE__ */ BigInt(0), Tt = /* @__PURE__ */ BigInt(1), ke = /* @__PURE__ */ BigInt(2), li = /* @__PURE__ */ BigInt(3), fi = /* @__PURE__ */ BigInt(4), di = /* @__PURE__ */ BigInt(5), ia = /* @__PURE__ */ BigInt(7), pi = /* @__PURE__ */ BigInt(8), oa = /* @__PURE__ */ BigInt(9), hi = /* @__PURE__ */ BigInt(16);
231
231
  function Pt(e, t) {
232
232
  const n = e % t;
233
233
  return n >= Ct ? n : t + n;
@@ -250,16 +250,16 @@ function $r(e, t, n) {
250
250
  if (!e.eql(e.sqr(t), n))
251
251
  throw new Error("Cannot find square root");
252
252
  }
253
- function gi(e, t) {
254
- const n = (e.ORDER + Tt) / di, r = e.pow(t, n);
253
+ function wi(e, t) {
254
+ const n = (e.ORDER + Tt) / fi, r = e.pow(t, n);
255
255
  return $r(e, r, t), r;
256
256
  }
257
- function ca(e, t) {
258
- const n = (e.ORDER - pi) / hi, r = e.mul(t, ke), s = e.pow(r, n), i = e.mul(t, s), o = e.mul(e.mul(i, ke), s), a = e.mul(i, e.sub(o, e.ONE));
257
+ function aa(e, t) {
258
+ const n = (e.ORDER - di) / pi, r = e.mul(t, ke), s = e.pow(r, n), i = e.mul(t, s), o = e.mul(e.mul(i, ke), s), a = e.mul(i, e.sub(o, e.ONE));
259
259
  return $r(e, a, t), a;
260
260
  }
261
- function ua(e) {
262
- const t = _n(e), n = yi(e), r = n(t, t.neg(t.ONE)), s = n(t, r), i = n(t, t.neg(r)), o = (e + oa) / wi;
261
+ function ca(e) {
262
+ const t = _n(e), n = gi(e), r = n(t, t.neg(t.ONE)), s = n(t, r), i = n(t, t.neg(r)), o = (e + ia) / hi;
263
263
  return (a, c) => {
264
264
  let u = a.pow(c, o), l = a.mul(u, r);
265
265
  const f = a.mul(u, s), d = a.mul(u, i), p = a.eql(a.sqr(l), c), w = a.eql(a.sqr(f), c);
@@ -268,8 +268,8 @@ function ua(e) {
268
268
  return $r(a, g, c), g;
269
269
  };
270
270
  }
271
- function yi(e) {
272
- if (e < fi)
271
+ function gi(e) {
272
+ if (e < li)
273
273
  throw new Error("sqrt is not defined for small field");
274
274
  let t = e - Tt, n = 0;
275
275
  for (; t % ke === Ct; )
@@ -280,7 +280,7 @@ function yi(e) {
280
280
  if (r++ > 1e3)
281
281
  throw new Error("Cannot find square root: probably non-prime P");
282
282
  if (n === 1)
283
- return gi;
283
+ return wi;
284
284
  let i = s.pow(r, t);
285
285
  const o = (t + Tt) / ke;
286
286
  return function(c, u) {
@@ -302,10 +302,10 @@ function yi(e) {
302
302
  return p;
303
303
  };
304
304
  }
305
- function la(e) {
306
- return e % di === fi ? gi : e % hi === pi ? ca : e % wi === aa ? ua(e) : yi(e);
305
+ function ua(e) {
306
+ return e % fi === li ? wi : e % pi === di ? aa : e % hi === oa ? ca(e) : gi(e);
307
307
  }
308
- const fa = [
308
+ const la = [
309
309
  "create",
310
310
  "isValid",
311
311
  "is0",
@@ -324,12 +324,12 @@ const fa = [
324
324
  "mulN",
325
325
  "sqrN"
326
326
  ];
327
- function bi(e) {
327
+ function yi(e) {
328
328
  const t = {
329
329
  ORDER: "bigint",
330
330
  BYTES: "number",
331
331
  BITS: "number"
332
- }, n = fa.reduce((r, s) => (r[s] = "function", r), t);
332
+ }, n = la.reduce((r, s) => (r[s] = "function", r), t);
333
333
  return Cr(e, n), e;
334
334
  }
335
335
  function Kn(e, t, n) {
@@ -354,12 +354,12 @@ function Mn(e, t) {
354
354
  throw new Error("invalid Legendre symbol result");
355
355
  return s ? 1 : i ? 0 : -1;
356
356
  }
357
- function da(e, t) {
357
+ function fa(e, t) {
358
358
  t !== void 0 && Je(t);
359
359
  const n = t !== void 0 ? t : e.toString(2).length, r = Math.ceil(n / 8);
360
360
  return { nBitLength: n, nByteLength: r };
361
361
  }
362
- class pa {
362
+ class da {
363
363
  ORDER;
364
364
  BITS;
365
365
  BYTES;
@@ -375,7 +375,7 @@ class pa {
375
375
  throw new Error("invalid field: expected ORDER > 0, got " + t);
376
376
  let r;
377
377
  this.isLE = !1, n != null && typeof n == "object" && (typeof n.BITS == "number" && (r = n.BITS), typeof n.sqrt == "function" && (this.sqrt = n.sqrt), typeof n.isLE == "boolean" && (this.isLE = n.isLE), n.allowedLengths && (this._lengths = n.allowedLengths?.slice()), typeof n.modFromBytes == "boolean" && (this._mod = n.modFromBytes));
378
- const { nBitLength: s, nByteLength: i } = da(t, r);
378
+ const { nBitLength: s, nByteLength: i } = fa(t, r);
379
379
  if (i > 2048)
380
380
  throw new Error("invalid field: expected ORDER of <= 2048 bytes");
381
381
  this.ORDER = t, this.BITS = s, this.BYTES = i, this._sqrt = void 0, Object.preventExtensions(this);
@@ -439,10 +439,10 @@ class pa {
439
439
  return Qr(t, this.ORDER);
440
440
  }
441
441
  sqrt(t) {
442
- return this._sqrt || (this._sqrt = la(this.ORDER)), this._sqrt(this, t);
442
+ return this._sqrt || (this._sqrt = ua(this.ORDER)), this._sqrt(this, t);
443
443
  }
444
444
  toBytes(t) {
445
- return this.isLE ? ui(t, this.BYTES) : mt(t, this.BYTES);
445
+ return this.isLE ? ci(t, this.BYTES) : mt(t, this.BYTES);
446
446
  }
447
447
  fromBytes(t, n = !1) {
448
448
  ft(t);
@@ -455,7 +455,7 @@ class pa {
455
455
  }
456
456
  if (t.length !== s)
457
457
  throw new Error("Field.fromBytes: expected " + s + " bytes, got " + t.length);
458
- let c = i ? ci(t) : Kt(t);
458
+ let c = i ? ai(t) : Kt(t);
459
459
  if (a && (c = Pt(c, o)), !n && !this.isValid(c))
460
460
  throw new Error("invalid field element: outside of range 0..ORDER");
461
461
  return c;
@@ -471,33 +471,33 @@ class pa {
471
471
  }
472
472
  }
473
473
  function _n(e, t = {}) {
474
- return new pa(e, t);
474
+ return new da(e, t);
475
475
  }
476
- function mi(e) {
476
+ function bi(e) {
477
477
  if (typeof e != "bigint")
478
478
  throw new Error("field order must be bigint");
479
479
  const t = e.toString(2).length;
480
480
  return Math.ceil(t / 8);
481
481
  }
482
- function _i(e) {
483
- const t = mi(e);
482
+ function mi(e) {
483
+ const t = bi(e);
484
484
  return t + Math.ceil(t / 2);
485
485
  }
486
- function xi(e, t, n = !1) {
486
+ function _i(e, t, n = !1) {
487
487
  ft(e);
488
- const r = e.length, s = mi(t), i = _i(t);
488
+ const r = e.length, s = bi(t), i = mi(t);
489
489
  if (r < 16 || r < i || r > 1024)
490
490
  throw new Error("expected " + i + "-1024 bytes of input, got " + r);
491
- const o = n ? ci(e) : Kt(e), a = Pt(o, t - Tt) + Tt;
492
- return n ? ui(a, s) : mt(a, s);
491
+ const o = n ? ai(e) : Kt(e), a = Pt(o, t - Tt) + Tt;
492
+ return n ? ci(a, s) : mt(a, s);
493
493
  }
494
- function ha(e, t, n) {
494
+ function pa(e, t, n) {
495
495
  return e & t ^ ~e & n;
496
496
  }
497
- function wa(e, t, n) {
497
+ function ha(e, t, n) {
498
498
  return e & t ^ e & n ^ t & n;
499
499
  }
500
- class ga {
500
+ class wa {
501
501
  blockLen;
502
502
  outputLen;
503
503
  padOffset;
@@ -528,10 +528,10 @@ class ga {
528
528
  return this.length += t.length, this.roundClean(), this;
529
529
  }
530
530
  digestInto(t) {
531
- Fn(this), Qo(t, this), this.finished = !0;
531
+ Fn(this), jo(t, this), this.finished = !0;
532
532
  const { buffer: n, view: r, blockLen: s, isLE: i } = this;
533
533
  let { pos: o } = this;
534
- n[o++] = 128, un(this.buffer.subarray(o)), this.padOffset > s - o && (this.process(r, 0), o = 0);
534
+ n[o++] = 128, cn(this.buffer.subarray(o)), this.padOffset > s - o && (this.process(r, 0), o = 0);
535
535
  for (let f = o; f < s; f++)
536
536
  n[f] = 0;
537
537
  r.setBigUint64(s - 8, BigInt(this.length * 8), i), this.process(r, 0);
@@ -568,7 +568,7 @@ const pe = /* @__PURE__ */ Uint32Array.from([
568
568
  2600822924,
569
569
  528734635,
570
570
  1541459225
571
- ]), ya = /* @__PURE__ */ Uint32Array.from([
571
+ ]), ga = /* @__PURE__ */ Uint32Array.from([
572
572
  1116352408,
573
573
  1899447441,
574
574
  3049323471,
@@ -634,7 +634,7 @@ const pe = /* @__PURE__ */ Uint32Array.from([
634
634
  3204031479,
635
635
  3329325298
636
636
  ]), he = /* @__PURE__ */ new Uint32Array(64);
637
- class ba extends ga {
637
+ class ya extends wa {
638
638
  constructor(t) {
639
639
  super(64, t, 8, !1);
640
640
  }
@@ -655,19 +655,19 @@ class ba extends ga {
655
655
  }
656
656
  let { A: r, B: s, C: i, D: o, E: a, F: c, G: u, H: l } = this;
657
657
  for (let f = 0; f < 64; f++) {
658
- const d = Ht(a, 6) ^ Ht(a, 11) ^ Ht(a, 25), p = l + d + ha(a, c, u) + ya[f] + he[f] | 0, h = (Ht(r, 2) ^ Ht(r, 13) ^ Ht(r, 22)) + wa(r, s, i) | 0;
658
+ const d = Ht(a, 6) ^ Ht(a, 11) ^ Ht(a, 25), p = l + d + pa(a, c, u) + ga[f] + he[f] | 0, h = (Ht(r, 2) ^ Ht(r, 13) ^ Ht(r, 22)) + ha(r, s, i) | 0;
659
659
  l = u, u = c, c = a, a = o + p | 0, o = i, i = s, s = r, r = p + h | 0;
660
660
  }
661
661
  r = r + this.A | 0, s = s + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, u = u + this.G | 0, l = l + this.H | 0, this.set(r, s, i, o, a, c, u, l);
662
662
  }
663
663
  roundClean() {
664
- un(he);
664
+ cn(he);
665
665
  }
666
666
  destroy() {
667
- this.set(0, 0, 0, 0, 0, 0, 0, 0), un(this.buffer);
667
+ this.set(0, 0, 0, 0, 0, 0, 0, 0), cn(this.buffer);
668
668
  }
669
669
  }
670
- class ma extends ba {
670
+ class ba extends ya {
671
671
  // We cannot use array here since array allows indexing by variable
672
672
  // which means optimizer/compiler cannot use registers.
673
673
  A = pe[0] | 0;
@@ -682,9 +682,9 @@ class ma extends ba {
682
682
  super(32);
683
683
  }
684
684
  }
685
- const Ei = /* @__PURE__ */ ea(
686
- () => new ma(),
687
- /* @__PURE__ */ na(1)
685
+ const xi = /* @__PURE__ */ ta(
686
+ () => new ba(),
687
+ /* @__PURE__ */ ea(1)
688
688
  );
689
689
  const Qe = /* @__PURE__ */ BigInt(0), Ne = /* @__PURE__ */ BigInt(1);
690
690
  function Wn(e, t) {
@@ -695,12 +695,12 @@ function Gn(e, t) {
695
695
  const n = Fe(e.Fp, t.map((r) => r.Z));
696
696
  return t.map((r, s) => e.fromAffine(r.toAffine(n[s])));
697
697
  }
698
- function Si(e, t) {
698
+ function Ei(e, t) {
699
699
  if (!Number.isSafeInteger(e) || e <= 0 || e > t)
700
700
  throw new Error("invalid window size, expected [1.." + t + "], got W=" + e);
701
701
  }
702
702
  function fr(e, t) {
703
- Si(e, t);
703
+ Ei(e, t);
704
704
  const n = Math.ceil(t / e) + 1, r = 2 ** (e - 1), s = 2 ** e, i = mn(e), o = BigInt(e);
705
705
  return { windows: n, windowSize: r, mask: i, maxNumber: s, shiftBy: o };
706
706
  }
@@ -711,15 +711,15 @@ function ts(e, t, n) {
711
711
  const u = t * r, l = u + Math.abs(a) - 1, f = a === 0, d = a < 0, p = t % 2 !== 0;
712
712
  return { nextN: c, offset: l, isZero: f, isNeg: d, isNegF: p, offsetF: u };
713
713
  }
714
- const dr = /* @__PURE__ */ new WeakMap(), Bi = /* @__PURE__ */ new WeakMap();
714
+ const dr = /* @__PURE__ */ new WeakMap(), Si = /* @__PURE__ */ new WeakMap();
715
715
  function pr(e) {
716
- return Bi.get(e) || 1;
716
+ return Si.get(e) || 1;
717
717
  }
718
718
  function es(e) {
719
719
  if (e !== Qe)
720
720
  throw new Error("invalid wNAF");
721
721
  }
722
- class _a {
722
+ class ma {
723
723
  BASE;
724
724
  ZERO;
725
725
  Fn;
@@ -807,13 +807,13 @@ class _a {
807
807
  // using windowed method. This specifies window size and
808
808
  // stores precomputed values. Usually only base point would be precomputed.
809
809
  createCache(t, n) {
810
- Si(n, this.bits), Bi.set(t, n), dr.delete(t);
810
+ Ei(n, this.bits), Si.set(t, n), dr.delete(t);
811
811
  }
812
812
  hasCache(t) {
813
813
  return pr(t) !== 1;
814
814
  }
815
815
  }
816
- function xa(e, t, n, r) {
816
+ function _a(e, t, n, r) {
817
817
  let s = t, i = e.ZERO, o = e.ZERO;
818
818
  for (; n > Qe || r > Qe; )
819
819
  n & Ne && (i = i.add(s)), r & Ne && (o = o.add(s)), s = s.double(), n >>= Ne, r >>= Ne;
@@ -823,11 +823,11 @@ function ns(e, t, n) {
823
823
  if (t) {
824
824
  if (t.ORDER !== e)
825
825
  throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
826
- return bi(t), t;
826
+ return yi(t), t;
827
827
  } else
828
828
  return _n(e, { isLE: n });
829
829
  }
830
- function Ea(e, t, n = {}, r) {
830
+ function xa(e, t, n = {}, r) {
831
831
  if (r === void 0 && (r = e === "edwards"), !t || typeof t != "object")
832
832
  throw new Error(`expected valid ${e} CURVE object`);
833
833
  for (const c of ["p", "n", "h"]) {
@@ -841,7 +841,7 @@ function Ea(e, t, n = {}, r) {
841
841
  throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
842
842
  return t = Object.freeze(Object.assign({}, t)), { CURVE: t, Fp: s, Fn: i };
843
843
  }
844
- const Sa = Kt;
844
+ const Ea = Kt;
845
845
  function we(e, t) {
846
846
  if (je(e), je(t), e < 0 || e >= 1 << 8 * t)
847
847
  throw new Error("invalid I2OSP input: " + e);
@@ -850,32 +850,32 @@ function we(e, t) {
850
850
  n[r] = e & 255, e >>>= 8;
851
851
  return new Uint8Array(n);
852
852
  }
853
- function Ba(e, t) {
853
+ function Sa(e, t) {
854
854
  const n = new Uint8Array(e.length);
855
855
  for (let r = 0; r < e.length; r++)
856
856
  n[r] = e[r] ^ t[r];
857
857
  return n;
858
858
  }
859
- function vi(e) {
860
- if (!si(e) && typeof e != "string")
859
+ function Bi(e) {
860
+ if (!ri(e) && typeof e != "string")
861
861
  throw new Error("DST must be Uint8Array or ascii string");
862
862
  return typeof e == "string" ? Yn(e) : e;
863
863
  }
864
- function va(e, t, n, r) {
865
- ft(e), je(n), t = vi(t), t.length > 255 && (t = r(ht(Yn("H2C-OVERSIZE-DST-"), t)));
864
+ function Ba(e, t, n, r) {
865
+ ft(e), je(n), t = Bi(t), t.length > 255 && (t = r(ht(Yn("H2C-OVERSIZE-DST-"), t)));
866
866
  const { outputLen: s, blockLen: i } = r, o = Math.ceil(n / s);
867
867
  if (n > 65535 || o > 255)
868
868
  throw new Error("expand_message_xmd: invalid lenInBytes");
869
869
  const a = ht(t, we(t.length, 1)), c = we(0, i), u = we(n, 2), l = new Array(o), f = r(ht(c, e, u, we(0, 1), a));
870
870
  l[0] = r(ht(f, we(1, 1), a));
871
871
  for (let p = 1; p <= o; p++) {
872
- const w = [Ba(f, l[p - 1]), we(p + 1, 1), a];
872
+ const w = [Sa(f, l[p - 1]), we(p + 1, 1), a];
873
873
  l[p] = r(ht(...w));
874
874
  }
875
875
  return ht(...l).slice(0, n);
876
876
  }
877
- function Oa(e, t, n, r, s) {
878
- if (ft(e), je(n), t = vi(t), t.length > 255) {
877
+ function va(e, t, n, r, s) {
878
+ if (ft(e), je(n), t = Bi(t), t.length > 255) {
879
879
  const i = Math.ceil(2 * r / 8);
880
880
  t = s.create({ dkLen: i }).update(Yn("H2C-OVERSIZE-DST-")).update(t).digest();
881
881
  }
@@ -895,9 +895,9 @@ function hr(e, t, n) {
895
895
  const u = r.toString(2).length, l = Math.ceil((u + s) / 8), f = t * i * l;
896
896
  let d;
897
897
  if (a === "xmd")
898
- d = va(e, c, f, o);
898
+ d = Ba(e, c, f, o);
899
899
  else if (a === "xof")
900
- d = Oa(e, c, f, s, o);
900
+ d = va(e, c, f, s, o);
901
901
  else if (a === "_internal_pass")
902
902
  d = e;
903
903
  else
@@ -907,20 +907,20 @@ function hr(e, t, n) {
907
907
  const h = new Array(i);
908
908
  for (let g = 0; g < i; g++) {
909
909
  const b = l * (g + w * i), S = d.subarray(b, b + l);
910
- h[g] = Pt(Sa(S), r);
910
+ h[g] = Pt(Ea(S), r);
911
911
  }
912
912
  p[w] = h;
913
913
  }
914
914
  return p;
915
915
  }
916
- function Oi(e, t) {
916
+ function vi(e, t) {
917
917
  const n = t.map((r) => Array.from(r).reverse());
918
918
  return (r, s) => {
919
919
  const [i, o, a, c] = n.map((f) => f.reduce((d, p) => e.add(e.mul(d, r), p))), [u, l] = Fe(e, [o, c], !0);
920
920
  return r = e.mul(i, u), s = e.mul(s, e.mul(a, l)), { x: r, y: s };
921
921
  };
922
922
  }
923
- const Ta = Yn("HashToScalar-");
923
+ const Oa = Yn("HashToScalar-");
924
924
  function rs(e, t, n) {
925
925
  if (typeof t != "function")
926
926
  throw new Error("mapToCurve() must be defined");
@@ -959,12 +959,12 @@ function rs(e, t, n) {
959
959
  // hash_to_scalar can produce 0: https://www.rfc-editor.org/errata/eid8393
960
960
  // RFC 9380, draft-irtf-cfrg-bbs-signatures-08
961
961
  hashToScalar(i, o) {
962
- const a = e.Fn.ORDER, c = Object.assign({}, n, { p: a, m: 1, DST: Ta }, o);
962
+ const a = e.Fn.ORDER, c = Object.assign({}, n, { p: a, m: 1, DST: Oa }, o);
963
963
  return hr(i, 1, c)[0][0];
964
964
  }
965
965
  };
966
966
  }
967
- class Ti {
967
+ class Oi {
968
968
  oHash;
969
969
  iHash;
970
970
  blockLen;
@@ -982,7 +982,7 @@ class Ti {
982
982
  this.iHash.update(s), this.oHash = t.create();
983
983
  for (let i = 0; i < s.length; i++)
984
984
  s[i] ^= 106;
985
- this.oHash.update(s), un(s);
985
+ this.oHash.update(s), cn(s);
986
986
  }
987
987
  update(t) {
988
988
  return Fn(this), this.iHash.update(t), this;
@@ -1006,10 +1006,10 @@ class Ti {
1006
1006
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
1007
1007
  }
1008
1008
  }
1009
- const Lr = (e, t, n) => new Ti(e, t).update(n).digest();
1010
- Lr.create = (e, t) => new Ti(e, t);
1009
+ const Lr = (e, t, n) => new Oi(e, t).update(n).digest();
1010
+ Lr.create = (e, t) => new Oi(e, t);
1011
1011
  const ss = (e, t) => (e + (e >= 0 ? t : -t) / re) / t;
1012
- function Ia(e, t, n) {
1012
+ function Ta(e, t, n) {
1013
1013
  const [[r, s], [i, o]] = t, a = ss(o * e, n), c = ss(-s * e, n);
1014
1014
  let u = e - a * r - c * i, l = -a * s - c * o;
1015
1015
  const f = u < Ce, d = l < Ce;
@@ -1020,8 +1020,8 @@ function Ia(e, t, n) {
1020
1020
  return { k1neg: f, k1: u, k2neg: d, k2: l };
1021
1021
  }
1022
1022
  const Ce = BigInt(0), It = BigInt(1), re = BigInt(2), He = BigInt(3), Er = BigInt(4);
1023
- function Ii(e, t = {}) {
1024
- const n = Ea("weierstrass", e, t), { Fp: r, Fn: s } = n;
1023
+ function Ti(e, t = {}) {
1024
+ const n = xa("weierstrass", e, t), { Fp: r, Fn: s } = n;
1025
1025
  let i = n.CURVE;
1026
1026
  const { h: o, n: a } = i;
1027
1027
  Cr(t, {}, {
@@ -1035,7 +1035,7 @@ function Ii(e, t = {}) {
1035
1035
  const { endo: c } = t;
1036
1036
  if (c && (!r.is0(i.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
1037
1037
  throw new Error('invalid endo: expected "beta": bigint and "basises": array');
1038
- const u = Na(r, s);
1038
+ const u = ka(r, s);
1039
1039
  function l() {
1040
1040
  if (!r.isOdd)
1041
1041
  throw new Error("compression is not supported: Field does not have .isOdd()");
@@ -1045,7 +1045,7 @@ function Ii(e, t = {}) {
1045
1045
  if (jr(x, "isCompressed"), x) {
1046
1046
  l();
1047
1047
  const $ = !r.isOdd(R);
1048
- return ht(Ra($), F);
1048
+ return ht(Ia($), F);
1049
1049
  } else
1050
1050
  return ht(Uint8Array.of(4), F, r.toBytes(R));
1051
1051
  }
@@ -1101,7 +1101,7 @@ function Ii(e, t = {}) {
1101
1101
  function M(U) {
1102
1102
  if (!c || !c.basises)
1103
1103
  throw new Error("no endo");
1104
- return Ia(U, c.basises, s.ORDER);
1104
+ return Ta(U, c.basises, s.ORDER);
1105
1105
  }
1106
1106
  const P = xr((U, y) => {
1107
1107
  const { X: x, Y: v, Z: R } = U;
@@ -1274,7 +1274,7 @@ function Ii(e, t = {}) {
1274
1274
  if (H.hasCache(this))
1275
1275
  return this.multiply(y);
1276
1276
  if (x) {
1277
- const { k1neg: R, k1: F, k2neg: $, k2: q } = M(y), { p1: k, p2: W } = xa(_, v, F, q);
1277
+ const { k1neg: R, k1: F, k2neg: $, k2: q } = M(y), { p1: k, p2: W } = _a(_, v, F, q);
1278
1278
  return I(x.beta, k, W, R, $);
1279
1279
  } else
1280
1280
  return H.unsafe(v, y);
@@ -1305,19 +1305,19 @@ function Ii(e, t = {}) {
1305
1305
  return jr(y, "isCompressed"), this.assertValidity(), p(_, this, y);
1306
1306
  }
1307
1307
  toHex(y = !0) {
1308
- return ln(this.toBytes(y));
1308
+ return un(this.toBytes(y));
1309
1309
  }
1310
1310
  toString() {
1311
1311
  return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
1312
1312
  }
1313
1313
  }
1314
- const D = s.BITS, H = new _a(_, t.endo ? Math.ceil(D / 2) : D);
1314
+ const D = s.BITS, H = new ma(_, t.endo ? Math.ceil(D / 2) : D);
1315
1315
  return _.BASE.precompute(8), _;
1316
1316
  }
1317
- function Ra(e) {
1317
+ function Ia(e) {
1318
1318
  return Uint8Array.of(e ? 2 : 3);
1319
1319
  }
1320
- function ka(e, t) {
1320
+ function Ra(e, t) {
1321
1321
  const n = e.ORDER;
1322
1322
  let r = Ce;
1323
1323
  for (let w = n - It; w % re === Ce; w /= re)
@@ -1356,12 +1356,12 @@ function ka(e, t) {
1356
1356
  }
1357
1357
  return p;
1358
1358
  }
1359
- function Ri(e, t) {
1360
- bi(e);
1359
+ function Ii(e, t) {
1360
+ yi(e);
1361
1361
  const { A: n, B: r, Z: s } = t;
1362
1362
  if (!e.isValid(n) || !e.isValid(r) || !e.isValid(s))
1363
1363
  throw new Error("mapToCurveSimpleSWU: invalid opts");
1364
- const i = ka(e, s);
1364
+ const i = Ra(e, s);
1365
1365
  if (!e.isOdd)
1366
1366
  throw new Error("Field does not have .isOdd()");
1367
1367
  return (o) => {
@@ -1375,7 +1375,7 @@ function Ri(e, t) {
1375
1375
  return p = e.mul(p, S), { x: p, y: w };
1376
1376
  };
1377
1377
  }
1378
- function Na(e, t) {
1378
+ function ka(e, t) {
1379
1379
  return {
1380
1380
  secretKey: t.BYTES,
1381
1381
  publicKey: 1 + e.BYTES,
@@ -1384,18 +1384,18 @@ function Na(e, t) {
1384
1384
  signature: 2 * t.BYTES
1385
1385
  };
1386
1386
  }
1387
- const Ca = BigInt(0), Tn = BigInt(1), is = BigInt(2), Ve = BigInt(3);
1388
- function $a(e) {
1387
+ const Na = BigInt(0), Tn = BigInt(1), is = BigInt(2), Ve = BigInt(3);
1388
+ function Ca(e) {
1389
1389
  const t = [];
1390
1390
  for (; e > Tn; e >>= Tn)
1391
- (e & Tn) === Ca ? t.unshift(0) : (e & Ve) === Ve ? (t.unshift(-1), e += Tn) : t.unshift(1);
1391
+ (e & Tn) === Na ? t.unshift(0) : (e & Ve) === Ve ? (t.unshift(-1), e += Tn) : t.unshift(1);
1392
1392
  return t;
1393
1393
  }
1394
1394
  function wr(e) {
1395
1395
  if (!Array.isArray(e) || e.length === 0)
1396
1396
  throw new Error("expected non-empty array");
1397
1397
  }
1398
- function La(e, t, n, r) {
1398
+ function $a(e, t, n, r) {
1399
1399
  const { Fr: s, Fp2: i, Fp12: o } = e, { twistType: a, ateLoopSize: c, postPrecompute: u } = r;
1400
1400
  let l;
1401
1401
  if (a === "multiplicative")
@@ -1415,7 +1415,7 @@ function La(e, t, n, r) {
1415
1415
  const F = i.sqr(y), $ = i.mul(F, y), q = i.mul(F, C), k = i.add(i.sub($, i.mul(q, is)), i.mul(i.sqr(U), _));
1416
1416
  return C = i.mul(y, k), I = i.sub(i.mul(i.sub(q, k), U), i.mul($, I)), _ = i.mul(_, $), { Rx: C, Ry: I, Rz: _ };
1417
1417
  }
1418
- const w = $a(c), h = xr((P) => {
1418
+ const w = Ca(c), h = xr((P) => {
1419
1419
  const C = P, { x: I, y: _ } = C.toAffine(), D = I, H = _, U = i.neg(_);
1420
1420
  let y = D, x = H, v = i.ONE;
1421
1421
  const R = [];
@@ -1458,8 +1458,8 @@ function La(e, t, n, r) {
1458
1458
  return b([{ g1: P, g2: C }], I);
1459
1459
  }
1460
1460
  const O = {
1461
- seed: _i(s.ORDER)
1462
- }, A = r.randomBytes || oi;
1461
+ seed: mi(s.ORDER)
1462
+ }, A = r.randomBytes || ii;
1463
1463
  return {
1464
1464
  lengths: O,
1465
1465
  Fr: s,
@@ -1469,7 +1469,7 @@ function La(e, t, n, r) {
1469
1469
  pairing: S,
1470
1470
  pairingBatch: b,
1471
1471
  calcPairingPrecomputes: h,
1472
- randomSecretKey: (P = A(O.seed)) => (ft(P, O.seed, "seed"), xi(P, s.ORDER))
1472
+ randomSecretKey: (P = A(O.seed)) => (ft(P, O.seed, "seed"), _i(P, s.ORDER))
1473
1473
  };
1474
1474
  }
1475
1475
  function os(e, t, n, r, s, i) {
@@ -1572,8 +1572,8 @@ function os(e, t, n, r, s, i) {
1572
1572
  Signature: i
1573
1573
  });
1574
1574
  }
1575
- function Aa(e, t, n, r) {
1576
- const { Fp: s, Fr: i, Fp2: o, Fp6: a, Fp12: c } = e, u = { Point: t }, l = { Point: n }, f = La(e, t, n, r), { millerLoopBatch: d, pairing: p, pairingBatch: w, calcPairingPrecomputes: h, randomSecretKey: g, lengths: b } = f;
1575
+ function La(e, t, n, r) {
1576
+ const { Fp: s, Fr: i, Fp2: o, Fp6: a, Fp12: c } = e, u = { Point: t }, l = { Point: n }, f = $a(e, t, n, r), { millerLoopBatch: d, pairing: p, pairingBatch: w, calcPairingPrecomputes: h, randomSecretKey: g, lengths: b } = f;
1577
1577
  return u.Point.BASE.precompute(4), Object.freeze({
1578
1578
  lengths: b,
1579
1579
  millerLoopBatch: d,
@@ -1592,8 +1592,8 @@ function Aa(e, t, n, r) {
1592
1592
  }
1593
1593
  });
1594
1594
  }
1595
- function Pa(e, t, n, r, s) {
1596
- const i = Aa(e, t, n, r), o = rs(t, s.mapToG1 || ye, {
1595
+ function Aa(e, t, n, r, s) {
1596
+ const i = La(e, t, n, r), o = rs(t, s.mapToG1 || ye, {
1597
1597
  ...s.hasherOpts,
1598
1598
  ...s.hasherOptsG1
1599
1599
  }), a = rs(n, s.mapToG2 || ye, {
@@ -1602,8 +1602,8 @@ function Pa(e, t, n, r, s) {
1602
1602
  });
1603
1603
  return Object.freeze({ ...i, G1: o, G2: a });
1604
1604
  }
1605
- function Fa(e, t, n, r, s, i) {
1606
- const o = Pa(e, t, n, r, s), a = {
1605
+ function Pa(e, t, n, r, s, i) {
1606
+ const o = Aa(e, t, n, r, s), a = {
1607
1607
  ...o,
1608
1608
  Fr: o.fields.Fr,
1609
1609
  Fp12: o.fields.Fp12,
@@ -1625,7 +1625,7 @@ function Ar(e, t, n, r, s = 1, i) {
1625
1625
  }
1626
1626
  return c;
1627
1627
  }
1628
- function Ua(e, t, n) {
1628
+ function Fa(e, t, n) {
1629
1629
  const r = t.pow(n, (e.ORDER - Ze) / cs), s = t.pow(n, (e.ORDER - Ze) / Bt);
1630
1630
  function i(d, p) {
1631
1631
  const w = t.mul(t.frobeniusMap(d, 1), r), h = t.mul(t.frobeniusMap(p, 1), s);
@@ -1649,7 +1649,7 @@ const us = (e, t) => {
1649
1649
  const n = t.map((r) => e.create(r));
1650
1650
  return { c0: n[0], c1: n[1] };
1651
1651
  };
1652
- class qa {
1652
+ class Ua {
1653
1653
  ORDER;
1654
1654
  BITS;
1655
1655
  BYTES;
@@ -1802,7 +1802,7 @@ class qa {
1802
1802
  };
1803
1803
  }
1804
1804
  }
1805
- class Da {
1805
+ class qa {
1806
1806
  ORDER;
1807
1807
  BITS;
1808
1808
  BYTES;
@@ -1993,7 +1993,7 @@ class Da {
1993
1993
  };
1994
1994
  }
1995
1995
  }
1996
- class Ma {
1996
+ class Da {
1997
1997
  ORDER;
1998
1998
  BITS;
1999
1999
  BYTES;
@@ -2205,52 +2205,52 @@ class Ma {
2205
2205
  _cyclotomicExp(t, n) {
2206
2206
  let r = this.ONE;
2207
2207
  for (let s = this.X_LEN - 1; s >= 0; s--)
2208
- r = this._cyclotomicSquare(r), ia(n, s) && (r = this.mul(r, t));
2208
+ r = this._cyclotomicSquare(r), sa(n, s) && (r = this.mul(r, t));
2209
2209
  return r;
2210
2210
  }
2211
2211
  }
2212
- function Wa(e) {
2213
- const t = _n(e.ORDER), n = new qa(t, e), r = new Da(n), s = new Ma(r, e);
2212
+ function Ma(e) {
2213
+ const t = _n(e.ORDER), n = new Ua(t, e), r = new qa(n), s = new Da(r, e);
2214
2214
  return { Fp: t, Fp2: n, Fp6: r, Fp12: s };
2215
2215
  }
2216
- const _t = BigInt(0), Hn = BigInt(1), qt = BigInt(2), Xn = BigInt(3), fn = BigInt(4), _e = BigInt("0xd201000000010000"), Ga = Dn(_e), en = {
2216
+ const _t = BigInt(0), Hn = BigInt(1), qt = BigInt(2), Xn = BigInt(3), ln = BigInt(4), _e = BigInt("0xd201000000010000"), Wa = Dn(_e), tn = {
2217
2217
  p: BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),
2218
2218
  n: BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"),
2219
2219
  h: BigInt("0x396c8c005555e1568c00aaab0000aaab"),
2220
2220
  a: _t,
2221
- b: fn,
2221
+ b: ln,
2222
2222
  Gx: BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),
2223
2223
  Gy: BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1")
2224
- }, Pr = _n(en.n, {
2224
+ }, Pr = _n(tn.n, {
2225
2225
  modFromBytes: !0
2226
- }), { Fp: N, Fp2: V, Fp6: Ha, Fp12: Y } = Wa({
2227
- ORDER: en.p,
2228
- X_LEN: Ga,
2226
+ }), { Fp: N, Fp2: V, Fp6: Ga, Fp12: Y } = Ma({
2227
+ ORDER: tn.p,
2228
+ X_LEN: Wa,
2229
2229
  // Finite extension field over irreducible polynominal.
2230
2230
  // Fp(u) / (u² - β) where β = -1
2231
2231
  FP2_NONRESIDUE: [Hn, Hn],
2232
2232
  Fp2mulByB: ({ c0: e, c1: t }) => {
2233
- const n = N.mul(e, fn), r = N.mul(t, fn);
2233
+ const n = N.mul(e, ln), r = N.mul(t, ln);
2234
2234
  return { c0: N.sub(n, r), c1: N.add(n, r) };
2235
2235
  },
2236
2236
  Fp12finalExponentiate: (e) => {
2237
2237
  const t = _e, n = Y.div(Y.frobeniusMap(e, 6), e), r = Y.mul(Y.frobeniusMap(n, 2), n), s = Y.conjugate(Y._cyclotomicExp(r, t)), i = Y.mul(Y.conjugate(Y._cyclotomicSquare(r)), s), o = Y.conjugate(Y._cyclotomicExp(i, t)), a = Y.conjugate(Y._cyclotomicExp(o, t)), c = Y.mul(Y.conjugate(Y._cyclotomicExp(a, t)), Y._cyclotomicSquare(s)), u = Y.conjugate(Y._cyclotomicExp(c, t)), l = Y.frobeniusMap(Y.mul(s, a), 2), f = Y.frobeniusMap(Y.mul(o, r), 3), d = Y.frobeniusMap(Y.mul(c, Y.conjugate(r)), 1), p = Y.mul(Y.mul(u, Y.conjugate(i)), r);
2238
2238
  return Y.mul(Y.mul(Y.mul(l, f), d), p);
2239
2239
  }
2240
- }), { G2psi: ls, G2psi2: Va } = Ua(N, V, V.div(V.ONE, V.NONRESIDUE)), gr = Object.freeze({
2240
+ }), { G2psi: ls, G2psi2: Ha } = Fa(N, V, V.div(V.ONE, V.NONRESIDUE)), gr = Object.freeze({
2241
2241
  DST: "BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",
2242
2242
  encodeDST: "BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",
2243
2243
  p: N.ORDER,
2244
2244
  m: 2,
2245
2245
  k: 128,
2246
2246
  expand: "xmd",
2247
- hash: Ei
2247
+ hash: xi
2248
2248
  }), Fr = {
2249
2249
  p: V.ORDER,
2250
- n: en.n,
2250
+ n: tn.n,
2251
2251
  h: BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),
2252
2252
  a: V.ZERO,
2253
- b: V.fromBigTuple([fn, fn]),
2253
+ b: V.fromBigTuple([ln, ln]),
2254
2254
  Gx: V.fromBigTuple([
2255
2255
  BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),
2256
2256
  BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")
@@ -2261,7 +2261,7 @@ const _t = BigInt(0), Hn = BigInt(1), qt = BigInt(2), Xn = BigInt(3), fn = BigIn
2261
2261
  ])
2262
2262
  }, zn = xn(N.toBytes(_t), { infinity: !0, compressed: !0 });
2263
2263
  function Jn(e) {
2264
- e = li(e);
2264
+ e = ui(e);
2265
2265
  const t = e[0] & 224, n = !!(t >> 7 & 1), r = !!(t >> 6 & 1), s = !!(t >> 5 & 1);
2266
2266
  return e[0] &= 31, { compressed: n, infinity: r, sort: s, value: e };
2267
2267
  }
@@ -2270,7 +2270,7 @@ function xn(e, t) {
2270
2270
  throw new Error("setMask: non-empty mask");
2271
2271
  return t.compressed && (e[0] |= 128), t.infinity && (e[0] |= 64), t.sort && (e[0] |= 32), e;
2272
2272
  }
2273
- function Za(e, t, n) {
2273
+ function Va(e, t, n) {
2274
2274
  const { BYTES: r, ORDER: s } = N, i = t.is0(), { x: o, y: a } = t.toAffine();
2275
2275
  if (n) {
2276
2276
  if (i)
@@ -2288,7 +2288,7 @@ function yr(e) {
2288
2288
  const i = !!(s * qt / n);
2289
2289
  return xn(mt(r, t), { compressed: !0, sort: i });
2290
2290
  }
2291
- function Ya(e) {
2291
+ function Za(e) {
2292
2292
  const { compressed: t, infinity: n, sort: r, value: s } = Jn(e), { BYTES: i, ORDER: o } = N;
2293
2293
  if (s.length === 48 && t) {
2294
2294
  const a = Kt(s), c = N.create(a & mn(N.BITS));
@@ -2297,7 +2297,7 @@ function Ya(e) {
2297
2297
  throw new Error("invalid G1 point: non-empty, at infinity, with compression");
2298
2298
  return { x: _t, y: _t };
2299
2299
  }
2300
- const u = N.add(N.pow(c, Xn), N.create(en.b));
2300
+ const u = N.add(N.pow(c, Xn), N.create(tn.b));
2301
2301
  let l = N.sqrt(u);
2302
2302
  if (!l)
2303
2303
  throw new Error("invalid G1 point: compressed point");
@@ -2317,7 +2317,7 @@ function fs(e) {
2317
2317
  const { infinity: t, sort: n, value: r } = Jn(ft(e, 48, "signature")), s = N.ORDER, i = T.G1.Point, o = Kt(r);
2318
2318
  if (t)
2319
2319
  return i.ZERO;
2320
- const a = N.create(o & mn(N.BITS)), c = N.add(N.pow(a, Xn), N.create(en.b));
2320
+ const a = N.create(o & mn(N.BITS)), c = N.add(N.pow(a, Xn), N.create(tn.b));
2321
2321
  let u = N.sqrt(c);
2322
2322
  if (!u)
2323
2323
  throw new Error("invalid G1 point: compressed");
@@ -2326,7 +2326,7 @@ function fs(e) {
2326
2326
  const f = i.fromAffine({ x: a, y: u });
2327
2327
  return f.assertValidity(), f;
2328
2328
  }
2329
- function Ka(e, t, n) {
2329
+ function Ya(e, t, n) {
2330
2330
  const { BYTES: r, ORDER: s } = N, i = t.is0(), { x: o, y: a } = t.toAffine();
2331
2331
  if (n) {
2332
2332
  if (i)
@@ -2348,7 +2348,7 @@ function br(e) {
2348
2348
  const { x: n, y: r } = e.toAffine(), { re: s, im: i } = V.reim(n), { re: o, im: a } = V.reim(r), u = !!((a > _t ? a * qt : o * qt) / N.ORDER & Hn), l = s;
2349
2349
  return ht(xn(mt(i, t), { sort: u, compressed: !0 }), mt(l, t));
2350
2350
  }
2351
- function Xa(e) {
2351
+ function Ka(e) {
2352
2352
  const { BYTES: t, ORDER: n } = N, { compressed: r, infinity: s, sort: i, value: o } = Jn(e);
2353
2353
  if (!r && !s && i || // 00100000
2354
2354
  !r && s && i || // 01100000
@@ -2392,7 +2392,7 @@ function ds(e) {
2392
2392
  const O = i.fromAffine({ x: f, y: p });
2393
2393
  return O.assertValidity(), O;
2394
2394
  }
2395
- const za = {
2395
+ const Xa = {
2396
2396
  ShortSignature: {
2397
2397
  fromBytes(e) {
2398
2398
  return fs(ft(e));
@@ -2407,7 +2407,7 @@ const za = {
2407
2407
  return yr(e);
2408
2408
  },
2409
2409
  toHex(e) {
2410
- return ln(yr(e));
2410
+ return un(yr(e));
2411
2411
  }
2412
2412
  },
2413
2413
  LongSignature: {
@@ -2424,20 +2424,20 @@ const za = {
2424
2424
  return br(e);
2425
2425
  },
2426
2426
  toHex(e) {
2427
- return ln(br(e));
2427
+ return un(br(e));
2428
2428
  }
2429
2429
  }
2430
- }, Ja = {
2430
+ }, za = {
2431
2431
  Fp: N,
2432
2432
  Fp2: V,
2433
- Fp6: Ha,
2433
+ Fp6: Ga,
2434
2434
  Fp12: Y,
2435
2435
  Fr: Pr
2436
- }, ja = Ii(en, {
2436
+ }, Ja = Ti(tn, {
2437
2437
  allowInfinityPoint: !0,
2438
2438
  Fn: Pr,
2439
- fromBytes: Ya,
2440
- toBytes: Za,
2439
+ fromBytes: Za,
2440
+ toBytes: Va,
2441
2441
  // Checks is the point resides in prime-order subgroup.
2442
2442
  // point.isTorsionFree() should return true for valid points
2443
2443
  // It returns false for shitty points.
@@ -2449,12 +2449,12 @@ const za = {
2449
2449
  // Clear cofactor of G1
2450
2450
  // https://eprint.iacr.org/2019/403
2451
2451
  clearCofactor: (e, t) => t.multiplyUnsafe(_e).add(t)
2452
- }), Qa = Ii(Fr, {
2452
+ }), ja = Ti(Fr, {
2453
2453
  Fp: V,
2454
2454
  allowInfinityPoint: !0,
2455
2455
  Fn: Pr,
2456
- fromBytes: Xa,
2457
- toBytes: Ka,
2456
+ fromBytes: Ka,
2457
+ toBytes: Ya,
2458
2458
  // https://eprint.iacr.org/2021/1130.pdf
2459
2459
  // Older version: https://eprint.iacr.org/2019/814.pdf
2460
2460
  isTorsionFree: (e, t) => t.multiplyUnsafe(_e).negate().equals(ls(e, t)),
@@ -2464,20 +2464,20 @@ const za = {
2464
2464
  clearCofactor: (e, t) => {
2465
2465
  const n = _e;
2466
2466
  let r = t.multiplyUnsafe(n).negate(), s = ls(e, t), i = t.double();
2467
- return i = Va(e, i), i = i.subtract(s), s = r.add(s), s = s.multiplyUnsafe(n).negate(), i = i.add(s), i = i.subtract(r), i.subtract(t);
2467
+ return i = Ha(e, i), i = i.subtract(s), s = r.add(s), s = s.multiplyUnsafe(n).negate(), i = i.add(s), i = i.subtract(r), i.subtract(t);
2468
2468
  }
2469
- }), tc = {
2470
- mapToG1: oc,
2471
- mapToG2: ac,
2469
+ }), Qa = {
2470
+ mapToG1: ic,
2471
+ mapToG2: oc,
2472
2472
  hasherOpts: gr,
2473
2473
  hasherOptsG1: { ...gr, m: 1, DST: "BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_" },
2474
2474
  hasherOptsG2: { ...gr }
2475
- }, ec = {
2475
+ }, tc = {
2476
2476
  ateLoopSize: _e,
2477
2477
  // The BLS parameter x for BLS12-381
2478
2478
  twistType: "multiplicative",
2479
- randomBytes: oi
2480
- }, T = Fa(Ja, ja, Qa, ec, tc, za), nc = Oi(V, [
2479
+ randomBytes: ii
2480
+ }, T = Pa(za, Ja, ja, tc, Qa, Xa), ec = vi(V, [
2481
2481
  // xNum
2482
2482
  [
2483
2483
  [
@@ -2546,7 +2546,7 @@ const za = {
2546
2546
  ["0x1", "0x0"]
2547
2547
  // LAST 1
2548
2548
  ]
2549
- ].map((e) => e.map((t) => V.fromBigTuple(t.map(BigInt))))), rc = Oi(N, [
2549
+ ].map((e) => e.map((t) => V.fromBigTuple(t.map(BigInt))))), nc = vi(N, [
2550
2550
  // xNum
2551
2551
  [
2552
2552
  "0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7",
@@ -2616,11 +2616,11 @@ const za = {
2616
2616
  "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"
2617
2617
  // LAST 1
2618
2618
  ]
2619
- ].map((e) => e.map((t) => BigInt(t)))), sc = Ri(N, {
2619
+ ].map((e) => e.map((t) => BigInt(t)))), rc = Ii(N, {
2620
2620
  A: N.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),
2621
2621
  B: N.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),
2622
2622
  Z: N.create(BigInt(11))
2623
- }), ic = Ri(V, {
2623
+ }), sc = Ii(V, {
2624
2624
  A: V.create({ c0: N.create(_t), c1: N.create(BigInt(240)) }),
2625
2625
  // A' = 240 * I
2626
2626
  B: V.create({ c0: N.create(BigInt(1012)), c1: N.create(BigInt(1012)) }),
@@ -2628,19 +2628,19 @@ const za = {
2628
2628
  Z: V.create({ c0: N.create(BigInt(-2)), c1: N.create(BigInt(-1)) })
2629
2629
  // Z: -(2 + I)
2630
2630
  });
2631
- function oc(e) {
2632
- const { x: t, y: n } = sc(N.create(e[0]));
2633
- return rc(t, n);
2634
- }
2635
- function ac(e) {
2636
- const { x: t, y: n } = ic(V.fromBigTuple(e));
2631
+ function ic(e) {
2632
+ const { x: t, y: n } = rc(N.create(e[0]));
2637
2633
  return nc(t, n);
2638
2634
  }
2639
- function cc(e, t, n) {
2635
+ function oc(e) {
2636
+ const { x: t, y: n } = sc(V.fromBigTuple(e));
2637
+ return ec(t, n);
2638
+ }
2639
+ function ac(e, t, n) {
2640
2640
  return kr(e), n === void 0 && (n = new Uint8Array(e.outputLen)), Lr(e, n, t);
2641
2641
  }
2642
2642
  const mr = /* @__PURE__ */ Uint8Array.of(0), ps = /* @__PURE__ */ Uint8Array.of();
2643
- function uc(e, t, n, r = 32) {
2643
+ function cc(e, t, n, r = 32) {
2644
2644
  kr(e), Je(r, "length");
2645
2645
  const s = e.outputLen;
2646
2646
  if (r > 255 * s)
@@ -2650,10 +2650,10 @@ function uc(e, t, n, r = 32) {
2650
2650
  const o = new Uint8Array(i * s), a = Lr.create(e, t), c = a._cloneInto(), u = new Uint8Array(a.outputLen);
2651
2651
  for (let l = 0; l < i; l++)
2652
2652
  mr[0] = l + 1, c.update(l === 0 ? ps : u).update(n).update(mr).digestInto(u), o.set(u, s * l), a._cloneInto(c);
2653
- return a.destroy(), c.destroy(), un(u, mr), o.slice(0, r);
2653
+ return a.destroy(), c.destroy(), cn(u, mr), o.slice(0, r);
2654
2654
  }
2655
- const lc = (e, t, n, r, s) => uc(e, cc(e, t, n), r, s), fc = "6.16.0";
2656
- function dc(e, t, n) {
2655
+ const uc = (e, t, n, r, s) => cc(e, ac(e, t, n), r, s), lc = "6.16.0";
2656
+ function fc(e, t, n) {
2657
2657
  const r = t.split("|").map((i) => i.trim());
2658
2658
  for (let i = 0; i < r.length; i++)
2659
2659
  switch (t) {
@@ -2673,7 +2673,7 @@ function st(e, t, n) {
2673
2673
  for (let r in t) {
2674
2674
  let s = t[r];
2675
2675
  const i = n ? n[r] : null;
2676
- i && dc(s, i, r), Object.defineProperty(e, r, { enumerable: !0, value: s, writable: !1 });
2676
+ i && fc(s, i, r), Object.defineProperty(e, r, { enumerable: !0, value: s, writable: !1 });
2677
2677
  }
2678
2678
  }
2679
2679
  function Ye(e, t) {
@@ -2714,7 +2714,7 @@ function Ye(e, t) {
2714
2714
  function hs(e, t) {
2715
2715
  return e && e.code === t;
2716
2716
  }
2717
- function ki(e, t, n) {
2717
+ function Ri(e, t, n) {
2718
2718
  let r = e;
2719
2719
  {
2720
2720
  const i = [];
@@ -2728,7 +2728,7 @@ function ki(e, t, n) {
2728
2728
  i.push(o + "=" + Ye(a));
2729
2729
  }
2730
2730
  }
2731
- i.push(`code=${t}`), i.push(`version=${fc}`), i.length && (e += " (" + i.join(", ") + ")");
2731
+ i.push(`code=${t}`), i.push(`version=${lc}`), i.length && (e += " (" + i.join(", ") + ")");
2732
2732
  }
2733
2733
  let s;
2734
2734
  switch (t) {
@@ -2746,12 +2746,12 @@ function ki(e, t, n) {
2746
2746
  }
2747
2747
  function at(e, t, n, r) {
2748
2748
  if (!e)
2749
- throw ki(t, n, r);
2749
+ throw Ri(t, n, r);
2750
2750
  }
2751
2751
  function m(e, t, n, r) {
2752
2752
  at(e, t, "INVALID_ARGUMENT", { argument: n, value: r });
2753
2753
  }
2754
- function Ni(e, t, n) {
2754
+ function ki(e, t, n) {
2755
2755
  n == null && (n = ""), n && (n = ": " + n), at(e >= t, "missing argument" + n, "MISSING_ARGUMENT", {
2756
2756
  count: e,
2757
2757
  expectedCount: t
@@ -2779,7 +2779,7 @@ function Ur(e, t, n) {
2779
2779
  });
2780
2780
  }
2781
2781
  }
2782
- function Ci(e, t, n) {
2782
+ function Ni(e, t, n) {
2783
2783
  if (e instanceof Uint8Array)
2784
2784
  return n ? new Uint8Array(e) : e;
2785
2785
  if (typeof e == "string" && e.length % 2 === 0 && e.match(/^0x[0-9a-f]*$/i)) {
@@ -2792,12 +2792,12 @@ function Ci(e, t, n) {
2792
2792
  m(!1, "invalid BytesLike value", t || "value", e);
2793
2793
  }
2794
2794
  function yt(e, t) {
2795
- return Ci(e, t, !1);
2795
+ return Ni(e, t, !1);
2796
2796
  }
2797
2797
  function Xt(e, t) {
2798
- return Ci(e, t, !0);
2798
+ return Ni(e, t, !0);
2799
2799
  }
2800
- function cn(e, t) {
2800
+ function an(e, t) {
2801
2801
  return !(typeof e != "string" || !e.match(/^0x[0-9A-Fa-f]*$/) || typeof t == "number" && e.length !== 2 + 2 * t || t === !0 && e.length % 2 !== 0);
2802
2802
  }
2803
2803
  const ws = "0123456789abcdef";
@@ -2813,8 +2813,8 @@ function bt(e) {
2813
2813
  function xe(e) {
2814
2814
  return "0x" + e.map((t) => bt(t).substring(2)).join("");
2815
2815
  }
2816
- function pc(e) {
2817
- return cn(e, !0) ? (e.length - 2) / 2 : yt(e).length;
2816
+ function dc(e) {
2817
+ return an(e, !0) ? (e.length - 2) / 2 : yt(e).length;
2818
2818
  }
2819
2819
  function We(e, t, n) {
2820
2820
  const r = yt(e);
@@ -2824,7 +2824,7 @@ function We(e, t, n) {
2824
2824
  offset: n
2825
2825
  }), bt(r.slice(t ?? 0, n ?? r.length));
2826
2826
  }
2827
- function $i(e, t, n) {
2827
+ function Ci(e, t, n) {
2828
2828
  const r = yt(e);
2829
2829
  at(t >= r.length, "padding exceeds data length", "BUFFER_OVERRUN", {
2830
2830
  buffer: new Uint8Array(r),
@@ -2835,13 +2835,13 @@ function $i(e, t, n) {
2835
2835
  return s.fill(0), n ? s.set(r, t - r.length) : s.set(r, 0), bt(s);
2836
2836
  }
2837
2837
  function An(e, t) {
2838
- return $i(e, t, !0);
2838
+ return Ci(e, t, !0);
2839
2839
  }
2840
- function Li(e, t) {
2841
- return $i(e, t, !1);
2840
+ function $i(e, t) {
2841
+ return Ci(e, t, !1);
2842
2842
  }
2843
2843
  const En = BigInt(0), Mt = BigInt(1), Ke = 9007199254740991;
2844
- function hc(e, t) {
2844
+ function pc(e, t) {
2845
2845
  const n = jn(e, "value"), r = BigInt(Ee(t, "width"));
2846
2846
  if (at(n >> r === En, "overflow", "NUMERIC_FAULT", {
2847
2847
  operation: "fromTwos",
@@ -2853,8 +2853,8 @@ function hc(e, t) {
2853
2853
  }
2854
2854
  return n;
2855
2855
  }
2856
- function Ai(e, t) {
2857
- let n = nn(e, "value");
2856
+ function Li(e, t) {
2857
+ let n = en(e, "value");
2858
2858
  const r = BigInt(Ee(t, "width")), s = Mt << r - Mt;
2859
2859
  if (n < En) {
2860
2860
  n = -n, at(n <= s, "too low", "NUMERIC_FAULT", {
@@ -2876,7 +2876,7 @@ function In(e, t) {
2876
2876
  const n = jn(e, "value"), r = BigInt(Ee(t, "bits"));
2877
2877
  return n & (Mt << r) - Mt;
2878
2878
  }
2879
- function nn(e, t) {
2879
+ function en(e, t) {
2880
2880
  switch (typeof e) {
2881
2881
  case "bigint":
2882
2882
  return e;
@@ -2894,7 +2894,7 @@ function nn(e, t) {
2894
2894
  m(!1, "invalid BigNumberish value", t || "value", e);
2895
2895
  }
2896
2896
  function jn(e, t) {
2897
- const n = nn(e, t);
2897
+ const n = en(e, t);
2898
2898
  return at(n >= En, "unsigned value cannot be negative", "NUMERIC_FAULT", {
2899
2899
  fault: "overflow",
2900
2900
  operation: "getUint",
@@ -2902,14 +2902,14 @@ function jn(e, t) {
2902
2902
  }), n;
2903
2903
  }
2904
2904
  const gs = "0123456789abcdef";
2905
- function Pi(e) {
2905
+ function Ai(e) {
2906
2906
  if (e instanceof Uint8Array) {
2907
2907
  let t = "0x0";
2908
2908
  for (const n of e)
2909
2909
  t += gs[n >> 4], t += gs[n & 15];
2910
2910
  return BigInt(t);
2911
2911
  }
2912
- return nn(e);
2912
+ return en(e);
2913
2913
  }
2914
2914
  function Ee(e, t) {
2915
2915
  switch (typeof e) {
@@ -2928,10 +2928,10 @@ function Ee(e, t) {
2928
2928
  }
2929
2929
  m(!1, "invalid numeric value", t || "value", e);
2930
2930
  }
2931
- function wc(e) {
2932
- return Ee(Pi(e));
2931
+ function hc(e) {
2932
+ return Ee(Ai(e));
2933
2933
  }
2934
- function Fi(e, t) {
2934
+ function Pi(e, t) {
2935
2935
  const n = jn(e, "value");
2936
2936
  let r = n.toString(16);
2937
2937
  if (t == null)
@@ -2949,7 +2949,7 @@ function Fi(e, t) {
2949
2949
  }
2950
2950
  return "0x" + r;
2951
2951
  }
2952
- function Ui(e, t) {
2952
+ function Fi(e, t) {
2953
2953
  const n = jn(e, "value");
2954
2954
  if (n === En)
2955
2955
  return new Uint8Array(0);
@@ -2962,10 +2962,10 @@ function Ui(e, t) {
2962
2962
  }
2963
2963
  return s;
2964
2964
  }
2965
- function gc(e, t, n, r, s) {
2965
+ function wc(e, t, n, r, s) {
2966
2966
  m(!1, `invalid codepoint at offset ${t}; ${e}`, "bytes", n);
2967
2967
  }
2968
- function qi(e, t, n, r, s) {
2968
+ function Ui(e, t, n, r, s) {
2969
2969
  if (e === "BAD_PREFIX" || e === "UNEXPECTED_CONTINUE") {
2970
2970
  let i = 0;
2971
2971
  for (let o = t + 1; o < n.length && n[o] >> 6 === 2; o++)
@@ -2974,16 +2974,16 @@ function qi(e, t, n, r, s) {
2974
2974
  }
2975
2975
  return e === "OVERRUN" ? n.length - t - 1 : 0;
2976
2976
  }
2977
- function yc(e, t, n, r, s) {
2978
- return e === "OVERLONG" ? (m(typeof s == "number", "invalid bad code point for replacement", "badCodepoint", s), r.push(s), 0) : (r.push(65533), qi(e, t, n));
2977
+ function gc(e, t, n, r, s) {
2978
+ return e === "OVERLONG" ? (m(typeof s == "number", "invalid bad code point for replacement", "badCodepoint", s), r.push(s), 0) : (r.push(65533), Ui(e, t, n));
2979
2979
  }
2980
- const bc = Object.freeze({
2981
- error: gc,
2982
- ignore: qi,
2983
- replace: yc
2980
+ const yc = Object.freeze({
2981
+ error: wc,
2982
+ ignore: Ui,
2983
+ replace: gc
2984
2984
  });
2985
- function mc(e, t) {
2986
- t == null && (t = bc.error);
2985
+ function bc(e, t) {
2986
+ t == null && (t = yc.error);
2987
2987
  const n = yt(e, "bytes"), r = [];
2988
2988
  let s = 0;
2989
2989
  for (; s < n.length; ) {
@@ -3054,20 +3054,20 @@ function qr(e, t) {
3054
3054
  }
3055
3055
  return new Uint8Array(n);
3056
3056
  }
3057
- function _c(e) {
3057
+ function mc(e) {
3058
3058
  return e.map((t) => t <= 65535 ? String.fromCharCode(t) : (t -= 65536, String.fromCharCode((t >> 10 & 1023) + 55296, (t & 1023) + 56320))).join("");
3059
3059
  }
3060
- function xc(e, t) {
3061
- return _c(mc(e, t));
3060
+ function _c(e, t) {
3061
+ return mc(bc(e, t));
3062
3062
  }
3063
- const vt = 32, Sr = new Uint8Array(vt), Ec = ["then"], Rn = {}, Di = /* @__PURE__ */ new WeakMap();
3063
+ const vt = 32, Sr = new Uint8Array(vt), xc = ["then"], Rn = {}, qi = /* @__PURE__ */ new WeakMap();
3064
3064
  function Re(e) {
3065
- return Di.get(e);
3065
+ return qi.get(e);
3066
3066
  }
3067
3067
  function ys(e, t) {
3068
- Di.set(e, t);
3068
+ qi.set(e, t);
3069
3069
  }
3070
- function on(e, t) {
3070
+ function sn(e, t) {
3071
3071
  const n = new Error(`deferred error during ABI decoding triggered accessing ${e}`);
3072
3072
  throw n.error = t, n;
3073
3073
  }
@@ -3106,9 +3106,9 @@ class oe extends Array {
3106
3106
  if (d < 0 || d >= this.length)
3107
3107
  throw new RangeError("out of result range");
3108
3108
  const p = c[d];
3109
- return p instanceof Error && on(`index ${d}`, p), p;
3109
+ return p instanceof Error && sn(`index ${d}`, p), p;
3110
3110
  }
3111
- if (Ec.indexOf(u) >= 0)
3111
+ if (xc.indexOf(u) >= 0)
3112
3112
  return Reflect.get(c, u, l);
3113
3113
  const f = c[u];
3114
3114
  if (f instanceof Function)
@@ -3133,7 +3133,7 @@ class oe extends Array {
3133
3133
  toArray(t) {
3134
3134
  const n = [];
3135
3135
  return this.forEach((r, s) => {
3136
- r instanceof Error && on(`index ${s}`, r), t && r instanceof oe && (r = r.toArray(t)), n.push(r);
3136
+ r instanceof Error && sn(`index ${s}`, r), t && r instanceof oe && (r = r.toArray(t)), n.push(r);
3137
3137
  }), n;
3138
3138
  }
3139
3139
  /**
@@ -3167,7 +3167,7 @@ class oe extends Array {
3167
3167
  const r = Re(this), s = [], i = [];
3168
3168
  for (let o = 0; o < this.length; o++) {
3169
3169
  const a = this[o];
3170
- a instanceof Error && on(`index ${o}`, a), t.call(n, a, o, this) && (s.push(a), i.push(r[o]));
3170
+ a instanceof Error && sn(`index ${o}`, a), t.call(n, a, o, this) && (s.push(a), i.push(r[o]));
3171
3171
  }
3172
3172
  return new oe(Rn, s, i);
3173
3173
  }
@@ -3178,7 +3178,7 @@ class oe extends Array {
3178
3178
  const r = [];
3179
3179
  for (let s = 0; s < this.length; s++) {
3180
3180
  const i = this[s];
3181
- i instanceof Error && on(`index ${s}`, i), r.push(t.call(n, i, s, this));
3181
+ i instanceof Error && sn(`index ${s}`, i), r.push(t.call(n, i, s, this));
3182
3182
  }
3183
3183
  return r;
3184
3184
  }
@@ -3195,7 +3195,7 @@ class oe extends Array {
3195
3195
  if (n === -1)
3196
3196
  return;
3197
3197
  const r = this[n];
3198
- return r instanceof Error && on(`property ${JSON.stringify(t)}`, r.error), r;
3198
+ return r instanceof Error && sn(`property ${JSON.stringify(t)}`, r.error), r;
3199
3199
  }
3200
3200
  /**
3201
3201
  * Creates a new [[Result]] for %%items%% with each entry
@@ -3206,7 +3206,7 @@ class oe extends Array {
3206
3206
  }
3207
3207
  }
3208
3208
  function bs(e) {
3209
- let t = Ui(e);
3209
+ let t = Fi(e);
3210
3210
  return at(t.length <= vt, "value out-of-bounds", "BUFFER_OVERRUN", { buffer: t, length: vt, offset: t.length }), t.length !== vt && (t = Xt(xe([Sr.slice(t.length % vt), t]))), t;
3211
3211
  }
3212
3212
  class de {
@@ -3332,17 +3332,17 @@ class Dr {
3332
3332
  }
3333
3333
  // Read a numeric values
3334
3334
  readValue() {
3335
- return Pi(this.readBytes(vt));
3335
+ return Ai(this.readBytes(vt));
3336
3336
  }
3337
3337
  readIndex() {
3338
- return wc(this.readBytes(vt));
3338
+ return hc(this.readBytes(vt));
3339
3339
  }
3340
3340
  }
3341
3341
  function ms(e) {
3342
3342
  if (!Number.isSafeInteger(e) || e < 0)
3343
3343
  throw new Error(`Wrong positive integer: ${e}`);
3344
3344
  }
3345
- function Mi(e, ...t) {
3345
+ function Di(e, ...t) {
3346
3346
  if (!(e instanceof Uint8Array))
3347
3347
  throw new Error("Expected Uint8Array");
3348
3348
  if (t.length > 0 && !t.includes(e.length))
@@ -3354,57 +3354,57 @@ function _s(e, t = !0) {
3354
3354
  if (t && e.finished)
3355
3355
  throw new Error("Hash#digest() has already been called");
3356
3356
  }
3357
- function Sc(e, t) {
3358
- Mi(e);
3357
+ function Ec(e, t) {
3358
+ Di(e);
3359
3359
  const n = t.outputLen;
3360
3360
  if (e.length < n)
3361
3361
  throw new Error(`digestInto() expects output buffer of length at least ${n}`);
3362
3362
  }
3363
- const Bc = (e) => e instanceof Uint8Array, vc = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), Oc = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
3364
- if (!Oc)
3363
+ const Sc = (e) => e instanceof Uint8Array, Bc = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), vc = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
3364
+ if (!vc)
3365
3365
  throw new Error("Non little-endian hardware is not supported");
3366
- function Tc(e) {
3366
+ function Oc(e) {
3367
3367
  if (typeof e != "string")
3368
3368
  throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
3369
3369
  return new Uint8Array(new TextEncoder().encode(e));
3370
3370
  }
3371
- function Wi(e) {
3372
- if (typeof e == "string" && (e = Tc(e)), !Bc(e))
3371
+ function Mi(e) {
3372
+ if (typeof e == "string" && (e = Oc(e)), !Sc(e))
3373
3373
  throw new Error(`expected Uint8Array, got ${typeof e}`);
3374
3374
  return e;
3375
3375
  }
3376
- class Ic {
3376
+ class Tc {
3377
3377
  // Safe version that clones internal state
3378
3378
  clone() {
3379
3379
  return this._cloneInto();
3380
3380
  }
3381
3381
  }
3382
- function Rc(e) {
3383
- const t = (r) => e().update(Wi(r)).digest(), n = e();
3382
+ function Ic(e) {
3383
+ const t = (r) => e().update(Mi(r)).digest(), n = e();
3384
3384
  return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
3385
3385
  }
3386
3386
  const kn = /* @__PURE__ */ BigInt(2 ** 32 - 1), xs = /* @__PURE__ */ BigInt(32);
3387
- function kc(e, t = !1) {
3387
+ function Rc(e, t = !1) {
3388
3388
  return t ? { h: Number(e & kn), l: Number(e >> xs & kn) } : { h: Number(e >> xs & kn) | 0, l: Number(e & kn) | 0 };
3389
3389
  }
3390
- function Nc(e, t = !1) {
3390
+ function kc(e, t = !1) {
3391
3391
  let n = new Uint32Array(e.length), r = new Uint32Array(e.length);
3392
3392
  for (let s = 0; s < e.length; s++) {
3393
- const { h: i, l: o } = kc(e[s], t);
3393
+ const { h: i, l: o } = Rc(e[s], t);
3394
3394
  [n[s], r[s]] = [i, o];
3395
3395
  }
3396
3396
  return [n, r];
3397
3397
  }
3398
- const Cc = (e, t, n) => e << n | t >>> 32 - n, $c = (e, t, n) => t << n | e >>> 32 - n, Lc = (e, t, n) => t << n - 32 | e >>> 64 - n, Ac = (e, t, n) => e << n - 32 | t >>> 64 - n, [Gi, Hi, Vi] = [[], [], []], Pc = /* @__PURE__ */ BigInt(0), an = /* @__PURE__ */ BigInt(1), Fc = /* @__PURE__ */ BigInt(2), Uc = /* @__PURE__ */ BigInt(7), qc = /* @__PURE__ */ BigInt(256), Dc = /* @__PURE__ */ BigInt(113);
3399
- for (let e = 0, t = an, n = 1, r = 0; e < 24; e++) {
3400
- [n, r] = [r, (2 * n + 3 * r) % 5], Gi.push(2 * (5 * r + n)), Hi.push((e + 1) * (e + 2) / 2 % 64);
3401
- let s = Pc;
3398
+ const Nc = (e, t, n) => e << n | t >>> 32 - n, Cc = (e, t, n) => t << n | e >>> 32 - n, $c = (e, t, n) => t << n - 32 | e >>> 64 - n, Lc = (e, t, n) => e << n - 32 | t >>> 64 - n, [Wi, Gi, Hi] = [[], [], []], Ac = /* @__PURE__ */ BigInt(0), on = /* @__PURE__ */ BigInt(1), Pc = /* @__PURE__ */ BigInt(2), Fc = /* @__PURE__ */ BigInt(7), Uc = /* @__PURE__ */ BigInt(256), qc = /* @__PURE__ */ BigInt(113);
3399
+ for (let e = 0, t = on, n = 1, r = 0; e < 24; e++) {
3400
+ [n, r] = [r, (2 * n + 3 * r) % 5], Wi.push(2 * (5 * r + n)), Gi.push((e + 1) * (e + 2) / 2 % 64);
3401
+ let s = Ac;
3402
3402
  for (let i = 0; i < 7; i++)
3403
- t = (t << an ^ (t >> Uc) * Dc) % qc, t & Fc && (s ^= an << (an << /* @__PURE__ */ BigInt(i)) - an);
3404
- Vi.push(s);
3403
+ t = (t << on ^ (t >> Fc) * qc) % Uc, t & Pc && (s ^= on << (on << /* @__PURE__ */ BigInt(i)) - on);
3404
+ Hi.push(s);
3405
3405
  }
3406
- const [Mc, Wc] = /* @__PURE__ */ Nc(Vi, !0), Es = (e, t, n) => n > 32 ? Lc(e, t, n) : Cc(e, t, n), Ss = (e, t, n) => n > 32 ? Ac(e, t, n) : $c(e, t, n);
3407
- function Gc(e, t = 24) {
3406
+ const [Dc, Mc] = /* @__PURE__ */ kc(Hi, !0), Es = (e, t, n) => n > 32 ? $c(e, t, n) : Nc(e, t, n), Ss = (e, t, n) => n > 32 ? Lc(e, t, n) : Cc(e, t, n);
3407
+ function Wc(e, t = 24) {
3408
3408
  const n = new Uint32Array(10);
3409
3409
  for (let r = 24 - t; r < 24; r++) {
3410
3410
  for (let o = 0; o < 10; o++)
@@ -3416,7 +3416,7 @@ function Gc(e, t = 24) {
3416
3416
  }
3417
3417
  let s = e[2], i = e[3];
3418
3418
  for (let o = 0; o < 24; o++) {
3419
- const a = Hi[o], c = Es(s, i, a), u = Ss(s, i, a), l = Gi[o];
3419
+ const a = Gi[o], c = Es(s, i, a), u = Ss(s, i, a), l = Wi[o];
3420
3420
  s = e[l], i = e[l + 1], e[l] = c, e[l + 1] = u;
3421
3421
  }
3422
3422
  for (let o = 0; o < 50; o += 10) {
@@ -3425,24 +3425,24 @@ function Gc(e, t = 24) {
3425
3425
  for (let a = 0; a < 10; a++)
3426
3426
  e[o + a] ^= ~n[(a + 2) % 10] & n[(a + 4) % 10];
3427
3427
  }
3428
- e[0] ^= Mc[r], e[1] ^= Wc[r];
3428
+ e[0] ^= Dc[r], e[1] ^= Mc[r];
3429
3429
  }
3430
3430
  n.fill(0);
3431
3431
  }
3432
- class Mr extends Ic {
3432
+ class Mr extends Tc {
3433
3433
  // NOTE: we accept arguments in bytes instead of bits here.
3434
3434
  constructor(t, n, r, s = !1, i = 24) {
3435
3435
  if (super(), this.blockLen = t, this.suffix = n, this.outputLen = r, this.enableXOF = s, this.rounds = i, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, ms(r), 0 >= this.blockLen || this.blockLen >= 200)
3436
3436
  throw new Error("Sha3 supports only keccak-f1600 function");
3437
- this.state = new Uint8Array(200), this.state32 = vc(this.state);
3437
+ this.state = new Uint8Array(200), this.state32 = Bc(this.state);
3438
3438
  }
3439
3439
  keccak() {
3440
- Gc(this.state32, this.rounds), this.posOut = 0, this.pos = 0;
3440
+ Wc(this.state32, this.rounds), this.posOut = 0, this.pos = 0;
3441
3441
  }
3442
3442
  update(t) {
3443
3443
  _s(this);
3444
3444
  const { blockLen: n, state: r } = this;
3445
- t = Wi(t);
3445
+ t = Mi(t);
3446
3446
  const s = t.length;
3447
3447
  for (let i = 0; i < s; ) {
3448
3448
  const o = Math.min(n - this.pos, s - i);
@@ -3460,7 +3460,7 @@ class Mr extends Ic {
3460
3460
  t[r] ^= n, (n & 128) !== 0 && r === s - 1 && this.keccak(), t[s - 1] ^= 128, this.keccak();
3461
3461
  }
3462
3462
  writeInto(t) {
3463
- _s(this, !1), Mi(t), this.finish();
3463
+ _s(this, !1), Di(t), this.finish();
3464
3464
  const n = this.state, { blockLen: r } = this;
3465
3465
  for (let s = 0, i = t.length; s < i; ) {
3466
3466
  this.posOut >= r && this.keccak();
@@ -3478,7 +3478,7 @@ class Mr extends Ic {
3478
3478
  return ms(t), this.xofInto(new Uint8Array(t));
3479
3479
  }
3480
3480
  digestInto(t) {
3481
- if (Sc(t, this), this.finished)
3481
+ if (Ec(t, this), this.finished)
3482
3482
  throw new Error("digest() was already called");
3483
3483
  return this.writeInto(t), this.destroy(), t;
3484
3484
  }
@@ -3493,27 +3493,27 @@ class Mr extends Ic {
3493
3493
  return t || (t = new Mr(n, r, s, o, i)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = i, t.suffix = r, t.outputLen = s, t.enableXOF = o, t.destroyed = this.destroyed, t;
3494
3494
  }
3495
3495
  }
3496
- const Hc = (e, t, n) => Rc(() => new Mr(t, e, n)), Vc = /* @__PURE__ */ Hc(1, 136, 256 / 8);
3497
- let Zi = !1;
3498
- const Yi = function(e) {
3499
- return Vc(e);
3496
+ const Gc = (e, t, n) => Ic(() => new Mr(t, e, n)), Hc = /* @__PURE__ */ Gc(1, 136, 256 / 8);
3497
+ let Vi = !1;
3498
+ const Zi = function(e) {
3499
+ return Hc(e);
3500
3500
  };
3501
- let Ki = Yi;
3501
+ let Yi = Zi;
3502
3502
  function tt(e) {
3503
3503
  const t = yt(e, "data");
3504
- return bt(Ki(t));
3504
+ return bt(Yi(t));
3505
3505
  }
3506
- tt._ = Yi;
3506
+ tt._ = Zi;
3507
3507
  tt.lock = function() {
3508
- Zi = !0;
3508
+ Vi = !0;
3509
3509
  };
3510
3510
  tt.register = function(e) {
3511
- if (Zi)
3511
+ if (Vi)
3512
3512
  throw new TypeError("keccak256 is locked");
3513
- Ki = e;
3513
+ Yi = e;
3514
3514
  };
3515
3515
  Object.freeze(tt);
3516
- const Zc = BigInt(0), Yc = BigInt(36);
3516
+ const Vc = BigInt(0), Zc = BigInt(36);
3517
3517
  function Bs(e) {
3518
3518
  e = e.toLowerCase();
3519
3519
  const t = e.substring(2).split(""), n = new Uint8Array(40);
@@ -3530,7 +3530,7 @@ for (let e = 0; e < 10; e++)
3530
3530
  for (let e = 0; e < 26; e++)
3531
3531
  Wr[String.fromCharCode(65 + e)] = String(10 + e);
3532
3532
  const vs = 15;
3533
- function Kc(e) {
3533
+ function Yc(e) {
3534
3534
  e = e.toUpperCase(), e = e.substring(4) + e.substring(0, 2) + "00";
3535
3535
  let t = e.split("").map((r) => Wr[r]).join("");
3536
3536
  for (; t.length >= vs; ) {
@@ -3542,7 +3542,7 @@ function Kc(e) {
3542
3542
  n = "0" + n;
3543
3543
  return n;
3544
3544
  }
3545
- const Xc = (function() {
3545
+ const Kc = (function() {
3546
3546
  const e = {};
3547
3547
  for (let t = 0; t < 36; t++) {
3548
3548
  const n = "0123456789abcdefghijklmnopqrstuvwxyz"[t];
@@ -3550,22 +3550,22 @@ const Xc = (function() {
3550
3550
  }
3551
3551
  return e;
3552
3552
  })();
3553
- function zc(e) {
3553
+ function Xc(e) {
3554
3554
  e = e.toLowerCase();
3555
- let t = Zc;
3555
+ let t = Vc;
3556
3556
  for (let n = 0; n < e.length; n++)
3557
- t = t * Yc + Xc[e[n]];
3557
+ t = t * Zc + Kc[e[n]];
3558
3558
  return t;
3559
3559
  }
3560
- function dn(e) {
3560
+ function fn(e) {
3561
3561
  if (m(typeof e == "string", "invalid address", "address", e), e.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
3562
3562
  e.startsWith("0x") || (e = "0x" + e);
3563
3563
  const t = Bs(e);
3564
3564
  return m(!e.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || t === e, "bad address checksum", "address", e), t;
3565
3565
  }
3566
3566
  if (e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
3567
- m(e.substring(2, 4) === Kc(e), "bad icap checksum", "address", e);
3568
- let t = zc(e.substring(4)).toString(16);
3567
+ m(e.substring(2, 4) === Yc(e), "bad icap checksum", "address", e);
3568
+ let t = Xc(e.substring(4)).toString(16);
3569
3569
  for (; t.length < 40; )
3570
3570
  t = "0" + t;
3571
3571
  return Bs("0x" + t);
@@ -3577,7 +3577,7 @@ function E(e, t) {
3577
3577
  let n = !1;
3578
3578
  return t < 0 && (n = !0, t *= -1), new pt(se, `${n ? "" : "u"}int${t}`, e, { signed: n, width: t });
3579
3579
  }
3580
- function K(e, t) {
3580
+ function X(e, t) {
3581
3581
  return new pt(se, `bytes${t || ""}`, e, { size: t });
3582
3582
  }
3583
3583
  const Os = /* @__PURE__ */ Symbol.for("_ethers_typed");
@@ -4075,193 +4075,193 @@ class pt {
4075
4075
  * Return a new ``bytes1`` type for %%v%%.
4076
4076
  */
4077
4077
  static bytes1(t) {
4078
- return K(t, 1);
4078
+ return X(t, 1);
4079
4079
  }
4080
4080
  /**
4081
4081
  * Return a new ``bytes2`` type for %%v%%.
4082
4082
  */
4083
4083
  static bytes2(t) {
4084
- return K(t, 2);
4084
+ return X(t, 2);
4085
4085
  }
4086
4086
  /**
4087
4087
  * Return a new ``bytes3`` type for %%v%%.
4088
4088
  */
4089
4089
  static bytes3(t) {
4090
- return K(t, 3);
4090
+ return X(t, 3);
4091
4091
  }
4092
4092
  /**
4093
4093
  * Return a new ``bytes4`` type for %%v%%.
4094
4094
  */
4095
4095
  static bytes4(t) {
4096
- return K(t, 4);
4096
+ return X(t, 4);
4097
4097
  }
4098
4098
  /**
4099
4099
  * Return a new ``bytes5`` type for %%v%%.
4100
4100
  */
4101
4101
  static bytes5(t) {
4102
- return K(t, 5);
4102
+ return X(t, 5);
4103
4103
  }
4104
4104
  /**
4105
4105
  * Return a new ``bytes6`` type for %%v%%.
4106
4106
  */
4107
4107
  static bytes6(t) {
4108
- return K(t, 6);
4108
+ return X(t, 6);
4109
4109
  }
4110
4110
  /**
4111
4111
  * Return a new ``bytes7`` type for %%v%%.
4112
4112
  */
4113
4113
  static bytes7(t) {
4114
- return K(t, 7);
4114
+ return X(t, 7);
4115
4115
  }
4116
4116
  /**
4117
4117
  * Return a new ``bytes8`` type for %%v%%.
4118
4118
  */
4119
4119
  static bytes8(t) {
4120
- return K(t, 8);
4120
+ return X(t, 8);
4121
4121
  }
4122
4122
  /**
4123
4123
  * Return a new ``bytes9`` type for %%v%%.
4124
4124
  */
4125
4125
  static bytes9(t) {
4126
- return K(t, 9);
4126
+ return X(t, 9);
4127
4127
  }
4128
4128
  /**
4129
4129
  * Return a new ``bytes10`` type for %%v%%.
4130
4130
  */
4131
4131
  static bytes10(t) {
4132
- return K(t, 10);
4132
+ return X(t, 10);
4133
4133
  }
4134
4134
  /**
4135
4135
  * Return a new ``bytes11`` type for %%v%%.
4136
4136
  */
4137
4137
  static bytes11(t) {
4138
- return K(t, 11);
4138
+ return X(t, 11);
4139
4139
  }
4140
4140
  /**
4141
4141
  * Return a new ``bytes12`` type for %%v%%.
4142
4142
  */
4143
4143
  static bytes12(t) {
4144
- return K(t, 12);
4144
+ return X(t, 12);
4145
4145
  }
4146
4146
  /**
4147
4147
  * Return a new ``bytes13`` type for %%v%%.
4148
4148
  */
4149
4149
  static bytes13(t) {
4150
- return K(t, 13);
4150
+ return X(t, 13);
4151
4151
  }
4152
4152
  /**
4153
4153
  * Return a new ``bytes14`` type for %%v%%.
4154
4154
  */
4155
4155
  static bytes14(t) {
4156
- return K(t, 14);
4156
+ return X(t, 14);
4157
4157
  }
4158
4158
  /**
4159
4159
  * Return a new ``bytes15`` type for %%v%%.
4160
4160
  */
4161
4161
  static bytes15(t) {
4162
- return K(t, 15);
4162
+ return X(t, 15);
4163
4163
  }
4164
4164
  /**
4165
4165
  * Return a new ``bytes16`` type for %%v%%.
4166
4166
  */
4167
4167
  static bytes16(t) {
4168
- return K(t, 16);
4168
+ return X(t, 16);
4169
4169
  }
4170
4170
  /**
4171
4171
  * Return a new ``bytes17`` type for %%v%%.
4172
4172
  */
4173
4173
  static bytes17(t) {
4174
- return K(t, 17);
4174
+ return X(t, 17);
4175
4175
  }
4176
4176
  /**
4177
4177
  * Return a new ``bytes18`` type for %%v%%.
4178
4178
  */
4179
4179
  static bytes18(t) {
4180
- return K(t, 18);
4180
+ return X(t, 18);
4181
4181
  }
4182
4182
  /**
4183
4183
  * Return a new ``bytes19`` type for %%v%%.
4184
4184
  */
4185
4185
  static bytes19(t) {
4186
- return K(t, 19);
4186
+ return X(t, 19);
4187
4187
  }
4188
4188
  /**
4189
4189
  * Return a new ``bytes20`` type for %%v%%.
4190
4190
  */
4191
4191
  static bytes20(t) {
4192
- return K(t, 20);
4192
+ return X(t, 20);
4193
4193
  }
4194
4194
  /**
4195
4195
  * Return a new ``bytes21`` type for %%v%%.
4196
4196
  */
4197
4197
  static bytes21(t) {
4198
- return K(t, 21);
4198
+ return X(t, 21);
4199
4199
  }
4200
4200
  /**
4201
4201
  * Return a new ``bytes22`` type for %%v%%.
4202
4202
  */
4203
4203
  static bytes22(t) {
4204
- return K(t, 22);
4204
+ return X(t, 22);
4205
4205
  }
4206
4206
  /**
4207
4207
  * Return a new ``bytes23`` type for %%v%%.
4208
4208
  */
4209
4209
  static bytes23(t) {
4210
- return K(t, 23);
4210
+ return X(t, 23);
4211
4211
  }
4212
4212
  /**
4213
4213
  * Return a new ``bytes24`` type for %%v%%.
4214
4214
  */
4215
4215
  static bytes24(t) {
4216
- return K(t, 24);
4216
+ return X(t, 24);
4217
4217
  }
4218
4218
  /**
4219
4219
  * Return a new ``bytes25`` type for %%v%%.
4220
4220
  */
4221
4221
  static bytes25(t) {
4222
- return K(t, 25);
4222
+ return X(t, 25);
4223
4223
  }
4224
4224
  /**
4225
4225
  * Return a new ``bytes26`` type for %%v%%.
4226
4226
  */
4227
4227
  static bytes26(t) {
4228
- return K(t, 26);
4228
+ return X(t, 26);
4229
4229
  }
4230
4230
  /**
4231
4231
  * Return a new ``bytes27`` type for %%v%%.
4232
4232
  */
4233
4233
  static bytes27(t) {
4234
- return K(t, 27);
4234
+ return X(t, 27);
4235
4235
  }
4236
4236
  /**
4237
4237
  * Return a new ``bytes28`` type for %%v%%.
4238
4238
  */
4239
4239
  static bytes28(t) {
4240
- return K(t, 28);
4240
+ return X(t, 28);
4241
4241
  }
4242
4242
  /**
4243
4243
  * Return a new ``bytes29`` type for %%v%%.
4244
4244
  */
4245
4245
  static bytes29(t) {
4246
- return K(t, 29);
4246
+ return X(t, 29);
4247
4247
  }
4248
4248
  /**
4249
4249
  * Return a new ``bytes30`` type for %%v%%.
4250
4250
  */
4251
4251
  static bytes30(t) {
4252
- return K(t, 30);
4252
+ return X(t, 30);
4253
4253
  }
4254
4254
  /**
4255
4255
  * Return a new ``bytes31`` type for %%v%%.
4256
4256
  */
4257
4257
  static bytes31(t) {
4258
- return K(t, 31);
4258
+ return X(t, 31);
4259
4259
  }
4260
4260
  /**
4261
4261
  * Return a new ``bytes32`` type for %%v%%.
4262
4262
  */
4263
4263
  static bytes32(t) {
4264
- return K(t, 32);
4264
+ return X(t, 32);
4265
4265
  }
4266
4266
  /**
4267
4267
  * Return a new ``address`` type for %%v%%.
@@ -4327,7 +4327,7 @@ class pt {
4327
4327
  return t;
4328
4328
  }
4329
4329
  }
4330
- class Jc extends de {
4330
+ class zc extends de {
4331
4331
  constructor(t) {
4332
4332
  super("address", "address", t, !1);
4333
4333
  }
@@ -4337,17 +4337,17 @@ class Jc extends de {
4337
4337
  encode(t, n) {
4338
4338
  let r = pt.dereference(n, "string");
4339
4339
  try {
4340
- r = dn(r);
4340
+ r = fn(r);
4341
4341
  } catch (s) {
4342
4342
  return this._throwError(s.message, n);
4343
4343
  }
4344
4344
  return t.writeValue(r);
4345
4345
  }
4346
4346
  decode(t) {
4347
- return dn(Fi(t.readValue(), 20));
4347
+ return fn(Pi(t.readValue(), 20));
4348
4348
  }
4349
4349
  }
4350
- class jc extends de {
4350
+ class Jc extends de {
4351
4351
  coder;
4352
4352
  constructor(t) {
4353
4353
  super(t.name, t.type, "_", t.dynamic), this.coder = t;
@@ -4362,7 +4362,7 @@ class jc extends de {
4362
4362
  return this.coder.decode(t);
4363
4363
  }
4364
4364
  }
4365
- function Xi(e, t, n) {
4365
+ function Ki(e, t, n) {
4366
4366
  let r = [];
4367
4367
  if (Array.isArray(n))
4368
4368
  r = n;
@@ -4393,7 +4393,7 @@ function Xi(e, t, n) {
4393
4393
  let a = e.appendWriter(s);
4394
4394
  return a += e.appendWriter(i), a;
4395
4395
  }
4396
- function zi(e, t) {
4396
+ function Xi(e, t) {
4397
4397
  let n = [], r = [], s = e.subReader(0);
4398
4398
  return t.forEach((i) => {
4399
4399
  let o = null;
@@ -4419,7 +4419,7 @@ function zi(e, t) {
4419
4419
  n.push(o), r.push(i.localName || null);
4420
4420
  }), oe.fromItems(n, r);
4421
4421
  }
4422
- class Qc extends de {
4422
+ class jc extends de {
4423
4423
  coder;
4424
4424
  length;
4425
4425
  constructor(t, n, r) {
@@ -4436,22 +4436,22 @@ class Qc extends de {
4436
4436
  const r = pt.dereference(n, "array");
4437
4437
  Array.isArray(r) || this._throwError("expected array value", r);
4438
4438
  let s = this.length;
4439
- s === -1 && (s = r.length, t.writeValue(r.length)), Ni(r.length, s, "coder array" + (this.localName ? " " + this.localName : ""));
4439
+ s === -1 && (s = r.length, t.writeValue(r.length)), ki(r.length, s, "coder array" + (this.localName ? " " + this.localName : ""));
4440
4440
  let i = [];
4441
4441
  for (let o = 0; o < r.length; o++)
4442
4442
  i.push(this.coder);
4443
- return Xi(t, i, r);
4443
+ return Ki(t, i, r);
4444
4444
  }
4445
4445
  decode(t) {
4446
4446
  let n = this.length;
4447
4447
  n === -1 && (n = t.readIndex(), at(n * vt <= t.dataLength, "insufficient data length", "BUFFER_OVERRUN", { buffer: t.bytes, offset: n * vt, length: t.dataLength }));
4448
4448
  let r = [];
4449
4449
  for (let s = 0; s < n; s++)
4450
- r.push(new jc(this.coder));
4451
- return zi(t, r);
4450
+ r.push(new Jc(this.coder));
4451
+ return Xi(t, r);
4452
4452
  }
4453
4453
  }
4454
- class tu extends de {
4454
+ class Qc extends de {
4455
4455
  constructor(t) {
4456
4456
  super("bool", "bool", t, !1);
4457
4457
  }
@@ -4466,7 +4466,7 @@ class tu extends de {
4466
4466
  return !!t.readValue();
4467
4467
  }
4468
4468
  }
4469
- class Ji extends de {
4469
+ class zi extends de {
4470
4470
  constructor(t, n) {
4471
4471
  super(t, t, n, !0);
4472
4472
  }
@@ -4482,7 +4482,7 @@ class Ji extends de {
4482
4482
  return t.readBytes(t.readIndex(), !0);
4483
4483
  }
4484
4484
  }
4485
- class eu extends Ji {
4485
+ class tu extends zi {
4486
4486
  constructor(t) {
4487
4487
  super("bytes", t);
4488
4488
  }
@@ -4490,7 +4490,7 @@ class eu extends Ji {
4490
4490
  return bt(super.decode(t));
4491
4491
  }
4492
4492
  }
4493
- class nu extends de {
4493
+ class eu extends de {
4494
4494
  size;
4495
4495
  constructor(t, n) {
4496
4496
  let r = "bytes" + String(t);
@@ -4507,8 +4507,8 @@ class nu extends de {
4507
4507
  return bt(t.readBytes(this.size));
4508
4508
  }
4509
4509
  }
4510
- const ru = new Uint8Array([]);
4511
- class su extends de {
4510
+ const nu = new Uint8Array([]);
4511
+ class ru extends de {
4512
4512
  constructor(t) {
4513
4513
  super("null", "", t, !1);
4514
4514
  }
@@ -4516,14 +4516,14 @@ class su extends de {
4516
4516
  return null;
4517
4517
  }
4518
4518
  encode(t, n) {
4519
- return n != null && this._throwError("not null", n), t.writeBytes(ru);
4519
+ return n != null && this._throwError("not null", n), t.writeBytes(nu);
4520
4520
  }
4521
4521
  decode(t) {
4522
4522
  return t.readBytes(0), null;
4523
4523
  }
4524
4524
  }
4525
- const iu = BigInt(0), ou = BigInt(1), au = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
4526
- class cu extends de {
4525
+ const su = BigInt(0), iu = BigInt(1), ou = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
4526
+ class au extends de {
4527
4527
  size;
4528
4528
  signed;
4529
4529
  constructor(t, n, r) {
@@ -4534,19 +4534,19 @@ class cu extends de {
4534
4534
  return 0;
4535
4535
  }
4536
4536
  encode(t, n) {
4537
- let r = nn(pt.dereference(n, this.type)), s = In(au, vt * 8);
4537
+ let r = en(pt.dereference(n, this.type)), s = In(ou, vt * 8);
4538
4538
  if (this.signed) {
4539
4539
  let i = In(s, this.size * 8 - 1);
4540
- (r > i || r < -(i + ou)) && this._throwError("value out-of-bounds", n), r = Ai(r, 8 * vt);
4541
- } else (r < iu || r > In(s, this.size * 8)) && this._throwError("value out-of-bounds", n);
4540
+ (r > i || r < -(i + iu)) && this._throwError("value out-of-bounds", n), r = Li(r, 8 * vt);
4541
+ } else (r < su || r > In(s, this.size * 8)) && this._throwError("value out-of-bounds", n);
4542
4542
  return t.writeValue(r);
4543
4543
  }
4544
4544
  decode(t) {
4545
4545
  let n = In(t.readValue(), this.size * 8);
4546
- return this.signed && (n = hc(n, this.size * 8)), n;
4546
+ return this.signed && (n = pc(n, this.size * 8)), n;
4547
4547
  }
4548
4548
  }
4549
- class uu extends Ji {
4549
+ class cu extends zi {
4550
4550
  constructor(t) {
4551
4551
  super("string", t);
4552
4552
  }
@@ -4557,7 +4557,7 @@ class uu extends Ji {
4557
4557
  return super.encode(t, qr(pt.dereference(n, "string")));
4558
4558
  }
4559
4559
  decode(t) {
4560
- return xc(super.decode(t));
4560
+ return _c(super.decode(t));
4561
4561
  }
4562
4562
  }
4563
4563
  class Nn extends de {
@@ -4587,20 +4587,20 @@ class Nn extends de {
4587
4587
  }
4588
4588
  encode(t, n) {
4589
4589
  const r = pt.dereference(n, "tuple");
4590
- return Xi(t, this.coders, r);
4590
+ return Ki(t, this.coders, r);
4591
4591
  }
4592
4592
  decode(t) {
4593
- return zi(t, this.coders);
4593
+ return Xi(t, this.coders);
4594
4594
  }
4595
4595
  }
4596
- function pn(e) {
4596
+ function dn(e) {
4597
4597
  return tt(qr(e));
4598
4598
  }
4599
- const lu = new RegExp("^bytes([0-9]+)$"), fu = new RegExp("^(u?int)([0-9]*)$"), du = new RegExp("^(.*)\\[([0-9]*)\\]$");
4600
- function ji(e, t, n) {
4599
+ const uu = new RegExp("^bytes([0-9]+)$"), lu = new RegExp("^(u?int)([0-9]*)$"), fu = new RegExp("^(.*)\\[([0-9]*)\\]$");
4600
+ function Ji(e, t, n) {
4601
4601
  switch (e) {
4602
4602
  case "address":
4603
- return yt(n ? An(t, 32) : dn(t));
4603
+ return yt(n ? An(t, 32) : fn(t));
4604
4604
  case "string":
4605
4605
  return qr(t);
4606
4606
  case "bytes":
@@ -4608,21 +4608,21 @@ function ji(e, t, n) {
4608
4608
  case "bool":
4609
4609
  return t = t ? "0x01" : "0x00", yt(n ? An(t, 32) : t);
4610
4610
  }
4611
- let r = e.match(fu);
4611
+ let r = e.match(lu);
4612
4612
  if (r) {
4613
4613
  let s = r[1] === "int", i = parseInt(r[2] || "256");
4614
- return m((!r[2] || r[2] === String(i)) && i % 8 === 0 && i !== 0 && i <= 256, "invalid number type", "type", e), n && (i = 256), s && (t = Ai(t, i)), yt(An(Ui(t), i / 8));
4614
+ return m((!r[2] || r[2] === String(i)) && i % 8 === 0 && i !== 0 && i <= 256, "invalid number type", "type", e), n && (i = 256), s && (t = Li(t, i)), yt(An(Fi(t), i / 8));
4615
4615
  }
4616
- if (r = e.match(lu), r) {
4616
+ if (r = e.match(uu), r) {
4617
4617
  const s = parseInt(r[1]);
4618
- return m(String(s) === r[1] && s !== 0 && s <= 32, "invalid bytes type", "type", e), m(pc(t) === s, `invalid value for ${e}`, "value", t), n ? yt(Li(t, 32)) : t;
4618
+ return m(String(s) === r[1] && s !== 0 && s <= 32, "invalid bytes type", "type", e), m(dc(t) === s, `invalid value for ${e}`, "value", t), n ? yt($i(t, 32)) : t;
4619
4619
  }
4620
- if (r = e.match(du), r && Array.isArray(t)) {
4620
+ if (r = e.match(fu), r && Array.isArray(t)) {
4621
4621
  const s = r[1], i = parseInt(r[2] || String(t.length));
4622
4622
  m(i === t.length, `invalid array length for ${e}`, "value", t);
4623
4623
  const o = [];
4624
4624
  return t.forEach(function(a) {
4625
- o.push(ji(s, a, !0));
4625
+ o.push(Ji(s, a, !0));
4626
4626
  }), yt(xe(o));
4627
4627
  }
4628
4628
  m(!1, "invalid type", "type", e);
@@ -4631,21 +4631,21 @@ function Ts(e, t) {
4631
4631
  m(e.length === t.length, "wrong number of values; expected ${ types.length }", "values", t);
4632
4632
  const n = [];
4633
4633
  return e.forEach(function(r, s) {
4634
- n.push(ji(r, t[s]));
4634
+ n.push(Ji(r, t[s]));
4635
4635
  }), bt(xe(n));
4636
4636
  }
4637
4637
  function Ot(e) {
4638
4638
  const t = /* @__PURE__ */ new Set();
4639
4639
  return e.forEach((n) => t.add(n)), Object.freeze(t);
4640
4640
  }
4641
- const pu = "external public payable override", hu = Ot(pu.split(" ")), Qi = "constant external internal payable private public pure view override", wu = Ot(Qi.split(" ")), to = "constructor error event fallback function receive struct", eo = Ot(to.split(" ")), no = "calldata memory storage payable indexed", gu = Ot(no.split(" ")), yu = "tuple returns", bu = [to, no, yu, Qi].join(" "), mu = Ot(bu.split(" ")), _u = {
4641
+ const du = "external public payable override", pu = Ot(du.split(" ")), ji = "constant external internal payable private public pure view override", hu = Ot(ji.split(" ")), Qi = "constructor error event fallback function receive struct", to = Ot(Qi.split(" ")), eo = "calldata memory storage payable indexed", wu = Ot(eo.split(" ")), gu = "tuple returns", yu = [Qi, eo, gu, ji].join(" "), bu = Ot(yu.split(" ")), mu = {
4642
4642
  "(": "OPEN_PAREN",
4643
4643
  ")": "CLOSE_PAREN",
4644
4644
  "[": "OPEN_BRACKET",
4645
4645
  "]": "CLOSE_BRACKET",
4646
4646
  ",": "COMMA",
4647
4647
  "@": "AT"
4648
- }, xu = new RegExp("^(\\s*)"), Eu = new RegExp("^([0-9]+)"), Su = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"), ro = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"), so = new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");
4648
+ }, _u = new RegExp("^(\\s*)"), xu = new RegExp("^([0-9]+)"), Eu = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"), no = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"), ro = new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");
4649
4649
  class Dt {
4650
4650
  #t;
4651
4651
  #e;
@@ -4745,11 +4745,11 @@ function Se(e) {
4745
4745
  };
4746
4746
  let r = [], s = [], i = 0;
4747
4747
  for (; i < e.length; ) {
4748
- let o = e.substring(i), a = o.match(xu);
4748
+ let o = e.substring(i), a = o.match(_u);
4749
4749
  a && (i += a[1].length, o = e.substring(i));
4750
4750
  const c = { depth: r.length, linkBack: -1, linkNext: -1, match: -1, type: "", text: "", offset: i, value: -1 };
4751
4751
  t.push(c);
4752
- let u = _u[o[0]] || "";
4752
+ let u = mu[o[0]] || "";
4753
4753
  if (u) {
4754
4754
  if (c.type = u, c.text = o[0], i++, u === "OPEN_PAREN")
4755
4755
  r.push(t.length - 1), s.push(t.length - 1);
@@ -4771,19 +4771,19 @@ function Se(e) {
4771
4771
  }
4772
4772
  continue;
4773
4773
  }
4774
- if (a = o.match(Su), a) {
4775
- if (c.text = a[1], i += c.text.length, mu.has(c.text)) {
4774
+ if (a = o.match(Eu), a) {
4775
+ if (c.text = a[1], i += c.text.length, bu.has(c.text)) {
4776
4776
  c.type = "KEYWORD";
4777
4777
  continue;
4778
4778
  }
4779
- if (c.text.match(so)) {
4779
+ if (c.text.match(ro)) {
4780
4780
  c.type = "TYPE";
4781
4781
  continue;
4782
4782
  }
4783
4783
  c.type = "ID";
4784
4784
  continue;
4785
4785
  }
4786
- if (a = o.match(Eu), a) {
4786
+ if (a = o.match(xu), a) {
4787
4787
  c.text = a[1], c.type = "NUMBER", i += c.text.length;
4788
4788
  continue;
4789
4789
  }
@@ -4799,7 +4799,7 @@ function Is(e, t) {
4799
4799
  throw new Error(`conflicting types: ${n.join(", ")}`);
4800
4800
  }
4801
4801
  function Qn(e, t) {
4802
- if (t.peekKeyword(eo)) {
4802
+ if (t.peekKeyword(to)) {
4803
4803
  const n = t.pop().text;
4804
4804
  if (n !== e)
4805
4805
  throw new Error(`expected ${e}, got ${n}`);
@@ -4818,17 +4818,17 @@ function le(e, t) {
4818
4818
  }
4819
4819
  return Object.freeze(n);
4820
4820
  }
4821
- function io(e) {
4822
- let t = le(e, wu);
4821
+ function so(e) {
4822
+ let t = le(e, hu);
4823
4823
  return Is(t, Ot("constant payable nonpayable".split(" "))), Is(t, Ot("pure view payable nonpayable".split(" "))), t.has("view") ? "view" : t.has("pure") ? "pure" : t.has("payable") ? "payable" : t.has("nonpayable") ? "nonpayable" : t.has("constant") ? "view" : "nonpayable";
4824
4824
  }
4825
4825
  function ue(e, t) {
4826
4826
  return e.popParams().map((n) => nt.from(n, t));
4827
4827
  }
4828
- function oo(e) {
4828
+ function io(e) {
4829
4829
  if (e.peekType("AT")) {
4830
4830
  if (e.pop(), e.peekType("NUMBER"))
4831
- return nn(e.pop().text);
4831
+ return en(e.pop().text);
4832
4832
  throw new Error("invalid gas");
4833
4833
  }
4834
4834
  return null;
@@ -4837,9 +4837,9 @@ function Le(e) {
4837
4837
  if (e.length)
4838
4838
  throw new Error(`unexpected tokens at offset ${e.offset}: ${e.toString()}`);
4839
4839
  }
4840
- const Bu = new RegExp(/^(.*)\[([0-9]*)\]$/);
4840
+ const Su = new RegExp(/^(.*)\[([0-9]*)\]$/);
4841
4841
  function Rs(e) {
4842
- const t = e.match(so);
4842
+ const t = e.match(ro);
4843
4843
  if (m(t, "invalid type", "type", e), e === "uint")
4844
4844
  return "uint256";
4845
4845
  if (e === "int")
@@ -5074,7 +5074,7 @@ class nt {
5074
5074
  l = new nt(ot, "", a, c, null, u, f, l), f = h.value, a += h.text, c = "array", u = null;
5075
5075
  }
5076
5076
  let d = null;
5077
- if (le(t, gu).has("indexed")) {
5077
+ if (le(t, wu).has("indexed")) {
5078
5078
  if (!n)
5079
5079
  throw new Error("");
5080
5080
  d = !0;
@@ -5085,10 +5085,10 @@ class nt {
5085
5085
  return new nt(ot, w, a, c, d, u, f, l);
5086
5086
  }
5087
5087
  const r = t.name;
5088
- m(!r || typeof r == "string" && r.match(ro), "invalid name", "obj.name", r);
5088
+ m(!r || typeof r == "string" && r.match(no), "invalid name", "obj.name", r);
5089
5089
  let s = t.indexed;
5090
5090
  s != null && (m(n, "parameter cannot be indexed", "obj.indexed", t.indexed), s = !!s);
5091
- let i = t.type, o = i.match(Bu);
5091
+ let i = t.type, o = i.match(Su);
5092
5092
  if (o) {
5093
5093
  const a = parseInt(o[2] || "-1"), c = nt.from({
5094
5094
  type: o[1],
@@ -5143,7 +5143,7 @@ class Ae {
5143
5143
  return Ae.from(Se(t));
5144
5144
  }
5145
5145
  if (t instanceof Dt)
5146
- switch (t.peekKeyword(eo)) {
5146
+ switch (t.peekKeyword(to)) {
5147
5147
  case "constructor":
5148
5148
  return ae.from(t);
5149
5149
  case "error":
@@ -5220,10 +5220,10 @@ class tr extends Ae {
5220
5220
  * @private
5221
5221
  */
5222
5222
  constructor(t, n, r, s) {
5223
- super(t, n, s), m(typeof r == "string" && r.match(ro), "invalid identifier", "name", r), s = Object.freeze(s.slice()), st(this, { name: r });
5223
+ super(t, n, s), m(typeof r == "string" && r.match(no), "invalid identifier", "name", r), s = Object.freeze(s.slice()), st(this, { name: r });
5224
5224
  }
5225
5225
  }
5226
- function hn(e, t) {
5226
+ function pn(e, t) {
5227
5227
  return "(" + t.map((n) => n.format(e)).join(e === "full" ? ", " : ",") + ")";
5228
5228
  }
5229
5229
  class Rt extends tr {
@@ -5237,7 +5237,7 @@ class Rt extends tr {
5237
5237
  * The Custom Error selector.
5238
5238
  */
5239
5239
  get selector() {
5240
- return pn(this.format("sighash")).substring(0, 10);
5240
+ return dn(this.format("sighash")).substring(0, 10);
5241
5241
  }
5242
5242
  /**
5243
5243
  * Returns a string representation of this fragment as %%format%%.
@@ -5250,7 +5250,7 @@ class Rt extends tr {
5250
5250
  inputs: this.inputs.map((r) => JSON.parse(r.format(t)))
5251
5251
  });
5252
5252
  const n = [];
5253
- return t !== "sighash" && n.push("error"), n.push(this.name + hn(t, this.inputs)), n.join(" ");
5253
+ return t !== "sighash" && n.push("error"), n.push(this.name + pn(t, this.inputs)), n.join(" ");
5254
5254
  }
5255
5255
  /**
5256
5256
  * Returns a new **ErrorFragment** for %%obj%%.
@@ -5289,7 +5289,7 @@ class Vt extends tr {
5289
5289
  * The Event topic hash.
5290
5290
  */
5291
5291
  get topicHash() {
5292
- return pn(this.format("sighash"));
5292
+ return dn(this.format("sighash"));
5293
5293
  }
5294
5294
  /**
5295
5295
  * Returns a string representation of this event as %%format%%.
@@ -5303,7 +5303,7 @@ class Vt extends tr {
5303
5303
  inputs: this.inputs.map((r) => JSON.parse(r.format(t)))
5304
5304
  });
5305
5305
  const n = [];
5306
- return t !== "sighash" && n.push("event"), n.push(this.name + hn(t, this.inputs)), t !== "sighash" && this.anonymous && n.push("anonymous"), n.join(" ");
5306
+ return t !== "sighash" && n.push("event"), n.push(this.name + pn(t, this.inputs)), t !== "sighash" && this.anonymous && n.push("anonymous"), n.join(" ");
5307
5307
  }
5308
5308
  /**
5309
5309
  * Return the topic hash for an event with %%name%% and %%params%%.
@@ -5364,7 +5364,7 @@ class ae extends Ae {
5364
5364
  gas: this.gas != null ? this.gas : void 0,
5365
5365
  inputs: this.inputs.map((r) => JSON.parse(r.format(t)))
5366
5366
  });
5367
- const n = [`constructor${hn(t, this.inputs)}`];
5367
+ const n = [`constructor${pn(t, this.inputs)}`];
5368
5368
  return this.payable && n.push("payable"), this.gas != null && n.push(`@${this.gas.toString()}`), n.join(" ");
5369
5369
  }
5370
5370
  /**
@@ -5381,7 +5381,7 @@ class ae extends Ae {
5381
5381
  }
5382
5382
  else if (t instanceof Dt) {
5383
5383
  le(t, Ot(["constructor"]));
5384
- const n = ue(t), r = !!le(t, hu).has("payable"), s = oo(t);
5384
+ const n = ue(t), r = !!le(t, pu).has("payable"), s = io(t);
5385
5385
  return Le(t), new ae(ot, "constructor", n, r, s);
5386
5386
  }
5387
5387
  return new ae(ot, "constructor", t.inputs ? t.inputs.map(nt.from) : [], !!t.payable, t.gas != null ? t.gas : null);
@@ -5433,7 +5433,7 @@ class ie extends Ae {
5433
5433
  }
5434
5434
  let i = ue(t);
5435
5435
  i.length ? m(i.length === 1 && i[0].type === "bytes", "invalid fallback inputs", "obj.inputs", i.map((a) => a.format("minimal")).join(", ")) : i = [nt.from("bytes")];
5436
- const o = io(t);
5436
+ const o = so(t);
5437
5437
  if (m(o === "nonpayable" || o === "payable", "fallback cannot be constants", "obj.stateMutability", o), le(t, Ot(["returns"])).has("returns")) {
5438
5438
  const a = ue(t);
5439
5439
  m(a.length === 1 && a[0].type === "bytes", "invalid fallback outputs", "obj.outputs", a.map((c) => c.format("minimal")).join(", "));
@@ -5488,7 +5488,7 @@ class Zt extends tr {
5488
5488
  * The Function selector.
5489
5489
  */
5490
5490
  get selector() {
5491
- return pn(this.format("sighash")).substring(0, 10);
5491
+ return dn(this.format("sighash")).substring(0, 10);
5492
5492
  }
5493
5493
  /**
5494
5494
  * Returns a string representation of this function as %%format%%.
@@ -5506,7 +5506,7 @@ class Zt extends tr {
5506
5506
  outputs: this.outputs.map((r) => JSON.parse(r.format(t)))
5507
5507
  });
5508
5508
  const n = [];
5509
- return t !== "sighash" && n.push("function"), n.push(this.name + hn(t, this.inputs)), t !== "sighash" && (this.stateMutability !== "nonpayable" && n.push(this.stateMutability), this.outputs && this.outputs.length && (n.push("returns"), n.push(hn(t, this.outputs))), this.gas != null && n.push(`@${this.gas.toString()}`)), n.join(" ");
5509
+ return t !== "sighash" && n.push("function"), n.push(this.name + pn(t, this.inputs)), t !== "sighash" && (this.stateMutability !== "nonpayable" && n.push(this.stateMutability), this.outputs && this.outputs.length && (n.push("returns"), n.push(pn(t, this.outputs))), this.gas != null && n.push(`@${this.gas.toString()}`)), n.join(" ");
5510
5510
  }
5511
5511
  /**
5512
5512
  * Return the selector for a function with %%name%% and %%params%%.
@@ -5527,10 +5527,10 @@ class Zt extends tr {
5527
5527
  m(!1, "invalid function fragment", "obj", t);
5528
5528
  }
5529
5529
  else if (t instanceof Dt) {
5530
- const r = Qn("function", t), s = ue(t), i = io(t);
5530
+ const r = Qn("function", t), s = ue(t), i = so(t);
5531
5531
  let o = [];
5532
5532
  le(t, Ot(["returns"])).has("returns") && (o = ue(t));
5533
- const a = oo(t);
5533
+ const a = io(t);
5534
5534
  return Le(t), new Zt(ot, r, i, s, o, a);
5535
5535
  }
5536
5536
  let n = t.stateMutability;
@@ -5593,9 +5593,9 @@ Gt.set(49, "STACK_UNDERFLOW");
5593
5593
  Gt.set(50, "ARRAY_RANGE_ERROR");
5594
5594
  Gt.set(65, "OUT_OF_MEMORY");
5595
5595
  Gt.set(81, "UNINITIALIZED_FUNCTION_CALL");
5596
- const vu = new RegExp(/^bytes([0-9]*)$/), Ou = new RegExp(/^(u?int)([0-9]*)$/);
5596
+ const Bu = new RegExp(/^bytes([0-9]*)$/), vu = new RegExp(/^(u?int)([0-9]*)$/);
5597
5597
  let _r = null, Fs = 1024;
5598
- function Tu(e, t, n, r) {
5598
+ function Ou(e, t, n, r) {
5599
5599
  let s = "missing revert data", i = null;
5600
5600
  const o = null;
5601
5601
  let a = null;
@@ -5631,10 +5631,10 @@ function Tu(e, t, n, r) {
5631
5631
  s += " (unknown custom error)";
5632
5632
  }
5633
5633
  const c = {
5634
- to: t.to ? dn(t.to) : null,
5634
+ to: t.to ? fn(t.to) : null,
5635
5635
  data: t.data || "0x"
5636
5636
  };
5637
- return t.from && (c.from = dn(t.from)), ki(s, "CALL_EXCEPTION", {
5637
+ return t.from && (c.from = fn(t.from)), Ri(s, "CALL_EXCEPTION", {
5638
5638
  action: e,
5639
5639
  data: n,
5640
5640
  reason: i,
@@ -5646,29 +5646,29 @@ function Tu(e, t, n, r) {
5646
5646
  class fe {
5647
5647
  #t(t) {
5648
5648
  if (t.isArray())
5649
- return new Qc(this.#t(t.arrayChildren), t.arrayLength, t.name);
5649
+ return new jc(this.#t(t.arrayChildren), t.arrayLength, t.name);
5650
5650
  if (t.isTuple())
5651
5651
  return new Nn(t.components.map((r) => this.#t(r)), t.name);
5652
5652
  switch (t.baseType) {
5653
5653
  case "address":
5654
- return new Jc(t.name);
5654
+ return new zc(t.name);
5655
5655
  case "bool":
5656
- return new tu(t.name);
5656
+ return new Qc(t.name);
5657
5657
  case "string":
5658
- return new uu(t.name);
5658
+ return new cu(t.name);
5659
5659
  case "bytes":
5660
- return new eu(t.name);
5660
+ return new tu(t.name);
5661
5661
  case "":
5662
- return new su(t.name);
5662
+ return new ru(t.name);
5663
5663
  }
5664
- let n = t.type.match(Ou);
5664
+ let n = t.type.match(vu);
5665
5665
  if (n) {
5666
5666
  let r = parseInt(n[2] || "256");
5667
- return m(r !== 0 && r <= 256 && r % 8 === 0, "invalid " + n[1] + " bit length", "param", t), new cu(r / 8, n[1] === "int", t.name);
5667
+ return m(r !== 0 && r <= 256 && r % 8 === 0, "invalid " + n[1] + " bit length", "param", t), new au(r / 8, n[1] === "int", t.name);
5668
5668
  }
5669
- if (n = t.type.match(vu), n) {
5669
+ if (n = t.type.match(Bu), n) {
5670
5670
  let r = parseInt(n[1]);
5671
- return m(r !== 0 && r <= 32, "invalid bytes length", "param", t), new nu(r, t.name);
5671
+ return m(r !== 0 && r <= 32, "invalid bytes length", "param", t), new eu(r, t.name);
5672
5672
  }
5673
5673
  m(!1, "invalid type", "type", t.type);
5674
5674
  }
@@ -5688,7 +5688,7 @@ class fe {
5688
5688
  * @returns DataHexstring
5689
5689
  */
5690
5690
  encode(t, n) {
5691
- Ni(n.length, t.length, "types/values length mismatch");
5691
+ ki(n.length, t.length, "types/values length mismatch");
5692
5692
  const r = t.map((o) => this.#t(nt.from(o))), s = new Nn(r, "_"), i = new vr();
5693
5693
  return s.encode(i, n), i.data;
5694
5694
  }
@@ -5720,10 +5720,10 @@ class fe {
5720
5720
  * the Transaction %%tx%%.
5721
5721
  */
5722
5722
  static getBuiltinCallException(t, n, r) {
5723
- return Tu(t, n, r, fe.defaultAbiCoder());
5723
+ return Ou(t, n, r, fe.defaultAbiCoder());
5724
5724
  }
5725
5725
  }
5726
- class Iu {
5726
+ class Tu {
5727
5727
  /**
5728
5728
  * The matching fragment for the ``topic0``.
5729
5729
  */
@@ -5758,7 +5758,7 @@ class Iu {
5758
5758
  });
5759
5759
  }
5760
5760
  }
5761
- class Ru {
5761
+ class Iu {
5762
5762
  /**
5763
5763
  * The matching fragment from the transaction ``data``.
5764
5764
  */
@@ -5798,7 +5798,7 @@ class Ru {
5798
5798
  });
5799
5799
  }
5800
5800
  }
5801
- class ku {
5801
+ class Ru {
5802
5802
  /**
5803
5803
  * The matching fragment.
5804
5804
  */
@@ -5981,7 +5981,7 @@ class ge {
5981
5981
  }
5982
5982
  // Find a function definition by any means necessary (unless it is ambiguous)
5983
5983
  #s(t, n, r) {
5984
- if (cn(t)) {
5984
+ if (an(t)) {
5985
5985
  const i = t.toLowerCase();
5986
5986
  for (const o of this.#n.values())
5987
5987
  if (i === o.selector)
@@ -6079,7 +6079,7 @@ class ge {
6079
6079
  }
6080
6080
  // Find an event definition by any means necessary (unless it is ambiguous)
6081
6081
  #i(t, n, r) {
6082
- if (cn(t)) {
6082
+ if (an(t)) {
6083
6083
  const i = t.toLowerCase();
6084
6084
  for (const o of this.#e.values())
6085
6085
  if (i === o.topicHash)
@@ -6169,7 +6169,7 @@ class ge {
6169
6169
  * the ABI, this will throw.
6170
6170
  */
6171
6171
  getError(t, n) {
6172
- if (cn(t)) {
6172
+ if (an(t)) {
6173
6173
  const s = t.toLowerCase();
6174
6174
  if (Ds[s])
6175
6175
  return Rt.from(Ds[s].signature);
@@ -6420,7 +6420,7 @@ class ge {
6420
6420
  at(n.length <= t.inputs.length, `too many arguments for ${t.format()}`, "UNEXPECTED_ARGUMENT", { count: n.length, expectedCount: t.inputs.length });
6421
6421
  const r = [];
6422
6422
  t.anonymous || r.push(t.topicHash);
6423
- const s = (i, o) => i.type === "string" ? pn(o) : i.type === "bytes" ? tt(bt(o)) : (i.type === "bool" && typeof o == "boolean" ? o = o ? "0x01" : "0x00" : i.type.match(/^u?int/) ? o = Fi(o) : i.type.match(/^bytes/) ? o = Li(o, 32) : i.type === "address" && this.#r.encode(["address"], [o]), An(bt(o), 32));
6423
+ const s = (i, o) => i.type === "string" ? dn(o) : i.type === "bytes" ? tt(bt(o)) : (i.type === "bool" && typeof o == "boolean" ? o = o ? "0x01" : "0x00" : i.type.match(/^u?int/) ? o = Pi(o) : i.type.match(/^bytes/) ? o = $i(o, 32) : i.type === "address" && this.#r.encode(["address"], [o]), An(bt(o), 32));
6424
6424
  for (n.forEach((i, o) => {
6425
6425
  const a = t.inputs[o];
6426
6426
  if (!a.indexed) {
@@ -6442,7 +6442,7 @@ class ge {
6442
6442
  const c = n[a];
6443
6443
  if (o.indexed)
6444
6444
  if (o.type === "string")
6445
- r.push(pn(c));
6445
+ r.push(dn(c));
6446
6446
  else if (o.type === "bytes")
6447
6447
  r.push(tt(c));
6448
6448
  else {
@@ -6465,7 +6465,7 @@ class ge {
6465
6465
  }
6466
6466
  if (r != null && !t.anonymous) {
6467
6467
  const p = t.topicHash;
6468
- m(cn(r[0], 32) && r[0].toLowerCase() === p, "fragment/topic mismatch", "topics[0]", r[0]), r = r.slice(1);
6468
+ m(an(r[0], 32) && r[0].toLowerCase() === p, "fragment/topic mismatch", "topics[0]", r[0]), r = r.slice(1);
6469
6469
  }
6470
6470
  const s = [], i = [], o = [];
6471
6471
  t.inputs.forEach((p, w) => {
@@ -6502,11 +6502,11 @@ class ge {
6502
6502
  * If the matching function cannot be found, return null.
6503
6503
  */
6504
6504
  parseTransaction(t) {
6505
- const n = yt(t.data, "tx.data"), r = nn(t.value != null ? t.value : 0, "tx.value"), s = this.getFunction(bt(n.slice(0, 4)));
6505
+ const n = yt(t.data, "tx.data"), r = en(t.value != null ? t.value : 0, "tx.value"), s = this.getFunction(bt(n.slice(0, 4)));
6506
6506
  if (!s)
6507
6507
  return null;
6508
6508
  const i = this.#r.decode(s.inputs, n.slice(4));
6509
- return new Ru(s, s.selector, i, r);
6509
+ return new Iu(s, s.selector, i, r);
6510
6510
  }
6511
6511
  parseCallResult(t) {
6512
6512
  throw new Error("@TODO");
@@ -6519,7 +6519,7 @@ class ge {
6519
6519
  */
6520
6520
  parseLog(t) {
6521
6521
  const n = this.getEvent(t.topics[0]);
6522
- return !n || n.anonymous ? null : new Iu(n, n.topicHash, this.decodeEventLog(n, t.data, t.topics));
6522
+ return !n || n.anonymous ? null : new Tu(n, n.topicHash, this.decodeEventLog(n, t.data, t.topics));
6523
6523
  }
6524
6524
  /**
6525
6525
  * Parses a revert data, finding the matching error and extracts
@@ -6532,7 +6532,7 @@ class ge {
6532
6532
  if (!r)
6533
6533
  return null;
6534
6534
  const s = this.#r.decode(r.inputs, We(n, 4));
6535
- return new ku(r, r.selector, s);
6535
+ return new Ru(r, r.selector, s);
6536
6536
  }
6537
6537
  /**
6538
6538
  * Creates a new [[Interface]] from the ABI %%value%%.
@@ -6544,16 +6544,16 @@ class ge {
6544
6544
  return t instanceof ge ? t : typeof t == "string" ? new ge(JSON.parse(t)) : typeof t.formatJson == "function" ? new ge(t.formatJson()) : typeof t.format == "function" ? new ge(t.format("json")) : new ge(t);
6545
6545
  }
6546
6546
  }
6547
- const ao = "The swap backend did not return a fee_policy from get_swap_info, so it is older than this wallet-kit release and swap fees cannot be computed. Upgrade the swap backend, or pin @bestinslot/wallet-kit below 0.11.0.", Nu = /^0x[0-9a-f]{40}$/;
6547
+ const oo = "The swap backend did not return a fee_policy from get_swap_info, so it is older than this wallet-kit release and swap fees cannot be computed. Upgrade the swap backend, or pin @bestinslot/wallet-kit below 0.11.0.", ku = /^0x[0-9a-f]{40}$/;
6548
6548
  function Ge(e) {
6549
6549
  return new Error(`Invalid fee_policy from the swap backend: ${e}`);
6550
6550
  }
6551
6551
  function Ms(e) {
6552
6552
  return typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= 1e4;
6553
6553
  }
6554
- function Cu(e) {
6554
+ function Nu(e) {
6555
6555
  if (e == null)
6556
- throw new Error(ao);
6556
+ throw new Error(oo);
6557
6557
  if (typeof e != "object")
6558
6558
  throw Ge("not an object");
6559
6559
  const {
@@ -6573,7 +6573,7 @@ function Cu(e) {
6573
6573
  throw Ge("priority_tokens must be a non-empty array");
6574
6574
  const o = r.map((a) => {
6575
6575
  const c = typeof a == "string" ? a.toLowerCase() : "";
6576
- if (!Nu.test(c))
6576
+ if (!ku.test(c))
6577
6577
  throw Ge(`priority_tokens contains an invalid address (${String(a)})`);
6578
6578
  return c;
6579
6579
  });
@@ -6586,7 +6586,7 @@ function Cu(e) {
6586
6586
  min_btc_exposure_sats: s
6587
6587
  };
6588
6588
  }
6589
- function $u(e, t, n) {
6589
+ function Cu(e, t, n) {
6590
6590
  const r = n.priority_tokens.indexOf(e.toLowerCase()), s = n.priority_tokens.indexOf(t.toLowerCase()), o = BigInt(r === 0 || s === 0 ? n.swap_fee_bps : n.token_pair_swap_fee_bps);
6591
6591
  if (r === -1 && s === -1) {
6592
6592
  const c = o / 2n;
@@ -6594,23 +6594,23 @@ function $u(e, t, n) {
6594
6594
  }
6595
6595
  return r !== -1 && (s === -1 || r < s) ? { token1FeeBps: o, token2FeeBps: 0n } : { token1FeeBps: 0n, token2FeeBps: o };
6596
6596
  }
6597
- const Lu = 30n;
6598
- function Au(e, t, n) {
6597
+ const $u = 30n;
6598
+ function Lu(e, t, n) {
6599
6599
  const r = n.toLowerCase();
6600
6600
  return e.toLowerCase() === r ? "buy" : t.toLowerCase() === r ? "sell" : null;
6601
6601
  }
6602
- function co(e) {
6602
+ function ao(e) {
6603
6603
  const t = BigInt(Number.MAX_SAFE_INTEGER);
6604
6604
  if (e > t || e < -t)
6605
6605
  throw new RangeError("satsToBtc: amount exceeds safe-integer precision (~90,000 BTC).");
6606
6606
  return Number(e) / 1e8;
6607
6607
  }
6608
- function Pu(e, t) {
6609
- return co(e) * t;
6608
+ function Au(e, t) {
6609
+ return ao(e) * t;
6610
6610
  }
6611
- function uo(e, t, n, r, s) {
6611
+ function co(e, t, n, r, s) {
6612
6612
  return {
6613
- pool_fee_bps: Lu,
6613
+ pool_fee_bps: $u,
6614
6614
  token_in_fee_bps: n,
6615
6615
  token_in_fee: e * n / 10000n,
6616
6616
  token_out_fee_bps: r,
@@ -6618,7 +6618,7 @@ function uo(e, t, n, r, s) {
6618
6618
  miner_fee_sats: s
6619
6619
  };
6620
6620
  }
6621
- function lo(e, t, n, r, s, i) {
6621
+ function uo(e, t, n, r, s, i) {
6622
6622
  const o = e.toLowerCase() === t.toLowerCase() ? n * 10n ** BigInt(i) * 100n / r : r * 10n ** BigInt(s) * 100n / n;
6623
6623
  return Number(o) / 100;
6624
6624
  }
@@ -6626,7 +6626,7 @@ let wt = "", Gr = "";
6626
6626
  function er(e, t) {
6627
6627
  wt = e.toLowerCase(), Gr = t.toLowerCase();
6628
6628
  }
6629
- function Fu(e) {
6629
+ function Pu(e) {
6630
6630
  if (e < 0n)
6631
6631
  throw new Error("square root of negative numbers is not supported");
6632
6632
  if (e < 2n)
@@ -6655,14 +6655,14 @@ async function Ws(e, t, n) {
6655
6655
  const r = await e.balanceOf(t, n);
6656
6656
  return r === null ? BigInt(0) : r;
6657
6657
  }
6658
- async function Uu(e, t, n) {
6658
+ async function Fu(e, t, n) {
6659
6659
  t.toLowerCase() > n.toLowerCase() && ([t, n] = [n, t]);
6660
6660
  const r = await e.reservesOf(nr(t, n));
6661
6661
  if (r === null)
6662
6662
  throw new Error("Token pair does not exist");
6663
6663
  return r;
6664
6664
  }
6665
- class qu {
6665
+ class Uu {
6666
6666
  map;
6667
6667
  proxy;
6668
6668
  constructor() {
@@ -6697,7 +6697,7 @@ class qu {
6697
6697
  this.map[s] = r;
6698
6698
  }
6699
6699
  }
6700
- class Du {
6700
+ class qu {
6701
6701
  map;
6702
6702
  proxy;
6703
6703
  constructor() {
@@ -6718,7 +6718,7 @@ class Du {
6718
6718
  throw new Error("Undefined reserves encountered");
6719
6719
  return this.map[r];
6720
6720
  }
6721
- const s = await Uu(this.proxy, t, n);
6721
+ const s = await Fu(this.proxy, t, n);
6722
6722
  return this.map[r] = s, s;
6723
6723
  }
6724
6724
  set(t, n, r) {
@@ -6728,7 +6728,7 @@ class Du {
6728
6728
  this.map[s] = r;
6729
6729
  }
6730
6730
  }
6731
- const L = new qu(), it = new Du();
6731
+ const L = new Uu(), it = new qu();
6732
6732
  let Gs = Promise.resolve();
6733
6733
  async function Sn(e) {
6734
6734
  const t = Gs;
@@ -6745,10 +6745,10 @@ async function Sn(e) {
6745
6745
  }
6746
6746
  return n;
6747
6747
  }
6748
- function fo(e, t) {
6748
+ function lo(e, t) {
6749
6749
  return e < t ? e + t : t + e;
6750
6750
  }
6751
- function Mu(e, t, n) {
6751
+ function Du(e, t, n) {
6752
6752
  if (e <= 0n)
6753
6753
  throw new Error("Insufficient input amount");
6754
6754
  if (t <= 0n || n <= 0n)
@@ -6756,7 +6756,7 @@ function Mu(e, t, n) {
6756
6756
  const r = e * 997n, s = r * n, i = t * 1000n + r;
6757
6757
  return s / i;
6758
6758
  }
6759
- function Wu(e, t, n) {
6759
+ function Mu(e, t, n) {
6760
6760
  if (e <= 0n)
6761
6761
  throw new Error("Insufficient output amount");
6762
6762
  if (t <= 0n || n <= 0n || e >= n)
@@ -6764,23 +6764,23 @@ function Wu(e, t, n) {
6764
6764
  const r = t * e * 1000n, s = (n - e) * 997n;
6765
6765
  return r / s + 1n;
6766
6766
  }
6767
- async function Gu(e, t) {
6767
+ async function Wu(e, t) {
6768
6768
  if (t.length < 2)
6769
6769
  throw new Error("Invalid path");
6770
6770
  const n = [e];
6771
6771
  for (let r = 0; r < t.length - 1; r++) {
6772
- const { reserveA: s, reserveB: i } = await zt(t[r], t[r + 1]), o = Mu(n[r], s, i);
6772
+ const { reserveA: s, reserveB: i } = await zt(t[r], t[r + 1]), o = Du(n[r], s, i);
6773
6773
  n.push(o);
6774
6774
  }
6775
6775
  return n;
6776
6776
  }
6777
- async function Hu(e, t) {
6777
+ async function Gu(e, t) {
6778
6778
  if (t.length < 2)
6779
6779
  throw new Error("Invalid path");
6780
6780
  const n = [];
6781
6781
  n[t.length - 1] = e;
6782
6782
  for (let r = t.length - 1; r > 0; r--) {
6783
- const { reserveA: s, reserveB: i } = await zt(t[r - 1], t[r]), o = Wu(n[r], s, i);
6783
+ const { reserveA: s, reserveB: i } = await zt(t[r - 1], t[r]), o = Mu(n[r], s, i);
6784
6784
  n[r - 1] = o;
6785
6785
  }
6786
6786
  return n;
@@ -6806,8 +6806,8 @@ async function zt(e, t) {
6806
6806
  total_supply: n.total_supply
6807
6807
  };
6808
6808
  }
6809
- const Vu = (...e) => e.reduce((t, n) => n < t ? n : t);
6810
- async function Zu(e, t, n, r) {
6809
+ const Hu = (...e) => e.reduce((t, n) => n < t ? n : t);
6810
+ async function Vu(e, t, n, r) {
6811
6811
  const {
6812
6812
  reserveA: s,
6813
6813
  reserveB: i,
@@ -6815,7 +6815,7 @@ async function Zu(e, t, n, r) {
6815
6815
  } = await zt(e, t), a = s - n, c = i - r;
6816
6816
  let u;
6817
6817
  if (o === 0n) {
6818
- u = Fu(n * r) - 1000n;
6818
+ u = Pu(n * r) - 1000n;
6819
6819
  const f = await it.get(e, t);
6820
6820
  it.set(e, t, {
6821
6821
  reserveA: f.reserveA,
@@ -6823,7 +6823,7 @@ async function Zu(e, t, n, r) {
6823
6823
  total_supply: f.total_supply + 1000n
6824
6824
  });
6825
6825
  } else
6826
- u = Vu(n * o / a, r * o / c);
6826
+ u = Hu(n * o / a, r * o / c);
6827
6827
  if (u <= 0n)
6828
6828
  throw new Error("Insufficient liquidity minted");
6829
6829
  const l = await it.get(e, t);
@@ -6833,7 +6833,7 @@ async function Zu(e, t, n, r) {
6833
6833
  total_supply: l.total_supply + u
6834
6834
  }), u;
6835
6835
  }
6836
- async function Yu(e, t, n, r, s, i) {
6836
+ async function Zu(e, t, n, r, s, i) {
6837
6837
  let o, a;
6838
6838
  try {
6839
6839
  await it.get(e, t);
@@ -6858,8 +6858,8 @@ async function Yu(e, t, n, r, s, i) {
6858
6858
  }
6859
6859
  return { amountA: o, amountB: a };
6860
6860
  }
6861
- async function Ku(e, t, n, r, s, i) {
6862
- const { amountA: o, amountB: a } = await Yu(
6861
+ async function Yu(e, t, n, r, s, i) {
6862
+ const { amountA: o, amountB: a } = await Zu(
6863
6863
  e,
6864
6864
  t,
6865
6865
  n,
@@ -6876,10 +6876,10 @@ async function Ku(e, t, n, r, s, i) {
6876
6876
  reserveB: c.reserveB + o,
6877
6877
  total_supply: c.total_supply
6878
6878
  });
6879
- const u = await Zu(e, t, o, a);
6879
+ const u = await Vu(e, t, o, a);
6880
6880
  return { amountA: o, amountB: a, liquidity: u };
6881
6881
  }
6882
- async function Xu(e, t, n) {
6882
+ async function Ku(e, t, n) {
6883
6883
  const {
6884
6884
  reserveA: r,
6885
6885
  reserveB: s,
@@ -6895,7 +6895,7 @@ async function Xu(e, t, n) {
6895
6895
  total_supply: u
6896
6896
  }), { amountA: o, amountB: a };
6897
6897
  }
6898
- async function zu(e, t, n, r, s, i, o, a) {
6898
+ async function Xu(e, t, n, r, s, i, o, a) {
6899
6899
  if (s <= 0n && i <= 0n)
6900
6900
  throw new Error("Insufficient output amount");
6901
6901
  const { reserveA: c, reserveB: u } = await zt(e, t), l = c - n, f = u - r;
@@ -6925,7 +6925,7 @@ async function zu(e, t, n, r, s, i, o, a) {
6925
6925
  if (b * S < BigInt(l) * BigInt(f) * 1000n * 1000n)
6926
6926
  throw new Error("K");
6927
6927
  }
6928
- async function po(e, t) {
6928
+ async function fo(e, t) {
6929
6929
  if (e.length !== t.length)
6930
6930
  throw new Error("Amounts and path length mismatch");
6931
6931
  if (e.length < 2)
@@ -6945,34 +6945,34 @@ async function po(e, t) {
6945
6945
  if (s === void 0 || i === void 0 || o === void 0 || a === void 0)
6946
6946
  throw new Error("Undefined value in swap path or amounts");
6947
6947
  const c = s < i ? o : 0n, u = s < i ? 0n : o, l = s < i ? 0n : a, f = s < i ? a : 0n, d = s < i ? s : i, p = s < i ? i : s, w = r < t.length - 2 ? [i, t[r + 2]] : null, h = w === null ? null : i >= t[r + 2];
6948
- await zu(d, p, c, u, l, f, w, h);
6948
+ await Xu(d, p, c, u, l, f, w, h);
6949
6949
  }
6950
6950
  }
6951
- async function Ju(e, t, n) {
6951
+ async function zu(e, t, n) {
6952
6952
  if (n.length < 2)
6953
6953
  throw new Error("Invalid path");
6954
- const r = await Gu(e, n);
6954
+ const r = await Wu(e, n);
6955
6955
  if (r[r.length - 1] < t)
6956
6956
  throw new Error("Insufficient output amount");
6957
- return await po(r, n), r;
6957
+ return await fo(r, n), r;
6958
6958
  }
6959
- async function ju(e, t, n) {
6959
+ async function Ju(e, t, n) {
6960
6960
  if (n.length < 2)
6961
6961
  throw new Error("Invalid path");
6962
- const r = await Hu(t, n);
6962
+ const r = await Gu(t, n);
6963
6963
  if (r[0] > e)
6964
6964
  throw new Error("Excessive Input Amount");
6965
- return await po(r, n), r;
6965
+ return await fo(r, n), r;
6966
6966
  }
6967
- async function Qu(e, t, n, r, s) {
6968
- const { amountA: i, amountB: o } = await Xu(e, t, n);
6967
+ async function ju(e, t, n, r, s) {
6968
+ const { amountA: i, amountB: o } = await Ku(e, t, n);
6969
6969
  if (i < r)
6970
6970
  throw new Error("Insufficient A amount");
6971
6971
  if (o < s)
6972
6972
  throw new Error("Insufficient B amount");
6973
6973
  return { amountA: i, amountB: o };
6974
6974
  }
6975
- function tl(e, t, n, r, s, i, o, a, c, u, l, f) {
6975
+ function Qu(e, t, n, r, s, i, o, a, c, u, l, f) {
6976
6976
  if (f === "")
6977
6977
  return !0;
6978
6978
  let d = tt(B.from(e, "hex")).slice(2);
@@ -6986,11 +6986,11 @@ function tl(e, t, n, r, s, i, o, a, c, u, l, f) {
6986
6986
  );
6987
6987
  return T.shortSignatures.verify(b, w, P);
6988
6988
  }
6989
- async function el(e, t, n, r, s, i, o, a, c, u, l, f, d) {
6989
+ async function tl(e, t, n, r, s, i, o, a, c, u, l, f, d) {
6990
6990
  n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, c = c.startsWith("0x") ? c.slice(2) : c;
6991
6991
  const p = await Sn(e);
6992
6992
  try {
6993
- if (!tl(
6993
+ if (!Qu(
6994
6994
  t,
6995
6995
  u,
6996
6996
  n,
@@ -7005,14 +7005,14 @@ async function el(e, t, n, r, s, i, o, a, c, u, l, f, d) {
7005
7005
  c
7006
7006
  ))
7007
7007
  throw new Error("Invalid BLS signature");
7008
- const { amountA: w, amountB: h, liquidity: g } = await Ku(
7008
+ const { amountA: w, amountB: h, liquidity: g } = await Yu(
7009
7009
  n,
7010
7010
  r,
7011
7011
  s,
7012
7012
  i,
7013
7013
  o,
7014
7014
  a
7015
- ), b = fo(n, r);
7015
+ ), b = lo(n, r);
7016
7016
  return L.setCheckPositive(
7017
7017
  t,
7018
7018
  n,
@@ -7044,7 +7044,7 @@ async function el(e, t, n, r, s, i, o, a, c, u, l, f, d) {
7044
7044
  p();
7045
7045
  }
7046
7046
  }
7047
- function nl(e, t, n, r, s, i, o, a, c, u, l) {
7047
+ function el(e, t, n, r, s, i, o, a, c, u, l) {
7048
7048
  if (l === "")
7049
7049
  return !0;
7050
7050
  let f = tt(B.from(e, "hex")).slice(2);
@@ -7058,11 +7058,11 @@ function nl(e, t, n, r, s, i, o, a, c, u, l) {
7058
7058
  );
7059
7059
  return T.shortSignatures.verify(g, p, M);
7060
7060
  }
7061
- async function rl(e, t, n, r, s, i, o, a, c, u, l, f) {
7061
+ async function nl(e, t, n, r, s, i, o, a, c, u, l, f) {
7062
7062
  n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, a = a.startsWith("0x") ? a.slice(2) : a;
7063
7063
  const d = await Sn(e);
7064
7064
  try {
7065
- if (!nl(
7065
+ if (!el(
7066
7066
  t,
7067
7067
  c,
7068
7068
  n,
@@ -7076,10 +7076,10 @@ async function rl(e, t, n, r, s, i, o, a, c, u, l, f) {
7076
7076
  a
7077
7077
  ))
7078
7078
  throw new Error("Invalid BLS signature");
7079
- const p = fo(n, r);
7079
+ const p = lo(n, r);
7080
7080
  if ((await L.get(t, p) || 0n) < s)
7081
7081
  throw new Error("Insufficient liquidity balance");
7082
- const { amountA: w, amountB: h } = await Qu(
7082
+ const { amountA: w, amountB: h } = await ju(
7083
7083
  n,
7084
7084
  r,
7085
7085
  s,
@@ -7117,7 +7117,7 @@ async function rl(e, t, n, r, s, i, o, a, c, u, l, f) {
7117
7117
  d();
7118
7118
  }
7119
7119
  }
7120
- function sl(e, t, n, r, s, i, o, a, c, u) {
7120
+ function rl(e, t, n, r, s, i, o, a, c, u) {
7121
7121
  if (u === "")
7122
7122
  return !0;
7123
7123
  let l = tt(B.from(e, "hex")).slice(2);
@@ -7131,11 +7131,11 @@ function sl(e, t, n, r, s, i, o, a, c, u) {
7131
7131
  );
7132
7132
  return T.shortSignatures.verify(h, d, A);
7133
7133
  }
7134
- async function il(e, t, n, r, s, i, o, a, c, u, l) {
7134
+ async function sl(e, t, n, r, s, i, o, a, c, u, l) {
7135
7135
  n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, o = o.startsWith("0x") ? o.slice(2) : o;
7136
7136
  const f = await Sn(e);
7137
7137
  try {
7138
- if (!sl(
7138
+ if (!rl(
7139
7139
  t,
7140
7140
  a,
7141
7141
  n,
@@ -7153,7 +7153,7 @@ async function il(e, t, n, r, s, i, o, a, c, u, l) {
7153
7153
  const { reserveA: d, reserveB: p } = await zt(
7154
7154
  n,
7155
7155
  r
7156
- ), w = await Ju(s, i, [n, r]);
7156
+ ), w = await zu(s, i, [n, r]);
7157
7157
  if (w.length !== 2)
7158
7158
  throw new Error("Invalid swap output amounts");
7159
7159
  L.setCheckPositive(
@@ -7194,7 +7194,7 @@ async function il(e, t, n, r, s, i, o, a, c, u, l) {
7194
7194
  f();
7195
7195
  }
7196
7196
  }
7197
- function ol(e, t, n, r, s, i, o, a, c, u) {
7197
+ function il(e, t, n, r, s, i, o, a, c, u) {
7198
7198
  if (u === "")
7199
7199
  return !0;
7200
7200
  let l = tt(B.from(e, "hex")).slice(2);
@@ -7208,11 +7208,11 @@ function ol(e, t, n, r, s, i, o, a, c, u) {
7208
7208
  );
7209
7209
  return T.shortSignatures.verify(h, d, A);
7210
7210
  }
7211
- async function al(e, t, n, r, s, i, o, a, c, u, l) {
7211
+ async function ol(e, t, n, r, s, i, o, a, c, u, l) {
7212
7212
  n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, o = o.startsWith("0x") ? o.slice(2) : o;
7213
7213
  const f = await Sn(e);
7214
7214
  try {
7215
- if (!ol(
7215
+ if (!il(
7216
7216
  t,
7217
7217
  a,
7218
7218
  n,
@@ -7228,7 +7228,7 @@ async function al(e, t, n, r, s, i, o, a, c, u, l) {
7228
7228
  const { reserveA: d, reserveB: p } = await zt(
7229
7229
  n,
7230
7230
  r
7231
- ), w = await ju(s, i, [n, r]);
7231
+ ), w = await Ju(s, i, [n, r]);
7232
7232
  if (w.length !== 2)
7233
7233
  throw new Error("Invalid swap output amounts");
7234
7234
  L.setCheckPositive(
@@ -7269,7 +7269,7 @@ async function al(e, t, n, r, s, i, o, a, c, u, l) {
7269
7269
  f();
7270
7270
  }
7271
7271
  }
7272
- function cl(e, t, n, r, s, i) {
7272
+ function al(e, t, n, r, s, i) {
7273
7273
  if (i === "")
7274
7274
  return !0;
7275
7275
  let o = tt(B.from(e, "hex")).slice(2);
@@ -7283,13 +7283,13 @@ function cl(e, t, n, r, s, i) {
7283
7283
  );
7284
7284
  return T.shortSignatures.verify(f, c, g);
7285
7285
  }
7286
- async function ul(e, t, n, r, s, i, o) {
7286
+ async function cl(e, t, n, r, s, i, o) {
7287
7287
  if (n = n.toLowerCase(), n = n.startsWith("0x") ? n.slice(2) : n, n.length > 126)
7288
7288
  throw new Error("Pkscript too long");
7289
7289
  t = t.startsWith("0x") ? t.slice(2) : t, s = s.startsWith("0x") ? s.slice(2) : s;
7290
7290
  const a = await Sn(e);
7291
7291
  try {
7292
- if (!cl(t, i, n, r, o, s))
7292
+ if (!al(t, i, n, r, o, s))
7293
7293
  throw new Error("Invalid BLS signature");
7294
7294
  if ((await L.get(t, wt) || 0n) < r)
7295
7295
  throw new Error("Insufficient token balance");
@@ -7327,7 +7327,7 @@ class Hr {
7327
7327
  return (...n) => (this.next(), t(...n));
7328
7328
  }
7329
7329
  }
7330
- const ho = [
7330
+ const po = [
7331
7331
  {
7332
7332
  type: "function",
7333
7333
  name: "deposit",
@@ -7343,16 +7343,16 @@ const ho = [
7343
7343
  outputs: [],
7344
7344
  stateMutability: "nonpayable"
7345
7345
  }
7346
- ], ll = ho, be = 1e3, Vs = 12e3, wo = 2500n, fl = `Sign this message only on official BiS interfaces.
7346
+ ], ul = po, be = 1e3, Vs = 12e3, ho = 2500n, ll = `Sign this message only on official BiS interfaces.
7347
7347
  This signature is required to generate your session-specific swap key.
7348
7348
  Signing this message outside official BiS interfaces may result in unauthorized access to your swap session and is at the user's own risk.
7349
- By signing, you acknowledge that the BiS Terms of Service also apply: https://bestinslot.xyz/legal/terms.`, dl = `Sign this message only on official BiS interfaces.
7349
+ By signing, you acknowledge that the BiS Terms of Service also apply: https://bestinslot.xyz/legal/terms.`, fl = `Sign this message only on official BiS interfaces.
7350
7350
  This signature is required to generate your session-specific swap key.
7351
7351
  Signing this message outside official BiS interfaces may result in unauthorized access to your swap session and is at the user's own risk.
7352
7352
  By signing, you acknowledge that the BiS Terms of Service also apply: https://bestinslot.xyz/legal/terms.
7353
7353
 
7354
7354
  Current Network: Bitcoin Mainnet`;
7355
- async function X(e, t) {
7355
+ async function z(e, t) {
7356
7356
  try {
7357
7357
  const n = await fetch(e, t);
7358
7358
  if (!n.ok) {
@@ -7374,45 +7374,37 @@ async function X(e, t) {
7374
7374
  }
7375
7375
  }
7376
7376
  function Zs() {
7377
- const e = tn();
7377
+ const e = yn();
7378
7378
  if (e === "signet")
7379
- return fl;
7379
+ return ll;
7380
7380
  if (e === "mainnet")
7381
- return dl;
7381
+ return fl;
7382
7382
  throw new Error("Unsupported network for swap signature request text");
7383
7383
  }
7384
- function z(e) {
7385
- const t = tn();
7386
- if (t === "signet")
7387
- return `https://sas-proxy.bestinslot.xyz/${e}`;
7388
- if (t === "mainnet")
7389
- return `https://sa-proxy.bestinslot.xyz/${e}`;
7390
- throw new Error("Unsupported network for orderbook backend URL");
7391
- }
7392
7384
  function rr() {
7393
- const e = tn();
7385
+ const e = yn();
7394
7386
  if (e === "signet")
7395
7387
  return "0xf41B09041DC546F0466D6F74cda81971012B589D";
7396
7388
  if (e === "mainnet")
7397
7389
  return "0x62879BB3dD949c4CF06f71BF7c281DcF24D163e7";
7398
7390
  throw new Error("Unsupported network for orderbook contract address");
7399
7391
  }
7400
- function go() {
7401
- const e = tn();
7392
+ function wo() {
7393
+ const e = yn();
7402
7394
  if (e === "signet")
7403
- return new ge(ho);
7395
+ return new ge(po);
7404
7396
  if (e === "mainnet")
7405
- return new ge(ll);
7397
+ return new ge(ul);
7406
7398
  throw new Error("Unsupported network for orderbook contract address");
7407
7399
  }
7408
7400
  async function et() {
7409
7401
  return await Rr(Wt()?.address || "");
7410
7402
  }
7411
- function yo(e) {
7403
+ function go(e) {
7412
7404
  const t = T.shortSignatures.getPublicKey(e);
7413
7405
  return `0x${t.x.c0.toString(16).padStart(128, "0")}${t.x.c1.toString(16).padStart(128, "0")}${t.y.c0.toString(16).padStart(128, "0")}${t.y.c1.toString(16).padStart(128, "0")}`;
7414
7406
  }
7415
- async function bo(e = {}) {
7407
+ async function yo(e = {}) {
7416
7408
  const t = Wt();
7417
7409
  if (!t?.address)
7418
7410
  throw new Error("Ordinals wallet address not found.");
@@ -7423,14 +7415,14 @@ async function bo(e = {}) {
7423
7415
  const s = await Kr(Zs());
7424
7416
  if (r !== s)
7425
7417
  throw new Error("Deterministic signature mismatch. Please try again.");
7426
- const i = B.from(tt(`0x${r}`).slice(2), "hex"), o = B.from("my-app/bls-keygen", "utf-8"), a = lc(Ei, i, void 0, o, 48), c = xi(a, T.fields.Fr.ORDER), u = B.from(c), l = yo(u), f = `0x${u.toString("hex")}`, d = {
7418
+ const i = B.from(tt(`0x${r}`).slice(2), "hex"), o = B.from("my-app/bls-keygen", "utf-8"), a = uc(xi, i, void 0, o, 48), c = _i(a, T.fields.Fr.ORDER), u = B.from(c), l = go(u), f = `0x${u.toString("hex")}`, d = {
7427
7419
  bitcoinAddress: t.address,
7428
7420
  swapPubkey: l,
7429
7421
  swapPrivkey: f
7430
7422
  };
7431
7423
  return await Ks(d), d;
7432
7424
  }
7433
- function pl(e) {
7425
+ function dl(e) {
7434
7426
  const t = e.trim(), n = t.toLowerCase().startsWith("0x") ? t.slice(2) : t;
7435
7427
  if (!/^[0-9a-f]{64}$/i.test(n))
7436
7428
  throw new Error("Invalid security code. Expected a 32-byte hex value.");
@@ -7439,13 +7431,13 @@ function pl(e) {
7439
7431
  throw new Error("Invalid security code. Not a valid swap key.");
7440
7432
  return B.from(n, "hex");
7441
7433
  }
7442
- async function hl(e, t = {}) {
7434
+ async function pl(e, t = {}) {
7443
7435
  const n = Wt();
7444
7436
  if (!n?.address)
7445
7437
  throw new Error("Ordinals wallet address not found.");
7446
- const r = pl(e), s = {
7438
+ const r = dl(e), s = {
7447
7439
  bitcoinAddress: n.address,
7448
- swapPubkey: yo(r),
7440
+ swapPubkey: go(r),
7449
7441
  swapPrivkey: `0x${r.toString("hex")}`
7450
7442
  }, i = await Rr(n.address);
7451
7443
  if (i && i.swapPubkey !== s.swapPubkey && !t.overwrite)
@@ -7454,30 +7446,30 @@ async function hl(e, t = {}) {
7454
7446
  );
7455
7447
  return await Ks(s), s;
7456
7448
  }
7457
- async function wl(e = {}) {
7449
+ async function hl(e = {}) {
7458
7450
  const t = Wt();
7459
7451
  if (!t?.address)
7460
7452
  throw new Error("Ordinals wallet address not found.");
7461
7453
  const n = await Rr(t.address);
7462
- return n ? { wallet: n, created: !1 } : { wallet: await bo(e), created: !0 };
7454
+ return n ? { wallet: n, created: !1 } : { wallet: await yo(e), created: !0 };
7463
7455
  }
7464
- async function gl() {
7456
+ async function wl() {
7465
7457
  return (await et())?.swapPrivkey ?? null;
7466
7458
  }
7467
- async function yl() {
7468
- const e = z("status");
7469
- return await X(e, {
7459
+ async function gl() {
7460
+ const e = await K("status");
7461
+ return await z(e, {
7470
7462
  method: "GET"
7471
7463
  });
7472
7464
  }
7473
- async function mo(e) {
7465
+ async function bo(e) {
7474
7466
  const t = Wt();
7475
7467
  if (!t?.address)
7476
7468
  throw new Error("Ordinals wallet address not found.");
7477
- const n = z("check_swap_allowance"), r = {
7469
+ const n = await K("check_swap_allowance"), r = {
7478
7470
  ordinal_address: t.address,
7479
7471
  token_address: e
7480
- }, s = await X(n, {
7472
+ }, s = await z(n, {
7481
7473
  method: "POST",
7482
7474
  headers: {
7483
7475
  "Content-Type": "application/json"
@@ -7486,18 +7478,18 @@ async function mo(e) {
7486
7478
  });
7487
7479
  return BigInt(s.result);
7488
7480
  }
7489
- const bl = 6e4, Ys = /* @__PURE__ */ new Map(), Or = /* @__PURE__ */ new Map();
7481
+ const yl = 6e4, Ys = /* @__PURE__ */ new Map(), Or = /* @__PURE__ */ new Map();
7490
7482
  async function Jt() {
7491
- const e = tn(), t = Ys.get(e);
7492
- if (t && Date.now() - t.fetchedAt < bl)
7483
+ const e = yn(), t = Ys.get(e);
7484
+ if (t && Date.now() - t.fetchedAt < yl)
7493
7485
  return t.info;
7494
- const n = z("get_swap_info"), r = await X(n, {
7486
+ const n = await K("get_swap_info"), r = await z(n, {
7495
7487
  method: "GET"
7496
7488
  }), s = r.result.fee_policy;
7497
7489
  let i = null;
7498
7490
  if (Or.delete(e), s != null)
7499
7491
  try {
7500
- i = Cu(s);
7492
+ i = Nu(s);
7501
7493
  } catch (a) {
7502
7494
  Or.set(e, a instanceof Error ? a.message : String(a));
7503
7495
  }
@@ -7523,14 +7515,14 @@ async function sr(e, t) {
7523
7515
  if (s.reserveA === 0n || s.reserveB === 0n)
7524
7516
  throw new Error(`No swap pool with liquidity for ${e} / ${t}.`);
7525
7517
  }
7526
- async function _o(e) {
7518
+ async function mo(e) {
7527
7519
  const t = Wt();
7528
7520
  if (!t?.address)
7529
7521
  throw new Error("Ordinals wallet address not found.");
7530
- const n = z("check_brc20_balance"), r = {
7522
+ const n = await K("check_brc20_balance"), r = {
7531
7523
  ordinal_address: t.address,
7532
7524
  token_address: e
7533
- }, s = await X(n, {
7525
+ }, s = await z(n, {
7534
7526
  method: "POST",
7535
7527
  headers: {
7536
7528
  "Content-Type": "application/json"
@@ -7539,14 +7531,14 @@ async function _o(e) {
7539
7531
  });
7540
7532
  return BigInt(s.result);
7541
7533
  }
7542
- async function xo(e) {
7534
+ async function _o(e) {
7543
7535
  const t = Wt();
7544
7536
  if (!t?.address)
7545
7537
  throw new Error("Ordinals wallet address not found.");
7546
- const n = z("check_base_brc20_balance"), r = {
7538
+ const n = await K("check_base_brc20_balance"), r = {
7547
7539
  ordinal_address: t.address,
7548
7540
  token_address: e
7549
- }, s = await X(n, {
7541
+ }, s = await z(n, {
7550
7542
  method: "POST",
7551
7543
  headers: {
7552
7544
  "Content-Type": "application/json"
@@ -7560,9 +7552,9 @@ async function xo(e) {
7560
7552
  ticker: s.result.ticker
7561
7553
  };
7562
7554
  }
7563
- async function ml(e) {
7564
- const t = z("get_all_balances");
7565
- return (await X(t, {
7555
+ async function bl(e) {
7556
+ const t = await K("get_all_balances");
7557
+ return (await z(t, {
7566
7558
  method: "POST",
7567
7559
  headers: {
7568
7560
  "Content-Type": "application/json"
@@ -7572,11 +7564,11 @@ async function ml(e) {
7572
7564
  })
7573
7565
  })).result;
7574
7566
  }
7575
- async function _l(e) {
7567
+ async function ml(e) {
7576
7568
  const t = await et();
7577
7569
  if (!t?.swapPubkey)
7578
7570
  throw new Error("Smart wallet not found. Please generate a smart wallet first.");
7579
- const n = t.swapPubkey, r = z("get_balance"), i = await X(r, {
7571
+ const n = t.swapPubkey, r = await K("get_balance"), i = await z(r, {
7580
7572
  method: "POST",
7581
7573
  headers: {
7582
7574
  "Content-Type": "application/json"
@@ -7589,7 +7581,7 @@ async function _l(e) {
7589
7581
  return BigInt(i.result);
7590
7582
  }
7591
7583
  async function Bn(e, t) {
7592
- const n = z("get_balance"), s = await X(n, {
7584
+ const n = await K("get_balance"), s = await z(n, {
7593
7585
  method: "POST",
7594
7586
  headers: {
7595
7587
  "Content-Type": "application/json"
@@ -7602,7 +7594,7 @@ async function Bn(e, t) {
7602
7594
  return BigInt(s.result);
7603
7595
  }
7604
7596
  async function Ue(e) {
7605
- const t = z("get_pair_reserves"), r = await X(t, {
7597
+ const t = await K("get_pair_reserves"), r = await z(t, {
7606
7598
  method: "POST",
7607
7599
  headers: {
7608
7600
  "Content-Type": "application/json"
@@ -7621,7 +7613,7 @@ async function qe() {
7621
7613
  const e = (await et())?.swapPubkey;
7622
7614
  if (!e)
7623
7615
  throw new Error("Smart wallet not found. Please generate a smart wallet first.");
7624
- const t = z("get_swap_wallet_nonce"), r = await X(t, {
7616
+ const t = await K("get_swap_wallet_nonce"), r = await z(t, {
7625
7617
  method: "POST",
7626
7618
  headers: {
7627
7619
  "Content-Type": "application/json"
@@ -7632,8 +7624,8 @@ async function qe() {
7632
7624
  });
7633
7625
  return BigInt(r.result);
7634
7626
  }
7635
- async function xl(e, t) {
7636
- const n = z("get_swap_referrer_info"), s = await X(n, {
7627
+ async function _l(e, t) {
7628
+ const n = await K("get_swap_referrer_info"), s = await z(n, {
7637
7629
  method: "POST",
7638
7630
  headers: {
7639
7631
  "Content-Type": "application/json"
@@ -7649,13 +7641,13 @@ async function xl(e, t) {
7649
7641
  }
7650
7642
  async function Vr(e, t) {
7651
7643
  try {
7652
- return await xl(e, t);
7644
+ return await _l(e, t);
7653
7645
  } catch (n) {
7654
7646
  return console.warn(`Failed to get referrer info for ref_id ${t}:`, n), { referrerPubkey: void 0, refReturnBps: void 0 };
7655
7647
  }
7656
7648
  }
7657
7649
  async function $t(e) {
7658
- const t = z("get_miner_fee"), r = await X(t, {
7650
+ const t = await K("get_miner_fee"), r = await z(t, {
7659
7651
  method: "POST",
7660
7652
  headers: {
7661
7653
  "Content-Type": "application/json"
@@ -7666,16 +7658,16 @@ async function $t(e) {
7666
7658
  });
7667
7659
  return BigInt(r.result);
7668
7660
  }
7669
- async function El() {
7670
- const e = z("get_tokens");
7671
- return (await X(e, {
7661
+ async function xl() {
7662
+ const e = await K("get_tokens");
7663
+ return (await z(e, {
7672
7664
  method: "GET"
7673
7665
  })).tokens;
7674
7666
  }
7675
7667
  function Cn(e) {
7676
7668
  return e === null ? null : BigInt(e);
7677
7669
  }
7678
- async function Sl(e = {}) {
7670
+ async function El(e = {}) {
7679
7671
  const t = e.order_by ?? "tvl_desc", n = e.page ?? 1, r = e.count ?? 20;
7680
7672
  if (r > 100)
7681
7673
  throw new Error("Count cannot exceed 100");
@@ -7683,7 +7675,7 @@ async function Sl(e = {}) {
7683
7675
  order_by: t,
7684
7676
  page: String(n),
7685
7677
  count: String(r)
7686
- }), i = z(`get_table_data?${s}`), o = await X(i, {
7678
+ }), i = await K(`get_table_data?${s}`), o = await z(i, {
7687
7679
  method: "GET"
7688
7680
  });
7689
7681
  return {
@@ -7700,62 +7692,50 @@ async function Sl(e = {}) {
7700
7692
  }))
7701
7693
  };
7702
7694
  }
7703
- async function Bl(e) {
7704
- const t = z(`volume/${e.pair_address}?days=${e.days}`);
7705
- return await X(t, {
7706
- method: "GET",
7707
- headers: {
7708
- "Content-Type": "application/json"
7709
- }
7695
+ async function Sl(e) {
7696
+ const t = await K(`volume/${e.pair_address}?days=${e.days}`);
7697
+ return await z(t, {
7698
+ method: "GET"
7710
7699
  });
7711
7700
  }
7712
- async function vl(e) {
7701
+ async function Bl(e) {
7713
7702
  if (e.limit > 1e3)
7714
7703
  throw new Error("Limit cannot exceed 1000");
7715
- let t = z(
7704
+ let t = await K(
7716
7705
  `klines/${e.pair_address}?interval=${e.interval}&limit=${e.limit}`
7717
7706
  );
7718
- return e.startTime !== null && (t += `&startTime=${e.startTime}`), e.endTime !== null && (t += `&endTime=${e.endTime}`), await X(t, {
7719
- method: "GET",
7720
- headers: {
7721
- "Content-Type": "application/json"
7722
- }
7707
+ return e.startTime !== null && (t += `&startTime=${e.startTime}`), e.endTime !== null && (t += `&endTime=${e.endTime}`), await z(t, {
7708
+ method: "GET"
7723
7709
  });
7724
7710
  }
7725
- async function Ol(e) {
7726
- const t = z(
7711
+ async function vl(e) {
7712
+ const t = await K(
7727
7713
  `tvl/${encodeURIComponent(e.pair_address)}?${new URLSearchParams({
7728
7714
  days: String(e.days)
7729
7715
  })}`
7730
7716
  );
7731
- return await X(t, {
7732
- method: "GET",
7733
- headers: {
7734
- "Content-Type": "application/json"
7735
- }
7717
+ return await z(t, {
7718
+ method: "GET"
7736
7719
  });
7737
7720
  }
7738
- async function Tl(e) {
7721
+ async function Ol(e) {
7739
7722
  if (e.limit > 200)
7740
7723
  throw new Error("Limit cannot exceed 200");
7741
- const t = z(
7724
+ const t = await K(
7742
7725
  `pair-activity/${e.pair_address}?limit=${e.limit}&offset=${e.offset}`
7743
7726
  );
7744
- return await X(t, {
7745
- method: "GET",
7746
- headers: {
7747
- "Content-Type": "application/json"
7748
- }
7727
+ return await z(t, {
7728
+ method: "GET"
7749
7729
  });
7750
7730
  }
7751
- const Il = [
7731
+ const Tl = [
7752
7732
  "swap",
7753
7733
  "add_liq",
7754
7734
  "remove_liq",
7755
7735
  "withdraw",
7756
7736
  "unwrap"
7757
7737
  ];
7758
- async function Rl(e = {}) {
7738
+ async function Il(e = {}) {
7759
7739
  if (e.limit !== void 0) {
7760
7740
  if (e.limit > 100)
7761
7741
  throw new Error("Limit cannot exceed 100");
@@ -7767,21 +7747,18 @@ async function Rl(e = {}) {
7767
7747
  if (e.kinds !== void 0) {
7768
7748
  if (e.kinds.length === 0)
7769
7749
  throw new Error("Kinds must name at least one kind");
7770
- const s = e.kinds.find((i) => !Il.includes(i));
7750
+ const s = e.kinds.find((i) => !Tl.includes(i));
7771
7751
  if (s !== void 0)
7772
7752
  throw new Error(`Unknown activity kind: ${s}`);
7773
7753
  }
7774
7754
  const t = new URLSearchParams();
7775
7755
  e.limit !== void 0 && t.set("limit", String(e.limit)), e.before !== void 0 && t.set("before", e.before), e.kinds !== void 0 && t.set("kinds", e.kinds.join(","));
7776
- const n = t.toString(), r = z(`recent-activity${n ? `?${n}` : ""}`);
7777
- return await X(r, {
7778
- method: "GET",
7779
- headers: {
7780
- "Content-Type": "application/json"
7781
- }
7756
+ const n = t.toString(), r = await K(`recent-activity${n ? `?${n}` : ""}`);
7757
+ return await z(r, {
7758
+ method: "GET"
7782
7759
  });
7783
7760
  }
7784
- const kl = [
7761
+ const Rl = [
7785
7762
  "swap",
7786
7763
  "add_liq",
7787
7764
  "remove_liq",
@@ -7789,7 +7766,7 @@ const kl = [
7789
7766
  "withdraw",
7790
7767
  "unwrap"
7791
7768
  ];
7792
- async function Nl(e) {
7769
+ async function kl(e) {
7793
7770
  if (e.limit !== void 0) {
7794
7771
  if (e.limit > 200)
7795
7772
  throw new Error("Limit cannot exceed 200");
@@ -7801,23 +7778,22 @@ async function Nl(e) {
7801
7778
  if (e.kinds !== void 0) {
7802
7779
  if (e.kinds.length === 0)
7803
7780
  throw new Error("Kinds must name at least one kind");
7804
- const s = e.kinds.find((i) => !kl.includes(i));
7781
+ const s = e.kinds.find((i) => !Rl.includes(i));
7805
7782
  if (s !== void 0)
7806
7783
  throw new Error(`Unknown activity kind: ${s}`);
7807
7784
  }
7808
7785
  const t = new URLSearchParams();
7809
7786
  e.pairAddress !== void 0 && t.set("pairAddress", e.pairAddress), e.limit !== void 0 && t.set("limit", String(e.limit)), e.offset !== void 0 && t.set("offset", String(e.offset)), e.kinds !== void 0 && t.set("kinds", e.kinds.join(","));
7810
- const n = z(`wallet-activity/${encodeURIComponent(e.pubkey)}?${t}`);
7811
- return await X(n, {
7812
- method: "GET",
7813
- headers: {
7814
- "Content-Type": "application/json"
7815
- }
7787
+ const n = await K(
7788
+ `wallet-activity/${encodeURIComponent(e.pubkey)}?${t}`
7789
+ );
7790
+ return await z(n, {
7791
+ method: "GET"
7816
7792
  });
7817
7793
  }
7818
- async function wn(e) {
7819
- const t = z("get_token_decimals");
7820
- return (await X(t, {
7794
+ async function hn(e) {
7795
+ const t = await K("get_token_decimals");
7796
+ return (await z(t, {
7821
7797
  method: "POST",
7822
7798
  headers: {
7823
7799
  "Content-Type": "application/json"
@@ -7827,7 +7803,7 @@ async function wn(e) {
7827
7803
  })
7828
7804
  })).result;
7829
7805
  }
7830
- async function Eo(e) {
7806
+ async function xo(e) {
7831
7807
  e.bls_pubkey = e.bls_pubkey.startsWith("0x") ? e.bls_pubkey.slice(2) : e.bls_pubkey, e.bls_pubkey = e.bls_pubkey.toLowerCase(), e.token_address = e.token_address.toLowerCase();
7832
7808
  const t = `Deposit Order:
7833
7809
  Bitcoin Address: ${e.btc_address}
@@ -7849,7 +7825,7 @@ async function ir(e) {
7849
7825
  const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = B.from(i, "hex"), c = T.shortSignatures.sign(r, o).negate();
7850
7826
  return `0x${c.x.toString(16).padStart(128, "0")}${c.y.toString(16).padStart(128, "0")}`;
7851
7827
  }
7852
- async function So(e) {
7828
+ async function Eo(e) {
7853
7829
  e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
7854
7830
  let t = tt(B.from(e.pubkey, "hex")).slice(2);
7855
7831
  t += "99", t += e.ordinals_script;
@@ -7861,9 +7837,9 @@ async function So(e) {
7861
7837
  const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = B.from(i, "hex"), c = T.shortSignatures.sign(r, o).negate();
7862
7838
  return `0x${c.x.toString(16).padStart(128, "0")}${c.y.toString(16).padStart(128, "0")}`;
7863
7839
  }
7864
- async function Bo(e) {
7865
- const t = z("get_deposit_signature");
7866
- return X(t, {
7840
+ async function So(e) {
7841
+ const t = await K("get_deposit_signature");
7842
+ return z(t, {
7867
7843
  method: "POST",
7868
7844
  headers: {
7869
7845
  "Content-Type": "application/json"
@@ -7871,9 +7847,9 @@ async function Bo(e) {
7871
7847
  body: JSON.stringify(e)
7872
7848
  });
7873
7849
  }
7874
- async function Cl(e) {
7875
- const t = z("deposit");
7876
- return X(t, {
7850
+ async function Nl(e) {
7851
+ const t = await K("deposit");
7852
+ return z(t, {
7877
7853
  method: "POST",
7878
7854
  headers: {
7879
7855
  "Content-Type": "application/json"
@@ -7881,7 +7857,7 @@ async function Cl(e) {
7881
7857
  body: JSON.stringify(e)
7882
7858
  });
7883
7859
  }
7884
- function vo(e, t) {
7860
+ function Bo(e, t) {
7885
7861
  if (e < 0n)
7886
7862
  throw new Error("Amount cannot be negative");
7887
7863
  if (t < 0 || t > 18)
@@ -7897,11 +7873,11 @@ function vo(e, t) {
7897
7873
  }
7898
7874
  return i ? `${s}.${i}` : s;
7899
7875
  }
7900
- function Oo(e) {
7876
+ function vo(e) {
7901
7877
  return e ? e.reduce((t, n) => t + n.amount, 0n) : 0n;
7902
7878
  }
7903
- async function $l(e, t, n, r = !0, s, i = {}) {
7904
- const o = yn();
7879
+ async function Cl(e, t, n, r = !0, s, i = {}) {
7880
+ const o = gn();
7905
7881
  if (!o || !o.wallets) throw new Error("Wallets not found");
7906
7882
  const a = Xe(), c = Zn(), u = Wt();
7907
7883
  if (!c) throw new Error("Payment wallet not found");
@@ -7910,17 +7886,17 @@ async function $l(e, t, n, r = !0, s, i = {}) {
7910
7886
  if (!u.address) throw new Error("Ordinals wallet address not found");
7911
7887
  const l = c.address, f = c.pubkey, d = u.address, p = new Ut(!1, null, l, null, f);
7912
7888
  let w = 0n, h = 0, g = "";
7913
- const b = await _o(e);
7889
+ const b = await mo(e);
7914
7890
  if (b < t) {
7915
- const At = await xo(e), te = At.available_balance_in_18_dec;
7891
+ const At = await _o(e), te = At.available_balance_in_18_dec;
7916
7892
  h = At.decimals, g = At.ticker, w = t - b;
7917
- const ee = Oo(s);
7893
+ const ee = vo(s);
7918
7894
  if (te + ee < w)
7919
7895
  throw console.error(
7920
7896
  `Insufficient BRC-2.0 + BRC20 available balance. Current BRC-2.0: ${b}, Available in base: ${te}, Reclaimable: ${ee}, Required: ${t}`
7921
7897
  ), new Error("Insufficient BRC-2.0 + BRC20 available balance");
7922
7898
  }
7923
- const S = await mo(e);
7899
+ const S = await bo(e);
7924
7900
  let O = !1;
7925
7901
  if (S < BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) {
7926
7902
  if (!r)
@@ -7943,14 +7919,14 @@ async function $l(e, t, n, r = !0, s, i = {}) {
7943
7919
  if (!H)
7944
7920
  throw new Error("Smart wallet not found. Please generate a smart wallet first.");
7945
7921
  A.next();
7946
- const U = await Eo({
7922
+ const U = await xo({
7947
7923
  btc_address: d,
7948
7924
  bls_pubkey: H,
7949
7925
  token_address: e
7950
- }), y = bn.address.toOutputScript(d, Xe()), x = await So({
7926
+ }), y = bn.address.toOutputScript(d, Xe()), x = await Eo({
7951
7927
  pubkey: H,
7952
7928
  ordinals_script: y.toString("hex")
7953
- }), v = await Bo({
7929
+ }), v = await So({
7954
7930
  btc_address: d,
7955
7931
  bls_pubkey: H,
7956
7932
  token_address: e.toLowerCase(),
@@ -7959,7 +7935,7 @@ async function $l(e, t, n, r = !0, s, i = {}) {
7959
7935
  }), R = v.edcsa_signature, F = v.pubkey_idx, $ = v.token_idx, q = await ir({
7960
7936
  pubkey: H,
7961
7937
  pk_idx: BigInt(F)
7962
- }), W = go().encodeFunctionData("deposit", [
7938
+ }), W = wo().encodeFunctionData("deposit", [
7963
7939
  e,
7964
7940
  $,
7965
7941
  t,
@@ -7979,7 +7955,7 @@ async function $l(e, t, n, r = !0, s, i = {}) {
7979
7955
  );
7980
7956
  let G = null, ut = null, gt = null, xt = null, Q = null, rt = null, jt = null, Be = null, Qt = null;
7981
7957
  if (w > 0n) {
7982
- const At = vo(
7958
+ const At = Bo(
7983
7959
  w,
7984
7960
  h
7985
7961
  ), te = new ce(
@@ -7993,7 +7969,7 @@ async function $l(e, t, n, r = !0, s, i = {}) {
7993
7969
  )
7994
7970
  );
7995
7971
  if ((s?.length ?? 0) > 0) {
7996
- const On = await zs(s, d), Ie = await Vo(
7972
+ const On = await zs(s, d), Ie = await Ho(
7997
7973
  te,
7998
7974
  On,
7999
7975
  n,
@@ -8059,7 +8035,7 @@ async function $l(e, t, n, r = !0, s, i = {}) {
8059
8035
  throw new Error("Failed to send inscription to OP_RETURN");
8060
8036
  jt = Me.signedTxHex, Be = Me.txId;
8061
8037
  }
8062
- let lt = null, Lt = null, dt = null, Et = null, St = null, Nt = null, ve = null, rn = null, Oe = null;
8038
+ let lt = null, Lt = null, dt = null, Et = null, St = null, Nt = null, ve = null, nn = null, Oe = null;
8063
8039
  if (O) {
8064
8040
  const At = [];
8065
8041
  w > 0n && At.push(
@@ -8113,7 +8089,7 @@ async function $l(e, t, n, r = !0, s, i = {}) {
8113
8089
  }
8114
8090
  if (ee == null)
8115
8091
  throw new Error("Failed to send inscription to OP_RETURN");
8116
- ve = ee.signedTxHex, rn = ee.txId;
8092
+ ve = ee.signedTxHex, nn = ee.txId;
8117
8093
  }
8118
8094
  const ar = [], De = [];
8119
8095
  if (w > 0n) {
@@ -8134,13 +8110,13 @@ async function $l(e, t, n, r = !0, s, i = {}) {
8134
8110
  if (!St || !Nt || !ve)
8135
8111
  throw new Error("Allowance transaction hexes are missing");
8136
8112
  De.push(St, Nt, ve), ar.push({
8137
- utxo: `${rn}:1`,
8113
+ utxo: `${nn}:1`,
8138
8114
  value: be,
8139
8115
  script_type: Pn(p.outputScript, a),
8140
8116
  wallet: p
8141
8117
  });
8142
8118
  }
8143
- let vn = null, Te = null, sn = "", Yr = "", cr = "", ur = "";
8119
+ let vn = null, Te = null, rn = "", Yr = "", cr = "", ur = "";
8144
8120
  try {
8145
8121
  De.length > 0 && Ft(De, null), Te = await js(
8146
8122
  j,
@@ -8151,9 +8127,9 @@ async function $l(e, t, n, r = !0, s, i = {}) {
8151
8127
  0,
8152
8128
  !0,
8153
8129
  M
8154
- ), cr = Te.signedCommitTxHex, ur = Te.signedRevealTxHex, sn = Te.inscriptionId;
8155
- const At = `${sn.split("i")[0]}:0:0`;
8156
- Yr = Te.secret, De.push(cr, ur), Ft(De, [sn, At]);
8130
+ ), cr = Te.signedCommitTxHex, ur = Te.signedRevealTxHex, rn = Te.inscriptionId;
8131
+ const At = `${rn.split("i")[0]}:0:0`;
8132
+ Yr = Te.secret, De.push(cr, ur), Ft(De, [rn, At]);
8157
8133
  const te = new Ut(
8158
8134
  !0,
8159
8135
  B.from(me.encode(["OP_RETURN", J.str("BRC20PROG")], !1)),
@@ -8162,7 +8138,7 @@ async function $l(e, t, n, r = !0, s, i = {}) {
8162
8138
  null
8163
8139
  );
8164
8140
  vn = await Ln(
8165
- sn,
8141
+ rn,
8166
8142
  [],
8167
8143
  te,
8168
8144
  1,
@@ -8176,22 +8152,22 @@ async function $l(e, t, n, r = !0, s, i = {}) {
8176
8152
  }
8177
8153
  if (vn == null)
8178
8154
  throw new Error("Failed to send inscription to OP_RETURN");
8179
- const Uo = vn.signedTxHex, qo = vn.txId, Do = {
8155
+ const Fo = vn.signedTxHex, Uo = vn.txId, qo = {
8180
8156
  commit_txid: Te.commitTxId,
8181
8157
  commit_txhex: cr,
8182
8158
  reveal_txid: Te.revealTxId,
8183
8159
  reveal_txhex: ur,
8184
- send_to_opreturn_txid: qo,
8185
- send_to_opreturn_txhex: Uo,
8160
+ send_to_opreturn_txid: Uo,
8161
+ send_to_opreturn_txhex: Fo,
8186
8162
  secret: Yr,
8187
- inscription_id: sn,
8163
+ inscription_id: rn,
8188
8164
  fee_rate: n,
8189
8165
  approve_details: O ? {
8190
8166
  commit_txid: dt,
8191
8167
  commit_txhex: St,
8192
8168
  reveal_txid: Et,
8193
8169
  reveal_txhex: Nt,
8194
- send_to_opreturn_txid: rn,
8170
+ send_to_opreturn_txid: nn,
8195
8171
  send_to_opreturn_txhex: ve,
8196
8172
  secret: Lt,
8197
8173
  inscription_id: lt,
@@ -8209,27 +8185,27 @@ async function $l(e, t, n, r = !0, s, i = {}) {
8209
8185
  fee_rate: n
8210
8186
  } : null
8211
8187
  };
8212
- return (await Cl(Do)).result;
8188
+ return (await Nl(qo)).result;
8213
8189
  }
8214
- async function Ll(e, t, n, r = !0, s) {
8215
- const i = yn();
8190
+ async function $l(e, t, n, r = !0, s) {
8191
+ const i = gn();
8216
8192
  if (!i || !i.wallets) throw new Error("Wallets not found");
8217
8193
  const o = Xe(), a = Zn();
8218
8194
  if (!a) throw new Error("Payment wallet not found");
8219
8195
  if (!a.address) throw new Error("Payment wallet address not found");
8220
8196
  const c = a.address, u = a.pubkey, l = new Ut(!1, null, c, null, u);
8221
8197
  let f = 0n, d = 0, p = "";
8222
- const w = await _o(e);
8198
+ const w = await mo(e);
8223
8199
  if (w < t) {
8224
- const lt = await xo(e), Lt = lt.available_balance_in_18_dec;
8200
+ const lt = await _o(e), Lt = lt.available_balance_in_18_dec;
8225
8201
  d = lt.decimals, p = lt.ticker, f = t - w;
8226
- const dt = Oo(s);
8202
+ const dt = vo(s);
8227
8203
  if (Lt + dt < f)
8228
8204
  throw console.error(
8229
8205
  `Insufficient BRC-2.0 + BRC20 available balance. Current BRC-2.0: ${w}, Available in base: ${Lt}, Reclaimable: ${dt}, Required: ${t}`
8230
8206
  ), new Error("Insufficient BRC-2.0 + BRC20 available balance");
8231
8207
  }
8232
- const h = await mo(e);
8208
+ const h = await bo(e);
8233
8209
  let g = !1;
8234
8210
  if (h < BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) {
8235
8211
  if (!r)
@@ -8251,7 +8227,7 @@ async function Ll(e, t, n, r = !0, s) {
8251
8227
  const C = `0x${"00".repeat(64)}`, I = 1, _ = 1, D = await ir({
8252
8228
  pubkey: P,
8253
8229
  pk_idx: BigInt(I)
8254
- }), U = go().encodeFunctionData("deposit", [
8230
+ }), U = wo().encodeFunctionData("deposit", [
8255
8231
  e,
8256
8232
  _,
8257
8233
  t,
@@ -8271,7 +8247,7 @@ async function Ll(e, t, n, r = !0, s) {
8271
8247
  ), R = await Xs(c);
8272
8248
  let F = null, $ = null, q = null, k = null, W = null, Z = 0;
8273
8249
  if (f > 0n) {
8274
- const lt = vo(
8250
+ const lt = Bo(
8275
8251
  f,
8276
8252
  d
8277
8253
  ), Lt = new ce(
@@ -8289,10 +8265,10 @@ async function Ll(e, t, n, r = !0, s) {
8289
8265
  const Nt = Wt();
8290
8266
  if (!Nt) throw new Error("Ordinals wallet not found");
8291
8267
  if (!Nt.address) throw new Error("Ordinals wallet address not found");
8292
- const ve = Nt.address, rn = await zs(s, ve);
8293
- dt = await Ho(
8268
+ const ve = Nt.address, nn = await zs(s, ve);
8269
+ dt = await Go(
8294
8270
  Lt,
8295
- rn,
8271
+ nn,
8296
8272
  n,
8297
8273
  null,
8298
8274
  R
@@ -8467,9 +8443,9 @@ async function Ll(e, t, n, r = !0, s) {
8467
8443
  fee_rate: n
8468
8444
  };
8469
8445
  }
8470
- async function Al(e) {
8471
- const t = z("wrap");
8472
- return X(t, {
8446
+ async function Ll(e) {
8447
+ const t = await K("wrap");
8448
+ return z(t, {
8473
8449
  method: "POST",
8474
8450
  headers: {
8475
8451
  "Content-Type": "application/json"
@@ -8477,9 +8453,9 @@ async function Al(e) {
8477
8453
  body: JSON.stringify(e)
8478
8454
  });
8479
8455
  }
8480
- async function Pl(e) {
8481
- const t = z("estimate_wrap_gas");
8482
- return X(t, {
8456
+ async function Al(e) {
8457
+ const t = await K("estimate_wrap_gas");
8458
+ return z(t, {
8483
8459
  method: "POST",
8484
8460
  headers: {
8485
8461
  "Content-Type": "application/json"
@@ -8487,8 +8463,8 @@ async function Pl(e) {
8487
8463
  body: JSON.stringify(e)
8488
8464
  });
8489
8465
  }
8490
- async function Fl(e, t, n = {}) {
8491
- const r = await Jt(), s = yn();
8466
+ async function Pl(e, t, n = {}) {
8467
+ const r = await Jt(), s = gn();
8492
8468
  if (!s || !s.wallets) throw new Error("Wallets not found");
8493
8469
  const i = new Hr(n), o = i.wrap(Ir(s.provider)), a = Zn(), c = Wt();
8494
8470
  if (!a) throw new Error("Payment wallet not found");
@@ -8499,14 +8475,14 @@ async function Fl(e, t, n = {}) {
8499
8475
  if (!f)
8500
8476
  throw new Error("Smart wallet not found. Please generate a smart wallet first.");
8501
8477
  i.next();
8502
- const d = await Eo({
8478
+ const d = await xo({
8503
8479
  btc_address: u,
8504
8480
  bls_pubkey: f,
8505
8481
  token_address: r.wbtc_address
8506
- }), p = bn.address.toOutputScript(u, Xe()), w = await So({
8482
+ }), p = bn.address.toOutputScript(u, Xe()), w = await Eo({
8507
8483
  pubkey: f,
8508
8484
  ordinals_script: p.toString("hex")
8509
- }), h = await Bo({
8485
+ }), h = await So({
8510
8486
  btc_address: u,
8511
8487
  bls_pubkey: f,
8512
8488
  token_address: r.wbtc_address.toLowerCase(),
@@ -8596,7 +8572,7 @@ async function Fl(e, t, n = {}) {
8596
8572
  secret: k,
8597
8573
  inscription_id: $,
8598
8574
  fee_rate: t
8599
- }, G = await Pl(j), ut = Math.max(
8575
+ }, G = await Al(j), ut = Math.max(
8600
8576
  G.estimated_gas + 1e5,
8601
8577
  G.estimated_gas * 1.2
8602
8578
  );
@@ -8604,12 +8580,12 @@ async function Fl(e, t, n = {}) {
8604
8580
  _ = ut + 5e4;
8605
8581
  continue;
8606
8582
  }
8607
- return (await Al(j)).result;
8583
+ return (await Ll(j)).result;
8608
8584
  }
8609
8585
  throw new Error("Failed to estimate gas for wrap order after multiple attempts");
8610
8586
  }
8611
- async function Ul(e, t) {
8612
- const n = await Jt(), r = yn();
8587
+ async function Fl(e, t) {
8588
+ const n = await Jt(), r = gn();
8613
8589
  if (!r || !r.wallets) throw new Error("Wallets not found");
8614
8590
  const s = Zn();
8615
8591
  if (!s) throw new Error("Payment wallet not found");
@@ -8692,7 +8668,7 @@ async function Ul(e, t) {
8692
8668
  fee_rate: t
8693
8669
  };
8694
8670
  }
8695
- async function ql(e, t, n, r) {
8671
+ async function Ul(e, t, n, r) {
8696
8672
  const s = await Jt();
8697
8673
  er(s.wbtc_address, s.factory_address);
8698
8674
  const i = (await et())?.swapPubkey;
@@ -8701,7 +8677,7 @@ async function ql(e, t, n, r) {
8701
8677
  const o = {
8702
8678
  balanceOf: Bn,
8703
8679
  reservesOf: Ue
8704
- }, a = await $t("add_liquidity"), c = await el(
8680
+ }, a = await $t("add_liquidity"), c = await tl(
8705
8681
  o,
8706
8682
  i,
8707
8683
  e,
@@ -8729,7 +8705,7 @@ async function ql(e, t, n, r) {
8729
8705
  throw new Error("No data returned from add liquidity request.");
8730
8706
  return c.data;
8731
8707
  }
8732
- async function Dl(e) {
8708
+ async function ql(e) {
8733
8709
  e.token1_addr = e.token1_addr.toLowerCase(), e.token2_addr = e.token2_addr.toLowerCase();
8734
8710
  const t = `Add Liquidity Order:
8735
8711
  Token 1 Address: ${e.token1_addr}
@@ -8745,7 +8721,7 @@ BTC Fee: ${e.btc_fee}
8745
8721
  By signing this message, you authorize the creation of an add liquidity order with the above parameters.`;
8746
8722
  return await Pe(t, "ordinals");
8747
8723
  }
8748
- async function Ml(e) {
8724
+ async function Dl(e) {
8749
8725
  e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
8750
8726
  let t = tt(B.from(e.pubkey, "hex")).slice(2);
8751
8727
  t += e.nonce.toString(16).padStart(8, "0"), t += "01", t += e.token1_addr.slice(2).padStart(40, "0"), t += e.token2_addr.slice(2).padStart(40, "0"), t += e.amt1.toString(16).padStart(64, "0"), t += e.amt2.toString(16).padStart(64, "0"), t += e.minamt1.toString(16).padStart(64, "0"), t += e.minamt2.toString(16).padStart(64, "0"), t += e.token1FeeBps.toString(16).padStart(64, "0"), t += e.token2FeeBps.toString(16).padStart(64, "0"), t += e.btc_fee.toString(16).padStart(64, "0");
@@ -8757,9 +8733,9 @@ async function Ml(e) {
8757
8733
  const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = B.from(i, "hex"), a = T.shortSignatures.sign(r, o);
8758
8734
  return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
8759
8735
  }
8760
- async function Wl(e) {
8761
- const t = z("add_liq_req");
8762
- return X(t, {
8736
+ async function Ml(e) {
8737
+ const t = await K("add_liq_req");
8738
+ return z(t, {
8763
8739
  method: "POST",
8764
8740
  headers: {
8765
8741
  "Content-Type": "application/json"
@@ -8767,11 +8743,11 @@ async function Wl(e) {
8767
8743
  body: JSON.stringify(e)
8768
8744
  });
8769
8745
  }
8770
- async function Gl(e, t, n, r, s) {
8746
+ async function Wl(e, t, n, r, s) {
8771
8747
  const i = (await et())?.swapPubkey;
8772
8748
  if (!i)
8773
8749
  throw new Error("Smart wallet not found. Please generate a smart wallet first.");
8774
- const o = n * (10000n - s) / 10000n, a = r * (10000n - s) / 10000n, c = 0n, u = 0n, l = await qe(), f = await $t("add_liquidity"), d = await Dl({
8750
+ const o = n * (10000n - s) / 10000n, a = r * (10000n - s) / 10000n, c = 0n, u = 0n, l = await qe(), f = await $t("add_liquidity"), d = await ql({
8775
8751
  token1_addr: e,
8776
8752
  token2_addr: t,
8777
8753
  amt1: n.toString(),
@@ -8781,7 +8757,7 @@ async function Gl(e, t, n, r, s) {
8781
8757
  token1FeeBps: c.toString(),
8782
8758
  token2FeeBps: u.toString(),
8783
8759
  btc_fee: f.toString()
8784
- }), p = await Ml({
8760
+ }), p = await Dl({
8785
8761
  pubkey: i,
8786
8762
  nonce: l,
8787
8763
  token1_addr: e,
@@ -8794,7 +8770,7 @@ async function Gl(e, t, n, r, s) {
8794
8770
  token2FeeBps: u,
8795
8771
  btc_fee: f
8796
8772
  });
8797
- return await Wl({
8773
+ return await Ml({
8798
8774
  pubkey: i,
8799
8775
  token1_addr: e,
8800
8776
  token2_addr: t,
@@ -8809,7 +8785,7 @@ async function Gl(e, t, n, r, s) {
8809
8785
  bip322_signature: d
8810
8786
  });
8811
8787
  }
8812
- async function Hl(e, t, n) {
8788
+ async function Gl(e, t, n) {
8813
8789
  const r = await Jt();
8814
8790
  er(r.wbtc_address, r.factory_address);
8815
8791
  const s = (await et())?.swapPubkey;
@@ -8818,7 +8794,7 @@ async function Hl(e, t, n) {
8818
8794
  const i = {
8819
8795
  balanceOf: Bn,
8820
8796
  reservesOf: Ue
8821
- }, o = await $t("remove_liquidity"), a = await rl(
8797
+ }, o = await $t("remove_liquidity"), a = await nl(
8822
8798
  i,
8823
8799
  s,
8824
8800
  e,
@@ -8845,7 +8821,7 @@ async function Hl(e, t, n) {
8845
8821
  throw new Error("No data returned from remove liquidity request.");
8846
8822
  return a.data;
8847
8823
  }
8848
- async function Vl(e) {
8824
+ async function Hl(e) {
8849
8825
  e.token1_addr = e.token1_addr.toLowerCase(), e.token2_addr = e.token2_addr.toLowerCase();
8850
8826
  const t = `Remove Liquidity Order:
8851
8827
  Token 1 Address: ${e.token1_addr}
@@ -8860,7 +8836,7 @@ BTC Fee: ${e.btc_fee}
8860
8836
  By signing this message, you authorize the creation of a remove liquidity order with the above parameters.`;
8861
8837
  return await Pe(t, "ordinals");
8862
8838
  }
8863
- async function Zl(e) {
8839
+ async function Vl(e) {
8864
8840
  e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
8865
8841
  let t = tt(B.from(e.pubkey, "hex")).slice(2);
8866
8842
  t += e.nonce.toString(16).padStart(8, "0"), t += "02", t += e.token1_addr.slice(2).padStart(40, "0"), t += e.token2_addr.slice(2).padStart(40, "0"), t += e.lp_amt.toString(16).padStart(64, "0"), t += e.minamt1.toString(16).padStart(64, "0"), t += e.minamt2.toString(16).padStart(64, "0"), t += e.token1FeeBps.toString(16).padStart(64, "0"), t += e.token2FeeBps.toString(16).padStart(64, "0"), t += e.btc_fee.toString(16).padStart(64, "0");
@@ -8872,9 +8848,9 @@ async function Zl(e) {
8872
8848
  const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = B.from(i, "hex"), a = T.shortSignatures.sign(r, o);
8873
8849
  return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
8874
8850
  }
8875
- async function Yl(e) {
8876
- const t = z("remove_liq_req");
8877
- return X(t, {
8851
+ async function Zl(e) {
8852
+ const t = await K("remove_liq_req");
8853
+ return z(t, {
8878
8854
  method: "POST",
8879
8855
  headers: {
8880
8856
  "Content-Type": "application/json"
@@ -8882,11 +8858,11 @@ async function Yl(e) {
8882
8858
  body: JSON.stringify(e)
8883
8859
  });
8884
8860
  }
8885
- async function Kl(e, t, n, r, s, i) {
8861
+ async function Yl(e, t, n, r, s, i) {
8886
8862
  const o = (await et())?.swapPubkey;
8887
8863
  if (!o)
8888
8864
  throw new Error("Smart wallet not found. Please generate a smart wallet first.");
8889
- const a = r * (10000n - i) / 10000n, c = s * (10000n - i) / 10000n, u = 0n, l = 0n, f = await qe(), d = await $t("remove_liquidity"), p = await Vl({
8865
+ const a = r * (10000n - i) / 10000n, c = s * (10000n - i) / 10000n, u = 0n, l = 0n, f = await qe(), d = await $t("remove_liquidity"), p = await Hl({
8890
8866
  token1_addr: e,
8891
8867
  token2_addr: t,
8892
8868
  lp_amt: n.toString(),
@@ -8895,7 +8871,7 @@ async function Kl(e, t, n, r, s, i) {
8895
8871
  token1FeeBps: u.toString(),
8896
8872
  token2FeeBps: l.toString(),
8897
8873
  btc_fee: d.toString()
8898
- }), w = await Zl({
8874
+ }), w = await Vl({
8899
8875
  pubkey: o,
8900
8876
  nonce: f,
8901
8877
  token1_addr: e,
@@ -8907,7 +8883,7 @@ async function Kl(e, t, n, r, s, i) {
8907
8883
  token2FeeBps: l,
8908
8884
  btc_fee: d
8909
8885
  });
8910
- return await Yl({
8886
+ return await Zl({
8911
8887
  pubkey: o,
8912
8888
  token1_addr: e,
8913
8889
  token2_addr: t,
@@ -8924,12 +8900,12 @@ async function Kl(e, t, n, r, s, i) {
8924
8900
  async function or(e, t) {
8925
8901
  const n = await Jt();
8926
8902
  if (n.fee_policy === null) {
8927
- const r = Or.get(tn());
8928
- throw new Error(r ?? ao);
8903
+ const r = Or.get(yn());
8904
+ throw new Error(r ?? oo);
8929
8905
  }
8930
- return $u(e, t, n.fee_policy);
8906
+ return Cu(e, t, n.fee_policy);
8931
8907
  }
8932
- async function Xl(e, t, n) {
8908
+ async function Kl(e, t, n) {
8933
8909
  const r = await Jt();
8934
8910
  await sr(e, t);
8935
8911
  const s = (await et())?.swapPubkey;
@@ -8938,7 +8914,7 @@ async function Xl(e, t, n) {
8938
8914
  const i = {
8939
8915
  balanceOf: Bn,
8940
8916
  reservesOf: Ue
8941
- }, o = await $t("swap"), { token1FeeBps: a, token2FeeBps: c } = await or(e, t), u = await il(
8917
+ }, o = await $t("swap"), { token1FeeBps: a, token2FeeBps: c } = await or(e, t), u = await sl(
8942
8918
  i,
8943
8919
  s,
8944
8920
  e,
@@ -8960,7 +8936,7 @@ async function Xl(e, t, n) {
8960
8936
  throw new Error("No data returned from swap request.");
8961
8937
  if (u.amounts.length < 2)
8962
8938
  throw new Error("Invalid amounts returned from swap request.");
8963
- const l = await wn(e), f = await wn(t), d = lo(
8939
+ const l = await hn(e), f = await hn(t), d = uo(
8964
8940
  e,
8965
8941
  r.wbtc_address,
8966
8942
  n,
@@ -8974,10 +8950,10 @@ async function Xl(e, t, n) {
8974
8950
  price_impact_bps: u.price_impact_bps,
8975
8951
  reserve_in: u.reserve_in,
8976
8952
  reserve_out: u.reserve_out,
8977
- fees: uo(n, u.amounts[1], a, c, o)
8953
+ fees: co(n, u.amounts[1], a, c, o)
8978
8954
  };
8979
8955
  }
8980
- async function zl(e) {
8956
+ async function Xl(e) {
8981
8957
  e.token1_addr = e.token1_addr.toLowerCase(), e.token2_addr = e.token2_addr.toLowerCase(), e.referrer_pubkey = e.referrer_pubkey?.startsWith("0x") ? e.referrer_pubkey.slice(2) : e.referrer_pubkey;
8982
8958
  const t = `Swap Order:
8983
8959
  Token 1 Address: ${e.token1_addr}
@@ -8993,10 +8969,10 @@ ${e.referrer_pubkey ? `Referrer Pubkey: ${e.referrer_pubkey}
8993
8969
  By signing this message, you authorize the creation of a swap order with the above parameters.`;
8994
8970
  return await Pe(t, "ordinals");
8995
8971
  }
8996
- async function Jl(e) {
8972
+ async function zl(e) {
8997
8973
  e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey, e.referrer_pubkey = e.referrer_pubkey?.startsWith("0x") ? e.referrer_pubkey.slice(2) : e.referrer_pubkey;
8998
8974
  let t = tt(B.from(e.pubkey, "hex")).slice(2);
8999
- t += e.nonce.toString(16).padStart(8, "0"), t += "03", t += e.token1_addr.slice(2).padStart(64, "0"), t += e.token2_addr.slice(2).padStart(64, "0"), t += e.in_amt.toString(16).padStart(64, "0"), t += e.min_out_amt.toString(16).padStart(64, "0"), t += e.token1FeeBps.toString(16).padStart(64, "0"), t += e.token2FeeBps.toString(16).padStart(64, "0"), t += e.btc_fee.toString(16).padStart(64, "0"), e.referrer_pubkey && (t += tt(B.from(e.referrer_pubkey, "hex")).slice(2), t += wo.toString(16).padStart(8, "0"), e.ref_return_bps && e.ref_return_bps > 0n && (t += e.ref_return_bps.toString(16).padStart(8, "0")));
8975
+ t += e.nonce.toString(16).padStart(8, "0"), t += "03", t += e.token1_addr.slice(2).padStart(64, "0"), t += e.token2_addr.slice(2).padStart(64, "0"), t += e.in_amt.toString(16).padStart(64, "0"), t += e.min_out_amt.toString(16).padStart(64, "0"), t += e.token1FeeBps.toString(16).padStart(64, "0"), t += e.token2FeeBps.toString(16).padStart(64, "0"), t += e.btc_fee.toString(16).padStart(64, "0"), e.referrer_pubkey && (t += tt(B.from(e.referrer_pubkey, "hex")).slice(2), t += ho.toString(16).padStart(8, "0"), e.ref_return_bps && e.ref_return_bps > 0n && (t += e.ref_return_bps.toString(16).padStart(8, "0")));
9000
8976
  const n = B.from(t, "hex"), r = T.G1.hashToCurve(n, {
9001
8977
  DST: "BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"
9002
8978
  }), s = await et();
@@ -9005,9 +8981,9 @@ async function Jl(e) {
9005
8981
  const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = B.from(i, "hex"), a = T.shortSignatures.sign(r, o);
9006
8982
  return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
9007
8983
  }
9008
- async function jl(e) {
9009
- const t = z("swap");
9010
- return X(t, {
8984
+ async function Jl(e) {
8985
+ const t = await K("swap");
8986
+ return z(t, {
9011
8987
  method: "POST",
9012
8988
  headers: {
9013
8989
  "Content-Type": "application/json"
@@ -9015,12 +8991,12 @@ async function jl(e) {
9015
8991
  body: JSON.stringify(e)
9016
8992
  });
9017
8993
  }
9018
- async function Ql(e, t, n, r, s, i) {
8994
+ async function jl(e, t, n, r, s, i) {
9019
8995
  const o = (await et())?.swapPubkey;
9020
8996
  if (!o)
9021
8997
  throw new Error("Smart wallet not found. Please generate a smart wallet first.");
9022
8998
  await sr(e, t);
9023
- const a = r * (10000n - s) / 10000n, c = await qe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await or(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await zl({
8999
+ const a = r * (10000n - s) / 10000n, c = await qe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await or(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await Xl({
9024
9000
  token1_addr: e,
9025
9001
  token2_addr: t,
9026
9002
  in_amt: n.toString(),
@@ -9030,7 +9006,7 @@ async function Ql(e, t, n, r, s, i) {
9030
9006
  btc_fee: u.toString(),
9031
9007
  referrer_pubkey: d,
9032
9008
  ref_return_bps: p ? p.toString() : void 0
9033
- }), h = await Jl({
9009
+ }), h = await zl({
9034
9010
  pubkey: o,
9035
9011
  nonce: c,
9036
9012
  token1_addr: e,
@@ -9043,7 +9019,7 @@ async function Ql(e, t, n, r, s, i) {
9043
9019
  referrer_pubkey: d,
9044
9020
  ref_return_bps: p
9045
9021
  });
9046
- return await jl({
9022
+ return await Jl({
9047
9023
  pubkey: o,
9048
9024
  token1_addr: e,
9049
9025
  token2_addr: t,
@@ -9058,7 +9034,7 @@ async function Ql(e, t, n, r, s, i) {
9058
9034
  referrer_id: d ? i : void 0
9059
9035
  });
9060
9036
  }
9061
- async function tf(e, t, n) {
9037
+ async function Ql(e, t, n) {
9062
9038
  const r = await Jt();
9063
9039
  await sr(e, t);
9064
9040
  const s = (await et())?.swapPubkey;
@@ -9067,7 +9043,7 @@ async function tf(e, t, n) {
9067
9043
  const i = {
9068
9044
  balanceOf: Bn,
9069
9045
  reservesOf: Ue
9070
- }, o = await $t("swap"), { token1FeeBps: a, token2FeeBps: c } = await or(e, t), u = await al(
9046
+ }, o = await $t("swap"), { token1FeeBps: a, token2FeeBps: c } = await or(e, t), u = await ol(
9071
9047
  i,
9072
9048
  s,
9073
9049
  e,
@@ -9089,7 +9065,7 @@ async function tf(e, t, n) {
9089
9065
  throw new Error("No data returned from swap request.");
9090
9066
  if (u.amounts.length < 2)
9091
9067
  throw new Error("Invalid data returned from swap request.");
9092
- const l = await wn(e), f = await wn(t), d = lo(
9068
+ const l = await hn(e), f = await hn(t), d = uo(
9093
9069
  e,
9094
9070
  r.wbtc_address,
9095
9071
  u.amounts[0],
@@ -9103,10 +9079,10 @@ async function tf(e, t, n) {
9103
9079
  price_impact_bps: u.price_impact_bps,
9104
9080
  reserve_in: u.reserve_in,
9105
9081
  reserve_out: u.reserve_out,
9106
- fees: uo(u.amounts[0], n, a, c, o)
9082
+ fees: co(u.amounts[0], n, a, c, o)
9107
9083
  };
9108
9084
  }
9109
- async function ef(e) {
9085
+ async function tf(e) {
9110
9086
  e.token1_addr = e.token1_addr.toLowerCase(), e.token2_addr = e.token2_addr.toLowerCase(), e.referrer_pubkey = e.referrer_pubkey?.startsWith("0x") ? e.referrer_pubkey.slice(2) : e.referrer_pubkey;
9111
9087
  const t = `Swap Order:
9112
9088
  Token 1 Address: ${e.token1_addr}
@@ -9122,10 +9098,10 @@ ${e.referrer_pubkey ? `Referrer Pubkey: ${e.referrer_pubkey}
9122
9098
  By signing this message, you authorize the creation of a swap order with the above parameters.`;
9123
9099
  return await Pe(t, "ordinals");
9124
9100
  }
9125
- async function nf(e) {
9101
+ async function ef(e) {
9126
9102
  e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey, e.referrer_pubkey = e.referrer_pubkey?.startsWith("0x") ? e.referrer_pubkey.slice(2) : e.referrer_pubkey;
9127
9103
  let t = tt(B.from(e.pubkey, "hex")).slice(2);
9128
- t += e.nonce.toString(16).padStart(8, "0"), t += "04", t += e.token1_addr.slice(2).padStart(64, "0"), t += e.token2_addr.slice(2).padStart(64, "0"), t += e.max_in_amt.toString(16).padStart(64, "0"), t += e.out_amt.toString(16).padStart(64, "0"), t += e.token1FeeBps.toString(16).padStart(64, "0"), t += e.token2FeeBps.toString(16).padStart(64, "0"), t += e.btc_fee.toString(16).padStart(64, "0"), e.referrer_pubkey && (t += tt(B.from(e.referrer_pubkey, "hex")).slice(2), t += wo.toString(16).padStart(8, "0"), e.ref_return_bps && e.ref_return_bps > 0n && (t += e.ref_return_bps.toString(16).padStart(8, "0")));
9104
+ t += e.nonce.toString(16).padStart(8, "0"), t += "04", t += e.token1_addr.slice(2).padStart(64, "0"), t += e.token2_addr.slice(2).padStart(64, "0"), t += e.max_in_amt.toString(16).padStart(64, "0"), t += e.out_amt.toString(16).padStart(64, "0"), t += e.token1FeeBps.toString(16).padStart(64, "0"), t += e.token2FeeBps.toString(16).padStart(64, "0"), t += e.btc_fee.toString(16).padStart(64, "0"), e.referrer_pubkey && (t += tt(B.from(e.referrer_pubkey, "hex")).slice(2), t += ho.toString(16).padStart(8, "0"), e.ref_return_bps && e.ref_return_bps > 0n && (t += e.ref_return_bps.toString(16).padStart(8, "0")));
9129
9105
  const n = B.from(t, "hex"), r = T.G1.hashToCurve(n, {
9130
9106
  DST: "BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"
9131
9107
  }), s = await et();
@@ -9134,9 +9110,9 @@ async function nf(e) {
9134
9110
  const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = B.from(i, "hex"), a = T.shortSignatures.sign(r, o);
9135
9111
  return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
9136
9112
  }
9137
- async function rf(e) {
9138
- const t = z("swap2");
9139
- return X(t, {
9113
+ async function nf(e) {
9114
+ const t = await K("swap2");
9115
+ return z(t, {
9140
9116
  method: "POST",
9141
9117
  headers: {
9142
9118
  "Content-Type": "application/json"
@@ -9144,12 +9120,12 @@ async function rf(e) {
9144
9120
  body: JSON.stringify(e)
9145
9121
  });
9146
9122
  }
9147
- async function sf(e, t, n, r, s, i) {
9123
+ async function rf(e, t, n, r, s, i) {
9148
9124
  const o = (await et())?.swapPubkey;
9149
9125
  if (!o)
9150
9126
  throw new Error("Smart wallet not found. Please generate a smart wallet first.");
9151
9127
  await sr(e, t);
9152
- const a = n * (10000n + s) / 10000n, c = await qe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await or(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await ef({
9128
+ const a = n * (10000n + s) / 10000n, c = await qe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await or(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await tf({
9153
9129
  token1_addr: e,
9154
9130
  token2_addr: t,
9155
9131
  max_in_amt: a.toString(),
@@ -9159,7 +9135,7 @@ async function sf(e, t, n, r, s, i) {
9159
9135
  btc_fee: u.toString(),
9160
9136
  referrer_pubkey: d,
9161
9137
  ref_return_bps: p ? p.toString() : void 0
9162
- }), h = await nf({
9138
+ }), h = await ef({
9163
9139
  pubkey: o,
9164
9140
  nonce: c,
9165
9141
  token1_addr: e,
@@ -9172,7 +9148,7 @@ async function sf(e, t, n, r, s, i) {
9172
9148
  referrer_pubkey: d,
9173
9149
  ref_return_bps: p
9174
9150
  });
9175
- return await rf({
9151
+ return await nf({
9176
9152
  pubkey: o,
9177
9153
  token1_addr: e,
9178
9154
  token2_addr: t,
@@ -9187,11 +9163,11 @@ async function sf(e, t, n, r, s, i) {
9187
9163
  referrer_id: d ? i : void 0
9188
9164
  });
9189
9165
  }
9190
- function To(e) {
9166
+ function Oo(e) {
9191
9167
  const t = Xe();
9192
9168
  return `0x${tt(bn.address.toOutputScript(e, t)).slice(26)}`;
9193
9169
  }
9194
- async function Io(e) {
9170
+ async function To(e) {
9195
9171
  e.token_address = e.token_address.toLowerCase(), e.target_addr = e.target_addr.toLowerCase();
9196
9172
  const t = `Withdraw Order:
9197
9173
  Token Address: ${e.token_address}
@@ -9204,7 +9180,7 @@ BTC Fee: ${e.btc_fee}
9204
9180
  By signing this message, you authorize the creation of a withdraw order with the above parameters.`;
9205
9181
  return await Pe(t, "ordinals");
9206
9182
  }
9207
- async function Ro(e) {
9183
+ async function Io(e) {
9208
9184
  e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
9209
9185
  let t = tt(B.from(e.pubkey, "hex")).slice(2);
9210
9186
  t += e.nonce.toString(16).padStart(8, "0"), t += "05", t += e.token_addr.slice(2).padStart(40, "0"), t += e.target_addr.slice(2).padStart(40, "0"), t += e.amt.toString(16).padStart(64, "0"), t += e.btc_fee.toString(16).padStart(64, "0");
@@ -9216,9 +9192,9 @@ async function Ro(e) {
9216
9192
  const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = B.from(i, "hex"), a = T.shortSignatures.sign(r, o);
9217
9193
  return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
9218
9194
  }
9219
- async function ko(e) {
9220
- const t = z("withdraw");
9221
- return X(t, {
9195
+ async function Ro(e) {
9196
+ const t = await K("withdraw");
9197
+ return z(t, {
9222
9198
  method: "POST",
9223
9199
  headers: {
9224
9200
  "Content-Type": "application/json"
@@ -9226,18 +9202,18 @@ async function ko(e) {
9226
9202
  body: JSON.stringify(e)
9227
9203
  });
9228
9204
  }
9229
- async function of(e, t, n) {
9205
+ async function sf(e, t, n) {
9230
9206
  const r = (await et())?.swapPubkey;
9231
9207
  if (!r)
9232
9208
  throw new Error("Smart wallet not found. Please generate a smart wallet first.");
9233
- const i = To(t), o = 0n, a = 0n, c = await qe(), u = await $t("withdraw"), l = await Io({
9209
+ const i = Oo(t), o = 0n, a = 0n, c = await qe(), u = await $t("withdraw"), l = await To({
9234
9210
  token_address: e,
9235
9211
  target_addr: i,
9236
9212
  amt: n.toString(),
9237
9213
  token1FeeBps: o.toString(),
9238
9214
  token2FeeBps: a.toString(),
9239
9215
  btc_fee: u.toString()
9240
- }), f = await Ro({
9216
+ }), f = await Io({
9241
9217
  pubkey: r,
9242
9218
  nonce: c,
9243
9219
  token_addr: e,
@@ -9245,7 +9221,7 @@ async function of(e, t, n) {
9245
9221
  amt: n,
9246
9222
  btc_fee: u
9247
9223
  });
9248
- return await ko({
9224
+ return await Ro({
9249
9225
  pubkey: r,
9250
9226
  token_addr: e,
9251
9227
  target_addr: i,
@@ -9257,21 +9233,21 @@ async function of(e, t, n) {
9257
9233
  bip322_signature: l
9258
9234
  });
9259
9235
  }
9260
- async function af(e, t) {
9236
+ async function of(e, t) {
9261
9237
  const n = (await et())?.swapPubkey;
9262
9238
  if (!n)
9263
9239
  throw new Error("Smart wallet not found. Please generate a smart wallet first.");
9264
9240
  const r = Wt();
9265
9241
  if (!r || !r.address)
9266
9242
  throw new Error("Ordinals wallet not found. Please set up your ordinals wallet first.");
9267
- const s = r.address, i = To(s), o = 0n, a = 0n, c = await qe(), u = await $t("withdraw"), l = await Io({
9243
+ const s = r.address, i = Oo(s), o = 0n, a = 0n, c = await qe(), u = await $t("withdraw"), l = await To({
9268
9244
  token_address: e,
9269
9245
  target_addr: i,
9270
9246
  amt: t.toString(),
9271
9247
  token1FeeBps: o.toString(),
9272
9248
  token2FeeBps: a.toString(),
9273
9249
  btc_fee: u.toString()
9274
- }), f = await Ro({
9250
+ }), f = await Io({
9275
9251
  pubkey: n,
9276
9252
  nonce: c,
9277
9253
  token_addr: e,
@@ -9279,7 +9255,7 @@ async function af(e, t) {
9279
9255
  amt: t,
9280
9256
  btc_fee: u
9281
9257
  });
9282
- return await ko({
9258
+ return await Ro({
9283
9259
  pubkey: n,
9284
9260
  token_addr: e,
9285
9261
  target_addr: i,
@@ -9291,7 +9267,7 @@ async function af(e, t) {
9291
9267
  bip322_signature: l
9292
9268
  });
9293
9269
  }
9294
- async function cf(e, t) {
9270
+ async function af(e, t) {
9295
9271
  const n = await Jt();
9296
9272
  er(n.wbtc_address, n.factory_address);
9297
9273
  const r = (await et())?.swapPubkey;
@@ -9300,7 +9276,7 @@ async function cf(e, t) {
9300
9276
  const s = {
9301
9277
  balanceOf: Bn,
9302
9278
  reservesOf: Ue
9303
- }, i = await $t("unwrap"), o = await ul(
9279
+ }, i = await $t("unwrap"), o = await cl(
9304
9280
  s,
9305
9281
  r,
9306
9282
  e,
@@ -9317,7 +9293,7 @@ async function cf(e, t) {
9317
9293
  throw new Error("No data returned from unwrap request.");
9318
9294
  return { amt: o.data.amt };
9319
9295
  }
9320
- async function uf(e) {
9296
+ async function cf(e) {
9321
9297
  e.pkscript = e.pkscript.toLowerCase();
9322
9298
  const t = `Unwrap Order:
9323
9299
  Pkscript: ${e.pkscript}
@@ -9329,7 +9305,7 @@ BTC Fee: ${e.btc_fee}
9329
9305
  By signing this message, you authorize the creation of a withdraw order with the above parameters.`;
9330
9306
  return await Pe(t, "ordinals");
9331
9307
  }
9332
- async function lf(e) {
9308
+ async function uf(e) {
9333
9309
  e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
9334
9310
  let t = tt(B.from(e.pubkey, "hex")).slice(2);
9335
9311
  t += e.nonce.toString(16).padStart(8, "0"), t += "06", t += tt(B.from(e.pkscript, "hex")).slice(2), t += e.amt.toString(16).padStart(64, "0"), t += e.btc_fee.toString(16).padStart(64, "0");
@@ -9341,9 +9317,9 @@ async function lf(e) {
9341
9317
  const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = B.from(i, "hex"), a = T.shortSignatures.sign(r, o);
9342
9318
  return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
9343
9319
  }
9344
- async function ff(e) {
9345
- const t = z("unwrap");
9346
- return X(t, {
9320
+ async function lf(e) {
9321
+ const t = await K("unwrap");
9322
+ return z(t, {
9347
9323
  method: "POST",
9348
9324
  headers: {
9349
9325
  "Content-Type": "application/json"
@@ -9351,24 +9327,24 @@ async function ff(e) {
9351
9327
  body: JSON.stringify(e)
9352
9328
  });
9353
9329
  }
9354
- async function df(e, t) {
9330
+ async function ff(e, t) {
9355
9331
  const n = (await et())?.swapPubkey;
9356
9332
  if (!n)
9357
9333
  throw new Error("Smart wallet not found. Please generate a smart wallet first.");
9358
- const r = 0n, s = 0n, i = await qe(), o = await $t("unwrap"), a = await uf({
9334
+ const r = 0n, s = 0n, i = await qe(), o = await $t("unwrap"), a = await cf({
9359
9335
  pkscript: e,
9360
9336
  amt: t.toString(),
9361
9337
  token1FeeBps: r.toString(),
9362
9338
  token2FeeBps: s.toString(),
9363
9339
  btc_fee: o.toString()
9364
- }), c = await lf({
9340
+ }), c = await uf({
9365
9341
  pubkey: n,
9366
9342
  nonce: i,
9367
9343
  pkscript: e,
9368
9344
  amt: t,
9369
9345
  btc_fee: o
9370
9346
  });
9371
- return await ff({
9347
+ return await lf({
9372
9348
  pubkey: n,
9373
9349
  pkscript: e,
9374
9350
  amt: t.toString(),
@@ -9379,8 +9355,8 @@ async function df(e, t) {
9379
9355
  bip322_signature: a
9380
9356
  });
9381
9357
  }
9382
- async function pf(e, t, n, r, s) {
9383
- return await Nl({
9358
+ async function df(e, t, n, r, s) {
9359
+ return await kl({
9384
9360
  pubkey: e,
9385
9361
  pairAddress: t,
9386
9362
  limit: n,
@@ -9388,18 +9364,18 @@ async function pf(e, t, n, r, s) {
9388
9364
  kinds: s
9389
9365
  });
9390
9366
  }
9391
- async function hf(e, t, n) {
9392
- return await Tl({
9367
+ async function pf(e, t, n) {
9368
+ return await Ol({
9393
9369
  pair_address: e,
9394
9370
  limit: t || 20,
9395
9371
  offset: n || 0
9396
9372
  });
9397
9373
  }
9398
- async function wf(e) {
9399
- return await Rl(e);
9374
+ async function hf(e) {
9375
+ return await Il(e);
9400
9376
  }
9401
- async function gf(e, t, n, r, s) {
9402
- return (await Gl(
9377
+ async function wf(e, t, n, r, s) {
9378
+ return (await Wl(
9403
9379
  e,
9404
9380
  t,
9405
9381
  n,
@@ -9407,8 +9383,8 @@ async function gf(e, t, n, r, s) {
9407
9383
  s
9408
9384
  )).success;
9409
9385
  }
9410
- async function yf(e, t, n, r, s, i) {
9411
- return (await Kl(
9386
+ async function gf(e, t, n, r, s, i) {
9387
+ return (await Yl(
9412
9388
  e,
9413
9389
  t,
9414
9390
  n,
@@ -9417,8 +9393,8 @@ async function yf(e, t, n, r, s, i) {
9417
9393
  i
9418
9394
  )).success;
9419
9395
  }
9420
- async function bf(e, t, n, r, s, i) {
9421
- return (await Ql(
9396
+ async function yf(e, t, n, r, s, i) {
9397
+ return (await jl(
9422
9398
  e,
9423
9399
  t,
9424
9400
  n,
@@ -9427,8 +9403,8 @@ async function bf(e, t, n, r, s, i) {
9427
9403
  i
9428
9404
  )).success;
9429
9405
  }
9430
- async function mf(e, t, n, r, s, i) {
9431
- return (await sf(
9406
+ async function bf(e, t, n, r, s, i) {
9407
+ return (await rf(
9432
9408
  e,
9433
9409
  t,
9434
9410
  n,
@@ -9437,11 +9413,11 @@ async function mf(e, t, n, r, s, i) {
9437
9413
  i
9438
9414
  )).success;
9439
9415
  }
9440
- async function _f(e, t) {
9441
- return (await df(e, t)).success;
9416
+ async function mf(e, t) {
9417
+ return (await ff(e, t)).success;
9442
9418
  }
9443
- async function xf(e, t, n, r = !0, s, i) {
9444
- return await $l(
9419
+ async function _f(e, t, n, r = !0, s, i) {
9420
+ return await Cl(
9445
9421
  e,
9446
9422
  t,
9447
9423
  n,
@@ -9450,70 +9426,70 @@ async function xf(e, t, n, r = !0, s, i) {
9450
9426
  i
9451
9427
  );
9452
9428
  }
9453
- async function Ef(e, t, n) {
9454
- return await Fl(e, t, n);
9429
+ async function xf(e, t, n) {
9430
+ return await Pl(e, t, n);
9455
9431
  }
9456
- async function Sf(e, t, n) {
9457
- return n ? (await of(e, n, t)).success : (await af(e, t)).success;
9432
+ async function Ef(e, t, n) {
9433
+ return n ? (await sf(e, n, t)).success : (await of(e, t)).success;
9458
9434
  }
9459
- const Zf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9435
+ const Vf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9460
9436
  __proto__: null,
9461
- addLiquidity: gf,
9462
- createSwapWallet: bo,
9463
- deposit: xf,
9464
- ensureSwapWallet: wl,
9465
- getActivityOfPair: hf,
9466
- getAddLiquidityResult: ql,
9467
- getKlines: vl,
9437
+ addLiquidity: wf,
9438
+ createSwapWallet: yo,
9439
+ deposit: _f,
9440
+ ensureSwapWallet: hl,
9441
+ getActivityOfPair: pf,
9442
+ getAddLiquidityResult: Ul,
9443
+ getKlines: Bl,
9468
9444
  getMinerFee: $t,
9469
- getMinerFeesOfDepositOrder: Ll,
9470
- getMinerFeesOfWrapOrder: Ul,
9445
+ getMinerFeesOfDepositOrder: $l,
9446
+ getMinerFeesOfWrapOrder: Fl,
9471
9447
  getPairAddress: nr,
9472
9448
  getPairReserves: Ue,
9473
- getPairVolumeOverDays: Bl,
9474
- getRecentActivity: wf,
9475
- getRemoveLiquidityResult: Hl,
9476
- getSwapBalance: _l,
9477
- getSwapBalances: ml,
9478
- getSwapExactInputResult: Xl,
9479
- getSwapExactOutputResult: tf,
9449
+ getPairVolumeOverDays: Sl,
9450
+ getRecentActivity: hf,
9451
+ getRemoveLiquidityResult: Gl,
9452
+ getSwapBalance: ml,
9453
+ getSwapBalances: bl,
9454
+ getSwapExactInputResult: Kl,
9455
+ getSwapExactOutputResult: Ql,
9480
9456
  getSwapInfo: Jt,
9481
- getSwapStatus: yl,
9482
- getSwapWalletSecurityCode: gl,
9483
- getTokenDecimals: wn,
9484
- getTvlHistory: Ol,
9485
- getUnwrapBtcResult: cf,
9486
- getWalletActivities: pf,
9487
- importSwapWallet: hl,
9488
- listPairs: Sl,
9489
- listTokens: El,
9490
- removeLiquidity: yf,
9491
- satsToBtc: co,
9492
- satsToUsd: Pu,
9493
- swapExactInput: bf,
9494
- swapExactOutput: mf,
9495
- swapSide: Au,
9457
+ getSwapStatus: gl,
9458
+ getSwapWalletSecurityCode: wl,
9459
+ getTokenDecimals: hn,
9460
+ getTvlHistory: vl,
9461
+ getUnwrapBtcResult: af,
9462
+ getWalletActivities: df,
9463
+ importSwapWallet: pl,
9464
+ listPairs: El,
9465
+ listTokens: xl,
9466
+ removeLiquidity: gf,
9467
+ satsToBtc: ao,
9468
+ satsToUsd: Au,
9469
+ swapExactInput: yf,
9470
+ swapExactOutput: bf,
9471
+ swapSide: Lu,
9496
9472
  tryGetSwapReferrerInfo: Vr,
9497
- unwrapBtc: _f,
9498
- withdraw: Sf,
9499
- wrapBtc: Ef
9500
- }, Symbol.toStringTag, { value: "Module" })), Bf = "text/plain", No = /^[a-z0-9-]{6}$/i, vf = /^(?:[0-9a-f]{2})+$/i;
9473
+ unwrapBtc: mf,
9474
+ withdraw: Ef,
9475
+ wrapBtc: xf
9476
+ }, Symbol.toStringTag, { value: "Module" })), Sf = "text/plain", ko = /^[a-z0-9-]{6}$/i, Bf = /^(?:[0-9a-f]{2})+$/i;
9501
9477
  function Zr(e) {
9502
9478
  if (typeof e != "string" || e.length === 0)
9503
9479
  throw new Error("tick must be a non-empty string");
9504
9480
  return J.str(e).length;
9505
9481
  }
9506
9482
  function Tr(e, t) {
9507
- if (typeof e != "string" || !vf.test(e))
9483
+ if (typeof e != "string" || !Bf.test(e))
9508
9484
  throw new Error(`${t} must be a non-empty hex string`);
9509
9485
  }
9510
9486
  function Vn(e, t) {
9511
9487
  if (typeof e != "string" || e.length === 0)
9512
9488
  throw new Error(`${t} must be a non-empty string`);
9513
9489
  }
9514
- function gn(e) {
9490
+ function wn(e) {
9515
9491
  return new ce(
9516
- J.str(Bf),
9492
+ J.str(Sf),
9517
9493
  null,
9518
9494
  null,
9519
9495
  null,
@@ -9521,7 +9497,7 @@ function gn(e) {
9521
9497
  J.str(JSON.stringify(e))
9522
9498
  );
9523
9499
  }
9524
- function Co(e, t, n) {
9500
+ function No(e, t, n) {
9525
9501
  Vn(e.max, "max"), e.lim != null && Vn(e.lim, "lim");
9526
9502
  const r = t === 5 || n != null;
9527
9503
  if (r && e.selfMint === !1)
@@ -9531,36 +9507,36 @@ function Co(e, t, n) {
9531
9507
  const s = r || e.selfMint === !0, i = { p: "brc-20", op: "deploy", tick: e.tick };
9532
9508
  return n != null && (i.salt = n), i.max = e.max, e.lim != null && (i.lim = e.lim), e.dec != null && (i.dec = String(e.dec)), s && (i.self_mint = "true"), i;
9533
9509
  }
9534
- function Of(e) {
9510
+ function vf(e) {
9535
9511
  const t = Zr(e.tick);
9536
9512
  if (t === 6)
9537
9513
  throw new Error("6-byte tickers require a predeploy; use predeployInscriptions()");
9538
9514
  if (t !== 4 && t !== 5)
9539
9515
  throw new Error(`deploy ticker must be 4 or 5 bytes, got ${t}`);
9540
- return gn(Co(e, t, null));
9516
+ return wn(No(e, t, null));
9541
9517
  }
9542
- function Tf(e) {
9518
+ function Of(e) {
9543
9519
  const t = Zr(e.tick);
9544
9520
  if (t < 4 || t > 6) throw new Error(`ticker must be 4-6 bytes, got ${t}`);
9545
- return Vn(e.amt, "amt"), gn({ p: "brc-20", op: "mint", tick: e.tick, amt: e.amt });
9521
+ return Vn(e.amt, "amt"), wn({ p: "brc-20", op: "mint", tick: e.tick, amt: e.amt });
9546
9522
  }
9547
- function If(e) {
9523
+ function Tf(e) {
9548
9524
  const t = Zr(e.tick);
9549
9525
  if (t < 4 || t > 6) throw new Error(`ticker must be 4-6 bytes, got ${t}`);
9550
- return Vn(e.amt, "amt"), gn({ p: "brc-20", op: "transfer", tick: e.tick, amt: e.amt });
9526
+ return Vn(e.amt, "amt"), wn({ p: "brc-20", op: "transfer", tick: e.tick, amt: e.amt });
9551
9527
  }
9552
- function $o(e = 16) {
9528
+ function Co(e = 16) {
9553
9529
  if (!Number.isInteger(e) || e <= 0)
9554
9530
  throw new Error("byteLength must be a positive integer");
9555
9531
  return J.random(e).hex;
9556
9532
  }
9557
- function Rf(e) {
9533
+ function If(e) {
9558
9534
  if (typeof e != "string" || e.length === 0)
9559
9535
  throw new Error("address must be a non-empty string");
9560
9536
  return bn.address.toOutputScript(e, Xe()).toString("hex");
9561
9537
  }
9562
- function Lo(e, t, n) {
9563
- if (typeof e != "string" || !No.test(e))
9538
+ function $o(e, t, n) {
9539
+ if (typeof e != "string" || !ko.test(e))
9564
9540
  throw new Error("6-byte ticker must match /^[A-Za-z0-9-]{6}$/");
9565
9541
  Tr(t, "salt"), Tr(n, "pkscript");
9566
9542
  const r = B.concat([
@@ -9570,12 +9546,12 @@ function Lo(e, t, n) {
9570
9546
  ]);
9571
9547
  return bn.crypto.hash256(r).toString("hex");
9572
9548
  }
9573
- function kf(e) {
9574
- if (typeof e.tick != "string" || !No.test(e.tick))
9549
+ function Rf(e) {
9550
+ if (typeof e.tick != "string" || !ko.test(e.tick))
9575
9551
  throw new Error("6-byte ticker must match /^[A-Za-z0-9-]{6}$/");
9576
- const t = Rf(e.address), n = e.salt ?? $o();
9552
+ const t = If(e.address), n = e.salt ?? Co();
9577
9553
  Tr(n, "salt");
9578
- const r = Lo(e.tick, n, t), s = Co(
9554
+ const r = $o(e.tick, n, t), s = No(
9579
9555
  { tick: e.tick, max: e.max, lim: e.lim, dec: e.dec },
9580
9556
  6,
9581
9557
  n
@@ -9583,13 +9559,13 @@ function kf(e) {
9583
9559
  return {
9584
9560
  salt: n,
9585
9561
  hash: r,
9586
- predeploy: gn({ p: "brc-20", op: "predeploy", hash: r }),
9587
- deploy: gn(s)
9562
+ predeploy: wn({ p: "brc-20", op: "predeploy", hash: r }),
9563
+ deploy: wn(s)
9588
9564
  };
9589
9565
  }
9590
- async function Ao(e, t, n, r, s, i, o, a, c) {
9566
+ async function Lo(e, t, n, r, s, i, o, a, c) {
9591
9567
  if (!c || c === "ordinals")
9592
- return await Zo(
9568
+ return await Vo(
9593
9569
  e,
9594
9570
  t,
9595
9571
  n,
@@ -9601,7 +9577,7 @@ async function Ao(e, t, n, r, s, i, o, a, c) {
9601
9577
  o
9602
9578
  );
9603
9579
  if (c === "payment")
9604
- return await Yo(
9580
+ return await Zo(
9605
9581
  e,
9606
9582
  t,
9607
9583
  n,
@@ -9614,12 +9590,12 @@ async function Ao(e, t, n, r, s, i, o, a, c) {
9614
9590
  );
9615
9591
  throw new Error(`Unsupported wallet type: ${c}`);
9616
9592
  }
9617
- async function Nf(e, t, n, r, s, i, o, a, c, u, l) {
9593
+ async function kf(e, t, n, r, s, i, o, a, c, u, l) {
9618
9594
  if (typeof t != "object") throw new Error("abi must be an object");
9619
9595
  if (typeof n != "string") throw new Error("func_name must be a string");
9620
9596
  if (!Array.isArray(r)) throw new Error("params must be an array");
9621
- const f = l || "payment", d = Ko(t, n, r);
9622
- return await Ao(
9597
+ const f = l || "payment", d = Yo(t, n, r);
9598
+ return await Lo(
9623
9599
  e,
9624
9600
  d,
9625
9601
  s,
@@ -9631,8 +9607,8 @@ async function Nf(e, t, n, r, s, i, o, a, c, u, l) {
9631
9607
  f
9632
9608
  );
9633
9609
  }
9634
- async function Cf(e, t, n, r, s, i) {
9635
- return await Xo(
9610
+ async function Nf(e, t, n, r, s, i) {
9611
+ return await Ko(
9636
9612
  e,
9637
9613
  t,
9638
9614
  n,
@@ -9642,8 +9618,8 @@ async function Cf(e, t, n, r, s, i) {
9642
9618
  s
9643
9619
  );
9644
9620
  }
9645
- async function $f(e, t, n, r, s, i, o) {
9646
- return await zo(
9621
+ async function Cf(e, t, n, r, s, i, o) {
9622
+ return await Xo(
9647
9623
  e,
9648
9624
  t,
9649
9625
  n,
@@ -9654,20 +9630,20 @@ async function $f(e, t, n, r, s, i, o) {
9654
9630
  i
9655
9631
  );
9656
9632
  }
9657
- const Yf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9633
+ const Zf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9658
9634
  __proto__: null,
9659
- callSmartContract: Ao,
9660
- callSmartContractAbi: Nf,
9661
- computeBrc20PredeployHash: Lo,
9662
- deployBrc20Inscription: Of,
9663
- depositToBrc20Prog: Cf,
9664
- generateBrc20Salt: $o,
9665
- mintBrc20Inscription: Tf,
9666
- predeployInscriptions: kf,
9667
- transferBrc20Inscription: If,
9668
- withdrawFromBrc20Prog: $f
9635
+ callSmartContract: Lo,
9636
+ callSmartContractAbi: kf,
9637
+ computeBrc20PredeployHash: $o,
9638
+ deployBrc20Inscription: vf,
9639
+ depositToBrc20Prog: Nf,
9640
+ generateBrc20Salt: Co,
9641
+ mintBrc20Inscription: Of,
9642
+ predeployInscriptions: Rf,
9643
+ transferBrc20Inscription: Tf,
9644
+ withdrawFromBrc20Prog: Cf
9669
9645
  }, Symbol.toStringTag, { value: "Module" }));
9670
- async function Lf(e, t, n, r, s) {
9646
+ async function $f(e, t, n, r, s) {
9671
9647
  const i = await Qs(
9672
9648
  [e],
9673
9649
  t,
@@ -9685,11 +9661,11 @@ async function Lf(e, t, n, r, s) {
9685
9661
  secret: i.secret
9686
9662
  };
9687
9663
  }
9688
- async function Af(e, t, n, r, s) {
9664
+ async function Lf(e, t, n, r, s) {
9689
9665
  return await Qs(e, t, n, r, s);
9690
9666
  }
9691
- async function Pf(e, t, n, r, s, i) {
9692
- return await Jo(
9667
+ async function Af(e, t, n, r, s, i) {
9668
+ return await zo(
9693
9669
  e,
9694
9670
  t,
9695
9671
  n,
@@ -9698,20 +9674,20 @@ async function Pf(e, t, n, r, s, i) {
9698
9674
  i
9699
9675
  );
9700
9676
  }
9701
- async function Ff(e, t, n, r) {
9677
+ async function Pf(e, t, n, r) {
9702
9678
  return await ti([e], t, n, r);
9703
9679
  }
9704
- async function Uf(e, t, n, r) {
9680
+ async function Ff(e, t, n, r) {
9705
9681
  return await ti(e, t, n, r);
9706
9682
  }
9707
- const Kf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9683
+ const Yf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9708
9684
  __proto__: null,
9709
- getInscribeFee: Ff,
9710
- getInscribeMultipleFee: Uf,
9711
- inscribe: Lf,
9712
- inscribeMultiple: Af,
9713
- inscribeWithParent: Pf
9714
- }, Symbol.toStringTag, { value: "Module" })), Po = [
9685
+ getInscribeFee: Pf,
9686
+ getInscribeMultipleFee: Ff,
9687
+ inscribe: $f,
9688
+ inscribeMultiple: Lf,
9689
+ inscribeWithParent: Af
9690
+ }, Symbol.toStringTag, { value: "Module" })), Ao = [
9715
9691
  { inputs: [], stateMutability: "nonpayable", type: "constructor" },
9716
9692
  {
9717
9693
  inputs: [{ internalType: "address", name: "owner", type: "address" }],
@@ -9868,9 +9844,9 @@ const Kf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9868
9844
  stateMutability: "nonpayable",
9869
9845
  type: "function"
9870
9846
  }
9871
- ], Fo = "0xc54dd4581af2dbf18e4d90840226756e9d2b3cdb";
9872
- async function qf(e, t) {
9873
- const n = t.toUpperCase(), r = ei("check_base_brc20_balance"), i = await ni(r, {
9847
+ ], Po = "0xc54dd4581af2dbf18e4d90840226756e9d2b3cdb";
9848
+ async function Uf(e, t) {
9849
+ const n = t.toUpperCase(), r = await K("check_base_brc20_balance"), i = await ei(r, {
9874
9850
  method: "POST",
9875
9851
  headers: {
9876
9852
  "Content-Type": "application/json"
@@ -9887,8 +9863,8 @@ async function qf(e, t) {
9887
9863
  ticker: i.result.ticker
9888
9864
  };
9889
9865
  }
9890
- async function Df(e, t) {
9891
- const n = ei("check_brc20_balance"), s = await ni(n, {
9866
+ async function qf(e, t) {
9867
+ const n = await K("check_brc20_balance"), s = await ei(n, {
9892
9868
  method: "POST",
9893
9869
  headers: {
9894
9870
  "Content-Type": "application/json"
@@ -9900,35 +9876,35 @@ async function Df(e, t) {
9900
9876
  });
9901
9877
  return BigInt(s.result);
9902
9878
  }
9903
- async function Mf(e, t) {
9904
- const n = B.from(t, "utf-8"), r = await ri(
9905
- Fo,
9879
+ async function Df(e, t) {
9880
+ const n = B.from(t, "utf-8"), r = await ni(
9906
9881
  Po,
9882
+ Ao,
9907
9883
  "balanceOf",
9908
- [n, jo(e)]
9884
+ [n, Jo(e)]
9909
9885
  );
9910
9886
  return BigInt(r);
9911
9887
  }
9912
- async function Wf(e) {
9888
+ async function Mf(e) {
9913
9889
  const t = B.from(e, "utf-8");
9914
- return `0x${(await ri(
9915
- Fo,
9890
+ return `0x${(await ni(
9916
9891
  Po,
9892
+ Ao,
9917
9893
  "getTickerAddress",
9918
9894
  [t]
9919
9895
  )).slice(-40)}`;
9920
9896
  }
9921
- const Xf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9897
+ const Kf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9922
9898
  __proto__: null,
9923
- getBRC20ProgBalanceOfAddress: Df,
9924
- getBRC20ProgBalanceOfTicker: Mf,
9925
- getBRC20ProgTokenAddressOfTicker: Wf,
9926
- getBaseBRC20BalanceOfAddress: qf
9899
+ getBRC20ProgBalanceOfAddress: qf,
9900
+ getBRC20ProgBalanceOfTicker: Df,
9901
+ getBRC20ProgTokenAddressOfTicker: Mf,
9902
+ getBaseBRC20BalanceOfAddress: Uf
9927
9903
  }, Symbol.toStringTag, { value: "Module" }));
9928
9904
  export {
9929
- Zf as a,
9930
- Yf as b,
9931
- Xf as c,
9932
- Kf as m,
9933
- Vf as s
9905
+ Vf as a,
9906
+ Zf as b,
9907
+ Kf as c,
9908
+ Yf as m,
9909
+ Hf as s
9934
9910
  };