@bestinslot/wallet-kit 0.13.3 → 0.13.5
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-p2-VUL2h.js → balances-CqYGF0ez.js} +463 -447
- package/dist/browser.js +2 -2
- package/dist/core.js +2 -2
- package/dist/node.js +2 -2
- package/dist/types/api/swap.d.ts +10 -6
- package/dist/types/core/bis_swap.d.ts +14 -5
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as yn, U as Ir, V as Do, X as Mo, Y as Wo, G as S, e as Wt, l as
|
|
2
|
-
async function
|
|
1
|
+
import { h as yn, U as Ir, V as Do, X as Mo, Y as Wo, G as S, e as Wt, l as Kr, Z as Ys, _ as Rr, O as ze, f as Zn, H as Ut, $ as Xe, a0 as z, a1 as ce, a2 as Ks, a3 as zs, a4 as Go, a5 as zr, a6 as Ft, a7 as me, a8 as $n, a9 as Yt, aa as Pn, ab as Xs, d as tn, D as bn, ac as Ho, ad as Xr, ae as Ln, af as Js, k as Pe, ag as Vo, ah as Zo, ai as Yo, aj as Ko, ak as zo, al as js, am as Xo, an as Qs, ao as ti, ap as ei, aq as ni, p as Jo } from "./mint-C_wN10-d.js";
|
|
2
|
+
async function Mf(e, t, n, r, s, i) {
|
|
3
3
|
const o = yn();
|
|
4
4
|
if (!o)
|
|
5
5
|
throw new Error("No wallet connected");
|
|
@@ -162,7 +162,7 @@ function oi(e) {
|
|
|
162
162
|
throw new Error("hex string expected, got " + typeof e);
|
|
163
163
|
return e === "" ? Nr : BigInt("0x" + e);
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function Kt(e) {
|
|
166
166
|
return oi(ln(e));
|
|
167
167
|
}
|
|
168
168
|
function ai(e) {
|
|
@@ -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 xr(e) {
|
|
221
221
|
const t = /* @__PURE__ */ new WeakMap();
|
|
222
222
|
return (n, ...r) => {
|
|
223
223
|
const s = t.get(n);
|
|
@@ -259,7 +259,7 @@ function aa(e, t) {
|
|
|
259
259
|
return $r(e, a, t), a;
|
|
260
260
|
}
|
|
261
261
|
function ca(e) {
|
|
262
|
-
const t =
|
|
262
|
+
const t = _n(e), n = gi(e), r = n(t, t.neg(t.ONE)), s = n(t, r), i = n(t, t.neg(r)), o = (e + ia) / hi;
|
|
263
263
|
return (a, c) => {
|
|
264
264
|
let u = a.pow(c, o), l = a.mul(u, r);
|
|
265
265
|
const f = a.mul(u, s), d = a.mul(u, i), p = a.eql(a.sqr(l), c), w = a.eql(a.sqr(f), c);
|
|
@@ -275,7 +275,7 @@ function gi(e) {
|
|
|
275
275
|
for (; t % ke === Ct; )
|
|
276
276
|
t /= ke, n++;
|
|
277
277
|
let r = ke;
|
|
278
|
-
const s =
|
|
278
|
+
const s = _n(e);
|
|
279
279
|
for (; Mn(s, r) === 1; )
|
|
280
280
|
if (r++ > 1e3)
|
|
281
281
|
throw new Error("Cannot find square root: probably non-prime P");
|
|
@@ -332,7 +332,7 @@ function yi(e) {
|
|
|
332
332
|
}, n = la.reduce((r, s) => (r[s] = "function", r), t);
|
|
333
333
|
return Cr(e, n), e;
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function Kn(e, t, n) {
|
|
336
336
|
if (n < Ct)
|
|
337
337
|
throw new Error("invalid exponent, negatives unsupported");
|
|
338
338
|
if (n === Ct)
|
|
@@ -417,7 +417,7 @@ class da {
|
|
|
417
417
|
return Pt(t * n, this.ORDER);
|
|
418
418
|
}
|
|
419
419
|
pow(t, n) {
|
|
420
|
-
return
|
|
420
|
+
return Kn(this, t, n);
|
|
421
421
|
}
|
|
422
422
|
div(t, n) {
|
|
423
423
|
return Pt(t * Qr(n, this.ORDER), this.ORDER);
|
|
@@ -455,7 +455,7 @@ class da {
|
|
|
455
455
|
}
|
|
456
456
|
if (t.length !== s)
|
|
457
457
|
throw new Error("Field.fromBytes: expected " + s + " bytes, got " + t.length);
|
|
458
|
-
let c = i ? ai(t) :
|
|
458
|
+
let c = i ? ai(t) : Kt(t);
|
|
459
459
|
if (a && (c = Pt(c, o)), !n && !this.isValid(c))
|
|
460
460
|
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
461
461
|
return c;
|
|
@@ -470,7 +470,7 @@ class da {
|
|
|
470
470
|
return r ? n : t;
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
function
|
|
473
|
+
function _n(e, t = {}) {
|
|
474
474
|
return new da(e, t);
|
|
475
475
|
}
|
|
476
476
|
function bi(e) {
|
|
@@ -483,12 +483,12 @@ function mi(e) {
|
|
|
483
483
|
const t = bi(e);
|
|
484
484
|
return t + Math.ceil(t / 2);
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function _i(e, t, n = !1) {
|
|
487
487
|
ft(e);
|
|
488
488
|
const r = e.length, s = bi(t), i = mi(t);
|
|
489
489
|
if (r < 16 || r < i || r > 1024)
|
|
490
490
|
throw new Error("expected " + i + "-1024 bytes of input, got " + r);
|
|
491
|
-
const o = n ? ai(e) :
|
|
491
|
+
const o = n ? ai(e) : Kt(e), a = Pt(o, t - Tt) + Tt;
|
|
492
492
|
return n ? ci(a, s) : mt(a, s);
|
|
493
493
|
}
|
|
494
494
|
function pa(e, t, n) {
|
|
@@ -682,7 +682,7 @@ class ba extends ya {
|
|
|
682
682
|
super(32);
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
|
-
const
|
|
685
|
+
const xi = /* @__PURE__ */ ta(
|
|
686
686
|
() => new ba(),
|
|
687
687
|
/* @__PURE__ */ ea(1)
|
|
688
688
|
);
|
|
@@ -813,7 +813,7 @@ class ma {
|
|
|
813
813
|
return pr(t) !== 1;
|
|
814
814
|
}
|
|
815
815
|
}
|
|
816
|
-
function
|
|
816
|
+
function _a(e, t, n, r) {
|
|
817
817
|
let s = t, i = e.ZERO, o = e.ZERO;
|
|
818
818
|
for (; n > Qe || r > Qe; )
|
|
819
819
|
n & Ne && (i = i.add(s)), r & Ne && (o = o.add(s)), s = s.double(), n >>= Ne, r >>= Ne;
|
|
@@ -825,9 +825,9 @@ function ns(e, t, n) {
|
|
|
825
825
|
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
826
826
|
return yi(t), t;
|
|
827
827
|
} else
|
|
828
|
-
return
|
|
828
|
+
return _n(e, { isLE: n });
|
|
829
829
|
}
|
|
830
|
-
function
|
|
830
|
+
function xa(e, t, n = {}, r) {
|
|
831
831
|
if (r === void 0 && (r = e === "edwards"), !t || typeof t != "object")
|
|
832
832
|
throw new Error(`expected valid ${e} CURVE object`);
|
|
833
833
|
for (const c of ["p", "n", "h"]) {
|
|
@@ -841,7 +841,7 @@ function _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 Ea =
|
|
844
|
+
const Ea = Kt;
|
|
845
845
|
function we(e, t) {
|
|
846
846
|
if (je(e), je(t), e < 0 || e >= 1 << 8 * t)
|
|
847
847
|
throw new Error("invalid I2OSP input: " + e);
|
|
@@ -1021,7 +1021,7 @@ function Ta(e, t, n) {
|
|
|
1021
1021
|
}
|
|
1022
1022
|
const Ce = BigInt(0), It = BigInt(1), re = BigInt(2), He = BigInt(3), Er = BigInt(4);
|
|
1023
1023
|
function Ti(e, t = {}) {
|
|
1024
|
-
const n =
|
|
1024
|
+
const n = xa("weierstrass", e, t), { Fp: r, Fn: s } = n;
|
|
1025
1025
|
let i = n.CURVE;
|
|
1026
1026
|
const { h: o, n: a } = i;
|
|
1027
1027
|
Cr(t, {}, {
|
|
@@ -1040,9 +1040,9 @@ function Ti(e, t = {}) {
|
|
|
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,
|
|
1043
|
+
function f(U, y, x) {
|
|
1044
1044
|
const { x: B, y: R } = y.toAffine(), P = r.toBytes(B);
|
|
1045
|
-
if (jr(
|
|
1045
|
+
if (jr(x, "isCompressed"), x) {
|
|
1046
1046
|
l();
|
|
1047
1047
|
const $ = !r.isOdd(R);
|
|
1048
1048
|
return ht(Ia($), P);
|
|
@@ -1051,7 +1051,7 @@ function Ti(e, t = {}) {
|
|
|
1051
1051
|
}
|
|
1052
1052
|
function d(U) {
|
|
1053
1053
|
ft(U, void 0, "Point");
|
|
1054
|
-
const { publicKey: y, publicKeyUncompressed:
|
|
1054
|
+
const { publicKey: y, publicKeyUncompressed: x } = u, B = U.length, R = U[0], P = U.subarray(1);
|
|
1055
1055
|
if (B === y && (R === 2 || R === 3)) {
|
|
1056
1056
|
const $ = r.fromBytes(P);
|
|
1057
1057
|
if (!r.isValid($))
|
|
@@ -1067,35 +1067,35 @@ function Ti(e, t = {}) {
|
|
|
1067
1067
|
l();
|
|
1068
1068
|
const W = r.isOdd(k);
|
|
1069
1069
|
return (R & 1) === 1 !== W && (k = r.neg(k)), { x: $, y: k };
|
|
1070
|
-
} else if (B ===
|
|
1070
|
+
} else if (B === x && R === 4) {
|
|
1071
1071
|
const $ = r.BYTES, q = r.fromBytes(P.subarray(0, $)), k = r.fromBytes(P.subarray($, $ * 2));
|
|
1072
1072
|
if (!g(q, k))
|
|
1073
1073
|
throw new Error("bad point: is not on curve");
|
|
1074
1074
|
return { x: q, y: k };
|
|
1075
1075
|
} else
|
|
1076
|
-
throw new Error(`bad point: got length ${B}, expected compressed=${y} or uncompressed=${
|
|
1076
|
+
throw new Error(`bad point: got length ${B}, expected compressed=${y} or uncompressed=${x}`);
|
|
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), x = r.mul(y, U);
|
|
1081
|
+
return r.add(r.add(x, r.mul(U, i.a)), i.b);
|
|
1082
1082
|
}
|
|
1083
1083
|
function g(U, y) {
|
|
1084
|
-
const
|
|
1085
|
-
return r.eql(
|
|
1084
|
+
const x = r.sqr(y), B = h(U);
|
|
1085
|
+
return r.eql(x, B);
|
|
1086
1086
|
}
|
|
1087
1087
|
if (!g(i.Gx, i.Gy))
|
|
1088
1088
|
throw new Error("bad curve params: generator point");
|
|
1089
1089
|
const b = r.mul(r.pow(i.a, He), Er), v = r.mul(r.sqr(i.b), BigInt(27));
|
|
1090
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, x = !1) {
|
|
1093
|
+
if (!r.isValid(y) || x && 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 _))
|
|
1099
1099
|
throw new Error("Weierstrass Point expected");
|
|
1100
1100
|
}
|
|
1101
1101
|
function M(U) {
|
|
@@ -1103,41 +1103,41 @@ function Ti(e, t = {}) {
|
|
|
1103
1103
|
throw new Error("no endo");
|
|
1104
1104
|
return Ta(U, c.basises, s.ORDER);
|
|
1105
1105
|
}
|
|
1106
|
-
const A =
|
|
1107
|
-
const { X:
|
|
1106
|
+
const A = xr((U, y) => {
|
|
1107
|
+
const { X: x, Y: B, Z: R } = U;
|
|
1108
1108
|
if (r.eql(R, r.ONE))
|
|
1109
|
-
return { x
|
|
1109
|
+
return { x, y: B };
|
|
1110
1110
|
const P = U.is0();
|
|
1111
1111
|
y == null && (y = P ? r.ONE : r.inv(R));
|
|
1112
|
-
const $ = r.mul(
|
|
1112
|
+
const $ = r.mul(x, y), q = r.mul(B, y), k = r.mul(R, y);
|
|
1113
1113
|
if (P)
|
|
1114
1114
|
return { x: r.ZERO, y: r.ZERO };
|
|
1115
1115
|
if (!r.eql(k, r.ONE))
|
|
1116
1116
|
throw new Error("invZ was invalid");
|
|
1117
1117
|
return { x: $, y: q };
|
|
1118
|
-
}), C =
|
|
1118
|
+
}), C = xr((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: x } = U.toAffine();
|
|
1125
|
+
if (!r.isValid(y) || !r.isValid(x))
|
|
1126
1126
|
throw new Error("bad point: x or y not field elements");
|
|
1127
|
-
if (!g(y,
|
|
1127
|
+
if (!g(y, x))
|
|
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 I(U, y,
|
|
1134
|
-
return
|
|
1133
|
+
function I(U, y, x, B, R) {
|
|
1134
|
+
return x = new _(r.mul(x.X, U), x.Y, x.Z), y = Wn(B, y), x = Wn(R, x), y.add(x);
|
|
1135
1135
|
}
|
|
1136
|
-
class
|
|
1136
|
+
class _ {
|
|
1137
1137
|
// base / generator point
|
|
1138
|
-
static BASE = new
|
|
1138
|
+
static BASE = new _(i.Gx, i.Gy, r.ONE);
|
|
1139
1139
|
// zero / infinity / identity point
|
|
1140
|
-
static ZERO = new
|
|
1140
|
+
static ZERO = new _(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 Ti(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, x, B) {
|
|
1151
|
+
this.X = O("x", y), this.Y = O("y", x, !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
|
|
1159
|
-
if (!y || !r.isValid(
|
|
1158
|
+
const { x, y: B } = y || {};
|
|
1159
|
+
if (!y || !r.isValid(x) || !r.isValid(B))
|
|
1160
1160
|
throw new Error("invalid affine point");
|
|
1161
|
-
if (y instanceof
|
|
1161
|
+
if (y instanceof _)
|
|
1162
1162
|
throw new Error("projective point not allowed");
|
|
1163
|
-
return r.is0(
|
|
1163
|
+
return r.is0(x) && r.is0(B) ? _.ZERO : new _(x, B, r.ONE);
|
|
1164
1164
|
}
|
|
1165
1165
|
static fromBytes(y) {
|
|
1166
|
-
const
|
|
1167
|
-
return
|
|
1166
|
+
const x = _.fromAffine(w(ft(y, void 0, "point")));
|
|
1167
|
+
return x.assertValidity(), x;
|
|
1168
1168
|
}
|
|
1169
1169
|
static fromHex(y) {
|
|
1170
|
-
return
|
|
1170
|
+
return _.fromBytes(Un(y));
|
|
1171
1171
|
}
|
|
1172
1172
|
get x() {
|
|
1173
1173
|
return this.toAffine().x;
|
|
@@ -1181,8 +1181,8 @@ function Ti(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 H.createCache(this, y),
|
|
1184
|
+
precompute(y = 8, x = !0) {
|
|
1185
|
+
return H.createCache(this, y), x || this.multiply(He), this;
|
|
1186
1186
|
}
|
|
1187
1187
|
// TODO: return `this`
|
|
1188
1188
|
/** A point on curve is valid if it conforms to equation. */
|
|
@@ -1198,21 +1198,21 @@ function Ti(e, t = {}) {
|
|
|
1198
1198
|
/** Compare one point to another. */
|
|
1199
1199
|
equals(y) {
|
|
1200
1200
|
F(y);
|
|
1201
|
-
const { X:
|
|
1201
|
+
const { X: x, Y: B, Z: R } = this, { X: P, Y: $, Z: q } = y, k = r.eql(r.mul(x, q), r.mul(P, R)), W = r.eql(r.mul(B, q), r.mul($, R));
|
|
1202
1202
|
return k && W;
|
|
1203
1203
|
}
|
|
1204
1204
|
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
1205
1205
|
negate() {
|
|
1206
|
-
return new
|
|
1206
|
+
return new _(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:
|
|
1213
|
+
const { a: y, b: x } = i, B = r.mul(x, He), { X: R, Y: P, Z: $ } = this;
|
|
1214
1214
|
let q = r.ZERO, k = r.ZERO, W = r.ZERO, Z = r.mul(R, R), ct = r.mul(P, P), j = r.mul($, $), G = r.mul(R, P);
|
|
1215
|
-
return G = r.add(G, G), W = r.mul(R, $), W = r.add(W, W), q = r.mul(y, W), k = r.mul(B, j), k = r.add(q, k), q = r.sub(ct, k), k = r.add(ct, k), k = r.mul(q, k), q = r.mul(G, q), W = r.mul(B, W), j = r.mul(y, j), G = r.sub(Z, j), G = r.mul(y, G), G = r.add(G, W), W = r.add(Z, Z), Z = r.add(W, Z), Z = r.add(Z, j), Z = r.mul(Z, G), k = r.add(k, Z), j = r.mul(P, $), j = r.add(j, j), Z = r.mul(j, G), q = r.sub(q, Z), W = r.mul(j, ct), W = r.add(W, W), W = r.add(W, W), new
|
|
1215
|
+
return G = r.add(G, G), W = r.mul(R, $), W = r.add(W, W), q = r.mul(y, W), k = r.mul(B, j), k = r.add(q, k), q = r.sub(ct, k), k = r.add(ct, k), k = r.mul(q, k), q = r.mul(G, q), W = r.mul(B, W), j = r.mul(y, j), G = r.sub(Z, j), G = r.mul(y, G), G = r.add(G, W), W = r.add(Z, Z), Z = r.add(W, Z), Z = r.add(Z, j), Z = r.mul(Z, G), k = r.add(k, Z), j = r.mul(P, $), j = r.add(j, j), Z = r.mul(j, G), q = r.sub(q, Z), W = r.mul(j, ct), W = r.add(W, W), W = r.add(W, W), new _(q, k, W);
|
|
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 Ti(e, t = {}) {
|
|
|
1220
1220
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
1221
1221
|
add(y) {
|
|
1222
1222
|
F(y);
|
|
1223
|
-
const { X:
|
|
1223
|
+
const { X: x, Y: B, Z: R } = this, { X: P, Y: $, Z: q } = y;
|
|
1224
1224
|
let k = r.ZERO, W = r.ZERO, Z = r.ZERO;
|
|
1225
1225
|
const ct = i.a, j = r.mul(i.b, He);
|
|
1226
|
-
let G = r.mul(
|
|
1227
|
-
|
|
1226
|
+
let G = r.mul(x, P), ut = r.mul(B, $), gt = r.mul(R, q), xt = r.add(x, B), Q = r.add(P, $);
|
|
1227
|
+
xt = r.mul(xt, Q), Q = r.add(G, ut), xt = r.sub(xt, Q), Q = r.add(x, R);
|
|
1228
1228
|
let rt = r.add(P, q);
|
|
1229
|
-
return Q = r.mul(Q, rt), rt = r.add(G, gt), Q = r.sub(Q, rt), rt = r.add(B, R), k = r.add($, q), rt = r.mul(rt, k), k = r.add(ut, gt), rt = r.sub(rt, k), Z = r.mul(ct, Q), k = r.mul(j, gt), Z = r.add(k, Z), k = r.sub(ut, Z), Z = r.add(ut, Z), W = r.mul(k, Z), ut = r.add(G, G), ut = r.add(ut, G), gt = r.mul(ct, gt), Q = r.mul(j, Q), ut = r.add(ut, gt), gt = r.sub(G, gt), gt = r.mul(ct, gt), Q = r.add(Q, gt), G = r.mul(ut, Q), W = r.add(W, G), G = r.mul(rt, Q), k = r.mul(
|
|
1229
|
+
return Q = r.mul(Q, rt), rt = r.add(G, gt), Q = r.sub(Q, rt), rt = r.add(B, R), k = r.add($, q), rt = r.mul(rt, k), k = r.add(ut, gt), rt = r.sub(rt, k), Z = r.mul(ct, Q), k = r.mul(j, gt), Z = r.add(k, Z), k = r.sub(ut, Z), Z = r.add(ut, Z), W = r.mul(k, Z), ut = r.add(G, G), ut = r.add(ut, G), gt = r.mul(ct, gt), Q = r.mul(j, Q), ut = r.add(ut, gt), gt = r.sub(G, gt), gt = r.mul(ct, gt), Q = r.add(Q, gt), G = r.mul(ut, Q), W = r.add(W, G), G = r.mul(rt, Q), k = r.mul(xt, k), k = r.sub(k, G), G = r.mul(xt, ut), Z = r.mul(rt, Z), Z = r.add(Z, G), new _(k, W, 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(_.ZERO);
|
|
1236
1236
|
}
|
|
1237
1237
|
/**
|
|
1238
1238
|
* Constant time multiplication.
|
|
@@ -1244,19 +1244,19 @@ function Ti(e, t = {}) {
|
|
|
1244
1244
|
* @returns New point
|
|
1245
1245
|
*/
|
|
1246
1246
|
multiply(y) {
|
|
1247
|
-
const { endo:
|
|
1247
|
+
const { endo: x } = t;
|
|
1248
1248
|
if (!s.isValidNot0(y))
|
|
1249
1249
|
throw new Error("invalid scalar: out of range");
|
|
1250
1250
|
let B, R;
|
|
1251
|
-
const P = ($) => H.cached(this, $, (q) => Gn(
|
|
1252
|
-
if (
|
|
1251
|
+
const P = ($) => H.cached(this, $, (q) => Gn(_, q));
|
|
1252
|
+
if (x) {
|
|
1253
1253
|
const { k1neg: $, k1: q, k2neg: k, k2: W } = M(y), { p: Z, f: ct } = P(q), { p: j, f: G } = P(W);
|
|
1254
|
-
R = ct.add(G), B = I(
|
|
1254
|
+
R = ct.add(G), B = I(x.beta, Z, j, $, k);
|
|
1255
1255
|
} else {
|
|
1256
1256
|
const { p: $, f: q } = P(y);
|
|
1257
1257
|
B = $, R = q;
|
|
1258
1258
|
}
|
|
1259
|
-
return Gn(
|
|
1259
|
+
return Gn(_, [B, R])[0];
|
|
1260
1260
|
}
|
|
1261
1261
|
/**
|
|
1262
1262
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -1264,18 +1264,18 @@ function Ti(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: x } = t, B = this;
|
|
1268
1268
|
if (!s.isValid(y))
|
|
1269
1269
|
throw new Error("invalid scalar: out of range");
|
|
1270
1270
|
if (y === Ce || B.is0())
|
|
1271
|
-
return
|
|
1271
|
+
return _.ZERO;
|
|
1272
1272
|
if (y === It)
|
|
1273
1273
|
return B;
|
|
1274
1274
|
if (H.hasCache(this))
|
|
1275
1275
|
return this.multiply(y);
|
|
1276
|
-
if (
|
|
1277
|
-
const { k1neg: R, k1: P, k2neg: $, k2: q } = M(y), { p1: k, p2: W } =
|
|
1278
|
-
return I(
|
|
1276
|
+
if (x) {
|
|
1277
|
+
const { k1neg: R, k1: P, k2neg: $, k2: q } = M(y), { p1: k, p2: W } = _a(_, B, P, q);
|
|
1278
|
+
return I(x.beta, k, W, R, $);
|
|
1279
1279
|
} else
|
|
1280
1280
|
return H.unsafe(B, y);
|
|
1281
1281
|
}
|
|
@@ -1292,17 +1292,17 @@ function Ti(e, t = {}) {
|
|
|
1292
1292
|
*/
|
|
1293
1293
|
isTorsionFree() {
|
|
1294
1294
|
const { isTorsionFree: y } = t;
|
|
1295
|
-
return o === It ? !0 : y ? y(
|
|
1295
|
+
return o === It ? !0 : y ? y(_, this) : H.unsafe(this, a).is0();
|
|
1296
1296
|
}
|
|
1297
1297
|
clearCofactor() {
|
|
1298
1298
|
const { clearCofactor: y } = t;
|
|
1299
|
-
return o === It ? this : y ? y(
|
|
1299
|
+
return o === It ? this : y ? y(_, 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(_, this, y);
|
|
1306
1306
|
}
|
|
1307
1307
|
toHex(y = !0) {
|
|
1308
1308
|
return ln(this.toBytes(y));
|
|
@@ -1311,8 +1311,8 @@ function Ti(e, t = {}) {
|
|
|
1311
1311
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
1312
1312
|
}
|
|
1313
1313
|
}
|
|
1314
|
-
const D = s.BITS, H = new ma(
|
|
1315
|
-
return
|
|
1314
|
+
const D = s.BITS, H = new ma(_, t.endo ? Math.ceil(D / 2) : D);
|
|
1315
|
+
return _.BASE.precompute(8), _;
|
|
1316
1316
|
}
|
|
1317
1317
|
function Ia(e) {
|
|
1318
1318
|
return Uint8Array.of(e ? 2 : 3);
|
|
@@ -1336,8 +1336,8 @@ function Ra(e, t) {
|
|
|
1336
1336
|
let C = A - re;
|
|
1337
1337
|
C = re << C - It;
|
|
1338
1338
|
let I = e.pow(F, C);
|
|
1339
|
-
const
|
|
1340
|
-
b = e.mul(v, g), g = e.mul(g, g), I = e.mul(F, g), v = e.cmov(b, v,
|
|
1339
|
+
const _ = 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, _), F = e.cmov(I, F, _);
|
|
1341
1341
|
}
|
|
1342
1342
|
return { isValid: M, value: v };
|
|
1343
1343
|
};
|
|
@@ -1399,57 +1399,57 @@ 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 = (A, C, I,
|
|
1402
|
+
l = (A, C, I, _, D, H) => o.mul014(_, A, i.mul(C, D), i.mul(I, H));
|
|
1403
1403
|
else if (a === "divisive")
|
|
1404
|
-
l = (A, C, I,
|
|
1404
|
+
l = (A, C, I, _, D, H) => o.mul034(_, i.mul(I, H), i.mul(C, D), 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(A, C, I,
|
|
1409
|
-
const D = i.sqr(I), H = i.sqr(
|
|
1410
|
-
return A.push([B, R, P]), C = i.mul(i.mul(i.mul(i.sub(D, y), C), I), f), I = i.sub(i.sqr(i.mul(i.add(D, y), f)), i.mul(i.sqr(U), Ve)),
|
|
1411
|
-
}
|
|
1412
|
-
function p(A, C, I,
|
|
1413
|
-
const U = i.sub(I, i.mul(H,
|
|
1414
|
-
A.push([
|
|
1415
|
-
const P = i.sqr(y), $ = i.mul(P, y), q = i.mul(P, C), k = i.add(i.sub($, i.mul(q, is)), i.mul(i.sqr(U),
|
|
1416
|
-
return C = i.mul(y, k), I = i.sub(i.mul(i.sub(q, k), U), i.mul($, I)),
|
|
1417
|
-
}
|
|
1418
|
-
const w = Ca(c), h =
|
|
1419
|
-
const C = A, { x: I, y:
|
|
1420
|
-
let y = D,
|
|
1408
|
+
function d(A, C, I, _) {
|
|
1409
|
+
const D = i.sqr(I), H = i.sqr(_), U = i.mulByB(i.mul(H, Ve)), y = i.mul(U, Ve), x = i.sub(i.sub(i.sqr(i.add(I, _)), H), D), B = i.sub(U, D), R = i.mul(i.sqr(C), Ve), P = i.neg(x);
|
|
1410
|
+
return A.push([B, R, P]), C = i.mul(i.mul(i.mul(i.sub(D, y), C), I), f), I = i.sub(i.sqr(i.mul(i.add(D, y), f)), i.mul(i.sqr(U), Ve)), _ = i.mul(D, x), { Rx: C, Ry: I, Rz: _ };
|
|
1411
|
+
}
|
|
1412
|
+
function p(A, C, I, _, D, H) {
|
|
1413
|
+
const U = i.sub(I, i.mul(H, _)), y = i.sub(C, i.mul(D, _)), x = i.sub(i.mul(U, D), i.mul(y, H)), B = i.neg(U), R = y;
|
|
1414
|
+
A.push([x, B, R]);
|
|
1415
|
+
const P = i.sqr(y), $ = i.mul(P, y), q = i.mul(P, C), k = i.add(i.sub($, i.mul(q, is)), i.mul(i.sqr(U), _));
|
|
1416
|
+
return C = i.mul(y, k), I = i.sub(i.mul(i.sub(q, k), U), i.mul($, I)), _ = i.mul(_, $), { Rx: C, Ry: I, Rz: _ };
|
|
1417
|
+
}
|
|
1418
|
+
const w = Ca(c), h = xr((A) => {
|
|
1419
|
+
const C = A, { x: I, y: _ } = C.toAffine(), D = I, H = _, U = i.neg(_);
|
|
1420
|
+
let y = D, x = H, B = i.ONE;
|
|
1421
1421
|
const R = [];
|
|
1422
1422
|
for (const P of w) {
|
|
1423
1423
|
const $ = [];
|
|
1424
|
-
({ Rx: y, Ry:
|
|
1424
|
+
({ Rx: y, Ry: x, Rz: B } = d($, y, x, B)), P && ({ Rx: y, Ry: x, Rz: B } = p($, y, x, B, D, P === -1 ? U : H)), R.push($);
|
|
1425
1425
|
}
|
|
1426
1426
|
if (u) {
|
|
1427
1427
|
const P = R[R.length - 1];
|
|
1428
|
-
u(y,
|
|
1428
|
+
u(y, x, B, D, H, p.bind(null, P));
|
|
1429
1429
|
}
|
|
1430
1430
|
return R;
|
|
1431
1431
|
});
|
|
1432
1432
|
function g(A, C = !1) {
|
|
1433
1433
|
let I = o.ONE;
|
|
1434
1434
|
if (A.length) {
|
|
1435
|
-
const
|
|
1436
|
-
for (let D = 0; D <
|
|
1435
|
+
const _ = A[0][0].length;
|
|
1436
|
+
for (let D = 0; D < _; D++) {
|
|
1437
1437
|
I = o.sqr(I);
|
|
1438
1438
|
for (const [H, U, y] of A)
|
|
1439
|
-
for (const [
|
|
1440
|
-
I = l(
|
|
1439
|
+
for (const [x, B, R] of H[D])
|
|
1440
|
+
I = l(x, B, R, I, U, y);
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
1443
|
return I = o.conjugate(I), C ? o.finalExponentiate(I) : I;
|
|
1444
1444
|
}
|
|
1445
1445
|
function b(A, C = !0) {
|
|
1446
1446
|
const I = [];
|
|
1447
|
-
Gn(t, A.map(({ g1:
|
|
1448
|
-
for (const { g1:
|
|
1449
|
-
if (
|
|
1447
|
+
Gn(t, A.map(({ g1: _ }) => _)), Gn(n, A.map(({ g2: _ }) => _));
|
|
1448
|
+
for (const { g1: _, g2: D } of A) {
|
|
1449
|
+
if (_.is0() || D.is0())
|
|
1450
1450
|
throw new Error("pairing is not available for ZERO point");
|
|
1451
|
-
|
|
1452
|
-
const H =
|
|
1451
|
+
_.assertValidity(), D.assertValidity();
|
|
1452
|
+
const H = _.toAffine();
|
|
1453
1453
|
I.push([h(D), H.x, H.y]);
|
|
1454
1454
|
}
|
|
1455
1455
|
return g(I, C);
|
|
@@ -1469,7 +1469,7 @@ function $a(e, t, n, r) {
|
|
|
1469
1469
|
pairing: v,
|
|
1470
1470
|
pairingBatch: b,
|
|
1471
1471
|
calcPairingPrecomputes: h,
|
|
1472
|
-
randomSecretKey: (A = F(O.seed)) => (ft(A, O.seed, "seed"),
|
|
1472
|
+
randomSecretKey: (A = F(O.seed)) => (ft(A, O.seed, "seed"), _i(A, s.ORDER))
|
|
1473
1473
|
};
|
|
1474
1474
|
}
|
|
1475
1475
|
function os(e, t, n, r, s, i) {
|
|
@@ -1537,15 +1537,15 @@ function os(e, t, n, r, s, i) {
|
|
|
1537
1537
|
wr(g);
|
|
1538
1538
|
const b = d(h), v = g.map((C) => C.message), O = g.map((C) => f(C.publicKey)), F = /* @__PURE__ */ new Map();
|
|
1539
1539
|
for (let C = 0; C < O.length; C++) {
|
|
1540
|
-
const I = O[C],
|
|
1541
|
-
let D = F.get(
|
|
1542
|
-
D === void 0 && (D = [], F.set(
|
|
1540
|
+
const I = O[C], _ = v[C];
|
|
1541
|
+
let D = F.get(_);
|
|
1542
|
+
D === void 0 && (D = [], F.set(_, D)), D.push(I);
|
|
1543
1543
|
}
|
|
1544
1544
|
const M = [], A = t.BASE;
|
|
1545
1545
|
try {
|
|
1546
1546
|
for (const [C, I] of F) {
|
|
1547
|
-
const
|
|
1548
|
-
M.push(w(
|
|
1547
|
+
const _ = I.reduce((D, H) => D.add(H));
|
|
1548
|
+
M.push(w(_, C));
|
|
1549
1549
|
}
|
|
1550
1550
|
return M.push(w(A.negate(), b)), a.eql(c(M), a.ONE);
|
|
1551
1551
|
} catch {
|
|
@@ -1691,7 +1691,7 @@ class Ua {
|
|
|
1691
1691
|
return { c0: this.Fp.neg(t), c1: this.Fp.neg(n) };
|
|
1692
1692
|
}
|
|
1693
1693
|
pow(t, n) {
|
|
1694
|
-
return
|
|
1694
|
+
return Kn(this, t, n);
|
|
1695
1695
|
}
|
|
1696
1696
|
invertBatch(t) {
|
|
1697
1697
|
return Fe(this, t);
|
|
@@ -1906,7 +1906,7 @@ class qa {
|
|
|
1906
1906
|
return this.mul(t, typeof n == "bigint" ? s.inv(s.create(n)) : this.inv(n));
|
|
1907
1907
|
}
|
|
1908
1908
|
pow(t, n) {
|
|
1909
|
-
return
|
|
1909
|
+
return Kn(this, t, n);
|
|
1910
1910
|
}
|
|
1911
1911
|
invertBatch(t) {
|
|
1912
1912
|
return Fe(this, t);
|
|
@@ -2043,7 +2043,7 @@ class Da {
|
|
|
2043
2043
|
return this.mul(t, typeof n == "bigint" ? i.inv(i.create(n)) : this.inv(n));
|
|
2044
2044
|
}
|
|
2045
2045
|
pow(t, n) {
|
|
2046
|
-
return
|
|
2046
|
+
return Kn(this, t, n);
|
|
2047
2047
|
}
|
|
2048
2048
|
invertBatch(t) {
|
|
2049
2049
|
return Fe(this, t);
|
|
@@ -2210,18 +2210,18 @@ class Da {
|
|
|
2210
2210
|
}
|
|
2211
2211
|
}
|
|
2212
2212
|
function Ma(e) {
|
|
2213
|
-
const t =
|
|
2213
|
+
const t = _n(e.ORDER), n = new Ua(t, e), r = new qa(n), s = new Da(r, e);
|
|
2214
2214
|
return { Fp: t, Fp2: n, Fp6: r, Fp12: s };
|
|
2215
2215
|
}
|
|
2216
|
-
const
|
|
2216
|
+
const _t = BigInt(0), Hn = BigInt(1), qt = BigInt(2), zn = BigInt(3), fn = BigInt(4), _e = BigInt("0xd201000000010000"), Wa = Dn(_e), en = {
|
|
2217
2217
|
p: BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),
|
|
2218
2218
|
n: BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"),
|
|
2219
2219
|
h: BigInt("0x396c8c005555e1568c00aaab0000aaab"),
|
|
2220
|
-
a:
|
|
2220
|
+
a: _t,
|
|
2221
2221
|
b: fn,
|
|
2222
2222
|
Gx: BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),
|
|
2223
2223
|
Gy: BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1")
|
|
2224
|
-
}, Pr =
|
|
2224
|
+
}, Pr = _n(en.n, {
|
|
2225
2225
|
modFromBytes: !0
|
|
2226
2226
|
}), { Fp: N, Fp2: V, Fp6: Ga, Fp12: Y } = Ma({
|
|
2227
2227
|
ORDER: en.p,
|
|
@@ -2234,7 +2234,7 @@ const xt = BigInt(0), Hn = BigInt(1), qt = BigInt(2), Kn = BigInt(3), fn = BigIn
|
|
|
2234
2234
|
return { c0: N.sub(n, r), c1: N.add(n, r) };
|
|
2235
2235
|
},
|
|
2236
2236
|
Fp12finalExponentiate: (e) => {
|
|
2237
|
-
const t =
|
|
2237
|
+
const t = _e, n = Y.div(Y.frobeniusMap(e, 6), e), r = Y.mul(Y.frobeniusMap(n, 2), n), s = Y.conjugate(Y._cyclotomicExp(r, t)), i = Y.mul(Y.conjugate(Y._cyclotomicSquare(r)), s), o = Y.conjugate(Y._cyclotomicExp(i, t)), a = Y.conjugate(Y._cyclotomicExp(o, t)), c = Y.mul(Y.conjugate(Y._cyclotomicExp(a, t)), Y._cyclotomicSquare(s)), u = Y.conjugate(Y._cyclotomicExp(c, t)), l = Y.frobeniusMap(Y.mul(s, a), 2), f = Y.frobeniusMap(Y.mul(o, r), 3), d = Y.frobeniusMap(Y.mul(c, Y.conjugate(r)), 1), p = Y.mul(Y.mul(u, Y.conjugate(i)), r);
|
|
2238
2238
|
return Y.mul(Y.mul(Y.mul(l, f), d), p);
|
|
2239
2239
|
}
|
|
2240
2240
|
}), { G2psi: ls, G2psi2: Ha } = Fa(N, V, V.div(V.ONE, V.NONRESIDUE)), gr = Object.freeze({
|
|
@@ -2244,7 +2244,7 @@ const xt = BigInt(0), Hn = BigInt(1), qt = BigInt(2), Kn = BigInt(3), fn = BigIn
|
|
|
2244
2244
|
m: 2,
|
|
2245
2245
|
k: 128,
|
|
2246
2246
|
expand: "xmd",
|
|
2247
|
-
hash:
|
|
2247
|
+
hash: xi
|
|
2248
2248
|
}), Fr = {
|
|
2249
2249
|
p: V.ORDER,
|
|
2250
2250
|
n: en.n,
|
|
@@ -2259,13 +2259,13 @@ const xt = BigInt(0), Hn = BigInt(1), qt = BigInt(2), Kn = BigInt(3), fn = BigIn
|
|
|
2259
2259
|
BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),
|
|
2260
2260
|
BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")
|
|
2261
2261
|
])
|
|
2262
|
-
}, Xn =
|
|
2262
|
+
}, Xn = xn(N.toBytes(_t), { infinity: !0, compressed: !0 });
|
|
2263
2263
|
function Jn(e) {
|
|
2264
2264
|
e = ui(e);
|
|
2265
2265
|
const t = e[0] & 224, n = !!(t >> 7 & 1), r = !!(t >> 6 & 1), s = !!(t >> 5 & 1);
|
|
2266
2266
|
return e[0] &= 31, { compressed: n, infinity: r, sort: s, value: e };
|
|
2267
2267
|
}
|
|
2268
|
-
function
|
|
2268
|
+
function xn(e, t) {
|
|
2269
2269
|
if (e[0] & 224)
|
|
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;
|
|
@@ -2276,7 +2276,7 @@ function Va(e, t, n) {
|
|
|
2276
2276
|
if (i)
|
|
2277
2277
|
return Xn.slice();
|
|
2278
2278
|
const c = !!(a * qt / s);
|
|
2279
|
-
return
|
|
2279
|
+
return xn(mt(o, r), { compressed: !0, sort: c });
|
|
2280
2280
|
} else
|
|
2281
2281
|
return i ? ht(Uint8Array.of(64), new Uint8Array(2 * r - 1)) : ht(mt(o, r), mt(a, r));
|
|
2282
2282
|
}
|
|
@@ -2286,26 +2286,26 @@ function yr(e) {
|
|
|
2286
2286
|
if (e.is0())
|
|
2287
2287
|
return Xn.slice();
|
|
2288
2288
|
const i = !!(s * qt / n);
|
|
2289
|
-
return
|
|
2289
|
+
return xn(mt(r, t), { compressed: !0, sort: i });
|
|
2290
2290
|
}
|
|
2291
2291
|
function Za(e) {
|
|
2292
2292
|
const { compressed: t, infinity: n, sort: r, value: s } = Jn(e), { BYTES: i, ORDER: o } = N;
|
|
2293
2293
|
if (s.length === 48 && t) {
|
|
2294
|
-
const a =
|
|
2294
|
+
const a = Kt(s), c = N.create(a & mn(N.BITS));
|
|
2295
2295
|
if (n) {
|
|
2296
|
-
if (c !==
|
|
2296
|
+
if (c !== _t)
|
|
2297
2297
|
throw new Error("invalid G1 point: non-empty, at infinity, with compression");
|
|
2298
|
-
return { x:
|
|
2298
|
+
return { x: _t, y: _t };
|
|
2299
2299
|
}
|
|
2300
|
-
const u = N.add(N.pow(c,
|
|
2300
|
+
const u = N.add(N.pow(c, zn), N.create(en.b));
|
|
2301
2301
|
let l = N.sqrt(u);
|
|
2302
2302
|
if (!l)
|
|
2303
2303
|
throw new Error("invalid G1 point: compressed point");
|
|
2304
2304
|
return l * qt / o !== BigInt(r) && (l = N.neg(l)), { x: N.create(c), y: N.create(l) };
|
|
2305
2305
|
} else if (s.length === 96 && !t) {
|
|
2306
|
-
const a =
|
|
2306
|
+
const a = Kt(s.subarray(0, i)), c = Kt(s.subarray(i));
|
|
2307
2307
|
if (n) {
|
|
2308
|
-
if (a !==
|
|
2308
|
+
if (a !== _t || c !== _t)
|
|
2309
2309
|
throw new Error("G1: non-empty point at infinity");
|
|
2310
2310
|
return T.G1.Point.ZERO.toAffine();
|
|
2311
2311
|
}
|
|
@@ -2314,10 +2314,10 @@ function Za(e) {
|
|
|
2314
2314
|
throw new Error("invalid G1 point: expected 48/96 bytes");
|
|
2315
2315
|
}
|
|
2316
2316
|
function fs(e) {
|
|
2317
|
-
const { infinity: t, sort: n, value: r } = Jn(ft(e, 48, "signature")), s = N.ORDER, i = T.G1.Point, o =
|
|
2317
|
+
const { infinity: t, sort: n, value: r } = Jn(ft(e, 48, "signature")), s = N.ORDER, i = T.G1.Point, o = Kt(r);
|
|
2318
2318
|
if (t)
|
|
2319
2319
|
return i.ZERO;
|
|
2320
|
-
const a = N.create(o & mn(N.BITS)), c = N.add(N.pow(a,
|
|
2320
|
+
const a = N.create(o & mn(N.BITS)), c = N.add(N.pow(a, zn), N.create(en.b));
|
|
2321
2321
|
let u = N.sqrt(c);
|
|
2322
2322
|
if (!u)
|
|
2323
2323
|
throw new Error("invalid G1 point: compressed");
|
|
@@ -2330,9 +2330,9 @@ function Ya(e, t, n) {
|
|
|
2330
2330
|
const { BYTES: r, ORDER: s } = N, i = t.is0(), { x: o, y: a } = t.toAffine();
|
|
2331
2331
|
if (n) {
|
|
2332
2332
|
if (i)
|
|
2333
|
-
return ht(Xn, mt(
|
|
2334
|
-
const c = !!(a.c1 ===
|
|
2335
|
-
return ht(
|
|
2333
|
+
return ht(Xn, mt(_t, r));
|
|
2334
|
+
const c = !!(a.c1 === _t ? a.c0 * qt / s : a.c1 * qt / s);
|
|
2335
|
+
return ht(xn(mt(o.c1, r), { compressed: !0, sort: c }), mt(o.c0, r));
|
|
2336
2336
|
} else {
|
|
2337
2337
|
if (i)
|
|
2338
2338
|
return ht(Uint8Array.of(64), new Uint8Array(4 * r - 1));
|
|
@@ -2344,26 +2344,26 @@ function br(e) {
|
|
|
2344
2344
|
e.assertValidity();
|
|
2345
2345
|
const { BYTES: t } = N;
|
|
2346
2346
|
if (e.is0())
|
|
2347
|
-
return ht(Xn, mt(
|
|
2348
|
-
const { x: n, y: r } = e.toAffine(), { re: s, im: i } = V.reim(n), { re: o, im: a } = V.reim(r), u = !!((a >
|
|
2349
|
-
return ht(
|
|
2347
|
+
return ht(Xn, mt(_t, 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 > _t ? a * qt : o * qt) / N.ORDER & Hn), l = s;
|
|
2349
|
+
return ht(xn(mt(i, t), { sort: u, compressed: !0 }), mt(l, t));
|
|
2350
2350
|
}
|
|
2351
|
-
function
|
|
2351
|
+
function Ka(e) {
|
|
2352
2352
|
const { BYTES: t, ORDER: n } = N, { compressed: r, infinity: s, sort: i, value: o } = Jn(e);
|
|
2353
2353
|
if (!r && !s && i || // 00100000
|
|
2354
2354
|
!r && s && i || // 01100000
|
|
2355
2355
|
i && s && r)
|
|
2356
2356
|
throw new Error("invalid encoding flag: " + (e[0] & 224));
|
|
2357
|
-
const a = (c, u, l) =>
|
|
2357
|
+
const a = (c, u, l) => Kt(c.slice(u, l));
|
|
2358
2358
|
if (o.length === 96 && r) {
|
|
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
2362
|
return { x: V.ZERO, y: V.ZERO };
|
|
2363
2363
|
}
|
|
2364
|
-
const c = a(o, 0, t), u = a(o, t, 2 * t), l = V.create({ c0: N.create(u), c1: N.create(c) }), f = V.add(V.pow(l,
|
|
2364
|
+
const c = a(o, 0, t), u = a(o, t, 2 * t), l = V.create({ c0: N.create(u), c1: N.create(c) }), f = V.add(V.pow(l, zn), Fr.b);
|
|
2365
2365
|
let d = V.sqrt(f);
|
|
2366
|
-
const p = d.c1 ===
|
|
2366
|
+
const p = d.c1 === _t ? d.c0 * qt / n : d.c1 * qt / n ? Hn : _t;
|
|
2367
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) {
|
|
@@ -2380,19 +2380,19 @@ function ds(e) {
|
|
|
2380
2380
|
const { ORDER: t } = N, { infinity: n, sort: r, value: s } = Jn(ft(e)), i = T.G2.Point, o = s.length / 2;
|
|
2381
2381
|
if (o !== 48 && o !== 96)
|
|
2382
2382
|
throw new Error("invalid compressed signature length, expected 96/192 bytes");
|
|
2383
|
-
const a =
|
|
2383
|
+
const a = Kt(s.slice(0, o)), c = Kt(s.slice(o));
|
|
2384
2384
|
if (n)
|
|
2385
2385
|
return i.ZERO;
|
|
2386
|
-
const u = N.create(a & mn(N.BITS)), l = N.create(c), f = V.create({ c0: l, c1: u }), d = V.add(V.pow(f,
|
|
2386
|
+
const u = N.create(a & mn(N.BITS)), l = N.create(c), f = V.create({ c0: l, c1: u }), d = V.add(V.pow(f, zn), Fr.b);
|
|
2387
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 } = V.reim(p), g = BigInt(r), b = h >
|
|
2390
|
+
const { re: w, im: h } = V.reim(p), g = BigInt(r), b = h > _t && h * qt / t !== g, v = h === _t && w * qt / t !== g;
|
|
2391
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 za = {
|
|
2396
2396
|
ShortSignature: {
|
|
2397
2397
|
fromBytes(e) {
|
|
2398
2398
|
return fs(ft(e));
|
|
@@ -2444,25 +2444,25 @@ const Ka = {
|
|
|
2444
2444
|
// https://eprint.iacr.org/2021/1130.pdf
|
|
2445
2445
|
isTorsionFree: (e, t) => {
|
|
2446
2446
|
const n = BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"), r = new e(N.mul(t.X, n), t.Y, t.Z);
|
|
2447
|
-
return t.multiplyUnsafe(
|
|
2447
|
+
return t.multiplyUnsafe(_e).negate().multiplyUnsafe(_e).equals(r);
|
|
2448
2448
|
},
|
|
2449
2449
|
// Clear cofactor of G1
|
|
2450
2450
|
// https://eprint.iacr.org/2019/403
|
|
2451
|
-
clearCofactor: (e, t) => t.multiplyUnsafe(
|
|
2451
|
+
clearCofactor: (e, t) => t.multiplyUnsafe(_e).add(t)
|
|
2452
2452
|
}), ja = Ti(Fr, {
|
|
2453
2453
|
Fp: V,
|
|
2454
2454
|
allowInfinityPoint: !0,
|
|
2455
2455
|
Fn: Pr,
|
|
2456
|
-
fromBytes:
|
|
2456
|
+
fromBytes: Ka,
|
|
2457
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(_e).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 = _e;
|
|
2466
2466
|
let r = t.multiplyUnsafe(n).negate(), s = ls(e, t), i = t.double();
|
|
2467
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
|
}
|
|
@@ -2473,11 +2473,11 @@ const Ka = {
|
|
|
2473
2473
|
hasherOptsG1: { ...gr, m: 1, DST: "BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_" },
|
|
2474
2474
|
hasherOptsG2: { ...gr }
|
|
2475
2475
|
}, tc = {
|
|
2476
|
-
ateLoopSize:
|
|
2476
|
+
ateLoopSize: _e,
|
|
2477
2477
|
// The BLS parameter x for BLS12-381
|
|
2478
2478
|
twistType: "multiplicative",
|
|
2479
2479
|
randomBytes: ii
|
|
2480
|
-
}, T = Pa(Xa, Ja, ja, tc, Qa,
|
|
2480
|
+
}, T = Pa(Xa, Ja, ja, tc, Qa, za), ec = vi(V, [
|
|
2481
2481
|
// xNum
|
|
2482
2482
|
[
|
|
2483
2483
|
[
|
|
@@ -2621,7 +2621,7 @@ const Ka = {
|
|
|
2621
2621
|
B: N.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),
|
|
2622
2622
|
Z: N.create(BigInt(11))
|
|
2623
2623
|
}), sc = Ii(V, {
|
|
2624
|
-
A: V.create({ c0: N.create(
|
|
2624
|
+
A: V.create({ c0: N.create(_t), c1: N.create(BigInt(240)) }),
|
|
2625
2625
|
// A' = 240 * I
|
|
2626
2626
|
B: V.create({ c0: N.create(BigInt(1012)), c1: N.create(BigInt(1012)) }),
|
|
2627
2627
|
// B' = 1012 * (1 + I)
|
|
@@ -2794,7 +2794,7 @@ function Ni(e, t, n) {
|
|
|
2794
2794
|
function yt(e, t) {
|
|
2795
2795
|
return Ni(e, t, !1);
|
|
2796
2796
|
}
|
|
2797
|
-
function
|
|
2797
|
+
function zt(e, t) {
|
|
2798
2798
|
return Ni(e, t, !0);
|
|
2799
2799
|
}
|
|
2800
2800
|
function cn(e, t) {
|
|
@@ -2810,7 +2810,7 @@ function bt(e) {
|
|
|
2810
2810
|
}
|
|
2811
2811
|
return n;
|
|
2812
2812
|
}
|
|
2813
|
-
function
|
|
2813
|
+
function xe(e) {
|
|
2814
2814
|
return "0x" + e.map((t) => bt(t).substring(2)).join("");
|
|
2815
2815
|
}
|
|
2816
2816
|
function dc(e) {
|
|
@@ -2840,7 +2840,7 @@ function An(e, t) {
|
|
|
2840
2840
|
function $i(e, t) {
|
|
2841
2841
|
return Ci(e, t, !1);
|
|
2842
2842
|
}
|
|
2843
|
-
const En = BigInt(0), Mt = BigInt(1),
|
|
2843
|
+
const En = BigInt(0), Mt = BigInt(1), Ke = 9007199254740991;
|
|
2844
2844
|
function pc(e, t) {
|
|
2845
2845
|
const n = jn(e, "value"), r = BigInt(Ee(t, "width"));
|
|
2846
2846
|
if (at(n >> r === En, "overflow", "NUMERIC_FAULT", {
|
|
@@ -2881,7 +2881,7 @@ function nn(e, t) {
|
|
|
2881
2881
|
case "bigint":
|
|
2882
2882
|
return e;
|
|
2883
2883
|
case "number":
|
|
2884
|
-
return m(Number.isInteger(e), "underflow", t || "value", e), m(e >= -
|
|
2884
|
+
return m(Number.isInteger(e), "underflow", t || "value", e), m(e >= -Ke && e <= Ke, "overflow", t || "value", e), BigInt(e);
|
|
2885
2885
|
case "string":
|
|
2886
2886
|
try {
|
|
2887
2887
|
if (e === "")
|
|
@@ -2914,9 +2914,9 @@ function Ai(e) {
|
|
|
2914
2914
|
function Ee(e, t) {
|
|
2915
2915
|
switch (typeof e) {
|
|
2916
2916
|
case "bigint":
|
|
2917
|
-
return m(e >= -
|
|
2917
|
+
return m(e >= -Ke && e <= Ke, "overflow", t || "value", e), Number(e);
|
|
2918
2918
|
case "number":
|
|
2919
|
-
return m(Number.isInteger(e), "underflow", t || "value", e), m(e >= -
|
|
2919
|
+
return m(Number.isInteger(e), "underflow", t || "value", e), m(e >= -Ke && e <= Ke, "overflow", t || "value", e), e;
|
|
2920
2920
|
case "string":
|
|
2921
2921
|
try {
|
|
2922
2922
|
if (e === "")
|
|
@@ -3057,10 +3057,10 @@ function qr(e, t) {
|
|
|
3057
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
|
|
3060
|
+
function _c(e, t) {
|
|
3061
3061
|
return mc(bc(e, t));
|
|
3062
3062
|
}
|
|
3063
|
-
const vt = 32, Sr = new Uint8Array(vt),
|
|
3063
|
+
const vt = 32, Sr = new Uint8Array(vt), xc = ["then"], Rn = {}, qi = /* @__PURE__ */ new WeakMap();
|
|
3064
3064
|
function Re(e) {
|
|
3065
3065
|
return qi.get(e);
|
|
3066
3066
|
}
|
|
@@ -3108,7 +3108,7 @@ class oe extends Array {
|
|
|
3108
3108
|
const p = c[d];
|
|
3109
3109
|
return p instanceof Error && on(`index ${d}`, p), p;
|
|
3110
3110
|
}
|
|
3111
|
-
if (
|
|
3111
|
+
if (xc.indexOf(u) >= 0)
|
|
3112
3112
|
return Reflect.get(c, u, l);
|
|
3113
3113
|
const f = c[u];
|
|
3114
3114
|
if (f instanceof Function)
|
|
@@ -3207,7 +3207,7 @@ class oe extends Array {
|
|
|
3207
3207
|
}
|
|
3208
3208
|
function bs(e) {
|
|
3209
3209
|
let t = Fi(e);
|
|
3210
|
-
return at(t.length <= vt, "value out-of-bounds", "BUFFER_OVERRUN", { buffer: t, length: vt, offset: t.length }), t.length !== vt && (t =
|
|
3210
|
+
return at(t.length <= vt, "value out-of-bounds", "BUFFER_OVERRUN", { buffer: t, length: vt, offset: t.length }), t.length !== vt && (t = zt(xe([Sr.slice(t.length % vt), t]))), t;
|
|
3211
3211
|
}
|
|
3212
3212
|
class de {
|
|
3213
3213
|
// The coder name:
|
|
@@ -3243,7 +3243,7 @@ class vr {
|
|
|
3243
3243
|
this.#t = [], this.#e = 0;
|
|
3244
3244
|
}
|
|
3245
3245
|
get data() {
|
|
3246
|
-
return
|
|
3246
|
+
return xe(this.#t);
|
|
3247
3247
|
}
|
|
3248
3248
|
get length() {
|
|
3249
3249
|
return this.#e;
|
|
@@ -3252,13 +3252,13 @@ class vr {
|
|
|
3252
3252
|
return this.#t.push(t), this.#e += t.length, t.length;
|
|
3253
3253
|
}
|
|
3254
3254
|
appendWriter(t) {
|
|
3255
|
-
return this.#n(
|
|
3255
|
+
return this.#n(zt(t.data));
|
|
3256
3256
|
}
|
|
3257
3257
|
// Arrayish item; pad on the right to *nearest* WordSize
|
|
3258
3258
|
writeBytes(t) {
|
|
3259
|
-
let n =
|
|
3259
|
+
let n = zt(t);
|
|
3260
3260
|
const r = n.length % vt;
|
|
3261
|
-
return r && (n =
|
|
3261
|
+
return r && (n = zt(xe([n, Sr.slice(r)]))), this.#n(n);
|
|
3262
3262
|
}
|
|
3263
3263
|
// Numeric item; pad on the left *to* WordSize
|
|
3264
3264
|
writeValue(t) {
|
|
@@ -3285,7 +3285,7 @@ class Dr {
|
|
|
3285
3285
|
#r;
|
|
3286
3286
|
#s;
|
|
3287
3287
|
constructor(t, n, r) {
|
|
3288
|
-
st(this, { allowLoose: !!n }), this.#t =
|
|
3288
|
+
st(this, { allowLoose: !!n }), this.#t = zt(t), this.#n = 0, this.#r = null, this.#s = r ?? 1024, this.#e = 0;
|
|
3289
3289
|
}
|
|
3290
3290
|
get data() {
|
|
3291
3291
|
return bt(this.#t);
|
|
@@ -3303,7 +3303,7 @@ class Dr {
|
|
|
3303
3303
|
if (this.#r)
|
|
3304
3304
|
return this.#r.#i(t);
|
|
3305
3305
|
this.#n += t, at(this.#s < 1 || this.#n <= this.#s * this.dataLength, `compressed ABI data exceeds inflation ratio of ${this.#s} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`, "BUFFER_OVERRUN", {
|
|
3306
|
-
buffer:
|
|
3306
|
+
buffer: zt(this.#t),
|
|
3307
3307
|
offset: this.#e,
|
|
3308
3308
|
length: t,
|
|
3309
3309
|
info: {
|
|
@@ -3315,7 +3315,7 @@ class Dr {
|
|
|
3315
3315
|
#o(t, n, r) {
|
|
3316
3316
|
let s = Math.ceil(n / vt) * vt;
|
|
3317
3317
|
return this.#e + s > this.#t.length && (this.allowLoose && r && this.#e + n <= this.#t.length ? s = n : at(!1, "data out-of-bounds", "BUFFER_OVERRUN", {
|
|
3318
|
-
buffer:
|
|
3318
|
+
buffer: zt(this.#t),
|
|
3319
3319
|
length: this.#t.length,
|
|
3320
3320
|
offset: this.#e + s
|
|
3321
3321
|
})), this.#t.slice(this.#e, this.#e + s);
|
|
@@ -3348,7 +3348,7 @@ function Di(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 _s(e, t = !0) {
|
|
3352
3352
|
if (e.destroyed)
|
|
3353
3353
|
throw new Error("Hash instance has been destroyed");
|
|
3354
3354
|
if (t && e.finished)
|
|
@@ -3383,9 +3383,9 @@ function Ic(e) {
|
|
|
3383
3383
|
const t = (r) => e().update(Mi(r)).digest(), n = e();
|
|
3384
3384
|
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
3385
3385
|
}
|
|
3386
|
-
const kn = /* @__PURE__ */ BigInt(2 ** 32 - 1),
|
|
3386
|
+
const kn = /* @__PURE__ */ BigInt(2 ** 32 - 1), xs = /* @__PURE__ */ BigInt(32);
|
|
3387
3387
|
function Rc(e, t = !1) {
|
|
3388
|
-
return t ? { h: Number(e & kn), l: Number(e >>
|
|
3388
|
+
return t ? { h: Number(e & kn), l: Number(e >> xs & kn) } : { h: Number(e >> xs & kn) | 0, l: Number(e & kn) | 0 };
|
|
3389
3389
|
}
|
|
3390
3390
|
function kc(e, t = !1) {
|
|
3391
3391
|
let n = new Uint32Array(e.length), r = new Uint32Array(e.length);
|
|
@@ -3440,7 +3440,7 @@ class Mr extends Tc {
|
|
|
3440
3440
|
Wc(this.state32, this.rounds), this.posOut = 0, this.pos = 0;
|
|
3441
3441
|
}
|
|
3442
3442
|
update(t) {
|
|
3443
|
-
|
|
3443
|
+
_s(this);
|
|
3444
3444
|
const { blockLen: n, state: r } = this;
|
|
3445
3445
|
t = Mi(t);
|
|
3446
3446
|
const s = t.length;
|
|
@@ -3460,7 +3460,7 @@ class Mr extends Tc {
|
|
|
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
|
+
_s(this, !1), Di(t), this.finish();
|
|
3464
3464
|
const n = this.state, { blockLen: r } = this;
|
|
3465
3465
|
for (let s = 0, i = t.length; s < i; ) {
|
|
3466
3466
|
this.posOut >= r && this.keccak();
|
|
@@ -3542,7 +3542,7 @@ function Yc(e) {
|
|
|
3542
3542
|
n = "0" + n;
|
|
3543
3543
|
return n;
|
|
3544
3544
|
}
|
|
3545
|
-
const
|
|
3545
|
+
const Kc = (function() {
|
|
3546
3546
|
const e = {};
|
|
3547
3547
|
for (let t = 0; t < 36; t++) {
|
|
3548
3548
|
const n = "0123456789abcdefghijklmnopqrstuvwxyz"[t];
|
|
@@ -3550,11 +3550,11 @@ const zc = (function() {
|
|
|
3550
3550
|
}
|
|
3551
3551
|
return e;
|
|
3552
3552
|
})();
|
|
3553
|
-
function
|
|
3553
|
+
function zc(e) {
|
|
3554
3554
|
e = e.toLowerCase();
|
|
3555
3555
|
let t = Vc;
|
|
3556
3556
|
for (let n = 0; n < e.length; n++)
|
|
3557
|
-
t = t * Zc +
|
|
3557
|
+
t = t * Zc + Kc[e[n]];
|
|
3558
3558
|
return t;
|
|
3559
3559
|
}
|
|
3560
3560
|
function dn(e) {
|
|
@@ -3565,7 +3565,7 @@ function dn(e) {
|
|
|
3565
3565
|
}
|
|
3566
3566
|
if (e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
|
3567
3567
|
m(e.substring(2, 4) === Yc(e), "bad icap checksum", "address", e);
|
|
3568
|
-
let t =
|
|
3568
|
+
let t = zc(e.substring(4)).toString(16);
|
|
3569
3569
|
for (; t.length < 40; )
|
|
3570
3570
|
t = "0" + t;
|
|
3571
3571
|
return Bs("0x" + t);
|
|
@@ -3577,7 +3577,7 @@ function E(e, t) {
|
|
|
3577
3577
|
let n = !1;
|
|
3578
3578
|
return t < 0 && (n = !0, t *= -1), new pt(se, `${n ? "" : "u"}int${t}`, e, { signed: n, width: t });
|
|
3579
3579
|
}
|
|
3580
|
-
function
|
|
3580
|
+
function K(e, t) {
|
|
3581
3581
|
return new pt(se, `bytes${t || ""}`, e, { size: t });
|
|
3582
3582
|
}
|
|
3583
3583
|
const Os = /* @__PURE__ */ Symbol.for("_ethers_typed");
|
|
@@ -4075,193 +4075,193 @@ class pt {
|
|
|
4075
4075
|
* Return a new ``bytes1`` type for %%v%%.
|
|
4076
4076
|
*/
|
|
4077
4077
|
static bytes1(t) {
|
|
4078
|
-
return
|
|
4078
|
+
return K(t, 1);
|
|
4079
4079
|
}
|
|
4080
4080
|
/**
|
|
4081
4081
|
* Return a new ``bytes2`` type for %%v%%.
|
|
4082
4082
|
*/
|
|
4083
4083
|
static bytes2(t) {
|
|
4084
|
-
return
|
|
4084
|
+
return K(t, 2);
|
|
4085
4085
|
}
|
|
4086
4086
|
/**
|
|
4087
4087
|
* Return a new ``bytes3`` type for %%v%%.
|
|
4088
4088
|
*/
|
|
4089
4089
|
static bytes3(t) {
|
|
4090
|
-
return
|
|
4090
|
+
return K(t, 3);
|
|
4091
4091
|
}
|
|
4092
4092
|
/**
|
|
4093
4093
|
* Return a new ``bytes4`` type for %%v%%.
|
|
4094
4094
|
*/
|
|
4095
4095
|
static bytes4(t) {
|
|
4096
|
-
return
|
|
4096
|
+
return K(t, 4);
|
|
4097
4097
|
}
|
|
4098
4098
|
/**
|
|
4099
4099
|
* Return a new ``bytes5`` type for %%v%%.
|
|
4100
4100
|
*/
|
|
4101
4101
|
static bytes5(t) {
|
|
4102
|
-
return
|
|
4102
|
+
return K(t, 5);
|
|
4103
4103
|
}
|
|
4104
4104
|
/**
|
|
4105
4105
|
* Return a new ``bytes6`` type for %%v%%.
|
|
4106
4106
|
*/
|
|
4107
4107
|
static bytes6(t) {
|
|
4108
|
-
return
|
|
4108
|
+
return K(t, 6);
|
|
4109
4109
|
}
|
|
4110
4110
|
/**
|
|
4111
4111
|
* Return a new ``bytes7`` type for %%v%%.
|
|
4112
4112
|
*/
|
|
4113
4113
|
static bytes7(t) {
|
|
4114
|
-
return
|
|
4114
|
+
return K(t, 7);
|
|
4115
4115
|
}
|
|
4116
4116
|
/**
|
|
4117
4117
|
* Return a new ``bytes8`` type for %%v%%.
|
|
4118
4118
|
*/
|
|
4119
4119
|
static bytes8(t) {
|
|
4120
|
-
return
|
|
4120
|
+
return K(t, 8);
|
|
4121
4121
|
}
|
|
4122
4122
|
/**
|
|
4123
4123
|
* Return a new ``bytes9`` type for %%v%%.
|
|
4124
4124
|
*/
|
|
4125
4125
|
static bytes9(t) {
|
|
4126
|
-
return
|
|
4126
|
+
return K(t, 9);
|
|
4127
4127
|
}
|
|
4128
4128
|
/**
|
|
4129
4129
|
* Return a new ``bytes10`` type for %%v%%.
|
|
4130
4130
|
*/
|
|
4131
4131
|
static bytes10(t) {
|
|
4132
|
-
return
|
|
4132
|
+
return K(t, 10);
|
|
4133
4133
|
}
|
|
4134
4134
|
/**
|
|
4135
4135
|
* Return a new ``bytes11`` type for %%v%%.
|
|
4136
4136
|
*/
|
|
4137
4137
|
static bytes11(t) {
|
|
4138
|
-
return
|
|
4138
|
+
return K(t, 11);
|
|
4139
4139
|
}
|
|
4140
4140
|
/**
|
|
4141
4141
|
* Return a new ``bytes12`` type for %%v%%.
|
|
4142
4142
|
*/
|
|
4143
4143
|
static bytes12(t) {
|
|
4144
|
-
return
|
|
4144
|
+
return K(t, 12);
|
|
4145
4145
|
}
|
|
4146
4146
|
/**
|
|
4147
4147
|
* Return a new ``bytes13`` type for %%v%%.
|
|
4148
4148
|
*/
|
|
4149
4149
|
static bytes13(t) {
|
|
4150
|
-
return
|
|
4150
|
+
return K(t, 13);
|
|
4151
4151
|
}
|
|
4152
4152
|
/**
|
|
4153
4153
|
* Return a new ``bytes14`` type for %%v%%.
|
|
4154
4154
|
*/
|
|
4155
4155
|
static bytes14(t) {
|
|
4156
|
-
return
|
|
4156
|
+
return K(t, 14);
|
|
4157
4157
|
}
|
|
4158
4158
|
/**
|
|
4159
4159
|
* Return a new ``bytes15`` type for %%v%%.
|
|
4160
4160
|
*/
|
|
4161
4161
|
static bytes15(t) {
|
|
4162
|
-
return
|
|
4162
|
+
return K(t, 15);
|
|
4163
4163
|
}
|
|
4164
4164
|
/**
|
|
4165
4165
|
* Return a new ``bytes16`` type for %%v%%.
|
|
4166
4166
|
*/
|
|
4167
4167
|
static bytes16(t) {
|
|
4168
|
-
return
|
|
4168
|
+
return K(t, 16);
|
|
4169
4169
|
}
|
|
4170
4170
|
/**
|
|
4171
4171
|
* Return a new ``bytes17`` type for %%v%%.
|
|
4172
4172
|
*/
|
|
4173
4173
|
static bytes17(t) {
|
|
4174
|
-
return
|
|
4174
|
+
return K(t, 17);
|
|
4175
4175
|
}
|
|
4176
4176
|
/**
|
|
4177
4177
|
* Return a new ``bytes18`` type for %%v%%.
|
|
4178
4178
|
*/
|
|
4179
4179
|
static bytes18(t) {
|
|
4180
|
-
return
|
|
4180
|
+
return K(t, 18);
|
|
4181
4181
|
}
|
|
4182
4182
|
/**
|
|
4183
4183
|
* Return a new ``bytes19`` type for %%v%%.
|
|
4184
4184
|
*/
|
|
4185
4185
|
static bytes19(t) {
|
|
4186
|
-
return
|
|
4186
|
+
return K(t, 19);
|
|
4187
4187
|
}
|
|
4188
4188
|
/**
|
|
4189
4189
|
* Return a new ``bytes20`` type for %%v%%.
|
|
4190
4190
|
*/
|
|
4191
4191
|
static bytes20(t) {
|
|
4192
|
-
return
|
|
4192
|
+
return K(t, 20);
|
|
4193
4193
|
}
|
|
4194
4194
|
/**
|
|
4195
4195
|
* Return a new ``bytes21`` type for %%v%%.
|
|
4196
4196
|
*/
|
|
4197
4197
|
static bytes21(t) {
|
|
4198
|
-
return
|
|
4198
|
+
return K(t, 21);
|
|
4199
4199
|
}
|
|
4200
4200
|
/**
|
|
4201
4201
|
* Return a new ``bytes22`` type for %%v%%.
|
|
4202
4202
|
*/
|
|
4203
4203
|
static bytes22(t) {
|
|
4204
|
-
return
|
|
4204
|
+
return K(t, 22);
|
|
4205
4205
|
}
|
|
4206
4206
|
/**
|
|
4207
4207
|
* Return a new ``bytes23`` type for %%v%%.
|
|
4208
4208
|
*/
|
|
4209
4209
|
static bytes23(t) {
|
|
4210
|
-
return
|
|
4210
|
+
return K(t, 23);
|
|
4211
4211
|
}
|
|
4212
4212
|
/**
|
|
4213
4213
|
* Return a new ``bytes24`` type for %%v%%.
|
|
4214
4214
|
*/
|
|
4215
4215
|
static bytes24(t) {
|
|
4216
|
-
return
|
|
4216
|
+
return K(t, 24);
|
|
4217
4217
|
}
|
|
4218
4218
|
/**
|
|
4219
4219
|
* Return a new ``bytes25`` type for %%v%%.
|
|
4220
4220
|
*/
|
|
4221
4221
|
static bytes25(t) {
|
|
4222
|
-
return
|
|
4222
|
+
return K(t, 25);
|
|
4223
4223
|
}
|
|
4224
4224
|
/**
|
|
4225
4225
|
* Return a new ``bytes26`` type for %%v%%.
|
|
4226
4226
|
*/
|
|
4227
4227
|
static bytes26(t) {
|
|
4228
|
-
return
|
|
4228
|
+
return K(t, 26);
|
|
4229
4229
|
}
|
|
4230
4230
|
/**
|
|
4231
4231
|
* Return a new ``bytes27`` type for %%v%%.
|
|
4232
4232
|
*/
|
|
4233
4233
|
static bytes27(t) {
|
|
4234
|
-
return
|
|
4234
|
+
return K(t, 27);
|
|
4235
4235
|
}
|
|
4236
4236
|
/**
|
|
4237
4237
|
* Return a new ``bytes28`` type for %%v%%.
|
|
4238
4238
|
*/
|
|
4239
4239
|
static bytes28(t) {
|
|
4240
|
-
return
|
|
4240
|
+
return K(t, 28);
|
|
4241
4241
|
}
|
|
4242
4242
|
/**
|
|
4243
4243
|
* Return a new ``bytes29`` type for %%v%%.
|
|
4244
4244
|
*/
|
|
4245
4245
|
static bytes29(t) {
|
|
4246
|
-
return
|
|
4246
|
+
return K(t, 29);
|
|
4247
4247
|
}
|
|
4248
4248
|
/**
|
|
4249
4249
|
* Return a new ``bytes30`` type for %%v%%.
|
|
4250
4250
|
*/
|
|
4251
4251
|
static bytes30(t) {
|
|
4252
|
-
return
|
|
4252
|
+
return K(t, 30);
|
|
4253
4253
|
}
|
|
4254
4254
|
/**
|
|
4255
4255
|
* Return a new ``bytes31`` type for %%v%%.
|
|
4256
4256
|
*/
|
|
4257
4257
|
static bytes31(t) {
|
|
4258
|
-
return
|
|
4258
|
+
return K(t, 31);
|
|
4259
4259
|
}
|
|
4260
4260
|
/**
|
|
4261
4261
|
* Return a new ``bytes32`` type for %%v%%.
|
|
4262
4262
|
*/
|
|
4263
4263
|
static bytes32(t) {
|
|
4264
|
-
return
|
|
4264
|
+
return K(t, 32);
|
|
4265
4265
|
}
|
|
4266
4266
|
/**
|
|
4267
4267
|
* Return a new ``address`` type for %%v%%.
|
|
@@ -4362,7 +4362,7 @@ class Jc extends de {
|
|
|
4362
4362
|
return this.coder.decode(t);
|
|
4363
4363
|
}
|
|
4364
4364
|
}
|
|
4365
|
-
function
|
|
4365
|
+
function Ki(e, t, n) {
|
|
4366
4366
|
let r = [];
|
|
4367
4367
|
if (Array.isArray(n))
|
|
4368
4368
|
r = n;
|
|
@@ -4393,7 +4393,7 @@ function zi(e, t, n) {
|
|
|
4393
4393
|
let a = e.appendWriter(s);
|
|
4394
4394
|
return a += e.appendWriter(i), a;
|
|
4395
4395
|
}
|
|
4396
|
-
function
|
|
4396
|
+
function zi(e, t) {
|
|
4397
4397
|
let n = [], r = [], s = e.subReader(0);
|
|
4398
4398
|
return t.forEach((i) => {
|
|
4399
4399
|
let o = null;
|
|
@@ -4440,7 +4440,7 @@ class jc extends de {
|
|
|
4440
4440
|
let i = [];
|
|
4441
4441
|
for (let o = 0; o < r.length; o++)
|
|
4442
4442
|
i.push(this.coder);
|
|
4443
|
-
return
|
|
4443
|
+
return Ki(t, i, r);
|
|
4444
4444
|
}
|
|
4445
4445
|
decode(t) {
|
|
4446
4446
|
let n = this.length;
|
|
@@ -4448,7 +4448,7 @@ class jc extends de {
|
|
|
4448
4448
|
let r = [];
|
|
4449
4449
|
for (let s = 0; s < n; s++)
|
|
4450
4450
|
r.push(new Jc(this.coder));
|
|
4451
|
-
return
|
|
4451
|
+
return zi(t, r);
|
|
4452
4452
|
}
|
|
4453
4453
|
}
|
|
4454
4454
|
class Qc extends de {
|
|
@@ -4474,7 +4474,7 @@ class Xi extends de {
|
|
|
4474
4474
|
return "0x";
|
|
4475
4475
|
}
|
|
4476
4476
|
encode(t, n) {
|
|
4477
|
-
n =
|
|
4477
|
+
n = zt(n);
|
|
4478
4478
|
let r = t.writeValue(n.length);
|
|
4479
4479
|
return r += t.writeBytes(n), r;
|
|
4480
4480
|
}
|
|
@@ -4500,7 +4500,7 @@ class eu extends de {
|
|
|
4500
4500
|
return "0x0000000000000000000000000000000000000000000000000000000000000000".substring(0, 2 + this.size * 2);
|
|
4501
4501
|
}
|
|
4502
4502
|
encode(t, n) {
|
|
4503
|
-
let r =
|
|
4503
|
+
let r = zt(pt.dereference(n, this.type));
|
|
4504
4504
|
return r.length !== this.size && this._throwError("incorrect data length", n), t.writeBytes(r);
|
|
4505
4505
|
}
|
|
4506
4506
|
decode(t) {
|
|
@@ -4557,7 +4557,7 @@ class cu extends Xi {
|
|
|
4557
4557
|
return super.encode(t, qr(pt.dereference(n, "string")));
|
|
4558
4558
|
}
|
|
4559
4559
|
decode(t) {
|
|
4560
|
-
return
|
|
4560
|
+
return _c(super.decode(t));
|
|
4561
4561
|
}
|
|
4562
4562
|
}
|
|
4563
4563
|
class Nn extends de {
|
|
@@ -4587,10 +4587,10 @@ class Nn extends de {
|
|
|
4587
4587
|
}
|
|
4588
4588
|
encode(t, n) {
|
|
4589
4589
|
const r = pt.dereference(n, "tuple");
|
|
4590
|
-
return
|
|
4590
|
+
return Ki(t, this.coders, r);
|
|
4591
4591
|
}
|
|
4592
4592
|
decode(t) {
|
|
4593
|
-
return
|
|
4593
|
+
return zi(t, this.coders);
|
|
4594
4594
|
}
|
|
4595
4595
|
}
|
|
4596
4596
|
function pn(e) {
|
|
@@ -4623,7 +4623,7 @@ function Ji(e, t, n) {
|
|
|
4623
4623
|
const o = [];
|
|
4624
4624
|
return t.forEach(function(a) {
|
|
4625
4625
|
o.push(Ji(s, a, !0));
|
|
4626
|
-
}), yt(
|
|
4626
|
+
}), yt(xe(o));
|
|
4627
4627
|
}
|
|
4628
4628
|
m(!1, "invalid type", "type", e);
|
|
4629
4629
|
}
|
|
@@ -4632,7 +4632,7 @@ function Ts(e, t) {
|
|
|
4632
4632
|
const n = [];
|
|
4633
4633
|
return e.forEach(function(r, s) {
|
|
4634
4634
|
n.push(Ji(r, t[s]));
|
|
4635
|
-
}), bt(
|
|
4635
|
+
}), bt(xe(n));
|
|
4636
4636
|
}
|
|
4637
4637
|
function Ot(e) {
|
|
4638
4638
|
const t = /* @__PURE__ */ new Set();
|
|
@@ -4645,7 +4645,7 @@ const du = "external public payable override", pu = Ot(du.split(" ")), ji = "con
|
|
|
4645
4645
|
"]": "CLOSE_BRACKET",
|
|
4646
4646
|
",": "COMMA",
|
|
4647
4647
|
"@": "AT"
|
|
4648
|
-
},
|
|
4648
|
+
}, _u = new RegExp("^(\\s*)"), xu = new RegExp("^([0-9]+)"), Eu = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"), no = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"), ro = new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");
|
|
4649
4649
|
class Dt {
|
|
4650
4650
|
#t;
|
|
4651
4651
|
#e;
|
|
@@ -4745,7 +4745,7 @@ 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(_u);
|
|
4749
4749
|
a && (i += a[1].length, o = e.substring(i));
|
|
4750
4750
|
const c = { depth: r.length, linkBack: -1, linkNext: -1, match: -1, type: "", text: "", offset: i, value: -1 };
|
|
4751
4751
|
t.push(c);
|
|
@@ -4783,7 +4783,7 @@ function Se(e) {
|
|
|
4783
4783
|
c.type = "ID";
|
|
4784
4784
|
continue;
|
|
4785
4785
|
}
|
|
4786
|
-
if (a = o.match(
|
|
4786
|
+
if (a = o.match(xu), a) {
|
|
4787
4787
|
c.text = a[1], c.type = "NUMBER", i += c.text.length;
|
|
4788
4788
|
continue;
|
|
4789
4789
|
}
|
|
@@ -5594,7 +5594,7 @@ Gt.set(50, "ARRAY_RANGE_ERROR");
|
|
|
5594
5594
|
Gt.set(65, "OUT_OF_MEMORY");
|
|
5595
5595
|
Gt.set(81, "UNINITIALIZED_FUNCTION_CALL");
|
|
5596
5596
|
const Bu = new RegExp(/^bytes([0-9]*)$/), vu = new RegExp(/^(u?int)([0-9]*)$/);
|
|
5597
|
-
let
|
|
5597
|
+
let _r = null, Fs = 1024;
|
|
5598
5598
|
function Ou(e, t, n, r) {
|
|
5599
5599
|
let s = "missing revert data", i = null;
|
|
5600
5600
|
const o = null;
|
|
@@ -5712,7 +5712,7 @@ class fe {
|
|
|
5712
5712
|
* On the first call, the instance is created internally.
|
|
5713
5713
|
*/
|
|
5714
5714
|
static defaultAbiCoder() {
|
|
5715
|
-
return
|
|
5715
|
+
return _r == null && (_r = new fe()), _r;
|
|
5716
5716
|
}
|
|
5717
5717
|
/**
|
|
5718
5718
|
* Returns an ethers-compatible [[CallExceptionError]] Error for the given
|
|
@@ -6281,7 +6281,7 @@ class ge {
|
|
|
6281
6281
|
const r = this.getError(t);
|
|
6282
6282
|
m(r, "unknown error", "fragment", t), t = r;
|
|
6283
6283
|
}
|
|
6284
|
-
return
|
|
6284
|
+
return xe([
|
|
6285
6285
|
t.selector,
|
|
6286
6286
|
this._encodeParams(t.inputs, n || [])
|
|
6287
6287
|
]);
|
|
@@ -6311,7 +6311,7 @@ class ge {
|
|
|
6311
6311
|
const r = this.getFunction(t);
|
|
6312
6312
|
m(r, "unknown function", "fragment", t), t = r;
|
|
6313
6313
|
}
|
|
6314
|
-
return
|
|
6314
|
+
return xe([
|
|
6315
6315
|
t.selector,
|
|
6316
6316
|
this._encodeParams(t.inputs, n || [])
|
|
6317
6317
|
]);
|
|
@@ -6331,7 +6331,7 @@ class ge {
|
|
|
6331
6331
|
m(i, "unknown function", "fragment", t), t = i;
|
|
6332
6332
|
}
|
|
6333
6333
|
let r = "invalid length for result data";
|
|
6334
|
-
const s =
|
|
6334
|
+
const s = zt(n);
|
|
6335
6335
|
if (s.length % 32 === 0)
|
|
6336
6336
|
try {
|
|
6337
6337
|
return this.#r.decode(t.outputs, s);
|
|
@@ -6471,7 +6471,7 @@ class ge {
|
|
|
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, xe(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;
|
|
@@ -6868,7 +6868,7 @@ async function Yu(e, t, n, r, s, i) {
|
|
|
6868
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 Ku(e, t, n) {
|
|
6872
6872
|
const {
|
|
6873
6873
|
reserveA: r,
|
|
6874
6874
|
reserveB: s,
|
|
@@ -6884,7 +6884,7 @@ async function zu(e, t, n) {
|
|
|
6884
6884
|
total_supply: u
|
|
6885
6885
|
}), { amountA: o, amountB: a };
|
|
6886
6886
|
}
|
|
6887
|
-
async function
|
|
6887
|
+
async function zu(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;
|
|
@@ -6934,7 +6934,7 @@ async function fo(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 zu(d, p, c, u, l, f, w, h);
|
|
6938
6938
|
}
|
|
6939
6939
|
}
|
|
6940
6940
|
async function Xu(e, t, n) {
|
|
@@ -6954,7 +6954,7 @@ async function Ju(e, t, n) {
|
|
|
6954
6954
|
return await fo(r, n), r;
|
|
6955
6955
|
}
|
|
6956
6956
|
async function ju(e, t, n, r, s) {
|
|
6957
|
-
const { amountA: i, amountB: o } = await
|
|
6957
|
+
const { amountA: i, amountB: o } = await Ku(e, t, n);
|
|
6958
6958
|
if (i < r)
|
|
6959
6959
|
throw new Error("Insufficient A amount");
|
|
6960
6960
|
if (o < s)
|
|
@@ -7392,12 +7392,12 @@ async function yo(e = {}) {
|
|
|
7392
7392
|
throw new Error("Ordinals wallet address not found.");
|
|
7393
7393
|
const n = new Hr(e, 2);
|
|
7394
7394
|
n.next();
|
|
7395
|
-
const r = await
|
|
7395
|
+
const r = await Kr(Vs());
|
|
7396
7396
|
await new Promise((p) => setTimeout(p, 500)), n.next();
|
|
7397
|
-
const s = await
|
|
7397
|
+
const s = await Kr(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 = uc(
|
|
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 = _i(a, T.fields.Fr.ORDER), u = S.from(c), l = go(u), f = `0x${u.toString("hex")}`, d = {
|
|
7401
7401
|
bitcoinAddress: t.address,
|
|
7402
7402
|
swapPubkey: l,
|
|
7403
7403
|
swapPrivkey: f
|
|
@@ -7513,7 +7513,7 @@ async function mo(e) {
|
|
|
7513
7513
|
});
|
|
7514
7514
|
return BigInt(s.result);
|
|
7515
7515
|
}
|
|
7516
|
-
async function
|
|
7516
|
+
async function _o(e) {
|
|
7517
7517
|
const t = Wt();
|
|
7518
7518
|
if (!t?.address)
|
|
7519
7519
|
throw new Error("Ordinals wallet address not found.");
|
|
@@ -7606,7 +7606,7 @@ async function qe() {
|
|
|
7606
7606
|
});
|
|
7607
7607
|
return BigInt(r.result);
|
|
7608
7608
|
}
|
|
7609
|
-
async function
|
|
7609
|
+
async function _l(e, t) {
|
|
7610
7610
|
const n = J("get_swap_referrer_info"), s = await X(n, {
|
|
7611
7611
|
method: "POST",
|
|
7612
7612
|
headers: {
|
|
@@ -7623,7 +7623,7 @@ async function xl(e, t) {
|
|
|
7623
7623
|
}
|
|
7624
7624
|
async function Vr(e, t) {
|
|
7625
7625
|
try {
|
|
7626
|
-
return await
|
|
7626
|
+
return await _l(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
|
}
|
|
@@ -7640,7 +7640,7 @@ async function $t(e) {
|
|
|
7640
7640
|
});
|
|
7641
7641
|
return BigInt(r.result);
|
|
7642
7642
|
}
|
|
7643
|
-
async function
|
|
7643
|
+
async function xl() {
|
|
7644
7644
|
const e = J("get_tokens");
|
|
7645
7645
|
return (await X(e, {
|
|
7646
7646
|
method: "GET"
|
|
@@ -7722,7 +7722,15 @@ async function Ol(e) {
|
|
|
7722
7722
|
}
|
|
7723
7723
|
});
|
|
7724
7724
|
}
|
|
7725
|
-
|
|
7725
|
+
const Tl = [
|
|
7726
|
+
"swap",
|
|
7727
|
+
"add_liq",
|
|
7728
|
+
"remove_liq",
|
|
7729
|
+
"deposit",
|
|
7730
|
+
"withdraw",
|
|
7731
|
+
"unwrap"
|
|
7732
|
+
];
|
|
7733
|
+
async function Il(e) {
|
|
7726
7734
|
if (e.limit !== void 0) {
|
|
7727
7735
|
if (e.limit > 200)
|
|
7728
7736
|
throw new Error("Limit cannot exceed 200");
|
|
@@ -7731,8 +7739,15 @@ async function Tl(e) {
|
|
|
7731
7739
|
}
|
|
7732
7740
|
if (e.offset !== void 0 && (!Number.isInteger(e.offset) || e.offset < 0))
|
|
7733
7741
|
throw new Error("Offset must be a non-negative integer");
|
|
7734
|
-
|
|
7735
|
-
|
|
7742
|
+
if (e.kinds !== void 0) {
|
|
7743
|
+
if (e.kinds.length === 0)
|
|
7744
|
+
throw new Error("Kinds must name at least one kind");
|
|
7745
|
+
const s = e.kinds.find((i) => !Tl.includes(i));
|
|
7746
|
+
if (s !== void 0)
|
|
7747
|
+
throw new Error(`Unknown activity kind: ${s}`);
|
|
7748
|
+
}
|
|
7749
|
+
const t = new URLSearchParams();
|
|
7750
|
+
e.pairAddress !== void 0 && t.set("pairAddress", e.pairAddress), e.limit !== void 0 && t.set("limit", String(e.limit)), e.offset !== void 0 && t.set("offset", String(e.offset)), e.kinds !== void 0 && t.set("kinds", e.kinds.join(","));
|
|
7736
7751
|
const n = J(`wallet-activity/${encodeURIComponent(e.pubkey)}?${t}`);
|
|
7737
7752
|
return await X(n, {
|
|
7738
7753
|
method: "GET",
|
|
@@ -7753,7 +7768,7 @@ async function wn(e) {
|
|
|
7753
7768
|
})
|
|
7754
7769
|
})).result;
|
|
7755
7770
|
}
|
|
7756
|
-
async function
|
|
7771
|
+
async function xo(e) {
|
|
7757
7772
|
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();
|
|
7758
7773
|
const t = `Deposit Order:
|
|
7759
7774
|
Bitcoin Address: ${e.btc_address}
|
|
@@ -7797,7 +7812,7 @@ async function So(e) {
|
|
|
7797
7812
|
body: JSON.stringify(e)
|
|
7798
7813
|
});
|
|
7799
7814
|
}
|
|
7800
|
-
async function
|
|
7815
|
+
async function Rl(e) {
|
|
7801
7816
|
const t = J("deposit");
|
|
7802
7817
|
return X(t, {
|
|
7803
7818
|
method: "POST",
|
|
@@ -7826,10 +7841,10 @@ function Bo(e, t) {
|
|
|
7826
7841
|
function vo(e) {
|
|
7827
7842
|
return e ? e.reduce((t, n) => t + n.amount, 0n) : 0n;
|
|
7828
7843
|
}
|
|
7829
|
-
async function
|
|
7844
|
+
async function kl(e, t, n, r = !0, s, i = {}) {
|
|
7830
7845
|
const o = yn();
|
|
7831
7846
|
if (!o || !o.wallets) throw new Error("Wallets not found");
|
|
7832
|
-
const a =
|
|
7847
|
+
const a = ze(), c = Zn(), u = Wt();
|
|
7833
7848
|
if (!c) throw new Error("Payment wallet not found");
|
|
7834
7849
|
if (!c.address) throw new Error("Payment wallet address not found");
|
|
7835
7850
|
if (!u) throw new Error("Ordinals wallet not found");
|
|
@@ -7838,7 +7853,7 @@ async function Rl(e, t, n, r = !0, s, i = {}) {
|
|
|
7838
7853
|
let w = 0n, h = 0, g = "";
|
|
7839
7854
|
const b = await mo(e);
|
|
7840
7855
|
if (b < t) {
|
|
7841
|
-
const At = await
|
|
7856
|
+
const At = await _o(e), te = At.available_balance_in_18_dec;
|
|
7842
7857
|
h = At.decimals, g = At.ticker, w = t - b;
|
|
7843
7858
|
const ee = vo(s);
|
|
7844
7859
|
if (te + ee < w)
|
|
@@ -7856,24 +7871,24 @@ async function Rl(e, t, n, r = !0, s, i = {}) {
|
|
|
7856
7871
|
const F = new Hr(
|
|
7857
7872
|
i,
|
|
7858
7873
|
3 + (w > 0n ? 2 : 0) + (O ? 2 : 0)
|
|
7859
|
-
), M = F.wrap(Ir(o.provider)), A = rr(), C = `0x095ea7b3000000000000000000000000${A.slice(2).toLowerCase()}ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`, I = await Xe(C),
|
|
7874
|
+
), M = F.wrap(Ir(o.provider)), A = rr(), C = `0x095ea7b3000000000000000000000000${A.slice(2).toLowerCase()}ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`, I = await Xe(C), _ = z.str(
|
|
7860
7875
|
`{"p":"brc20-prog","op":"c","c":"${e}","b":"${I}"}`
|
|
7861
7876
|
), D = new ce(
|
|
7862
|
-
|
|
7877
|
+
z.str("text/plain"),
|
|
7863
7878
|
null,
|
|
7864
7879
|
null,
|
|
7865
7880
|
null,
|
|
7866
7881
|
null,
|
|
7867
|
-
|
|
7882
|
+
_
|
|
7868
7883
|
), H = (await et())?.swapPubkey;
|
|
7869
7884
|
if (!H)
|
|
7870
7885
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
7871
7886
|
F.next();
|
|
7872
|
-
const U = await
|
|
7887
|
+
const U = await xo({
|
|
7873
7888
|
btc_address: d,
|
|
7874
7889
|
bls_pubkey: H,
|
|
7875
7890
|
token_address: e
|
|
7876
|
-
}), y = bn.address.toOutputScript(d,
|
|
7891
|
+
}), y = bn.address.toOutputScript(d, ze()), x = await Eo({
|
|
7877
7892
|
pubkey: H,
|
|
7878
7893
|
ordinals_script: y.toString("hex")
|
|
7879
7894
|
}), B = await So({
|
|
@@ -7881,7 +7896,7 @@ async function Rl(e, t, n, r = !0, s, i = {}) {
|
|
|
7881
7896
|
bls_pubkey: H,
|
|
7882
7897
|
token_address: e.toLowerCase(),
|
|
7883
7898
|
bip322_signature: U,
|
|
7884
|
-
bls12_signature:
|
|
7899
|
+
bls12_signature: x
|
|
7885
7900
|
}), R = B.edcsa_signature, P = B.pubkey_idx, $ = B.token_idx, q = await ir({
|
|
7886
7901
|
pubkey: H,
|
|
7887
7902
|
pk_idx: BigInt(P)
|
|
@@ -7893,33 +7908,33 @@ async function Rl(e, t, n, r = !0, s, i = {}) {
|
|
|
7893
7908
|
BigInt(P),
|
|
7894
7909
|
q,
|
|
7895
7910
|
R
|
|
7896
|
-
]), Z = await Xe(W), ct =
|
|
7911
|
+
]), Z = await Xe(W), ct = z.str(
|
|
7897
7912
|
`{"p":"brc20-prog","op":"c","c":"${A}","b":"${Z}"}`
|
|
7898
7913
|
), j = new ce(
|
|
7899
|
-
|
|
7914
|
+
z.str("text/plain"),
|
|
7900
7915
|
null,
|
|
7901
7916
|
null,
|
|
7902
7917
|
null,
|
|
7903
7918
|
null,
|
|
7904
7919
|
ct
|
|
7905
7920
|
);
|
|
7906
|
-
let G = null, ut = null, gt = null,
|
|
7921
|
+
let G = null, ut = null, gt = null, xt = null, Q = null, rt = null, jt = null, Be = null, Qt = null;
|
|
7907
7922
|
if (w > 0n) {
|
|
7908
7923
|
const At = Bo(
|
|
7909
7924
|
w,
|
|
7910
7925
|
h
|
|
7911
7926
|
), te = new ce(
|
|
7912
|
-
|
|
7927
|
+
z.str("text/plain"),
|
|
7913
7928
|
null,
|
|
7914
7929
|
null,
|
|
7915
7930
|
null,
|
|
7916
7931
|
null,
|
|
7917
|
-
|
|
7932
|
+
z.str(
|
|
7918
7933
|
`{"p":"brc-20","op":"transfer","tick":"${g}","amt":"${At}"}`
|
|
7919
7934
|
)
|
|
7920
7935
|
);
|
|
7921
7936
|
if ((s?.length ?? 0) > 0) {
|
|
7922
|
-
const On = await
|
|
7937
|
+
const On = await zs(s, d), Ie = await Ho(
|
|
7923
7938
|
te,
|
|
7924
7939
|
On,
|
|
7925
7940
|
n,
|
|
@@ -7945,7 +7960,7 @@ async function Rl(e, t, n, r = !0, s, i = {}) {
|
|
|
7945
7960
|
!0,
|
|
7946
7961
|
M
|
|
7947
7962
|
);
|
|
7948
|
-
Q = Qt.signed_commit_tx_hex, rt = Qt.signed_reveal_tx_hex, gt = Qt.commit_txid,
|
|
7963
|
+
Q = Qt.signed_commit_tx_hex, rt = Qt.signed_reveal_tx_hex, gt = Qt.commit_txid, xt = Qt.reveal_txid, G = Qt.inscription_id;
|
|
7949
7964
|
const ee = `${G.split("i")[0]}:0:0`;
|
|
7950
7965
|
ut = Qt.secret;
|
|
7951
7966
|
let Me = null;
|
|
@@ -7958,7 +7973,7 @@ async function Rl(e, t, n, r = !0, s, i = {}) {
|
|
|
7958
7973
|
);
|
|
7959
7974
|
const On = new Ut(
|
|
7960
7975
|
!0,
|
|
7961
|
-
S.from(me.encode(["OP_RETURN",
|
|
7976
|
+
S.from(me.encode(["OP_RETURN", z.str("BRC20PROG")], !1)),
|
|
7962
7977
|
null,
|
|
7963
7978
|
null,
|
|
7964
7979
|
null
|
|
@@ -8014,7 +8029,7 @@ async function Rl(e, t, n, r = !0, s, i = {}) {
|
|
|
8014
8029
|
At.push(St, Nt), Ft(At, [lt, te]);
|
|
8015
8030
|
const Me = new Ut(
|
|
8016
8031
|
!0,
|
|
8017
|
-
S.from(me.encode(["OP_RETURN",
|
|
8032
|
+
S.from(me.encode(["OP_RETURN", z.str("BRC20PROG")], !1)),
|
|
8018
8033
|
null,
|
|
8019
8034
|
null,
|
|
8020
8035
|
null
|
|
@@ -8082,7 +8097,7 @@ async function Rl(e, t, n, r = !0, s, i = {}) {
|
|
|
8082
8097
|
Yr = Te.secret, De.push(cr, ur), Ft(De, [sn, At]);
|
|
8083
8098
|
const te = new Ut(
|
|
8084
8099
|
!0,
|
|
8085
|
-
S.from(me.encode(["OP_RETURN",
|
|
8100
|
+
S.from(me.encode(["OP_RETURN", z.str("BRC20PROG")], !1)),
|
|
8086
8101
|
null,
|
|
8087
8102
|
null,
|
|
8088
8103
|
null
|
|
@@ -8126,7 +8141,7 @@ async function Rl(e, t, n, r = !0, s, i = {}) {
|
|
|
8126
8141
|
base_deposit_details: w > 0n ? {
|
|
8127
8142
|
commit_txid: gt,
|
|
8128
8143
|
commit_txhex: Q,
|
|
8129
|
-
reveal_txid:
|
|
8144
|
+
reveal_txid: xt,
|
|
8130
8145
|
reveal_txhex: rt,
|
|
8131
8146
|
send_to_opreturn_txid: Be,
|
|
8132
8147
|
send_to_opreturn_txhex: jt,
|
|
@@ -8135,19 +8150,19 @@ async function Rl(e, t, n, r = !0, s, i = {}) {
|
|
|
8135
8150
|
fee_rate: n
|
|
8136
8151
|
} : null
|
|
8137
8152
|
};
|
|
8138
|
-
return (await
|
|
8153
|
+
return (await Rl(qo)).result;
|
|
8139
8154
|
}
|
|
8140
|
-
async function
|
|
8155
|
+
async function Nl(e, t, n, r = !0, s) {
|
|
8141
8156
|
const i = yn();
|
|
8142
8157
|
if (!i || !i.wallets) throw new Error("Wallets not found");
|
|
8143
|
-
const o =
|
|
8158
|
+
const o = ze(), a = Zn();
|
|
8144
8159
|
if (!a) throw new Error("Payment wallet not found");
|
|
8145
8160
|
if (!a.address) throw new Error("Payment wallet address not found");
|
|
8146
8161
|
const c = a.address, u = a.pubkey, l = new Ut(!1, null, c, null, u);
|
|
8147
8162
|
let f = 0n, d = 0, p = "";
|
|
8148
8163
|
const w = await mo(e);
|
|
8149
8164
|
if (w < t) {
|
|
8150
|
-
const lt = await
|
|
8165
|
+
const lt = await _o(e), Lt = lt.available_balance_in_18_dec;
|
|
8151
8166
|
d = lt.decimals, p = lt.ticker, f = t - w;
|
|
8152
8167
|
const dt = vo(s);
|
|
8153
8168
|
if (Lt + dt < f)
|
|
@@ -8162,10 +8177,10 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8162
8177
|
throw console.error("Insufficient allowance for BRC-2.0 token transfer."), new Error("Insufficient allowance for BRC-2.0 token transfer.");
|
|
8163
8178
|
g = !0;
|
|
8164
8179
|
}
|
|
8165
|
-
const b = rr(), v = `0x095ea7b3000000000000000000000000${b.slice(2).toLowerCase()}ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`, O = await Xe(v), F =
|
|
8180
|
+
const b = rr(), v = `0x095ea7b3000000000000000000000000${b.slice(2).toLowerCase()}ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`, O = await Xe(v), F = z.str(
|
|
8166
8181
|
`{"p":"brc20-prog","op":"c","c":"${e}","b":"${O}"}`
|
|
8167
8182
|
), M = new ce(
|
|
8168
|
-
|
|
8183
|
+
z.str("text/plain"),
|
|
8169
8184
|
null,
|
|
8170
8185
|
null,
|
|
8171
8186
|
null,
|
|
@@ -8174,39 +8189,39 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8174
8189
|
), A = (await et())?.swapPubkey;
|
|
8175
8190
|
if (!A)
|
|
8176
8191
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
8177
|
-
const C = `0x${"00".repeat(64)}`, I = 1,
|
|
8192
|
+
const C = `0x${"00".repeat(64)}`, I = 1, _ = 1, D = await ir({
|
|
8178
8193
|
pubkey: A,
|
|
8179
8194
|
pk_idx: BigInt(I)
|
|
8180
8195
|
}), U = wo().encodeFunctionData("deposit", [
|
|
8181
8196
|
e,
|
|
8182
|
-
|
|
8197
|
+
_,
|
|
8183
8198
|
t,
|
|
8184
8199
|
A,
|
|
8185
8200
|
BigInt(I),
|
|
8186
8201
|
D,
|
|
8187
8202
|
C
|
|
8188
|
-
]), y = await Xe(U),
|
|
8203
|
+
]), y = await Xe(U), x = z.str(
|
|
8189
8204
|
`{"p":"brc20-prog","op":"c","c":"${b}","b":"${y}"}`
|
|
8190
8205
|
), B = new ce(
|
|
8191
|
-
|
|
8206
|
+
z.str("text/plain"),
|
|
8192
8207
|
null,
|
|
8193
8208
|
null,
|
|
8194
8209
|
null,
|
|
8195
8210
|
null,
|
|
8196
|
-
|
|
8197
|
-
), R = await
|
|
8211
|
+
x
|
|
8212
|
+
), R = await Ks(c);
|
|
8198
8213
|
let P = null, $ = null, q = null, k = null, W = null, Z = 0;
|
|
8199
8214
|
if (f > 0n) {
|
|
8200
8215
|
const lt = Bo(
|
|
8201
8216
|
f,
|
|
8202
8217
|
d
|
|
8203
8218
|
), Lt = new ce(
|
|
8204
|
-
|
|
8219
|
+
z.str("text/plain"),
|
|
8205
8220
|
null,
|
|
8206
8221
|
null,
|
|
8207
8222
|
null,
|
|
8208
8223
|
null,
|
|
8209
|
-
|
|
8224
|
+
z.str(
|
|
8210
8225
|
`{"p":"brc-20","op":"transfer","tick":"${p}","amt":"${lt}"}`
|
|
8211
8226
|
)
|
|
8212
8227
|
);
|
|
@@ -8215,7 +8230,7 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8215
8230
|
const Nt = Wt();
|
|
8216
8231
|
if (!Nt) throw new Error("Ordinals wallet not found");
|
|
8217
8232
|
if (!Nt.address) throw new Error("Ordinals wallet address not found");
|
|
8218
|
-
const ve = Nt.address, rn = await
|
|
8233
|
+
const ve = Nt.address, rn = await zs(s, ve);
|
|
8219
8234
|
dt = await Go(
|
|
8220
8235
|
Lt,
|
|
8221
8236
|
rn,
|
|
@@ -8224,7 +8239,7 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8224
8239
|
R
|
|
8225
8240
|
);
|
|
8226
8241
|
} else
|
|
8227
|
-
dt = await
|
|
8242
|
+
dt = await zr(
|
|
8228
8243
|
Lt,
|
|
8229
8244
|
n,
|
|
8230
8245
|
null,
|
|
@@ -8244,7 +8259,7 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8244
8259
|
);
|
|
8245
8260
|
const Nt = new Ut(
|
|
8246
8261
|
!0,
|
|
8247
|
-
S.from(me.encode(["OP_RETURN",
|
|
8262
|
+
S.from(me.encode(["OP_RETURN", z.str("BRC20PROG")], !1)),
|
|
8248
8263
|
null,
|
|
8249
8264
|
null,
|
|
8250
8265
|
null
|
|
@@ -8270,7 +8285,7 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8270
8285
|
throw new Error("Failed to send inscription to OP_RETURN");
|
|
8271
8286
|
k = St.unsigned_tx_hex, W = St.txid, Z += St.tx_fee;
|
|
8272
8287
|
}
|
|
8273
|
-
let ct = null, j = null, G = null, ut = null, gt = null,
|
|
8288
|
+
let ct = null, j = null, G = null, ut = null, gt = null, xt = 0;
|
|
8274
8289
|
if (g) {
|
|
8275
8290
|
const lt = [];
|
|
8276
8291
|
f > 0n && lt.push(
|
|
@@ -8280,7 +8295,7 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8280
8295
|
);
|
|
8281
8296
|
try {
|
|
8282
8297
|
Ft(lt, null);
|
|
8283
|
-
const Et = await
|
|
8298
|
+
const Et = await zr(
|
|
8284
8299
|
M,
|
|
8285
8300
|
n,
|
|
8286
8301
|
null,
|
|
@@ -8288,7 +8303,7 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8288
8303
|
0,
|
|
8289
8304
|
R
|
|
8290
8305
|
);
|
|
8291
|
-
j = Et.unsigned_commit_tx_hex, G = Et.signed_reveal_tx_hex, ct = Et.inscription_id,
|
|
8306
|
+
j = Et.unsigned_commit_tx_hex, G = Et.signed_reveal_tx_hex, ct = Et.inscription_id, xt += Et.total_fee;
|
|
8292
8307
|
} finally {
|
|
8293
8308
|
Yt();
|
|
8294
8309
|
}
|
|
@@ -8300,7 +8315,7 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8300
8315
|
lt.push(j, G), Ft(lt, [ct, Lt]);
|
|
8301
8316
|
const Et = new Ut(
|
|
8302
8317
|
!0,
|
|
8303
|
-
S.from(me.encode(["OP_RETURN",
|
|
8318
|
+
S.from(me.encode(["OP_RETURN", z.str("BRC20PROG")], !1)),
|
|
8304
8319
|
null,
|
|
8305
8320
|
null,
|
|
8306
8321
|
null
|
|
@@ -8324,7 +8339,7 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8324
8339
|
}
|
|
8325
8340
|
if (dt == null)
|
|
8326
8341
|
throw new Error("Failed to send inscription to OP_RETURN");
|
|
8327
|
-
ut = dt.unsigned_tx_hex, gt = dt.txid,
|
|
8342
|
+
ut = dt.unsigned_tx_hex, gt = dt.txid, xt += dt.tx_fee;
|
|
8328
8343
|
}
|
|
8329
8344
|
const Q = [], rt = [];
|
|
8330
8345
|
if (f > 0n) {
|
|
@@ -8366,7 +8381,7 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8366
8381
|
jt += lt.total_fee, rt.push(Lt, dt), Ft(rt, [Et, St]);
|
|
8367
8382
|
const Nt = new Ut(
|
|
8368
8383
|
!0,
|
|
8369
|
-
S.from(me.encode(["OP_RETURN",
|
|
8384
|
+
S.from(me.encode(["OP_RETURN", z.str("BRC20PROG")], !1)),
|
|
8370
8385
|
null,
|
|
8371
8386
|
null,
|
|
8372
8387
|
null
|
|
@@ -8388,12 +8403,12 @@ async function kl(e, t, n, r = !0, s) {
|
|
|
8388
8403
|
return jt += Be.tx_fee, {
|
|
8389
8404
|
needs_approval: g,
|
|
8390
8405
|
base_deposit_fees_total: Z,
|
|
8391
|
-
allowance_fees_total:
|
|
8406
|
+
allowance_fees_total: xt,
|
|
8392
8407
|
deposit_fees_total: jt,
|
|
8393
8408
|
fee_rate: n
|
|
8394
8409
|
};
|
|
8395
8410
|
}
|
|
8396
|
-
async function
|
|
8411
|
+
async function Cl(e) {
|
|
8397
8412
|
const t = J("wrap");
|
|
8398
8413
|
return X(t, {
|
|
8399
8414
|
method: "POST",
|
|
@@ -8403,7 +8418,7 @@ async function Nl(e) {
|
|
|
8403
8418
|
body: JSON.stringify(e)
|
|
8404
8419
|
});
|
|
8405
8420
|
}
|
|
8406
|
-
async function
|
|
8421
|
+
async function $l(e) {
|
|
8407
8422
|
const t = J("estimate_wrap_gas");
|
|
8408
8423
|
return X(t, {
|
|
8409
8424
|
method: "POST",
|
|
@@ -8413,7 +8428,7 @@ async function Cl(e) {
|
|
|
8413
8428
|
body: JSON.stringify(e)
|
|
8414
8429
|
});
|
|
8415
8430
|
}
|
|
8416
|
-
async function
|
|
8431
|
+
async function Ll(e, t, n = {}) {
|
|
8417
8432
|
const r = await Jt(), s = yn();
|
|
8418
8433
|
if (!s || !s.wallets) throw new Error("Wallets not found");
|
|
8419
8434
|
const i = new Hr(n), o = i.wrap(Ir(s.provider)), a = Zn(), c = Wt();
|
|
@@ -8425,11 +8440,11 @@ async function $l(e, t, n = {}) {
|
|
|
8425
8440
|
if (!f)
|
|
8426
8441
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
8427
8442
|
i.next();
|
|
8428
|
-
const d = await
|
|
8443
|
+
const d = await xo({
|
|
8429
8444
|
btc_address: u,
|
|
8430
8445
|
bls_pubkey: f,
|
|
8431
8446
|
token_address: r.wbtc_address
|
|
8432
|
-
}), p = bn.address.toOutputScript(u,
|
|
8447
|
+
}), p = bn.address.toOutputScript(u, ze()), w = await Eo({
|
|
8433
8448
|
pubkey: f,
|
|
8434
8449
|
ordinals_script: p.toString("hex")
|
|
8435
8450
|
}), h = await So({
|
|
@@ -8454,22 +8469,22 @@ async function $l(e, t, n = {}) {
|
|
|
8454
8469
|
), A = `0x5608f857${fe.defaultAbiCoder().encode(
|
|
8455
8470
|
["address", "bytes"],
|
|
8456
8471
|
[l, S.from(F.slice(2), "hex")]
|
|
8457
|
-
).slice(2)}`, C = await Xe(A), I =
|
|
8472
|
+
).slice(2)}`, C = await Xe(A), I = z.str(
|
|
8458
8473
|
`{"p":"brc20-prog","op":"c","c":"${r.wbtc_address}","b":"${C}"}`
|
|
8459
8474
|
);
|
|
8460
|
-
let
|
|
8475
|
+
let _ = 0;
|
|
8461
8476
|
for (let D = 0; D < 5; D++) {
|
|
8462
|
-
const H = I.length * Hs, U =
|
|
8463
|
-
S.concat([I,
|
|
8464
|
-
),
|
|
8465
|
-
|
|
8477
|
+
const H = I.length * Hs, U = _ > H ? Math.ceil((_ - H) / Hs) : 0, y = z.from(
|
|
8478
|
+
S.concat([I, z.str(" ".repeat(U))])
|
|
8479
|
+
), x = new ce(
|
|
8480
|
+
z.str("text/plain"),
|
|
8466
8481
|
null,
|
|
8467
8482
|
null,
|
|
8468
8483
|
null,
|
|
8469
8484
|
null,
|
|
8470
8485
|
y
|
|
8471
8486
|
), B = await Js(
|
|
8472
|
-
|
|
8487
|
+
x,
|
|
8473
8488
|
[],
|
|
8474
8489
|
t,
|
|
8475
8490
|
null,
|
|
@@ -8484,9 +8499,9 @@ async function $l(e, t, n = {}) {
|
|
|
8484
8499
|
[R, P],
|
|
8485
8500
|
[$, q]
|
|
8486
8501
|
);
|
|
8487
|
-
const
|
|
8502
|
+
const xt = new Ut(
|
|
8488
8503
|
!0,
|
|
8489
|
-
S.from(me.encode(["OP_RETURN",
|
|
8504
|
+
S.from(me.encode(["OP_RETURN", z.str("BRC20PROG")], !1)),
|
|
8490
8505
|
null,
|
|
8491
8506
|
null,
|
|
8492
8507
|
null
|
|
@@ -8500,7 +8515,7 @@ async function $l(e, t, n = {}) {
|
|
|
8500
8515
|
W = await Ln(
|
|
8501
8516
|
$,
|
|
8502
8517
|
[],
|
|
8503
|
-
|
|
8518
|
+
xt,
|
|
8504
8519
|
1,
|
|
8505
8520
|
Q,
|
|
8506
8521
|
t,
|
|
@@ -8522,19 +8537,19 @@ async function $l(e, t, n = {}) {
|
|
|
8522
8537
|
secret: k,
|
|
8523
8538
|
inscription_id: $,
|
|
8524
8539
|
fee_rate: t
|
|
8525
|
-
}, G = await
|
|
8540
|
+
}, G = await $l(j), ut = Math.max(
|
|
8526
8541
|
G.estimated_gas + 1e5,
|
|
8527
8542
|
G.estimated_gas * 1.2
|
|
8528
8543
|
);
|
|
8529
8544
|
if (G.allocated_gas < ut) {
|
|
8530
|
-
|
|
8545
|
+
_ = ut + 5e4;
|
|
8531
8546
|
continue;
|
|
8532
8547
|
}
|
|
8533
|
-
return (await
|
|
8548
|
+
return (await Cl(j)).result;
|
|
8534
8549
|
}
|
|
8535
8550
|
throw new Error("Failed to estimate gas for wrap order after multiple attempts");
|
|
8536
8551
|
}
|
|
8537
|
-
async function
|
|
8552
|
+
async function Al(e, t) {
|
|
8538
8553
|
const n = await Jt(), r = yn();
|
|
8539
8554
|
if (!r || !r.wallets) throw new Error("Wallets not found");
|
|
8540
8555
|
const s = Zn();
|
|
@@ -8559,16 +8574,16 @@ async function Ll(e, t) {
|
|
|
8559
8574
|
), p = `0x5608f857${fe.defaultAbiCoder().encode(
|
|
8560
8575
|
["address", "bytes"],
|
|
8561
8576
|
[i, S.from(f.slice(2), "hex")]
|
|
8562
|
-
).slice(2)}`, w = await Xe(p), h =
|
|
8577
|
+
).slice(2)}`, w = await Xe(p), h = z.str(
|
|
8563
8578
|
`{"p":"brc20-prog","op":"c","c":"${n.wbtc_address}","b":"${w}"}`
|
|
8564
8579
|
), g = new ce(
|
|
8565
|
-
|
|
8580
|
+
z.str("text/plain"),
|
|
8566
8581
|
null,
|
|
8567
8582
|
null,
|
|
8568
8583
|
null,
|
|
8569
8584
|
null,
|
|
8570
8585
|
h
|
|
8571
|
-
), b = await
|
|
8586
|
+
), b = await Ks(s.address);
|
|
8572
8587
|
let v = 0;
|
|
8573
8588
|
const O = await Xs(
|
|
8574
8589
|
g,
|
|
@@ -8588,7 +8603,7 @@ async function Ll(e, t) {
|
|
|
8588
8603
|
);
|
|
8589
8604
|
const D = new Ut(
|
|
8590
8605
|
!0,
|
|
8591
|
-
S.from(me.encode(["OP_RETURN",
|
|
8606
|
+
S.from(me.encode(["OP_RETURN", z.str("BRC20PROG")], !1)),
|
|
8592
8607
|
null,
|
|
8593
8608
|
null,
|
|
8594
8609
|
null
|
|
@@ -8618,7 +8633,7 @@ async function Ll(e, t) {
|
|
|
8618
8633
|
fee_rate: t
|
|
8619
8634
|
};
|
|
8620
8635
|
}
|
|
8621
|
-
async function
|
|
8636
|
+
async function Pl(e, t, n, r) {
|
|
8622
8637
|
const s = await Jt();
|
|
8623
8638
|
er(s.wbtc_address, s.factory_address);
|
|
8624
8639
|
const i = (await et())?.swapPubkey;
|
|
@@ -8655,7 +8670,7 @@ async function Al(e, t, n, r) {
|
|
|
8655
8670
|
throw new Error("No data returned from add liquidity request.");
|
|
8656
8671
|
return c.data;
|
|
8657
8672
|
}
|
|
8658
|
-
async function
|
|
8673
|
+
async function Fl(e) {
|
|
8659
8674
|
e.token1_addr = e.token1_addr.toLowerCase(), e.token2_addr = e.token2_addr.toLowerCase();
|
|
8660
8675
|
const t = `Add Liquidity Order:
|
|
8661
8676
|
Token 1 Address: ${e.token1_addr}
|
|
@@ -8671,7 +8686,7 @@ BTC Fee: ${e.btc_fee}
|
|
|
8671
8686
|
By signing this message, you authorize the creation of an add liquidity order with the above parameters.`;
|
|
8672
8687
|
return await Pe(t, "ordinals");
|
|
8673
8688
|
}
|
|
8674
|
-
async function
|
|
8689
|
+
async function Ul(e) {
|
|
8675
8690
|
e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
|
|
8676
8691
|
let t = tt(S.from(e.pubkey, "hex")).slice(2);
|
|
8677
8692
|
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");
|
|
@@ -8683,7 +8698,7 @@ async function Fl(e) {
|
|
|
8683
8698
|
const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = S.from(i, "hex"), a = T.shortSignatures.sign(r, o);
|
|
8684
8699
|
return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
|
|
8685
8700
|
}
|
|
8686
|
-
async function
|
|
8701
|
+
async function ql(e) {
|
|
8687
8702
|
const t = J("add_liq_req");
|
|
8688
8703
|
return X(t, {
|
|
8689
8704
|
method: "POST",
|
|
@@ -8693,11 +8708,11 @@ async function Ul(e) {
|
|
|
8693
8708
|
body: JSON.stringify(e)
|
|
8694
8709
|
});
|
|
8695
8710
|
}
|
|
8696
|
-
async function
|
|
8711
|
+
async function Dl(e, t, n, r, s) {
|
|
8697
8712
|
const i = (await et())?.swapPubkey;
|
|
8698
8713
|
if (!i)
|
|
8699
8714
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
8700
|
-
const o = n * (10000n - s) / 10000n, a = r * (10000n - s) / 10000n, c = 0n, u = 0n, l = await qe(), f = await $t("add_liquidity"), d = await
|
|
8715
|
+
const o = n * (10000n - s) / 10000n, a = r * (10000n - s) / 10000n, c = 0n, u = 0n, l = await qe(), f = await $t("add_liquidity"), d = await Fl({
|
|
8701
8716
|
token1_addr: e,
|
|
8702
8717
|
token2_addr: t,
|
|
8703
8718
|
amt1: n.toString(),
|
|
@@ -8707,7 +8722,7 @@ async function ql(e, t, n, r, s) {
|
|
|
8707
8722
|
token1FeeBps: c.toString(),
|
|
8708
8723
|
token2FeeBps: u.toString(),
|
|
8709
8724
|
btc_fee: f.toString()
|
|
8710
|
-
}), p = await
|
|
8725
|
+
}), p = await Ul({
|
|
8711
8726
|
pubkey: i,
|
|
8712
8727
|
nonce: l,
|
|
8713
8728
|
token1_addr: e,
|
|
@@ -8720,7 +8735,7 @@ async function ql(e, t, n, r, s) {
|
|
|
8720
8735
|
token2FeeBps: u,
|
|
8721
8736
|
btc_fee: f
|
|
8722
8737
|
});
|
|
8723
|
-
return await
|
|
8738
|
+
return await ql({
|
|
8724
8739
|
pubkey: i,
|
|
8725
8740
|
token1_addr: e,
|
|
8726
8741
|
token2_addr: t,
|
|
@@ -8735,7 +8750,7 @@ async function ql(e, t, n, r, s) {
|
|
|
8735
8750
|
bip322_signature: d
|
|
8736
8751
|
});
|
|
8737
8752
|
}
|
|
8738
|
-
async function
|
|
8753
|
+
async function Ml(e, t, n) {
|
|
8739
8754
|
const r = await Jt();
|
|
8740
8755
|
er(r.wbtc_address, r.factory_address);
|
|
8741
8756
|
const s = (await et())?.swapPubkey;
|
|
@@ -8771,7 +8786,7 @@ async function Dl(e, t, n) {
|
|
|
8771
8786
|
throw new Error("No data returned from remove liquidity request.");
|
|
8772
8787
|
return a.data;
|
|
8773
8788
|
}
|
|
8774
|
-
async function
|
|
8789
|
+
async function Wl(e) {
|
|
8775
8790
|
e.token1_addr = e.token1_addr.toLowerCase(), e.token2_addr = e.token2_addr.toLowerCase();
|
|
8776
8791
|
const t = `Remove Liquidity Order:
|
|
8777
8792
|
Token 1 Address: ${e.token1_addr}
|
|
@@ -8786,7 +8801,7 @@ BTC Fee: ${e.btc_fee}
|
|
|
8786
8801
|
By signing this message, you authorize the creation of a remove liquidity order with the above parameters.`;
|
|
8787
8802
|
return await Pe(t, "ordinals");
|
|
8788
8803
|
}
|
|
8789
|
-
async function
|
|
8804
|
+
async function Gl(e) {
|
|
8790
8805
|
e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
|
|
8791
8806
|
let t = tt(S.from(e.pubkey, "hex")).slice(2);
|
|
8792
8807
|
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");
|
|
@@ -8798,7 +8813,7 @@ async function Wl(e) {
|
|
|
8798
8813
|
const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = S.from(i, "hex"), a = T.shortSignatures.sign(r, o);
|
|
8799
8814
|
return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
|
|
8800
8815
|
}
|
|
8801
|
-
async function
|
|
8816
|
+
async function Hl(e) {
|
|
8802
8817
|
const t = J("remove_liq_req");
|
|
8803
8818
|
return X(t, {
|
|
8804
8819
|
method: "POST",
|
|
@@ -8808,11 +8823,11 @@ async function Gl(e) {
|
|
|
8808
8823
|
body: JSON.stringify(e)
|
|
8809
8824
|
});
|
|
8810
8825
|
}
|
|
8811
|
-
async function
|
|
8826
|
+
async function Vl(e, t, n, r, s, i) {
|
|
8812
8827
|
const o = (await et())?.swapPubkey;
|
|
8813
8828
|
if (!o)
|
|
8814
8829
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
8815
|
-
const a = r * (10000n - i) / 10000n, c = s * (10000n - i) / 10000n, u = 0n, l = 0n, f = await qe(), d = await $t("remove_liquidity"), p = await
|
|
8830
|
+
const a = r * (10000n - i) / 10000n, c = s * (10000n - i) / 10000n, u = 0n, l = 0n, f = await qe(), d = await $t("remove_liquidity"), p = await Wl({
|
|
8816
8831
|
token1_addr: e,
|
|
8817
8832
|
token2_addr: t,
|
|
8818
8833
|
lp_amt: n.toString(),
|
|
@@ -8821,7 +8836,7 @@ async function Hl(e, t, n, r, s, i) {
|
|
|
8821
8836
|
token1FeeBps: u.toString(),
|
|
8822
8837
|
token2FeeBps: l.toString(),
|
|
8823
8838
|
btc_fee: d.toString()
|
|
8824
|
-
}), w = await
|
|
8839
|
+
}), w = await Gl({
|
|
8825
8840
|
pubkey: o,
|
|
8826
8841
|
nonce: f,
|
|
8827
8842
|
token1_addr: e,
|
|
@@ -8833,7 +8848,7 @@ async function Hl(e, t, n, r, s, i) {
|
|
|
8833
8848
|
token2FeeBps: l,
|
|
8834
8849
|
btc_fee: d
|
|
8835
8850
|
});
|
|
8836
|
-
return await
|
|
8851
|
+
return await Hl({
|
|
8837
8852
|
pubkey: o,
|
|
8838
8853
|
token1_addr: e,
|
|
8839
8854
|
token2_addr: t,
|
|
@@ -8855,7 +8870,7 @@ async function or(e, t) {
|
|
|
8855
8870
|
}
|
|
8856
8871
|
return Cu(e, t, n.fee_policy);
|
|
8857
8872
|
}
|
|
8858
|
-
async function
|
|
8873
|
+
async function Zl(e, t, n) {
|
|
8859
8874
|
const r = await Jt();
|
|
8860
8875
|
await sr(e, t);
|
|
8861
8876
|
const s = (await et())?.swapPubkey;
|
|
@@ -8903,7 +8918,7 @@ async function Vl(e, t, n) {
|
|
|
8903
8918
|
fees: co(n, u.amounts[1], a, c, o)
|
|
8904
8919
|
};
|
|
8905
8920
|
}
|
|
8906
|
-
async function
|
|
8921
|
+
async function Yl(e) {
|
|
8907
8922
|
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;
|
|
8908
8923
|
const t = `Swap Order:
|
|
8909
8924
|
Token 1 Address: ${e.token1_addr}
|
|
@@ -8919,7 +8934,7 @@ ${e.referrer_pubkey ? `Referrer Pubkey: ${e.referrer_pubkey}
|
|
|
8919
8934
|
By signing this message, you authorize the creation of a swap order with the above parameters.`;
|
|
8920
8935
|
return await Pe(t, "ordinals");
|
|
8921
8936
|
}
|
|
8922
|
-
async function
|
|
8937
|
+
async function Kl(e) {
|
|
8923
8938
|
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;
|
|
8924
8939
|
let t = tt(S.from(e.pubkey, "hex")).slice(2);
|
|
8925
8940
|
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 += ho.toString(16).padStart(8, "0"), e.ref_return_bps && e.ref_return_bps > 0n && (t += e.ref_return_bps.toString(16).padStart(8, "0")));
|
|
@@ -8941,12 +8956,12 @@ async function zl(e) {
|
|
|
8941
8956
|
body: JSON.stringify(e)
|
|
8942
8957
|
});
|
|
8943
8958
|
}
|
|
8944
|
-
async function
|
|
8959
|
+
async function Xl(e, t, n, r, s, i) {
|
|
8945
8960
|
const o = (await et())?.swapPubkey;
|
|
8946
8961
|
if (!o)
|
|
8947
8962
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
8948
8963
|
await sr(e, t);
|
|
8949
|
-
const a = r * (10000n - s) / 10000n, c = await qe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await or(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await
|
|
8964
|
+
const a = r * (10000n - s) / 10000n, c = await qe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await or(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await Yl({
|
|
8950
8965
|
token1_addr: e,
|
|
8951
8966
|
token2_addr: t,
|
|
8952
8967
|
in_amt: n.toString(),
|
|
@@ -8956,7 +8971,7 @@ async function Kl(e, t, n, r, s, i) {
|
|
|
8956
8971
|
btc_fee: u.toString(),
|
|
8957
8972
|
referrer_pubkey: d,
|
|
8958
8973
|
ref_return_bps: p ? p.toString() : void 0
|
|
8959
|
-
}), h = await
|
|
8974
|
+
}), h = await Kl({
|
|
8960
8975
|
pubkey: o,
|
|
8961
8976
|
nonce: c,
|
|
8962
8977
|
token1_addr: e,
|
|
@@ -8984,7 +8999,7 @@ async function Kl(e, t, n, r, s, i) {
|
|
|
8984
8999
|
referrer_id: d ? i : void 0
|
|
8985
9000
|
});
|
|
8986
9001
|
}
|
|
8987
|
-
async function
|
|
9002
|
+
async function Jl(e, t, n) {
|
|
8988
9003
|
const r = await Jt();
|
|
8989
9004
|
await sr(e, t);
|
|
8990
9005
|
const s = (await et())?.swapPubkey;
|
|
@@ -9032,7 +9047,7 @@ async function Xl(e, t, n) {
|
|
|
9032
9047
|
fees: co(u.amounts[0], n, a, c, o)
|
|
9033
9048
|
};
|
|
9034
9049
|
}
|
|
9035
|
-
async function
|
|
9050
|
+
async function jl(e) {
|
|
9036
9051
|
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;
|
|
9037
9052
|
const t = `Swap Order:
|
|
9038
9053
|
Token 1 Address: ${e.token1_addr}
|
|
@@ -9048,7 +9063,7 @@ ${e.referrer_pubkey ? `Referrer Pubkey: ${e.referrer_pubkey}
|
|
|
9048
9063
|
By signing this message, you authorize the creation of a swap order with the above parameters.`;
|
|
9049
9064
|
return await Pe(t, "ordinals");
|
|
9050
9065
|
}
|
|
9051
|
-
async function
|
|
9066
|
+
async function Ql(e) {
|
|
9052
9067
|
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;
|
|
9053
9068
|
let t = tt(S.from(e.pubkey, "hex")).slice(2);
|
|
9054
9069
|
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 += ho.toString(16).padStart(8, "0"), e.ref_return_bps && e.ref_return_bps > 0n && (t += e.ref_return_bps.toString(16).padStart(8, "0")));
|
|
@@ -9060,7 +9075,7 @@ async function jl(e) {
|
|
|
9060
9075
|
const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = S.from(i, "hex"), a = T.shortSignatures.sign(r, o);
|
|
9061
9076
|
return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
|
|
9062
9077
|
}
|
|
9063
|
-
async function
|
|
9078
|
+
async function tf(e) {
|
|
9064
9079
|
const t = J("swap2");
|
|
9065
9080
|
return X(t, {
|
|
9066
9081
|
method: "POST",
|
|
@@ -9070,12 +9085,12 @@ async function Ql(e) {
|
|
|
9070
9085
|
body: JSON.stringify(e)
|
|
9071
9086
|
});
|
|
9072
9087
|
}
|
|
9073
|
-
async function
|
|
9088
|
+
async function ef(e, t, n, r, s, i) {
|
|
9074
9089
|
const o = (await et())?.swapPubkey;
|
|
9075
9090
|
if (!o)
|
|
9076
9091
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
9077
9092
|
await sr(e, t);
|
|
9078
|
-
const a = n * (10000n + s) / 10000n, c = await qe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await or(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await
|
|
9093
|
+
const a = n * (10000n + s) / 10000n, c = await qe(), u = await $t("swap"), { token1FeeBps: l, token2FeeBps: f } = await or(e, t), { referrerPubkey: d, refReturnBps: p } = i ? await Vr(o, i) : { referrerPubkey: void 0, refReturnBps: void 0 }, w = await jl({
|
|
9079
9094
|
token1_addr: e,
|
|
9080
9095
|
token2_addr: t,
|
|
9081
9096
|
max_in_amt: a.toString(),
|
|
@@ -9085,7 +9100,7 @@ async function tf(e, t, n, r, s, i) {
|
|
|
9085
9100
|
btc_fee: u.toString(),
|
|
9086
9101
|
referrer_pubkey: d,
|
|
9087
9102
|
ref_return_bps: p ? p.toString() : void 0
|
|
9088
|
-
}), h = await
|
|
9103
|
+
}), h = await Ql({
|
|
9089
9104
|
pubkey: o,
|
|
9090
9105
|
nonce: c,
|
|
9091
9106
|
token1_addr: e,
|
|
@@ -9098,7 +9113,7 @@ async function tf(e, t, n, r, s, i) {
|
|
|
9098
9113
|
referrer_pubkey: d,
|
|
9099
9114
|
ref_return_bps: p
|
|
9100
9115
|
});
|
|
9101
|
-
return await
|
|
9116
|
+
return await tf({
|
|
9102
9117
|
pubkey: o,
|
|
9103
9118
|
token1_addr: e,
|
|
9104
9119
|
token2_addr: t,
|
|
@@ -9114,7 +9129,7 @@ async function tf(e, t, n, r, s, i) {
|
|
|
9114
9129
|
});
|
|
9115
9130
|
}
|
|
9116
9131
|
function Oo(e) {
|
|
9117
|
-
const t =
|
|
9132
|
+
const t = ze();
|
|
9118
9133
|
return `0x${tt(bn.address.toOutputScript(e, t)).slice(26)}`;
|
|
9119
9134
|
}
|
|
9120
9135
|
async function To(e) {
|
|
@@ -9152,7 +9167,7 @@ async function Ro(e) {
|
|
|
9152
9167
|
body: JSON.stringify(e)
|
|
9153
9168
|
});
|
|
9154
9169
|
}
|
|
9155
|
-
async function
|
|
9170
|
+
async function nf(e, t, n) {
|
|
9156
9171
|
const r = (await et())?.swapPubkey;
|
|
9157
9172
|
if (!r)
|
|
9158
9173
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
@@ -9183,7 +9198,7 @@ async function ef(e, t, n) {
|
|
|
9183
9198
|
bip322_signature: l
|
|
9184
9199
|
});
|
|
9185
9200
|
}
|
|
9186
|
-
async function
|
|
9201
|
+
async function rf(e, t) {
|
|
9187
9202
|
const n = (await et())?.swapPubkey;
|
|
9188
9203
|
if (!n)
|
|
9189
9204
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
@@ -9217,7 +9232,7 @@ async function nf(e, t) {
|
|
|
9217
9232
|
bip322_signature: l
|
|
9218
9233
|
});
|
|
9219
9234
|
}
|
|
9220
|
-
async function
|
|
9235
|
+
async function sf(e, t) {
|
|
9221
9236
|
const n = await Jt();
|
|
9222
9237
|
er(n.wbtc_address, n.factory_address);
|
|
9223
9238
|
const r = (await et())?.swapPubkey;
|
|
@@ -9243,7 +9258,7 @@ async function rf(e, t) {
|
|
|
9243
9258
|
throw new Error("No data returned from unwrap request.");
|
|
9244
9259
|
return { amt: o.data.amt };
|
|
9245
9260
|
}
|
|
9246
|
-
async function
|
|
9261
|
+
async function of(e) {
|
|
9247
9262
|
e.pkscript = e.pkscript.toLowerCase();
|
|
9248
9263
|
const t = `Unwrap Order:
|
|
9249
9264
|
Pkscript: ${e.pkscript}
|
|
@@ -9255,7 +9270,7 @@ BTC Fee: ${e.btc_fee}
|
|
|
9255
9270
|
By signing this message, you authorize the creation of a withdraw order with the above parameters.`;
|
|
9256
9271
|
return await Pe(t, "ordinals");
|
|
9257
9272
|
}
|
|
9258
|
-
async function
|
|
9273
|
+
async function af(e) {
|
|
9259
9274
|
e.pubkey = e.pubkey.startsWith("0x") ? e.pubkey.slice(2) : e.pubkey;
|
|
9260
9275
|
let t = tt(S.from(e.pubkey, "hex")).slice(2);
|
|
9261
9276
|
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");
|
|
@@ -9267,7 +9282,7 @@ async function of(e) {
|
|
|
9267
9282
|
const i = s.swapPrivkey.startsWith("0x") ? s.swapPrivkey.slice(2) : s.swapPrivkey, o = S.from(i, "hex"), a = T.shortSignatures.sign(r, o);
|
|
9268
9283
|
return `0x${a.x.toString(16).padStart(128, "0")}${a.y.toString(16).padStart(128, "0")}`;
|
|
9269
9284
|
}
|
|
9270
|
-
async function
|
|
9285
|
+
async function cf(e) {
|
|
9271
9286
|
const t = J("unwrap");
|
|
9272
9287
|
return X(t, {
|
|
9273
9288
|
method: "POST",
|
|
@@ -9277,24 +9292,24 @@ async function af(e) {
|
|
|
9277
9292
|
body: JSON.stringify(e)
|
|
9278
9293
|
});
|
|
9279
9294
|
}
|
|
9280
|
-
async function
|
|
9295
|
+
async function uf(e, t) {
|
|
9281
9296
|
const n = (await et())?.swapPubkey;
|
|
9282
9297
|
if (!n)
|
|
9283
9298
|
throw new Error("Smart wallet not found. Please generate a smart wallet first.");
|
|
9284
|
-
const r = 0n, s = 0n, i = await qe(), o = await $t("unwrap"), a = await
|
|
9299
|
+
const r = 0n, s = 0n, i = await qe(), o = await $t("unwrap"), a = await of({
|
|
9285
9300
|
pkscript: e,
|
|
9286
9301
|
amt: t.toString(),
|
|
9287
9302
|
token1FeeBps: r.toString(),
|
|
9288
9303
|
token2FeeBps: s.toString(),
|
|
9289
9304
|
btc_fee: o.toString()
|
|
9290
|
-
}), c = await
|
|
9305
|
+
}), c = await af({
|
|
9291
9306
|
pubkey: n,
|
|
9292
9307
|
nonce: i,
|
|
9293
9308
|
pkscript: e,
|
|
9294
9309
|
amt: t,
|
|
9295
9310
|
btc_fee: o
|
|
9296
9311
|
});
|
|
9297
|
-
return await
|
|
9312
|
+
return await cf({
|
|
9298
9313
|
pubkey: n,
|
|
9299
9314
|
pkscript: e,
|
|
9300
9315
|
amt: t.toString(),
|
|
@@ -9305,23 +9320,24 @@ async function cf(e, t) {
|
|
|
9305
9320
|
bip322_signature: a
|
|
9306
9321
|
});
|
|
9307
9322
|
}
|
|
9308
|
-
async function
|
|
9309
|
-
return await
|
|
9323
|
+
async function lf(e, t, n, r, s) {
|
|
9324
|
+
return await Il({
|
|
9310
9325
|
pubkey: e,
|
|
9311
9326
|
pairAddress: t,
|
|
9312
9327
|
limit: n,
|
|
9313
|
-
offset: r
|
|
9328
|
+
offset: r,
|
|
9329
|
+
kinds: s
|
|
9314
9330
|
});
|
|
9315
9331
|
}
|
|
9316
|
-
async function
|
|
9332
|
+
async function ff(e, t, n) {
|
|
9317
9333
|
return await Ol({
|
|
9318
9334
|
pair_address: e,
|
|
9319
9335
|
limit: t || 20,
|
|
9320
9336
|
offset: n || 0
|
|
9321
9337
|
});
|
|
9322
9338
|
}
|
|
9323
|
-
async function
|
|
9324
|
-
return (await
|
|
9339
|
+
async function df(e, t, n, r, s) {
|
|
9340
|
+
return (await Dl(
|
|
9325
9341
|
e,
|
|
9326
9342
|
t,
|
|
9327
9343
|
n,
|
|
@@ -9329,8 +9345,8 @@ async function ff(e, t, n, r, s) {
|
|
|
9329
9345
|
s
|
|
9330
9346
|
)).success;
|
|
9331
9347
|
}
|
|
9332
|
-
async function
|
|
9333
|
-
return (await
|
|
9348
|
+
async function pf(e, t, n, r, s, i) {
|
|
9349
|
+
return (await Vl(
|
|
9334
9350
|
e,
|
|
9335
9351
|
t,
|
|
9336
9352
|
n,
|
|
@@ -9339,8 +9355,8 @@ async function df(e, t, n, r, s, i) {
|
|
|
9339
9355
|
i
|
|
9340
9356
|
)).success;
|
|
9341
9357
|
}
|
|
9342
|
-
async function
|
|
9343
|
-
return (await
|
|
9358
|
+
async function hf(e, t, n, r, s, i) {
|
|
9359
|
+
return (await Xl(
|
|
9344
9360
|
e,
|
|
9345
9361
|
t,
|
|
9346
9362
|
n,
|
|
@@ -9349,8 +9365,8 @@ async function pf(e, t, n, r, s, i) {
|
|
|
9349
9365
|
i
|
|
9350
9366
|
)).success;
|
|
9351
9367
|
}
|
|
9352
|
-
async function
|
|
9353
|
-
return (await
|
|
9368
|
+
async function wf(e, t, n, r, s, i) {
|
|
9369
|
+
return (await ef(
|
|
9354
9370
|
e,
|
|
9355
9371
|
t,
|
|
9356
9372
|
n,
|
|
@@ -9359,11 +9375,11 @@ async function hf(e, t, n, r, s, i) {
|
|
|
9359
9375
|
i
|
|
9360
9376
|
)).success;
|
|
9361
9377
|
}
|
|
9362
|
-
async function
|
|
9363
|
-
return (await
|
|
9378
|
+
async function gf(e, t) {
|
|
9379
|
+
return (await uf(e, t)).success;
|
|
9364
9380
|
}
|
|
9365
|
-
async function
|
|
9366
|
-
return await
|
|
9381
|
+
async function yf(e, t, n, r = !0, s, i) {
|
|
9382
|
+
return await kl(
|
|
9367
9383
|
e,
|
|
9368
9384
|
t,
|
|
9369
9385
|
n,
|
|
@@ -9372,57 +9388,57 @@ async function gf(e, t, n, r = !0, s, i) {
|
|
|
9372
9388
|
i
|
|
9373
9389
|
);
|
|
9374
9390
|
}
|
|
9375
|
-
async function yf(e, t, n) {
|
|
9376
|
-
return await $l(e, t, n);
|
|
9377
|
-
}
|
|
9378
9391
|
async function bf(e, t, n) {
|
|
9379
|
-
return
|
|
9392
|
+
return await Ll(e, t, n);
|
|
9393
|
+
}
|
|
9394
|
+
async function mf(e, t, n) {
|
|
9395
|
+
return n ? (await nf(e, n, t)).success : (await rf(e, t)).success;
|
|
9380
9396
|
}
|
|
9381
|
-
const
|
|
9397
|
+
const Wf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9382
9398
|
__proto__: null,
|
|
9383
|
-
addLiquidity:
|
|
9399
|
+
addLiquidity: df,
|
|
9384
9400
|
createSwapWallet: yo,
|
|
9385
|
-
deposit:
|
|
9401
|
+
deposit: yf,
|
|
9386
9402
|
ensureSwapWallet: hl,
|
|
9387
|
-
getActivityOfPair:
|
|
9388
|
-
getAddLiquidityResult:
|
|
9403
|
+
getActivityOfPair: ff,
|
|
9404
|
+
getAddLiquidityResult: Pl,
|
|
9389
9405
|
getKlines: Bl,
|
|
9390
9406
|
getMinerFee: $t,
|
|
9391
|
-
getMinerFeesOfDepositOrder:
|
|
9392
|
-
getMinerFeesOfWrapOrder:
|
|
9407
|
+
getMinerFeesOfDepositOrder: Nl,
|
|
9408
|
+
getMinerFeesOfWrapOrder: Al,
|
|
9393
9409
|
getPairAddress: nr,
|
|
9394
9410
|
getPairReserves: Ue,
|
|
9395
9411
|
getPairVolumeOverDays: Sl,
|
|
9396
|
-
getRemoveLiquidityResult:
|
|
9412
|
+
getRemoveLiquidityResult: Ml,
|
|
9397
9413
|
getSwapBalance: ml,
|
|
9398
9414
|
getSwapBalances: bl,
|
|
9399
|
-
getSwapExactInputResult:
|
|
9400
|
-
getSwapExactOutputResult:
|
|
9415
|
+
getSwapExactInputResult: Zl,
|
|
9416
|
+
getSwapExactOutputResult: Jl,
|
|
9401
9417
|
getSwapInfo: Jt,
|
|
9402
9418
|
getSwapStatus: gl,
|
|
9403
9419
|
getSwapWalletSecurityCode: wl,
|
|
9404
9420
|
getTokenDecimals: wn,
|
|
9405
9421
|
getTvlHistory: vl,
|
|
9406
|
-
getUnwrapBtcResult:
|
|
9407
|
-
getWalletActivities:
|
|
9422
|
+
getUnwrapBtcResult: sf,
|
|
9423
|
+
getWalletActivities: lf,
|
|
9408
9424
|
importSwapWallet: pl,
|
|
9409
9425
|
listPairs: El,
|
|
9410
|
-
listTokens:
|
|
9411
|
-
removeLiquidity:
|
|
9426
|
+
listTokens: xl,
|
|
9427
|
+
removeLiquidity: pf,
|
|
9412
9428
|
satsToBtc: ao,
|
|
9413
9429
|
satsToUsd: Au,
|
|
9414
|
-
swapExactInput:
|
|
9415
|
-
swapExactOutput:
|
|
9430
|
+
swapExactInput: hf,
|
|
9431
|
+
swapExactOutput: wf,
|
|
9416
9432
|
swapSide: Lu,
|
|
9417
9433
|
tryGetSwapReferrerInfo: Vr,
|
|
9418
|
-
unwrapBtc:
|
|
9419
|
-
withdraw:
|
|
9420
|
-
wrapBtc:
|
|
9421
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
9434
|
+
unwrapBtc: gf,
|
|
9435
|
+
withdraw: mf,
|
|
9436
|
+
wrapBtc: bf
|
|
9437
|
+
}, Symbol.toStringTag, { value: "Module" })), _f = "text/plain", ko = /^[a-z0-9-]{6}$/i, xf = /^(?:[0-9a-f]{2})+$/i;
|
|
9422
9438
|
function Zr(e) {
|
|
9423
9439
|
if (typeof e != "string" || e.length === 0)
|
|
9424
9440
|
throw new Error("tick must be a non-empty string");
|
|
9425
|
-
return
|
|
9441
|
+
return z.str(e).length;
|
|
9426
9442
|
}
|
|
9427
9443
|
function Tr(e, t) {
|
|
9428
9444
|
if (typeof e != "string" || !xf.test(e))
|
|
@@ -9434,12 +9450,12 @@ function Vn(e, t) {
|
|
|
9434
9450
|
}
|
|
9435
9451
|
function gn(e) {
|
|
9436
9452
|
return new ce(
|
|
9437
|
-
|
|
9453
|
+
z.str(_f),
|
|
9438
9454
|
null,
|
|
9439
9455
|
null,
|
|
9440
9456
|
null,
|
|
9441
9457
|
null,
|
|
9442
|
-
|
|
9458
|
+
z.str(JSON.stringify(e))
|
|
9443
9459
|
);
|
|
9444
9460
|
}
|
|
9445
9461
|
function No(e, t, n) {
|
|
@@ -9452,7 +9468,7 @@ function No(e, t, n) {
|
|
|
9452
9468
|
const s = r || e.selfMint === !0, i = { p: "brc-20", op: "deploy", tick: e.tick };
|
|
9453
9469
|
return n != null && (i.salt = n), i.max = e.max, e.lim != null && (i.lim = e.lim), e.dec != null && (i.dec = String(e.dec)), s && (i.self_mint = "true"), i;
|
|
9454
9470
|
}
|
|
9455
|
-
function
|
|
9471
|
+
function Ef(e) {
|
|
9456
9472
|
const t = Zr(e.tick);
|
|
9457
9473
|
if (t === 6)
|
|
9458
9474
|
throw new Error("6-byte tickers require a predeploy; use predeployInscriptions()");
|
|
@@ -9460,12 +9476,12 @@ function _f(e) {
|
|
|
9460
9476
|
throw new Error(`deploy ticker must be 4 or 5 bytes, got ${t}`);
|
|
9461
9477
|
return gn(No(e, t, null));
|
|
9462
9478
|
}
|
|
9463
|
-
function
|
|
9479
|
+
function Sf(e) {
|
|
9464
9480
|
const t = Zr(e.tick);
|
|
9465
9481
|
if (t < 4 || t > 6) throw new Error(`ticker must be 4-6 bytes, got ${t}`);
|
|
9466
9482
|
return Vn(e.amt, "amt"), gn({ p: "brc-20", op: "mint", tick: e.tick, amt: e.amt });
|
|
9467
9483
|
}
|
|
9468
|
-
function
|
|
9484
|
+
function Bf(e) {
|
|
9469
9485
|
const t = Zr(e.tick);
|
|
9470
9486
|
if (t < 4 || t > 6) throw new Error(`ticker must be 4-6 bytes, got ${t}`);
|
|
9471
9487
|
return Vn(e.amt, "amt"), gn({ p: "brc-20", op: "transfer", tick: e.tick, amt: e.amt });
|
|
@@ -9473,12 +9489,12 @@ function Sf(e) {
|
|
|
9473
9489
|
function Co(e = 16) {
|
|
9474
9490
|
if (!Number.isInteger(e) || e <= 0)
|
|
9475
9491
|
throw new Error("byteLength must be a positive integer");
|
|
9476
|
-
return
|
|
9492
|
+
return z.random(e).hex;
|
|
9477
9493
|
}
|
|
9478
|
-
function
|
|
9494
|
+
function vf(e) {
|
|
9479
9495
|
if (typeof e != "string" || e.length === 0)
|
|
9480
9496
|
throw new Error("address must be a non-empty string");
|
|
9481
|
-
return bn.address.toOutputScript(e,
|
|
9497
|
+
return bn.address.toOutputScript(e, ze()).toString("hex");
|
|
9482
9498
|
}
|
|
9483
9499
|
function $o(e, t, n) {
|
|
9484
9500
|
if (typeof e != "string" || !ko.test(e))
|
|
@@ -9491,10 +9507,10 @@ function $o(e, t, n) {
|
|
|
9491
9507
|
]);
|
|
9492
9508
|
return bn.crypto.hash256(r).toString("hex");
|
|
9493
9509
|
}
|
|
9494
|
-
function
|
|
9510
|
+
function Of(e) {
|
|
9495
9511
|
if (typeof e.tick != "string" || !ko.test(e.tick))
|
|
9496
9512
|
throw new Error("6-byte ticker must match /^[A-Za-z0-9-]{6}$/");
|
|
9497
|
-
const t =
|
|
9513
|
+
const t = vf(e.address), n = e.salt ?? Co();
|
|
9498
9514
|
Tr(n, "salt");
|
|
9499
9515
|
const r = $o(e.tick, n, t), s = No(
|
|
9500
9516
|
{ tick: e.tick, max: e.max, lim: e.lim, dec: e.dec },
|
|
@@ -9535,7 +9551,7 @@ async function Lo(e, t, n, r, s, i, o, a, c) {
|
|
|
9535
9551
|
);
|
|
9536
9552
|
throw new Error(`Unsupported wallet type: ${c}`);
|
|
9537
9553
|
}
|
|
9538
|
-
async function
|
|
9554
|
+
async function Tf(e, t, n, r, s, i, o, a, c, u, l) {
|
|
9539
9555
|
if (typeof t != "object") throw new Error("abi must be an object");
|
|
9540
9556
|
if (typeof n != "string") throw new Error("func_name must be a string");
|
|
9541
9557
|
if (!Array.isArray(r)) throw new Error("params must be an array");
|
|
@@ -9552,8 +9568,8 @@ async function Of(e, t, n, r, s, i, o, a, c, u, l) {
|
|
|
9552
9568
|
f
|
|
9553
9569
|
);
|
|
9554
9570
|
}
|
|
9555
|
-
async function
|
|
9556
|
-
return await
|
|
9571
|
+
async function If(e, t, n, r, s, i) {
|
|
9572
|
+
return await Ko(
|
|
9557
9573
|
e,
|
|
9558
9574
|
t,
|
|
9559
9575
|
n,
|
|
@@ -9563,8 +9579,8 @@ async function Tf(e, t, n, r, s, i) {
|
|
|
9563
9579
|
s
|
|
9564
9580
|
);
|
|
9565
9581
|
}
|
|
9566
|
-
async function
|
|
9567
|
-
return await
|
|
9582
|
+
async function Rf(e, t, n, r, s, i, o) {
|
|
9583
|
+
return await zo(
|
|
9568
9584
|
e,
|
|
9569
9585
|
t,
|
|
9570
9586
|
n,
|
|
@@ -9575,20 +9591,20 @@ async function If(e, t, n, r, s, i, o) {
|
|
|
9575
9591
|
i
|
|
9576
9592
|
);
|
|
9577
9593
|
}
|
|
9578
|
-
const
|
|
9594
|
+
const Gf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9579
9595
|
__proto__: null,
|
|
9580
9596
|
callSmartContract: Lo,
|
|
9581
|
-
callSmartContractAbi:
|
|
9597
|
+
callSmartContractAbi: Tf,
|
|
9582
9598
|
computeBrc20PredeployHash: $o,
|
|
9583
|
-
deployBrc20Inscription:
|
|
9584
|
-
depositToBrc20Prog:
|
|
9599
|
+
deployBrc20Inscription: Ef,
|
|
9600
|
+
depositToBrc20Prog: If,
|
|
9585
9601
|
generateBrc20Salt: Co,
|
|
9586
|
-
mintBrc20Inscription:
|
|
9587
|
-
predeployInscriptions:
|
|
9588
|
-
transferBrc20Inscription:
|
|
9589
|
-
withdrawFromBrc20Prog:
|
|
9602
|
+
mintBrc20Inscription: Sf,
|
|
9603
|
+
predeployInscriptions: Of,
|
|
9604
|
+
transferBrc20Inscription: Bf,
|
|
9605
|
+
withdrawFromBrc20Prog: Rf
|
|
9590
9606
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
9591
|
-
async function
|
|
9607
|
+
async function kf(e, t, n, r, s) {
|
|
9592
9608
|
const i = await js(
|
|
9593
9609
|
[e],
|
|
9594
9610
|
t,
|
|
@@ -9606,10 +9622,10 @@ async function Rf(e, t, n, r, s) {
|
|
|
9606
9622
|
secret: i.secret
|
|
9607
9623
|
};
|
|
9608
9624
|
}
|
|
9609
|
-
async function
|
|
9625
|
+
async function Nf(e, t, n, r, s) {
|
|
9610
9626
|
return await js(e, t, n, r, s);
|
|
9611
9627
|
}
|
|
9612
|
-
async function
|
|
9628
|
+
async function Cf(e, t, n, r, s, i) {
|
|
9613
9629
|
return await Xo(
|
|
9614
9630
|
e,
|
|
9615
9631
|
t,
|
|
@@ -9619,19 +9635,19 @@ async function Nf(e, t, n, r, s, i) {
|
|
|
9619
9635
|
i
|
|
9620
9636
|
);
|
|
9621
9637
|
}
|
|
9622
|
-
async function
|
|
9638
|
+
async function $f(e, t, n, r) {
|
|
9623
9639
|
return await Qs([e], t, n, r);
|
|
9624
9640
|
}
|
|
9625
|
-
async function
|
|
9641
|
+
async function Lf(e, t, n, r) {
|
|
9626
9642
|
return await Qs(e, t, n, r);
|
|
9627
9643
|
}
|
|
9628
|
-
const
|
|
9644
|
+
const Hf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9629
9645
|
__proto__: null,
|
|
9630
|
-
getInscribeFee:
|
|
9631
|
-
getInscribeMultipleFee:
|
|
9632
|
-
inscribe:
|
|
9633
|
-
inscribeMultiple:
|
|
9634
|
-
inscribeWithParent:
|
|
9646
|
+
getInscribeFee: $f,
|
|
9647
|
+
getInscribeMultipleFee: Lf,
|
|
9648
|
+
inscribe: kf,
|
|
9649
|
+
inscribeMultiple: Nf,
|
|
9650
|
+
inscribeWithParent: Cf
|
|
9635
9651
|
}, Symbol.toStringTag, { value: "Module" })), Ao = [
|
|
9636
9652
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
9637
9653
|
{
|
|
@@ -9790,7 +9806,7 @@ const Gf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
9790
9806
|
type: "function"
|
|
9791
9807
|
}
|
|
9792
9808
|
], Po = "0xc54dd4581af2dbf18e4d90840226756e9d2b3cdb";
|
|
9793
|
-
async function
|
|
9809
|
+
async function Af(e, t) {
|
|
9794
9810
|
const n = t.toUpperCase(), r = ti("check_base_brc20_balance"), i = await ei(r, {
|
|
9795
9811
|
method: "POST",
|
|
9796
9812
|
headers: {
|
|
@@ -9808,7 +9824,7 @@ async function Lf(e, t) {
|
|
|
9808
9824
|
ticker: i.result.ticker
|
|
9809
9825
|
};
|
|
9810
9826
|
}
|
|
9811
|
-
async function
|
|
9827
|
+
async function Pf(e, t) {
|
|
9812
9828
|
const n = ti("check_brc20_balance"), s = await ei(n, {
|
|
9813
9829
|
method: "POST",
|
|
9814
9830
|
headers: {
|
|
@@ -9821,7 +9837,7 @@ async function Af(e, t) {
|
|
|
9821
9837
|
});
|
|
9822
9838
|
return BigInt(s.result);
|
|
9823
9839
|
}
|
|
9824
|
-
async function
|
|
9840
|
+
async function Ff(e, t) {
|
|
9825
9841
|
const n = S.from(t, "utf-8"), r = await ni(
|
|
9826
9842
|
Po,
|
|
9827
9843
|
Ao,
|
|
@@ -9830,7 +9846,7 @@ async function Pf(e, t) {
|
|
|
9830
9846
|
);
|
|
9831
9847
|
return BigInt(r);
|
|
9832
9848
|
}
|
|
9833
|
-
async function
|
|
9849
|
+
async function Uf(e) {
|
|
9834
9850
|
const t = S.from(e, "utf-8");
|
|
9835
9851
|
return `0x${(await ni(
|
|
9836
9852
|
Po,
|
|
@@ -9839,17 +9855,17 @@ async function Ff(e) {
|
|
|
9839
9855
|
[t]
|
|
9840
9856
|
)).slice(-40)}`;
|
|
9841
9857
|
}
|
|
9842
|
-
const
|
|
9858
|
+
const Vf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9843
9859
|
__proto__: null,
|
|
9844
|
-
getBRC20ProgBalanceOfAddress:
|
|
9845
|
-
getBRC20ProgBalanceOfTicker:
|
|
9846
|
-
getBRC20ProgTokenAddressOfTicker:
|
|
9847
|
-
getBaseBRC20BalanceOfAddress:
|
|
9860
|
+
getBRC20ProgBalanceOfAddress: Pf,
|
|
9861
|
+
getBRC20ProgBalanceOfTicker: Ff,
|
|
9862
|
+
getBRC20ProgTokenAddressOfTicker: Uf,
|
|
9863
|
+
getBaseBRC20BalanceOfAddress: Af
|
|
9848
9864
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
9849
9865
|
export {
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9866
|
+
Wf as a,
|
|
9867
|
+
Gf as b,
|
|
9868
|
+
Vf as c,
|
|
9869
|
+
Hf as m,
|
|
9870
|
+
Mf as s
|
|
9855
9871
|
};
|