@bestinslot/wallet-kit 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{balances-_-oF5kR6.js → balances-HcqAUOXv.js} +898 -896
- package/dist/browser.js +5 -5
- package/dist/core.js +5 -5
- package/dist/{mint-Dm67SjcM.js → mint-A-bG5QIH.js} +148 -136
- package/dist/node.js +4 -4
- package/dist/react.js +1 -1
- package/dist/{register-browser-providers-BTO9Kyf2.js → register-browser-providers-DoWxih1t.js} +1 -1
- package/dist/types/core/helpers.d.ts +18 -1
- package/dist/types/core/mint.d.ts +18 -2
- package/dist/vue.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as wn, U as Ir, V as qo, X as Do, Y as Mo, G as S, e as Wt, l as zr, Z as Ys, _ as Rr, O as ze, f as Hn, H as Ft, $ as Ke, a0 as X, a1 as ae, a2 as zs, a3 as Wo, a4 as Kr, a5 as Pt, a6 as me, a7 as Nn, a8 as Yt, a9 as Ln, aa as Ks, d as Qe, D as gn,
|
|
2
|
-
async function
|
|
1
|
+
import { h as wn, U as Ir, V as qo, X as Do, Y as Mo, G as S, e as Wt, l as zr, Z as Ys, _ as Rr, O as ze, f as Hn, H as Ft, $ as Ke, a0 as X, a1 as ae, a2 as zs, a3 as Wo, a4 as Kr, a5 as Pt, a6 as me, a7 as Nn, a8 as Yt, a9 as Ln, aa as Ks, ab as Go, d as Qe, D as gn, ac as Ho, ad as Xr, ae as Cn, af as Xs, k as Le, ag as Vo, ah as Zo, ai as Yo, aj as zo, ak as Ko, al as Js, am as Xo, an as js, ao as Qs, ap as ti, aq as ei, p as Jo } from "./mint-A-bG5QIH.js";
|
|
2
|
+
async function Df(e, t, n, r, s, i) {
|
|
3
3
|
const o = wn();
|
|
4
4
|
if (!o)
|
|
5
5
|
throw new Error("No wallet connected");
|
|
@@ -56,7 +56,7 @@ function An(e, t = !0) {
|
|
|
56
56
|
if (t && e.finished)
|
|
57
57
|
throw new Error("Hash#digest() has already been called");
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function jo(e, t) {
|
|
60
60
|
lt(e, void 0, "digestInto() output");
|
|
61
61
|
const n = t.outputLen;
|
|
62
62
|
if (e.length < n)
|
|
@@ -72,13 +72,13 @@ function ur(e) {
|
|
|
72
72
|
function Ht(e, t) {
|
|
73
73
|
return e << 32 - t | e >>> t;
|
|
74
74
|
}
|
|
75
|
-
const ri = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function",
|
|
75
|
+
const ri = /* @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
76
|
function cn(e) {
|
|
77
77
|
if (lt(e), ri)
|
|
78
78
|
return e.toHex();
|
|
79
79
|
let t = "";
|
|
80
80
|
for (let n = 0; n < e.length; n++)
|
|
81
|
-
t +=
|
|
81
|
+
t += Qo[e[n]];
|
|
82
82
|
return t;
|
|
83
83
|
}
|
|
84
84
|
const ee = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
@@ -122,7 +122,7 @@ function wt(...e) {
|
|
|
122
122
|
}
|
|
123
123
|
return n;
|
|
124
124
|
}
|
|
125
|
-
function
|
|
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
|
}
|
|
@@ -132,7 +132,7 @@ function si(e = 32) {
|
|
|
132
132
|
throw new Error("crypto.getRandomValues must be defined");
|
|
133
133
|
return t.getRandomValues(new Uint8Array(e));
|
|
134
134
|
}
|
|
135
|
-
const
|
|
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), Fn = /* @__PURE__ */ BigInt(1);
|
|
@@ -143,9 +143,9 @@ function jr(e, t = "") {
|
|
|
143
143
|
}
|
|
144
144
|
return e;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function na(e) {
|
|
147
147
|
if (typeof e == "bigint") {
|
|
148
|
-
if (!
|
|
148
|
+
if (!ra(e))
|
|
149
149
|
throw new Error("positive bigint expected, got " + e);
|
|
150
150
|
} else
|
|
151
151
|
Xe(e);
|
|
@@ -169,7 +169,7 @@ function oi(e) {
|
|
|
169
169
|
return ii(cn(ci(lt(e)).reverse()));
|
|
170
170
|
}
|
|
171
171
|
function mt(e, t) {
|
|
172
|
-
Xe(t), e =
|
|
172
|
+
Xe(t), e = na(e);
|
|
173
173
|
const n = Pn(e.toString(16).padStart(t * 2, "0"));
|
|
174
174
|
if (n.length !== t)
|
|
175
175
|
throw new Error("number too large");
|
|
@@ -189,14 +189,14 @@ function Vn(e) {
|
|
|
189
189
|
return r;
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
|
-
const
|
|
192
|
+
const ra = (e) => typeof e == "bigint" && Nr <= e;
|
|
193
193
|
function Un(e) {
|
|
194
194
|
let t;
|
|
195
195
|
for (t = 0; e > Nr; e >>= Fn, t += 1)
|
|
196
196
|
;
|
|
197
197
|
return t;
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function sa(e, t) {
|
|
200
200
|
return e >> BigInt(t) & Fn;
|
|
201
201
|
}
|
|
202
202
|
const yn = (e) => (Fn << BigInt(e)) - Fn;
|
|
@@ -217,7 +217,7 @@ function Cr(e, t = {}, n = {}) {
|
|
|
217
217
|
const ye = () => {
|
|
218
218
|
throw new Error("not implemented");
|
|
219
219
|
};
|
|
220
|
-
function
|
|
220
|
+
function _r(e) {
|
|
221
221
|
const t = /* @__PURE__ */ new WeakMap();
|
|
222
222
|
return (n, ...r) => {
|
|
223
223
|
const s = t.get(n);
|
|
@@ -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), Ie = /* @__PURE__ */ BigInt(2), ui = /* @__PURE__ */ BigInt(3), li = /* @__PURE__ */ BigInt(4), fi = /* @__PURE__ */ BigInt(5),
|
|
230
|
+
const Ct = /* @__PURE__ */ BigInt(0), Tt = /* @__PURE__ */ BigInt(1), Ie = /* @__PURE__ */ BigInt(2), ui = /* @__PURE__ */ BigInt(3), li = /* @__PURE__ */ BigInt(4), fi = /* @__PURE__ */ BigInt(5), ia = /* @__PURE__ */ BigInt(7), di = /* @__PURE__ */ BigInt(8), oa = /* @__PURE__ */ BigInt(9), pi = /* @__PURE__ */ BigInt(16);
|
|
231
231
|
function At(e, t) {
|
|
232
232
|
const n = e % t;
|
|
233
233
|
return n >= Ct ? n : t + n;
|
|
@@ -254,12 +254,12 @@ function hi(e, t) {
|
|
|
254
254
|
const n = (e.ORDER + Tt) / li, r = e.pow(t, n);
|
|
255
255
|
return $r(e, r, t), r;
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function aa(e, t) {
|
|
258
258
|
const n = (e.ORDER - fi) / di, r = e.mul(t, Ie), s = e.pow(r, n), i = e.mul(t, s), o = e.mul(e.mul(i, Ie), s), a = e.mul(i, e.sub(o, e.ONE));
|
|
259
259
|
return $r(e, a, t), a;
|
|
260
260
|
}
|
|
261
|
-
function
|
|
262
|
-
const t = bn(e), n = wi(e), r = n(t, t.neg(t.ONE)), s = n(t, r), i = n(t, t.neg(r)), o = (e +
|
|
261
|
+
function ca(e) {
|
|
262
|
+
const t = bn(e), n = wi(e), r = n(t, t.neg(t.ONE)), s = n(t, r), i = n(t, t.neg(r)), o = (e + ia) / pi;
|
|
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);
|
|
@@ -302,10 +302,10 @@ function wi(e) {
|
|
|
302
302
|
return p;
|
|
303
303
|
};
|
|
304
304
|
}
|
|
305
|
-
function
|
|
306
|
-
return e % li === ui ? hi : e % di === fi ?
|
|
305
|
+
function ua(e) {
|
|
306
|
+
return e % li === ui ? hi : e % di === fi ? aa : e % pi === oa ? ca(e) : wi(e);
|
|
307
307
|
}
|
|
308
|
-
const
|
|
308
|
+
const la = [
|
|
309
309
|
"create",
|
|
310
310
|
"isValid",
|
|
311
311
|
"is0",
|
|
@@ -329,7 +329,7 @@ function gi(e) {
|
|
|
329
329
|
ORDER: "bigint",
|
|
330
330
|
BYTES: "number",
|
|
331
331
|
BITS: "number"
|
|
332
|
-
}, n =
|
|
332
|
+
}, n = la.reduce((r, s) => (r[s] = "function", r), t);
|
|
333
333
|
return Cr(e, n), e;
|
|
334
334
|
}
|
|
335
335
|
function Zn(e, t, n) {
|
|
@@ -354,12 +354,12 @@ function qn(e, t) {
|
|
|
354
354
|
throw new Error("invalid Legendre symbol result");
|
|
355
355
|
return s ? 1 : i ? 0 : -1;
|
|
356
356
|
}
|
|
357
|
-
function
|
|
357
|
+
function fa(e, t) {
|
|
358
358
|
t !== void 0 && Xe(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
|
|
362
|
+
class da {
|
|
363
363
|
ORDER;
|
|
364
364
|
BITS;
|
|
365
365
|
BYTES;
|
|
@@ -375,7 +375,7 @@ class fa {
|
|
|
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 } =
|
|
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,7 +439,7 @@ class fa {
|
|
|
439
439
|
return Qr(t, this.ORDER);
|
|
440
440
|
}
|
|
441
441
|
sqrt(t) {
|
|
442
|
-
return this._sqrt || (this._sqrt =
|
|
442
|
+
return this._sqrt || (this._sqrt = ua(this.ORDER)), this._sqrt(this, t);
|
|
443
443
|
}
|
|
444
444
|
toBytes(t) {
|
|
445
445
|
return this.isLE ? ai(t, this.BYTES) : mt(t, this.BYTES);
|
|
@@ -471,7 +471,7 @@ class fa {
|
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
function bn(e, t = {}) {
|
|
474
|
-
return new
|
|
474
|
+
return new da(e, t);
|
|
475
475
|
}
|
|
476
476
|
function yi(e) {
|
|
477
477
|
if (typeof e != "bigint")
|
|
@@ -491,13 +491,13 @@ function mi(e, t, n = !1) {
|
|
|
491
491
|
const o = n ? oi(e) : zt(e), a = At(o, t - Tt) + Tt;
|
|
492
492
|
return n ? ai(a, s) : mt(a, s);
|
|
493
493
|
}
|
|
494
|
-
function
|
|
494
|
+
function pa(e, t, n) {
|
|
495
495
|
return e & t ^ ~e & n;
|
|
496
496
|
}
|
|
497
|
-
function
|
|
497
|
+
function ha(e, t, n) {
|
|
498
498
|
return e & t ^ e & n ^ t & n;
|
|
499
499
|
}
|
|
500
|
-
class
|
|
500
|
+
class wa {
|
|
501
501
|
blockLen;
|
|
502
502
|
outputLen;
|
|
503
503
|
padOffset;
|
|
@@ -528,7 +528,7 @@ class ha {
|
|
|
528
528
|
return this.length += t.length, this.roundClean(), this;
|
|
529
529
|
}
|
|
530
530
|
digestInto(t) {
|
|
531
|
-
An(this),
|
|
531
|
+
An(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
534
|
n[o++] = 128, an(this.buffer.subarray(o)), this.padOffset > s - o && (this.process(r, 0), o = 0);
|
|
@@ -568,7 +568,7 @@ const pe = /* @__PURE__ */ Uint32Array.from([
|
|
|
568
568
|
2600822924,
|
|
569
569
|
528734635,
|
|
570
570
|
1541459225
|
|
571
|
-
]),
|
|
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
|
|
637
|
+
class ya extends wa {
|
|
638
638
|
constructor(t) {
|
|
639
639
|
super(64, t, 8, !1);
|
|
640
640
|
}
|
|
@@ -655,7 +655,7 @@ class ga extends ha {
|
|
|
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 +
|
|
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);
|
|
@@ -667,7 +667,7 @@ class ga extends ha {
|
|
|
667
667
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), an(this.buffer);
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
|
-
class
|
|
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 ya extends ga {
|
|
|
682
682
|
super(32);
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
|
-
const
|
|
686
|
-
() => new
|
|
687
|
-
/* @__PURE__ */
|
|
685
|
+
const xi = /* @__PURE__ */ ta(
|
|
686
|
+
() => new ba(),
|
|
687
|
+
/* @__PURE__ */ ea(1)
|
|
688
688
|
);
|
|
689
689
|
const je = /* @__PURE__ */ BigInt(0), Re = /* @__PURE__ */ BigInt(1);
|
|
690
690
|
function Dn(e, t) {
|
|
@@ -695,12 +695,12 @@ function Mn(e, t) {
|
|
|
695
695
|
const n = Ae(e.Fp, t.map((r) => r.Z));
|
|
696
696
|
return t.map((r, s) => e.fromAffine(r.toAffine(n[s])));
|
|
697
697
|
}
|
|
698
|
-
function
|
|
698
|
+
function _i(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 lr(e, t) {
|
|
703
|
-
|
|
703
|
+
_i(e, t);
|
|
704
704
|
const n = Math.ceil(t / e) + 1, r = 2 ** (e - 1), s = 2 ** e, i = yn(e), o = BigInt(e);
|
|
705
705
|
return { windows: n, windowSize: r, mask: i, maxNumber: s, shiftBy: o };
|
|
706
706
|
}
|
|
@@ -719,7 +719,7 @@ function es(e) {
|
|
|
719
719
|
if (e !== je)
|
|
720
720
|
throw new Error("invalid wNAF");
|
|
721
721
|
}
|
|
722
|
-
class
|
|
722
|
+
class ma {
|
|
723
723
|
BASE;
|
|
724
724
|
ZERO;
|
|
725
725
|
Fn;
|
|
@@ -807,13 +807,13 @@ class ba {
|
|
|
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
|
-
|
|
810
|
+
_i(n, this.bits), Ei.set(t, n), fr.delete(t);
|
|
811
811
|
}
|
|
812
812
|
hasCache(t) {
|
|
813
813
|
return dr(t) !== 1;
|
|
814
814
|
}
|
|
815
815
|
}
|
|
816
|
-
function
|
|
816
|
+
function xa(e, t, n, r) {
|
|
817
817
|
let s = t, i = e.ZERO, o = e.ZERO;
|
|
818
818
|
for (; n > je || r > je; )
|
|
819
819
|
n & Re && (i = i.add(s)), r & Re && (o = o.add(s)), s = s.double(), n >>= Re, r >>= Re;
|
|
@@ -841,7 +841,7 @@ function _a(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
|
|
844
|
+
const Ea = zt;
|
|
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,7 +850,7 @@ function we(e, t) {
|
|
|
850
850
|
n[r] = e & 255, e >>>= 8;
|
|
851
851
|
return new Uint8Array(n);
|
|
852
852
|
}
|
|
853
|
-
function
|
|
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];
|
|
@@ -861,7 +861,7 @@ function Si(e) {
|
|
|
861
861
|
throw new Error("DST must be Uint8Array or ascii string");
|
|
862
862
|
return typeof e == "string" ? Vn(e) : e;
|
|
863
863
|
}
|
|
864
|
-
function
|
|
864
|
+
function Ba(e, t, n, r) {
|
|
865
865
|
lt(e), Je(n), t = Si(t), t.length > 255 && (t = r(wt(Vn("H2C-OVERSIZE-DST-"), t)));
|
|
866
866
|
const { outputLen: s, blockLen: i } = r, o = Math.ceil(n / s);
|
|
867
867
|
if (n > 65535 || o > 255)
|
|
@@ -869,12 +869,12 @@ function Sa(e, t, n, r) {
|
|
|
869
869
|
const a = wt(t, we(t.length, 1)), c = we(0, i), u = we(n, 2), l = new Array(o), f = r(wt(c, e, u, we(0, 1), a));
|
|
870
870
|
l[0] = r(wt(f, we(1, 1), a));
|
|
871
871
|
for (let p = 1; p <= o; p++) {
|
|
872
|
-
const w = [
|
|
872
|
+
const w = [Sa(f, l[p - 1]), we(p + 1, 1), a];
|
|
873
873
|
l[p] = r(wt(...w));
|
|
874
874
|
}
|
|
875
875
|
return wt(...l).slice(0, n);
|
|
876
876
|
}
|
|
877
|
-
function
|
|
877
|
+
function va(e, t, n, r, s) {
|
|
878
878
|
if (lt(e), Je(n), t = Si(t), t.length > 255) {
|
|
879
879
|
const i = Math.ceil(2 * r / 8);
|
|
880
880
|
t = s.create({ dkLen: i }).update(Vn("H2C-OVERSIZE-DST-")).update(t).digest();
|
|
@@ -895,9 +895,9 @@ function pr(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 =
|
|
898
|
+
d = Ba(e, c, f, o);
|
|
899
899
|
else if (a === "xof")
|
|
900
|
-
d =
|
|
900
|
+
d = va(e, c, f, s, o);
|
|
901
901
|
else if (a === "_internal_pass")
|
|
902
902
|
d = e;
|
|
903
903
|
else
|
|
@@ -906,8 +906,8 @@ function pr(e, t, n) {
|
|
|
906
906
|
for (let w = 0; w < t; w++) {
|
|
907
907
|
const h = new Array(i);
|
|
908
908
|
for (let g = 0; g < i; g++) {
|
|
909
|
-
const b = l * (g + w * i),
|
|
910
|
-
h[g] = At(
|
|
909
|
+
const b = l * (g + w * i), v = d.subarray(b, b + l);
|
|
910
|
+
h[g] = At(Ea(v), r);
|
|
911
911
|
}
|
|
912
912
|
p[w] = h;
|
|
913
913
|
}
|
|
@@ -920,7 +920,7 @@ function Bi(e, t) {
|
|
|
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
|
|
923
|
+
const Oa = Vn("HashToScalar-");
|
|
924
924
|
function rs(e, t, n) {
|
|
925
925
|
if (typeof t != "function")
|
|
926
926
|
throw new Error("mapToCurve() must be defined");
|
|
@@ -959,7 +959,7 @@ 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:
|
|
962
|
+
const a = e.Fn.ORDER, c = Object.assign({}, n, { p: a, m: 1, DST: Oa }, o);
|
|
963
963
|
return pr(i, 1, c)[0][0];
|
|
964
964
|
}
|
|
965
965
|
};
|
|
@@ -1009,7 +1009,7 @@ class vi {
|
|
|
1009
1009
|
const Lr = (e, t, n) => new vi(e, t).update(n).digest();
|
|
1010
1010
|
Lr.create = (e, t) => new vi(e, t);
|
|
1011
1011
|
const ss = (e, t) => (e + (e >= 0 ? t : -t) / ne) / t;
|
|
1012
|
-
function
|
|
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 < ke, d = l < ke;
|
|
@@ -1035,109 +1035,109 @@ function Oi(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 =
|
|
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()");
|
|
1042
1042
|
}
|
|
1043
|
-
function f(U, y,
|
|
1044
|
-
const { x:
|
|
1045
|
-
if (jr(
|
|
1043
|
+
function f(U, y, _) {
|
|
1044
|
+
const { x: B, y: N } = y.toAffine(), P = r.toBytes(B);
|
|
1045
|
+
if (jr(_, "isCompressed"), _) {
|
|
1046
1046
|
l();
|
|
1047
1047
|
const $ = !r.isOdd(N);
|
|
1048
|
-
return wt(
|
|
1048
|
+
return wt(Ia($), P);
|
|
1049
1049
|
} else
|
|
1050
|
-
return wt(Uint8Array.of(4),
|
|
1050
|
+
return wt(Uint8Array.of(4), P, r.toBytes(N));
|
|
1051
1051
|
}
|
|
1052
1052
|
function d(U) {
|
|
1053
1053
|
lt(U, void 0, "Point");
|
|
1054
|
-
const { publicKey: y, publicKeyUncompressed:
|
|
1055
|
-
if (
|
|
1056
|
-
const $ = r.fromBytes(
|
|
1054
|
+
const { publicKey: y, publicKeyUncompressed: _ } = u, B = U.length, N = U[0], P = U.subarray(1);
|
|
1055
|
+
if (B === y && (N === 2 || N === 3)) {
|
|
1056
|
+
const $ = r.fromBytes(P);
|
|
1057
1057
|
if (!r.isValid($))
|
|
1058
1058
|
throw new Error("bad point: is not on curve, wrong x");
|
|
1059
|
-
const
|
|
1059
|
+
const D = h($);
|
|
1060
1060
|
let L;
|
|
1061
1061
|
try {
|
|
1062
|
-
L = r.sqrt(
|
|
1062
|
+
L = r.sqrt(D);
|
|
1063
1063
|
} catch (at) {
|
|
1064
1064
|
const Q = at instanceof Error ? ": " + at.message : "";
|
|
1065
1065
|
throw new Error("bad point: is not on curve, sqrt error" + Q);
|
|
1066
1066
|
}
|
|
1067
1067
|
l();
|
|
1068
|
-
const
|
|
1069
|
-
return (N & 1) === 1 !==
|
|
1070
|
-
} else if (
|
|
1071
|
-
const $ = r.BYTES,
|
|
1072
|
-
if (!g(
|
|
1068
|
+
const M = r.isOdd(L);
|
|
1069
|
+
return (N & 1) === 1 !== M && (L = r.neg(L)), { x: $, y: L };
|
|
1070
|
+
} else if (B === _ && N === 4) {
|
|
1071
|
+
const $ = r.BYTES, D = r.fromBytes(P.subarray(0, $)), L = r.fromBytes(P.subarray($, $ * 2));
|
|
1072
|
+
if (!g(D, L))
|
|
1073
1073
|
throw new Error("bad point: is not on curve");
|
|
1074
|
-
return { x:
|
|
1074
|
+
return { x: D, y: L };
|
|
1075
1075
|
} else
|
|
1076
|
-
throw new Error(`bad point: got length ${
|
|
1076
|
+
throw new Error(`bad point: got length ${B}, expected compressed=${y} or uncompressed=${_}`);
|
|
1077
1077
|
}
|
|
1078
1078
|
const p = t.toBytes || f, w = t.fromBytes || d;
|
|
1079
1079
|
function h(U) {
|
|
1080
|
-
const y = r.sqr(U),
|
|
1081
|
-
return r.add(r.add(
|
|
1080
|
+
const y = r.sqr(U), _ = r.mul(y, U);
|
|
1081
|
+
return r.add(r.add(_, r.mul(U, i.a)), i.b);
|
|
1082
1082
|
}
|
|
1083
1083
|
function g(U, y) {
|
|
1084
|
-
const
|
|
1085
|
-
return r.eql(
|
|
1084
|
+
const _ = r.sqr(y), B = h(U);
|
|
1085
|
+
return r.eql(_, B);
|
|
1086
1086
|
}
|
|
1087
1087
|
if (!g(i.Gx, i.Gy))
|
|
1088
1088
|
throw new Error("bad curve params: generator point");
|
|
1089
|
-
const b = r.mul(r.pow(i.a, Ge), Er),
|
|
1090
|
-
if (r.is0(r.add(b,
|
|
1089
|
+
const b = r.mul(r.pow(i.a, Ge), Er), v = r.mul(r.sqr(i.b), BigInt(27));
|
|
1090
|
+
if (r.is0(r.add(b, v)))
|
|
1091
1091
|
throw new Error("bad curve params: a or b");
|
|
1092
|
-
function O(U, y,
|
|
1093
|
-
if (!r.isValid(y) ||
|
|
1092
|
+
function O(U, y, _ = !1) {
|
|
1093
|
+
if (!r.isValid(y) || _ && r.is0(y))
|
|
1094
1094
|
throw new Error(`bad point coordinate ${U}`);
|
|
1095
1095
|
return y;
|
|
1096
1096
|
}
|
|
1097
1097
|
function F(U) {
|
|
1098
|
-
if (!(U instanceof
|
|
1098
|
+
if (!(U instanceof x))
|
|
1099
1099
|
throw new Error("Weierstrass Point expected");
|
|
1100
1100
|
}
|
|
1101
|
-
function
|
|
1101
|
+
function W(U) {
|
|
1102
1102
|
if (!c || !c.basises)
|
|
1103
1103
|
throw new Error("no endo");
|
|
1104
|
-
return
|
|
1104
|
+
return Ta(U, c.basises, s.ORDER);
|
|
1105
1105
|
}
|
|
1106
|
-
const
|
|
1107
|
-
const { X:
|
|
1106
|
+
const A = _r((U, y) => {
|
|
1107
|
+
const { X: _, Y: B, Z: N } = U;
|
|
1108
1108
|
if (r.eql(N, r.ONE))
|
|
1109
|
-
return { x, y:
|
|
1110
|
-
const
|
|
1111
|
-
y == null && (y =
|
|
1112
|
-
const $ = r.mul(
|
|
1113
|
-
if (
|
|
1109
|
+
return { x: _, y: B };
|
|
1110
|
+
const P = U.is0();
|
|
1111
|
+
y == null && (y = P ? r.ONE : r.inv(N));
|
|
1112
|
+
const $ = r.mul(_, y), D = r.mul(B, y), L = r.mul(N, y);
|
|
1113
|
+
if (P)
|
|
1114
1114
|
return { x: r.ZERO, y: r.ZERO };
|
|
1115
1115
|
if (!r.eql(L, r.ONE))
|
|
1116
1116
|
throw new Error("invZ was invalid");
|
|
1117
|
-
return { x: $, y:
|
|
1118
|
-
}),
|
|
1117
|
+
return { x: $, y: D };
|
|
1118
|
+
}), k = _r((U) => {
|
|
1119
1119
|
if (U.is0()) {
|
|
1120
1120
|
if (t.allowInfinityPoint && !r.is0(U.Y))
|
|
1121
1121
|
return;
|
|
1122
1122
|
throw new Error("bad point: ZERO");
|
|
1123
1123
|
}
|
|
1124
|
-
const { x: y, y:
|
|
1125
|
-
if (!r.isValid(y) || !r.isValid(
|
|
1124
|
+
const { x: y, y: _ } = U.toAffine();
|
|
1125
|
+
if (!r.isValid(y) || !r.isValid(_))
|
|
1126
1126
|
throw new Error("bad point: x or y not field elements");
|
|
1127
|
-
if (!g(y,
|
|
1127
|
+
if (!g(y, _))
|
|
1128
1128
|
throw new Error("bad point: equation left != right");
|
|
1129
1129
|
if (!U.isTorsionFree())
|
|
1130
1130
|
throw new Error("bad point: not in prime-order subgroup");
|
|
1131
1131
|
return !0;
|
|
1132
1132
|
});
|
|
1133
|
-
function
|
|
1134
|
-
return
|
|
1133
|
+
function I(U, y, _, B, N) {
|
|
1134
|
+
return _ = new x(r.mul(_.X, U), _.Y, _.Z), y = Dn(B, y), _ = Dn(N, _), y.add(_);
|
|
1135
1135
|
}
|
|
1136
|
-
class
|
|
1136
|
+
class x {
|
|
1137
1137
|
// base / generator point
|
|
1138
|
-
static BASE = new
|
|
1138
|
+
static BASE = new x(i.Gx, i.Gy, r.ONE);
|
|
1139
1139
|
// zero / infinity / identity point
|
|
1140
|
-
static ZERO = new
|
|
1140
|
+
static ZERO = new x(r.ZERO, r.ONE, r.ZERO);
|
|
1141
1141
|
// 0, 1, 0
|
|
1142
1142
|
// math field
|
|
1143
1143
|
static Fp = r;
|
|
@@ -1147,27 +1147,27 @@ function Oi(e, t = {}) {
|
|
|
1147
1147
|
Y;
|
|
1148
1148
|
Z;
|
|
1149
1149
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
1150
|
-
constructor(y,
|
|
1151
|
-
this.X = O("x", y), this.Y = O("y",
|
|
1150
|
+
constructor(y, _, B) {
|
|
1151
|
+
this.X = O("x", y), this.Y = O("y", _, !0), this.Z = O("z", B), Object.freeze(this);
|
|
1152
1152
|
}
|
|
1153
1153
|
static CURVE() {
|
|
1154
1154
|
return i;
|
|
1155
1155
|
}
|
|
1156
1156
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
1157
1157
|
static fromAffine(y) {
|
|
1158
|
-
const { x, y:
|
|
1159
|
-
if (!y || !r.isValid(
|
|
1158
|
+
const { x: _, y: B } = y || {};
|
|
1159
|
+
if (!y || !r.isValid(_) || !r.isValid(B))
|
|
1160
1160
|
throw new Error("invalid affine point");
|
|
1161
|
-
if (y instanceof
|
|
1161
|
+
if (y instanceof x)
|
|
1162
1162
|
throw new Error("projective point not allowed");
|
|
1163
|
-
return r.is0(
|
|
1163
|
+
return r.is0(_) && r.is0(B) ? x.ZERO : new x(_, B, r.ONE);
|
|
1164
1164
|
}
|
|
1165
1165
|
static fromBytes(y) {
|
|
1166
|
-
const
|
|
1167
|
-
return
|
|
1166
|
+
const _ = x.fromAffine(w(lt(y, void 0, "point")));
|
|
1167
|
+
return _.assertValidity(), _;
|
|
1168
1168
|
}
|
|
1169
1169
|
static fromHex(y) {
|
|
1170
|
-
return
|
|
1170
|
+
return x.fromBytes(Pn(y));
|
|
1171
1171
|
}
|
|
1172
1172
|
get x() {
|
|
1173
1173
|
return this.toAffine().x;
|
|
@@ -1181,13 +1181,13 @@ function Oi(e, t = {}) {
|
|
|
1181
1181
|
* @param isLazy true will defer table computation until the first multiplication
|
|
1182
1182
|
* @returns
|
|
1183
1183
|
*/
|
|
1184
|
-
precompute(y = 8,
|
|
1185
|
-
return
|
|
1184
|
+
precompute(y = 8, _ = !0) {
|
|
1185
|
+
return H.createCache(this, y), _ || this.multiply(Ge), this;
|
|
1186
1186
|
}
|
|
1187
1187
|
// TODO: return `this`
|
|
1188
1188
|
/** A point on curve is valid if it conforms to equation. */
|
|
1189
1189
|
assertValidity() {
|
|
1190
|
-
|
|
1190
|
+
k(this);
|
|
1191
1191
|
}
|
|
1192
1192
|
hasEvenY() {
|
|
1193
1193
|
const { y } = this.toAffine();
|
|
@@ -1198,21 +1198,21 @@ function Oi(e, t = {}) {
|
|
|
1198
1198
|
/** Compare one point to another. */
|
|
1199
1199
|
equals(y) {
|
|
1200
1200
|
F(y);
|
|
1201
|
-
const { X:
|
|
1202
|
-
return L &&
|
|
1201
|
+
const { X: _, Y: B, Z: N } = this, { X: P, Y: $, Z: D } = y, L = r.eql(r.mul(_, D), r.mul(P, N)), M = r.eql(r.mul(B, D), r.mul($, N));
|
|
1202
|
+
return L && M;
|
|
1203
1203
|
}
|
|
1204
1204
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
1205
1205
|
negate() {
|
|
1206
|
-
return new
|
|
1206
|
+
return new x(this.X, r.neg(this.Y), this.Z);
|
|
1207
1207
|
}
|
|
1208
1208
|
// Renes-Costello-Batina exception-free doubling formula.
|
|
1209
1209
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
1210
1210
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
1211
1211
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
1212
1212
|
double() {
|
|
1213
|
-
const { a: y, b:
|
|
1214
|
-
let
|
|
1215
|
-
return G = r.add(G, G),
|
|
1213
|
+
const { a: y, b: _ } = i, B = r.mul(_, Ge), { X: N, Y: P, Z: $ } = this;
|
|
1214
|
+
let D = r.ZERO, L = r.ZERO, M = r.ZERO, Z = r.mul(N, N), at = r.mul(P, P), Q = r.mul($, $), G = r.mul(N, P);
|
|
1215
|
+
return G = r.add(G, G), M = r.mul(N, $), M = r.add(M, M), D = r.mul(y, M), L = r.mul(B, Q), L = r.add(D, L), D = r.sub(at, L), L = r.add(at, L), L = r.mul(D, L), D = r.mul(G, D), M = r.mul(B, M), Q = r.mul(y, Q), G = r.sub(Z, Q), G = r.mul(y, G), G = r.add(G, M), M = r.add(Z, Z), Z = r.add(M, Z), Z = r.add(Z, Q), Z = r.mul(Z, G), L = r.add(L, Z), Q = r.mul(P, $), Q = r.add(Q, Q), Z = r.mul(Q, G), D = r.sub(D, Z), M = r.mul(Q, at), M = r.add(M, M), M = r.add(M, M), new x(D, L, M);
|
|
1216
1216
|
}
|
|
1217
1217
|
// Renes-Costello-Batina exception-free addition formula.
|
|
1218
1218
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
@@ -1220,19 +1220,19 @@ function Oi(e, t = {}) {
|
|
|
1220
1220
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
1221
1221
|
add(y) {
|
|
1222
1222
|
F(y);
|
|
1223
|
-
const { X:
|
|
1224
|
-
let L = r.ZERO,
|
|
1223
|
+
const { X: _, Y: B, Z: N } = this, { X: P, Y: $, Z: D } = y;
|
|
1224
|
+
let L = r.ZERO, M = r.ZERO, Z = r.ZERO;
|
|
1225
1225
|
const at = i.a, Q = r.mul(i.b, Ge);
|
|
1226
|
-
let G = r.mul(
|
|
1227
|
-
|
|
1228
|
-
let ut = r.add(
|
|
1229
|
-
return z = r.mul(z, ut), ut = r.add(G, ht), z = r.sub(z, ut), ut = r.add(
|
|
1226
|
+
let G = r.mul(_, P), ft = r.mul(B, $), ht = r.mul(N, D), _t = r.add(_, B), z = r.add(P, $);
|
|
1227
|
+
_t = r.mul(_t, z), z = r.add(G, ft), _t = r.sub(_t, z), z = r.add(_, N);
|
|
1228
|
+
let ut = r.add(P, D);
|
|
1229
|
+
return z = r.mul(z, ut), ut = r.add(G, ht), z = r.sub(z, ut), ut = r.add(B, N), L = r.add($, D), ut = r.mul(ut, L), L = r.add(ft, ht), ut = r.sub(ut, L), Z = r.mul(at, z), L = r.mul(Q, ht), Z = r.add(L, Z), L = r.sub(ft, Z), Z = r.add(ft, Z), M = r.mul(L, Z), ft = r.add(G, G), ft = r.add(ft, G), ht = r.mul(at, ht), z = r.mul(Q, z), ft = r.add(ft, ht), ht = r.sub(G, ht), ht = r.mul(at, ht), z = r.add(z, ht), G = r.mul(ft, z), M = r.add(M, G), G = r.mul(ut, z), L = r.mul(_t, L), L = r.sub(L, G), G = r.mul(_t, ft), Z = r.mul(ut, Z), Z = r.add(Z, G), new x(L, M, Z);
|
|
1230
1230
|
}
|
|
1231
1231
|
subtract(y) {
|
|
1232
1232
|
return this.add(y.negate());
|
|
1233
1233
|
}
|
|
1234
1234
|
is0() {
|
|
1235
|
-
return this.equals(
|
|
1235
|
+
return this.equals(x.ZERO);
|
|
1236
1236
|
}
|
|
1237
1237
|
/**
|
|
1238
1238
|
* Constant time multiplication.
|
|
@@ -1244,19 +1244,19 @@ function Oi(e, t = {}) {
|
|
|
1244
1244
|
* @returns New point
|
|
1245
1245
|
*/
|
|
1246
1246
|
multiply(y) {
|
|
1247
|
-
const { endo:
|
|
1247
|
+
const { endo: _ } = t;
|
|
1248
1248
|
if (!s.isValidNot0(y))
|
|
1249
1249
|
throw new Error("invalid scalar: out of range");
|
|
1250
|
-
let
|
|
1251
|
-
const
|
|
1252
|
-
if (
|
|
1253
|
-
const { k1neg: $, k1:
|
|
1254
|
-
N = at.add(G),
|
|
1250
|
+
let B, N;
|
|
1251
|
+
const P = ($) => H.cached(this, $, (D) => Mn(x, D));
|
|
1252
|
+
if (_) {
|
|
1253
|
+
const { k1neg: $, k1: D, k2neg: L, k2: M } = W(y), { p: Z, f: at } = P(D), { p: Q, f: G } = P(M);
|
|
1254
|
+
N = at.add(G), B = I(_.beta, Z, Q, $, L);
|
|
1255
1255
|
} else {
|
|
1256
|
-
const { p: $, f:
|
|
1257
|
-
|
|
1256
|
+
const { p: $, f: D } = P(y);
|
|
1257
|
+
B = $, N = D;
|
|
1258
1258
|
}
|
|
1259
|
-
return Mn(
|
|
1259
|
+
return Mn(x, [B, N])[0];
|
|
1260
1260
|
}
|
|
1261
1261
|
/**
|
|
1262
1262
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -1264,27 +1264,27 @@ function Oi(e, t = {}) {
|
|
|
1264
1264
|
* an exposed secret key e.g. sig verification, which works over *public* keys.
|
|
1265
1265
|
*/
|
|
1266
1266
|
multiplyUnsafe(y) {
|
|
1267
|
-
const { endo:
|
|
1267
|
+
const { endo: _ } = t, B = this;
|
|
1268
1268
|
if (!s.isValid(y))
|
|
1269
1269
|
throw new Error("invalid scalar: out of range");
|
|
1270
|
-
if (y === ke ||
|
|
1271
|
-
return
|
|
1270
|
+
if (y === ke || B.is0())
|
|
1271
|
+
return x.ZERO;
|
|
1272
1272
|
if (y === Rt)
|
|
1273
|
-
return
|
|
1274
|
-
if (
|
|
1273
|
+
return B;
|
|
1274
|
+
if (H.hasCache(this))
|
|
1275
1275
|
return this.multiply(y);
|
|
1276
|
-
if (
|
|
1277
|
-
const { k1neg: N, k1:
|
|
1278
|
-
return
|
|
1276
|
+
if (_) {
|
|
1277
|
+
const { k1neg: N, k1: P, k2neg: $, k2: D } = W(y), { p1: L, p2: M } = xa(x, B, P, D);
|
|
1278
|
+
return I(_.beta, L, M, N, $);
|
|
1279
1279
|
} else
|
|
1280
|
-
return
|
|
1280
|
+
return H.unsafe(B, y);
|
|
1281
1281
|
}
|
|
1282
1282
|
/**
|
|
1283
1283
|
* Converts Projective point to affine (x, y) coordinates.
|
|
1284
1284
|
* @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
|
|
1285
1285
|
*/
|
|
1286
1286
|
toAffine(y) {
|
|
1287
|
-
return
|
|
1287
|
+
return A(this, y);
|
|
1288
1288
|
}
|
|
1289
1289
|
/**
|
|
1290
1290
|
* Checks whether Point is free of torsion elements (is in prime subgroup).
|
|
@@ -1292,17 +1292,17 @@ function Oi(e, t = {}) {
|
|
|
1292
1292
|
*/
|
|
1293
1293
|
isTorsionFree() {
|
|
1294
1294
|
const { isTorsionFree: y } = t;
|
|
1295
|
-
return o === Rt ? !0 : y ? y(
|
|
1295
|
+
return o === Rt ? !0 : y ? y(x, this) : H.unsafe(this, a).is0();
|
|
1296
1296
|
}
|
|
1297
1297
|
clearCofactor() {
|
|
1298
1298
|
const { clearCofactor: y } = t;
|
|
1299
|
-
return o === Rt ? this : y ? y(
|
|
1299
|
+
return o === Rt ? this : y ? y(x, this) : this.multiplyUnsafe(o);
|
|
1300
1300
|
}
|
|
1301
1301
|
isSmallOrder() {
|
|
1302
1302
|
return this.multiplyUnsafe(o).is0();
|
|
1303
1303
|
}
|
|
1304
1304
|
toBytes(y = !0) {
|
|
1305
|
-
return jr(y, "isCompressed"), this.assertValidity(), p(
|
|
1305
|
+
return jr(y, "isCompressed"), this.assertValidity(), p(x, this, y);
|
|
1306
1306
|
}
|
|
1307
1307
|
toHex(y = !0) {
|
|
1308
1308
|
return cn(this.toBytes(y));
|
|
@@ -1311,47 +1311,47 @@ function Oi(e, t = {}) {
|
|
|
1311
1311
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
1312
1312
|
}
|
|
1313
1313
|
}
|
|
1314
|
-
const
|
|
1315
|
-
return
|
|
1314
|
+
const q = s.BITS, H = new ma(x, t.endo ? Math.ceil(q / 2) : q);
|
|
1315
|
+
return x.BASE.precompute(8), x;
|
|
1316
1316
|
}
|
|
1317
|
-
function
|
|
1317
|
+
function Ia(e) {
|
|
1318
1318
|
return Uint8Array.of(e ? 2 : 3);
|
|
1319
1319
|
}
|
|
1320
|
-
function
|
|
1320
|
+
function Ra(e, t) {
|
|
1321
1321
|
const n = e.ORDER;
|
|
1322
1322
|
let r = ke;
|
|
1323
1323
|
for (let w = n - Rt; w % ne === ke; w /= ne)
|
|
1324
1324
|
r += Rt;
|
|
1325
1325
|
const s = r, i = ne << s - Rt - Rt, o = i * ne, a = (n - Rt) / o, c = (a - Rt) / ne, u = o - Rt, l = i, f = e.pow(t, a), d = e.pow(t, (a + Rt) / ne);
|
|
1326
1326
|
let p = (w, h) => {
|
|
1327
|
-
let g = f, b = e.pow(h, u),
|
|
1328
|
-
|
|
1329
|
-
let O = e.mul(w,
|
|
1330
|
-
O = e.pow(O, c), O = e.mul(O, b), b = e.mul(O, h),
|
|
1331
|
-
let F = e.mul(
|
|
1327
|
+
let g = f, b = e.pow(h, u), v = e.sqr(b);
|
|
1328
|
+
v = e.mul(v, h);
|
|
1329
|
+
let O = e.mul(w, v);
|
|
1330
|
+
O = e.pow(O, c), O = e.mul(O, b), b = e.mul(O, h), v = e.mul(O, w);
|
|
1331
|
+
let F = e.mul(v, b);
|
|
1332
1332
|
O = e.pow(F, l);
|
|
1333
|
-
let
|
|
1334
|
-
b = e.mul(
|
|
1335
|
-
for (let
|
|
1336
|
-
let
|
|
1337
|
-
|
|
1338
|
-
let
|
|
1339
|
-
const
|
|
1340
|
-
b = e.mul(
|
|
1341
|
-
}
|
|
1342
|
-
return { isValid:
|
|
1333
|
+
let W = e.eql(O, e.ONE);
|
|
1334
|
+
b = e.mul(v, d), O = e.mul(F, g), v = e.cmov(b, v, W), F = e.cmov(O, F, W);
|
|
1335
|
+
for (let A = s; A > Rt; A--) {
|
|
1336
|
+
let k = A - ne;
|
|
1337
|
+
k = ne << k - Rt;
|
|
1338
|
+
let I = e.pow(F, k);
|
|
1339
|
+
const x = e.eql(I, e.ONE);
|
|
1340
|
+
b = e.mul(v, g), g = e.mul(g, g), I = e.mul(F, g), v = e.cmov(b, v, x), F = e.cmov(I, F, x);
|
|
1341
|
+
}
|
|
1342
|
+
return { isValid: W, value: v };
|
|
1343
1343
|
};
|
|
1344
1344
|
if (e.ORDER % Er === Ge) {
|
|
1345
1345
|
const w = (e.ORDER - Ge) / Er, h = e.sqrt(e.neg(t));
|
|
1346
1346
|
p = (g, b) => {
|
|
1347
|
-
let
|
|
1347
|
+
let v = e.sqr(b);
|
|
1348
1348
|
const O = e.mul(g, b);
|
|
1349
|
-
|
|
1350
|
-
let F = e.pow(
|
|
1349
|
+
v = e.mul(v, O);
|
|
1350
|
+
let F = e.pow(v, w);
|
|
1351
1351
|
F = e.mul(F, O);
|
|
1352
|
-
const
|
|
1353
|
-
let
|
|
1354
|
-
return { isValid:
|
|
1352
|
+
const W = e.mul(F, h), A = e.mul(e.sqr(F), b), k = e.eql(A, g);
|
|
1353
|
+
let I = e.cmov(W, F, k);
|
|
1354
|
+
return { isValid: k, value: I };
|
|
1355
1355
|
};
|
|
1356
1356
|
}
|
|
1357
1357
|
return p;
|
|
@@ -1361,7 +1361,7 @@ function Ti(e, t) {
|
|
|
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 =
|
|
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) => {
|
|
@@ -1371,11 +1371,11 @@ function Ti(e, t) {
|
|
|
1371
1371
|
w = e.mul(a, o), w = e.mul(w, g), p = e.cmov(p, u, h), w = e.cmov(w, g, h);
|
|
1372
1372
|
const b = e.isOdd(o) === e.isOdd(w);
|
|
1373
1373
|
w = e.cmov(e.neg(w), w, b);
|
|
1374
|
-
const
|
|
1375
|
-
return p = e.mul(p,
|
|
1374
|
+
const v = Ae(e, [l], !0)[0];
|
|
1375
|
+
return p = e.mul(p, v), { x: p, y: w };
|
|
1376
1376
|
};
|
|
1377
1377
|
}
|
|
1378
|
-
function
|
|
1378
|
+
function ka(e, t) {
|
|
1379
1379
|
return {
|
|
1380
1380
|
secretKey: t.BYTES,
|
|
1381
1381
|
publicKey: 1 + e.BYTES,
|
|
@@ -1384,78 +1384,78 @@ function Ra(e, t) {
|
|
|
1384
1384
|
signature: 2 * t.BYTES
|
|
1385
1385
|
};
|
|
1386
1386
|
}
|
|
1387
|
-
const
|
|
1388
|
-
function
|
|
1387
|
+
const Na = BigInt(0), On = BigInt(1), is = BigInt(2), He = BigInt(3);
|
|
1388
|
+
function Ca(e) {
|
|
1389
1389
|
const t = [];
|
|
1390
1390
|
for (; e > On; e >>= On)
|
|
1391
|
-
(e & On) ===
|
|
1391
|
+
(e & On) === Na ? t.unshift(0) : (e & He) === He ? (t.unshift(-1), e += On) : t.unshift(1);
|
|
1392
1392
|
return t;
|
|
1393
1393
|
}
|
|
1394
1394
|
function hr(e) {
|
|
1395
1395
|
if (!Array.isArray(e) || e.length === 0)
|
|
1396
1396
|
throw new Error("expected non-empty array");
|
|
1397
1397
|
}
|
|
1398
|
-
function
|
|
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")
|
|
1402
|
-
l = (
|
|
1402
|
+
l = (A, k, I, x, q, H) => o.mul014(x, A, i.mul(k, q), i.mul(I, H));
|
|
1403
1403
|
else if (a === "divisive")
|
|
1404
|
-
l = (
|
|
1404
|
+
l = (A, k, I, x, q, H) => o.mul034(x, i.mul(I, H), i.mul(k, q), A);
|
|
1405
1405
|
else
|
|
1406
1406
|
throw new Error("bls: unknown twist type");
|
|
1407
1407
|
const f = i.div(i.ONE, i.mul(i.ONE, is));
|
|
1408
|
-
function d(
|
|
1409
|
-
const
|
|
1410
|
-
return
|
|
1411
|
-
}
|
|
1412
|
-
function p(
|
|
1413
|
-
const U = i.sub(
|
|
1414
|
-
|
|
1415
|
-
const
|
|
1416
|
-
return
|
|
1417
|
-
}
|
|
1418
|
-
const w =
|
|
1419
|
-
const
|
|
1420
|
-
let y =
|
|
1408
|
+
function d(A, k, I, x) {
|
|
1409
|
+
const q = i.sqr(I), H = i.sqr(x), U = i.mulByB(i.mul(H, He)), y = i.mul(U, He), _ = i.sub(i.sub(i.sqr(i.add(I, x)), H), q), B = i.sub(U, q), N = i.mul(i.sqr(k), He), P = i.neg(_);
|
|
1410
|
+
return A.push([B, N, P]), k = i.mul(i.mul(i.mul(i.sub(q, y), k), I), f), I = i.sub(i.sqr(i.mul(i.add(q, y), f)), i.mul(i.sqr(U), He)), x = i.mul(q, _), { Rx: k, Ry: I, Rz: x };
|
|
1411
|
+
}
|
|
1412
|
+
function p(A, k, I, x, q, H) {
|
|
1413
|
+
const U = i.sub(I, i.mul(H, x)), y = i.sub(k, i.mul(q, x)), _ = i.sub(i.mul(U, q), i.mul(y, H)), B = i.neg(U), N = y;
|
|
1414
|
+
A.push([_, B, N]);
|
|
1415
|
+
const P = i.sqr(y), $ = i.mul(P, y), D = i.mul(P, k), L = i.add(i.sub($, i.mul(D, is)), i.mul(i.sqr(U), x));
|
|
1416
|
+
return k = i.mul(y, L), I = i.sub(i.mul(i.sub(D, L), U), i.mul($, I)), x = i.mul(x, $), { Rx: k, Ry: I, Rz: x };
|
|
1417
|
+
}
|
|
1418
|
+
const w = Ca(c), h = _r((A) => {
|
|
1419
|
+
const k = A, { x: I, y: x } = k.toAffine(), q = I, H = x, U = i.neg(x);
|
|
1420
|
+
let y = q, _ = H, B = i.ONE;
|
|
1421
1421
|
const N = [];
|
|
1422
|
-
for (const
|
|
1422
|
+
for (const P of w) {
|
|
1423
1423
|
const $ = [];
|
|
1424
|
-
({ Rx: y, Ry:
|
|
1424
|
+
({ Rx: y, Ry: _, Rz: B } = d($, y, _, B)), P && ({ Rx: y, Ry: _, Rz: B } = p($, y, _, B, q, P === -1 ? U : H)), N.push($);
|
|
1425
1425
|
}
|
|
1426
1426
|
if (u) {
|
|
1427
|
-
const
|
|
1428
|
-
u(y,
|
|
1427
|
+
const P = N[N.length - 1];
|
|
1428
|
+
u(y, _, B, q, H, p.bind(null, P));
|
|
1429
1429
|
}
|
|
1430
1430
|
return N;
|
|
1431
1431
|
});
|
|
1432
|
-
function g(
|
|
1433
|
-
let
|
|
1434
|
-
if (
|
|
1435
|
-
const
|
|
1436
|
-
for (let
|
|
1437
|
-
|
|
1438
|
-
for (const [
|
|
1439
|
-
for (const [
|
|
1440
|
-
|
|
1432
|
+
function g(A, k = !1) {
|
|
1433
|
+
let I = o.ONE;
|
|
1434
|
+
if (A.length) {
|
|
1435
|
+
const x = A[0][0].length;
|
|
1436
|
+
for (let q = 0; q < x; q++) {
|
|
1437
|
+
I = o.sqr(I);
|
|
1438
|
+
for (const [H, U, y] of A)
|
|
1439
|
+
for (const [_, B, N] of H[q])
|
|
1440
|
+
I = l(_, B, N, I, U, y);
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
|
-
return
|
|
1443
|
+
return I = o.conjugate(I), k ? o.finalExponentiate(I) : I;
|
|
1444
1444
|
}
|
|
1445
|
-
function b(
|
|
1446
|
-
const
|
|
1447
|
-
Mn(t,
|
|
1448
|
-
for (const { g1:
|
|
1449
|
-
if (
|
|
1445
|
+
function b(A, k = !0) {
|
|
1446
|
+
const I = [];
|
|
1447
|
+
Mn(t, A.map(({ g1: x }) => x)), Mn(n, A.map(({ g2: x }) => x));
|
|
1448
|
+
for (const { g1: x, g2: q } of A) {
|
|
1449
|
+
if (x.is0() || q.is0())
|
|
1450
1450
|
throw new Error("pairing is not available for ZERO point");
|
|
1451
|
-
|
|
1452
|
-
const
|
|
1453
|
-
|
|
1451
|
+
x.assertValidity(), q.assertValidity();
|
|
1452
|
+
const H = x.toAffine();
|
|
1453
|
+
I.push([h(q), H.x, H.y]);
|
|
1454
1454
|
}
|
|
1455
|
-
return g(
|
|
1455
|
+
return g(I, k);
|
|
1456
1456
|
}
|
|
1457
|
-
function
|
|
1458
|
-
return b([{ g1:
|
|
1457
|
+
function v(A, k, I = !0) {
|
|
1458
|
+
return b([{ g1: A, g2: k }], I);
|
|
1459
1459
|
}
|
|
1460
1460
|
const O = {
|
|
1461
1461
|
seed: bi(s.ORDER)
|
|
@@ -1466,10 +1466,10 @@ function Ca(e, t, n, r) {
|
|
|
1466
1466
|
Fp12: o,
|
|
1467
1467
|
// NOTE: we re-export Fp12 here because pairing results are Fp12!
|
|
1468
1468
|
millerLoopBatch: g,
|
|
1469
|
-
pairing:
|
|
1469
|
+
pairing: v,
|
|
1470
1470
|
pairingBatch: b,
|
|
1471
1471
|
calcPairingPrecomputes: h,
|
|
1472
|
-
randomSecretKey: (
|
|
1472
|
+
randomSecretKey: (A = F(O.seed)) => (lt(A, O.seed, "seed"), mi(A, s.ORDER))
|
|
1473
1473
|
};
|
|
1474
1474
|
}
|
|
1475
1475
|
function os(e, t, n, r, s, i) {
|
|
@@ -1512,20 +1512,20 @@ function os(e, t, n, r, s, i) {
|
|
|
1512
1512
|
sign(h, g, b) {
|
|
1513
1513
|
if (b != null)
|
|
1514
1514
|
throw new Error("sign() expects 2 arguments");
|
|
1515
|
-
const
|
|
1516
|
-
return p(h).assertValidity(), h.multiply(
|
|
1515
|
+
const v = t.Fn.fromBytes(g);
|
|
1516
|
+
return p(h).assertValidity(), h.multiply(v);
|
|
1517
1517
|
},
|
|
1518
1518
|
// Checks if pairing of public key & hash is equal to pairing of generator & signature.
|
|
1519
1519
|
// e(P, H(m)) == e(G, S)
|
|
1520
1520
|
// e(S, G) == e(H(m), P)
|
|
1521
|
-
verify(h, g, b,
|
|
1522
|
-
if (
|
|
1521
|
+
verify(h, g, b, v) {
|
|
1522
|
+
if (v != null)
|
|
1523
1523
|
throw new Error("verify() expects 3 arguments");
|
|
1524
1524
|
h = d(h), b = f(b);
|
|
1525
|
-
const O = b.negate(), F = t.BASE,
|
|
1525
|
+
const O = b.negate(), F = t.BASE, W = p(g), A = h;
|
|
1526
1526
|
try {
|
|
1527
|
-
const
|
|
1528
|
-
return a.eql(
|
|
1527
|
+
const k = c([w(O, W), w(F, A)]);
|
|
1528
|
+
return a.eql(k, a.ONE);
|
|
1529
1529
|
} catch {
|
|
1530
1530
|
return !1;
|
|
1531
1531
|
}
|
|
@@ -1535,19 +1535,19 @@ function os(e, t, n, r, s, i) {
|
|
|
1535
1535
|
// TODO: maybe `{message: G2Hex, publicKey: G1Hex}[]` instead?
|
|
1536
1536
|
verifyBatch(h, g) {
|
|
1537
1537
|
hr(g);
|
|
1538
|
-
const b = d(h),
|
|
1539
|
-
for (let
|
|
1540
|
-
const
|
|
1541
|
-
let
|
|
1542
|
-
|
|
1538
|
+
const b = d(h), v = g.map((k) => k.message), O = g.map((k) => f(k.publicKey)), F = /* @__PURE__ */ new Map();
|
|
1539
|
+
for (let k = 0; k < O.length; k++) {
|
|
1540
|
+
const I = O[k], x = v[k];
|
|
1541
|
+
let q = F.get(x);
|
|
1542
|
+
q === void 0 && (q = [], F.set(x, q)), q.push(I);
|
|
1543
1543
|
}
|
|
1544
|
-
const
|
|
1544
|
+
const W = [], A = t.BASE;
|
|
1545
1545
|
try {
|
|
1546
|
-
for (const [
|
|
1547
|
-
const
|
|
1548
|
-
|
|
1546
|
+
for (const [k, I] of F) {
|
|
1547
|
+
const x = I.reduce((q, H) => q.add(H));
|
|
1548
|
+
W.push(w(x, k));
|
|
1549
1549
|
}
|
|
1550
|
-
return
|
|
1550
|
+
return W.push(w(A.negate(), b)), a.eql(c(W), a.ONE);
|
|
1551
1551
|
} catch {
|
|
1552
1552
|
return !1;
|
|
1553
1553
|
}
|
|
@@ -1556,14 +1556,14 @@ function os(e, t, n, r, s, i) {
|
|
|
1556
1556
|
// pk1 + pk2 + pk3 = pkA
|
|
1557
1557
|
aggregatePublicKeys(h) {
|
|
1558
1558
|
hr(h), h = h.map((b) => f(b));
|
|
1559
|
-
const g = h.reduce((b,
|
|
1559
|
+
const g = h.reduce((b, v) => b.add(v), t.ZERO);
|
|
1560
1560
|
return g.assertValidity(), g;
|
|
1561
1561
|
},
|
|
1562
1562
|
// Adds a bunch of signature points together.
|
|
1563
1563
|
// pk1 + pk2 + pk3 = pkA
|
|
1564
1564
|
aggregateSignatures(h) {
|
|
1565
1565
|
hr(h), h = h.map((b) => d(b));
|
|
1566
|
-
const g = h.reduce((b,
|
|
1566
|
+
const g = h.reduce((b, v) => b.add(v), n.ZERO);
|
|
1567
1567
|
return g.assertValidity(), g;
|
|
1568
1568
|
},
|
|
1569
1569
|
hash(h, g) {
|
|
@@ -1572,8 +1572,8 @@ function os(e, t, n, r, s, i) {
|
|
|
1572
1572
|
Signature: i
|
|
1573
1573
|
});
|
|
1574
1574
|
}
|
|
1575
|
-
function
|
|
1576
|
-
const { Fp: s, Fr: i, Fp2: o, Fp6: a, Fp12: c } = e, u = { Point: t }, l = { Point: n }, 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 $a(e, t, n, r) {
|
|
|
1592
1592
|
}
|
|
1593
1593
|
});
|
|
1594
1594
|
}
|
|
1595
|
-
function
|
|
1596
|
-
const i =
|
|
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 La(e, t, n, r, s) {
|
|
|
1602
1602
|
});
|
|
1603
1603
|
return Object.freeze({ ...i, G1: o, G2: a });
|
|
1604
1604
|
}
|
|
1605
|
-
function
|
|
1606
|
-
const o =
|
|
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
|
|
1628
|
+
function Fa(e, t, n) {
|
|
1629
1629
|
const r = t.pow(n, (e.ORDER - Ve) / cs), s = t.pow(n, (e.ORDER - Ve) / 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
|
|
1652
|
+
class Ua {
|
|
1653
1653
|
ORDER;
|
|
1654
1654
|
BITS;
|
|
1655
1655
|
BYTES;
|
|
@@ -1802,7 +1802,7 @@ class Fa {
|
|
|
1802
1802
|
};
|
|
1803
1803
|
}
|
|
1804
1804
|
}
|
|
1805
|
-
class
|
|
1805
|
+
class qa {
|
|
1806
1806
|
ORDER;
|
|
1807
1807
|
BITS;
|
|
1808
1808
|
BYTES;
|
|
@@ -1993,7 +1993,7 @@ class Ua {
|
|
|
1993
1993
|
};
|
|
1994
1994
|
}
|
|
1995
1995
|
}
|
|
1996
|
-
class
|
|
1996
|
+
class Da {
|
|
1997
1997
|
ORDER;
|
|
1998
1998
|
BITS;
|
|
1999
1999
|
BYTES;
|
|
@@ -2205,27 +2205,27 @@ class qa {
|
|
|
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),
|
|
2208
|
+
r = this._cyclotomicSquare(r), sa(n, s) && (r = this.mul(r, t));
|
|
2209
2209
|
return r;
|
|
2210
2210
|
}
|
|
2211
2211
|
}
|
|
2212
|
-
function
|
|
2213
|
-
const t = bn(e.ORDER), n = new
|
|
2212
|
+
function Ma(e) {
|
|
2213
|
+
const t = bn(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
|
|
2216
|
+
const xt = BigInt(0), Wn = BigInt(1), Ut = BigInt(2), Yn = BigInt(3), un = BigInt(4), xe = BigInt("0xd201000000010000"), Wa = Un(xe), tn = {
|
|
2217
2217
|
p: BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),
|
|
2218
2218
|
n: BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"),
|
|
2219
2219
|
h: BigInt("0x396c8c005555e1568c00aaab0000aaab"),
|
|
2220
|
-
a:
|
|
2220
|
+
a: xt,
|
|
2221
2221
|
b: un,
|
|
2222
2222
|
Gx: BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),
|
|
2223
2223
|
Gy: BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1")
|
|
2224
2224
|
}, Pr = bn(tn.n, {
|
|
2225
2225
|
modFromBytes: !0
|
|
2226
|
-
}), { Fp: R, Fp2:
|
|
2226
|
+
}), { Fp: R, Fp2: V, Fp6: Ga, Fp12: Y } = Ma({
|
|
2227
2227
|
ORDER: tn.p,
|
|
2228
|
-
X_LEN:
|
|
2228
|
+
X_LEN: Wa,
|
|
2229
2229
|
// Finite extension field over irreducible polynominal.
|
|
2230
2230
|
// Fp(u) / (u² - β) where β = -1
|
|
2231
2231
|
FP2_NONRESIDUE: [Wn, Wn],
|
|
@@ -2234,32 +2234,32 @@ const _t = BigInt(0), Wn = BigInt(1), Ut = BigInt(2), Yn = BigInt(3), un = BigIn
|
|
|
2234
2234
|
return { c0: R.sub(n, r), c1: R.add(n, r) };
|
|
2235
2235
|
},
|
|
2236
2236
|
Fp12finalExponentiate: (e) => {
|
|
2237
|
-
const t =
|
|
2237
|
+
const t = xe, 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:
|
|
2240
|
+
}), { G2psi: ls, G2psi2: Ha } = Fa(R, V, V.div(V.ONE, V.NONRESIDUE)), wr = 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: R.ORDER,
|
|
2244
2244
|
m: 2,
|
|
2245
2245
|
k: 128,
|
|
2246
2246
|
expand: "xmd",
|
|
2247
|
-
hash:
|
|
2247
|
+
hash: xi
|
|
2248
2248
|
}), Fr = {
|
|
2249
|
-
p:
|
|
2249
|
+
p: V.ORDER,
|
|
2250
2250
|
n: tn.n,
|
|
2251
2251
|
h: BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),
|
|
2252
|
-
a:
|
|
2253
|
-
b:
|
|
2254
|
-
Gx:
|
|
2252
|
+
a: V.ZERO,
|
|
2253
|
+
b: V.fromBigTuple([un, un]),
|
|
2254
|
+
Gx: V.fromBigTuple([
|
|
2255
2255
|
BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),
|
|
2256
2256
|
BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")
|
|
2257
2257
|
]),
|
|
2258
|
-
Gy:
|
|
2258
|
+
Gy: V.fromBigTuple([
|
|
2259
2259
|
BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),
|
|
2260
2260
|
BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")
|
|
2261
2261
|
])
|
|
2262
|
-
}, zn = mn(R.toBytes(
|
|
2262
|
+
}, zn = mn(R.toBytes(xt), { infinity: !0, compressed: !0 });
|
|
2263
2263
|
function Kn(e) {
|
|
2264
2264
|
e = ci(e);
|
|
2265
2265
|
const t = e[0] & 224, n = !!(t >> 7 & 1), r = !!(t >> 6 & 1), s = !!(t >> 5 & 1);
|
|
@@ -2270,7 +2270,7 @@ function mn(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
|
|
2273
|
+
function Va(e, t, n) {
|
|
2274
2274
|
const { BYTES: r, ORDER: s } = R, i = t.is0(), { x: o, y: a } = t.toAffine();
|
|
2275
2275
|
if (n) {
|
|
2276
2276
|
if (i)
|
|
@@ -2288,14 +2288,14 @@ function gr(e) {
|
|
|
2288
2288
|
const i = !!(s * Ut / n);
|
|
2289
2289
|
return mn(mt(r, t), { compressed: !0, sort: i });
|
|
2290
2290
|
}
|
|
2291
|
-
function
|
|
2291
|
+
function Za(e) {
|
|
2292
2292
|
const { compressed: t, infinity: n, sort: r, value: s } = Kn(e), { BYTES: i, ORDER: o } = R;
|
|
2293
2293
|
if (s.length === 48 && t) {
|
|
2294
2294
|
const a = zt(s), c = R.create(a & yn(R.BITS));
|
|
2295
2295
|
if (n) {
|
|
2296
|
-
if (c !==
|
|
2296
|
+
if (c !== xt)
|
|
2297
2297
|
throw new Error("invalid G1 point: non-empty, at infinity, with compression");
|
|
2298
|
-
return { x:
|
|
2298
|
+
return { x: xt, y: xt };
|
|
2299
2299
|
}
|
|
2300
2300
|
const u = R.add(R.pow(c, Yn), R.create(tn.b));
|
|
2301
2301
|
let l = R.sqrt(u);
|
|
@@ -2305,7 +2305,7 @@ function Va(e) {
|
|
|
2305
2305
|
} else if (s.length === 96 && !t) {
|
|
2306
2306
|
const a = zt(s.subarray(0, i)), c = zt(s.subarray(i));
|
|
2307
2307
|
if (n) {
|
|
2308
|
-
if (a !==
|
|
2308
|
+
if (a !== xt || c !== xt)
|
|
2309
2309
|
throw new Error("G1: non-empty point at infinity");
|
|
2310
2310
|
return T.G1.Point.ZERO.toAffine();
|
|
2311
2311
|
}
|
|
@@ -2326,17 +2326,17 @@ function fs(e) {
|
|
|
2326
2326
|
const f = i.fromAffine({ x: a, y: u });
|
|
2327
2327
|
return f.assertValidity(), f;
|
|
2328
2328
|
}
|
|
2329
|
-
function
|
|
2329
|
+
function Ya(e, t, n) {
|
|
2330
2330
|
const { BYTES: r, ORDER: s } = R, i = t.is0(), { x: o, y: a } = t.toAffine();
|
|
2331
2331
|
if (n) {
|
|
2332
2332
|
if (i)
|
|
2333
|
-
return wt(zn, mt(
|
|
2334
|
-
const c = !!(a.c1 ===
|
|
2333
|
+
return wt(zn, mt(xt, r));
|
|
2334
|
+
const c = !!(a.c1 === xt ? a.c0 * Ut / s : a.c1 * Ut / s);
|
|
2335
2335
|
return wt(mn(mt(o.c1, r), { compressed: !0, sort: c }), mt(o.c0, r));
|
|
2336
2336
|
} else {
|
|
2337
2337
|
if (i)
|
|
2338
2338
|
return wt(Uint8Array.of(64), new Uint8Array(4 * r - 1));
|
|
2339
|
-
const { re: c, im: u } =
|
|
2339
|
+
const { re: c, im: u } = V.reim(o), { re: l, im: f } = V.reim(a);
|
|
2340
2340
|
return wt(mt(u, r), mt(c, r), mt(f, r), mt(l, r));
|
|
2341
2341
|
}
|
|
2342
2342
|
}
|
|
@@ -2344,11 +2344,11 @@ function yr(e) {
|
|
|
2344
2344
|
e.assertValidity();
|
|
2345
2345
|
const { BYTES: t } = R;
|
|
2346
2346
|
if (e.is0())
|
|
2347
|
-
return wt(zn, mt(
|
|
2348
|
-
const { x: n, y: r } = e.toAffine(), { re: s, im: i } =
|
|
2347
|
+
return wt(zn, mt(xt, t));
|
|
2348
|
+
const { x: n, y: r } = e.toAffine(), { re: s, im: i } = V.reim(n), { re: o, im: a } = V.reim(r), u = !!((a > xt ? a * Ut : o * Ut) / R.ORDER & Wn), l = s;
|
|
2349
2349
|
return wt(mn(mt(i, t), { sort: u, compressed: !0 }), mt(l, t));
|
|
2350
2350
|
}
|
|
2351
|
-
function
|
|
2351
|
+
function za(e) {
|
|
2352
2352
|
const { BYTES: t, ORDER: n } = R, { compressed: r, infinity: s, sort: i, value: o } = Kn(e);
|
|
2353
2353
|
if (!r && !s && i || // 00100000
|
|
2354
2354
|
!r && s && i || // 01100000
|
|
@@ -2359,20 +2359,20 @@ function Ya(e) {
|
|
|
2359
2359
|
if (s) {
|
|
2360
2360
|
if (o.reduce((w, h) => w !== 0 ? h + 1 : h, 0) > 0)
|
|
2361
2361
|
throw new Error("invalid G2 point: compressed");
|
|
2362
|
-
return { x:
|
|
2362
|
+
return { x: V.ZERO, y: V.ZERO };
|
|
2363
2363
|
}
|
|
2364
|
-
const c = a(o, 0, t), u = a(o, t, 2 * t), l =
|
|
2365
|
-
let d =
|
|
2366
|
-
const p = d.c1 ===
|
|
2367
|
-
return d = i && p > 0 ? d :
|
|
2364
|
+
const c = a(o, 0, t), u = a(o, t, 2 * t), l = V.create({ c0: R.create(u), c1: R.create(c) }), f = V.add(V.pow(l, Yn), Fr.b);
|
|
2365
|
+
let d = V.sqrt(f);
|
|
2366
|
+
const p = d.c1 === xt ? d.c0 * Ut / n : d.c1 * Ut / n ? Wn : xt;
|
|
2367
|
+
return d = i && p > 0 ? d : V.neg(d), { x: l, y: d };
|
|
2368
2368
|
} else if (o.length === 192 && !r) {
|
|
2369
2369
|
if (s) {
|
|
2370
2370
|
if (o.reduce((d, p) => d !== 0 ? p + 1 : p, 0) > 0)
|
|
2371
2371
|
throw new Error("invalid G2 point: uncompressed");
|
|
2372
|
-
return { x:
|
|
2372
|
+
return { x: V.ZERO, y: V.ZERO };
|
|
2373
2373
|
}
|
|
2374
2374
|
const c = a(o, 0 * t, 1 * t), u = a(o, 1 * t, 2 * t), l = a(o, 2 * t, 3 * t), f = a(o, 3 * t, 4 * t);
|
|
2375
|
-
return { x:
|
|
2375
|
+
return { x: V.fromBigTuple([u, c]), y: V.fromBigTuple([f, l]) };
|
|
2376
2376
|
} else
|
|
2377
2377
|
throw new Error("invalid G2 point: expected 96/192 bytes");
|
|
2378
2378
|
}
|
|
@@ -2383,16 +2383,16 @@ function ds(e) {
|
|
|
2383
2383
|
const a = zt(s.slice(0, o)), c = zt(s.slice(o));
|
|
2384
2384
|
if (n)
|
|
2385
2385
|
return i.ZERO;
|
|
2386
|
-
const u = R.create(a & yn(R.BITS)), l = R.create(c), f =
|
|
2387
|
-
let p =
|
|
2386
|
+
const u = R.create(a & yn(R.BITS)), l = R.create(c), f = V.create({ c0: l, c1: u }), d = V.add(V.pow(f, Yn), Fr.b);
|
|
2387
|
+
let p = V.sqrt(d);
|
|
2388
2388
|
if (!p)
|
|
2389
2389
|
throw new Error("Failed to find a square root");
|
|
2390
|
-
const { re: w, im: h } =
|
|
2391
|
-
(b ||
|
|
2390
|
+
const { re: w, im: h } = V.reim(p), g = BigInt(r), b = h > xt && h * Ut / t !== g, v = h === xt && w * Ut / t !== g;
|
|
2391
|
+
(b || v) && (p = V.neg(p));
|
|
2392
2392
|
const O = i.fromAffine({ x: f, y: p });
|
|
2393
2393
|
return O.assertValidity(), O;
|
|
2394
2394
|
}
|
|
2395
|
-
const
|
|
2395
|
+
const Ka = {
|
|
2396
2396
|
ShortSignature: {
|
|
2397
2397
|
fromBytes(e) {
|
|
2398
2398
|
return fs(lt(e));
|
|
@@ -2427,57 +2427,57 @@ const za = {
|
|
|
2427
2427
|
return cn(yr(e));
|
|
2428
2428
|
}
|
|
2429
2429
|
}
|
|
2430
|
-
},
|
|
2430
|
+
}, Xa = {
|
|
2431
2431
|
Fp: R,
|
|
2432
|
-
Fp2:
|
|
2433
|
-
Fp6:
|
|
2432
|
+
Fp2: V,
|
|
2433
|
+
Fp6: Ga,
|
|
2434
2434
|
Fp12: Y,
|
|
2435
2435
|
Fr: Pr
|
|
2436
|
-
},
|
|
2436
|
+
}, Ja = Oi(tn, {
|
|
2437
2437
|
allowInfinityPoint: !0,
|
|
2438
2438
|
Fn: Pr,
|
|
2439
|
-
fromBytes:
|
|
2440
|
-
toBytes:
|
|
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.
|
|
2444
2444
|
// https://eprint.iacr.org/2021/1130.pdf
|
|
2445
2445
|
isTorsionFree: (e, t) => {
|
|
2446
2446
|
const n = BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"), r = new e(R.mul(t.X, n), t.Y, t.Z);
|
|
2447
|
-
return t.multiplyUnsafe(
|
|
2447
|
+
return t.multiplyUnsafe(xe).negate().multiplyUnsafe(xe).equals(r);
|
|
2448
2448
|
},
|
|
2449
2449
|
// Clear cofactor of G1
|
|
2450
2450
|
// https://eprint.iacr.org/2019/403
|
|
2451
|
-
clearCofactor: (e, t) => t.multiplyUnsafe(
|
|
2452
|
-
}),
|
|
2453
|
-
Fp:
|
|
2451
|
+
clearCofactor: (e, t) => t.multiplyUnsafe(xe).add(t)
|
|
2452
|
+
}), ja = Oi(Fr, {
|
|
2453
|
+
Fp: V,
|
|
2454
2454
|
allowInfinityPoint: !0,
|
|
2455
2455
|
Fn: Pr,
|
|
2456
|
-
fromBytes:
|
|
2457
|
-
toBytes:
|
|
2456
|
+
fromBytes: za,
|
|
2457
|
+
toBytes: Ya,
|
|
2458
2458
|
// https://eprint.iacr.org/2021/1130.pdf
|
|
2459
2459
|
// Older version: https://eprint.iacr.org/2019/814.pdf
|
|
2460
|
-
isTorsionFree: (e, t) => t.multiplyUnsafe(
|
|
2460
|
+
isTorsionFree: (e, t) => t.multiplyUnsafe(xe).negate().equals(ls(e, t)),
|
|
2461
2461
|
// clear_cofactor_bls12381_g2 from RFC 9380.
|
|
2462
2462
|
// https://eprint.iacr.org/2017/419.pdf
|
|
2463
2463
|
// prettier-ignore
|
|
2464
2464
|
clearCofactor: (e, t) => {
|
|
2465
|
-
const n =
|
|
2465
|
+
const n = xe;
|
|
2466
2466
|
let r = t.multiplyUnsafe(n).negate(), s = ls(e, t), i = t.double();
|
|
2467
|
-
return i =
|
|
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
|
-
}),
|
|
2470
|
-
mapToG1:
|
|
2471
|
-
mapToG2:
|
|
2469
|
+
}), Qa = {
|
|
2470
|
+
mapToG1: ic,
|
|
2471
|
+
mapToG2: oc,
|
|
2472
2472
|
hasherOpts: wr,
|
|
2473
2473
|
hasherOptsG1: { ...wr, m: 1, DST: "BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_" },
|
|
2474
2474
|
hasherOptsG2: { ...wr }
|
|
2475
|
-
},
|
|
2476
|
-
ateLoopSize:
|
|
2475
|
+
}, tc = {
|
|
2476
|
+
ateLoopSize: xe,
|
|
2477
2477
|
// The BLS parameter x for BLS12-381
|
|
2478
2478
|
twistType: "multiplicative",
|
|
2479
2479
|
randomBytes: si
|
|
2480
|
-
}, T =
|
|
2480
|
+
}, T = Pa(Xa, Ja, ja, tc, Qa, Ka), ec = Bi(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) =>
|
|
2549
|
+
].map((e) => e.map((t) => V.fromBigTuple(t.map(BigInt))))), nc = Bi(R, [
|
|
2550
2550
|
// xNum
|
|
2551
2551
|
[
|
|
2552
2552
|
"0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7",
|
|
@@ -2616,31 +2616,31 @@ const za = {
|
|
|
2616
2616
|
"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"
|
|
2617
2617
|
// LAST 1
|
|
2618
2618
|
]
|
|
2619
|
-
].map((e) => e.map((t) => BigInt(t)))),
|
|
2619
|
+
].map((e) => e.map((t) => BigInt(t)))), rc = Ti(R, {
|
|
2620
2620
|
A: R.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),
|
|
2621
2621
|
B: R.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),
|
|
2622
2622
|
Z: R.create(BigInt(11))
|
|
2623
|
-
}),
|
|
2624
|
-
A:
|
|
2623
|
+
}), sc = Ti(V, {
|
|
2624
|
+
A: V.create({ c0: R.create(xt), c1: R.create(BigInt(240)) }),
|
|
2625
2625
|
// A' = 240 * I
|
|
2626
|
-
B:
|
|
2626
|
+
B: V.create({ c0: R.create(BigInt(1012)), c1: R.create(BigInt(1012)) }),
|
|
2627
2627
|
// B' = 1012 * (1 + I)
|
|
2628
|
-
Z:
|
|
2628
|
+
Z: V.create({ c0: R.create(BigInt(-2)), c1: R.create(BigInt(-1)) })
|
|
2629
2629
|
// Z: -(2 + I)
|
|
2630
2630
|
});
|
|
2631
|
-
function sc(e) {
|
|
2632
|
-
const { x: t, y: n } = nc(R.create(e[0]));
|
|
2633
|
-
return ec(t, n);
|
|
2634
|
-
}
|
|
2635
2631
|
function ic(e) {
|
|
2636
|
-
const { x: t, y: n } = rc(
|
|
2637
|
-
return
|
|
2632
|
+
const { x: t, y: n } = rc(R.create(e[0]));
|
|
2633
|
+
return nc(t, n);
|
|
2634
|
+
}
|
|
2635
|
+
function oc(e) {
|
|
2636
|
+
const { x: t, y: n } = sc(V.fromBigTuple(e));
|
|
2637
|
+
return ec(t, n);
|
|
2638
2638
|
}
|
|
2639
|
-
function
|
|
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 br = /* @__PURE__ */ Uint8Array.of(0), ps = /* @__PURE__ */ Uint8Array.of();
|
|
2643
|
-
function
|
|
2643
|
+
function cc(e, t, n, r = 32) {
|
|
2644
2644
|
kr(e), Xe(r, "length");
|
|
2645
2645
|
const s = e.outputLen;
|
|
2646
2646
|
if (r > 255 * s)
|
|
@@ -2652,8 +2652,8 @@ function ac(e, t, n, r = 32) {
|
|
|
2652
2652
|
br[0] = l + 1, c.update(l === 0 ? ps : u).update(n).update(br).digestInto(u), o.set(u, s * l), a._cloneInto(c);
|
|
2653
2653
|
return a.destroy(), c.destroy(), an(u, br), o.slice(0, r);
|
|
2654
2654
|
}
|
|
2655
|
-
const
|
|
2656
|
-
function
|
|
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 &&
|
|
2676
|
+
i && fc(s, i, r), Object.defineProperty(e, r, { enumerable: !0, value: s, writable: !1 });
|
|
2677
2677
|
}
|
|
2678
2678
|
}
|
|
2679
2679
|
function Ze(e, t) {
|
|
@@ -2728,7 +2728,7 @@ function Ii(e, t, n) {
|
|
|
2728
2728
|
i.push(o + "=" + Ze(a));
|
|
2729
2729
|
}
|
|
2730
2730
|
}
|
|
2731
|
-
i.push(`code=${t}`), i.push(`version=${
|
|
2731
|
+
i.push(`code=${t}`), i.push(`version=${lc}`), i.length && (e += " (" + i.join(", ") + ")");
|
|
2732
2732
|
}
|
|
2733
2733
|
let s;
|
|
2734
2734
|
switch (t) {
|
|
@@ -2748,7 +2748,7 @@ function ct(e, t, n, r) {
|
|
|
2748
2748
|
if (!e)
|
|
2749
2749
|
throw Ii(t, n, r);
|
|
2750
2750
|
}
|
|
2751
|
-
function
|
|
2751
|
+
function m(e, t, n, r) {
|
|
2752
2752
|
ct(e, t, "INVALID_ARGUMENT", { argument: n, value: r });
|
|
2753
2753
|
}
|
|
2754
2754
|
function Ri(e, t, n) {
|
|
@@ -2789,7 +2789,7 @@ function ki(e, t, n) {
|
|
|
2789
2789
|
r[i] = parseInt(e.substring(s, s + 2), 16), s += 2;
|
|
2790
2790
|
return r;
|
|
2791
2791
|
}
|
|
2792
|
-
|
|
2792
|
+
m(!1, "invalid BytesLike value", t || "value", e);
|
|
2793
2793
|
}
|
|
2794
2794
|
function yt(e, t) {
|
|
2795
2795
|
return ki(e, t, !1);
|
|
@@ -2810,10 +2810,10 @@ function bt(e) {
|
|
|
2810
2810
|
}
|
|
2811
2811
|
return n;
|
|
2812
2812
|
}
|
|
2813
|
-
function
|
|
2813
|
+
function _e(e) {
|
|
2814
2814
|
return "0x" + e.map((t) => bt(t).substring(2)).join("");
|
|
2815
2815
|
}
|
|
2816
|
-
function
|
|
2816
|
+
function dc(e) {
|
|
2817
2817
|
return on(e, !0) ? (e.length - 2) / 2 : yt(e).length;
|
|
2818
2818
|
}
|
|
2819
2819
|
function Me(e, t, n) {
|
|
@@ -2840,10 +2840,10 @@ function $n(e, t) {
|
|
|
2840
2840
|
function Ci(e, t) {
|
|
2841
2841
|
return Ni(e, t, !1);
|
|
2842
2842
|
}
|
|
2843
|
-
const
|
|
2844
|
-
function
|
|
2843
|
+
const xn = BigInt(0), Mt = BigInt(1), Ye = 9007199254740991;
|
|
2844
|
+
function pc(e, t) {
|
|
2845
2845
|
const n = Xn(e, "value"), r = BigInt(Ee(t, "width"));
|
|
2846
|
-
if (ct(n >> r ===
|
|
2846
|
+
if (ct(n >> r === xn, "overflow", "NUMERIC_FAULT", {
|
|
2847
2847
|
operation: "fromTwos",
|
|
2848
2848
|
fault: "overflow",
|
|
2849
2849
|
value: e
|
|
@@ -2856,7 +2856,7 @@ function dc(e, t) {
|
|
|
2856
2856
|
function $i(e, t) {
|
|
2857
2857
|
let n = en(e, "value");
|
|
2858
2858
|
const r = BigInt(Ee(t, "width")), s = Mt << r - Mt;
|
|
2859
|
-
if (n <
|
|
2859
|
+
if (n < xn) {
|
|
2860
2860
|
n = -n, ct(n <= s, "too low", "NUMERIC_FAULT", {
|
|
2861
2861
|
operation: "toTwos",
|
|
2862
2862
|
fault: "overflow",
|
|
@@ -2881,21 +2881,21 @@ function en(e, t) {
|
|
|
2881
2881
|
case "bigint":
|
|
2882
2882
|
return e;
|
|
2883
2883
|
case "number":
|
|
2884
|
-
return
|
|
2884
|
+
return m(Number.isInteger(e), "underflow", t || "value", e), m(e >= -Ye && e <= Ye, "overflow", t || "value", e), BigInt(e);
|
|
2885
2885
|
case "string":
|
|
2886
2886
|
try {
|
|
2887
2887
|
if (e === "")
|
|
2888
2888
|
throw new Error("empty string");
|
|
2889
2889
|
return e[0] === "-" && e[1] !== "-" ? -BigInt(e.substring(1)) : BigInt(e);
|
|
2890
2890
|
} catch (n) {
|
|
2891
|
-
|
|
2891
|
+
m(!1, `invalid BigNumberish string: ${n.message}`, t || "value", e);
|
|
2892
2892
|
}
|
|
2893
2893
|
}
|
|
2894
|
-
|
|
2894
|
+
m(!1, "invalid BigNumberish value", t || "value", e);
|
|
2895
2895
|
}
|
|
2896
2896
|
function Xn(e, t) {
|
|
2897
2897
|
const n = en(e, t);
|
|
2898
|
-
return ct(n >=
|
|
2898
|
+
return ct(n >= xn, "unsigned value cannot be negative", "NUMERIC_FAULT", {
|
|
2899
2899
|
fault: "overflow",
|
|
2900
2900
|
operation: "getUint",
|
|
2901
2901
|
value: e
|
|
@@ -2914,21 +2914,21 @@ function Li(e) {
|
|
|
2914
2914
|
function Ee(e, t) {
|
|
2915
2915
|
switch (typeof e) {
|
|
2916
2916
|
case "bigint":
|
|
2917
|
-
return
|
|
2917
|
+
return m(e >= -Ye && e <= Ye, "overflow", t || "value", e), Number(e);
|
|
2918
2918
|
case "number":
|
|
2919
|
-
return
|
|
2919
|
+
return m(Number.isInteger(e), "underflow", t || "value", e), m(e >= -Ye && e <= Ye, "overflow", t || "value", e), e;
|
|
2920
2920
|
case "string":
|
|
2921
2921
|
try {
|
|
2922
2922
|
if (e === "")
|
|
2923
2923
|
throw new Error("empty string");
|
|
2924
2924
|
return Ee(BigInt(e), t);
|
|
2925
2925
|
} catch (n) {
|
|
2926
|
-
|
|
2926
|
+
m(!1, `invalid numeric string: ${n.message}`, t || "value", e);
|
|
2927
2927
|
}
|
|
2928
2928
|
}
|
|
2929
|
-
|
|
2929
|
+
m(!1, "invalid numeric value", t || "value", e);
|
|
2930
2930
|
}
|
|
2931
|
-
function
|
|
2931
|
+
function hc(e) {
|
|
2932
2932
|
return Ee(Li(e));
|
|
2933
2933
|
}
|
|
2934
2934
|
function Ai(e, t) {
|
|
@@ -2938,7 +2938,7 @@ function Ai(e, t) {
|
|
|
2938
2938
|
r.length % 2 && (r = "0" + r);
|
|
2939
2939
|
else {
|
|
2940
2940
|
const s = Ee(t, "width");
|
|
2941
|
-
if (s === 0 && n ===
|
|
2941
|
+
if (s === 0 && n === xn)
|
|
2942
2942
|
return "0x";
|
|
2943
2943
|
for (ct(s * 2 >= r.length, `value exceeds width (${s} bytes)`, "NUMERIC_FAULT", {
|
|
2944
2944
|
operation: "toBeHex",
|
|
@@ -2951,7 +2951,7 @@ function Ai(e, t) {
|
|
|
2951
2951
|
}
|
|
2952
2952
|
function Pi(e, t) {
|
|
2953
2953
|
const n = Xn(e, "value");
|
|
2954
|
-
if (n ===
|
|
2954
|
+
if (n === xn)
|
|
2955
2955
|
return new Uint8Array(0);
|
|
2956
2956
|
let r = n.toString(16);
|
|
2957
2957
|
r.length % 2 && (r = "0" + r);
|
|
@@ -2962,8 +2962,8 @@ function Pi(e, t) {
|
|
|
2962
2962
|
}
|
|
2963
2963
|
return s;
|
|
2964
2964
|
}
|
|
2965
|
-
function
|
|
2966
|
-
|
|
2965
|
+
function wc(e, t, n, r, s) {
|
|
2966
|
+
m(!1, `invalid codepoint at offset ${t}; ${e}`, "bytes", n);
|
|
2967
2967
|
}
|
|
2968
2968
|
function Fi(e, t, n, r, s) {
|
|
2969
2969
|
if (e === "BAD_PREFIX" || e === "UNEXPECTED_CONTINUE") {
|
|
@@ -2974,16 +2974,16 @@ function Fi(e, t, n, r, s) {
|
|
|
2974
2974
|
}
|
|
2975
2975
|
return e === "OVERRUN" ? n.length - t - 1 : 0;
|
|
2976
2976
|
}
|
|
2977
|
-
function
|
|
2978
|
-
return e === "OVERLONG" ? (
|
|
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), Fi(e, t, n));
|
|
2979
2979
|
}
|
|
2980
|
-
const
|
|
2981
|
-
error:
|
|
2980
|
+
const yc = Object.freeze({
|
|
2981
|
+
error: wc,
|
|
2982
2982
|
ignore: Fi,
|
|
2983
|
-
replace:
|
|
2983
|
+
replace: gc
|
|
2984
2984
|
});
|
|
2985
|
-
function
|
|
2986
|
-
t == null && (t =
|
|
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; ) {
|
|
@@ -3035,7 +3035,7 @@ function yc(e, t) {
|
|
|
3035
3035
|
return r;
|
|
3036
3036
|
}
|
|
3037
3037
|
function qr(e, t) {
|
|
3038
|
-
|
|
3038
|
+
m(typeof e == "string", "invalid string value", "str", e);
|
|
3039
3039
|
let n = [];
|
|
3040
3040
|
for (let r = 0; r < e.length; r++) {
|
|
3041
3041
|
const s = e.charCodeAt(r);
|
|
@@ -3046,7 +3046,7 @@ function qr(e, t) {
|
|
|
3046
3046
|
else if ((s & 64512) == 55296) {
|
|
3047
3047
|
r++;
|
|
3048
3048
|
const i = e.charCodeAt(r);
|
|
3049
|
-
|
|
3049
|
+
m(r < e.length && (i & 64512) === 56320, "invalid surrogate pair", "str", e);
|
|
3050
3050
|
const o = 65536 + ((s & 1023) << 10) + (i & 1023);
|
|
3051
3051
|
n.push(o >> 18 | 240), n.push(o >> 12 & 63 | 128), n.push(o >> 6 & 63 | 128), n.push(o & 63 | 128);
|
|
3052
3052
|
} else
|
|
@@ -3054,11 +3054,11 @@ function qr(e, t) {
|
|
|
3054
3054
|
}
|
|
3055
3055
|
return new Uint8Array(n);
|
|
3056
3056
|
}
|
|
3057
|
-
function
|
|
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
|
|
3061
|
-
return bc(
|
|
3060
|
+
function xc(e, t) {
|
|
3061
|
+
return mc(bc(e, t));
|
|
3062
3062
|
}
|
|
3063
3063
|
const vt = 32, Sr = new Uint8Array(vt), _c = ["then"], In = {}, Ui = /* @__PURE__ */ new WeakMap();
|
|
3064
3064
|
function Te(e) {
|
|
@@ -3207,7 +3207,7 @@ class ie extends Array {
|
|
|
3207
3207
|
}
|
|
3208
3208
|
function bs(e) {
|
|
3209
3209
|
let t = Pi(e);
|
|
3210
|
-
return ct(t.length <= vt, "value out-of-bounds", "BUFFER_OVERRUN", { buffer: t, length: vt, offset: t.length }), t.length !== vt && (t = Kt(
|
|
3210
|
+
return ct(t.length <= vt, "value out-of-bounds", "BUFFER_OVERRUN", { buffer: t, length: vt, offset: t.length }), t.length !== vt && (t = Kt(_e([Sr.slice(t.length % vt), t]))), t;
|
|
3211
3211
|
}
|
|
3212
3212
|
class fe {
|
|
3213
3213
|
// The coder name:
|
|
@@ -3232,7 +3232,7 @@ class fe {
|
|
|
3232
3232
|
});
|
|
3233
3233
|
}
|
|
3234
3234
|
_throwError(t, n) {
|
|
3235
|
-
|
|
3235
|
+
m(!1, t, this.localName, n);
|
|
3236
3236
|
}
|
|
3237
3237
|
}
|
|
3238
3238
|
class vr {
|
|
@@ -3243,7 +3243,7 @@ class vr {
|
|
|
3243
3243
|
this.#t = [], this.#e = 0;
|
|
3244
3244
|
}
|
|
3245
3245
|
get data() {
|
|
3246
|
-
return
|
|
3246
|
+
return _e(this.#t);
|
|
3247
3247
|
}
|
|
3248
3248
|
get length() {
|
|
3249
3249
|
return this.#e;
|
|
@@ -3258,7 +3258,7 @@ class vr {
|
|
|
3258
3258
|
writeBytes(t) {
|
|
3259
3259
|
let n = Kt(t);
|
|
3260
3260
|
const r = n.length % vt;
|
|
3261
|
-
return r && (n = Kt(
|
|
3261
|
+
return r && (n = Kt(_e([n, Sr.slice(r)]))), this.#n(n);
|
|
3262
3262
|
}
|
|
3263
3263
|
// Numeric item; pad on the left *to* WordSize
|
|
3264
3264
|
writeValue(t) {
|
|
@@ -3335,7 +3335,7 @@ class Dr {
|
|
|
3335
3335
|
return Li(this.readBytes(vt));
|
|
3336
3336
|
}
|
|
3337
3337
|
readIndex() {
|
|
3338
|
-
return
|
|
3338
|
+
return hc(this.readBytes(vt));
|
|
3339
3339
|
}
|
|
3340
3340
|
}
|
|
3341
3341
|
function ms(e) {
|
|
@@ -3348,63 +3348,63 @@ function qi(e, ...t) {
|
|
|
3348
3348
|
if (t.length > 0 && !t.includes(e.length))
|
|
3349
3349
|
throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`);
|
|
3350
3350
|
}
|
|
3351
|
-
function
|
|
3351
|
+
function xs(e, t = !0) {
|
|
3352
3352
|
if (e.destroyed)
|
|
3353
3353
|
throw new Error("Hash instance has been destroyed");
|
|
3354
3354
|
if (t && e.finished)
|
|
3355
3355
|
throw new Error("Hash#digest() has already been called");
|
|
3356
3356
|
}
|
|
3357
|
-
function
|
|
3357
|
+
function Ec(e, t) {
|
|
3358
3358
|
qi(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
|
|
3364
|
-
if (!
|
|
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
|
|
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
3371
|
function Di(e) {
|
|
3372
|
-
if (typeof e == "string" && (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
|
|
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
|
|
3382
|
+
function Ic(e) {
|
|
3383
3383
|
const t = (r) => e().update(Di(r)).digest(), n = e();
|
|
3384
3384
|
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
3385
3385
|
}
|
|
3386
|
-
const Rn = /* @__PURE__ */ BigInt(2 ** 32 - 1),
|
|
3387
|
-
function Ic(e, t = !1) {
|
|
3388
|
-
return t ? { h: Number(e & Rn), l: Number(e >> xs & Rn) } : { h: Number(e >> xs & Rn) | 0, l: Number(e & Rn) | 0 };
|
|
3389
|
-
}
|
|
3386
|
+
const Rn = /* @__PURE__ */ BigInt(2 ** 32 - 1), _s = /* @__PURE__ */ BigInt(32);
|
|
3390
3387
|
function Rc(e, t = !1) {
|
|
3388
|
+
return t ? { h: Number(e & Rn), l: Number(e >> _s & Rn) } : { h: Number(e >> _s & Rn) | 0, l: Number(e & Rn) | 0 };
|
|
3389
|
+
}
|
|
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 } =
|
|
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
|
|
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, [Mi, Wi, Gi] = [[], [], []], Ac = /* @__PURE__ */ BigInt(0), sn = /* @__PURE__ */ BigInt(1), Pc = /* @__PURE__ */ BigInt(2), Fc = /* @__PURE__ */ BigInt(7), Uc = /* @__PURE__ */ BigInt(256), qc = /* @__PURE__ */ BigInt(113);
|
|
3399
3399
|
for (let e = 0, t = sn, n = 1, r = 0; e < 24; e++) {
|
|
3400
3400
|
[n, r] = [r, (2 * n + 3 * r) % 5], Mi.push(2 * (5 * r + n)), Wi.push((e + 1) * (e + 2) / 2 % 64);
|
|
3401
|
-
let s =
|
|
3401
|
+
let s = Ac;
|
|
3402
3402
|
for (let i = 0; i < 7; i++)
|
|
3403
|
-
t = (t << sn ^ (t >>
|
|
3403
|
+
t = (t << sn ^ (t >> Fc) * qc) % Uc, t & Pc && (s ^= sn << (sn << /* @__PURE__ */ BigInt(i)) - sn);
|
|
3404
3404
|
Gi.push(s);
|
|
3405
3405
|
}
|
|
3406
|
-
const [
|
|
3407
|
-
function
|
|
3406
|
+
const [Dc, Mc] = /* @__PURE__ */ kc(Gi, !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++)
|
|
@@ -3425,22 +3425,22 @@ function Mc(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] ^=
|
|
3428
|
+
e[0] ^= Dc[r], e[1] ^= Mc[r];
|
|
3429
3429
|
}
|
|
3430
3430
|
n.fill(0);
|
|
3431
3431
|
}
|
|
3432
|
-
class Mr extends
|
|
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 =
|
|
3437
|
+
this.state = new Uint8Array(200), this.state32 = Bc(this.state);
|
|
3438
3438
|
}
|
|
3439
3439
|
keccak() {
|
|
3440
|
-
|
|
3440
|
+
Wc(this.state32, this.rounds), this.posOut = 0, this.pos = 0;
|
|
3441
3441
|
}
|
|
3442
3442
|
update(t) {
|
|
3443
|
-
|
|
3443
|
+
xs(this);
|
|
3444
3444
|
const { blockLen: n, state: r } = this;
|
|
3445
3445
|
t = Di(t);
|
|
3446
3446
|
const s = t.length;
|
|
@@ -3460,7 +3460,7 @@ class Mr extends Oc {
|
|
|
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
|
-
|
|
3463
|
+
xs(this, !1), qi(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 Oc {
|
|
|
3478
3478
|
return ms(t), this.xofInto(new Uint8Array(t));
|
|
3479
3479
|
}
|
|
3480
3480
|
digestInto(t) {
|
|
3481
|
-
if (
|
|
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,10 +3493,10 @@ class Mr extends Oc {
|
|
|
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
|
|
3496
|
+
const Gc = (e, t, n) => Ic(() => new Mr(t, e, n)), Hc = /* @__PURE__ */ Gc(1, 136, 256 / 8);
|
|
3497
3497
|
let Hi = !1;
|
|
3498
3498
|
const Vi = function(e) {
|
|
3499
|
-
return
|
|
3499
|
+
return Hc(e);
|
|
3500
3500
|
};
|
|
3501
3501
|
let Zi = Vi;
|
|
3502
3502
|
function tt(e) {
|
|
@@ -3513,7 +3513,7 @@ tt.register = function(e) {
|
|
|
3513
3513
|
Zi = e;
|
|
3514
3514
|
};
|
|
3515
3515
|
Object.freeze(tt);
|
|
3516
|
-
const
|
|
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
|
|
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 Zc(e) {
|
|
|
3542
3542
|
n = "0" + n;
|
|
3543
3543
|
return n;
|
|
3544
3544
|
}
|
|
3545
|
-
const
|
|
3545
|
+
const zc = (function() {
|
|
3546
3546
|
const e = {};
|
|
3547
3547
|
for (let t = 0; t < 36; t++) {
|
|
3548
3548
|
const n = "0123456789abcdefghijklmnopqrstuvwxyz"[t];
|
|
@@ -3550,27 +3550,27 @@ const Yc = (function() {
|
|
|
3550
3550
|
}
|
|
3551
3551
|
return e;
|
|
3552
3552
|
})();
|
|
3553
|
-
function
|
|
3553
|
+
function Kc(e) {
|
|
3554
3554
|
e = e.toLowerCase();
|
|
3555
|
-
let t =
|
|
3555
|
+
let t = Vc;
|
|
3556
3556
|
for (let n = 0; n < e.length; n++)
|
|
3557
|
-
t = t *
|
|
3557
|
+
t = t * Zc + zc[e[n]];
|
|
3558
3558
|
return t;
|
|
3559
3559
|
}
|
|
3560
3560
|
function ln(e) {
|
|
3561
|
-
if (
|
|
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
|
-
return
|
|
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
|
-
|
|
3568
|
-
let t =
|
|
3567
|
+
m(e.substring(2, 4) === Yc(e), "bad icap checksum", "address", e);
|
|
3568
|
+
let t = Kc(e.substring(4)).toString(16);
|
|
3569
3569
|
for (; t.length < 40; )
|
|
3570
3570
|
t = "0" + t;
|
|
3571
3571
|
return Bs("0x" + t);
|
|
3572
3572
|
}
|
|
3573
|
-
|
|
3573
|
+
m(!1, "invalid address", "address", e);
|
|
3574
3574
|
}
|
|
3575
3575
|
const re = {};
|
|
3576
3576
|
function E(e, t) {
|
|
@@ -4327,7 +4327,7 @@ class pt {
|
|
|
4327
4327
|
return t;
|
|
4328
4328
|
}
|
|
4329
4329
|
}
|
|
4330
|
-
class
|
|
4330
|
+
class Xc extends fe {
|
|
4331
4331
|
constructor(t) {
|
|
4332
4332
|
super("address", "address", t, !1);
|
|
4333
4333
|
}
|
|
@@ -4347,7 +4347,7 @@ class Kc extends fe {
|
|
|
4347
4347
|
return ln(Ai(t.readValue(), 20));
|
|
4348
4348
|
}
|
|
4349
4349
|
}
|
|
4350
|
-
class
|
|
4350
|
+
class Jc extends fe {
|
|
4351
4351
|
coder;
|
|
4352
4352
|
constructor(t) {
|
|
4353
4353
|
super(t.name, t.type, "_", t.dynamic), this.coder = t;
|
|
@@ -4373,8 +4373,8 @@ function Yi(e, t, n) {
|
|
|
4373
4373
|
return ct(l, "cannot encode object for signature with missing names", "INVALID_ARGUMENT", { argument: "values", info: { coder: u }, value: n }), ct(!c[l], "cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", { argument: "values", info: { coder: u }, value: n }), c[l] = !0, n[l];
|
|
4374
4374
|
});
|
|
4375
4375
|
} else
|
|
4376
|
-
|
|
4377
|
-
|
|
4376
|
+
m(!1, "invalid tuple value", "tuple", n);
|
|
4377
|
+
m(t.length === r.length, "types/value length mismatch", "tuple", n);
|
|
4378
4378
|
let s = new vr(), i = new vr(), o = [];
|
|
4379
4379
|
t.forEach((c, u) => {
|
|
4380
4380
|
let l = r[u];
|
|
@@ -4419,7 +4419,7 @@ function zi(e, t) {
|
|
|
4419
4419
|
n.push(o), r.push(i.localName || null);
|
|
4420
4420
|
}), ie.fromItems(n, r);
|
|
4421
4421
|
}
|
|
4422
|
-
class
|
|
4422
|
+
class jc extends fe {
|
|
4423
4423
|
coder;
|
|
4424
4424
|
length;
|
|
4425
4425
|
constructor(t, n, r) {
|
|
@@ -4447,11 +4447,11 @@ class Jc extends fe {
|
|
|
4447
4447
|
n === -1 && (n = t.readIndex(), ct(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
|
|
4450
|
+
r.push(new Jc(this.coder));
|
|
4451
4451
|
return zi(t, r);
|
|
4452
4452
|
}
|
|
4453
4453
|
}
|
|
4454
|
-
class
|
|
4454
|
+
class Qc extends fe {
|
|
4455
4455
|
constructor(t) {
|
|
4456
4456
|
super("bool", "bool", t, !1);
|
|
4457
4457
|
}
|
|
@@ -4482,7 +4482,7 @@ class Ki extends fe {
|
|
|
4482
4482
|
return t.readBytes(t.readIndex(), !0);
|
|
4483
4483
|
}
|
|
4484
4484
|
}
|
|
4485
|
-
class
|
|
4485
|
+
class tu extends Ki {
|
|
4486
4486
|
constructor(t) {
|
|
4487
4487
|
super("bytes", t);
|
|
4488
4488
|
}
|
|
@@ -4490,7 +4490,7 @@ class Qc extends Ki {
|
|
|
4490
4490
|
return bt(super.decode(t));
|
|
4491
4491
|
}
|
|
4492
4492
|
}
|
|
4493
|
-
class
|
|
4493
|
+
class eu extends fe {
|
|
4494
4494
|
size;
|
|
4495
4495
|
constructor(t, n) {
|
|
4496
4496
|
let r = "bytes" + String(t);
|
|
@@ -4507,8 +4507,8 @@ class tu extends fe {
|
|
|
4507
4507
|
return bt(t.readBytes(this.size));
|
|
4508
4508
|
}
|
|
4509
4509
|
}
|
|
4510
|
-
const
|
|
4511
|
-
class
|
|
4510
|
+
const nu = new Uint8Array([]);
|
|
4511
|
+
class ru extends fe {
|
|
4512
4512
|
constructor(t) {
|
|
4513
4513
|
super("null", "", t, !1);
|
|
4514
4514
|
}
|
|
@@ -4516,14 +4516,14 @@ class nu extends fe {
|
|
|
4516
4516
|
return null;
|
|
4517
4517
|
}
|
|
4518
4518
|
encode(t, n) {
|
|
4519
|
-
return n != null && this._throwError("not null", n), t.writeBytes(
|
|
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
|
|
4526
|
-
class
|
|
4525
|
+
const su = BigInt(0), iu = BigInt(1), ou = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
4526
|
+
class au extends fe {
|
|
4527
4527
|
size;
|
|
4528
4528
|
signed;
|
|
4529
4529
|
constructor(t, n, r) {
|
|
@@ -4534,19 +4534,19 @@ class ou extends fe {
|
|
|
4534
4534
|
return 0;
|
|
4535
4535
|
}
|
|
4536
4536
|
encode(t, n) {
|
|
4537
|
-
let r = en(pt.dereference(n, this.type)), s = Tn(
|
|
4537
|
+
let r = en(pt.dereference(n, this.type)), s = Tn(ou, vt * 8);
|
|
4538
4538
|
if (this.signed) {
|
|
4539
4539
|
let i = Tn(s, this.size * 8 - 1);
|
|
4540
|
-
(r > i || r < -(i +
|
|
4541
|
-
} else (r <
|
|
4540
|
+
(r > i || r < -(i + iu)) && this._throwError("value out-of-bounds", n), r = $i(r, 8 * vt);
|
|
4541
|
+
} else (r < su || r > Tn(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 = Tn(t.readValue(), this.size * 8);
|
|
4546
|
-
return this.signed && (n =
|
|
4546
|
+
return this.signed && (n = pc(n, this.size * 8)), n;
|
|
4547
4547
|
}
|
|
4548
4548
|
}
|
|
4549
|
-
class
|
|
4549
|
+
class cu extends Ki {
|
|
4550
4550
|
constructor(t) {
|
|
4551
4551
|
super("string", t);
|
|
4552
4552
|
}
|
|
@@ -4557,7 +4557,7 @@ class au extends Ki {
|
|
|
4557
4557
|
return super.encode(t, qr(pt.dereference(n, "string")));
|
|
4558
4558
|
}
|
|
4559
4559
|
decode(t) {
|
|
4560
|
-
return
|
|
4560
|
+
return xc(super.decode(t));
|
|
4561
4561
|
}
|
|
4562
4562
|
}
|
|
4563
4563
|
class kn extends fe {
|
|
@@ -4596,7 +4596,7 @@ class kn extends fe {
|
|
|
4596
4596
|
function fn(e) {
|
|
4597
4597
|
return tt(qr(e));
|
|
4598
4598
|
}
|
|
4599
|
-
const
|
|
4599
|
+
const uu = new RegExp("^bytes([0-9]+)$"), lu = new RegExp("^(u?int)([0-9]*)$"), fu = new RegExp("^(.*)\\[([0-9]*)\\]$");
|
|
4600
4600
|
function Xi(e, t, n) {
|
|
4601
4601
|
switch (e) {
|
|
4602
4602
|
case "address":
|
|
@@ -4608,44 +4608,44 @@ function Xi(e, t, n) {
|
|
|
4608
4608
|
case "bool":
|
|
4609
4609
|
return t = t ? "0x01" : "0x00", yt(n ? $n(t, 32) : t);
|
|
4610
4610
|
}
|
|
4611
|
-
let r = e.match(
|
|
4611
|
+
let r = e.match(lu);
|
|
4612
4612
|
if (r) {
|
|
4613
4613
|
let s = r[1] === "int", i = parseInt(r[2] || "256");
|
|
4614
|
-
return
|
|
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 = $i(t, i)), yt($n(Pi(t), i / 8));
|
|
4615
4615
|
}
|
|
4616
|
-
if (r = e.match(
|
|
4616
|
+
if (r = e.match(uu), r) {
|
|
4617
4617
|
const s = parseInt(r[1]);
|
|
4618
|
-
return
|
|
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(Ci(t, 32)) : t;
|
|
4619
4619
|
}
|
|
4620
|
-
if (r = e.match(
|
|
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
4625
|
o.push(Xi(s, a, !0));
|
|
4626
|
-
}), yt(
|
|
4626
|
+
}), yt(_e(o));
|
|
4627
4627
|
}
|
|
4628
|
-
|
|
4628
|
+
m(!1, "invalid type", "type", e);
|
|
4629
4629
|
}
|
|
4630
4630
|
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
4634
|
n.push(Xi(r, t[s]));
|
|
4635
|
-
}), bt(
|
|
4635
|
+
}), bt(_e(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
|
|
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(" ")), ji = "constructor error event fallback function receive struct", Qi = Ot(ji.split(" ")), to = "calldata memory storage payable indexed", wu = Ot(to.split(" ")), gu = "tuple returns", yu = [ji, to, 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
|
-
},
|
|
4648
|
+
}, xu = new RegExp("^(\\s*)"), _u = new RegExp("^([0-9]+)"), Eu = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"), eo = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"), no = new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");
|
|
4649
4649
|
class qt {
|
|
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(
|
|
4748
|
+
let o = e.substring(i), a = o.match(xu);
|
|
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 =
|
|
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,8 +4771,8 @@ function Se(e) {
|
|
|
4771
4771
|
}
|
|
4772
4772
|
continue;
|
|
4773
4773
|
}
|
|
4774
|
-
if (a = o.match(
|
|
4775
|
-
if (c.text = a[1], i += c.text.length,
|
|
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
|
}
|
|
@@ -4819,7 +4819,7 @@ function ue(e, t) {
|
|
|
4819
4819
|
return Object.freeze(n);
|
|
4820
4820
|
}
|
|
4821
4821
|
function ro(e) {
|
|
4822
|
-
let t = ue(e,
|
|
4822
|
+
let t = ue(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 ce(e, t) {
|
|
@@ -4837,19 +4837,19 @@ function Ce(e) {
|
|
|
4837
4837
|
if (e.length)
|
|
4838
4838
|
throw new Error(`unexpected tokens at offset ${e.offset}: ${e.toString()}`);
|
|
4839
4839
|
}
|
|
4840
|
-
const
|
|
4840
|
+
const Su = new RegExp(/^(.*)\[([0-9]*)\]$/);
|
|
4841
4841
|
function Rs(e) {
|
|
4842
4842
|
const t = e.match(no);
|
|
4843
|
-
if (
|
|
4843
|
+
if (m(t, "invalid type", "type", e), e === "uint")
|
|
4844
4844
|
return "uint256";
|
|
4845
4845
|
if (e === "int")
|
|
4846
4846
|
return "int256";
|
|
4847
4847
|
if (t[2]) {
|
|
4848
4848
|
const n = parseInt(t[2]);
|
|
4849
|
-
|
|
4849
|
+
m(n !== 0 && n <= 32, "invalid bytes length", "type", e);
|
|
4850
4850
|
} else if (t[3]) {
|
|
4851
4851
|
const n = parseInt(t[3]);
|
|
4852
|
-
|
|
4852
|
+
m(n !== 0 && n <= 256 && n % 8 === 0, "invalid numeric width", "type", e);
|
|
4853
4853
|
}
|
|
4854
4854
|
return e;
|
|
4855
4855
|
}
|
|
@@ -5063,7 +5063,7 @@ class nt {
|
|
|
5063
5063
|
try {
|
|
5064
5064
|
return nt.from(Se(t), n);
|
|
5065
5065
|
} catch {
|
|
5066
|
-
|
|
5066
|
+
m(!1, "invalid param type", "obj", t);
|
|
5067
5067
|
}
|
|
5068
5068
|
else if (t instanceof qt) {
|
|
5069
5069
|
let a = "", c = "", u = null;
|
|
@@ -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 (ue(t,
|
|
5077
|
+
if (ue(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
|
-
|
|
5088
|
+
m(!r || typeof r == "string" && r.match(eo), "invalid name", "obj.name", r);
|
|
5089
5089
|
let s = t.indexed;
|
|
5090
|
-
s != null && (
|
|
5091
|
-
let i = t.type, o = i.match(
|
|
5090
|
+
s != null && (m(n, "parameter cannot be indexed", "obj.indexed", t.indexed), s = !!s);
|
|
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],
|
|
@@ -5178,7 +5178,7 @@ class $e {
|
|
|
5178
5178
|
operation: "Fragment.from"
|
|
5179
5179
|
});
|
|
5180
5180
|
}
|
|
5181
|
-
|
|
5181
|
+
m(!1, "unsupported frgament object", "obj", t);
|
|
5182
5182
|
}
|
|
5183
5183
|
/**
|
|
5184
5184
|
* Returns true if %%value%% is a [[ConstructorFragment]].
|
|
@@ -5220,7 +5220,7 @@ class jn extends $e {
|
|
|
5220
5220
|
* @private
|
|
5221
5221
|
*/
|
|
5222
5222
|
constructor(t, n, r, s) {
|
|
5223
|
-
super(t, n, s),
|
|
5223
|
+
super(t, n, s), m(typeof r == "string" && r.match(eo), "invalid identifier", "name", r), s = Object.freeze(s.slice()), st(this, { name: r });
|
|
5224
5224
|
}
|
|
5225
5225
|
}
|
|
5226
5226
|
function dn(e, t) {
|
|
@@ -5321,7 +5321,7 @@ class Vt extends jn {
|
|
|
5321
5321
|
try {
|
|
5322
5322
|
return Vt.from(Se(t));
|
|
5323
5323
|
} catch {
|
|
5324
|
-
|
|
5324
|
+
m(!1, "invalid event fragment", "obj", t);
|
|
5325
5325
|
}
|
|
5326
5326
|
else if (t instanceof qt) {
|
|
5327
5327
|
const n = Jn("event", t), r = ce(t, !0), s = !!ue(t, Ot(["anonymous"])).has("anonymous");
|
|
@@ -5377,11 +5377,11 @@ class oe extends $e {
|
|
|
5377
5377
|
try {
|
|
5378
5378
|
return oe.from(Se(t));
|
|
5379
5379
|
} catch {
|
|
5380
|
-
|
|
5380
|
+
m(!1, "invalid constuctor fragment", "obj", t);
|
|
5381
5381
|
}
|
|
5382
5382
|
else if (t instanceof qt) {
|
|
5383
5383
|
ue(t, Ot(["constructor"]));
|
|
5384
|
-
const n = ce(t), r = !!ue(t,
|
|
5384
|
+
const n = ce(t), r = !!ue(t, pu).has("payable"), s = so(t);
|
|
5385
5385
|
return Ce(t), new oe(ot, "constructor", n, r, s);
|
|
5386
5386
|
}
|
|
5387
5387
|
return new oe(ot, "constructor", t.inputs ? t.inputs.map(nt.from) : [], !!t.payable, t.gas != null ? t.gas : null);
|
|
@@ -5423,20 +5423,20 @@ class se extends $e {
|
|
|
5423
5423
|
try {
|
|
5424
5424
|
return se.from(Se(t));
|
|
5425
5425
|
} catch {
|
|
5426
|
-
|
|
5426
|
+
m(!1, "invalid fallback fragment", "obj", t);
|
|
5427
5427
|
}
|
|
5428
5428
|
else if (t instanceof qt) {
|
|
5429
5429
|
const n = t.toString(), r = t.peekKeyword(Ot(["fallback", "receive"]));
|
|
5430
|
-
if (
|
|
5430
|
+
if (m(r, "type must be fallback or receive", "obj", n), t.popKeyword(Ot(["fallback", "receive"])) === "receive") {
|
|
5431
5431
|
const a = ce(t);
|
|
5432
|
-
return
|
|
5432
|
+
return m(a.length === 0, "receive cannot have arguments", "obj.inputs", a), ue(t, Ot(["payable"])), Ce(t), new se(ot, [], !0);
|
|
5433
5433
|
}
|
|
5434
5434
|
let i = ce(t);
|
|
5435
|
-
i.length ?
|
|
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
5436
|
const o = ro(t);
|
|
5437
|
-
if (
|
|
5437
|
+
if (m(o === "nonpayable" || o === "payable", "fallback cannot be constants", "obj.stateMutability", o), ue(t, Ot(["returns"])).has("returns")) {
|
|
5438
5438
|
const a = ce(t);
|
|
5439
|
-
|
|
5439
|
+
m(a.length === 1 && a[0].type === "bytes", "invalid fallback outputs", "obj.outputs", a.map((c) => c.format("minimal")).join(", "));
|
|
5440
5440
|
}
|
|
5441
5441
|
return Ce(t), new se(ot, i, o === "payable");
|
|
5442
5442
|
}
|
|
@@ -5446,7 +5446,7 @@ class se extends $e {
|
|
|
5446
5446
|
const n = [nt.from("bytes")], r = t.stateMutability === "payable";
|
|
5447
5447
|
return new se(ot, n, r);
|
|
5448
5448
|
}
|
|
5449
|
-
|
|
5449
|
+
m(!1, "invalid fallback description", "obj", t);
|
|
5450
5450
|
}
|
|
5451
5451
|
/**
|
|
5452
5452
|
* Returns ``true`` and provides a type guard if %%value%% is a
|
|
@@ -5524,7 +5524,7 @@ class Zt extends jn {
|
|
|
5524
5524
|
try {
|
|
5525
5525
|
return Zt.from(Se(t));
|
|
5526
5526
|
} catch {
|
|
5527
|
-
|
|
5527
|
+
m(!1, "invalid function fragment", "obj", t);
|
|
5528
5528
|
}
|
|
5529
5529
|
else if (t instanceof qt) {
|
|
5530
5530
|
const r = Jn("function", t), s = ce(t), i = ro(t);
|
|
@@ -5565,7 +5565,7 @@ class Ne extends jn {
|
|
|
5565
5565
|
try {
|
|
5566
5566
|
return Ne.from(Se(t));
|
|
5567
5567
|
} catch {
|
|
5568
|
-
|
|
5568
|
+
m(!1, "invalid struct fragment", "obj", t);
|
|
5569
5569
|
}
|
|
5570
5570
|
else if (t instanceof qt) {
|
|
5571
5571
|
const n = Jn("struct", t), r = ce(t);
|
|
@@ -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
|
|
5596
|
+
const Bu = new RegExp(/^bytes([0-9]*)$/), vu = new RegExp(/^(u?int)([0-9]*)$/);
|
|
5597
5597
|
let mr = null, Fs = 1024;
|
|
5598
|
-
function
|
|
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;
|
|
@@ -5646,31 +5646,31 @@ function vu(e, t, n, r) {
|
|
|
5646
5646
|
class le {
|
|
5647
5647
|
#t(t) {
|
|
5648
5648
|
if (t.isArray())
|
|
5649
|
-
return new
|
|
5649
|
+
return new jc(this.#t(t.arrayChildren), t.arrayLength, t.name);
|
|
5650
5650
|
if (t.isTuple())
|
|
5651
5651
|
return new kn(t.components.map((r) => this.#t(r)), t.name);
|
|
5652
5652
|
switch (t.baseType) {
|
|
5653
5653
|
case "address":
|
|
5654
|
-
return new
|
|
5654
|
+
return new Xc(t.name);
|
|
5655
5655
|
case "bool":
|
|
5656
|
-
return new
|
|
5656
|
+
return new Qc(t.name);
|
|
5657
5657
|
case "string":
|
|
5658
|
-
return new
|
|
5658
|
+
return new cu(t.name);
|
|
5659
5659
|
case "bytes":
|
|
5660
|
-
return new
|
|
5660
|
+
return new tu(t.name);
|
|
5661
5661
|
case "":
|
|
5662
|
-
return new
|
|
5662
|
+
return new ru(t.name);
|
|
5663
5663
|
}
|
|
5664
|
-
let n = t.type.match(
|
|
5664
|
+
let n = t.type.match(vu);
|
|
5665
5665
|
if (n) {
|
|
5666
5666
|
let r = parseInt(n[2] || "256");
|
|
5667
|
-
return
|
|
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(
|
|
5669
|
+
if (n = t.type.match(Bu), n) {
|
|
5670
5670
|
let r = parseInt(n[1]);
|
|
5671
|
-
return
|
|
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
|
}
|
|
5675
5675
|
/**
|
|
5676
5676
|
* Get the default values for the given %%types%%.
|
|
@@ -5704,7 +5704,7 @@ class le {
|
|
|
5704
5704
|
return new kn(s, "_").decode(new Dr(n, r, Fs));
|
|
5705
5705
|
}
|
|
5706
5706
|
static _setDefaultMaxInflation(t) {
|
|
5707
|
-
|
|
5707
|
+
m(typeof t == "number" && Number.isInteger(t), "invalid defaultMaxInflation factor", "value", t), Fs = t;
|
|
5708
5708
|
}
|
|
5709
5709
|
/**
|
|
5710
5710
|
* Returns the shared singleton instance of a default [[AbiCoder]].
|
|
@@ -5720,10 +5720,10 @@ class le {
|
|
|
5720
5720
|
* the Transaction %%tx%%.
|
|
5721
5721
|
*/
|
|
5722
5722
|
static getBuiltinCallException(t, n, r) {
|
|
5723
|
-
return
|
|
5723
|
+
return Ou(t, n, r, le.defaultAbiCoder());
|
|
5724
5724
|
}
|
|
5725
5725
|
}
|
|
5726
|
-
class
|
|
5726
|
+
class Tu {
|
|
5727
5727
|
/**
|
|
5728
5728
|
* The matching fragment for the ``topic0``.
|
|
5729
5729
|
*/
|
|
@@ -5758,7 +5758,7 @@ class Ou {
|
|
|
5758
5758
|
});
|
|
5759
5759
|
}
|
|
5760
5760
|
}
|
|
5761
|
-
class
|
|
5761
|
+
class Iu {
|
|
5762
5762
|
/**
|
|
5763
5763
|
* The matching fragment from the transaction ``data``.
|
|
5764
5764
|
*/
|
|
@@ -5798,7 +5798,7 @@ class Tu {
|
|
|
5798
5798
|
});
|
|
5799
5799
|
}
|
|
5800
5800
|
}
|
|
5801
|
-
class
|
|
5801
|
+
class Ru {
|
|
5802
5802
|
/**
|
|
5803
5803
|
* The matching fragment.
|
|
5804
5804
|
*/
|
|
@@ -5935,7 +5935,7 @@ class ge {
|
|
|
5935
5935
|
st(this, { deploy: o });
|
|
5936
5936
|
return;
|
|
5937
5937
|
case "fallback":
|
|
5938
|
-
o.inputs.length === 0 ? i = !0 : (
|
|
5938
|
+
o.inputs.length === 0 ? i = !0 : (m(!s || o.payable !== s.payable, "conflicting fallback fragments", `fragments[${a}]`, o), s = o, i = s.payable);
|
|
5939
5939
|
return;
|
|
5940
5940
|
case "function":
|
|
5941
5941
|
c = this.#n;
|
|
@@ -6028,7 +6028,7 @@ class ge {
|
|
|
6028
6028
|
return null;
|
|
6029
6029
|
if (i.length > 1 && r) {
|
|
6030
6030
|
const o = i.map((a) => JSON.stringify(a.format())).join(", ");
|
|
6031
|
-
|
|
6031
|
+
m(!1, `ambiguous function description (i.e. matches ${o})`, "key", t);
|
|
6032
6032
|
}
|
|
6033
6033
|
return i[0];
|
|
6034
6034
|
}
|
|
@@ -6041,7 +6041,7 @@ class ge {
|
|
|
6041
6041
|
*/
|
|
6042
6042
|
getFunctionName(t) {
|
|
6043
6043
|
const n = this.#s(t, null, !1);
|
|
6044
|
-
return
|
|
6044
|
+
return m(n, "no matching function", "key", t), n.name;
|
|
6045
6045
|
}
|
|
6046
6046
|
/**
|
|
6047
6047
|
* Returns true if %%key%% (a function selector, function name or
|
|
@@ -6109,7 +6109,7 @@ class ge {
|
|
|
6109
6109
|
return null;
|
|
6110
6110
|
if (i.length > 1 && r) {
|
|
6111
6111
|
const o = i.map((a) => JSON.stringify(a.format())).join(", ");
|
|
6112
|
-
|
|
6112
|
+
m(!1, `ambiguous event description (i.e. matches ${o})`, "key", t);
|
|
6113
6113
|
}
|
|
6114
6114
|
return i[0];
|
|
6115
6115
|
}
|
|
@@ -6122,7 +6122,7 @@ class ge {
|
|
|
6122
6122
|
*/
|
|
6123
6123
|
getEventName(t) {
|
|
6124
6124
|
const n = this.#i(t, null, !1);
|
|
6125
|
-
return
|
|
6125
|
+
return m(n, "no matching event", "key", t), n.name;
|
|
6126
6126
|
}
|
|
6127
6127
|
/**
|
|
6128
6128
|
* Returns true if %%key%% (an event topic hash, event name or
|
|
@@ -6189,7 +6189,7 @@ class ge {
|
|
|
6189
6189
|
return t === "Error" ? kt.from("error Error(string)") : t === "Panic" ? kt.from("error Panic(uint256)") : null;
|
|
6190
6190
|
if (s.length > 1) {
|
|
6191
6191
|
const i = s.map((o) => JSON.stringify(o.format())).join(", ");
|
|
6192
|
-
|
|
6192
|
+
m(!1, `ambiguous error description (i.e. ${i})`, "name", t);
|
|
6193
6193
|
}
|
|
6194
6194
|
return s[0];
|
|
6195
6195
|
}
|
|
@@ -6264,9 +6264,9 @@ class ge {
|
|
|
6264
6264
|
decodeErrorResult(t, n) {
|
|
6265
6265
|
if (typeof t == "string") {
|
|
6266
6266
|
const r = this.getError(t);
|
|
6267
|
-
|
|
6267
|
+
m(r, "unknown error", "fragment", t), t = r;
|
|
6268
6268
|
}
|
|
6269
|
-
return
|
|
6269
|
+
return m(Me(n, 0, 4) === t.selector, `data signature does not match error ${t.name}.`, "data", n), this._decodeParams(t.inputs, Me(n, 4));
|
|
6270
6270
|
}
|
|
6271
6271
|
/**
|
|
6272
6272
|
* Encodes the transaction revert data for a call result that
|
|
@@ -6279,9 +6279,9 @@ class ge {
|
|
|
6279
6279
|
encodeErrorResult(t, n) {
|
|
6280
6280
|
if (typeof t == "string") {
|
|
6281
6281
|
const r = this.getError(t);
|
|
6282
|
-
|
|
6282
|
+
m(r, "unknown error", "fragment", t), t = r;
|
|
6283
6283
|
}
|
|
6284
|
-
return
|
|
6284
|
+
return _e([
|
|
6285
6285
|
t.selector,
|
|
6286
6286
|
this._encodeParams(t.inputs, n || [])
|
|
6287
6287
|
]);
|
|
@@ -6297,9 +6297,9 @@ class ge {
|
|
|
6297
6297
|
decodeFunctionData(t, n) {
|
|
6298
6298
|
if (typeof t == "string") {
|
|
6299
6299
|
const r = this.getFunction(t);
|
|
6300
|
-
|
|
6300
|
+
m(r, "unknown function", "fragment", t), t = r;
|
|
6301
6301
|
}
|
|
6302
|
-
return
|
|
6302
|
+
return m(Me(n, 0, 4) === t.selector, `data signature does not match function ${t.name}.`, "data", n), this._decodeParams(t.inputs, Me(n, 4));
|
|
6303
6303
|
}
|
|
6304
6304
|
/**
|
|
6305
6305
|
* Encodes the ``tx.data`` for a transaction that calls the function
|
|
@@ -6309,9 +6309,9 @@ class ge {
|
|
|
6309
6309
|
encodeFunctionData(t, n) {
|
|
6310
6310
|
if (typeof t == "string") {
|
|
6311
6311
|
const r = this.getFunction(t);
|
|
6312
|
-
|
|
6312
|
+
m(r, "unknown function", "fragment", t), t = r;
|
|
6313
6313
|
}
|
|
6314
|
-
return
|
|
6314
|
+
return _e([
|
|
6315
6315
|
t.selector,
|
|
6316
6316
|
this._encodeParams(t.inputs, n || [])
|
|
6317
6317
|
]);
|
|
@@ -6328,7 +6328,7 @@ class ge {
|
|
|
6328
6328
|
decodeFunctionResult(t, n) {
|
|
6329
6329
|
if (typeof t == "string") {
|
|
6330
6330
|
const i = this.getFunction(t);
|
|
6331
|
-
|
|
6331
|
+
m(i, "unknown function", "fragment", t), t = i;
|
|
6332
6332
|
}
|
|
6333
6333
|
let r = "invalid length for result data";
|
|
6334
6334
|
const s = Kt(n);
|
|
@@ -6377,7 +6377,7 @@ class ge {
|
|
|
6377
6377
|
encodeFunctionResult(t, n) {
|
|
6378
6378
|
if (typeof t == "string") {
|
|
6379
6379
|
const r = this.getFunction(t);
|
|
6380
|
-
|
|
6380
|
+
m(r, "unknown function", "fragment", t), t = r;
|
|
6381
6381
|
}
|
|
6382
6382
|
return bt(this.#r.encode(t.outputs, n || []));
|
|
6383
6383
|
}
|
|
@@ -6415,7 +6415,7 @@ class ge {
|
|
|
6415
6415
|
encodeFilterTopics(t, n) {
|
|
6416
6416
|
if (typeof t == "string") {
|
|
6417
6417
|
const i = this.getEvent(t);
|
|
6418
|
-
|
|
6418
|
+
m(i, "unknown event", "eventFragment", t), t = i;
|
|
6419
6419
|
}
|
|
6420
6420
|
ct(n.length <= t.inputs.length, `too many arguments for ${t.format()}`, "UNEXPECTED_ARGUMENT", { count: n.length, expectedCount: t.inputs.length });
|
|
6421
6421
|
const r = [];
|
|
@@ -6424,10 +6424,10 @@ class ge {
|
|
|
6424
6424
|
for (n.forEach((i, o) => {
|
|
6425
6425
|
const a = t.inputs[o];
|
|
6426
6426
|
if (!a.indexed) {
|
|
6427
|
-
|
|
6427
|
+
m(i == null, "cannot filter non-indexed parameters; must be null", "contract." + a.name, i);
|
|
6428
6428
|
return;
|
|
6429
6429
|
}
|
|
6430
|
-
i == null ? r.push(null) : a.baseType === "array" || a.baseType === "tuple" ?
|
|
6430
|
+
i == null ? r.push(null) : a.baseType === "array" || a.baseType === "tuple" ? m(!1, "filtering with tuples or arrays not supported", "contract." + a.name, i) : Array.isArray(i) ? r.push(i.map((c) => s(a, c))) : r.push(s(a, i));
|
|
6431
6431
|
}); r.length && r[r.length - 1] === null; )
|
|
6432
6432
|
r.pop();
|
|
6433
6433
|
return r;
|
|
@@ -6435,10 +6435,10 @@ class ge {
|
|
|
6435
6435
|
encodeEventLog(t, n) {
|
|
6436
6436
|
if (typeof t == "string") {
|
|
6437
6437
|
const o = this.getEvent(t);
|
|
6438
|
-
|
|
6438
|
+
m(o, "unknown event", "eventFragment", t), t = o;
|
|
6439
6439
|
}
|
|
6440
6440
|
const r = [], s = [], i = [];
|
|
6441
|
-
return t.anonymous || r.push(t.topicHash),
|
|
6441
|
+
return t.anonymous || r.push(t.topicHash), m(n.length === t.inputs.length, "event arguments/values mismatch", "values", n), t.inputs.forEach((o, a) => {
|
|
6442
6442
|
const c = n[a];
|
|
6443
6443
|
if (o.indexed)
|
|
6444
6444
|
if (o.type === "string")
|
|
@@ -6461,17 +6461,17 @@ class ge {
|
|
|
6461
6461
|
decodeEventLog(t, n, r) {
|
|
6462
6462
|
if (typeof t == "string") {
|
|
6463
6463
|
const p = this.getEvent(t);
|
|
6464
|
-
|
|
6464
|
+
m(p, "unknown event", "eventFragment", t), t = p;
|
|
6465
6465
|
}
|
|
6466
6466
|
if (r != null && !t.anonymous) {
|
|
6467
6467
|
const p = t.topicHash;
|
|
6468
|
-
|
|
6468
|
+
m(on(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) => {
|
|
6472
6472
|
p.indexed ? p.type === "string" || p.type === "bytes" || p.baseType === "tuple" || p.baseType === "array" ? (s.push(nt.from({ type: "bytes32", name: p.name })), o.push(!0)) : (s.push(p), o.push(!1)) : (i.push(p), o.push(!1));
|
|
6473
6473
|
});
|
|
6474
|
-
const a = r != null ? this.#r.decode(s,
|
|
6474
|
+
const a = r != null ? this.#r.decode(s, _e(r)) : null, c = this.#r.decode(i, n, !0), u = [], l = [];
|
|
6475
6475
|
let f = 0, d = 0;
|
|
6476
6476
|
return t.inputs.forEach((p, w) => {
|
|
6477
6477
|
let h = null;
|
|
@@ -6506,7 +6506,7 @@ class ge {
|
|
|
6506
6506
|
if (!s)
|
|
6507
6507
|
return null;
|
|
6508
6508
|
const i = this.#r.decode(s.inputs, n.slice(4));
|
|
6509
|
-
return new
|
|
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
|
|
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, Me(n, 4));
|
|
6535
|
-
return new
|
|
6535
|
+
return new Ru(r, r.selector, s);
|
|
6536
6536
|
}
|
|
6537
6537
|
/**
|
|
6538
6538
|
* Creates a new [[Interface]] from the ABI %%value%%.
|
|
@@ -6544,14 +6544,14 @@ 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 io = "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.",
|
|
6547
|
+
const io = "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 We(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
|
|
6554
|
+
function Nu(e) {
|
|
6555
6555
|
if (e == null)
|
|
6556
6556
|
throw new Error(io);
|
|
6557
6557
|
if (typeof e != "object")
|
|
@@ -6573,7 +6573,7 @@ function ku(e) {
|
|
|
6573
6573
|
throw We("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 (!
|
|
6576
|
+
if (!ku.test(c))
|
|
6577
6577
|
throw We(`priority_tokens contains an invalid address (${String(a)})`);
|
|
6578
6578
|
return c;
|
|
6579
6579
|
});
|
|
@@ -6586,7 +6586,7 @@ function ku(e) {
|
|
|
6586
6586
|
min_btc_exposure_sats: s
|
|
6587
6587
|
};
|
|
6588
6588
|
}
|
|
6589
|
-
function
|
|
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,8 +6594,8 @@ function Nu(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
|
|
6598
|
-
function
|
|
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
|
}
|
|
@@ -6605,12 +6605,12 @@ function oo(e) {
|
|
|
6605
6605
|
throw new RangeError("satsToBtc: amount exceeds safe-integer precision (~90,000 BTC).");
|
|
6606
6606
|
return Number(e) / 1e8;
|
|
6607
6607
|
}
|
|
6608
|
-
function
|
|
6608
|
+
function Au(e, t) {
|
|
6609
6609
|
return oo(e) * t;
|
|
6610
6610
|
}
|
|
6611
6611
|
function ao(e, t, n, r, s) {
|
|
6612
6612
|
return {
|
|
6613
|
-
pool_fee_bps:
|
|
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,
|
|
@@ -6626,7 +6626,7 @@ let gt = "", Gr = "";
|
|
|
6626
6626
|
function Qn(e, t) {
|
|
6627
6627
|
gt = e.toLowerCase(), Gr = t.toLowerCase();
|
|
6628
6628
|
}
|
|
6629
|
-
function
|
|
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
|
|
6658
|
+
async function Fu(e, t, n) {
|
|
6659
6659
|
t.toLowerCase() > n.toLowerCase() && ([t, n] = [n, t]);
|
|
6660
6660
|
const r = await e.reservesOf(tr(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
|
|
6665
|
+
class Uu {
|
|
6666
6666
|
map;
|
|
6667
6667
|
proxy;
|
|
6668
6668
|
constructor() {
|
|
@@ -6697,7 +6697,7 @@ class Fu {
|
|
|
6697
6697
|
this.map[s] = r;
|
|
6698
6698
|
}
|
|
6699
6699
|
}
|
|
6700
|
-
class
|
|
6700
|
+
class qu {
|
|
6701
6701
|
map;
|
|
6702
6702
|
proxy;
|
|
6703
6703
|
constructor() {
|
|
@@ -6718,7 +6718,7 @@ class Uu {
|
|
|
6718
6718
|
throw new Error("Undefined reserves encountered");
|
|
6719
6719
|
return this.map[r];
|
|
6720
6720
|
}
|
|
6721
|
-
const s = await
|
|
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,8 +6728,8 @@ class Uu {
|
|
|
6728
6728
|
this.map[s] = r;
|
|
6729
6729
|
}
|
|
6730
6730
|
}
|
|
6731
|
-
const C = new
|
|
6732
|
-
function
|
|
6731
|
+
const C = new Uu(), it = new qu();
|
|
6732
|
+
function _n(e) {
|
|
6733
6733
|
if (gt === "" || Gr === "")
|
|
6734
6734
|
throw new Error("Uniswap info not set");
|
|
6735
6735
|
C.clear(e), it.clear(e);
|
|
@@ -6737,7 +6737,7 @@ function xn(e) {
|
|
|
6737
6737
|
function uo(e, t) {
|
|
6738
6738
|
return e < t ? e + t : t + e;
|
|
6739
6739
|
}
|
|
6740
|
-
function
|
|
6740
|
+
function Du(e, t, n) {
|
|
6741
6741
|
if (e <= 0n)
|
|
6742
6742
|
throw new Error("Insufficient input amount");
|
|
6743
6743
|
if (t <= 0n || n <= 0n)
|
|
@@ -6745,7 +6745,7 @@ function qu(e, t, n) {
|
|
|
6745
6745
|
const r = e * 997n, s = r * n, i = t * 1000n + r;
|
|
6746
6746
|
return s / i;
|
|
6747
6747
|
}
|
|
6748
|
-
function
|
|
6748
|
+
function Mu(e, t, n) {
|
|
6749
6749
|
if (e <= 0n)
|
|
6750
6750
|
throw new Error("Insufficient output amount");
|
|
6751
6751
|
if (t <= 0n || n <= 0n || e >= n)
|
|
@@ -6753,23 +6753,23 @@ function Du(e, t, n) {
|
|
|
6753
6753
|
const r = t * e * 1000n, s = (n - e) * 997n;
|
|
6754
6754
|
return r / s + 1n;
|
|
6755
6755
|
}
|
|
6756
|
-
async function
|
|
6756
|
+
async function Wu(e, t) {
|
|
6757
6757
|
if (t.length < 2)
|
|
6758
6758
|
throw new Error("Invalid path");
|
|
6759
6759
|
const n = [e];
|
|
6760
6760
|
for (let r = 0; r < t.length - 1; r++) {
|
|
6761
|
-
const { reserveA: s, reserveB: i } = await Xt(t[r], t[r + 1]), o =
|
|
6761
|
+
const { reserveA: s, reserveB: i } = await Xt(t[r], t[r + 1]), o = Du(n[r], s, i);
|
|
6762
6762
|
n.push(o);
|
|
6763
6763
|
}
|
|
6764
6764
|
return n;
|
|
6765
6765
|
}
|
|
6766
|
-
async function
|
|
6766
|
+
async function Gu(e, t) {
|
|
6767
6767
|
if (t.length < 2)
|
|
6768
6768
|
throw new Error("Invalid path");
|
|
6769
6769
|
const n = [];
|
|
6770
6770
|
n[t.length - 1] = e;
|
|
6771
6771
|
for (let r = t.length - 1; r > 0; r--) {
|
|
6772
|
-
const { reserveA: s, reserveB: i } = await Xt(t[r - 1], t[r]), o =
|
|
6772
|
+
const { reserveA: s, reserveB: i } = await Xt(t[r - 1], t[r]), o = Mu(n[r], s, i);
|
|
6773
6773
|
n[r - 1] = o;
|
|
6774
6774
|
}
|
|
6775
6775
|
return n;
|
|
@@ -6795,8 +6795,8 @@ async function Xt(e, t) {
|
|
|
6795
6795
|
total_supply: n.total_supply
|
|
6796
6796
|
};
|
|
6797
6797
|
}
|
|
6798
|
-
const
|
|
6799
|
-
async function
|
|
6798
|
+
const Hu = (...e) => e.reduce((t, n) => n < t ? n : t);
|
|
6799
|
+
async function Vu(e, t, n, r) {
|
|
6800
6800
|
const {
|
|
6801
6801
|
reserveA: s,
|
|
6802
6802
|
reserveB: i,
|
|
@@ -6804,7 +6804,7 @@ async function Hu(e, t, n, r) {
|
|
|
6804
6804
|
} = await Xt(e, t), a = s - n, c = i - r;
|
|
6805
6805
|
let u;
|
|
6806
6806
|
if (o === 0n) {
|
|
6807
|
-
u =
|
|
6807
|
+
u = Pu(n * r) - 1000n;
|
|
6808
6808
|
const f = await it.get(e, t);
|
|
6809
6809
|
it.set(e, t, {
|
|
6810
6810
|
reserveA: f.reserveA,
|
|
@@ -6812,7 +6812,7 @@ async function Hu(e, t, n, r) {
|
|
|
6812
6812
|
total_supply: f.total_supply + 1000n
|
|
6813
6813
|
});
|
|
6814
6814
|
} else
|
|
6815
|
-
u =
|
|
6815
|
+
u = Hu(n * o / a, r * o / c);
|
|
6816
6816
|
if (u <= 0n)
|
|
6817
6817
|
throw new Error("Insufficient liquidity minted");
|
|
6818
6818
|
const l = await it.get(e, t);
|
|
@@ -6822,7 +6822,7 @@ async function Hu(e, t, n, r) {
|
|
|
6822
6822
|
total_supply: l.total_supply + u
|
|
6823
6823
|
}), u;
|
|
6824
6824
|
}
|
|
6825
|
-
async function
|
|
6825
|
+
async function Zu(e, t, n, r, s, i) {
|
|
6826
6826
|
let o, a;
|
|
6827
6827
|
try {
|
|
6828
6828
|
await it.get(e, t);
|
|
@@ -6847,8 +6847,8 @@ async function Vu(e, t, n, r, s, i) {
|
|
|
6847
6847
|
}
|
|
6848
6848
|
return { amountA: o, amountB: a };
|
|
6849
6849
|
}
|
|
6850
|
-
async function
|
|
6851
|
-
const { amountA: o, amountB: a } = await
|
|
6850
|
+
async function Yu(e, t, n, r, s, i) {
|
|
6851
|
+
const { amountA: o, amountB: a } = await Zu(
|
|
6852
6852
|
e,
|
|
6853
6853
|
t,
|
|
6854
6854
|
n,
|
|
@@ -6865,10 +6865,10 @@ async function Zu(e, t, n, r, s, i) {
|
|
|
6865
6865
|
reserveB: c.reserveB + o,
|
|
6866
6866
|
total_supply: c.total_supply
|
|
6867
6867
|
});
|
|
6868
|
-
const u = await
|
|
6868
|
+
const u = await Vu(e, t, o, a);
|
|
6869
6869
|
return { amountA: o, amountB: a, liquidity: u };
|
|
6870
6870
|
}
|
|
6871
|
-
async function
|
|
6871
|
+
async function zu(e, t, n) {
|
|
6872
6872
|
const {
|
|
6873
6873
|
reserveA: r,
|
|
6874
6874
|
reserveB: s,
|
|
@@ -6884,7 +6884,7 @@ async function Yu(e, t, n) {
|
|
|
6884
6884
|
total_supply: u
|
|
6885
6885
|
}), { amountA: o, amountB: a };
|
|
6886
6886
|
}
|
|
6887
|
-
async function
|
|
6887
|
+
async function Ku(e, t, n, r, s, i, o, a) {
|
|
6888
6888
|
if (s <= 0n && i <= 0n)
|
|
6889
6889
|
throw new Error("Insufficient output amount");
|
|
6890
6890
|
const { reserveA: c, reserveB: u } = await Xt(e, t), l = c - n, f = u - r;
|
|
@@ -6896,22 +6896,22 @@ async function zu(e, t, n, r, s, i, o, a) {
|
|
|
6896
6896
|
reserveB: d.reserveB - i,
|
|
6897
6897
|
total_supply: d.total_supply
|
|
6898
6898
|
}), o !== null) {
|
|
6899
|
-
const O = o[0], F = o[1],
|
|
6899
|
+
const O = o[0], F = o[1], W = await it.get(O, F);
|
|
6900
6900
|
a ? it.set(O, F, {
|
|
6901
|
-
reserveA:
|
|
6902
|
-
reserveB:
|
|
6903
|
-
total_supply:
|
|
6901
|
+
reserveA: W.reserveA + i,
|
|
6902
|
+
reserveB: W.reserveB + s,
|
|
6903
|
+
total_supply: W.total_supply
|
|
6904
6904
|
}) : it.set(O, F, {
|
|
6905
|
-
reserveA:
|
|
6906
|
-
reserveB:
|
|
6907
|
-
total_supply:
|
|
6905
|
+
reserveA: W.reserveA + s,
|
|
6906
|
+
reserveB: W.reserveB + i,
|
|
6907
|
+
total_supply: W.total_supply
|
|
6908
6908
|
});
|
|
6909
6909
|
}
|
|
6910
6910
|
const p = (await it.get(e, t)).reserveA, w = (await it.get(e, t)).reserveB, h = p > l - s ? p - (l - s) : 0n, g = w > f - i ? w - (f - i) : 0n;
|
|
6911
6911
|
if (h <= 0n && g <= 0n)
|
|
6912
6912
|
throw new Error("Insufficient input amount");
|
|
6913
|
-
const b = p * 1000n - h * 3n,
|
|
6914
|
-
if (b *
|
|
6913
|
+
const b = p * 1000n - h * 3n, v = w * 1000n - g * 3n;
|
|
6914
|
+
if (b * v < BigInt(l) * BigInt(f) * 1000n * 1000n)
|
|
6915
6915
|
throw new Error("K");
|
|
6916
6916
|
}
|
|
6917
6917
|
async function lo(e, t) {
|
|
@@ -6934,51 +6934,51 @@ async function lo(e, t) {
|
|
|
6934
6934
|
if (s === void 0 || i === void 0 || o === void 0 || a === void 0)
|
|
6935
6935
|
throw new Error("Undefined value in swap path or amounts");
|
|
6936
6936
|
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];
|
|
6937
|
-
await
|
|
6937
|
+
await Ku(d, p, c, u, l, f, w, h);
|
|
6938
6938
|
}
|
|
6939
6939
|
}
|
|
6940
|
-
async function
|
|
6940
|
+
async function Xu(e, t, n) {
|
|
6941
6941
|
if (n.length < 2)
|
|
6942
6942
|
throw new Error("Invalid path");
|
|
6943
|
-
const r = await
|
|
6943
|
+
const r = await Wu(e, n);
|
|
6944
6944
|
if (r[r.length - 1] < t)
|
|
6945
6945
|
throw new Error("Insufficient output amount");
|
|
6946
6946
|
return await lo(r, n), r;
|
|
6947
6947
|
}
|
|
6948
|
-
async function
|
|
6948
|
+
async function Ju(e, t, n) {
|
|
6949
6949
|
if (n.length < 2)
|
|
6950
6950
|
throw new Error("Invalid path");
|
|
6951
|
-
const r = await
|
|
6951
|
+
const r = await Gu(t, n);
|
|
6952
6952
|
if (r[0] > e)
|
|
6953
6953
|
throw new Error("Excessive Input Amount");
|
|
6954
6954
|
return await lo(r, n), r;
|
|
6955
6955
|
}
|
|
6956
|
-
async function
|
|
6957
|
-
const { amountA: i, amountB: o } = await
|
|
6956
|
+
async function ju(e, t, n, r, s) {
|
|
6957
|
+
const { amountA: i, amountB: o } = await zu(e, t, n);
|
|
6958
6958
|
if (i < r)
|
|
6959
6959
|
throw new Error("Insufficient A amount");
|
|
6960
6960
|
if (o < s)
|
|
6961
6961
|
throw new Error("Insufficient B amount");
|
|
6962
6962
|
return { amountA: i, amountB: o };
|
|
6963
6963
|
}
|
|
6964
|
-
function
|
|
6964
|
+
function Qu(e, t, n, r, s, i, o, a, c, u, l, f) {
|
|
6965
6965
|
if (f === "")
|
|
6966
6966
|
return !0;
|
|
6967
6967
|
let d = tt(S.from(e, "hex")).slice(2);
|
|
6968
6968
|
d += t.toString(16).padStart(8, "0"), d += "01", d += n.slice(2).padStart(40, "0"), d += r.slice(2).padStart(40, "0"), d += s.toString(16).padStart(64, "0"), d += i.toString(16).padStart(64, "0"), d += o.toString(16).padStart(64, "0"), d += a.toString(16).padStart(64, "0"), d += c.toString(16).padStart(64, "0"), d += u.toString(16).padStart(64, "0"), d += l.toString(16).padStart(64, "0");
|
|
6969
6969
|
const p = S.from(d, "hex"), w = T.G1.hashToCurve(p, {
|
|
6970
6970
|
DST: "BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"
|
|
6971
|
-
}), h = BigInt(`0x${f.slice(0, 128)}`), g = BigInt(`0x${f.slice(128, 256)}`), b = new T.G1.Point(h, g, BigInt(1)),
|
|
6972
|
-
T.fields.Fp2.create({ c0:
|
|
6973
|
-
T.fields.Fp2.create({ c0: F, c1:
|
|
6971
|
+
}), h = BigInt(`0x${f.slice(0, 128)}`), g = BigInt(`0x${f.slice(128, 256)}`), b = new T.G1.Point(h, g, BigInt(1)), v = BigInt(`0x${e.slice(0, 128)}`), O = BigInt(`0x${e.slice(128, 256)}`), F = BigInt(`0x${e.slice(256, 384)}`), W = BigInt(`0x${e.slice(384, 512)}`), A = new T.G2.Point(
|
|
6972
|
+
T.fields.Fp2.create({ c0: v, c1: O }),
|
|
6973
|
+
T.fields.Fp2.create({ c0: F, c1: W }),
|
|
6974
6974
|
T.fields.Fp2.ONE
|
|
6975
6975
|
);
|
|
6976
|
-
return T.shortSignatures.verify(b, w,
|
|
6976
|
+
return T.shortSignatures.verify(b, w, A);
|
|
6977
6977
|
}
|
|
6978
|
-
async function
|
|
6979
|
-
n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, c = c.startsWith("0x") ? c.slice(2) : c,
|
|
6978
|
+
async function tl(e, t, n, r, s, i, o, a, c, u, l, f, d) {
|
|
6979
|
+
n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, c = c.startsWith("0x") ? c.slice(2) : c, _n(e);
|
|
6980
6980
|
try {
|
|
6981
|
-
if (!
|
|
6981
|
+
if (!Qu(
|
|
6982
6982
|
t,
|
|
6983
6983
|
u,
|
|
6984
6984
|
n,
|
|
@@ -6993,7 +6993,7 @@ async function Qu(e, t, n, r, s, i, o, a, c, u, l, f, d) {
|
|
|
6993
6993
|
c
|
|
6994
6994
|
))
|
|
6995
6995
|
throw new Error("Invalid BLS signature");
|
|
6996
|
-
const { amountA: p, amountB: w, liquidity: h } = await
|
|
6996
|
+
const { amountA: p, amountB: w, liquidity: h } = await Yu(
|
|
6997
6997
|
n,
|
|
6998
6998
|
r,
|
|
6999
6999
|
s,
|
|
@@ -7030,24 +7030,24 @@ async function Qu(e, t, n, r, s, i, o, a, c, u, l, f, d) {
|
|
|
7030
7030
|
return console.error("Error in add_liquidity_request:", p), { success: !1, error_message: p.message };
|
|
7031
7031
|
}
|
|
7032
7032
|
}
|
|
7033
|
-
function
|
|
7033
|
+
function el(e, t, n, r, s, i, o, a, c, u, l) {
|
|
7034
7034
|
if (l === "")
|
|
7035
7035
|
return !0;
|
|
7036
7036
|
let f = tt(S.from(e, "hex")).slice(2);
|
|
7037
7037
|
f += t.toString(16).padStart(8, "0"), f += "02", f += n.slice(2).padStart(40, "0"), f += r.slice(2).padStart(40, "0"), f += s.toString(16).padStart(64, "0"), f += i.toString(16).padStart(64, "0"), f += o.toString(16).padStart(64, "0"), f += a.toString(16).padStart(64, "0"), f += c.toString(16).padStart(64, "0"), f += u.toString(16).padStart(64, "0");
|
|
7038
7038
|
const d = S.from(f, "hex"), p = T.G1.hashToCurve(d, {
|
|
7039
7039
|
DST: "BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"
|
|
7040
|
-
}), w = BigInt(`0x${l.slice(0, 128)}`), h = BigInt(`0x${l.slice(128, 256)}`), g = new T.G1.Point(w, h, BigInt(1)), b = BigInt(`0x${e.slice(0, 128)}`),
|
|
7041
|
-
T.fields.Fp2.create({ c0: b, c1:
|
|
7040
|
+
}), w = BigInt(`0x${l.slice(0, 128)}`), h = BigInt(`0x${l.slice(128, 256)}`), g = new T.G1.Point(w, h, BigInt(1)), b = BigInt(`0x${e.slice(0, 128)}`), v = BigInt(`0x${e.slice(128, 256)}`), O = BigInt(`0x${e.slice(256, 384)}`), F = BigInt(`0x${e.slice(384, 512)}`), W = new T.G2.Point(
|
|
7041
|
+
T.fields.Fp2.create({ c0: b, c1: v }),
|
|
7042
7042
|
T.fields.Fp2.create({ c0: O, c1: F }),
|
|
7043
7043
|
T.fields.Fp2.ONE
|
|
7044
7044
|
);
|
|
7045
|
-
return T.shortSignatures.verify(g, p,
|
|
7045
|
+
return T.shortSignatures.verify(g, p, W);
|
|
7046
7046
|
}
|
|
7047
|
-
async function
|
|
7048
|
-
n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, a = a.startsWith("0x") ? a.slice(2) : a,
|
|
7047
|
+
async function nl(e, t, n, r, s, i, o, a, c, u, l, f) {
|
|
7048
|
+
n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, a = a.startsWith("0x") ? a.slice(2) : a, _n(e);
|
|
7049
7049
|
try {
|
|
7050
|
-
if (!
|
|
7050
|
+
if (!el(
|
|
7051
7051
|
t,
|
|
7052
7052
|
c,
|
|
7053
7053
|
n,
|
|
@@ -7064,7 +7064,7 @@ async function el(e, t, n, r, s, i, o, a, c, u, l, f) {
|
|
|
7064
7064
|
const d = uo(n, r);
|
|
7065
7065
|
if ((await C.get(t, d) || 0n) < s)
|
|
7066
7066
|
throw new Error("Insufficient liquidity balance");
|
|
7067
|
-
const { amountA: p, amountB: w } = await
|
|
7067
|
+
const { amountA: p, amountB: w } = await ju(
|
|
7068
7068
|
n,
|
|
7069
7069
|
r,
|
|
7070
7070
|
s,
|
|
@@ -7100,24 +7100,24 @@ async function el(e, t, n, r, s, i, o, a, c, u, l, f) {
|
|
|
7100
7100
|
return console.error("Error in remove_liquidity_request:", d), { success: !1, error_message: d.message };
|
|
7101
7101
|
}
|
|
7102
7102
|
}
|
|
7103
|
-
function
|
|
7103
|
+
function rl(e, t, n, r, s, i, o, a, c, u) {
|
|
7104
7104
|
if (u === "")
|
|
7105
7105
|
return !0;
|
|
7106
7106
|
let l = tt(S.from(e, "hex")).slice(2);
|
|
7107
7107
|
l += t.toString(16).padStart(8, "0"), l += "03", l += n.slice(2).padStart(64, "0"), l += r.slice(2).padStart(64, "0"), l += s.toString(16).padStart(64, "0"), l += i.toString(16).padStart(64, "0"), l += o.toString(16).padStart(64, "0"), l += a.toString(16).padStart(64, "0"), l += c.toString(16).padStart(64, "0");
|
|
7108
7108
|
const f = S.from(l, "hex"), d = T.G1.hashToCurve(f, {
|
|
7109
7109
|
DST: "BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"
|
|
7110
|
-
}), p = BigInt(`0x${u.slice(0, 128)}`), w = BigInt(`0x${u.slice(128, 256)}`), h = new T.G1.Point(p, w, BigInt(1)), g = BigInt(`0x${e.slice(0, 128)}`), b = BigInt(`0x${e.slice(128, 256)}`),
|
|
7110
|
+
}), p = BigInt(`0x${u.slice(0, 128)}`), w = BigInt(`0x${u.slice(128, 256)}`), h = new T.G1.Point(p, w, BigInt(1)), g = BigInt(`0x${e.slice(0, 128)}`), b = BigInt(`0x${e.slice(128, 256)}`), v = BigInt(`0x${e.slice(256, 384)}`), O = BigInt(`0x${e.slice(384, 512)}`), F = new T.G2.Point(
|
|
7111
7111
|
T.fields.Fp2.create({ c0: g, c1: b }),
|
|
7112
|
-
T.fields.Fp2.create({ c0:
|
|
7112
|
+
T.fields.Fp2.create({ c0: v, c1: O }),
|
|
7113
7113
|
T.fields.Fp2.ONE
|
|
7114
7114
|
);
|
|
7115
7115
|
return T.shortSignatures.verify(h, d, F);
|
|
7116
7116
|
}
|
|
7117
|
-
async function
|
|
7118
|
-
n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, o = o.startsWith("0x") ? o.slice(2) : o,
|
|
7117
|
+
async function sl(e, t, n, r, s, i, o, a, c, u, l) {
|
|
7118
|
+
n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, o = o.startsWith("0x") ? o.slice(2) : o, _n(e);
|
|
7119
7119
|
try {
|
|
7120
|
-
if (!
|
|
7120
|
+
if (!rl(
|
|
7121
7121
|
t,
|
|
7122
7122
|
a,
|
|
7123
7123
|
n,
|
|
@@ -7135,7 +7135,7 @@ async function rl(e, t, n, r, s, i, o, a, c, u, l) {
|
|
|
7135
7135
|
const { reserveA: f, reserveB: d } = await Xt(
|
|
7136
7136
|
n,
|
|
7137
7137
|
r
|
|
7138
|
-
), p = await
|
|
7138
|
+
), p = await Xu(s, i, [n, r]);
|
|
7139
7139
|
if (p.length !== 2)
|
|
7140
7140
|
throw new Error("Invalid swap output amounts");
|
|
7141
7141
|
C.setCheckPositive(
|
|
@@ -7162,7 +7162,7 @@ async function rl(e, t, n, r, s, i, o, a, c, u, l) {
|
|
|
7162
7162
|
const { reserveA: w, reserveB: h } = await Xt(
|
|
7163
7163
|
n,
|
|
7164
7164
|
r
|
|
7165
|
-
), g = n === gt ? f * 1000000000000000000n * 10000n / d : d * 1000000000000000000n * 10000n / f, b = n === gt ? w * 1000000000000000000n * 10000n / h : h * 1000000000000000000n * 10000n / w,
|
|
7165
|
+
), g = n === gt ? f * 1000000000000000000n * 10000n / d : d * 1000000000000000000n * 10000n / f, b = n === gt ? w * 1000000000000000000n * 10000n / h : h * 1000000000000000000n * 10000n / w, v = g > b ? g - b : b - g, O = g !== 0n ? v * 10000n / g : 0n;
|
|
7166
7166
|
return {
|
|
7167
7167
|
success: !0,
|
|
7168
7168
|
amounts: p,
|
|
@@ -7174,24 +7174,24 @@ async function rl(e, t, n, r, s, i, o, a, c, u, l) {
|
|
|
7174
7174
|
return console.error("Error in swap_request:", f), { success: !1, error_message: f.message };
|
|
7175
7175
|
}
|
|
7176
7176
|
}
|
|
7177
|
-
function
|
|
7177
|
+
function il(e, t, n, r, s, i, o, a, c, u) {
|
|
7178
7178
|
if (u === "")
|
|
7179
7179
|
return !0;
|
|
7180
7180
|
let l = tt(S.from(e, "hex")).slice(2);
|
|
7181
7181
|
l += t.toString(16).padStart(8, "0"), l += "03", l += n.slice(2).padStart(64, "0"), l += r.slice(2).padStart(64, "0"), l += s.toString(16).padStart(64, "0"), l += i.toString(16).padStart(64, "0"), l += o.toString(16).padStart(64, "0"), l += a.toString(16).padStart(64, "0"), l += c.toString(16).padStart(64, "0");
|
|
7182
7182
|
const f = S.from(l, "hex"), d = T.G1.hashToCurve(f, {
|
|
7183
7183
|
DST: "BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"
|
|
7184
|
-
}), p = BigInt(`0x${u.slice(0, 128)}`), w = BigInt(`0x${u.slice(128, 256)}`), h = new T.G1.Point(p, w, BigInt(1)), g = BigInt(`0x${e.slice(0, 128)}`), b = BigInt(`0x${e.slice(128, 256)}`),
|
|
7184
|
+
}), p = BigInt(`0x${u.slice(0, 128)}`), w = BigInt(`0x${u.slice(128, 256)}`), h = new T.G1.Point(p, w, BigInt(1)), g = BigInt(`0x${e.slice(0, 128)}`), b = BigInt(`0x${e.slice(128, 256)}`), v = BigInt(`0x${e.slice(256, 384)}`), O = BigInt(`0x${e.slice(384, 512)}`), F = new T.G2.Point(
|
|
7185
7185
|
T.fields.Fp2.create({ c0: g, c1: b }),
|
|
7186
|
-
T.fields.Fp2.create({ c0:
|
|
7186
|
+
T.fields.Fp2.create({ c0: v, c1: O }),
|
|
7187
7187
|
T.fields.Fp2.ONE
|
|
7188
7188
|
);
|
|
7189
7189
|
return T.shortSignatures.verify(h, d, F);
|
|
7190
7190
|
}
|
|
7191
|
-
async function
|
|
7192
|
-
n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, o = o.startsWith("0x") ? o.slice(2) : o,
|
|
7191
|
+
async function ol(e, t, n, r, s, i, o, a, c, u, l) {
|
|
7192
|
+
n = n.toLowerCase(), r = r.toLowerCase(), t = t.startsWith("0x") ? t.slice(2) : t, o = o.startsWith("0x") ? o.slice(2) : o, _n(e);
|
|
7193
7193
|
try {
|
|
7194
|
-
if (!
|
|
7194
|
+
if (!il(
|
|
7195
7195
|
t,
|
|
7196
7196
|
a,
|
|
7197
7197
|
n,
|
|
@@ -7207,7 +7207,7 @@ async function il(e, t, n, r, s, i, o, a, c, u, l) {
|
|
|
7207
7207
|
const { reserveA: f, reserveB: d } = await Xt(
|
|
7208
7208
|
n,
|
|
7209
7209
|
r
|
|
7210
|
-
), p = await
|
|
7210
|
+
), p = await Ju(s, i, [n, r]);
|
|
7211
7211
|
if (p.length !== 2)
|
|
7212
7212
|
throw new Error("Invalid swap output amounts");
|
|
7213
7213
|
C.setCheckPositive(
|
|
@@ -7234,7 +7234,7 @@ async function il(e, t, n, r, s, i, o, a, c, u, l) {
|
|
|
7234
7234
|
const { reserveA: w, reserveB: h } = await Xt(
|
|
7235
7235
|
n,
|
|
7236
7236
|
r
|
|
7237
|
-
), g = n === gt ? f * 1000000000000000000n * 10000n / d : d * 1000000000000000000n * 10000n / f, b = n === gt ? w * 1000000000000000000n * 10000n / h : h * 1000000000000000000n * 10000n / w,
|
|
7237
|
+
), g = n === gt ? f * 1000000000000000000n * 10000n / d : d * 1000000000000000000n * 10000n / f, b = n === gt ? w * 1000000000000000000n * 10000n / h : h * 1000000000000000000n * 10000n / w, v = g > b ? g - b : b - g, O = g !== 0n ? v * 10000n / g : 0n;
|
|
7238
7238
|
return {
|
|
7239
7239
|
success: !0,
|
|
7240
7240
|
amounts: p,
|
|
@@ -7246,7 +7246,7 @@ async function il(e, t, n, r, s, i, o, a, c, u, l) {
|
|
|
7246
7246
|
return console.error("Error in swap2_request:", f), { success: !1, error_message: f.message };
|
|
7247
7247
|
}
|
|
7248
7248
|
}
|
|
7249
|
-
function
|
|
7249
|
+
function al(e, t, n, r, s, i) {
|
|
7250
7250
|
if (i === "")
|
|
7251
7251
|
return !0;
|
|
7252
7252
|
let o = tt(S.from(e, "hex")).slice(2);
|
|
@@ -7260,12 +7260,12 @@ function ol(e, t, n, r, s, i) {
|
|
|
7260
7260
|
);
|
|
7261
7261
|
return T.shortSignatures.verify(f, c, g);
|
|
7262
7262
|
}
|
|
7263
|
-
async function
|
|
7263
|
+
async function cl(e, t, n, r, s, i, o) {
|
|
7264
7264
|
if (n = n.toLowerCase(), n = n.startsWith("0x") ? n.slice(2) : n, n.length > 126)
|
|
7265
7265
|
throw new Error("Pkscript too long");
|
|
7266
|
-
t = t.startsWith("0x") ? t.slice(2) : t, s = s.startsWith("0x") ? s.slice(2) : s,
|
|
7266
|
+
t = t.startsWith("0x") ? t.slice(2) : t, s = s.startsWith("0x") ? s.slice(2) : s, _n(e);
|
|
7267
7267
|
try {
|
|
7268
|
-
if (!
|
|
7268
|
+
if (!al(t, i, n, r, o, s))
|
|
7269
7269
|
throw new Error("Invalid BLS signature");
|
|
7270
7270
|
if ((await C.get(t, gt) || 0n) < r)
|
|
7271
7271
|
throw new Error("Insufficient token balance");
|
|
@@ -7317,10 +7317,10 @@ const fo = [
|
|
|
7317
7317
|
outputs: [],
|
|
7318
7318
|
stateMutability: "nonpayable"
|
|
7319
7319
|
}
|
|
7320
|
-
],
|
|
7320
|
+
], ul = fo, be = 1e3, Hs = 12e3, po = 2500n, ll = `Sign this message only on official BiS interfaces.
|
|
7321
7321
|
This signature is required to generate your session-specific swap key.
|
|
7322
7322
|
Signing this message outside official BiS interfaces may result in unauthorized access to your swap session and is at the user's own risk.
|
|
7323
|
-
By signing, you acknowledge that the BiS Terms of Service also apply: https://bestinslot.xyz/legal/terms.`,
|
|
7323
|
+
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.
|
|
7324
7324
|
This signature is required to generate your session-specific swap key.
|
|
7325
7325
|
Signing this message outside official BiS interfaces may result in unauthorized access to your swap session and is at the user's own risk.
|
|
7326
7326
|
By signing, you acknowledge that the BiS Terms of Service also apply: https://bestinslot.xyz/legal/terms.
|
|
@@ -7350,9 +7350,9 @@ async function J(e, t) {
|
|
|
7350
7350
|
function Vs() {
|
|
7351
7351
|
const e = Qe();
|
|
7352
7352
|
if (e === "signet")
|
|
7353
|
-
return ul;
|
|
7354
|
-
if (e === "mainnet")
|
|
7355
7353
|
return ll;
|
|
7354
|
+
if (e === "mainnet")
|
|
7355
|
+
return fl;
|
|
7356
7356
|
throw new Error("Unsupported network for swap signature request text");
|
|
7357
7357
|
}
|
|
7358
7358
|
function j(e) {
|
|
@@ -7376,7 +7376,7 @@ function ho() {
|
|
|
7376
7376
|
if (e === "signet")
|
|
7377
7377
|
return new ge(fo);
|
|
7378
7378
|
if (e === "mainnet")
|
|
7379
|
-
return new ge(
|
|
7379
|
+
return new ge(ul);
|
|
7380
7380
|
throw new Error("Unsupported network for orderbook contract address");
|
|
7381
7381
|
}
|
|
7382
7382
|
async function et() {
|
|
@@ -7397,14 +7397,14 @@ async function go(e = {}) {
|
|
|
7397
7397
|
const s = await zr(Vs());
|
|
7398
7398
|
if (r !== s)
|
|
7399
7399
|
throw new Error("Deterministic signature mismatch. Please try again.");
|
|
7400
|
-
const i = S.from(tt(`0x${r}`).slice(2), "hex"), o = S.from("my-app/bls-keygen", "utf-8"), a =
|
|
7400
|
+
const i = S.from(tt(`0x${r}`).slice(2), "hex"), o = S.from("my-app/bls-keygen", "utf-8"), a = uc(xi, i, void 0, o, 48), c = mi(a, T.fields.Fr.ORDER), u = S.from(c), l = wo(u), f = `0x${u.toString("hex")}`, d = {
|
|
7401
7401
|
bitcoinAddress: t.address,
|
|
7402
7402
|
swapPubkey: l,
|
|
7403
7403
|
swapPrivkey: f
|
|
7404
7404
|
};
|
|
7405
7405
|
return await Ys(d), d;
|
|
7406
7406
|
}
|
|
7407
|
-
function
|
|
7407
|
+
function dl(e) {
|
|
7408
7408
|
const t = e.trim(), n = t.toLowerCase().startsWith("0x") ? t.slice(2) : t;
|
|
7409
7409
|
if (!/^[0-9a-f]{64}$/i.test(n))
|
|
7410
7410
|
throw new Error("Invalid security code. Expected a 32-byte hex value.");
|
|
@@ -7413,11 +7413,11 @@ function fl(e) {
|
|
|
7413
7413
|
throw new Error("Invalid security code. Not a valid swap key.");
|
|
7414
7414
|
return S.from(n, "hex");
|
|
7415
7415
|
}
|
|
7416
|
-
async function
|
|
7416
|
+
async function pl(e, t = {}) {
|
|
7417
7417
|
const n = Wt();
|
|
7418
7418
|
if (!n?.address)
|
|
7419
7419
|
throw new Error("Ordinals wallet address not found.");
|
|
7420
|
-
const r =
|
|
7420
|
+
const r = dl(e), s = {
|
|
7421
7421
|
bitcoinAddress: n.address,
|
|
7422
7422
|
swapPubkey: wo(r),
|
|
7423
7423
|
swapPrivkey: `0x${r.toString("hex")}`
|
|
@@ -7428,17 +7428,17 @@ async function dl(e, t = {}) {
|
|
|
7428
7428
|
);
|
|
7429
7429
|
return await Ys(s), s;
|
|
7430
7430
|
}
|
|
7431
|
-
async function
|
|
7431
|
+
async function hl(e = {}) {
|
|
7432
7432
|
const t = Wt();
|
|
7433
7433
|
if (!t?.address)
|
|
7434
7434
|
throw new Error("Ordinals wallet address not found.");
|
|
7435
7435
|
const n = await Rr(t.address);
|
|
7436
7436
|
return n ? { wallet: n, created: !1 } : { wallet: await go(e), created: !0 };
|
|
7437
7437
|
}
|
|
7438
|
-
async function
|
|
7438
|
+
async function wl() {
|
|
7439
7439
|
return (await et())?.swapPrivkey ?? null;
|
|
7440
7440
|
}
|
|
7441
|
-
async function
|
|
7441
|
+
async function gl() {
|
|
7442
7442
|
const e = j("status");
|
|
7443
7443
|
return await J(e, {
|
|
7444
7444
|
method: "GET"
|
|
@@ -7460,10 +7460,10 @@ async function yo(e) {
|
|
|
7460
7460
|
});
|
|
7461
7461
|
return BigInt(s.result);
|
|
7462
7462
|
}
|
|
7463
|
-
const
|
|
7463
|
+
const yl = 6e4, Zs = /* @__PURE__ */ new Map(), Or = /* @__PURE__ */ new Map();
|
|
7464
7464
|
async function Jt() {
|
|
7465
7465
|
const e = Qe(), t = Zs.get(e);
|
|
7466
|
-
if (t && Date.now() - t.fetchedAt <
|
|
7466
|
+
if (t && Date.now() - t.fetchedAt < yl)
|
|
7467
7467
|
return t.info;
|
|
7468
7468
|
const n = j("get_swap_info"), r = await J(n, {
|
|
7469
7469
|
method: "GET"
|
|
@@ -7471,7 +7471,7 @@ async function Jt() {
|
|
|
7471
7471
|
let i = null;
|
|
7472
7472
|
if (Or.delete(e), s != null)
|
|
7473
7473
|
try {
|
|
7474
|
-
i =
|
|
7474
|
+
i = Nu(s);
|
|
7475
7475
|
} catch (a) {
|
|
7476
7476
|
Or.set(e, a instanceof Error ? a.message : String(a));
|
|
7477
7477
|
}
|
|
@@ -7534,7 +7534,7 @@ async function mo(e) {
|
|
|
7534
7534
|
ticker: s.result.ticker
|
|
7535
7535
|
};
|
|
7536
7536
|
}
|
|
7537
|
-
async function
|
|
7537
|
+
async function bl(e) {
|
|
7538
7538
|
const t = j("get_all_balances");
|
|
7539
7539
|
return (await J(t, {
|
|
7540
7540
|
method: "POST",
|
|
@@ -7546,7 +7546,7 @@ async function yl(e) {
|
|
|
7546
7546
|
})
|
|
7547
7547
|
})).result;
|
|
7548
7548
|
}
|
|
7549
|
-
async function
|
|
7549
|
+
async function ml(e) {
|
|
7550
7550
|
const t = await et();
|
|
7551
7551
|
if (!t?.swapPubkey)
|
|
7552
7552
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
@@ -7606,7 +7606,7 @@ async function Fe() {
|
|
|
7606
7606
|
});
|
|
7607
7607
|
return BigInt(r.result);
|
|
7608
7608
|
}
|
|
7609
|
-
async function
|
|
7609
|
+
async function xl(e, t) {
|
|
7610
7610
|
const n = j("get_swap_referrer_info"), s = await J(n, {
|
|
7611
7611
|
method: "POST",
|
|
7612
7612
|
headers: {
|
|
@@ -7623,7 +7623,7 @@ async function ml(e, t) {
|
|
|
7623
7623
|
}
|
|
7624
7624
|
async function Vr(e, t) {
|
|
7625
7625
|
try {
|
|
7626
|
-
return await
|
|
7626
|
+
return await xl(e, t);
|
|
7627
7627
|
} catch (n) {
|
|
7628
7628
|
return console.warn(`Failed to get referrer info for ref_id ${t}:`, n), { referrerPubkey: void 0, refReturnBps: void 0 };
|
|
7629
7629
|
}
|
|
@@ -7646,10 +7646,10 @@ async function _l() {
|
|
|
7646
7646
|
method: "GET"
|
|
7647
7647
|
})).tokens;
|
|
7648
7648
|
}
|
|
7649
|
-
function
|
|
7649
|
+
function xr(e) {
|
|
7650
7650
|
return e === null ? null : BigInt(e);
|
|
7651
7651
|
}
|
|
7652
|
-
async function
|
|
7652
|
+
async function El(e = {}) {
|
|
7653
7653
|
const t = e.order_by ?? "tvl_desc", n = e.page ?? 1, r = e.count ?? 20;
|
|
7654
7654
|
if (r > 100)
|
|
7655
7655
|
throw new Error("Count cannot exceed 100");
|
|
@@ -7666,14 +7666,14 @@ async function xl(e = {}) {
|
|
|
7666
7666
|
total: o.total,
|
|
7667
7667
|
data: o.data.map((a) => ({
|
|
7668
7668
|
...a,
|
|
7669
|
-
volume_24h:
|
|
7670
|
-
volume_7d:
|
|
7671
|
-
tvl:
|
|
7669
|
+
volume_24h: xr(a.volume_24h),
|
|
7670
|
+
volume_7d: xr(a.volume_7d),
|
|
7671
|
+
tvl: xr(a.tvl),
|
|
7672
7672
|
exposure_sats: BigInt(a.exposure_sats)
|
|
7673
7673
|
}))
|
|
7674
7674
|
};
|
|
7675
7675
|
}
|
|
7676
|
-
async function
|
|
7676
|
+
async function Sl(e) {
|
|
7677
7677
|
const t = j(`volume/${e.pair_address}?days=${e.days}`);
|
|
7678
7678
|
return await J(t, {
|
|
7679
7679
|
method: "GET",
|
|
@@ -7682,7 +7682,7 @@ async function El(e) {
|
|
|
7682
7682
|
}
|
|
7683
7683
|
});
|
|
7684
7684
|
}
|
|
7685
|
-
async function
|
|
7685
|
+
async function Bl(e) {
|
|
7686
7686
|
if (e.limit > 1e3)
|
|
7687
7687
|
throw new Error("Limit cannot exceed 1000");
|
|
7688
7688
|
let t = j(
|
|
@@ -7695,7 +7695,7 @@ async function Sl(e) {
|
|
|
7695
7695
|
}
|
|
7696
7696
|
});
|
|
7697
7697
|
}
|
|
7698
|
-
async function
|
|
7698
|
+
async function vl(e) {
|
|
7699
7699
|
const t = j(
|
|
7700
7700
|
`tvl/${encodeURIComponent(e.pair_address)}?${new URLSearchParams({
|
|
7701
7701
|
days: String(e.days)
|
|
@@ -7708,7 +7708,7 @@ async function Bl(e) {
|
|
|
7708
7708
|
}
|
|
7709
7709
|
});
|
|
7710
7710
|
}
|
|
7711
|
-
async function
|
|
7711
|
+
async function Ol(e) {
|
|
7712
7712
|
if (e.limit > 200)
|
|
7713
7713
|
throw new Error("Limit cannot exceed 200");
|
|
7714
7714
|
const t = j(
|
|
@@ -7721,7 +7721,7 @@ async function vl(e) {
|
|
|
7721
7721
|
}
|
|
7722
7722
|
});
|
|
7723
7723
|
}
|
|
7724
|
-
async function
|
|
7724
|
+
async function Tl(e) {
|
|
7725
7725
|
if (e.limit !== void 0) {
|
|
7726
7726
|
if (e.limit > 200)
|
|
7727
7727
|
throw new Error("Limit cannot exceed 200");
|
|
@@ -7752,7 +7752,7 @@ async function pn(e) {
|
|
|
7752
7752
|
})
|
|
7753
7753
|
})).result;
|
|
7754
7754
|
}
|
|
7755
|
-
async function
|
|
7755
|
+
async function xo(e) {
|
|
7756
7756
|
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();
|
|
7757
7757
|
const t = `Deposit Order:
|
|
7758
7758
|
Bitcoin Address: ${e.btc_address}
|
|
@@ -7774,7 +7774,7 @@ async function rr(e) {
|
|
|
7774
7774
|
const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = S.from(i, "hex"), c = T.shortSignatures.sign(r, o).negate();
|
|
7775
7775
|
return `0x${c.x.toString(16).padStart(128, "0")}${c.y.toString(16).padStart(128, "0")}`;
|
|
7776
7776
|
}
|
|
7777
|
-
async function
|
|
7777
|
+
async function _o(e) {
|
|
7778
7778
|
e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
|
|
7779
7779
|
let t = tt(S.from(e.pubkey, "hex")).slice(2);
|
|
7780
7780
|
t += "99", t += e.ordinals_script;
|
|
@@ -7796,7 +7796,7 @@ async function Eo(e) {
|
|
|
7796
7796
|
body: JSON.stringify(e)
|
|
7797
7797
|
});
|
|
7798
7798
|
}
|
|
7799
|
-
async function
|
|
7799
|
+
async function Il(e) {
|
|
7800
7800
|
const t = j("deposit");
|
|
7801
7801
|
return J(t, {
|
|
7802
7802
|
method: "POST",
|
|
@@ -7825,7 +7825,7 @@ function So(e, t) {
|
|
|
7825
7825
|
function Bo(e) {
|
|
7826
7826
|
return e ? e.reduce((t, n) => t + n.amount, 0n) : 0n;
|
|
7827
7827
|
}
|
|
7828
|
-
async function
|
|
7828
|
+
async function Rl(e, t, n, r = !0, s, i = {}) {
|
|
7829
7829
|
const o = wn();
|
|
7830
7830
|
if (!o || !o.wallets) throw new Error("Wallets not found");
|
|
7831
7831
|
const a = ze(), c = Hn(), u = Wt();
|
|
@@ -7845,9 +7845,9 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
7845
7845
|
`Insufficient BRC-2.0 + BRC20 available balance. Current BRC-2.0: ${b}, Available in base: ${Qt}, Reclaimable: ${te}, Required: ${t}`
|
|
7846
7846
|
), new Error("Insufficient BRC-2.0 + BRC20 available balance");
|
|
7847
7847
|
}
|
|
7848
|
-
const
|
|
7848
|
+
const v = await yo(e);
|
|
7849
7849
|
let O = !1;
|
|
7850
|
-
if (
|
|
7850
|
+
if (v < BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) {
|
|
7851
7851
|
if (!r)
|
|
7852
7852
|
throw console.error("Insufficient allowance for BRC-2.0 token transfer."), new Error("Insufficient allowance for BRC-2.0 token transfer.");
|
|
7853
7853
|
O = !0;
|
|
@@ -7855,45 +7855,45 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
7855
7855
|
const F = new Hr(
|
|
7856
7856
|
i,
|
|
7857
7857
|
3 + (w > 0n ? 2 : 0) + (O ? 2 : 0)
|
|
7858
|
-
),
|
|
7859
|
-
`{"p":"brc20-prog","op":"c","c":"${e}","b":"${
|
|
7860
|
-
),
|
|
7858
|
+
), W = F.wrap(Ir(o.provider)), A = er(), k = `0x095ea7b3000000000000000000000000${A.slice(2).toLowerCase()}ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`, I = await Ke(k), x = X.str(
|
|
7859
|
+
`{"p":"brc20-prog","op":"c","c":"${e}","b":"${I}"}`
|
|
7860
|
+
), q = new ae(
|
|
7861
7861
|
X.str("text/plain"),
|
|
7862
7862
|
null,
|
|
7863
7863
|
null,
|
|
7864
7864
|
null,
|
|
7865
7865
|
null,
|
|
7866
|
-
|
|
7867
|
-
),
|
|
7868
|
-
if (!
|
|
7866
|
+
x
|
|
7867
|
+
), H = (await et())?.swapPubkey;
|
|
7868
|
+
if (!H)
|
|
7869
7869
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
7870
7870
|
F.next();
|
|
7871
|
-
const U = await
|
|
7871
|
+
const U = await xo({
|
|
7872
7872
|
btc_address: d,
|
|
7873
|
-
bls_pubkey:
|
|
7873
|
+
bls_pubkey: H,
|
|
7874
7874
|
token_address: e
|
|
7875
|
-
}), y = gn.address.toOutputScript(d, ze()),
|
|
7876
|
-
pubkey:
|
|
7875
|
+
}), y = gn.address.toOutputScript(d, ze()), _ = await _o({
|
|
7876
|
+
pubkey: H,
|
|
7877
7877
|
ordinals_script: y.toString("hex")
|
|
7878
|
-
}),
|
|
7878
|
+
}), B = await Eo({
|
|
7879
7879
|
btc_address: d,
|
|
7880
|
-
bls_pubkey:
|
|
7880
|
+
bls_pubkey: H,
|
|
7881
7881
|
token_address: e.toLowerCase(),
|
|
7882
7882
|
bip322_signature: U,
|
|
7883
|
-
bls12_signature:
|
|
7884
|
-
}), N =
|
|
7885
|
-
pubkey:
|
|
7886
|
-
pk_idx: BigInt(
|
|
7887
|
-
}),
|
|
7883
|
+
bls12_signature: _
|
|
7884
|
+
}), N = B.edcsa_signature, P = B.pubkey_idx, $ = B.token_idx, D = await rr({
|
|
7885
|
+
pubkey: H,
|
|
7886
|
+
pk_idx: BigInt(P)
|
|
7887
|
+
}), M = ho().encodeFunctionData("deposit", [
|
|
7888
7888
|
e,
|
|
7889
7889
|
$,
|
|
7890
7890
|
t,
|
|
7891
|
-
|
|
7892
|
-
BigInt(
|
|
7893
|
-
|
|
7891
|
+
H,
|
|
7892
|
+
BigInt(P),
|
|
7893
|
+
D,
|
|
7894
7894
|
N
|
|
7895
|
-
]), Z = await Ke(
|
|
7896
|
-
`{"p":"brc20-prog","op":"c","c":"${
|
|
7895
|
+
]), Z = await Ke(M), at = X.str(
|
|
7896
|
+
`{"p":"brc20-prog","op":"c","c":"${A}","b":"${Z}"}`
|
|
7897
7897
|
), Q = new ae(
|
|
7898
7898
|
X.str("text/plain"),
|
|
7899
7899
|
null,
|
|
@@ -7902,7 +7902,7 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
7902
7902
|
null,
|
|
7903
7903
|
at
|
|
7904
7904
|
);
|
|
7905
|
-
let G = null, ft = null, ht = null,
|
|
7905
|
+
let G = null, ft = null, ht = null, _t = null, z = null, ut = null, jt = null, Sn = null, rt = null;
|
|
7906
7906
|
if (w > 0n) {
|
|
7907
7907
|
const Lt = So(
|
|
7908
7908
|
w,
|
|
@@ -7918,13 +7918,13 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
7918
7918
|
)
|
|
7919
7919
|
);
|
|
7920
7920
|
if ((s?.length ?? 0) > 0) {
|
|
7921
|
-
const vn = await zs(s, d), Oe = await
|
|
7921
|
+
const vn = await zs(s, d), Oe = await Ho(
|
|
7922
7922
|
Qt,
|
|
7923
7923
|
vn,
|
|
7924
7924
|
n,
|
|
7925
7925
|
null,
|
|
7926
7926
|
!0,
|
|
7927
|
-
|
|
7927
|
+
W
|
|
7928
7928
|
);
|
|
7929
7929
|
rt = {
|
|
7930
7930
|
signed_commit_tx_hex: Oe.signedCommitTxHex,
|
|
@@ -7942,9 +7942,9 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
7942
7942
|
null,
|
|
7943
7943
|
0,
|
|
7944
7944
|
!0,
|
|
7945
|
-
|
|
7945
|
+
W
|
|
7946
7946
|
);
|
|
7947
|
-
z = rt.signed_commit_tx_hex, ut = rt.signed_reveal_tx_hex, ht = rt.commit_txid,
|
|
7947
|
+
z = rt.signed_commit_tx_hex, ut = rt.signed_reveal_tx_hex, ht = rt.commit_txid, _t = rt.reveal_txid, G = rt.inscription_id;
|
|
7948
7948
|
const te = `${G.split("i")[0]}:0:0`;
|
|
7949
7949
|
ft = rt.secret;
|
|
7950
7950
|
let De = null;
|
|
@@ -7975,7 +7975,7 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
7975
7975
|
],
|
|
7976
7976
|
n,
|
|
7977
7977
|
!0,
|
|
7978
|
-
|
|
7978
|
+
W
|
|
7979
7979
|
);
|
|
7980
7980
|
} finally {
|
|
7981
7981
|
Yt();
|
|
@@ -7994,13 +7994,13 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
7994
7994
|
);
|
|
7995
7995
|
try {
|
|
7996
7996
|
Pt(Lt, null), Be = await Xr(
|
|
7997
|
-
|
|
7997
|
+
q,
|
|
7998
7998
|
n,
|
|
7999
7999
|
null,
|
|
8000
8000
|
null,
|
|
8001
8001
|
0,
|
|
8002
8002
|
!0,
|
|
8003
|
-
|
|
8003
|
+
W
|
|
8004
8004
|
), It = Be.signed_commit_tx_hex, de = Be.signed_reveal_tx_hex, St = Be.commit_txid, Dt = Be.reveal_txid, Et = Be.inscription_id, dt = Be.secret;
|
|
8005
8005
|
} finally {
|
|
8006
8006
|
Yt();
|
|
@@ -8031,7 +8031,7 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
8031
8031
|
],
|
|
8032
8032
|
n,
|
|
8033
8033
|
!0,
|
|
8034
|
-
|
|
8034
|
+
W
|
|
8035
8035
|
);
|
|
8036
8036
|
} finally {
|
|
8037
8037
|
Yt();
|
|
@@ -8075,7 +8075,7 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
8075
8075
|
null,
|
|
8076
8076
|
0,
|
|
8077
8077
|
!0,
|
|
8078
|
-
|
|
8078
|
+
W
|
|
8079
8079
|
), ar = ve.signedCommitTxHex, cr = ve.signedRevealTxHex, nn = ve.inscriptionId;
|
|
8080
8080
|
const Lt = `${nn.split("i")[0]}:0:0`;
|
|
8081
8081
|
Yr = ve.secret, qe.push(ar, cr), Pt(qe, [nn, Lt]);
|
|
@@ -8094,7 +8094,7 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
8094
8094
|
[],
|
|
8095
8095
|
n,
|
|
8096
8096
|
!0,
|
|
8097
|
-
|
|
8097
|
+
W
|
|
8098
8098
|
);
|
|
8099
8099
|
} finally {
|
|
8100
8100
|
Yt();
|
|
@@ -8125,7 +8125,7 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
8125
8125
|
base_deposit_details: w > 0n ? {
|
|
8126
8126
|
commit_txid: ht,
|
|
8127
8127
|
commit_txhex: z,
|
|
8128
|
-
reveal_txid:
|
|
8128
|
+
reveal_txid: _t,
|
|
8129
8129
|
reveal_txhex: ut,
|
|
8130
8130
|
send_to_opreturn_txid: Sn,
|
|
8131
8131
|
send_to_opreturn_txhex: jt,
|
|
@@ -8134,9 +8134,9 @@ async function Il(e, t, n, r = !0, s, i = {}) {
|
|
|
8134
8134
|
fee_rate: n
|
|
8135
8135
|
} : null
|
|
8136
8136
|
};
|
|
8137
|
-
return (await
|
|
8137
|
+
return (await Il(Uo)).result;
|
|
8138
8138
|
}
|
|
8139
|
-
async function
|
|
8139
|
+
async function kl(e, t, n, r = !0, s) {
|
|
8140
8140
|
const i = wn();
|
|
8141
8141
|
if (!i || !i.wallets) throw new Error("Wallets not found");
|
|
8142
8142
|
const o = ze(), a = Hn();
|
|
@@ -8161,40 +8161,40 @@ async function Rl(e, t, n, r = !0, s) {
|
|
|
8161
8161
|
throw console.error("Insufficient allowance for BRC-2.0 token transfer."), new Error("Insufficient allowance for BRC-2.0 token transfer.");
|
|
8162
8162
|
g = !0;
|
|
8163
8163
|
}
|
|
8164
|
-
const b = er(),
|
|
8164
|
+
const b = er(), v = `0x095ea7b3000000000000000000000000${b.slice(2).toLowerCase()}ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`, O = await Ke(v), F = X.str(
|
|
8165
8165
|
`{"p":"brc20-prog","op":"c","c":"${e}","b":"${O}"}`
|
|
8166
|
-
),
|
|
8166
|
+
), W = new ae(
|
|
8167
8167
|
X.str("text/plain"),
|
|
8168
8168
|
null,
|
|
8169
8169
|
null,
|
|
8170
8170
|
null,
|
|
8171
8171
|
null,
|
|
8172
8172
|
F
|
|
8173
|
-
),
|
|
8174
|
-
if (!
|
|
8173
|
+
), A = (await et())?.swapPubkey;
|
|
8174
|
+
if (!A)
|
|
8175
8175
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
8176
|
-
const
|
|
8177
|
-
pubkey:
|
|
8178
|
-
pk_idx: BigInt(
|
|
8176
|
+
const k = `0x${"00".repeat(64)}`, I = 1, x = 1, q = await rr({
|
|
8177
|
+
pubkey: A,
|
|
8178
|
+
pk_idx: BigInt(I)
|
|
8179
8179
|
}), U = ho().encodeFunctionData("deposit", [
|
|
8180
8180
|
e,
|
|
8181
|
-
|
|
8181
|
+
x,
|
|
8182
8182
|
t,
|
|
8183
|
-
|
|
8184
|
-
BigInt(
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
]), y = await Ke(U),
|
|
8183
|
+
A,
|
|
8184
|
+
BigInt(I),
|
|
8185
|
+
q,
|
|
8186
|
+
k
|
|
8187
|
+
]), y = await Ke(U), _ = X.str(
|
|
8188
8188
|
`{"p":"brc20-prog","op":"c","c":"${b}","b":"${y}"}`
|
|
8189
|
-
),
|
|
8189
|
+
), B = new ae(
|
|
8190
8190
|
X.str("text/plain"),
|
|
8191
8191
|
null,
|
|
8192
8192
|
null,
|
|
8193
8193
|
null,
|
|
8194
8194
|
null,
|
|
8195
|
-
|
|
8195
|
+
_
|
|
8196
8196
|
);
|
|
8197
|
-
let N = null,
|
|
8197
|
+
let N = null, P = null, $ = null, D = null, L = null, M = 0;
|
|
8198
8198
|
if (f > 0n) {
|
|
8199
8199
|
const rt = So(
|
|
8200
8200
|
f,
|
|
@@ -8229,14 +8229,14 @@ async function Rl(e, t, n, r = !0, s) {
|
|
|
8229
8229
|
null,
|
|
8230
8230
|
0
|
|
8231
8231
|
);
|
|
8232
|
-
|
|
8232
|
+
P = dt.unsigned_commit_tx_hex, $ = dt.signed_reveal_tx_hex, N = dt.inscription_id, M += dt.total_fee;
|
|
8233
8233
|
const St = `${N.split("i")[0]}:0:0`;
|
|
8234
8234
|
let Dt = null;
|
|
8235
8235
|
try {
|
|
8236
|
-
if (!
|
|
8236
|
+
if (!P)
|
|
8237
8237
|
throw new Error("Base deposit commit tx hex is missing");
|
|
8238
8238
|
Pt(
|
|
8239
|
-
[
|
|
8239
|
+
[P, $],
|
|
8240
8240
|
[N, St]
|
|
8241
8241
|
);
|
|
8242
8242
|
const It = new Ft(
|
|
@@ -8264,20 +8264,20 @@ async function Rl(e, t, n, r = !0, s) {
|
|
|
8264
8264
|
}
|
|
8265
8265
|
if (Dt == null)
|
|
8266
8266
|
throw new Error("Failed to send inscription to OP_RETURN");
|
|
8267
|
-
|
|
8267
|
+
D = Dt.unsigned_tx_hex, L = Dt.txid, M += Dt.tx_fee;
|
|
8268
8268
|
}
|
|
8269
8269
|
let Z = null, at = null, Q = null, G = null, ft = null, ht = 0;
|
|
8270
8270
|
if (g) {
|
|
8271
8271
|
const rt = [];
|
|
8272
8272
|
f > 0n && rt.push(
|
|
8273
|
-
|
|
8273
|
+
P,
|
|
8274
8274
|
$,
|
|
8275
|
-
|
|
8275
|
+
D
|
|
8276
8276
|
);
|
|
8277
8277
|
try {
|
|
8278
8278
|
Pt(rt, null);
|
|
8279
8279
|
const St = await Kr(
|
|
8280
|
-
|
|
8280
|
+
W,
|
|
8281
8281
|
n,
|
|
8282
8282
|
null,
|
|
8283
8283
|
null,
|
|
@@ -8320,15 +8320,15 @@ async function Rl(e, t, n, r = !0, s) {
|
|
|
8320
8320
|
throw new Error("Failed to send inscription to OP_RETURN");
|
|
8321
8321
|
G = dt.unsigned_tx_hex, ft = dt.txid, ht += dt.tx_fee;
|
|
8322
8322
|
}
|
|
8323
|
-
const
|
|
8323
|
+
const _t = [], z = [];
|
|
8324
8324
|
if (f > 0n) {
|
|
8325
|
-
if (!
|
|
8325
|
+
if (!P || !$ || !D)
|
|
8326
8326
|
throw new Error("Base deposit transaction hexes are missing");
|
|
8327
8327
|
z.push(
|
|
8328
|
-
|
|
8328
|
+
P,
|
|
8329
8329
|
$,
|
|
8330
|
-
|
|
8331
|
-
),
|
|
8330
|
+
D
|
|
8331
|
+
), _t.push({
|
|
8332
8332
|
utxo: `${L}:1`,
|
|
8333
8333
|
value: be,
|
|
8334
8334
|
script_type: Ln(l.outputScript, o),
|
|
@@ -8338,7 +8338,7 @@ async function Rl(e, t, n, r = !0, s) {
|
|
|
8338
8338
|
if (g) {
|
|
8339
8339
|
if (!at || !Q || !G)
|
|
8340
8340
|
throw new Error("Allowance transaction hexes are missing");
|
|
8341
|
-
z.push(at, Q, G),
|
|
8341
|
+
z.push(at, Q, G), _t.push({
|
|
8342
8342
|
utxo: `${ft}:1`,
|
|
8343
8343
|
value: be,
|
|
8344
8344
|
script_type: Ln(l.outputScript, o),
|
|
@@ -8349,8 +8349,8 @@ async function Rl(e, t, n, r = !0, s) {
|
|
|
8349
8349
|
try {
|
|
8350
8350
|
z.length > 0 && Pt(z, null);
|
|
8351
8351
|
const rt = await Ks(
|
|
8352
|
-
|
|
8353
|
-
|
|
8352
|
+
B,
|
|
8353
|
+
_t,
|
|
8354
8354
|
n,
|
|
8355
8355
|
null,
|
|
8356
8356
|
null,
|
|
@@ -8379,13 +8379,13 @@ async function Rl(e, t, n, r = !0, s) {
|
|
|
8379
8379
|
throw new Error("Failed to send inscription to OP_RETURN");
|
|
8380
8380
|
return ut += jt.tx_fee, {
|
|
8381
8381
|
needs_approval: g,
|
|
8382
|
-
base_deposit_fees_total:
|
|
8382
|
+
base_deposit_fees_total: M,
|
|
8383
8383
|
allowance_fees_total: ht,
|
|
8384
8384
|
deposit_fees_total: ut,
|
|
8385
8385
|
fee_rate: n
|
|
8386
8386
|
};
|
|
8387
8387
|
}
|
|
8388
|
-
async function
|
|
8388
|
+
async function Nl(e) {
|
|
8389
8389
|
const t = j("wrap");
|
|
8390
8390
|
return J(t, {
|
|
8391
8391
|
method: "POST",
|
|
@@ -8395,7 +8395,7 @@ async function kl(e) {
|
|
|
8395
8395
|
body: JSON.stringify(e)
|
|
8396
8396
|
});
|
|
8397
8397
|
}
|
|
8398
|
-
async function
|
|
8398
|
+
async function Cl(e) {
|
|
8399
8399
|
const t = j("estimate_wrap_gas");
|
|
8400
8400
|
return J(t, {
|
|
8401
8401
|
method: "POST",
|
|
@@ -8405,7 +8405,7 @@ async function Nl(e) {
|
|
|
8405
8405
|
body: JSON.stringify(e)
|
|
8406
8406
|
});
|
|
8407
8407
|
}
|
|
8408
|
-
async function
|
|
8408
|
+
async function $l(e, t, n = {}) {
|
|
8409
8409
|
const r = await Jt(), s = wn();
|
|
8410
8410
|
if (!s || !s.wallets) throw new Error("Wallets not found");
|
|
8411
8411
|
const i = new Hr(n), o = i.wrap(Ir(s.provider)), a = Hn(), c = Wt();
|
|
@@ -8417,11 +8417,11 @@ async function Cl(e, t, n = {}) {
|
|
|
8417
8417
|
if (!f)
|
|
8418
8418
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
8419
8419
|
i.next();
|
|
8420
|
-
const d = await
|
|
8420
|
+
const d = await xo({
|
|
8421
8421
|
btc_address: u,
|
|
8422
8422
|
bls_pubkey: f,
|
|
8423
8423
|
token_address: r.wbtc_address
|
|
8424
|
-
}), p = gn.address.toOutputScript(u, ze()), w = await
|
|
8424
|
+
}), p = gn.address.toOutputScript(u, ze()), w = await _o({
|
|
8425
8425
|
pubkey: f,
|
|
8426
8426
|
ordinals_script: p.toString("hex")
|
|
8427
8427
|
}), h = await Eo({
|
|
@@ -8430,38 +8430,38 @@ async function Cl(e, t, n = {}) {
|
|
|
8430
8430
|
token_address: r.wbtc_address.toLowerCase(),
|
|
8431
8431
|
bip322_signature: d,
|
|
8432
8432
|
bls12_signature: w
|
|
8433
|
-
}), g = h.edcsa_signature, b = h.pubkey_idx,
|
|
8433
|
+
}), g = h.edcsa_signature, b = h.pubkey_idx, v = h.token_idx, O = await rr({
|
|
8434
8434
|
pubkey: f,
|
|
8435
8435
|
pk_idx: BigInt(b)
|
|
8436
8436
|
}), F = le.defaultAbiCoder().encode(
|
|
8437
8437
|
["address", "uint32", "bytes", "uint64", "bytes", "bytes"],
|
|
8438
8438
|
[
|
|
8439
8439
|
r.wbtc_address,
|
|
8440
|
-
|
|
8440
|
+
v,
|
|
8441
8441
|
S.from(f.slice(2), "hex"),
|
|
8442
8442
|
b,
|
|
8443
8443
|
S.from(O.slice(2), "hex"),
|
|
8444
8444
|
S.from(g.slice(2), "hex")
|
|
8445
8445
|
]
|
|
8446
|
-
),
|
|
8446
|
+
), A = `0x5608f857${le.defaultAbiCoder().encode(
|
|
8447
8447
|
["address", "bytes"],
|
|
8448
8448
|
[l, S.from(F.slice(2), "hex")]
|
|
8449
|
-
).slice(2)}`,
|
|
8450
|
-
`{"p":"brc20-prog","op":"c","c":"${r.wbtc_address}","b":"${
|
|
8449
|
+
).slice(2)}`, k = await Ke(A), I = X.str(
|
|
8450
|
+
`{"p":"brc20-prog","op":"c","c":"${r.wbtc_address}","b":"${k}"}`
|
|
8451
8451
|
);
|
|
8452
|
-
let
|
|
8453
|
-
for (let
|
|
8454
|
-
const
|
|
8455
|
-
S.concat([
|
|
8456
|
-
),
|
|
8452
|
+
let x = 0;
|
|
8453
|
+
for (let q = 0; q < 5; q++) {
|
|
8454
|
+
const H = I.length * Hs, U = x > H ? Math.ceil((x - H) / Hs) : 0, y = X.from(
|
|
8455
|
+
S.concat([I, X.str(" ".repeat(U))])
|
|
8456
|
+
), _ = new ae(
|
|
8457
8457
|
X.str("text/plain"),
|
|
8458
8458
|
null,
|
|
8459
8459
|
null,
|
|
8460
8460
|
null,
|
|
8461
8461
|
null,
|
|
8462
8462
|
y
|
|
8463
|
-
),
|
|
8464
|
-
|
|
8463
|
+
), B = await Xs(
|
|
8464
|
+
_,
|
|
8465
8465
|
[],
|
|
8466
8466
|
t,
|
|
8467
8467
|
null,
|
|
@@ -8469,14 +8469,14 @@ async function Cl(e, t, n = {}) {
|
|
|
8469
8469
|
0,
|
|
8470
8470
|
!0,
|
|
8471
8471
|
o
|
|
8472
|
-
), N =
|
|
8473
|
-
let
|
|
8472
|
+
), N = B.signedCommitTxHex, P = B.signedRevealTxHex, $ = B.inscriptionId, D = `${$.split("i")[0]}:0:0`, L = B.secret;
|
|
8473
|
+
let M = null;
|
|
8474
8474
|
try {
|
|
8475
8475
|
Pt(
|
|
8476
|
-
[N,
|
|
8477
|
-
[$,
|
|
8476
|
+
[N, P],
|
|
8477
|
+
[$, D]
|
|
8478
8478
|
);
|
|
8479
|
-
const
|
|
8479
|
+
const _t = new Ft(
|
|
8480
8480
|
!0,
|
|
8481
8481
|
S.from(me.encode(["OP_RETURN", X.str("BRC20PROG")], !1)),
|
|
8482
8482
|
null,
|
|
@@ -8489,10 +8489,10 @@ async function Cl(e, t, n = {}) {
|
|
|
8489
8489
|
value: Number.parseInt(e.toString())
|
|
8490
8490
|
}
|
|
8491
8491
|
];
|
|
8492
|
-
|
|
8492
|
+
M = await Cn(
|
|
8493
8493
|
$,
|
|
8494
8494
|
[],
|
|
8495
|
-
|
|
8495
|
+
_t,
|
|
8496
8496
|
1,
|
|
8497
8497
|
z,
|
|
8498
8498
|
t,
|
|
@@ -8502,31 +8502,31 @@ async function Cl(e, t, n = {}) {
|
|
|
8502
8502
|
} finally {
|
|
8503
8503
|
Yt();
|
|
8504
8504
|
}
|
|
8505
|
-
if (
|
|
8505
|
+
if (M == null)
|
|
8506
8506
|
throw new Error("Failed to send inscription to OP_RETURN");
|
|
8507
|
-
const Z =
|
|
8508
|
-
commit_txid:
|
|
8507
|
+
const Z = M.signedTxHex, at = M.txId, Q = {
|
|
8508
|
+
commit_txid: B.commitTxId,
|
|
8509
8509
|
commit_txhex: N,
|
|
8510
|
-
reveal_txid:
|
|
8511
|
-
reveal_txhex:
|
|
8510
|
+
reveal_txid: B.revealTxId,
|
|
8511
|
+
reveal_txhex: P,
|
|
8512
8512
|
send_to_opreturn_txid: at,
|
|
8513
8513
|
send_to_opreturn_txhex: Z,
|
|
8514
8514
|
secret: L,
|
|
8515
8515
|
inscription_id: $,
|
|
8516
8516
|
fee_rate: t
|
|
8517
|
-
}, G = await
|
|
8517
|
+
}, G = await Cl(Q), ft = Math.max(
|
|
8518
8518
|
G.estimated_gas + 1e5,
|
|
8519
8519
|
G.estimated_gas * 1.2
|
|
8520
8520
|
);
|
|
8521
8521
|
if (G.allocated_gas < ft) {
|
|
8522
|
-
|
|
8522
|
+
x = ft + 5e4;
|
|
8523
8523
|
continue;
|
|
8524
8524
|
}
|
|
8525
|
-
return (await
|
|
8525
|
+
return (await Nl(Q)).result;
|
|
8526
8526
|
}
|
|
8527
8527
|
throw new Error("Failed to estimate gas for wrap order after multiple attempts");
|
|
8528
8528
|
}
|
|
8529
|
-
async function
|
|
8529
|
+
async function Ll(e, t) {
|
|
8530
8530
|
const n = await Jt(), r = wn();
|
|
8531
8531
|
if (!r || !r.wallets) throw new Error("Wallets not found");
|
|
8532
8532
|
const s = Hn();
|
|
@@ -8560,30 +8560,31 @@ async function $l(e, t) {
|
|
|
8560
8560
|
null,
|
|
8561
8561
|
null,
|
|
8562
8562
|
h
|
|
8563
|
-
);
|
|
8564
|
-
let
|
|
8565
|
-
const
|
|
8563
|
+
), b = await Go(s.address);
|
|
8564
|
+
let v = 0;
|
|
8565
|
+
const O = await Ks(
|
|
8566
8566
|
g,
|
|
8567
8567
|
[],
|
|
8568
8568
|
t,
|
|
8569
8569
|
null,
|
|
8570
8570
|
null,
|
|
8571
|
-
0
|
|
8572
|
-
|
|
8573
|
-
|
|
8571
|
+
0,
|
|
8572
|
+
b
|
|
8573
|
+
), F = O.unsigned_commit_tx_hex, W = O.signed_reveal_tx_hex, A = O.inscription_id, k = `${A.split("i")[0]}:0:0`;
|
|
8574
|
+
v += O.total_fee;
|
|
8574
8575
|
let I = null;
|
|
8575
8576
|
try {
|
|
8576
8577
|
Pt(
|
|
8577
|
-
[
|
|
8578
|
-
[
|
|
8578
|
+
[F, W],
|
|
8579
|
+
[A, k]
|
|
8579
8580
|
);
|
|
8580
|
-
const
|
|
8581
|
+
const q = new Ft(
|
|
8581
8582
|
!0,
|
|
8582
8583
|
S.from(me.encode(["OP_RETURN", X.str("BRC20PROG")], !1)),
|
|
8583
8584
|
null,
|
|
8584
8585
|
null,
|
|
8585
8586
|
null
|
|
8586
|
-
),
|
|
8587
|
+
), H = [
|
|
8587
8588
|
// send BTC to WBTC handler
|
|
8588
8589
|
{
|
|
8589
8590
|
wallet: new Ft(!1, null, n.wbtc_handler_address, null, null),
|
|
@@ -8591,24 +8592,25 @@ async function $l(e, t) {
|
|
|
8591
8592
|
}
|
|
8592
8593
|
];
|
|
8593
8594
|
I = await Nn(
|
|
8594
|
-
|
|
8595
|
+
A,
|
|
8595
8596
|
[],
|
|
8596
|
-
|
|
8597
|
+
q,
|
|
8597
8598
|
1,
|
|
8598
|
-
|
|
8599
|
-
t
|
|
8599
|
+
H,
|
|
8600
|
+
t,
|
|
8601
|
+
b
|
|
8600
8602
|
);
|
|
8601
8603
|
} finally {
|
|
8602
8604
|
Yt();
|
|
8603
8605
|
}
|
|
8604
8606
|
if (I == null)
|
|
8605
8607
|
throw new Error("Failed to send inscription to OP_RETURN");
|
|
8606
|
-
return
|
|
8607
|
-
total_fee:
|
|
8608
|
+
return v += I.tx_fee, {
|
|
8609
|
+
total_fee: v,
|
|
8608
8610
|
fee_rate: t
|
|
8609
8611
|
};
|
|
8610
8612
|
}
|
|
8611
|
-
async function
|
|
8613
|
+
async function Al(e, t, n, r) {
|
|
8612
8614
|
const s = await Jt();
|
|
8613
8615
|
Qn(s.wbtc_address, s.factory_address);
|
|
8614
8616
|
const i = (await et())?.swapPubkey;
|
|
@@ -8617,7 +8619,7 @@ async function Ll(e, t, n, r) {
|
|
|
8617
8619
|
const o = {
|
|
8618
8620
|
balanceOf: En,
|
|
8619
8621
|
reservesOf: Pe
|
|
8620
|
-
}, a = await $t("add_liquidity"), c = await
|
|
8622
|
+
}, a = await $t("add_liquidity"), c = await tl(
|
|
8621
8623
|
o,
|
|
8622
8624
|
i,
|
|
8623
8625
|
e,
|
|
@@ -8645,7 +8647,7 @@ async function Ll(e, t, n, r) {
|
|
|
8645
8647
|
throw new Error("No data returned from add liquidity request.");
|
|
8646
8648
|
return c.data;
|
|
8647
8649
|
}
|
|
8648
|
-
async function
|
|
8650
|
+
async function Pl(e) {
|
|
8649
8651
|
e.token1_addr = e.token1_addr.toLowerCase(), e.token2_addr = e.token2_addr.toLowerCase();
|
|
8650
8652
|
const t = `Add Liquidity Order:
|
|
8651
8653
|
Token 1 Address: ${e.token1_addr}
|
|
@@ -8661,7 +8663,7 @@ BTC Fee: ${e.btc_fee}
|
|
|
8661
8663
|
By signing this message, you authorize the creation of an add liquidity order with the above parameters.`;
|
|
8662
8664
|
return await Le(t, "ordinals");
|
|
8663
8665
|
}
|
|
8664
|
-
async function
|
|
8666
|
+
async function Fl(e) {
|
|
8665
8667
|
e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
|
|
8666
8668
|
let t = tt(S.from(e.pubkey, "hex")).slice(2);
|
|
8667
8669
|
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");
|
|
@@ -8673,7 +8675,7 @@ async function Pl(e) {
|
|
|
8673
8675
|
const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = S.from(i, "hex"), a = T.shortSignatures.sign(r, o);
|
|
8674
8676
|
return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
|
|
8675
8677
|
}
|
|
8676
|
-
async function
|
|
8678
|
+
async function Ul(e) {
|
|
8677
8679
|
const t = j("add_liq_req");
|
|
8678
8680
|
return J(t, {
|
|
8679
8681
|
method: "POST",
|
|
@@ -8683,11 +8685,11 @@ async function Fl(e) {
|
|
|
8683
8685
|
body: JSON.stringify(e)
|
|
8684
8686
|
});
|
|
8685
8687
|
}
|
|
8686
|
-
async function
|
|
8688
|
+
async function ql(e, t, n, r, s) {
|
|
8687
8689
|
const i = (await et())?.swapPubkey;
|
|
8688
8690
|
if (!i)
|
|
8689
8691
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
8690
|
-
const o = n * (10000n - s) / 10000n, a = r * (10000n - s) / 10000n, c = 0n, u = 0n, l = await Fe(), f = await $t("add_liquidity"), d = await
|
|
8692
|
+
const o = n * (10000n - s) / 10000n, a = r * (10000n - s) / 10000n, c = 0n, u = 0n, l = await Fe(), f = await $t("add_liquidity"), d = await Pl({
|
|
8691
8693
|
token1_addr: e,
|
|
8692
8694
|
token2_addr: t,
|
|
8693
8695
|
amt1: n.toString(),
|
|
@@ -8697,7 +8699,7 @@ async function Ul(e, t, n, r, s) {
|
|
|
8697
8699
|
token1FeeBps: c.toString(),
|
|
8698
8700
|
token2FeeBps: u.toString(),
|
|
8699
8701
|
btc_fee: f.toString()
|
|
8700
|
-
}), p = await
|
|
8702
|
+
}), p = await Fl({
|
|
8701
8703
|
pubkey: i,
|
|
8702
8704
|
nonce: l,
|
|
8703
8705
|
token1_addr: e,
|
|
@@ -8710,7 +8712,7 @@ async function Ul(e, t, n, r, s) {
|
|
|
8710
8712
|
token2FeeBps: u,
|
|
8711
8713
|
btc_fee: f
|
|
8712
8714
|
});
|
|
8713
|
-
return await
|
|
8715
|
+
return await Ul({
|
|
8714
8716
|
pubkey: i,
|
|
8715
8717
|
token1_addr: e,
|
|
8716
8718
|
token2_addr: t,
|
|
@@ -8725,7 +8727,7 @@ async function Ul(e, t, n, r, s) {
|
|
|
8725
8727
|
bip322_signature: d
|
|
8726
8728
|
});
|
|
8727
8729
|
}
|
|
8728
|
-
async function
|
|
8730
|
+
async function Dl(e, t, n) {
|
|
8729
8731
|
const r = await Jt();
|
|
8730
8732
|
Qn(r.wbtc_address, r.factory_address);
|
|
8731
8733
|
const s = (await et())?.swapPubkey;
|
|
@@ -8734,7 +8736,7 @@ async function ql(e, t, n) {
|
|
|
8734
8736
|
const i = {
|
|
8735
8737
|
balanceOf: En,
|
|
8736
8738
|
reservesOf: Pe
|
|
8737
|
-
}, o = await $t("remove_liquidity"), a = await
|
|
8739
|
+
}, o = await $t("remove_liquidity"), a = await nl(
|
|
8738
8740
|
i,
|
|
8739
8741
|
s,
|
|
8740
8742
|
e,
|
|
@@ -8761,7 +8763,7 @@ async function ql(e, t, n) {
|
|
|
8761
8763
|
throw new Error("No data returned from remove liquidity request.");
|
|
8762
8764
|
return a.data;
|
|
8763
8765
|
}
|
|
8764
|
-
async function
|
|
8766
|
+
async function Ml(e) {
|
|
8765
8767
|
e.token1_addr = e.token1_addr.toLowerCase(), e.token2_addr = e.token2_addr.toLowerCase();
|
|
8766
8768
|
const t = `Remove Liquidity Order:
|
|
8767
8769
|
Token 1 Address: ${e.token1_addr}
|
|
@@ -8776,7 +8778,7 @@ BTC Fee: ${e.btc_fee}
|
|
|
8776
8778
|
By signing this message, you authorize the creation of a remove liquidity order with the above parameters.`;
|
|
8777
8779
|
return await Le(t, "ordinals");
|
|
8778
8780
|
}
|
|
8779
|
-
async function
|
|
8781
|
+
async function Wl(e) {
|
|
8780
8782
|
e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
|
|
8781
8783
|
let t = tt(S.from(e.pubkey, "hex")).slice(2);
|
|
8782
8784
|
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");
|
|
@@ -8788,7 +8790,7 @@ async function Ml(e) {
|
|
|
8788
8790
|
const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = S.from(i, "hex"), a = T.shortSignatures.sign(r, o);
|
|
8789
8791
|
return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
|
|
8790
8792
|
}
|
|
8791
|
-
async function
|
|
8793
|
+
async function Gl(e) {
|
|
8792
8794
|
const t = j("remove_liq_req");
|
|
8793
8795
|
return J(t, {
|
|
8794
8796
|
method: "POST",
|
|
@@ -8798,11 +8800,11 @@ async function Wl(e) {
|
|
|
8798
8800
|
body: JSON.stringify(e)
|
|
8799
8801
|
});
|
|
8800
8802
|
}
|
|
8801
|
-
async function
|
|
8803
|
+
async function Hl(e, t, n, r, s, i) {
|
|
8802
8804
|
const o = (await et())?.swapPubkey;
|
|
8803
8805
|
if (!o)
|
|
8804
8806
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
8805
|
-
const a = r * (10000n - i) / 10000n, c = s * (10000n - i) / 10000n, u = 0n, l = 0n, f = await Fe(), d = await $t("remove_liquidity"), p = await
|
|
8807
|
+
const a = r * (10000n - i) / 10000n, c = s * (10000n - i) / 10000n, u = 0n, l = 0n, f = await Fe(), d = await $t("remove_liquidity"), p = await Ml({
|
|
8806
8808
|
token1_addr: e,
|
|
8807
8809
|
token2_addr: t,
|
|
8808
8810
|
lp_amt: n.toString(),
|
|
@@ -8811,7 +8813,7 @@ async function Gl(e, t, n, r, s, i) {
|
|
|
8811
8813
|
token1FeeBps: u.toString(),
|
|
8812
8814
|
token2FeeBps: l.toString(),
|
|
8813
8815
|
btc_fee: d.toString()
|
|
8814
|
-
}), w = await
|
|
8816
|
+
}), w = await Wl({
|
|
8815
8817
|
pubkey: o,
|
|
8816
8818
|
nonce: f,
|
|
8817
8819
|
token1_addr: e,
|
|
@@ -8823,7 +8825,7 @@ async function Gl(e, t, n, r, s, i) {
|
|
|
8823
8825
|
token2FeeBps: l,
|
|
8824
8826
|
btc_fee: d
|
|
8825
8827
|
});
|
|
8826
|
-
return await
|
|
8828
|
+
return await Gl({
|
|
8827
8829
|
pubkey: o,
|
|
8828
8830
|
token1_addr: e,
|
|
8829
8831
|
token2_addr: t,
|
|
@@ -8843,9 +8845,9 @@ async function sr(e, t) {
|
|
|
8843
8845
|
const r = Or.get(Qe());
|
|
8844
8846
|
throw new Error(r ?? io);
|
|
8845
8847
|
}
|
|
8846
|
-
return
|
|
8848
|
+
return Cu(e, t, n.fee_policy);
|
|
8847
8849
|
}
|
|
8848
|
-
async function
|
|
8850
|
+
async function Vl(e, t, n) {
|
|
8849
8851
|
const r = await Jt();
|
|
8850
8852
|
await nr(e, t);
|
|
8851
8853
|
const s = (await et())?.swapPubkey;
|
|
@@ -8854,7 +8856,7 @@ async function Hl(e, t, n) {
|
|
|
8854
8856
|
const i = {
|
|
8855
8857
|
balanceOf: En,
|
|
8856
8858
|
reservesOf: Pe
|
|
8857
|
-
}, o = await $t("swap"), { token1FeeBps: a, token2FeeBps: c } = await sr(e, t), u = await
|
|
8859
|
+
}, o = await $t("swap"), { token1FeeBps: a, token2FeeBps: c } = await sr(e, t), u = await sl(
|
|
8858
8860
|
i,
|
|
8859
8861
|
s,
|
|
8860
8862
|
e,
|
|
@@ -8893,7 +8895,7 @@ async function Hl(e, t, n) {
|
|
|
8893
8895
|
fees: ao(n, u.amounts[1], a, c, o)
|
|
8894
8896
|
};
|
|
8895
8897
|
}
|
|
8896
|
-
async function
|
|
8898
|
+
async function Zl(e) {
|
|
8897
8899
|
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;
|
|
8898
8900
|
const t = `Swap Order:
|
|
8899
8901
|
Token 1 Address: ${e.token1_addr}
|
|
@@ -8909,7 +8911,7 @@ ${e.referrer_pubkey ? `Referrer Pubkey: ${e.referrer_pubkey}
|
|
|
8909
8911
|
By signing this message, you authorize the creation of a swap order with the above parameters.`;
|
|
8910
8912
|
return await Le(t, "ordinals");
|
|
8911
8913
|
}
|
|
8912
|
-
async function
|
|
8914
|
+
async function Yl(e) {
|
|
8913
8915
|
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;
|
|
8914
8916
|
let t = tt(S.from(e.pubkey, "hex")).slice(2);
|
|
8915
8917
|
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(S.from(e.referrer_pubkey, "hex")).slice(2), t += po.toString(16).padStart(8, "0"), e.ref_return_bps && e.ref_return_bps > 0n && (t += e.ref_return_bps.toString(16).padStart(8, "0")));
|
|
@@ -8921,7 +8923,7 @@ async function Zl(e) {
|
|
|
8921
8923
|
const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = S.from(i, "hex"), a = T.shortSignatures.sign(r, o);
|
|
8922
8924
|
return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
|
|
8923
8925
|
}
|
|
8924
|
-
async function
|
|
8926
|
+
async function zl(e) {
|
|
8925
8927
|
const t = j("swap");
|
|
8926
8928
|
return J(t, {
|
|
8927
8929
|
method: "POST",
|
|
@@ -8931,12 +8933,12 @@ async function Yl(e) {
|
|
|
8931
8933
|
body: JSON.stringify(e)
|
|
8932
8934
|
});
|
|
8933
8935
|
}
|
|
8934
|
-
async function
|
|
8936
|
+
async function Kl(e, t, n, r, s, i) {
|
|
8935
8937
|
const o = (await et())?.swapPubkey;
|
|
8936
8938
|
if (!o)
|
|
8937
8939
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
8938
8940
|
await nr(e, t);
|
|
8939
|
-
const a = r * (10000n - s) / 10000n, c = await Fe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await sr(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await
|
|
8941
|
+
const a = r * (10000n - s) / 10000n, c = await Fe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await sr(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await Zl({
|
|
8940
8942
|
token1_addr: e,
|
|
8941
8943
|
token2_addr: t,
|
|
8942
8944
|
in_amt: n.toString(),
|
|
@@ -8946,7 +8948,7 @@ async function zl(e, t, n, r, s, i) {
|
|
|
8946
8948
|
btc_fee: u.toString(),
|
|
8947
8949
|
referrer_pubkey: d,
|
|
8948
8950
|
ref_return_bps: p ? p.toString() : void 0
|
|
8949
|
-
}), h = await
|
|
8951
|
+
}), h = await Yl({
|
|
8950
8952
|
pubkey: o,
|
|
8951
8953
|
nonce: c,
|
|
8952
8954
|
token1_addr: e,
|
|
@@ -8959,7 +8961,7 @@ async function zl(e, t, n, r, s, i) {
|
|
|
8959
8961
|
referrer_pubkey: d,
|
|
8960
8962
|
ref_return_bps: p
|
|
8961
8963
|
});
|
|
8962
|
-
return await
|
|
8964
|
+
return await zl({
|
|
8963
8965
|
pubkey: o,
|
|
8964
8966
|
token1_addr: e,
|
|
8965
8967
|
token2_addr: t,
|
|
@@ -8974,7 +8976,7 @@ async function zl(e, t, n, r, s, i) {
|
|
|
8974
8976
|
referrer_id: d ? i : void 0
|
|
8975
8977
|
});
|
|
8976
8978
|
}
|
|
8977
|
-
async function
|
|
8979
|
+
async function Xl(e, t, n) {
|
|
8978
8980
|
const r = await Jt();
|
|
8979
8981
|
await nr(e, t);
|
|
8980
8982
|
const s = (await et())?.swapPubkey;
|
|
@@ -8983,7 +8985,7 @@ async function Kl(e, t, n) {
|
|
|
8983
8985
|
const i = {
|
|
8984
8986
|
balanceOf: En,
|
|
8985
8987
|
reservesOf: Pe
|
|
8986
|
-
}, o = await $t("swap"), { token1FeeBps: a, token2FeeBps: c } = await sr(e, t), u = await
|
|
8988
|
+
}, o = await $t("swap"), { token1FeeBps: a, token2FeeBps: c } = await sr(e, t), u = await ol(
|
|
8987
8989
|
i,
|
|
8988
8990
|
s,
|
|
8989
8991
|
e,
|
|
@@ -9022,7 +9024,7 @@ async function Kl(e, t, n) {
|
|
|
9022
9024
|
fees: ao(u.amounts[0], n, a, c, o)
|
|
9023
9025
|
};
|
|
9024
9026
|
}
|
|
9025
|
-
async function
|
|
9027
|
+
async function Jl(e) {
|
|
9026
9028
|
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;
|
|
9027
9029
|
const t = `Swap Order:
|
|
9028
9030
|
Token 1 Address: ${e.token1_addr}
|
|
@@ -9038,7 +9040,7 @@ ${e.referrer_pubkey ? `Referrer Pubkey: ${e.referrer_pubkey}
|
|
|
9038
9040
|
By signing this message, you authorize the creation of a swap order with the above parameters.`;
|
|
9039
9041
|
return await Le(t, "ordinals");
|
|
9040
9042
|
}
|
|
9041
|
-
async function
|
|
9043
|
+
async function jl(e) {
|
|
9042
9044
|
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;
|
|
9043
9045
|
let t = tt(S.from(e.pubkey, "hex")).slice(2);
|
|
9044
9046
|
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(S.from(e.referrer_pubkey, "hex")).slice(2), t += po.toString(16).padStart(8, "0"), e.ref_return_bps && e.ref_return_bps > 0n && (t += e.ref_return_bps.toString(16).padStart(8, "0")));
|
|
@@ -9050,7 +9052,7 @@ async function Jl(e) {
|
|
|
9050
9052
|
const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = S.from(i, "hex"), a = T.shortSignatures.sign(r, o);
|
|
9051
9053
|
return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
|
|
9052
9054
|
}
|
|
9053
|
-
async function
|
|
9055
|
+
async function Ql(e) {
|
|
9054
9056
|
const t = j("swap2");
|
|
9055
9057
|
return J(t, {
|
|
9056
9058
|
method: "POST",
|
|
@@ -9060,12 +9062,12 @@ async function jl(e) {
|
|
|
9060
9062
|
body: JSON.stringify(e)
|
|
9061
9063
|
});
|
|
9062
9064
|
}
|
|
9063
|
-
async function
|
|
9065
|
+
async function tf(e, t, n, r, s, i) {
|
|
9064
9066
|
const o = (await et())?.swapPubkey;
|
|
9065
9067
|
if (!o)
|
|
9066
9068
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
9067
9069
|
await nr(e, t);
|
|
9068
|
-
const a = n * (10000n + s) / 10000n, c = await Fe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await sr(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await
|
|
9070
|
+
const a = n * (10000n + s) / 10000n, c = await Fe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await sr(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await Jl({
|
|
9069
9071
|
token1_addr: e,
|
|
9070
9072
|
token2_addr: t,
|
|
9071
9073
|
max_in_amt: a.toString(),
|
|
@@ -9075,7 +9077,7 @@ async function Ql(e, t, n, r, s, i) {
|
|
|
9075
9077
|
btc_fee: u.toString(),
|
|
9076
9078
|
referrer_pubkey: d,
|
|
9077
9079
|
ref_return_bps: p ? p.toString() : void 0
|
|
9078
|
-
}), h = await
|
|
9080
|
+
}), h = await jl({
|
|
9079
9081
|
pubkey: o,
|
|
9080
9082
|
nonce: c,
|
|
9081
9083
|
token1_addr: e,
|
|
@@ -9088,7 +9090,7 @@ async function Ql(e, t, n, r, s, i) {
|
|
|
9088
9090
|
referrer_pubkey: d,
|
|
9089
9091
|
ref_return_bps: p
|
|
9090
9092
|
});
|
|
9091
|
-
return await
|
|
9093
|
+
return await Ql({
|
|
9092
9094
|
pubkey: o,
|
|
9093
9095
|
token1_addr: e,
|
|
9094
9096
|
token2_addr: t,
|
|
@@ -9142,7 +9144,7 @@ async function Io(e) {
|
|
|
9142
9144
|
body: JSON.stringify(e)
|
|
9143
9145
|
});
|
|
9144
9146
|
}
|
|
9145
|
-
async function
|
|
9147
|
+
async function ef(e, t, n) {
|
|
9146
9148
|
const r = (await et())?.swapPubkey;
|
|
9147
9149
|
if (!r)
|
|
9148
9150
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
@@ -9173,7 +9175,7 @@ async function tf(e, t, n) {
|
|
|
9173
9175
|
bip322_signature: l
|
|
9174
9176
|
});
|
|
9175
9177
|
}
|
|
9176
|
-
async function
|
|
9178
|
+
async function nf(e, t) {
|
|
9177
9179
|
const n = (await et())?.swapPubkey;
|
|
9178
9180
|
if (!n)
|
|
9179
9181
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
@@ -9207,7 +9209,7 @@ async function ef(e, t) {
|
|
|
9207
9209
|
bip322_signature: l
|
|
9208
9210
|
});
|
|
9209
9211
|
}
|
|
9210
|
-
async function
|
|
9212
|
+
async function rf(e, t) {
|
|
9211
9213
|
const n = await Jt();
|
|
9212
9214
|
Qn(n.wbtc_address, n.factory_address);
|
|
9213
9215
|
const r = (await et())?.swapPubkey;
|
|
@@ -9216,7 +9218,7 @@ async function nf(e, t) {
|
|
|
9216
9218
|
const s = {
|
|
9217
9219
|
balanceOf: En,
|
|
9218
9220
|
reservesOf: Pe
|
|
9219
|
-
}, i = await $t("unwrap"), o = await
|
|
9221
|
+
}, i = await $t("unwrap"), o = await cl(
|
|
9220
9222
|
s,
|
|
9221
9223
|
r,
|
|
9222
9224
|
e,
|
|
@@ -9233,7 +9235,7 @@ async function nf(e, t) {
|
|
|
9233
9235
|
throw new Error("No data returned from unwrap request.");
|
|
9234
9236
|
return { amt: o.data.amt };
|
|
9235
9237
|
}
|
|
9236
|
-
async function
|
|
9238
|
+
async function sf(e) {
|
|
9237
9239
|
e.pkscript = e.pkscript.toLowerCase();
|
|
9238
9240
|
const t = `Unwrap Order:
|
|
9239
9241
|
Pkscript: ${e.pkscript}
|
|
@@ -9245,7 +9247,7 @@ BTC Fee: ${e.btc_fee}
|
|
|
9245
9247
|
By signing this message, you authorize the creation of a withdraw order with the above parameters.`;
|
|
9246
9248
|
return await Le(t, "ordinals");
|
|
9247
9249
|
}
|
|
9248
|
-
async function
|
|
9250
|
+
async function of(e) {
|
|
9249
9251
|
e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
|
|
9250
9252
|
let t = tt(S.from(e.pubkey, "hex")).slice(2);
|
|
9251
9253
|
t += e.nonce.toString(16).padStart(8, "0"), t += "06", t += tt(S.from(e.pkscript, "hex")).slice(2), t += e.amt.toString(16).padStart(64, "0"), t += e.btc_fee.toString(16).padStart(64, "0");
|
|
@@ -9257,7 +9259,7 @@ async function sf(e) {
|
|
|
9257
9259
|
const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = S.from(i, "hex"), a = T.shortSignatures.sign(r, o);
|
|
9258
9260
|
return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
|
|
9259
9261
|
}
|
|
9260
|
-
async function
|
|
9262
|
+
async function af(e) {
|
|
9261
9263
|
const t = j("unwrap");
|
|
9262
9264
|
return J(t, {
|
|
9263
9265
|
method: "POST",
|
|
@@ -9267,24 +9269,24 @@ async function of(e) {
|
|
|
9267
9269
|
body: JSON.stringify(e)
|
|
9268
9270
|
});
|
|
9269
9271
|
}
|
|
9270
|
-
async function
|
|
9272
|
+
async function cf(e, t) {
|
|
9271
9273
|
const n = (await et())?.swapPubkey;
|
|
9272
9274
|
if (!n)
|
|
9273
9275
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
9274
|
-
const r = 0n, s = 0n, i = await Fe(), o = await $t("unwrap"), a = await
|
|
9276
|
+
const r = 0n, s = 0n, i = await Fe(), o = await $t("unwrap"), a = await sf({
|
|
9275
9277
|
pkscript: e,
|
|
9276
9278
|
amt: t.toString(),
|
|
9277
9279
|
token1FeeBps: r.toString(),
|
|
9278
9280
|
token2FeeBps: s.toString(),
|
|
9279
9281
|
btc_fee: o.toString()
|
|
9280
|
-
}), c = await
|
|
9282
|
+
}), c = await of({
|
|
9281
9283
|
pubkey: n,
|
|
9282
9284
|
nonce: i,
|
|
9283
9285
|
pkscript: e,
|
|
9284
9286
|
amt: t,
|
|
9285
9287
|
btc_fee: o
|
|
9286
9288
|
});
|
|
9287
|
-
return await
|
|
9289
|
+
return await af({
|
|
9288
9290
|
pubkey: n,
|
|
9289
9291
|
pkscript: e,
|
|
9290
9292
|
amt: t.toString(),
|
|
@@ -9295,23 +9297,23 @@ async function af(e, t) {
|
|
|
9295
9297
|
bip322_signature: a
|
|
9296
9298
|
});
|
|
9297
9299
|
}
|
|
9298
|
-
async function
|
|
9299
|
-
return await
|
|
9300
|
+
async function uf(e, t, n, r) {
|
|
9301
|
+
return await Tl({
|
|
9300
9302
|
pubkey: e,
|
|
9301
9303
|
pairAddress: t,
|
|
9302
9304
|
limit: n,
|
|
9303
9305
|
offset: r
|
|
9304
9306
|
});
|
|
9305
9307
|
}
|
|
9306
|
-
async function
|
|
9307
|
-
return await
|
|
9308
|
+
async function lf(e, t, n) {
|
|
9309
|
+
return await Ol({
|
|
9308
9310
|
pair_address: e,
|
|
9309
9311
|
limit: t || 20,
|
|
9310
9312
|
offset: n || 0
|
|
9311
9313
|
});
|
|
9312
9314
|
}
|
|
9313
|
-
async function
|
|
9314
|
-
return (await
|
|
9315
|
+
async function ff(e, t, n, r, s) {
|
|
9316
|
+
return (await ql(
|
|
9315
9317
|
e,
|
|
9316
9318
|
t,
|
|
9317
9319
|
n,
|
|
@@ -9319,8 +9321,8 @@ async function lf(e, t, n, r, s) {
|
|
|
9319
9321
|
s
|
|
9320
9322
|
)).success;
|
|
9321
9323
|
}
|
|
9322
|
-
async function
|
|
9323
|
-
return (await
|
|
9324
|
+
async function df(e, t, n, r, s, i) {
|
|
9325
|
+
return (await Hl(
|
|
9324
9326
|
e,
|
|
9325
9327
|
t,
|
|
9326
9328
|
n,
|
|
@@ -9329,8 +9331,8 @@ async function ff(e, t, n, r, s, i) {
|
|
|
9329
9331
|
i
|
|
9330
9332
|
)).success;
|
|
9331
9333
|
}
|
|
9332
|
-
async function
|
|
9333
|
-
return (await
|
|
9334
|
+
async function pf(e, t, n, r, s, i) {
|
|
9335
|
+
return (await Kl(
|
|
9334
9336
|
e,
|
|
9335
9337
|
t,
|
|
9336
9338
|
n,
|
|
@@ -9339,8 +9341,8 @@ async function df(e, t, n, r, s, i) {
|
|
|
9339
9341
|
i
|
|
9340
9342
|
)).success;
|
|
9341
9343
|
}
|
|
9342
|
-
async function
|
|
9343
|
-
return (await
|
|
9344
|
+
async function hf(e, t, n, r, s, i) {
|
|
9345
|
+
return (await tf(
|
|
9344
9346
|
e,
|
|
9345
9347
|
t,
|
|
9346
9348
|
n,
|
|
@@ -9349,11 +9351,11 @@ async function pf(e, t, n, r, s, i) {
|
|
|
9349
9351
|
i
|
|
9350
9352
|
)).success;
|
|
9351
9353
|
}
|
|
9352
|
-
async function
|
|
9353
|
-
return (await
|
|
9354
|
+
async function wf(e, t) {
|
|
9355
|
+
return (await cf(e, t)).success;
|
|
9354
9356
|
}
|
|
9355
|
-
async function
|
|
9356
|
-
return await
|
|
9357
|
+
async function gf(e, t, n, r = !0, s, i) {
|
|
9358
|
+
return await Rl(
|
|
9357
9359
|
e,
|
|
9358
9360
|
t,
|
|
9359
9361
|
n,
|
|
@@ -9362,60 +9364,60 @@ async function wf(e, t, n, r = !0, s, i) {
|
|
|
9362
9364
|
i
|
|
9363
9365
|
);
|
|
9364
9366
|
}
|
|
9365
|
-
async function gf(e, t, n) {
|
|
9366
|
-
return await Cl(e, t, n);
|
|
9367
|
-
}
|
|
9368
9367
|
async function yf(e, t, n) {
|
|
9369
|
-
return
|
|
9368
|
+
return await $l(e, t, n);
|
|
9370
9369
|
}
|
|
9371
|
-
|
|
9370
|
+
async function bf(e, t, n) {
|
|
9371
|
+
return n ? (await ef(e, n, t)).success : (await nf(e, t)).success;
|
|
9372
|
+
}
|
|
9373
|
+
const Mf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9372
9374
|
__proto__: null,
|
|
9373
|
-
addLiquidity:
|
|
9375
|
+
addLiquidity: ff,
|
|
9374
9376
|
createSwapWallet: go,
|
|
9375
|
-
deposit:
|
|
9376
|
-
ensureSwapWallet:
|
|
9377
|
-
getActivityOfPair:
|
|
9378
|
-
getAddLiquidityResult:
|
|
9379
|
-
getKlines:
|
|
9377
|
+
deposit: gf,
|
|
9378
|
+
ensureSwapWallet: hl,
|
|
9379
|
+
getActivityOfPair: lf,
|
|
9380
|
+
getAddLiquidityResult: Al,
|
|
9381
|
+
getKlines: Bl,
|
|
9380
9382
|
getMinerFee: $t,
|
|
9381
|
-
getMinerFeesOfDepositOrder:
|
|
9382
|
-
getMinerFeesOfWrapOrder:
|
|
9383
|
+
getMinerFeesOfDepositOrder: kl,
|
|
9384
|
+
getMinerFeesOfWrapOrder: Ll,
|
|
9383
9385
|
getPairAddress: tr,
|
|
9384
9386
|
getPairReserves: Pe,
|
|
9385
|
-
getPairVolumeOverDays:
|
|
9386
|
-
getRemoveLiquidityResult:
|
|
9387
|
-
getSwapBalance:
|
|
9388
|
-
getSwapBalances:
|
|
9389
|
-
getSwapExactInputResult:
|
|
9390
|
-
getSwapExactOutputResult:
|
|
9387
|
+
getPairVolumeOverDays: Sl,
|
|
9388
|
+
getRemoveLiquidityResult: Dl,
|
|
9389
|
+
getSwapBalance: ml,
|
|
9390
|
+
getSwapBalances: bl,
|
|
9391
|
+
getSwapExactInputResult: Vl,
|
|
9392
|
+
getSwapExactOutputResult: Xl,
|
|
9391
9393
|
getSwapInfo: Jt,
|
|
9392
|
-
getSwapStatus:
|
|
9393
|
-
getSwapWalletSecurityCode:
|
|
9394
|
+
getSwapStatus: gl,
|
|
9395
|
+
getSwapWalletSecurityCode: wl,
|
|
9394
9396
|
getTokenDecimals: pn,
|
|
9395
|
-
getTvlHistory:
|
|
9396
|
-
getUnwrapBtcResult:
|
|
9397
|
-
getWalletActivities:
|
|
9398
|
-
importSwapWallet:
|
|
9399
|
-
listPairs:
|
|
9397
|
+
getTvlHistory: vl,
|
|
9398
|
+
getUnwrapBtcResult: rf,
|
|
9399
|
+
getWalletActivities: uf,
|
|
9400
|
+
importSwapWallet: pl,
|
|
9401
|
+
listPairs: El,
|
|
9400
9402
|
listTokens: _l,
|
|
9401
|
-
removeLiquidity:
|
|
9403
|
+
removeLiquidity: df,
|
|
9402
9404
|
satsToBtc: oo,
|
|
9403
|
-
satsToUsd:
|
|
9404
|
-
swapExactInput:
|
|
9405
|
-
swapExactOutput:
|
|
9406
|
-
swapSide:
|
|
9405
|
+
satsToUsd: Au,
|
|
9406
|
+
swapExactInput: pf,
|
|
9407
|
+
swapExactOutput: hf,
|
|
9408
|
+
swapSide: Lu,
|
|
9407
9409
|
tryGetSwapReferrerInfo: Vr,
|
|
9408
|
-
unwrapBtc:
|
|
9409
|
-
withdraw:
|
|
9410
|
-
wrapBtc:
|
|
9411
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
9410
|
+
unwrapBtc: wf,
|
|
9411
|
+
withdraw: bf,
|
|
9412
|
+
wrapBtc: yf
|
|
9413
|
+
}, Symbol.toStringTag, { value: "Module" })), mf = "text/plain", Ro = /^[a-z0-9-]{6}$/i, xf = /^(?:[0-9a-f]{2})+$/i;
|
|
9412
9414
|
function Zr(e) {
|
|
9413
9415
|
if (typeof e != "string" || e.length === 0)
|
|
9414
9416
|
throw new Error("tick must be a non-empty string");
|
|
9415
9417
|
return X.str(e).length;
|
|
9416
9418
|
}
|
|
9417
9419
|
function Tr(e, t) {
|
|
9418
|
-
if (typeof e != "string" || !
|
|
9420
|
+
if (typeof e != "string" || !xf.test(e))
|
|
9419
9421
|
throw new Error(`${t} must be a non-empty hex string`);
|
|
9420
9422
|
}
|
|
9421
9423
|
function Gn(e, t) {
|
|
@@ -9424,7 +9426,7 @@ function Gn(e, t) {
|
|
|
9424
9426
|
}
|
|
9425
9427
|
function hn(e) {
|
|
9426
9428
|
return new ae(
|
|
9427
|
-
X.str(
|
|
9429
|
+
X.str(mf),
|
|
9428
9430
|
null,
|
|
9429
9431
|
null,
|
|
9430
9432
|
null,
|
|
@@ -9450,12 +9452,12 @@ function _f(e) {
|
|
|
9450
9452
|
throw new Error(`deploy ticker must be 4 or 5 bytes, got ${t}`);
|
|
9451
9453
|
return hn(ko(e, t, null));
|
|
9452
9454
|
}
|
|
9453
|
-
function
|
|
9455
|
+
function Ef(e) {
|
|
9454
9456
|
const t = Zr(e.tick);
|
|
9455
9457
|
if (t < 4 || t > 6) throw new Error(`ticker must be 4-6 bytes, got ${t}`);
|
|
9456
9458
|
return Gn(e.amt, "amt"), hn({ p: "brc-20", op: "mint", tick: e.tick, amt: e.amt });
|
|
9457
9459
|
}
|
|
9458
|
-
function
|
|
9460
|
+
function Sf(e) {
|
|
9459
9461
|
const t = Zr(e.tick);
|
|
9460
9462
|
if (t < 4 || t > 6) throw new Error(`ticker must be 4-6 bytes, got ${t}`);
|
|
9461
9463
|
return Gn(e.amt, "amt"), hn({ p: "brc-20", op: "transfer", tick: e.tick, amt: e.amt });
|
|
@@ -9465,7 +9467,7 @@ function No(e = 16) {
|
|
|
9465
9467
|
throw new Error("byteLength must be a positive integer");
|
|
9466
9468
|
return X.random(e).hex;
|
|
9467
9469
|
}
|
|
9468
|
-
function
|
|
9470
|
+
function Bf(e) {
|
|
9469
9471
|
if (typeof e != "string" || e.length === 0)
|
|
9470
9472
|
throw new Error("address must be a non-empty string");
|
|
9471
9473
|
return gn.address.toOutputScript(e, ze()).toString("hex");
|
|
@@ -9481,10 +9483,10 @@ function Co(e, t, n) {
|
|
|
9481
9483
|
]);
|
|
9482
9484
|
return gn.crypto.hash256(r).toString("hex");
|
|
9483
9485
|
}
|
|
9484
|
-
function
|
|
9486
|
+
function vf(e) {
|
|
9485
9487
|
if (typeof e.tick != "string" || !Ro.test(e.tick))
|
|
9486
9488
|
throw new Error("6-byte ticker must match /^[A-Za-z0-9-]{6}$/");
|
|
9487
|
-
const t =
|
|
9489
|
+
const t = Bf(e.address), n = e.salt ?? No();
|
|
9488
9490
|
Tr(n, "salt");
|
|
9489
9491
|
const r = Co(e.tick, n, t), s = ko(
|
|
9490
9492
|
{ tick: e.tick, max: e.max, lim: e.lim, dec: e.dec },
|
|
@@ -9500,7 +9502,7 @@ function Bf(e) {
|
|
|
9500
9502
|
}
|
|
9501
9503
|
async function $o(e, t, n, r, s, i, o, a, c) {
|
|
9502
9504
|
if (!c || c === "ordinals")
|
|
9503
|
-
return await
|
|
9505
|
+
return await Vo(
|
|
9504
9506
|
e,
|
|
9505
9507
|
t,
|
|
9506
9508
|
n,
|
|
@@ -9512,7 +9514,7 @@ async function $o(e, t, n, r, s, i, o, a, c) {
|
|
|
9512
9514
|
o
|
|
9513
9515
|
);
|
|
9514
9516
|
if (c === "payment")
|
|
9515
|
-
return await
|
|
9517
|
+
return await Zo(
|
|
9516
9518
|
e,
|
|
9517
9519
|
t,
|
|
9518
9520
|
n,
|
|
@@ -9525,11 +9527,11 @@ async function $o(e, t, n, r, s, i, o, a, c) {
|
|
|
9525
9527
|
);
|
|
9526
9528
|
throw new Error(`Unsupported wallet type: ${c}`);
|
|
9527
9529
|
}
|
|
9528
|
-
async function
|
|
9530
|
+
async function Of(e, t, n, r, s, i, o, a, c, u, l) {
|
|
9529
9531
|
if (typeof t != "object") throw new Error("abi must be an object");
|
|
9530
9532
|
if (typeof n != "string") throw new Error("func_name must be a string");
|
|
9531
9533
|
if (!Array.isArray(r)) throw new Error("params must be an array");
|
|
9532
|
-
const f = l || "payment", d =
|
|
9534
|
+
const f = l || "payment", d = Yo(t, n, r);
|
|
9533
9535
|
return await $o(
|
|
9534
9536
|
e,
|
|
9535
9537
|
d,
|
|
@@ -9542,8 +9544,8 @@ async function vf(e, t, n, r, s, i, o, a, c, u, l) {
|
|
|
9542
9544
|
f
|
|
9543
9545
|
);
|
|
9544
9546
|
}
|
|
9545
|
-
async function
|
|
9546
|
-
return await
|
|
9547
|
+
async function Tf(e, t, n, r, s, i) {
|
|
9548
|
+
return await zo(
|
|
9547
9549
|
e,
|
|
9548
9550
|
t,
|
|
9549
9551
|
n,
|
|
@@ -9553,8 +9555,8 @@ async function Of(e, t, n, r, s, i) {
|
|
|
9553
9555
|
s
|
|
9554
9556
|
);
|
|
9555
9557
|
}
|
|
9556
|
-
async function
|
|
9557
|
-
return await
|
|
9558
|
+
async function If(e, t, n, r, s, i, o) {
|
|
9559
|
+
return await Ko(
|
|
9558
9560
|
e,
|
|
9559
9561
|
t,
|
|
9560
9562
|
n,
|
|
@@ -9565,20 +9567,20 @@ async function Tf(e, t, n, r, s, i, o) {
|
|
|
9565
9567
|
i
|
|
9566
9568
|
);
|
|
9567
9569
|
}
|
|
9568
|
-
const
|
|
9570
|
+
const Wf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9569
9571
|
__proto__: null,
|
|
9570
9572
|
callSmartContract: $o,
|
|
9571
|
-
callSmartContractAbi:
|
|
9573
|
+
callSmartContractAbi: Of,
|
|
9572
9574
|
computeBrc20PredeployHash: Co,
|
|
9573
9575
|
deployBrc20Inscription: _f,
|
|
9574
|
-
depositToBrc20Prog:
|
|
9576
|
+
depositToBrc20Prog: Tf,
|
|
9575
9577
|
generateBrc20Salt: No,
|
|
9576
|
-
mintBrc20Inscription:
|
|
9577
|
-
predeployInscriptions:
|
|
9578
|
-
transferBrc20Inscription:
|
|
9579
|
-
withdrawFromBrc20Prog:
|
|
9578
|
+
mintBrc20Inscription: Ef,
|
|
9579
|
+
predeployInscriptions: vf,
|
|
9580
|
+
transferBrc20Inscription: Sf,
|
|
9581
|
+
withdrawFromBrc20Prog: If
|
|
9580
9582
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
9581
|
-
async function
|
|
9583
|
+
async function Rf(e, t, n, r, s) {
|
|
9582
9584
|
const i = await Js(
|
|
9583
9585
|
[e],
|
|
9584
9586
|
t,
|
|
@@ -9596,11 +9598,11 @@ async function If(e, t, n, r, s) {
|
|
|
9596
9598
|
secret: i.secret
|
|
9597
9599
|
};
|
|
9598
9600
|
}
|
|
9599
|
-
async function
|
|
9601
|
+
async function kf(e, t, n, r, s) {
|
|
9600
9602
|
return await Js(e, t, n, r, s);
|
|
9601
9603
|
}
|
|
9602
|
-
async function
|
|
9603
|
-
return await
|
|
9604
|
+
async function Nf(e, t, n, r, s, i) {
|
|
9605
|
+
return await Xo(
|
|
9604
9606
|
e,
|
|
9605
9607
|
t,
|
|
9606
9608
|
n,
|
|
@@ -9609,19 +9611,19 @@ async function kf(e, t, n, r, s, i) {
|
|
|
9609
9611
|
i
|
|
9610
9612
|
);
|
|
9611
9613
|
}
|
|
9612
|
-
async function
|
|
9614
|
+
async function Cf(e, t, n, r) {
|
|
9613
9615
|
return await js([e], t, n, r);
|
|
9614
9616
|
}
|
|
9615
|
-
async function
|
|
9617
|
+
async function $f(e, t, n, r) {
|
|
9616
9618
|
return await js(e, t, n, r);
|
|
9617
9619
|
}
|
|
9618
|
-
const
|
|
9620
|
+
const Gf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9619
9621
|
__proto__: null,
|
|
9620
|
-
getInscribeFee:
|
|
9621
|
-
getInscribeMultipleFee:
|
|
9622
|
-
inscribe:
|
|
9623
|
-
inscribeMultiple:
|
|
9624
|
-
inscribeWithParent:
|
|
9622
|
+
getInscribeFee: Cf,
|
|
9623
|
+
getInscribeMultipleFee: $f,
|
|
9624
|
+
inscribe: Rf,
|
|
9625
|
+
inscribeMultiple: kf,
|
|
9626
|
+
inscribeWithParent: Nf
|
|
9625
9627
|
}, Symbol.toStringTag, { value: "Module" })), Lo = [
|
|
9626
9628
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
9627
9629
|
{
|
|
@@ -9780,7 +9782,7 @@ const Wf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
9780
9782
|
type: "function"
|
|
9781
9783
|
}
|
|
9782
9784
|
], Ao = "0xc54dd4581af2dbf18e4d90840226756e9d2b3cdb";
|
|
9783
|
-
async function
|
|
9785
|
+
async function Lf(e, t) {
|
|
9784
9786
|
const n = t.toUpperCase(), r = Qs("check_base_brc20_balance"), i = await ti(r, {
|
|
9785
9787
|
method: "POST",
|
|
9786
9788
|
headers: {
|
|
@@ -9798,7 +9800,7 @@ async function $f(e, t) {
|
|
|
9798
9800
|
ticker: i.result.ticker
|
|
9799
9801
|
};
|
|
9800
9802
|
}
|
|
9801
|
-
async function
|
|
9803
|
+
async function Af(e, t) {
|
|
9802
9804
|
const n = Qs("check_brc20_balance"), s = await ti(n, {
|
|
9803
9805
|
method: "POST",
|
|
9804
9806
|
headers: {
|
|
@@ -9811,16 +9813,16 @@ async function Lf(e, t) {
|
|
|
9811
9813
|
});
|
|
9812
9814
|
return BigInt(s.result);
|
|
9813
9815
|
}
|
|
9814
|
-
async function
|
|
9816
|
+
async function Pf(e, t) {
|
|
9815
9817
|
const n = S.from(t, "utf-8"), r = await ei(
|
|
9816
9818
|
Ao,
|
|
9817
9819
|
Lo,
|
|
9818
9820
|
"balanceOf",
|
|
9819
|
-
[n,
|
|
9821
|
+
[n, Jo(e)]
|
|
9820
9822
|
);
|
|
9821
9823
|
return BigInt(r);
|
|
9822
9824
|
}
|
|
9823
|
-
async function
|
|
9825
|
+
async function Ff(e) {
|
|
9824
9826
|
const t = S.from(e, "utf-8");
|
|
9825
9827
|
return `0x${(await ei(
|
|
9826
9828
|
Ao,
|
|
@@ -9829,17 +9831,17 @@ async function Pf(e) {
|
|
|
9829
9831
|
[t]
|
|
9830
9832
|
)).slice(-40)}`;
|
|
9831
9833
|
}
|
|
9832
|
-
const
|
|
9834
|
+
const Hf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9833
9835
|
__proto__: null,
|
|
9834
|
-
getBRC20ProgBalanceOfAddress:
|
|
9835
|
-
getBRC20ProgBalanceOfTicker:
|
|
9836
|
-
getBRC20ProgTokenAddressOfTicker:
|
|
9837
|
-
getBaseBRC20BalanceOfAddress:
|
|
9836
|
+
getBRC20ProgBalanceOfAddress: Af,
|
|
9837
|
+
getBRC20ProgBalanceOfTicker: Pf,
|
|
9838
|
+
getBRC20ProgTokenAddressOfTicker: Ff,
|
|
9839
|
+
getBaseBRC20BalanceOfAddress: Lf
|
|
9838
9840
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
9839
9841
|
export {
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9842
|
+
Mf as a,
|
|
9843
|
+
Wf as b,
|
|
9844
|
+
Hf as c,
|
|
9845
|
+
Gf as m,
|
|
9846
|
+
Df as s
|
|
9845
9847
|
};
|