@cartridge/controller 0.13.9 → 0.13.10
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/.turbo/turbo-build$colon$deps.log +13 -13
- package/dist/controller.d.ts +2 -1
- package/dist/iframe/keychain.d.ts +1 -1
- package/dist/{index-CJNujYxo.js → index-C7KGk-LM.js} +473 -198
- package/dist/index-C7KGk-LM.js.map +1 -0
- package/dist/index.js +834 -796
- package/dist/index.js.map +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/session.js +4 -4
- package/dist/stats.html +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/utils.d.ts +0 -1
- package/dist/wallets/ethereum-base.d.ts +5 -1
- package/dist/wallets/metamask/index.d.ts +1 -0
- package/dist/wallets/phantom-evm/index.d.ts +1 -0
- package/package.json +3 -4
- package/src/__tests__/disconnect.test.ts +18 -0
- package/src/controller.ts +47 -4
- package/src/iframe/keychain.ts +5 -0
- package/src/types.ts +14 -0
- package/src/utils.ts +0 -8
- package/src/wallets/ethereum-base.ts +35 -48
- package/src/wallets/metamask/index.ts +6 -0
- package/src/wallets/phantom-evm/index.ts +4 -0
- package/dist/index-CJNujYxo.js.map +0 -1
- package/dist/telegram/backend.d.ts +0 -30
- package/dist/telegram/provider.d.ts +0 -24
- package/src/telegram/backend.ts +0 -43
- package/src/telegram/provider.ts +0 -148
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { WalletAccount as
|
|
2
|
-
import { R
|
|
3
|
-
import { c as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
return
|
|
1
|
+
import { WalletAccount as Sn, constants as ge, num as Bt, shortString as ft } from "starknet";
|
|
2
|
+
import { R, t as $n, K as Ut, A as Mt, I as Ln, B as _n, N as $, H as ue, p as In, v as Pn, s as Rt } from "./index-C7KGk-LM.js";
|
|
3
|
+
import { c as Ni, i as Bi, E as Ui, k as Mi, j as Ri, F as Oi, b as Fi, a as zi, l as ji, m as Hi, o as Wi, q as qi, g as Vi, h as Di, r as Zi, u as Ki, n as Xi, f as Gi, d as Yi, e as Ji } from "./index-C7KGk-LM.js";
|
|
4
|
+
const Tn = "standard:connect", Nn = "standard:disconnect", Bn = "standard:events", Un = "0.1.1";
|
|
5
|
+
function Mn() {
|
|
6
|
+
return Un;
|
|
7
7
|
}
|
|
8
8
|
class ie extends Error {
|
|
9
9
|
constructor(e, n = {}) {
|
|
@@ -59,46 +59,46 @@ class ie extends Error {
|
|
|
59
59
|
enumerable: !0,
|
|
60
60
|
configurable: !0,
|
|
61
61
|
writable: !0,
|
|
62
|
-
value: `ox@${
|
|
62
|
+
value: `ox@${Mn()}`
|
|
63
63
|
}), this.cause = n.cause, this.details = r, this.docs = o, this.docsPath = s, this.shortMessage = e;
|
|
64
64
|
}
|
|
65
65
|
walk(e) {
|
|
66
|
-
return
|
|
66
|
+
return Ot(this, e);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
return e?.(t) ? t : t && typeof t == "object" && "cause" in t && t.cause ?
|
|
69
|
+
function Ot(t, e) {
|
|
70
|
+
return e?.(t) ? t : t && typeof t == "object" && "cause" in t && t.cause ? Ot(t.cause, e) : e ? null : t;
|
|
71
71
|
}
|
|
72
72
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
73
|
-
function
|
|
73
|
+
function Rn(t) {
|
|
74
74
|
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function pt(t) {
|
|
77
77
|
if (!Number.isSafeInteger(t) || t < 0)
|
|
78
78
|
throw new Error("positive integer expected, got " + t);
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
if (!
|
|
80
|
+
function me(t, ...e) {
|
|
81
|
+
if (!Rn(t))
|
|
82
82
|
throw new Error("Uint8Array expected");
|
|
83
83
|
if (e.length > 0 && !e.includes(t.length))
|
|
84
84
|
throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function wt(t, e = !0) {
|
|
87
87
|
if (t.destroyed)
|
|
88
88
|
throw new Error("Hash instance has been destroyed");
|
|
89
89
|
if (e && t.finished)
|
|
90
90
|
throw new Error("Hash#digest() has already been called");
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
|
|
92
|
+
function On(t, e) {
|
|
93
|
+
me(t);
|
|
94
94
|
const n = e.outputLen;
|
|
95
95
|
if (t.length < n)
|
|
96
96
|
throw new Error("digestInto() expects output buffer of length at least " + n);
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function Fn(t) {
|
|
99
99
|
return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function Ft(...t) {
|
|
102
102
|
for (let e = 0; e < t.length; e++)
|
|
103
103
|
t[e].fill(0);
|
|
104
104
|
}
|
|
@@ -106,61 +106,61 @@ const zn = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
|
106
106
|
function jn(t) {
|
|
107
107
|
return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function Hn(t) {
|
|
110
110
|
for (let e = 0; e < t.length; e++)
|
|
111
111
|
t[e] = jn(t[e]);
|
|
112
112
|
return t;
|
|
113
113
|
}
|
|
114
|
-
const
|
|
115
|
-
function
|
|
114
|
+
const gt = zn ? (t) => t : Hn;
|
|
115
|
+
function Wn(t) {
|
|
116
116
|
if (typeof t != "string")
|
|
117
117
|
throw new Error("string expected");
|
|
118
118
|
return new Uint8Array(new TextEncoder().encode(t));
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
return typeof t == "string" && (t =
|
|
120
|
+
function zt(t) {
|
|
121
|
+
return typeof t == "string" && (t = Wn(t)), me(t), t;
|
|
122
122
|
}
|
|
123
|
-
class
|
|
123
|
+
class qn {
|
|
124
124
|
}
|
|
125
|
-
function
|
|
126
|
-
const e = (r) => t().update(
|
|
125
|
+
function Vn(t) {
|
|
126
|
+
const e = (r) => t().update(zt(r)).digest(), n = t();
|
|
127
127
|
return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e;
|
|
128
128
|
}
|
|
129
|
-
const
|
|
130
|
-
function Vn(t, e = !1) {
|
|
131
|
-
return e ? { h: Number(t & ue), l: Number(t >> wt & ue) } : { h: Number(t >> wt & ue) | 0, l: Number(t & ue) | 0 };
|
|
132
|
-
}
|
|
129
|
+
const fe = /* @__PURE__ */ BigInt(2 ** 32 - 1), mt = /* @__PURE__ */ BigInt(32);
|
|
133
130
|
function Dn(t, e = !1) {
|
|
131
|
+
return e ? { h: Number(t & fe), l: Number(t >> mt & fe) } : { h: Number(t >> mt & fe) | 0, l: Number(t & fe) | 0 };
|
|
132
|
+
}
|
|
133
|
+
function Zn(t, e = !1) {
|
|
134
134
|
const n = t.length;
|
|
135
135
|
let r = new Uint32Array(n), s = new Uint32Array(n);
|
|
136
136
|
for (let i = 0; i < n; i++) {
|
|
137
|
-
const { h: o, l: a } =
|
|
137
|
+
const { h: o, l: a } = Dn(t[i], e);
|
|
138
138
|
[r[i], s[i]] = [o, a];
|
|
139
139
|
}
|
|
140
140
|
return [r, s];
|
|
141
141
|
}
|
|
142
|
-
const
|
|
142
|
+
const Kn = (t, e, n) => t << n | e >>> 32 - n, Xn = (t, e, n) => e << n | t >>> 32 - n, Gn = (t, e, n) => e << n - 32 | t >>> 64 - n, Yn = (t, e, n) => t << n - 32 | e >>> 64 - n, Jn = BigInt(0), ee = BigInt(1), Qn = BigInt(2), er = BigInt(7), tr = BigInt(256), nr = BigInt(113), jt = [], Ht = [], Wt = [];
|
|
143
143
|
for (let t = 0, e = ee, n = 1, r = 0; t < 24; t++) {
|
|
144
|
-
[n, r] = [r, (2 * n + 3 * r) % 5],
|
|
145
|
-
let s =
|
|
144
|
+
[n, r] = [r, (2 * n + 3 * r) % 5], jt.push(2 * (5 * r + n)), Ht.push((t + 1) * (t + 2) / 2 % 64);
|
|
145
|
+
let s = Jn;
|
|
146
146
|
for (let i = 0; i < 7; i++)
|
|
147
|
-
e = (e << ee ^ (e >>
|
|
148
|
-
|
|
147
|
+
e = (e << ee ^ (e >> er) * nr) % tr, e & Qn && (s ^= ee << (ee << /* @__PURE__ */ BigInt(i)) - ee);
|
|
148
|
+
Wt.push(s);
|
|
149
149
|
}
|
|
150
|
-
const
|
|
151
|
-
function
|
|
150
|
+
const qt = Zn(Wt, !0), rr = qt[0], sr = qt[1], yt = (t, e, n) => n > 32 ? Gn(t, e, n) : Kn(t, e, n), Ct = (t, e, n) => n > 32 ? Yn(t, e, n) : Xn(t, e, n);
|
|
151
|
+
function ir(t, e = 24) {
|
|
152
152
|
const n = new Uint32Array(10);
|
|
153
153
|
for (let r = 24 - e; r < 24; r++) {
|
|
154
154
|
for (let o = 0; o < 10; o++)
|
|
155
155
|
n[o] = t[o] ^ t[o + 10] ^ t[o + 20] ^ t[o + 30] ^ t[o + 40];
|
|
156
156
|
for (let o = 0; o < 10; o += 2) {
|
|
157
|
-
const a = (o + 8) % 10, l = (o + 2) % 10, c = n[l], d = n[l + 1], h =
|
|
157
|
+
const a = (o + 8) % 10, l = (o + 2) % 10, c = n[l], d = n[l + 1], h = yt(c, d, 1) ^ n[a], u = Ct(c, d, 1) ^ n[a + 1];
|
|
158
158
|
for (let f = 0; f < 50; f += 10)
|
|
159
159
|
t[o + f] ^= h, t[o + f + 1] ^= u;
|
|
160
160
|
}
|
|
161
161
|
let s = t[2], i = t[3];
|
|
162
162
|
for (let o = 0; o < 24; o++) {
|
|
163
|
-
const a =
|
|
163
|
+
const a = Ht[o], l = yt(s, i, a), c = Ct(s, i, a), d = jt[o];
|
|
164
164
|
s = t[d], i = t[d + 1], t[d] = l, t[d + 1] = c;
|
|
165
165
|
}
|
|
166
166
|
for (let o = 0; o < 50; o += 10) {
|
|
@@ -169,25 +169,25 @@ function sr(t, e = 24) {
|
|
|
169
169
|
for (let a = 0; a < 10; a++)
|
|
170
170
|
t[o + a] ^= ~n[(a + 2) % 10] & n[(a + 4) % 10];
|
|
171
171
|
}
|
|
172
|
-
t[0] ^=
|
|
172
|
+
t[0] ^= rr[r], t[1] ^= sr[r];
|
|
173
173
|
}
|
|
174
|
-
|
|
174
|
+
Ft(n);
|
|
175
175
|
}
|
|
176
|
-
class
|
|
176
|
+
class Je extends qn {
|
|
177
177
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
178
178
|
constructor(e, n, r, s = !1, i = 24) {
|
|
179
|
-
if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = n, this.outputLen = r, this.enableXOF = s, this.rounds = i,
|
|
179
|
+
if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = n, this.outputLen = r, this.enableXOF = s, this.rounds = i, pt(r), !(0 < e && e < 200))
|
|
180
180
|
throw new Error("only keccak-f1600 function is supported");
|
|
181
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
181
|
+
this.state = new Uint8Array(200), this.state32 = Fn(this.state);
|
|
182
182
|
}
|
|
183
183
|
clone() {
|
|
184
184
|
return this._cloneInto();
|
|
185
185
|
}
|
|
186
186
|
keccak() {
|
|
187
|
-
|
|
187
|
+
gt(this.state32), ir(this.state32, this.rounds), gt(this.state32), this.posOut = 0, this.pos = 0;
|
|
188
188
|
}
|
|
189
189
|
update(e) {
|
|
190
|
-
|
|
190
|
+
wt(this), e = zt(e), me(e);
|
|
191
191
|
const { blockLen: n, state: r } = this, s = e.length;
|
|
192
192
|
for (let i = 0; i < s; ) {
|
|
193
193
|
const o = Math.min(n - this.pos, s - i);
|
|
@@ -205,7 +205,7 @@ class Ge extends Wn {
|
|
|
205
205
|
e[r] ^= n, (n & 128) !== 0 && r === s - 1 && this.keccak(), e[s - 1] ^= 128, this.keccak();
|
|
206
206
|
}
|
|
207
207
|
writeInto(e) {
|
|
208
|
-
|
|
208
|
+
wt(this, !1), me(e), this.finish();
|
|
209
209
|
const n = this.state, { blockLen: r } = this;
|
|
210
210
|
for (let s = 0, i = e.length; s < i; ) {
|
|
211
211
|
this.posOut >= r && this.keccak();
|
|
@@ -220,10 +220,10 @@ class Ge extends Wn {
|
|
|
220
220
|
return this.writeInto(e);
|
|
221
221
|
}
|
|
222
222
|
xof(e) {
|
|
223
|
-
return
|
|
223
|
+
return pt(e), this.xofInto(new Uint8Array(e));
|
|
224
224
|
}
|
|
225
225
|
digestInto(e) {
|
|
226
|
-
if (
|
|
226
|
+
if (On(e, this), this.finished)
|
|
227
227
|
throw new Error("digest() was already called");
|
|
228
228
|
return this.writeInto(e), this.destroy(), e;
|
|
229
229
|
}
|
|
@@ -231,39 +231,39 @@ class Ge extends Wn {
|
|
|
231
231
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
232
232
|
}
|
|
233
233
|
destroy() {
|
|
234
|
-
this.destroyed = !0,
|
|
234
|
+
this.destroyed = !0, Ft(this.state);
|
|
235
235
|
}
|
|
236
236
|
_cloneInto(e) {
|
|
237
237
|
const { blockLen: n, suffix: r, outputLen: s, rounds: i, enableXOF: o } = this;
|
|
238
|
-
return e || (e = new
|
|
238
|
+
return e || (e = new Je(n, r, s, o, i)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = i, e.suffix = r, e.outputLen = s, e.enableXOF = o, e.destroyed = this.destroyed, e;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
const
|
|
242
|
-
function
|
|
243
|
-
return JSON.stringify(t, (r, s) => typeof s == "bigint" ? s.toString() +
|
|
241
|
+
const or = (t, e, n) => Vn(() => new Je(e, t, n)), ar = or(1, 136, 256 / 8), cr = "#__bigint";
|
|
242
|
+
function lr(t, e, n) {
|
|
243
|
+
return JSON.stringify(t, (r, s) => typeof s == "bigint" ? s.toString() + cr : s, n);
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function dr(t, e = {}) {
|
|
246
246
|
const { strict: n = !1 } = e;
|
|
247
247
|
if (!t)
|
|
248
|
-
throw new
|
|
248
|
+
throw new bt(t);
|
|
249
249
|
if (typeof t != "string")
|
|
250
|
-
throw new
|
|
250
|
+
throw new bt(t);
|
|
251
251
|
if (n && !/^0x[0-9a-fA-F]*$/.test(t))
|
|
252
|
-
throw new
|
|
252
|
+
throw new xt(t);
|
|
253
253
|
if (!t.startsWith("0x"))
|
|
254
|
-
throw new
|
|
254
|
+
throw new xt(t);
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function Vt(t, e = {}) {
|
|
257
257
|
const { strict: n = !1 } = e;
|
|
258
258
|
try {
|
|
259
|
-
return
|
|
259
|
+
return dr(t, { strict: n }), !0;
|
|
260
260
|
} catch {
|
|
261
261
|
return !1;
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
-
class
|
|
264
|
+
class bt extends ie {
|
|
265
265
|
constructor(e) {
|
|
266
|
-
super(`Value \`${typeof e == "object" ?
|
|
266
|
+
super(`Value \`${typeof e == "object" ? lr(e) : e}\` of type \`${typeof e}\` is an invalid hex type.`, {
|
|
267
267
|
metaMessages: ['Hex types must be represented as `"0x${string}"`.']
|
|
268
268
|
}), Object.defineProperty(this, "name", {
|
|
269
269
|
enumerable: !0,
|
|
@@ -273,7 +273,7 @@ class yt extends ie {
|
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
class
|
|
276
|
+
class xt extends ie {
|
|
277
277
|
constructor(e) {
|
|
278
278
|
super(`Value \`${e}\` is an invalid hex value.`, {
|
|
279
279
|
metaMessages: [
|
|
@@ -287,40 +287,40 @@ class Ct extends ie {
|
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
const
|
|
291
|
-
class
|
|
290
|
+
const hr = "starknet:";
|
|
291
|
+
class ur extends Error {
|
|
292
292
|
constructor(e) {
|
|
293
293
|
super(e), this.name = "StarknetChainError";
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
const
|
|
296
|
+
const fr = [
|
|
297
297
|
"starknet:0x534e5f4d41494e",
|
|
298
298
|
// mainnet
|
|
299
299
|
"starknet:0x534e5f5345504f4c4941"
|
|
300
300
|
// sepolia
|
|
301
301
|
];
|
|
302
|
-
function
|
|
302
|
+
function Dt(t) {
|
|
303
303
|
const e = t.split(":");
|
|
304
|
-
return e.length !== 2 || e[0] !== "starknet" ? !1 :
|
|
304
|
+
return e.length !== 2 || e[0] !== "starknet" ? !1 : Vt(e[1]);
|
|
305
305
|
}
|
|
306
|
-
function
|
|
307
|
-
if (!
|
|
308
|
-
throw new
|
|
309
|
-
return `${
|
|
306
|
+
function Zt(t) {
|
|
307
|
+
if (!Vt(t))
|
|
308
|
+
throw new ur(`Invalid Starknet chain id: ${t}`);
|
|
309
|
+
return `${hr}${t}`;
|
|
310
310
|
}
|
|
311
|
-
const
|
|
312
|
-
var
|
|
311
|
+
const pr = "starknet:walletApi";
|
|
312
|
+
var Qe = (t, e, n) => {
|
|
313
313
|
if (!e.has(t))
|
|
314
314
|
throw TypeError("Cannot " + n);
|
|
315
|
-
}, E = (t, e, n) => (
|
|
315
|
+
}, E = (t, e, n) => (Qe(t, e, "read from private field"), n ? n.call(t) : e.get(t)), B = (t, e, n) => {
|
|
316
316
|
if (e.has(t))
|
|
317
317
|
throw TypeError("Cannot add the same private member more than once");
|
|
318
318
|
e instanceof WeakSet ? e.add(t) : e.set(t, n);
|
|
319
|
-
},
|
|
320
|
-
class
|
|
319
|
+
}, ye = (t, e, n, r) => (Qe(t, e, "write to private field"), e.set(t, n), n), I = (t, e, n) => (Qe(t, e, "access private method"), n), z, L, Oe, Fe, ze, D, J, je, Kt, oe, Ee, He, Xt, We, Gt, Ce, et, qe, Yt, tt, Jt;
|
|
320
|
+
class wr {
|
|
321
321
|
constructor(e) {
|
|
322
|
-
this.injected = e,
|
|
323
|
-
if (!E(this,
|
|
322
|
+
this.injected = e, B(this, D), B(this, je), B(this, oe), B(this, He), B(this, We), B(this, Ce), B(this, qe), B(this, tt), B(this, z, {}), B(this, L, null), B(this, Oe, async ({ silent: n }) => {
|
|
323
|
+
if (!E(this, L)) {
|
|
324
324
|
const r = await this.injected.request({
|
|
325
325
|
type: "wallet_requestAccounts",
|
|
326
326
|
params: {
|
|
@@ -329,12 +329,12 @@ class pr {
|
|
|
329
329
|
});
|
|
330
330
|
if (r.length === 0)
|
|
331
331
|
return { accounts: [] };
|
|
332
|
-
await
|
|
332
|
+
await I(this, Ce, et).call(this, r);
|
|
333
333
|
}
|
|
334
334
|
return { accounts: this.accounts };
|
|
335
|
-
}),
|
|
336
|
-
|
|
337
|
-
}),
|
|
335
|
+
}), B(this, Fe, async () => {
|
|
336
|
+
I(this, oe, Ee).call(this);
|
|
337
|
+
}), B(this, ze, (n, r) => (E(this, z)[n] || (E(this, z)[n] = []), E(this, z)[n].push(r), () => I(this, je, Kt).call(this, n, r))), this.injected.on("accountsChanged", I(this, He, Xt).bind(this)), this.injected.on("networkChanged", I(this, We, Gt).bind(this));
|
|
338
338
|
}
|
|
339
339
|
get version() {
|
|
340
340
|
return "1.0.0";
|
|
@@ -347,111 +347,111 @@ class pr {
|
|
|
347
347
|
}
|
|
348
348
|
get features() {
|
|
349
349
|
return {
|
|
350
|
-
[Pn]: {
|
|
351
|
-
version: "1.0.0",
|
|
352
|
-
connect: E(this, Me).bind(this)
|
|
353
|
-
},
|
|
354
350
|
[Tn]: {
|
|
355
351
|
version: "1.0.0",
|
|
356
|
-
|
|
352
|
+
connect: E(this, Oe).bind(this)
|
|
357
353
|
},
|
|
358
354
|
[Nn]: {
|
|
359
355
|
version: "1.0.0",
|
|
360
|
-
|
|
356
|
+
disconnect: E(this, Fe).bind(this)
|
|
357
|
+
},
|
|
358
|
+
[Bn]: {
|
|
359
|
+
version: "1.0.0",
|
|
360
|
+
on: E(this, ze).bind(this)
|
|
361
361
|
},
|
|
362
|
-
[
|
|
362
|
+
[pr]: {
|
|
363
363
|
version: "1.0.0",
|
|
364
|
-
request:
|
|
364
|
+
request: I(this, qe, Yt).bind(this),
|
|
365
365
|
walletVersion: this.injected.version
|
|
366
366
|
}
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
369
|
get chains() {
|
|
370
|
-
return
|
|
370
|
+
return fr.slice();
|
|
371
371
|
}
|
|
372
372
|
get accounts() {
|
|
373
|
-
return E(this,
|
|
373
|
+
return E(this, L) ? [
|
|
374
374
|
{
|
|
375
|
-
address: E(this,
|
|
375
|
+
address: E(this, L).address,
|
|
376
376
|
publicKey: new Uint8Array(),
|
|
377
|
-
chains: [E(this,
|
|
377
|
+
chains: [E(this, L).chain],
|
|
378
378
|
features: []
|
|
379
379
|
}
|
|
380
380
|
] : [];
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
z = /* @__PURE__ */ new WeakMap();
|
|
384
|
-
|
|
385
|
-
Me = /* @__PURE__ */ new WeakMap();
|
|
386
|
-
Re = /* @__PURE__ */ new WeakMap();
|
|
384
|
+
L = /* @__PURE__ */ new WeakMap();
|
|
387
385
|
Oe = /* @__PURE__ */ new WeakMap();
|
|
386
|
+
Fe = /* @__PURE__ */ new WeakMap();
|
|
387
|
+
ze = /* @__PURE__ */ new WeakMap();
|
|
388
388
|
D = /* @__PURE__ */ new WeakSet();
|
|
389
389
|
J = function(t, ...e) {
|
|
390
390
|
if (E(this, z)[t])
|
|
391
391
|
for (const n of E(this, z)[t])
|
|
392
392
|
n.apply(null, e);
|
|
393
393
|
};
|
|
394
|
-
|
|
395
|
-
|
|
394
|
+
je = /* @__PURE__ */ new WeakSet();
|
|
395
|
+
Kt = function(t, e) {
|
|
396
396
|
E(this, z)[t] = E(this, z)[t]?.filter(
|
|
397
397
|
(n) => e !== n
|
|
398
398
|
);
|
|
399
399
|
};
|
|
400
400
|
oe = /* @__PURE__ */ new WeakSet();
|
|
401
|
-
|
|
402
|
-
E(this,
|
|
401
|
+
Ee = function() {
|
|
402
|
+
E(this, L) && (ye(this, L, null), I(this, D, J).call(this, "change", { accounts: this.accounts }));
|
|
403
403
|
};
|
|
404
|
-
|
|
405
|
-
|
|
404
|
+
He = /* @__PURE__ */ new WeakSet();
|
|
405
|
+
Xt = async function(t) {
|
|
406
406
|
if (!t || t.length === 0) {
|
|
407
|
-
|
|
407
|
+
I(this, oe, Ee).call(this);
|
|
408
408
|
return;
|
|
409
409
|
}
|
|
410
|
-
E(this,
|
|
410
|
+
E(this, L) && await I(this, Ce, et).call(this, t);
|
|
411
411
|
};
|
|
412
|
-
|
|
413
|
-
|
|
412
|
+
We = /* @__PURE__ */ new WeakSet();
|
|
413
|
+
Gt = function(t, e) {
|
|
414
414
|
if (!t) {
|
|
415
|
-
|
|
415
|
+
I(this, oe, Ee).call(this);
|
|
416
416
|
return;
|
|
417
417
|
}
|
|
418
|
-
if (!E(this,
|
|
418
|
+
if (!E(this, L))
|
|
419
419
|
return;
|
|
420
|
-
const n =
|
|
421
|
-
if (!
|
|
420
|
+
const n = Zt(t);
|
|
421
|
+
if (!Dt(n))
|
|
422
422
|
throw new Error(`Invalid Starknet chain: ${n}`);
|
|
423
423
|
if (e?.length > 0) {
|
|
424
424
|
const [r] = e;
|
|
425
|
-
|
|
425
|
+
ye(this, L, { address: r, chain: n }), I(this, D, J).call(this, "change", { accounts: this.accounts });
|
|
426
426
|
} else
|
|
427
|
-
|
|
427
|
+
ye(this, L, { address: E(this, L)?.address, chain: n }), I(this, D, J).call(this, "change", { accounts: this.accounts });
|
|
428
428
|
};
|
|
429
|
-
|
|
430
|
-
|
|
429
|
+
Ce = /* @__PURE__ */ new WeakSet();
|
|
430
|
+
et = async function(t) {
|
|
431
431
|
if (t.length === 0)
|
|
432
432
|
return;
|
|
433
433
|
const [e] = t;
|
|
434
|
-
if (E(this,
|
|
435
|
-
E(this,
|
|
434
|
+
if (E(this, L)?.chain)
|
|
435
|
+
E(this, L).address = e, I(this, D, J).call(this, "change", { accounts: this.accounts });
|
|
436
436
|
else {
|
|
437
|
-
const n = await
|
|
438
|
-
|
|
437
|
+
const n = await I(this, tt, Jt).call(this);
|
|
438
|
+
ye(this, L, { address: e, chain: n }), I(this, D, J).call(this, "change", { accounts: this.accounts });
|
|
439
439
|
}
|
|
440
440
|
};
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
qe = /* @__PURE__ */ new WeakSet();
|
|
442
|
+
Yt = function(...t) {
|
|
443
443
|
return this.injected.request(...t);
|
|
444
444
|
};
|
|
445
|
-
|
|
446
|
-
|
|
445
|
+
tt = /* @__PURE__ */ new WeakSet();
|
|
446
|
+
Jt = async function() {
|
|
447
447
|
const t = await this.injected.request({
|
|
448
448
|
type: "wallet_requestChainId"
|
|
449
|
-
}), e =
|
|
450
|
-
if (!
|
|
449
|
+
}), e = Zt(t);
|
|
450
|
+
if (!Dt(e))
|
|
451
451
|
throw new Error(`Invalid Starknet chain: ${e}`);
|
|
452
452
|
return e;
|
|
453
453
|
};
|
|
454
|
-
class
|
|
454
|
+
class _e extends Sn {
|
|
455
455
|
keychain;
|
|
456
456
|
modal;
|
|
457
457
|
options;
|
|
@@ -475,7 +475,7 @@ class Le extends En {
|
|
|
475
475
|
* @returns response from addTransaction
|
|
476
476
|
*/
|
|
477
477
|
async execute(e) {
|
|
478
|
-
return e =
|
|
478
|
+
return e = $n(e), new Promise(async (n, r) => {
|
|
479
479
|
const s = await this.keychain.execute(
|
|
480
480
|
e,
|
|
481
481
|
void 0,
|
|
@@ -483,15 +483,15 @@ class Le extends En {
|
|
|
483
483
|
!1,
|
|
484
484
|
this.options?.feeSource
|
|
485
485
|
);
|
|
486
|
-
if (s.code ===
|
|
486
|
+
if (s.code === R.SUCCESS) {
|
|
487
487
|
n(s);
|
|
488
488
|
return;
|
|
489
489
|
}
|
|
490
|
-
if (this.options?.propagateSessionErrors && s.code !==
|
|
490
|
+
if (this.options?.propagateSessionErrors && s.code !== R.USER_INTERACTION_REQUIRED) {
|
|
491
491
|
r(s.error);
|
|
492
492
|
return;
|
|
493
493
|
}
|
|
494
|
-
const i = this.options?.errorDisplayMode || "modal", o = s.error, a = s.code ===
|
|
494
|
+
const i = this.options?.errorDisplayMode || "modal", o = s.error, a = s.code === R.USER_INTERACTION_REQUIRED;
|
|
495
495
|
if (i === "silent" && !a) {
|
|
496
496
|
console.warn(
|
|
497
497
|
"[Cartridge Controller] Transaction failed silently:",
|
|
@@ -500,7 +500,7 @@ class Le extends En {
|
|
|
500
500
|
return;
|
|
501
501
|
}
|
|
502
502
|
if (i === "notification" && !a) {
|
|
503
|
-
const { toast: c } = await Promise.resolve().then(() =>
|
|
503
|
+
const { toast: c } = await Promise.resolve().then(() => Ai);
|
|
504
504
|
let d = !1, h;
|
|
505
505
|
h = c({
|
|
506
506
|
variant: "error",
|
|
@@ -508,7 +508,7 @@ class Le extends En {
|
|
|
508
508
|
duration: 1e4,
|
|
509
509
|
onClick: () => {
|
|
510
510
|
d = !0, h && h(), this.modal.open(), this.keychain.execute(e, void 0, void 0, !0, o).then((u) => {
|
|
511
|
-
u.code ===
|
|
511
|
+
u.code === R.SUCCESS ? (n(u), this.modal.close()) : r(u.error);
|
|
512
512
|
});
|
|
513
513
|
}
|
|
514
514
|
}), setTimeout(() => {
|
|
@@ -524,7 +524,7 @@ class Le extends En {
|
|
|
524
524
|
!0,
|
|
525
525
|
o
|
|
526
526
|
);
|
|
527
|
-
if (l.code ===
|
|
527
|
+
if (l.code === R.SUCCESS) {
|
|
528
528
|
n(l), this.modal.close();
|
|
529
529
|
return;
|
|
530
530
|
}
|
|
@@ -552,10 +552,10 @@ class Le extends En {
|
|
|
552
552
|
});
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
|
-
var
|
|
555
|
+
var O;
|
|
556
556
|
(function(t) {
|
|
557
557
|
t.Call = "call", t.Reply = "reply", t.Syn = "syn", t.SynAck = "synAck", t.Ack = "ack";
|
|
558
|
-
})(
|
|
558
|
+
})(O || (O = {}));
|
|
559
559
|
var q;
|
|
560
560
|
(function(t) {
|
|
561
561
|
t.Fulfilled = "fulfilled", t.Rejected = "rejected";
|
|
@@ -564,15 +564,15 @@ var ae;
|
|
|
564
564
|
(function(t) {
|
|
565
565
|
t.ConnectionDestroyed = "ConnectionDestroyed", t.ConnectionTimeout = "ConnectionTimeout", t.NoIframeSrc = "NoIframeSrc";
|
|
566
566
|
})(ae || (ae = {}));
|
|
567
|
-
var
|
|
567
|
+
var Ve;
|
|
568
568
|
(function(t) {
|
|
569
569
|
t.DataCloneError = "DataCloneError";
|
|
570
|
-
})(
|
|
570
|
+
})(Ve || (Ve = {}));
|
|
571
571
|
var H;
|
|
572
572
|
(function(t) {
|
|
573
573
|
t.Message = "message";
|
|
574
574
|
})(H || (H = {}));
|
|
575
|
-
const
|
|
575
|
+
const gr = (t, e) => {
|
|
576
576
|
const n = [];
|
|
577
577
|
let r = !1;
|
|
578
578
|
return {
|
|
@@ -585,31 +585,31 @@ const wr = (t, e) => {
|
|
|
585
585
|
r ? s() : n.push(s);
|
|
586
586
|
}
|
|
587
587
|
};
|
|
588
|
-
},
|
|
588
|
+
}, mr = (t) => (...e) => {
|
|
589
589
|
t && console.log("[Penpal]", ...e);
|
|
590
|
-
},
|
|
590
|
+
}, yr = {
|
|
591
591
|
"http:": "80",
|
|
592
592
|
"https:": "443"
|
|
593
|
-
},
|
|
594
|
-
if (t &&
|
|
593
|
+
}, Cr = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, br = ["file:", "data:"], xr = (t) => {
|
|
594
|
+
if (t && br.find((a) => t.startsWith(a)))
|
|
595
595
|
return "null";
|
|
596
|
-
const e = document.location, n =
|
|
596
|
+
const e = document.location, n = Cr.exec(t);
|
|
597
597
|
let r, s, i;
|
|
598
598
|
n ? (r = n[1] ? n[1] : e.protocol, s = n[2], i = n[4]) : (r = e.protocol, s = e.hostname, i = e.port);
|
|
599
|
-
const o = i && i !==
|
|
599
|
+
const o = i && i !== yr[r] ? `:${i}` : "";
|
|
600
600
|
return `${r}//${s}${o}`;
|
|
601
|
-
},
|
|
601
|
+
}, kt = ({ name: t, message: e, stack: n }) => ({
|
|
602
602
|
name: t,
|
|
603
603
|
message: e,
|
|
604
604
|
stack: n
|
|
605
|
-
}),
|
|
605
|
+
}), kr = (t) => {
|
|
606
606
|
const e = new Error();
|
|
607
607
|
return Object.keys(t).forEach((n) => e[n] = t[n]), e;
|
|
608
|
-
},
|
|
608
|
+
}, vr = (t, e, n) => {
|
|
609
609
|
const { localName: r, local: s, remote: i, originForSending: o, originForReceiving: a } = t;
|
|
610
610
|
let l = !1;
|
|
611
611
|
const c = (d) => {
|
|
612
|
-
if (d.source !== i || d.data.penpal !==
|
|
612
|
+
if (d.source !== i || d.data.penpal !== O.Call)
|
|
613
613
|
return;
|
|
614
614
|
if (a !== "*" && d.origin !== a) {
|
|
615
615
|
n(`${r} received message from origin ${d.origin} which did not match expected origin ${a}`);
|
|
@@ -617,101 +617,101 @@ const wr = (t, e) => {
|
|
|
617
617
|
}
|
|
618
618
|
const h = d.data, { methodName: u, args: f, id: w } = h;
|
|
619
619
|
n(`${r}: Received ${u}() call`);
|
|
620
|
-
const
|
|
620
|
+
const C = (m) => (T) => {
|
|
621
621
|
if (n(`${r}: Sending ${u}() reply`), l) {
|
|
622
622
|
n(`${r}: Unable to send ${u}() reply due to destroyed connection`);
|
|
623
623
|
return;
|
|
624
624
|
}
|
|
625
|
-
const
|
|
626
|
-
penpal:
|
|
625
|
+
const b = {
|
|
626
|
+
penpal: O.Reply,
|
|
627
627
|
id: w,
|
|
628
|
-
resolution:
|
|
629
|
-
returnValue:
|
|
628
|
+
resolution: m,
|
|
629
|
+
returnValue: T
|
|
630
630
|
};
|
|
631
|
-
|
|
631
|
+
m === q.Rejected && T instanceof Error && (b.returnValue = kt(T), b.returnValueIsError = !0);
|
|
632
632
|
try {
|
|
633
|
-
i.postMessage(
|
|
633
|
+
i.postMessage(b, o);
|
|
634
634
|
} catch (g) {
|
|
635
|
-
if (g.name ===
|
|
636
|
-
const
|
|
637
|
-
penpal:
|
|
635
|
+
if (g.name === Ve.DataCloneError) {
|
|
636
|
+
const S = {
|
|
637
|
+
penpal: O.Reply,
|
|
638
638
|
id: w,
|
|
639
639
|
resolution: q.Rejected,
|
|
640
|
-
returnValue:
|
|
640
|
+
returnValue: kt(g),
|
|
641
641
|
returnValueIsError: !0
|
|
642
642
|
};
|
|
643
|
-
i.postMessage(
|
|
643
|
+
i.postMessage(S, o);
|
|
644
644
|
}
|
|
645
645
|
throw g;
|
|
646
646
|
}
|
|
647
647
|
};
|
|
648
|
-
new Promise((
|
|
648
|
+
new Promise((m) => m(e[u].call(e, d.origin).apply(e, f))).then(C(q.Fulfilled), C(q.Rejected));
|
|
649
649
|
};
|
|
650
650
|
return s.addEventListener(H.Message, c), () => {
|
|
651
651
|
l = !0, s.removeEventListener(H.Message, c);
|
|
652
652
|
};
|
|
653
653
|
};
|
|
654
|
-
let
|
|
655
|
-
const
|
|
656
|
-
const n =
|
|
657
|
-
return n.push(t),
|
|
658
|
-
},
|
|
659
|
-
const r =
|
|
654
|
+
let Er = 0;
|
|
655
|
+
const Ar = () => ++Er, Qt = ".", en = (t) => t ? t.split(Qt) : [], Sr = (t) => t.join(Qt), $r = (t, e) => {
|
|
656
|
+
const n = en(e || "");
|
|
657
|
+
return n.push(t), Sr(n);
|
|
658
|
+
}, Lr = (t, e, n) => {
|
|
659
|
+
const r = en(e);
|
|
660
660
|
return r.reduce((s, i, o) => (typeof s[i] > "u" && (s[i] = {}), o === r.length - 1 && (s[i] = n), s[i]), t), t;
|
|
661
|
-
},
|
|
661
|
+
}, tn = (t, e) => {
|
|
662
662
|
const n = {};
|
|
663
663
|
return Object.keys(t).forEach((r) => {
|
|
664
|
-
const s = t[r], i =
|
|
665
|
-
typeof s == "object" && Object.assign(n,
|
|
664
|
+
const s = t[r], i = $r(r, e);
|
|
665
|
+
typeof s == "object" && Object.assign(n, tn(s, i)), typeof s == "function" && (n[i] = s);
|
|
666
666
|
}), n;
|
|
667
|
-
},
|
|
667
|
+
}, _r = (t) => {
|
|
668
668
|
const e = {};
|
|
669
669
|
for (const n in t)
|
|
670
|
-
|
|
670
|
+
Lr(e, n, t[n]);
|
|
671
671
|
return e;
|
|
672
|
-
},
|
|
672
|
+
}, Ir = (t, e, n, r, s) => {
|
|
673
673
|
const { localName: i, local: o, remote: a, originForSending: l, originForReceiving: c } = e;
|
|
674
674
|
let d = !1;
|
|
675
675
|
s(`${i}: Connecting call sender`);
|
|
676
676
|
const h = (f) => (...w) => {
|
|
677
677
|
s(`${i}: Sending ${f}() call`);
|
|
678
|
-
let
|
|
678
|
+
let C;
|
|
679
679
|
try {
|
|
680
|
-
a.closed && (
|
|
680
|
+
a.closed && (C = !0);
|
|
681
681
|
} catch {
|
|
682
|
-
|
|
682
|
+
C = !0;
|
|
683
683
|
}
|
|
684
|
-
if (
|
|
685
|
-
const
|
|
686
|
-
throw
|
|
684
|
+
if (C && r(), d) {
|
|
685
|
+
const m = new Error(`Unable to send ${f}() call due to destroyed connection`);
|
|
686
|
+
throw m.code = ae.ConnectionDestroyed, m;
|
|
687
687
|
}
|
|
688
|
-
return new Promise((
|
|
689
|
-
const
|
|
690
|
-
if (
|
|
688
|
+
return new Promise((m, T) => {
|
|
689
|
+
const b = Ar(), g = (_) => {
|
|
690
|
+
if (_.source !== a || _.data.penpal !== O.Reply || _.data.id !== b)
|
|
691
691
|
return;
|
|
692
|
-
if (c !== "*" &&
|
|
693
|
-
s(`${i} received message from origin ${
|
|
692
|
+
if (c !== "*" && _.origin !== c) {
|
|
693
|
+
s(`${i} received message from origin ${_.origin} which did not match expected origin ${c}`);
|
|
694
694
|
return;
|
|
695
695
|
}
|
|
696
|
-
const
|
|
696
|
+
const x = _.data;
|
|
697
697
|
s(`${i}: Received ${f}() reply`), o.removeEventListener(H.Message, g);
|
|
698
|
-
let
|
|
699
|
-
|
|
698
|
+
let X = x.returnValue;
|
|
699
|
+
x.returnValueIsError && (X = kr(X)), (x.resolution === q.Fulfilled ? m : T)(X);
|
|
700
700
|
};
|
|
701
701
|
o.addEventListener(H.Message, g);
|
|
702
|
-
const
|
|
703
|
-
penpal:
|
|
704
|
-
id:
|
|
702
|
+
const S = {
|
|
703
|
+
penpal: O.Call,
|
|
704
|
+
id: b,
|
|
705
705
|
methodName: f,
|
|
706
706
|
args: w
|
|
707
707
|
};
|
|
708
|
-
a.postMessage(
|
|
708
|
+
a.postMessage(S, l);
|
|
709
709
|
});
|
|
710
710
|
}, u = n.reduce((f, w) => (f[w] = h(w), f), {});
|
|
711
|
-
return Object.assign(t,
|
|
711
|
+
return Object.assign(t, _r(u)), () => {
|
|
712
712
|
d = !0;
|
|
713
713
|
};
|
|
714
|
-
},
|
|
714
|
+
}, Pr = (t, e, n, r, s) => {
|
|
715
715
|
const { destroy: i, onDestroy: o } = r;
|
|
716
716
|
let a, l;
|
|
717
717
|
const c = {};
|
|
@@ -728,13 +728,13 @@ const Er = () => ++vr, Yt = ".", Jt = (t) => t ? t.split(Yt) : [], Ar = (t) => t
|
|
|
728
728
|
originForSending: n,
|
|
729
729
|
originForReceiving: e
|
|
730
730
|
};
|
|
731
|
-
a && a(), a =
|
|
731
|
+
a && a(), a = vr(h, t, s), o(a), l && l.forEach((f) => {
|
|
732
732
|
delete c[f];
|
|
733
733
|
}), l = d.data.methodNames;
|
|
734
|
-
const u =
|
|
734
|
+
const u = Ir(c, h, l, i, s);
|
|
735
735
|
return o(u), c;
|
|
736
736
|
};
|
|
737
|
-
},
|
|
737
|
+
}, Tr = (t, e, n, r) => (s) => {
|
|
738
738
|
if (!s.source)
|
|
739
739
|
return;
|
|
740
740
|
if (n !== "*" && s.origin !== n) {
|
|
@@ -743,18 +743,18 @@ const Er = () => ++vr, Yt = ".", Jt = (t) => t ? t.split(Yt) : [], Ar = (t) => t
|
|
|
743
743
|
}
|
|
744
744
|
t("Parent: Handshake - Received SYN, responding with SYN-ACK");
|
|
745
745
|
const i = {
|
|
746
|
-
penpal:
|
|
746
|
+
penpal: O.SynAck,
|
|
747
747
|
methodNames: Object.keys(e)
|
|
748
748
|
};
|
|
749
749
|
s.source.postMessage(i, r);
|
|
750
|
-
},
|
|
750
|
+
}, Nr = 6e4, Br = (t, e) => {
|
|
751
751
|
const { destroy: n, onDestroy: r } = e, s = setInterval(() => {
|
|
752
752
|
t.isConnected || (clearInterval(s), n());
|
|
753
|
-
},
|
|
753
|
+
}, Nr);
|
|
754
754
|
r(() => {
|
|
755
755
|
clearInterval(s);
|
|
756
756
|
});
|
|
757
|
-
},
|
|
757
|
+
}, Ur = (t, e) => {
|
|
758
758
|
let n;
|
|
759
759
|
return t !== void 0 && (n = window.setTimeout(() => {
|
|
760
760
|
const r = new Error(`Connection timed out after ${t}ms`);
|
|
@@ -762,48 +762,48 @@ const Er = () => ++vr, Yt = ".", Jt = (t) => t ? t.split(Yt) : [], Ar = (t) => t
|
|
|
762
762
|
}, t)), () => {
|
|
763
763
|
clearTimeout(n);
|
|
764
764
|
};
|
|
765
|
-
},
|
|
765
|
+
}, Mr = (t) => {
|
|
766
766
|
if (!t.src && !t.srcdoc) {
|
|
767
767
|
const e = new Error("Iframe must have src or srcdoc property defined.");
|
|
768
768
|
throw e.code = ae.NoIframeSrc, e;
|
|
769
769
|
}
|
|
770
|
-
},
|
|
770
|
+
}, Rr = (t) => {
|
|
771
771
|
let { iframe: e, methods: n = {}, childOrigin: r, timeout: s, debug: i = !1 } = t;
|
|
772
|
-
const o =
|
|
773
|
-
r || (
|
|
774
|
-
const d = r === "null" ? "*" : r, h =
|
|
772
|
+
const o = mr(i), a = gr("Parent", o), { onDestroy: l, destroy: c } = a;
|
|
773
|
+
r || (Mr(e), r = xr(e.src));
|
|
774
|
+
const d = r === "null" ? "*" : r, h = tn(n), u = Tr(o, h, r, d), f = Pr(h, r, d, a, o);
|
|
775
775
|
return {
|
|
776
|
-
promise: new Promise((
|
|
777
|
-
const
|
|
776
|
+
promise: new Promise((C, m) => {
|
|
777
|
+
const T = Ur(s, c), b = (g) => {
|
|
778
778
|
if (!(g.source !== e.contentWindow || !g.data)) {
|
|
779
|
-
if (g.data.penpal ===
|
|
779
|
+
if (g.data.penpal === O.Syn) {
|
|
780
780
|
u(g);
|
|
781
781
|
return;
|
|
782
782
|
}
|
|
783
|
-
if (g.data.penpal ===
|
|
784
|
-
const
|
|
785
|
-
|
|
783
|
+
if (g.data.penpal === O.Ack) {
|
|
784
|
+
const S = f(g);
|
|
785
|
+
S && (T(), C(S));
|
|
786
786
|
return;
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
789
|
};
|
|
790
|
-
window.addEventListener(H.Message,
|
|
791
|
-
window.removeEventListener(H.Message,
|
|
790
|
+
window.addEventListener(H.Message, b), o("Parent: Awaiting handshake"), Br(e, a), l((g) => {
|
|
791
|
+
window.removeEventListener(H.Message, b), g && m(g);
|
|
792
792
|
});
|
|
793
793
|
}),
|
|
794
794
|
destroy() {
|
|
795
795
|
c();
|
|
796
796
|
}
|
|
797
797
|
};
|
|
798
|
-
},
|
|
799
|
-
function
|
|
798
|
+
}, Or = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
799
|
+
function nn(t) {
|
|
800
800
|
const e = t.toLowerCase();
|
|
801
|
-
return
|
|
801
|
+
return Or.has(e) || e.endsWith(".localhost");
|
|
802
802
|
}
|
|
803
|
-
function
|
|
803
|
+
function Fr(t) {
|
|
804
804
|
if (t.username || t.password)
|
|
805
805
|
throw new Error("Invalid keychain iframe URL: credentials are not allowed");
|
|
806
|
-
if (t.protocol !== "https:" && !(t.protocol === "http:" &&
|
|
806
|
+
if (t.protocol !== "https:" && !(t.protocol === "http:" && nn(t.hostname)))
|
|
807
807
|
throw new Error(
|
|
808
808
|
"Invalid keychain iframe URL: only https:// or local http:// URLs are allowed"
|
|
809
809
|
);
|
|
@@ -815,7 +815,7 @@ function zr(t) {
|
|
|
815
815
|
"clipboard-write",
|
|
816
816
|
"payment *"
|
|
817
817
|
];
|
|
818
|
-
return
|
|
818
|
+
return nn(t.hostname) && e.push("local-network-access *"), e.join("; ");
|
|
819
819
|
}
|
|
820
820
|
class jr {
|
|
821
821
|
url;
|
|
@@ -832,7 +832,7 @@ class jr {
|
|
|
832
832
|
}) {
|
|
833
833
|
if (typeof document > "u" || typeof window > "u")
|
|
834
834
|
return;
|
|
835
|
-
this.url = n,
|
|
835
|
+
this.url = n, Fr(n);
|
|
836
836
|
const o = document.head, a = document.createElement("meta");
|
|
837
837
|
a.name = "viewport", a.id = "controller-viewport", a.content = "width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, interactive-widget=resizes-content", o.appendChild(a);
|
|
838
838
|
const l = document.createElement("iframe");
|
|
@@ -856,7 +856,7 @@ class jr {
|
|
|
856
856
|
u.touches.length > 1 && u.preventDefault();
|
|
857
857
|
},
|
|
858
858
|
{ passive: !1 }
|
|
859
|
-
), this.iframe = l, this.container = c,
|
|
859
|
+
), this.iframe = l, this.container = c, Rr({
|
|
860
860
|
iframe: this.iframe,
|
|
861
861
|
childOrigin: n.origin,
|
|
862
862
|
methods: {
|
|
@@ -912,8 +912,8 @@ class jr {
|
|
|
912
912
|
return this.container?.style.display !== "none";
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
|
-
const
|
|
916
|
-
function
|
|
915
|
+
const Hr = "6.13.7";
|
|
916
|
+
function vt(t, e, n) {
|
|
917
917
|
for (let r in e) {
|
|
918
918
|
let s = e[r];
|
|
919
919
|
Object.defineProperty(t, r, { enumerable: !0, value: s, writable: !1 });
|
|
@@ -950,7 +950,7 @@ function G(t) {
|
|
|
950
950
|
}
|
|
951
951
|
return "[ COULD NOT SERIALIZE ]";
|
|
952
952
|
}
|
|
953
|
-
function
|
|
953
|
+
function Wr(t, e, n) {
|
|
954
954
|
let r = t;
|
|
955
955
|
{
|
|
956
956
|
const i = [];
|
|
@@ -964,7 +964,7 @@ function Hr(t, e, n) {
|
|
|
964
964
|
i.push(o + "=" + G(a));
|
|
965
965
|
}
|
|
966
966
|
}
|
|
967
|
-
i.push(`code=${e}`), i.push(`version=${
|
|
967
|
+
i.push(`code=${e}`), i.push(`version=${Hr}`), i.length && (t += " (" + i.join(", ") + ")");
|
|
968
968
|
}
|
|
969
969
|
let s;
|
|
970
970
|
switch (e) {
|
|
@@ -978,14 +978,14 @@ function Hr(t, e, n) {
|
|
|
978
978
|
default:
|
|
979
979
|
s = new Error(t);
|
|
980
980
|
}
|
|
981
|
-
return
|
|
981
|
+
return vt(s, { code: e }), n && Object.assign(s, n), s.shortMessage == null && vt(s, { shortMessage: r }), s;
|
|
982
982
|
}
|
|
983
|
-
function
|
|
983
|
+
function qr(t, e, n, r) {
|
|
984
984
|
if (!t)
|
|
985
|
-
throw
|
|
985
|
+
throw Wr(e, n, r);
|
|
986
986
|
}
|
|
987
987
|
function te(t, e, n, r) {
|
|
988
|
-
|
|
988
|
+
qr(t, e, "INVALID_ARGUMENT", { argument: n, value: r });
|
|
989
989
|
}
|
|
990
990
|
["NFD", "NFC", "NFKD", "NFKC"].reduce((t, e) => {
|
|
991
991
|
try {
|
|
@@ -998,7 +998,7 @@ function te(t, e, n, r) {
|
|
|
998
998
|
}
|
|
999
999
|
return t;
|
|
1000
1000
|
}, []);
|
|
1001
|
-
function
|
|
1001
|
+
function Vr(t, e, n) {
|
|
1002
1002
|
if (t instanceof Uint8Array)
|
|
1003
1003
|
return t;
|
|
1004
1004
|
if (typeof t == "string" && t.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
|
|
@@ -1010,60 +1010,60 @@ function qr(t, e, n) {
|
|
|
1010
1010
|
}
|
|
1011
1011
|
te(!1, "invalid BytesLike value", e || "value", t);
|
|
1012
1012
|
}
|
|
1013
|
-
function
|
|
1014
|
-
return
|
|
1013
|
+
function nt(t, e) {
|
|
1014
|
+
return Vr(t, e);
|
|
1015
1015
|
}
|
|
1016
|
-
const
|
|
1017
|
-
function
|
|
1018
|
-
const e =
|
|
1016
|
+
const Et = "0123456789abcdef";
|
|
1017
|
+
function Dr(t) {
|
|
1018
|
+
const e = nt(t);
|
|
1019
1019
|
let n = "0x";
|
|
1020
1020
|
for (let r = 0; r < e.length; r++) {
|
|
1021
1021
|
const s = e[r];
|
|
1022
|
-
n +=
|
|
1022
|
+
n += Et[(s & 240) >> 4] + Et[s & 15];
|
|
1023
1023
|
}
|
|
1024
1024
|
return n;
|
|
1025
1025
|
}
|
|
1026
|
-
let
|
|
1027
|
-
const
|
|
1028
|
-
return
|
|
1026
|
+
let rn = !1;
|
|
1027
|
+
const sn = function(t) {
|
|
1028
|
+
return ar(t);
|
|
1029
1029
|
};
|
|
1030
|
-
let
|
|
1030
|
+
let on = sn;
|
|
1031
1031
|
function ce(t) {
|
|
1032
|
-
const e =
|
|
1033
|
-
return
|
|
1032
|
+
const e = nt(t, "data");
|
|
1033
|
+
return Dr(on(e));
|
|
1034
1034
|
}
|
|
1035
|
-
ce._ =
|
|
1035
|
+
ce._ = sn;
|
|
1036
1036
|
ce.lock = function() {
|
|
1037
|
-
|
|
1037
|
+
rn = !0;
|
|
1038
1038
|
};
|
|
1039
1039
|
ce.register = function(t) {
|
|
1040
|
-
if (
|
|
1040
|
+
if (rn)
|
|
1041
1041
|
throw new TypeError("keccak256 is locked");
|
|
1042
|
-
|
|
1042
|
+
on = t;
|
|
1043
1043
|
};
|
|
1044
1044
|
Object.freeze(ce);
|
|
1045
|
-
const
|
|
1046
|
-
function
|
|
1045
|
+
const Zr = BigInt(0), Kr = BigInt(36);
|
|
1046
|
+
function At(t) {
|
|
1047
1047
|
t = t.toLowerCase();
|
|
1048
1048
|
const e = t.substring(2).split(""), n = new Uint8Array(40);
|
|
1049
1049
|
for (let s = 0; s < 40; s++)
|
|
1050
1050
|
n[s] = e[s].charCodeAt(0);
|
|
1051
|
-
const r =
|
|
1051
|
+
const r = nt(ce(n));
|
|
1052
1052
|
for (let s = 0; s < 40; s += 2)
|
|
1053
1053
|
r[s >> 1] >> 4 >= 8 && (e[s] = e[s].toUpperCase()), (r[s >> 1] & 15) >= 8 && (e[s + 1] = e[s + 1].toUpperCase());
|
|
1054
1054
|
return "0x" + e.join("");
|
|
1055
1055
|
}
|
|
1056
|
-
const
|
|
1056
|
+
const rt = {};
|
|
1057
1057
|
for (let t = 0; t < 10; t++)
|
|
1058
|
-
|
|
1058
|
+
rt[String(t)] = String(t);
|
|
1059
1059
|
for (let t = 0; t < 26; t++)
|
|
1060
|
-
|
|
1061
|
-
const
|
|
1062
|
-
function
|
|
1060
|
+
rt[String.fromCharCode(65 + t)] = String(10 + t);
|
|
1061
|
+
const St = 15;
|
|
1062
|
+
function Xr(t) {
|
|
1063
1063
|
t = t.toUpperCase(), t = t.substring(4) + t.substring(0, 2) + "00";
|
|
1064
|
-
let e = t.split("").map((r) =>
|
|
1065
|
-
for (; e.length >=
|
|
1066
|
-
let r = e.substring(0,
|
|
1064
|
+
let e = t.split("").map((r) => rt[r]).join("");
|
|
1065
|
+
for (; e.length >= St; ) {
|
|
1066
|
+
let r = e.substring(0, St);
|
|
1067
1067
|
e = parseInt(r, 10) % 97 + e.substring(r.length);
|
|
1068
1068
|
}
|
|
1069
1069
|
let n = String(98 - parseInt(e, 10) % 97);
|
|
@@ -1071,7 +1071,7 @@ function Kr(t) {
|
|
|
1071
1071
|
n = "0" + n;
|
|
1072
1072
|
return n;
|
|
1073
1073
|
}
|
|
1074
|
-
const
|
|
1074
|
+
const Gr = function() {
|
|
1075
1075
|
const t = {};
|
|
1076
1076
|
for (let e = 0; e < 36; e++) {
|
|
1077
1077
|
const n = "0123456789abcdefghijklmnopqrstuvwxyz"[e];
|
|
@@ -1079,29 +1079,29 @@ const Xr = function() {
|
|
|
1079
1079
|
}
|
|
1080
1080
|
return t;
|
|
1081
1081
|
}();
|
|
1082
|
-
function
|
|
1082
|
+
function Yr(t) {
|
|
1083
1083
|
t = t.toLowerCase();
|
|
1084
|
-
let e =
|
|
1084
|
+
let e = Zr;
|
|
1085
1085
|
for (let n = 0; n < t.length; n++)
|
|
1086
|
-
e = e *
|
|
1086
|
+
e = e * Kr + Gr[t[n]];
|
|
1087
1087
|
return e;
|
|
1088
1088
|
}
|
|
1089
|
-
function
|
|
1089
|
+
function F(t) {
|
|
1090
1090
|
if (te(typeof t == "string", "invalid address", "address", t), t.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
|
|
1091
1091
|
t.startsWith("0x") || (t = "0x" + t);
|
|
1092
|
-
const e =
|
|
1092
|
+
const e = At(t);
|
|
1093
1093
|
return te(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || e === t, "bad address checksum", "address", t), e;
|
|
1094
1094
|
}
|
|
1095
1095
|
if (t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
|
1096
|
-
te(t.substring(2, 4) ===
|
|
1097
|
-
let e =
|
|
1096
|
+
te(t.substring(2, 4) === Xr(t), "bad icap checksum", "address", t);
|
|
1097
|
+
let e = Yr(t.substring(4)).toString(16);
|
|
1098
1098
|
for (; e.length < 40; )
|
|
1099
1099
|
e = "0" + e;
|
|
1100
|
-
return
|
|
1100
|
+
return At("0x" + e);
|
|
1101
1101
|
}
|
|
1102
1102
|
te(!1, "invalid address", "address", t);
|
|
1103
1103
|
}
|
|
1104
|
-
class
|
|
1104
|
+
class Jr {
|
|
1105
1105
|
type = "argent";
|
|
1106
1106
|
platform = "starknet";
|
|
1107
1107
|
wallet = void 0;
|
|
@@ -1235,16 +1235,16 @@ class Yr {
|
|
|
1235
1235
|
this.removeAccountChangeListener(), this.wallet = void 0, this.account = void 0, this.connectedAccounts = [];
|
|
1236
1236
|
}
|
|
1237
1237
|
}
|
|
1238
|
-
function
|
|
1238
|
+
function Qr(t) {
|
|
1239
1239
|
if (typeof window > "u")
|
|
1240
1240
|
return;
|
|
1241
1241
|
const e = (n) => t(n.detail);
|
|
1242
1242
|
return window.addEventListener("eip6963:announceProvider", e), window.dispatchEvent(new CustomEvent("eip6963:requestProvider")), () => window.removeEventListener("eip6963:announceProvider", e);
|
|
1243
1243
|
}
|
|
1244
|
-
function
|
|
1244
|
+
function es() {
|
|
1245
1245
|
const t = /* @__PURE__ */ new Set();
|
|
1246
1246
|
let e = [];
|
|
1247
|
-
const n = () =>
|
|
1247
|
+
const n = () => Qr((s) => {
|
|
1248
1248
|
e.some(({ info: i }) => i.uuid === s.info.uuid) || (e = [...e, s], t.forEach((i) => i(e, { added: [s] })));
|
|
1249
1249
|
});
|
|
1250
1250
|
let r = n();
|
|
@@ -1272,7 +1272,7 @@ function Qr() {
|
|
|
1272
1272
|
}
|
|
1273
1273
|
};
|
|
1274
1274
|
}
|
|
1275
|
-
const
|
|
1275
|
+
const ts = {
|
|
1276
1276
|
"0x1": "ethereum",
|
|
1277
1277
|
// ethereum mainnet
|
|
1278
1278
|
"0xaa36a7": "ethereum",
|
|
@@ -1289,27 +1289,38 @@ const es = {
|
|
|
1289
1289
|
// op mainnet
|
|
1290
1290
|
"0xaa37dc": "optimism",
|
|
1291
1291
|
// op sepolia
|
|
1292
|
-
[
|
|
1293
|
-
[
|
|
1294
|
-
},
|
|
1295
|
-
const e =
|
|
1292
|
+
[ge.StarknetChainId.SN_MAIN]: "starknet",
|
|
1293
|
+
[ge.StarknetChainId.SN_SEPOLIA]: "starknet"
|
|
1294
|
+
}, Ie = (t) => {
|
|
1295
|
+
const e = Bt.toHex(t), n = ts[e];
|
|
1296
1296
|
return n || console.warn(`Unknown chain ID: ${e}`), n;
|
|
1297
1297
|
};
|
|
1298
|
-
|
|
1298
|
+
let Pe;
|
|
1299
|
+
function ns() {
|
|
1300
|
+
return Pe || (Pe = es()), Pe;
|
|
1301
|
+
}
|
|
1302
|
+
class Ae {
|
|
1299
1303
|
platform;
|
|
1300
1304
|
account = void 0;
|
|
1301
|
-
store = Qr();
|
|
1302
1305
|
provider;
|
|
1303
1306
|
connectedAccounts = [];
|
|
1304
1307
|
constructor() {
|
|
1305
1308
|
this.initializeIfAvailable();
|
|
1306
1309
|
}
|
|
1307
1310
|
getProvider() {
|
|
1308
|
-
|
|
1311
|
+
const e = ns().findProvider({ rdns: this.rdns });
|
|
1312
|
+
return e && (this.provider = e), this.provider;
|
|
1309
1313
|
}
|
|
1310
1314
|
getEthereumProvider() {
|
|
1311
1315
|
const e = this.getProvider();
|
|
1312
|
-
return e ? e.provider : this.
|
|
1316
|
+
return e ? e.provider : this.getFallbackProvider();
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Fallback provider detection when EIP-6963 announcement is missed.
|
|
1320
|
+
* Subclasses can override to provide wallet-specific fallback logic.
|
|
1321
|
+
*/
|
|
1322
|
+
getFallbackProvider() {
|
|
1323
|
+
return null;
|
|
1313
1324
|
}
|
|
1314
1325
|
initializeIfAvailable() {
|
|
1315
1326
|
this.getProvider() && !this.initialized && (this.initialized = !0, this.initializeProvider());
|
|
@@ -1320,22 +1331,20 @@ class Ee {
|
|
|
1320
1331
|
e && (e.provider.request({
|
|
1321
1332
|
method: "eth_accounts"
|
|
1322
1333
|
}).then((n) => {
|
|
1323
|
-
this.connectedAccounts = n.map(
|
|
1334
|
+
this.connectedAccounts = n.map(F), n.length > 0 && (this.account = F(n[0]));
|
|
1324
1335
|
}).catch(console.error), e.provider.request({
|
|
1325
1336
|
method: "eth_chainId"
|
|
1326
1337
|
}).then((n) => {
|
|
1327
|
-
this.platform =
|
|
1338
|
+
this.platform = Ie(n);
|
|
1328
1339
|
}).catch(console.error), e.provider?.on("chainChanged", (n) => {
|
|
1329
|
-
this.platform =
|
|
1340
|
+
this.platform = Ie(n);
|
|
1330
1341
|
}), e.provider?.on("accountsChanged", (n) => {
|
|
1331
|
-
n && (this.connectedAccounts = n.map((r) =>
|
|
1342
|
+
n && (this.connectedAccounts = n.map((r) => F(r)), this.account = n.length > 0 ? F(n[0]) : void 0);
|
|
1332
1343
|
}));
|
|
1333
1344
|
}
|
|
1334
1345
|
isAvailable() {
|
|
1335
|
-
if (Sn())
|
|
1336
|
-
return !1;
|
|
1337
1346
|
const e = this.getProvider();
|
|
1338
|
-
return
|
|
1347
|
+
return e && !this.initialized && this.initializeIfAvailable(), e ? !0 : typeof window < "u" && !!this.getFallbackProvider();
|
|
1339
1348
|
}
|
|
1340
1349
|
getInfo() {
|
|
1341
1350
|
const e = this.isAvailable();
|
|
@@ -1353,25 +1362,24 @@ class Ee {
|
|
|
1353
1362
|
return this.connectedAccounts;
|
|
1354
1363
|
}
|
|
1355
1364
|
async connect(e) {
|
|
1356
|
-
if (e && this.connectedAccounts.includes(
|
|
1365
|
+
if (e && this.connectedAccounts.includes(F(e)) && (this.account = F(e)), this.account)
|
|
1357
1366
|
return { success: !0, wallet: this.type, account: this.account };
|
|
1358
1367
|
try {
|
|
1359
1368
|
if (!this.isAvailable())
|
|
1360
1369
|
throw new Error(`${this.displayName} is not available`);
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
if (r ? n = r.provider : this.rdns === "io.metamask" && window.ethereum?.isMetaMask && (n = window.ethereum), !n)
|
|
1370
|
+
const n = this.getEthereumProvider();
|
|
1371
|
+
if (!n)
|
|
1364
1372
|
throw new Error(`${this.displayName} provider not found`);
|
|
1365
|
-
const
|
|
1373
|
+
const r = await n.request({
|
|
1366
1374
|
method: "eth_requestAccounts"
|
|
1367
1375
|
});
|
|
1368
|
-
if (
|
|
1369
|
-
return this.account =
|
|
1376
|
+
if (r && r.length > 0)
|
|
1377
|
+
return this.account = F(r[0]), this.connectedAccounts = r.map(F), this.getProvider() || (this.provider = {
|
|
1370
1378
|
info: {
|
|
1371
|
-
uuid:
|
|
1372
|
-
name:
|
|
1379
|
+
uuid: `${this.rdns}-fallback`,
|
|
1380
|
+
name: this.displayName,
|
|
1373
1381
|
icon: "data:image/svg+xml;base64,",
|
|
1374
|
-
rdns:
|
|
1382
|
+
rdns: this.rdns
|
|
1375
1383
|
},
|
|
1376
1384
|
provider: n
|
|
1377
1385
|
}, this.initializeIfAvailable()), { success: !0, wallet: this.type, account: this.account };
|
|
@@ -1484,7 +1492,7 @@ class Ee {
|
|
|
1484
1492
|
return await n.request({
|
|
1485
1493
|
method: "wallet_switchEthereumChain",
|
|
1486
1494
|
params: [{ chainId: e }]
|
|
1487
|
-
}), this.platform =
|
|
1495
|
+
}), this.platform = Ie(e), !0;
|
|
1488
1496
|
} catch (r) {
|
|
1489
1497
|
throw r.code === 4902 && console.warn(`Chain not added to ${this.displayName}`), r;
|
|
1490
1498
|
}
|
|
@@ -1554,30 +1562,33 @@ class Ee {
|
|
|
1554
1562
|
}
|
|
1555
1563
|
}
|
|
1556
1564
|
}
|
|
1557
|
-
class
|
|
1565
|
+
class rs extends Ae {
|
|
1558
1566
|
type = "base";
|
|
1559
1567
|
rdns = "com.coinbase.wallet";
|
|
1560
1568
|
displayName = "Base Wallet";
|
|
1561
1569
|
}
|
|
1562
|
-
class
|
|
1570
|
+
class ss extends Ae {
|
|
1563
1571
|
type = "metamask";
|
|
1564
1572
|
rdns = "io.metamask";
|
|
1565
1573
|
displayName = "MetaMask";
|
|
1574
|
+
getFallbackProvider() {
|
|
1575
|
+
return window.ethereum?.isMetaMask ? window.ethereum : null;
|
|
1576
|
+
}
|
|
1566
1577
|
}
|
|
1567
1578
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1568
|
-
function
|
|
1579
|
+
function st(t) {
|
|
1569
1580
|
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
|
|
1570
1581
|
}
|
|
1571
|
-
function
|
|
1572
|
-
if (!
|
|
1582
|
+
function an(t, ...e) {
|
|
1583
|
+
if (!st(t))
|
|
1573
1584
|
throw new Error("Uint8Array expected");
|
|
1574
1585
|
if (e.length > 0 && !e.includes(t.length))
|
|
1575
1586
|
throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
|
|
1576
1587
|
}
|
|
1577
|
-
function
|
|
1588
|
+
function cn(t, e) {
|
|
1578
1589
|
return Array.isArray(e) ? e.length === 0 ? !0 : t ? e.every((n) => typeof n == "string") : e.every((n) => Number.isSafeInteger(n)) : !1;
|
|
1579
1590
|
}
|
|
1580
|
-
function
|
|
1591
|
+
function is(t) {
|
|
1581
1592
|
if (typeof t != "function")
|
|
1582
1593
|
throw new Error("function expected");
|
|
1583
1594
|
return !0;
|
|
@@ -1591,35 +1602,35 @@ function le(t) {
|
|
|
1591
1602
|
if (!Number.isSafeInteger(t))
|
|
1592
1603
|
throw new Error(`invalid integer: ${t}`);
|
|
1593
1604
|
}
|
|
1594
|
-
function
|
|
1605
|
+
function be(t) {
|
|
1595
1606
|
if (!Array.isArray(t))
|
|
1596
1607
|
throw new Error("array expected");
|
|
1597
1608
|
}
|
|
1598
|
-
function
|
|
1599
|
-
if (!
|
|
1609
|
+
function xe(t, e) {
|
|
1610
|
+
if (!cn(!0, e))
|
|
1600
1611
|
throw new Error(`${t}: array of strings expected`);
|
|
1601
1612
|
}
|
|
1602
|
-
function
|
|
1603
|
-
if (!
|
|
1613
|
+
function ln(t, e) {
|
|
1614
|
+
if (!cn(!1, e))
|
|
1604
1615
|
throw new Error(`${t}: array of numbers expected`);
|
|
1605
1616
|
}
|
|
1606
1617
|
// @__NO_SIDE_EFFECTS__
|
|
1607
|
-
function
|
|
1618
|
+
function it(...t) {
|
|
1608
1619
|
const e = (i) => i, n = (i, o) => (a) => i(o(a)), r = t.map((i) => i.encode).reduceRight(n, e), s = t.map((i) => i.decode).reduce(n, e);
|
|
1609
1620
|
return { encode: r, decode: s };
|
|
1610
1621
|
}
|
|
1611
1622
|
// @__NO_SIDE_EFFECTS__
|
|
1612
|
-
function
|
|
1623
|
+
function ot(t) {
|
|
1613
1624
|
const e = typeof t == "string" ? t.split("") : t, n = e.length;
|
|
1614
|
-
|
|
1625
|
+
xe("alphabet", e);
|
|
1615
1626
|
const r = new Map(e.map((s, i) => [s, i]));
|
|
1616
1627
|
return {
|
|
1617
|
-
encode: (s) => (
|
|
1628
|
+
encode: (s) => (be(s), s.map((i) => {
|
|
1618
1629
|
if (!Number.isSafeInteger(i) || i < 0 || i >= n)
|
|
1619
1630
|
throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${t}`);
|
|
1620
1631
|
return e[i];
|
|
1621
1632
|
})),
|
|
1622
|
-
decode: (s) => (
|
|
1633
|
+
decode: (s) => (be(s), s.map((i) => {
|
|
1623
1634
|
Q("alphabet.decode", i);
|
|
1624
1635
|
const o = r.get(i);
|
|
1625
1636
|
if (o === void 0)
|
|
@@ -1629,22 +1640,22 @@ function st(t) {
|
|
|
1629
1640
|
};
|
|
1630
1641
|
}
|
|
1631
1642
|
// @__NO_SIDE_EFFECTS__
|
|
1632
|
-
function
|
|
1643
|
+
function at(t = "") {
|
|
1633
1644
|
return Q("join", t), {
|
|
1634
|
-
encode: (e) => (
|
|
1645
|
+
encode: (e) => (xe("join.decode", e), e.join(t)),
|
|
1635
1646
|
decode: (e) => (Q("join.decode", e), e.split(t))
|
|
1636
1647
|
};
|
|
1637
1648
|
}
|
|
1638
1649
|
// @__NO_SIDE_EFFECTS__
|
|
1639
|
-
function
|
|
1650
|
+
function os(t, e = "=") {
|
|
1640
1651
|
return le(t), Q("padding", e), {
|
|
1641
1652
|
encode(n) {
|
|
1642
|
-
for (
|
|
1653
|
+
for (xe("padding.encode", n); n.length * t % 8; )
|
|
1643
1654
|
n.push(e);
|
|
1644
1655
|
return n;
|
|
1645
1656
|
},
|
|
1646
1657
|
decode(n) {
|
|
1647
|
-
|
|
1658
|
+
xe("padding.decode", n);
|
|
1648
1659
|
let r = n.length;
|
|
1649
1660
|
if (r * t % 8)
|
|
1650
1661
|
throw new Error("padding: invalid, string should have whole number of bytes");
|
|
@@ -1656,15 +1667,15 @@ function ss(t, e = "=") {
|
|
|
1656
1667
|
};
|
|
1657
1668
|
}
|
|
1658
1669
|
// @__NO_SIDE_EFFECTS__
|
|
1659
|
-
function
|
|
1660
|
-
return
|
|
1670
|
+
function as(t) {
|
|
1671
|
+
return is(t), { encode: (e) => e, decode: (e) => t(e) };
|
|
1661
1672
|
}
|
|
1662
|
-
function
|
|
1673
|
+
function $t(t, e, n) {
|
|
1663
1674
|
if (e < 2)
|
|
1664
1675
|
throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);
|
|
1665
1676
|
if (n < 2)
|
|
1666
1677
|
throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);
|
|
1667
|
-
if (
|
|
1678
|
+
if (be(t), !t.length)
|
|
1668
1679
|
return [];
|
|
1669
1680
|
let r = 0;
|
|
1670
1681
|
const s = [], i = Array.from(t, (a) => {
|
|
@@ -1694,21 +1705,21 @@ function At(t, e, n) {
|
|
|
1694
1705
|
s.push(0);
|
|
1695
1706
|
return s.reverse();
|
|
1696
1707
|
}
|
|
1697
|
-
const
|
|
1708
|
+
const dn = (t, e) => e === 0 ? t : dn(e, t % e), ke = /* @__NO_SIDE_EFFECTS__ */ (t, e) => t + (e - dn(t, e)), Te = /* @__PURE__ */ (() => {
|
|
1698
1709
|
let t = [];
|
|
1699
1710
|
for (let e = 0; e < 40; e++)
|
|
1700
1711
|
t.push(2 ** e);
|
|
1701
1712
|
return t;
|
|
1702
1713
|
})();
|
|
1703
|
-
function
|
|
1704
|
-
if (
|
|
1714
|
+
function Lt(t, e, n, r) {
|
|
1715
|
+
if (be(t), e <= 0 || e > 32)
|
|
1705
1716
|
throw new Error(`convertRadix2: wrong from=${e}`);
|
|
1706
1717
|
if (n <= 0 || n > 32)
|
|
1707
1718
|
throw new Error(`convertRadix2: wrong to=${n}`);
|
|
1708
|
-
if (/* @__PURE__ */
|
|
1709
|
-
throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${/* @__PURE__ */
|
|
1719
|
+
if (/* @__PURE__ */ ke(e, n) > 32)
|
|
1720
|
+
throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${/* @__PURE__ */ ke(e, n)}`);
|
|
1710
1721
|
let s = 0, i = 0;
|
|
1711
|
-
const o =
|
|
1722
|
+
const o = Te[e], a = Te[n] - 1, l = [];
|
|
1712
1723
|
for (const c of t) {
|
|
1713
1724
|
if (le(c), c >= o)
|
|
1714
1725
|
throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);
|
|
@@ -1716,7 +1727,7 @@ function St(t, e, n, r) {
|
|
|
1716
1727
|
throw new Error(`convertRadix2: carry overflow pos=${i} from=${e}`);
|
|
1717
1728
|
for (i += e; i >= n; i -= n)
|
|
1718
1729
|
l.push((s >> i - n & a) >>> 0);
|
|
1719
|
-
const d =
|
|
1730
|
+
const d = Te[i];
|
|
1720
1731
|
if (d === void 0)
|
|
1721
1732
|
throw new Error("invalid carry");
|
|
1722
1733
|
s &= d - 1;
|
|
@@ -1728,56 +1739,56 @@ function St(t, e, n, r) {
|
|
|
1728
1739
|
return r && i > 0 && l.push(s >>> 0), l;
|
|
1729
1740
|
}
|
|
1730
1741
|
// @__NO_SIDE_EFFECTS__
|
|
1731
|
-
function
|
|
1742
|
+
function cs(t) {
|
|
1732
1743
|
le(t);
|
|
1733
1744
|
const e = 2 ** 8;
|
|
1734
1745
|
return {
|
|
1735
1746
|
encode: (n) => {
|
|
1736
|
-
if (!
|
|
1747
|
+
if (!st(n))
|
|
1737
1748
|
throw new Error("radix.encode input should be Uint8Array");
|
|
1738
|
-
return
|
|
1749
|
+
return $t(Array.from(n), e, t);
|
|
1739
1750
|
},
|
|
1740
|
-
decode: (n) => (
|
|
1751
|
+
decode: (n) => (ln("radix.decode", n), Uint8Array.from($t(n, t, e)))
|
|
1741
1752
|
};
|
|
1742
1753
|
}
|
|
1743
1754
|
// @__NO_SIDE_EFFECTS__
|
|
1744
|
-
function
|
|
1755
|
+
function hn(t, e = !1) {
|
|
1745
1756
|
if (le(t), t <= 0 || t > 32)
|
|
1746
1757
|
throw new Error("radix2: bits should be in (0..32]");
|
|
1747
|
-
if (/* @__PURE__ */
|
|
1758
|
+
if (/* @__PURE__ */ ke(8, t) > 32 || /* @__PURE__ */ ke(t, 8) > 32)
|
|
1748
1759
|
throw new Error("radix2: carry overflow");
|
|
1749
1760
|
return {
|
|
1750
1761
|
encode: (n) => {
|
|
1751
|
-
if (!
|
|
1762
|
+
if (!st(n))
|
|
1752
1763
|
throw new Error("radix2.encode input should be Uint8Array");
|
|
1753
|
-
return
|
|
1764
|
+
return Lt(Array.from(n), 8, t, !e);
|
|
1754
1765
|
},
|
|
1755
|
-
decode: (n) => (
|
|
1766
|
+
decode: (n) => (ln("radix2.decode", n), Uint8Array.from(Lt(n, t, 8, e)))
|
|
1756
1767
|
};
|
|
1757
1768
|
}
|
|
1758
|
-
const
|
|
1769
|
+
const ls = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Array.fromBase64 == "function", ds = ls ? {
|
|
1759
1770
|
encode(t) {
|
|
1760
|
-
return
|
|
1771
|
+
return an(t), t.toBase64();
|
|
1761
1772
|
},
|
|
1762
1773
|
decode(t) {
|
|
1763
1774
|
return Q("base64", t), Uint8Array.fromBase64(t, { lastChunkHandling: "strict" });
|
|
1764
1775
|
}
|
|
1765
|
-
} : /* @__PURE__ */
|
|
1776
|
+
} : /* @__PURE__ */ it(/* @__PURE__ */ hn(6), /* @__PURE__ */ ot("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ os(6), /* @__PURE__ */ at("")), hs = /* @__NO_SIDE_EFFECTS__ */ (t) => /* @__PURE__ */ it(/* @__PURE__ */ cs(58), /* @__PURE__ */ ot(t), /* @__PURE__ */ at("")), De = /* @__PURE__ */ hs("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"), us = {
|
|
1766
1777
|
encode: (t) => new TextDecoder().decode(t),
|
|
1767
1778
|
decode: (t) => new TextEncoder().encode(t)
|
|
1768
|
-
},
|
|
1779
|
+
}, fs = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", ps = {
|
|
1769
1780
|
encode(t) {
|
|
1770
|
-
return
|
|
1781
|
+
return an(t), t.toHex();
|
|
1771
1782
|
},
|
|
1772
1783
|
decode(t) {
|
|
1773
1784
|
return Q("hex", t), Uint8Array.fromHex(t);
|
|
1774
1785
|
}
|
|
1775
|
-
},
|
|
1786
|
+
}, Ne = fs ? ps : /* @__PURE__ */ it(/* @__PURE__ */ hn(4), /* @__PURE__ */ ot("0123456789abcdef"), /* @__PURE__ */ at(""), /* @__PURE__ */ as((t) => {
|
|
1776
1787
|
if (typeof t != "string" || t.length % 2 !== 0)
|
|
1777
1788
|
throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);
|
|
1778
1789
|
return t.toLowerCase();
|
|
1779
1790
|
}));
|
|
1780
|
-
function
|
|
1791
|
+
function Ze(t, e) {
|
|
1781
1792
|
if (t.length !== e.length)
|
|
1782
1793
|
return !1;
|
|
1783
1794
|
for (let n = 0; n < t.length; n++)
|
|
@@ -1785,24 +1796,24 @@ function Ve(t, e) {
|
|
|
1785
1796
|
return !1;
|
|
1786
1797
|
return !0;
|
|
1787
1798
|
}
|
|
1788
|
-
function
|
|
1799
|
+
function j(t) {
|
|
1789
1800
|
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
|
|
1790
1801
|
}
|
|
1791
|
-
const
|
|
1802
|
+
const un = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
1792
1803
|
function K(t) {
|
|
1793
1804
|
return Object.prototype.toString.call(t) === "[object Object]";
|
|
1794
1805
|
}
|
|
1795
|
-
function
|
|
1806
|
+
function M(t) {
|
|
1796
1807
|
return Number.isSafeInteger(t);
|
|
1797
1808
|
}
|
|
1798
|
-
const
|
|
1799
|
-
if (t !== null && typeof t != "string" && !
|
|
1809
|
+
const fn = (t) => {
|
|
1810
|
+
if (t !== null && typeof t != "string" && !U(t) && !j(t) && !M(t))
|
|
1800
1811
|
throw new Error(`lengthCoder: expected null | number | Uint8Array | CoderType, got ${t} (${typeof t})`);
|
|
1801
1812
|
return {
|
|
1802
1813
|
encodeStream(e, n) {
|
|
1803
1814
|
if (t === null)
|
|
1804
1815
|
return;
|
|
1805
|
-
if (
|
|
1816
|
+
if (U(t))
|
|
1806
1817
|
return t.encodeStream(e, n);
|
|
1807
1818
|
let r;
|
|
1808
1819
|
if (typeof t == "number" ? r = t : typeof t == "string" && (r = Z.resolve(e.stack, t)), typeof r == "bigint" && (r = Number(r)), r === void 0 || r !== n)
|
|
@@ -1810,22 +1821,22 @@ const hn = (t) => {
|
|
|
1810
1821
|
},
|
|
1811
1822
|
decodeStream(e) {
|
|
1812
1823
|
let n;
|
|
1813
|
-
if (
|
|
1824
|
+
if (U(t) ? n = Number(t.decodeStream(e)) : typeof t == "number" ? n = t : typeof t == "string" && (n = Z.resolve(e.stack, t)), typeof n == "bigint" && (n = Number(n)), typeof n != "number")
|
|
1814
1825
|
throw e.err(`Wrong length: ${n}`);
|
|
1815
1826
|
return n;
|
|
1816
1827
|
}
|
|
1817
1828
|
};
|
|
1818
|
-
},
|
|
1829
|
+
}, A = {
|
|
1819
1830
|
BITS: 32,
|
|
1820
1831
|
FULL_MASK: -1 >>> 0,
|
|
1821
1832
|
// 1<<32 will overflow
|
|
1822
1833
|
len: (t) => Math.ceil(t / 32),
|
|
1823
|
-
create: (t) => new Uint32Array(
|
|
1834
|
+
create: (t) => new Uint32Array(A.len(t)),
|
|
1824
1835
|
clean: (t) => t.fill(0),
|
|
1825
1836
|
debug: (t) => Array.from(t).map((e) => (e >>> 0).toString(2).padStart(32, "0")),
|
|
1826
1837
|
checkLen: (t, e) => {
|
|
1827
|
-
if (
|
|
1828
|
-
throw new Error(`wrong length=${t.length}. Expected: ${
|
|
1838
|
+
if (A.len(e) !== t.length)
|
|
1839
|
+
throw new Error(`wrong length=${t.length}. Expected: ${A.len(e)}`);
|
|
1829
1840
|
},
|
|
1830
1841
|
chunkLen: (t, e, n) => {
|
|
1831
1842
|
if (e < 0)
|
|
@@ -1839,8 +1850,8 @@ const hn = (t) => {
|
|
|
1839
1850
|
mask: 1 << 32 - (t + e) % 32 - 1
|
|
1840
1851
|
}),
|
|
1841
1852
|
indices: (t, e, n = !1) => {
|
|
1842
|
-
|
|
1843
|
-
const { FULL_MASK: r, BITS: s } =
|
|
1853
|
+
A.checkLen(t, e);
|
|
1854
|
+
const { FULL_MASK: r, BITS: s } = A, i = s - e % s, o = i ? r >>> i << i : r, a = [];
|
|
1844
1855
|
for (let l = 0; l < t.length; l++) {
|
|
1845
1856
|
let c = t[l];
|
|
1846
1857
|
if (n && (c = ~c), l === t.length - 1 && (c &= o), c !== 0)
|
|
@@ -1858,19 +1869,19 @@ const hn = (t) => {
|
|
|
1858
1869
|
n === void 0 || r !== n.pos + n.length ? e.push(n = { pos: r, length: 1 }) : n.length += 1;
|
|
1859
1870
|
return e;
|
|
1860
1871
|
},
|
|
1861
|
-
rangeDebug: (t, e, n = !1) => `[${
|
|
1872
|
+
rangeDebug: (t, e, n = !1) => `[${A.range(A.indices(t, e, n)).map((r) => `(${r.pos}/${r.length})`).join(", ")}]`,
|
|
1862
1873
|
setRange: (t, e, n, r, s = !0) => {
|
|
1863
|
-
|
|
1864
|
-
const { FULL_MASK: i, BITS: o } =
|
|
1874
|
+
A.chunkLen(e, n, r);
|
|
1875
|
+
const { FULL_MASK: i, BITS: o } = A, a = n % o ? Math.floor(n / o) : void 0, l = n + r, c = l % o ? Math.floor(l / o) : void 0;
|
|
1865
1876
|
if (a !== void 0 && a === c)
|
|
1866
|
-
return
|
|
1867
|
-
if (a !== void 0 && !
|
|
1877
|
+
return A.set(t, a, i >>> o - r << o - r - n, s);
|
|
1878
|
+
if (a !== void 0 && !A.set(t, a, i >>> n % o, s))
|
|
1868
1879
|
return !1;
|
|
1869
1880
|
const d = a !== void 0 ? a + 1 : n / o, h = c !== void 0 ? c : l / o;
|
|
1870
1881
|
for (let u = d; u < h; u++)
|
|
1871
|
-
if (!
|
|
1882
|
+
if (!A.set(t, u, i, s))
|
|
1872
1883
|
return !1;
|
|
1873
|
-
return !(c !== void 0 && a !== c && !
|
|
1884
|
+
return !(c !== void 0 && a !== c && !A.set(t, c, i << o - l % o, s));
|
|
1874
1885
|
}
|
|
1875
1886
|
}, Z = {
|
|
1876
1887
|
/**
|
|
@@ -1911,18 +1922,18 @@ const hn = (t) => {
|
|
|
1911
1922
|
return i;
|
|
1912
1923
|
}
|
|
1913
1924
|
};
|
|
1914
|
-
class
|
|
1925
|
+
class ct {
|
|
1915
1926
|
constructor(e, n = {}, r = [], s = void 0, i = 0) {
|
|
1916
|
-
this.pos = 0, this.bitBuf = 0, this.bitPos = 0, this.data = e, this.opts = n, this.stack = r, this.parent = s, this.parentOffset = i, this.view =
|
|
1927
|
+
this.pos = 0, this.bitBuf = 0, this.bitPos = 0, this.data = e, this.opts = n, this.stack = r, this.parent = s, this.parentOffset = i, this.view = un(e);
|
|
1917
1928
|
}
|
|
1918
1929
|
/** Internal method for pointers. */
|
|
1919
1930
|
_enablePointers() {
|
|
1920
1931
|
if (this.parent)
|
|
1921
1932
|
return this.parent._enablePointers();
|
|
1922
|
-
this.bs || (this.bs =
|
|
1933
|
+
this.bs || (this.bs = A.create(this.data.length), A.setRange(this.bs, this.data.length, 0, this.pos, this.opts.allowMultipleReads));
|
|
1923
1934
|
}
|
|
1924
1935
|
markBytesBS(e, n) {
|
|
1925
|
-
return this.parent ? this.parent.markBytesBS(this.parentOffset + e, n) : !n || !this.bs ? !0 :
|
|
1936
|
+
return this.parent ? this.parent.markBytesBS(this.parentOffset + e, n) : !n || !this.bs ? !0 : A.setRange(this.bs, this.data.length, e, n, !1);
|
|
1926
1937
|
}
|
|
1927
1938
|
markBytes(e) {
|
|
1928
1939
|
const n = this.pos;
|
|
@@ -1952,17 +1963,17 @@ class ot {
|
|
|
1952
1963
|
finish() {
|
|
1953
1964
|
if (!this.opts.allowUnreadBytes) {
|
|
1954
1965
|
if (this.bitPos)
|
|
1955
|
-
throw this.err(`${this.bitPos} bits left after unpack: ${
|
|
1966
|
+
throw this.err(`${this.bitPos} bits left after unpack: ${Ne.encode(this.data.slice(this.pos))}`);
|
|
1956
1967
|
if (this.bs && !this.parent) {
|
|
1957
|
-
const e =
|
|
1968
|
+
const e = A.indices(this.bs, this.data.length, !0);
|
|
1958
1969
|
if (e.length) {
|
|
1959
|
-
const n =
|
|
1970
|
+
const n = A.range(e).map(({ pos: r, length: s }) => `(${r}/${s})[${Ne.encode(this.data.subarray(r, r + s))}]`).join(", ");
|
|
1960
1971
|
throw this.err(`unread byte ranges: ${n} (total=${this.data.length})`);
|
|
1961
1972
|
} else
|
|
1962
1973
|
return;
|
|
1963
1974
|
}
|
|
1964
1975
|
if (!this.isEnd())
|
|
1965
|
-
throw this.err(`${this.leftBytes} bytes ${this.bitPos} bits left after unpack: ${
|
|
1976
|
+
throw this.err(`${this.leftBytes} bytes ${this.bitPos} bits left after unpack: ${Ne.encode(this.data.slice(this.pos))}`);
|
|
1966
1977
|
}
|
|
1967
1978
|
}
|
|
1968
1979
|
// User methods
|
|
@@ -1972,7 +1983,7 @@ class ot {
|
|
|
1972
1983
|
offsetReader(e) {
|
|
1973
1984
|
if (e > this.data.length)
|
|
1974
1985
|
throw this.err("offsetReader: Unexpected end of buffer");
|
|
1975
|
-
return new
|
|
1986
|
+
return new ct(this.absBytes(e), this.opts, this.stack, this, e);
|
|
1976
1987
|
}
|
|
1977
1988
|
bytes(e, n = !1) {
|
|
1978
1989
|
if (this.bitPos)
|
|
@@ -2014,7 +2025,7 @@ class ot {
|
|
|
2014
2025
|
return n >>> 0;
|
|
2015
2026
|
}
|
|
2016
2027
|
find(e, n = this.pos) {
|
|
2017
|
-
if (!
|
|
2028
|
+
if (!j(e))
|
|
2018
2029
|
throw this.err(`find: needle is not bytes! ${e}`);
|
|
2019
2030
|
if (this.bitPos)
|
|
2020
2031
|
throw this.err("findByte: bitPos not empty");
|
|
@@ -2023,14 +2034,14 @@ class ot {
|
|
|
2023
2034
|
for (let r = n; (r = this.data.indexOf(e[0], r)) !== -1; r++) {
|
|
2024
2035
|
if (r === -1 || this.data.length - r < e.length)
|
|
2025
2036
|
return;
|
|
2026
|
-
if (
|
|
2037
|
+
if (Ze(e, this.data.subarray(r, r + e.length)))
|
|
2027
2038
|
return r;
|
|
2028
2039
|
}
|
|
2029
2040
|
}
|
|
2030
2041
|
}
|
|
2031
|
-
class
|
|
2042
|
+
class ws {
|
|
2032
2043
|
constructor(e = []) {
|
|
2033
|
-
this.pos = 0, this.buffers = [], this.ptrs = [], this.bitBuf = 0, this.bitPos = 0, this.viewBuf = new Uint8Array(8), this.finished = !1, this.stack = e, this.view =
|
|
2044
|
+
this.pos = 0, this.buffers = [], this.ptrs = [], this.bitBuf = 0, this.bitPos = 0, this.viewBuf = new Uint8Array(8), this.finished = !1, this.stack = e, this.view = un(this.viewBuf);
|
|
2034
2045
|
}
|
|
2035
2046
|
pushObj(e, n) {
|
|
2036
2047
|
return Z.pushObj(this.stack, e, n);
|
|
@@ -2038,7 +2049,7 @@ class fs {
|
|
|
2038
2049
|
writeView(e, n) {
|
|
2039
2050
|
if (this.finished)
|
|
2040
2051
|
throw this.err("buffer: finished");
|
|
2041
|
-
if (!
|
|
2052
|
+
if (!M(e) || e > 8)
|
|
2042
2053
|
throw new Error(`wrong writeView length=${e}`);
|
|
2043
2054
|
n(this.view), this.bytes(this.viewBuf.slice(0, e)), this.viewBuf.fill(0);
|
|
2044
2055
|
}
|
|
@@ -2095,8 +2106,8 @@ class fs {
|
|
|
2095
2106
|
}
|
|
2096
2107
|
}
|
|
2097
2108
|
}
|
|
2098
|
-
const
|
|
2099
|
-
function
|
|
2109
|
+
const Ke = (t) => Uint8Array.from(t).reverse();
|
|
2110
|
+
function gs(t, e, n) {
|
|
2100
2111
|
if (n) {
|
|
2101
2112
|
const r = 2n ** (e - 1n);
|
|
2102
2113
|
if (t < -r || t >= r)
|
|
@@ -2104,28 +2115,28 @@ function ps(t, e, n) {
|
|
|
2104
2115
|
} else if (0n > t || t >= 2n ** e)
|
|
2105
2116
|
throw new Error(`value out of unsigned bounds. Expected 0 <= ${t} < ${2n ** e}`);
|
|
2106
2117
|
}
|
|
2107
|
-
function
|
|
2118
|
+
function pn(t) {
|
|
2108
2119
|
return {
|
|
2109
2120
|
// NOTE: we cannot export validate here, since it is likely mistake.
|
|
2110
2121
|
encodeStream: t.encodeStream,
|
|
2111
2122
|
decodeStream: t.decodeStream,
|
|
2112
2123
|
size: t.size,
|
|
2113
2124
|
encode: (e) => {
|
|
2114
|
-
const n = new
|
|
2125
|
+
const n = new ws();
|
|
2115
2126
|
return t.encodeStream(n, e), n.finish();
|
|
2116
2127
|
},
|
|
2117
2128
|
decode: (e, n = {}) => {
|
|
2118
|
-
const r = new
|
|
2129
|
+
const r = new ct(e, n), s = t.decodeStream(r);
|
|
2119
2130
|
return r.finish(), s;
|
|
2120
2131
|
}
|
|
2121
2132
|
};
|
|
2122
2133
|
}
|
|
2123
|
-
function
|
|
2124
|
-
if (!
|
|
2134
|
+
function wn(t, e) {
|
|
2135
|
+
if (!U(t))
|
|
2125
2136
|
throw new Error(`validate: invalid inner value ${t}`);
|
|
2126
2137
|
if (typeof e != "function")
|
|
2127
2138
|
throw new Error("validate: fn should be function");
|
|
2128
|
-
return
|
|
2139
|
+
return pn({
|
|
2129
2140
|
size: t.size,
|
|
2130
2141
|
encodeStream: (n, r) => {
|
|
2131
2142
|
let s;
|
|
@@ -2146,14 +2157,14 @@ function fn(t, e) {
|
|
|
2146
2157
|
}
|
|
2147
2158
|
});
|
|
2148
2159
|
}
|
|
2149
|
-
const
|
|
2150
|
-
const e =
|
|
2151
|
-
return t.validate ?
|
|
2152
|
-
},
|
|
2153
|
-
function
|
|
2154
|
-
return K(t) &&
|
|
2160
|
+
const P = (t) => {
|
|
2161
|
+
const e = pn(t);
|
|
2162
|
+
return t.validate ? wn(e, t.validate) : e;
|
|
2163
|
+
}, Se = (t) => K(t) && typeof t.decode == "function" && typeof t.encode == "function";
|
|
2164
|
+
function U(t) {
|
|
2165
|
+
return K(t) && Se(t) && typeof t.encodeStream == "function" && typeof t.decodeStream == "function" && (t.size === void 0 || M(t.size));
|
|
2155
2166
|
}
|
|
2156
|
-
function
|
|
2167
|
+
function ms() {
|
|
2157
2168
|
return {
|
|
2158
2169
|
encode: (t) => {
|
|
2159
2170
|
if (!Array.isArray(t))
|
|
@@ -2176,7 +2187,7 @@ function ws() {
|
|
|
2176
2187
|
}
|
|
2177
2188
|
};
|
|
2178
2189
|
}
|
|
2179
|
-
const
|
|
2190
|
+
const ys = {
|
|
2180
2191
|
encode: (t) => {
|
|
2181
2192
|
if (typeof t != "bigint")
|
|
2182
2193
|
throw new Error(`expected bigint, got ${typeof t}`);
|
|
@@ -2185,17 +2196,17 @@ const gs = {
|
|
|
2185
2196
|
return Number(t);
|
|
2186
2197
|
},
|
|
2187
2198
|
decode: (t) => {
|
|
2188
|
-
if (!
|
|
2199
|
+
if (!M(t))
|
|
2189
2200
|
throw new Error("element is not a safe integer");
|
|
2190
2201
|
return BigInt(t);
|
|
2191
2202
|
}
|
|
2192
2203
|
};
|
|
2193
|
-
function
|
|
2204
|
+
function Cs(t) {
|
|
2194
2205
|
if (!K(t))
|
|
2195
2206
|
throw new Error("plain object expected");
|
|
2196
2207
|
return {
|
|
2197
2208
|
encode: (e) => {
|
|
2198
|
-
if (!
|
|
2209
|
+
if (!M(e) || !(e in t))
|
|
2199
2210
|
throw new Error(`wrong value ${e}`);
|
|
2200
2211
|
return t[e];
|
|
2201
2212
|
},
|
|
@@ -2206,8 +2217,8 @@ function ms(t) {
|
|
|
2206
2217
|
}
|
|
2207
2218
|
};
|
|
2208
2219
|
}
|
|
2209
|
-
function
|
|
2210
|
-
if (!
|
|
2220
|
+
function bs(t, e = !1) {
|
|
2221
|
+
if (!M(t))
|
|
2211
2222
|
throw new Error(`decimal/precision: wrong value ${t}`);
|
|
2212
2223
|
if (typeof e != "boolean")
|
|
2213
2224
|
throw new Error(`decimal/round: expected boolean, got ${typeof e}`);
|
|
@@ -2242,11 +2253,11 @@ function ys(t, e = !1) {
|
|
|
2242
2253
|
}
|
|
2243
2254
|
};
|
|
2244
2255
|
}
|
|
2245
|
-
function
|
|
2256
|
+
function xs(t) {
|
|
2246
2257
|
if (!Array.isArray(t))
|
|
2247
2258
|
throw new Error(`expected array, got ${typeof t}`);
|
|
2248
2259
|
for (const e of t)
|
|
2249
|
-
if (!
|
|
2260
|
+
if (!Se(e))
|
|
2250
2261
|
throw new Error(`wrong base coder ${e}`);
|
|
2251
2262
|
return {
|
|
2252
2263
|
encode: (e) => {
|
|
@@ -2267,12 +2278,12 @@ function Cs(t) {
|
|
|
2267
2278
|
}
|
|
2268
2279
|
};
|
|
2269
2280
|
}
|
|
2270
|
-
const
|
|
2271
|
-
if (!
|
|
2281
|
+
const ks = (t) => {
|
|
2282
|
+
if (!Se(t))
|
|
2272
2283
|
throw new Error("BaseCoder expected");
|
|
2273
2284
|
return { encode: t.decode, decode: t.encode };
|
|
2274
|
-
}, ne = { dict:
|
|
2275
|
-
if (!
|
|
2285
|
+
}, ne = { dict: ms, numberBigint: ys, tsEnum: Cs, decimal: bs, match: xs, reverse: ks }, vs = (t, e = !1, n = !1, r = !0) => {
|
|
2286
|
+
if (!M(t))
|
|
2276
2287
|
throw new Error(`bigint/size: wrong value ${t}`);
|
|
2277
2288
|
if (typeof e != "boolean")
|
|
2278
2289
|
throw new Error(`bigint/le: expected boolean, got ${typeof e}`);
|
|
@@ -2281,7 +2292,7 @@ const bs = (t) => {
|
|
|
2281
2292
|
if (typeof r != "boolean")
|
|
2282
2293
|
throw new Error(`bigint/sized: expected boolean, got ${typeof r}`);
|
|
2283
2294
|
const s = BigInt(t), i = 2n ** (8n * s - 1n);
|
|
2284
|
-
return
|
|
2295
|
+
return P({
|
|
2285
2296
|
size: r ? t : void 0,
|
|
2286
2297
|
encodeStream: (o, a) => {
|
|
2287
2298
|
n && a < 0 && (a = a | i);
|
|
@@ -2298,7 +2309,7 @@ const bs = (t) => {
|
|
|
2298
2309
|
o.bytes(e ? c.reverse() : c);
|
|
2299
2310
|
},
|
|
2300
2311
|
decodeStream: (o) => {
|
|
2301
|
-
const a = o.bytes(r ? t : Math.min(t, o.leftBytes)), l = e ? a :
|
|
2312
|
+
const a = o.bytes(r ? t : Math.min(t, o.leftBytes)), l = e ? a : Ke(a);
|
|
2302
2313
|
let c = 0n;
|
|
2303
2314
|
for (let d = 0; d < l.length; d++)
|
|
2304
2315
|
c |= BigInt(l[d]) << 8n * BigInt(d);
|
|
@@ -2307,10 +2318,10 @@ const bs = (t) => {
|
|
|
2307
2318
|
validate: (o) => {
|
|
2308
2319
|
if (typeof o != "bigint")
|
|
2309
2320
|
throw new Error(`bigint: invalid value: ${o}`);
|
|
2310
|
-
return
|
|
2321
|
+
return gs(o, 8n * s, !!n), o;
|
|
2311
2322
|
}
|
|
2312
2323
|
});
|
|
2313
|
-
}, v = /* @__PURE__ */
|
|
2324
|
+
}, v = /* @__PURE__ */ vs(8, !0), Es = (t, e) => P({
|
|
2314
2325
|
size: t,
|
|
2315
2326
|
encodeStream: (n, r) => n.writeView(t, (s) => e.write(s, r)),
|
|
2316
2327
|
decodeStream: (n) => n.readView(t, e.read),
|
|
@@ -2319,30 +2330,30 @@ const bs = (t) => {
|
|
|
2319
2330
|
throw new Error(`viewCoder: expected number, got ${typeof n}`);
|
|
2320
2331
|
return e.validate && e.validate(n), n;
|
|
2321
2332
|
}
|
|
2322
|
-
}),
|
|
2333
|
+
}), gn = (t, e, n) => {
|
|
2323
2334
|
const r = t * 8, s = 2 ** (r - 1), i = (l) => {
|
|
2324
|
-
if (!
|
|
2335
|
+
if (!M(l))
|
|
2325
2336
|
throw new Error(`sintView: value is not safe integer: ${l}`);
|
|
2326
2337
|
if (l < -s || l >= s)
|
|
2327
2338
|
throw new Error(`sintView: value out of bounds. Expected ${-s} <= ${l} < ${s}`);
|
|
2328
2339
|
}, o = 2 ** r, a = (l) => {
|
|
2329
|
-
if (!
|
|
2340
|
+
if (!M(l))
|
|
2330
2341
|
throw new Error(`uintView: value is not safe integer: ${l}`);
|
|
2331
2342
|
if (0 > l || l >= o)
|
|
2332
2343
|
throw new Error(`uintView: value out of bounds. Expected 0 <= ${l} < ${o}`);
|
|
2333
2344
|
};
|
|
2334
|
-
return
|
|
2345
|
+
return Es(t, {
|
|
2335
2346
|
write: n.write,
|
|
2336
2347
|
read: n.read,
|
|
2337
2348
|
validate: e ? i : a
|
|
2338
2349
|
});
|
|
2339
|
-
},
|
|
2350
|
+
}, ve = /* @__PURE__ */ gn(4, !1, {
|
|
2340
2351
|
read: (t, e) => t.getUint32(e, !0),
|
|
2341
2352
|
write: (t, e) => t.setUint32(0, e, !0)
|
|
2342
|
-
}),
|
|
2353
|
+
}), N = /* @__PURE__ */ gn(1, !1, {
|
|
2343
2354
|
read: (t, e) => t.getUint8(e),
|
|
2344
2355
|
write: (t, e) => t.setUint8(0, e)
|
|
2345
|
-
}),
|
|
2356
|
+
}), Xe = /* @__PURE__ */ P({
|
|
2346
2357
|
size: 1,
|
|
2347
2358
|
encodeStream: (t, e) => t.byte(e ? 1 : 0),
|
|
2348
2359
|
decodeStream: (t) => {
|
|
@@ -2356,14 +2367,14 @@ const bs = (t) => {
|
|
|
2356
2367
|
throw new Error(`bool: invalid value ${t}`);
|
|
2357
2368
|
return t;
|
|
2358
2369
|
}
|
|
2359
|
-
}),
|
|
2370
|
+
}), $e = (t, e = !1) => {
|
|
2360
2371
|
if (typeof e != "boolean")
|
|
2361
2372
|
throw new Error(`bytes/le: expected boolean, got ${typeof e}`);
|
|
2362
|
-
const n =
|
|
2363
|
-
return
|
|
2373
|
+
const n = fn(t), r = j(t);
|
|
2374
|
+
return P({
|
|
2364
2375
|
size: typeof t == "number" ? t : void 0,
|
|
2365
2376
|
encodeStream: (s, i) => {
|
|
2366
|
-
r || n.encodeStream(s, i.length), s.bytes(e ?
|
|
2377
|
+
r || n.encodeStream(s, i.length), s.bytes(e ? Ke(i) : i), r && s.bytes(t);
|
|
2367
2378
|
},
|
|
2368
2379
|
decodeStream: (s) => {
|
|
2369
2380
|
let i;
|
|
@@ -2374,25 +2385,25 @@ const bs = (t) => {
|
|
|
2374
2385
|
i = s.bytes(o - s.pos), s.bytes(t.length);
|
|
2375
2386
|
} else
|
|
2376
2387
|
i = s.bytes(t === null ? s.leftBytes : n.decodeStream(s));
|
|
2377
|
-
return e ?
|
|
2388
|
+
return e ? Ke(i) : i;
|
|
2378
2389
|
},
|
|
2379
2390
|
validate: (s) => {
|
|
2380
|
-
if (!
|
|
2391
|
+
if (!j(s))
|
|
2381
2392
|
throw new Error(`bytes: invalid value ${s}`);
|
|
2382
2393
|
return s;
|
|
2383
2394
|
}
|
|
2384
2395
|
});
|
|
2385
|
-
},
|
|
2396
|
+
}, As = (t, e = !1) => wn(Ss($e(t, e), us), (n) => {
|
|
2386
2397
|
if (typeof n != "string")
|
|
2387
2398
|
throw new Error(`expected string, got ${typeof n}`);
|
|
2388
2399
|
return n;
|
|
2389
2400
|
});
|
|
2390
|
-
function
|
|
2391
|
-
if (!
|
|
2401
|
+
function Ss(t, e) {
|
|
2402
|
+
if (!U(t))
|
|
2392
2403
|
throw new Error(`apply: invalid inner value ${t}`);
|
|
2393
|
-
if (!
|
|
2404
|
+
if (!Se(e))
|
|
2394
2405
|
throw new Error(`apply: invalid base value ${t}`);
|
|
2395
|
-
return
|
|
2406
|
+
return P({
|
|
2396
2407
|
size: t.size,
|
|
2397
2408
|
encodeStream: (n, r) => {
|
|
2398
2409
|
let s;
|
|
@@ -2414,9 +2425,9 @@ function Es(t, e) {
|
|
|
2414
2425
|
});
|
|
2415
2426
|
}
|
|
2416
2427
|
function se(t, e, n) {
|
|
2417
|
-
if (!
|
|
2428
|
+
if (!U(t) || !U(e))
|
|
2418
2429
|
throw new Error(`optional: invalid flag or inner value flag=${t} inner=${e}`);
|
|
2419
|
-
return
|
|
2430
|
+
return P({
|
|
2420
2431
|
size: n !== void 0 && t.size && e.size ? t.size + e.size : void 0,
|
|
2421
2432
|
encodeStream: (r, s) => {
|
|
2422
2433
|
t.encodeStream(r, !!s), s ? e.encodeStream(r, s) : n !== void 0 && e.encodeStream(r, n);
|
|
@@ -2428,8 +2439,8 @@ function se(t, e, n) {
|
|
|
2428
2439
|
}
|
|
2429
2440
|
});
|
|
2430
2441
|
}
|
|
2431
|
-
function
|
|
2432
|
-
return
|
|
2442
|
+
function $s(t) {
|
|
2443
|
+
return P({
|
|
2433
2444
|
encodeStream: (e, n) => {
|
|
2434
2445
|
if (n !== t)
|
|
2435
2446
|
throw new Error(`constant: invalid value ${n} (exp: ${t})`);
|
|
@@ -2437,12 +2448,12 @@ function As(t) {
|
|
|
2437
2448
|
decodeStream: (e) => t
|
|
2438
2449
|
});
|
|
2439
2450
|
}
|
|
2440
|
-
function
|
|
2451
|
+
function Ls(t) {
|
|
2441
2452
|
let e = 0;
|
|
2442
2453
|
for (const n of t) {
|
|
2443
2454
|
if (n.size === void 0)
|
|
2444
2455
|
return;
|
|
2445
|
-
if (!
|
|
2456
|
+
if (!M(n.size))
|
|
2446
2457
|
throw new Error(`sizeof: wrong element size=${e}`);
|
|
2447
2458
|
e += n.size;
|
|
2448
2459
|
}
|
|
@@ -2452,10 +2463,10 @@ function p(t) {
|
|
|
2452
2463
|
if (!K(t))
|
|
2453
2464
|
throw new Error(`struct: expected plain object, got ${t}`);
|
|
2454
2465
|
for (const e in t)
|
|
2455
|
-
if (!
|
|
2466
|
+
if (!U(t[e]))
|
|
2456
2467
|
throw new Error(`struct: field ${e} is not CoderType`);
|
|
2457
|
-
return
|
|
2458
|
-
size:
|
|
2468
|
+
return P({
|
|
2469
|
+
size: Ls(Object.values(t)),
|
|
2459
2470
|
encodeStream: (e, n) => {
|
|
2460
2471
|
e.pushObj(n, (r) => {
|
|
2461
2472
|
for (const s in t)
|
|
@@ -2476,28 +2487,28 @@ function p(t) {
|
|
|
2476
2487
|
}
|
|
2477
2488
|
});
|
|
2478
2489
|
}
|
|
2479
|
-
function
|
|
2480
|
-
if (!
|
|
2490
|
+
function we(t, e) {
|
|
2491
|
+
if (!U(e))
|
|
2481
2492
|
throw new Error(`array: invalid inner value ${e}`);
|
|
2482
|
-
const n =
|
|
2483
|
-
return
|
|
2493
|
+
const n = fn(typeof t == "string" ? `../${t}` : t);
|
|
2494
|
+
return P({
|
|
2484
2495
|
size: typeof t == "number" && e.size ? t * e.size : void 0,
|
|
2485
2496
|
encodeStream: (r, s) => {
|
|
2486
2497
|
const i = r;
|
|
2487
2498
|
i.pushObj(s, (o) => {
|
|
2488
|
-
|
|
2499
|
+
j(t) || n.encodeStream(r, s.length);
|
|
2489
2500
|
for (let a = 0; a < s.length; a++)
|
|
2490
2501
|
o(`${a}`, () => {
|
|
2491
2502
|
const l = s[a], c = r.pos;
|
|
2492
|
-
if (e.encodeStream(r, l),
|
|
2503
|
+
if (e.encodeStream(r, l), j(t)) {
|
|
2493
2504
|
if (t.length > i.pos - c)
|
|
2494
2505
|
return;
|
|
2495
2506
|
const d = i.finish(!1).subarray(c, i.pos);
|
|
2496
|
-
if (
|
|
2507
|
+
if (Ze(d.subarray(0, t.length), t))
|
|
2497
2508
|
throw i.err(`array: inner element encoding same as separator. elm=${l} data=${d}`);
|
|
2498
2509
|
}
|
|
2499
2510
|
});
|
|
2500
|
-
}),
|
|
2511
|
+
}), j(t) && r.bytes(t);
|
|
2501
2512
|
},
|
|
2502
2513
|
decodeStream: (r) => {
|
|
2503
2514
|
const s = [];
|
|
@@ -2505,9 +2516,9 @@ function pe(t, e) {
|
|
|
2505
2516
|
if (t === null)
|
|
2506
2517
|
for (let o = 0; !r.isEnd() && (i(`${o}`, () => s.push(e.decodeStream(r))), !(e.size && r.leftBytes < e.size)); o++)
|
|
2507
2518
|
;
|
|
2508
|
-
else if (
|
|
2519
|
+
else if (j(t))
|
|
2509
2520
|
for (let o = 0; ; o++) {
|
|
2510
|
-
if (
|
|
2521
|
+
if (Ze(r.bytes(t.length, !0), t)) {
|
|
2511
2522
|
r.bytes(t.length);
|
|
2512
2523
|
break;
|
|
2513
2524
|
}
|
|
@@ -2528,15 +2539,15 @@ function pe(t, e) {
|
|
|
2528
2539
|
}
|
|
2529
2540
|
});
|
|
2530
2541
|
}
|
|
2531
|
-
function
|
|
2532
|
-
if (!
|
|
2542
|
+
function lt(t, e) {
|
|
2543
|
+
if (!U(t))
|
|
2533
2544
|
throw new Error(`map: invalid inner value ${t}`);
|
|
2534
2545
|
if (!K(e))
|
|
2535
2546
|
throw new Error("map: variants should be plain object");
|
|
2536
2547
|
const n = /* @__PURE__ */ new Map();
|
|
2537
2548
|
for (const r in e)
|
|
2538
2549
|
n.set(e[r], r);
|
|
2539
|
-
return
|
|
2550
|
+
return P({
|
|
2540
2551
|
size: t.size,
|
|
2541
2552
|
encodeStream: (r, s) => t.encodeStream(r, e[s]),
|
|
2542
2553
|
decodeStream: (r) => {
|
|
@@ -2554,15 +2565,15 @@ function at(t, e) {
|
|
|
2554
2565
|
}
|
|
2555
2566
|
});
|
|
2556
2567
|
}
|
|
2557
|
-
function
|
|
2558
|
-
if (!
|
|
2568
|
+
function _s(t, e) {
|
|
2569
|
+
if (!U(t))
|
|
2559
2570
|
throw new Error(`tag: invalid tag value ${t}`);
|
|
2560
2571
|
if (!K(e))
|
|
2561
2572
|
throw new Error("tag: variants should be plain object");
|
|
2562
2573
|
for (const n in e)
|
|
2563
|
-
if (!
|
|
2574
|
+
if (!U(e[n]))
|
|
2564
2575
|
throw new Error(`tag: variant ${n} is not CoderType`);
|
|
2565
|
-
return
|
|
2576
|
+
return P({
|
|
2566
2577
|
size: t.size,
|
|
2567
2578
|
encodeStream: (n, r) => {
|
|
2568
2579
|
const { TAG: s, data: i } = r, o = e[s];
|
|
@@ -2582,34 +2593,34 @@ function $s(t, e) {
|
|
|
2582
2593
|
}
|
|
2583
2594
|
});
|
|
2584
2595
|
}
|
|
2585
|
-
const
|
|
2586
|
-
function
|
|
2596
|
+
const Is = (t) => 0;
|
|
2597
|
+
function Be(t, e) {
|
|
2587
2598
|
return e % t === 0 ? 0 : t - e % t;
|
|
2588
2599
|
}
|
|
2589
|
-
function
|
|
2590
|
-
if (!
|
|
2600
|
+
function mn(t, e, n) {
|
|
2601
|
+
if (!U(e))
|
|
2591
2602
|
throw new Error(`padRight: invalid inner value ${e}`);
|
|
2592
|
-
if (!
|
|
2603
|
+
if (!M(t) || t <= 0)
|
|
2593
2604
|
throw new Error(`padLeft: wrong blockSize=${t}`);
|
|
2594
2605
|
if (n !== void 0 && typeof n != "function")
|
|
2595
2606
|
throw new Error(`padRight: wrong padFn=${typeof n}`);
|
|
2596
|
-
const r = n ||
|
|
2597
|
-
return
|
|
2598
|
-
size: e.size ? e.size +
|
|
2607
|
+
const r = n || Is;
|
|
2608
|
+
return P({
|
|
2609
|
+
size: e.size ? e.size + Be(t, e.size) : void 0,
|
|
2599
2610
|
encodeStream: (s, i) => {
|
|
2600
2611
|
const o = s, a = o.pos;
|
|
2601
2612
|
e.encodeStream(s, i);
|
|
2602
|
-
const l =
|
|
2613
|
+
const l = Be(t, o.pos - a);
|
|
2603
2614
|
for (let c = 0; c < l; c++)
|
|
2604
2615
|
s.byte(r(c));
|
|
2605
2616
|
},
|
|
2606
2617
|
decodeStream: (s) => {
|
|
2607
2618
|
const i = s.pos, o = e.decodeStream(s);
|
|
2608
|
-
return s.bytes(
|
|
2619
|
+
return s.bytes(Be(t, s.pos - i)), o;
|
|
2609
2620
|
}
|
|
2610
2621
|
});
|
|
2611
2622
|
}
|
|
2612
|
-
const
|
|
2623
|
+
const Ps = 9, Ue = ne.decimal(Ps), re = P({
|
|
2613
2624
|
encodeStream: (t, e) => {
|
|
2614
2625
|
if (!e)
|
|
2615
2626
|
return t.byte(0);
|
|
@@ -2625,32 +2636,32 @@ const _s = 9, Ne = ne.decimal(_s), re = I({
|
|
|
2625
2636
|
}
|
|
2626
2637
|
return e;
|
|
2627
2638
|
}
|
|
2628
|
-
}),
|
|
2629
|
-
const t =
|
|
2630
|
-
return
|
|
2639
|
+
}), pe = As(mn(8, ve, void 0)), Ts = () => {
|
|
2640
|
+
const t = $e(32);
|
|
2641
|
+
return P({
|
|
2631
2642
|
size: t.size,
|
|
2632
|
-
encodeStream: (e, n) => t.encodeStream(e,
|
|
2633
|
-
decodeStream: (e) =>
|
|
2643
|
+
encodeStream: (e, n) => t.encodeStream(e, De.decode(n)),
|
|
2644
|
+
decodeStream: (e) => De.encode(t.decodeStream(e))
|
|
2634
2645
|
});
|
|
2635
|
-
},
|
|
2636
|
-
requiredSignatures:
|
|
2637
|
-
readSigned:
|
|
2638
|
-
readUnsigned:
|
|
2639
|
-
keys:
|
|
2640
|
-
blockhash:
|
|
2641
|
-
instructions:
|
|
2646
|
+
}, y = Ts(), Ns = p({
|
|
2647
|
+
requiredSignatures: N,
|
|
2648
|
+
readSigned: N,
|
|
2649
|
+
readUnsigned: N,
|
|
2650
|
+
keys: we(re, y),
|
|
2651
|
+
blockhash: y,
|
|
2652
|
+
instructions: we(re, p({ programIdx: N, keys: we(re, N), data: $e(re) }))
|
|
2642
2653
|
});
|
|
2643
|
-
function
|
|
2644
|
-
if (
|
|
2654
|
+
function Bs(t) {
|
|
2655
|
+
if (De.decode(t).length !== 32)
|
|
2645
2656
|
throw new Error("Invalid Solana address");
|
|
2646
2657
|
}
|
|
2647
|
-
const
|
|
2658
|
+
const Us = (t, e, n, r, s) => ({
|
|
2648
2659
|
sign: t < e,
|
|
2649
2660
|
write: t < e - n || t >= e && t < s - r
|
|
2650
|
-
}),
|
|
2651
|
-
signatures:
|
|
2652
|
-
msg:
|
|
2653
|
-
}),
|
|
2661
|
+
}), _t = p({
|
|
2662
|
+
signatures: we(re, $e(64)),
|
|
2663
|
+
msg: Ns
|
|
2664
|
+
}), Ge = P({
|
|
2654
2665
|
encodeStream: (t, e) => {
|
|
2655
2666
|
const { msg: n, signatures: r } = e, s = {}, i = (h, u, f) => {
|
|
2656
2667
|
let w = s[h] || (s[h] = { sign: !1, write: !1 });
|
|
@@ -2672,7 +2683,7 @@ const Ns = (t, e, n, r, s) => ({
|
|
|
2672
2683
|
let l = 0, c = 0, d = 0;
|
|
2673
2684
|
for (let h of a)
|
|
2674
2685
|
s[h].sign && l++, !s[h].write && (s[h].sign ? c++ : d++);
|
|
2675
|
-
|
|
2686
|
+
_t.encodeStream(t, {
|
|
2676
2687
|
signatures: a.filter((h) => s[h].sign).map((h) => r[h] || new Uint8Array(64)),
|
|
2677
2688
|
msg: {
|
|
2678
2689
|
requiredSignatures: l,
|
|
@@ -2690,7 +2701,7 @@ const Ns = (t, e, n, r, s) => ({
|
|
|
2690
2701
|
});
|
|
2691
2702
|
},
|
|
2692
2703
|
decodeStream: (t) => {
|
|
2693
|
-
const { signatures: e, msg: n } =
|
|
2704
|
+
const { signatures: e, msg: n } = _t.decodeStream(t);
|
|
2694
2705
|
if (e.length !== n.requiredSignatures)
|
|
2695
2706
|
throw new Error("SOL.tx: wrong signatures length");
|
|
2696
2707
|
if (n.keys.length < e.length)
|
|
@@ -2702,7 +2713,7 @@ const Ns = (t, e, n, r, s) => ({
|
|
|
2702
2713
|
for (let i = 0; i < n.keys.length; i++)
|
|
2703
2714
|
s.push({
|
|
2704
2715
|
address: n.keys[i],
|
|
2705
|
-
...
|
|
2716
|
+
...Us(i, n.requiredSignatures, n.readSigned, n.readUnsigned, n.keys.length)
|
|
2706
2717
|
});
|
|
2707
2718
|
if (!s.length)
|
|
2708
2719
|
throw new Error("SOL.tx: empty accounts array");
|
|
@@ -2719,12 +2730,12 @@ const Ns = (t, e, n, r, s) => ({
|
|
|
2719
2730
|
signatures: r
|
|
2720
2731
|
};
|
|
2721
2732
|
}
|
|
2722
|
-
}),
|
|
2723
|
-
function
|
|
2724
|
-
if (
|
|
2733
|
+
}), It = {};
|
|
2734
|
+
function dt(t, e, n) {
|
|
2735
|
+
if (It[t])
|
|
2725
2736
|
throw new Error("SOL: program for this address already defined");
|
|
2726
|
-
const r =
|
|
2727
|
-
|
|
2737
|
+
const r = lt(e, Object.keys(n).reduce((a, l, c) => ({ ...a, [l]: c }), {})), s = Object.keys(n).reduce((a, l) => ({ ...a, [l]: n[l].coder }), {}), i = _s(r, s);
|
|
2738
|
+
It[t] = (a, l) => {
|
|
2728
2739
|
if (a.program !== t)
|
|
2729
2740
|
throw new Error("SOL.parseInstruction: Wrong instruction program address");
|
|
2730
2741
|
const { TAG: c, data: d } = i.decode(a.data), h = { type: c, info: d }, u = Object.keys(n[c].keys);
|
|
@@ -2748,37 +2759,37 @@ function ct(t, e, n) {
|
|
|
2748
2759
|
data: i.encode({ TAG: a, data: l }),
|
|
2749
2760
|
keys: Object.keys(n[a].keys).map((c) => {
|
|
2750
2761
|
let { sign: d, write: h, address: u } = n[a].keys[c];
|
|
2751
|
-
return u || (u = l[c]),
|
|
2762
|
+
return u || (u = l[c]), Bs(u), { address: u, sign: d, write: h };
|
|
2752
2763
|
})
|
|
2753
2764
|
});
|
|
2754
2765
|
return o;
|
|
2755
2766
|
}
|
|
2756
|
-
const
|
|
2767
|
+
const Me = "SysvarRecentB1ockHashes11111111111111111111", V = "SysvarRent111111111111111111111111111111111", yn = "11111111111111111111111111111111", Cn = dt(yn, ve, {
|
|
2757
2768
|
createAccount: {
|
|
2758
|
-
coder: p({ lamports: v, space: v, owner:
|
|
2769
|
+
coder: p({ lamports: v, space: v, owner: y }),
|
|
2759
2770
|
keys: {
|
|
2760
2771
|
source: { sign: !0, write: !0 },
|
|
2761
2772
|
newAccount: { sign: !0, write: !0 }
|
|
2762
2773
|
},
|
|
2763
|
-
hint: (t) => `Create new account=${t.newAccount} with balance of ${
|
|
2774
|
+
hint: (t) => `Create new account=${t.newAccount} with balance of ${Ue.encode(t.lamports)} and owner program ${t.owner}, using funding account ${t.source}`
|
|
2764
2775
|
},
|
|
2765
2776
|
assign: {
|
|
2766
|
-
coder: p({ owner:
|
|
2777
|
+
coder: p({ owner: y }),
|
|
2767
2778
|
keys: { account: { sign: !0, write: !0 } },
|
|
2768
2779
|
hint: (t) => `Assign account=${t.account} to owner program=${t.owner}`
|
|
2769
2780
|
},
|
|
2770
2781
|
transfer: {
|
|
2771
2782
|
coder: p({ lamports: v }),
|
|
2772
2783
|
keys: { source: { sign: !0, write: !0 }, destination: { sign: !1, write: !0 } },
|
|
2773
|
-
hint: (t) => `Transfer ${
|
|
2784
|
+
hint: (t) => `Transfer ${Ue.encode(t.lamports)} SOL from ${t.source} to ${t.destination}`
|
|
2774
2785
|
},
|
|
2775
2786
|
createAccountWithSeed: {
|
|
2776
2787
|
coder: p({
|
|
2777
|
-
base:
|
|
2778
|
-
seed:
|
|
2788
|
+
base: y,
|
|
2789
|
+
seed: pe,
|
|
2779
2790
|
lamports: v,
|
|
2780
2791
|
space: v,
|
|
2781
|
-
owner:
|
|
2792
|
+
owner: y
|
|
2782
2793
|
}),
|
|
2783
2794
|
keys: {
|
|
2784
2795
|
source: { sign: !0, write: !0 },
|
|
@@ -2790,7 +2801,7 @@ const Be = "SysvarRecentB1ockHashes11111111111111111111", V = "SysvarRent1111111
|
|
|
2790
2801
|
coder: p({}),
|
|
2791
2802
|
keys: {
|
|
2792
2803
|
nonceAccount: { sign: !1, write: !0 },
|
|
2793
|
-
_recent_bh: { address:
|
|
2804
|
+
_recent_bh: { address: Me, sign: !1, write: !1 },
|
|
2794
2805
|
nonceAuthority: { sign: !0, write: !1 }
|
|
2795
2806
|
},
|
|
2796
2807
|
hint: (t) => `Consume nonce in nonce account=${t.nonceAccount} (owner: ${t.nonceAuthority})`
|
|
@@ -2800,22 +2811,22 @@ const Be = "SysvarRecentB1ockHashes11111111111111111111", V = "SysvarRent1111111
|
|
|
2800
2811
|
keys: {
|
|
2801
2812
|
nonceAccount: { sign: !1, write: !0 },
|
|
2802
2813
|
destination: { sign: !1, write: !0 },
|
|
2803
|
-
_recent_bh: { address:
|
|
2814
|
+
_recent_bh: { address: Me, sign: !1, write: !1 },
|
|
2804
2815
|
_rent: { address: V, sign: !1, write: !1 },
|
|
2805
2816
|
nonceAuthority: { sign: !0, write: !1 }
|
|
2806
2817
|
},
|
|
2807
|
-
hint: (t) => `Withdraw ${
|
|
2818
|
+
hint: (t) => `Withdraw ${Ue.encode(t.lamports)} SOL from nonce account=${t.nonceAccount} (owner: ${t.nonceAuthority}) to ${t.destination}`
|
|
2808
2819
|
},
|
|
2809
2820
|
initializeNonce: {
|
|
2810
|
-
coder: p({ nonceAuthority:
|
|
2821
|
+
coder: p({ nonceAuthority: y }),
|
|
2811
2822
|
keys: {
|
|
2812
2823
|
nonceAccount: { sign: !1, write: !0 },
|
|
2813
|
-
_recent_bh: { address:
|
|
2824
|
+
_recent_bh: { address: Me, sign: !1, write: !1 },
|
|
2814
2825
|
_rent: { address: V, sign: !1, write: !1 }
|
|
2815
2826
|
}
|
|
2816
2827
|
},
|
|
2817
2828
|
authorizeNonce: {
|
|
2818
|
-
coder: p({ newAuthorized:
|
|
2829
|
+
coder: p({ newAuthorized: y }),
|
|
2819
2830
|
keys: {
|
|
2820
2831
|
nonceAccount: { sign: !1, write: !0 },
|
|
2821
2832
|
nonceAuthority: { sign: !0, write: !1 }
|
|
@@ -2830,10 +2841,10 @@ const Be = "SysvarRecentB1ockHashes11111111111111111111", V = "SysvarRent1111111
|
|
|
2830
2841
|
},
|
|
2831
2842
|
allocateWithSeed: {
|
|
2832
2843
|
coder: p({
|
|
2833
|
-
base:
|
|
2834
|
-
seed:
|
|
2844
|
+
base: y,
|
|
2845
|
+
seed: pe,
|
|
2835
2846
|
space: v,
|
|
2836
|
-
owner:
|
|
2847
|
+
owner: y
|
|
2837
2848
|
}),
|
|
2838
2849
|
keys: {
|
|
2839
2850
|
account: { sign: !1, write: !0 },
|
|
@@ -2842,9 +2853,9 @@ const Be = "SysvarRecentB1ockHashes11111111111111111111", V = "SysvarRent1111111
|
|
|
2842
2853
|
},
|
|
2843
2854
|
assignWithSeed: {
|
|
2844
2855
|
coder: p({
|
|
2845
|
-
base:
|
|
2846
|
-
seed:
|
|
2847
|
-
owner:
|
|
2856
|
+
base: y,
|
|
2857
|
+
seed: pe,
|
|
2858
|
+
owner: y
|
|
2848
2859
|
}),
|
|
2849
2860
|
keys: {
|
|
2850
2861
|
account: { sign: !1, write: !0 },
|
|
@@ -2854,8 +2865,8 @@ const Be = "SysvarRecentB1ockHashes11111111111111111111", V = "SysvarRent1111111
|
|
|
2854
2865
|
transferWithSeed: {
|
|
2855
2866
|
coder: p({
|
|
2856
2867
|
lamports: v,
|
|
2857
|
-
sourceSeed:
|
|
2858
|
-
sourceOwner:
|
|
2868
|
+
sourceSeed: pe,
|
|
2869
|
+
sourceOwner: y
|
|
2859
2870
|
}),
|
|
2860
2871
|
keys: {
|
|
2861
2872
|
source: { sign: !1, write: !0 },
|
|
@@ -2863,22 +2874,22 @@ const Be = "SysvarRecentB1ockHashes11111111111111111111", V = "SysvarRent1111111
|
|
|
2863
2874
|
destination: { sign: !1, write: !0 }
|
|
2864
2875
|
}
|
|
2865
2876
|
}
|
|
2866
|
-
}),
|
|
2877
|
+
}), bn = (t) => {
|
|
2867
2878
|
};
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
const
|
|
2879
|
+
bn(Cn.transfer);
|
|
2880
|
+
bn(Cn.advanceNonce);
|
|
2881
|
+
const Ms = lt(N, {
|
|
2871
2882
|
MintTokens: 0,
|
|
2872
2883
|
FreezeAccount: 1,
|
|
2873
2884
|
AccountOwner: 2,
|
|
2874
2885
|
CloseAccount: 3
|
|
2875
|
-
}), W = (t, e) => e[t]?.symbol || t,
|
|
2876
|
-
|
|
2886
|
+
}), W = (t, e) => e[t]?.symbol || t, xn = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
2887
|
+
dt(xn, N, {
|
|
2877
2888
|
initializeMint: {
|
|
2878
2889
|
coder: p({
|
|
2879
|
-
decimals:
|
|
2880
|
-
mintAuthority:
|
|
2881
|
-
freezeAuthority: se(
|
|
2890
|
+
decimals: N,
|
|
2891
|
+
mintAuthority: y,
|
|
2892
|
+
freezeAuthority: se(Xe, y, "11111111111111111111111111111111")
|
|
2882
2893
|
}),
|
|
2883
2894
|
keys: {
|
|
2884
2895
|
mint: { sign: !1, write: !0 },
|
|
@@ -2897,7 +2908,7 @@ ct(Cn, T, {
|
|
|
2897
2908
|
},
|
|
2898
2909
|
// TODO: multisig support?
|
|
2899
2910
|
initializeMultisig: {
|
|
2900
|
-
coder: p({ m:
|
|
2911
|
+
coder: p({ m: N }),
|
|
2901
2912
|
keys: {
|
|
2902
2913
|
account: { sign: !1, write: !0 },
|
|
2903
2914
|
_rent: { address: V, sign: !1, write: !1 }
|
|
@@ -2932,8 +2943,8 @@ ct(Cn, T, {
|
|
|
2932
2943
|
},
|
|
2933
2944
|
setAuthority: {
|
|
2934
2945
|
coder: p({
|
|
2935
|
-
authorityType:
|
|
2936
|
-
newAuthority: se(
|
|
2946
|
+
authorityType: Ms,
|
|
2947
|
+
newAuthority: se(Xe, y, "11111111111111111111111111111111")
|
|
2937
2948
|
}),
|
|
2938
2949
|
keys: {
|
|
2939
2950
|
account: { sign: !1, write: !0 },
|
|
@@ -2986,7 +2997,7 @@ ct(Cn, T, {
|
|
|
2986
2997
|
hint: (t, e) => `Thaw a frozne token account=${t.account} of mint=${t.mint} using freeze_authority=${t.authority}`
|
|
2987
2998
|
},
|
|
2988
2999
|
transferChecked: {
|
|
2989
|
-
coder: p({ amount: v, decimals:
|
|
3000
|
+
coder: p({ amount: v, decimals: N }),
|
|
2990
3001
|
keys: {
|
|
2991
3002
|
source: { sign: !1, write: !0 },
|
|
2992
3003
|
mint: { sign: !1, write: !1 },
|
|
@@ -2996,7 +3007,7 @@ ct(Cn, T, {
|
|
|
2996
3007
|
hint: (t, e) => `Transfer ${ne.decimal(t.decimals).encode(t.amount)} ${W(t.mint, e)} from token account=${t.source} of owner=${t.owner} to ${t.destination}`
|
|
2997
3008
|
},
|
|
2998
3009
|
approveChecked: {
|
|
2999
|
-
coder: p({ amount: v, decimals:
|
|
3010
|
+
coder: p({ amount: v, decimals: N }),
|
|
3000
3011
|
keys: {
|
|
3001
3012
|
source: { sign: !1, write: !0 },
|
|
3002
3013
|
mint: { sign: !1, write: !1 },
|
|
@@ -3006,7 +3017,7 @@ ct(Cn, T, {
|
|
|
3006
3017
|
hint: (t, e) => `Approve delgate=${t.delegate} authority on behalf account=${t.source} owner=${t.owner} over ${ne.decimal(t.decimals).encode(t.amount)} ${W(t.mint, e)}`
|
|
3007
3018
|
},
|
|
3008
3019
|
mintToChecked: {
|
|
3009
|
-
coder: p({ amount: v, decimals:
|
|
3020
|
+
coder: p({ amount: v, decimals: N }),
|
|
3010
3021
|
keys: {
|
|
3011
3022
|
mint: { sign: !1, write: !0 },
|
|
3012
3023
|
dest: { sign: !1, write: !0 },
|
|
@@ -3015,7 +3026,7 @@ ct(Cn, T, {
|
|
|
3015
3026
|
hint: (t, e) => `Mint new tokens (${ne.decimal(t.decimals).encode(t.amount)} ${W(t.mint, e)}) to account=${t.dest} using authority=${t.authority}`
|
|
3016
3027
|
},
|
|
3017
3028
|
burnChecked: {
|
|
3018
|
-
coder: p({ amount: v, decimals:
|
|
3029
|
+
coder: p({ amount: v, decimals: N }),
|
|
3019
3030
|
keys: {
|
|
3020
3031
|
mint: { sign: !1, write: !0 },
|
|
3021
3032
|
account: { sign: !1, write: !0 },
|
|
@@ -3024,7 +3035,7 @@ ct(Cn, T, {
|
|
|
3024
3035
|
hint: (t, e) => `Burn tokens (${ne.decimal(t.decimals).encode(t.amount)} ${W(t.mint, e)}) on account=${t.account} of owner=${t.owner}`
|
|
3025
3036
|
},
|
|
3026
3037
|
initializeAccount2: {
|
|
3027
|
-
coder: p({ owner:
|
|
3038
|
+
coder: p({ owner: y }),
|
|
3028
3039
|
keys: {
|
|
3029
3040
|
account: { sign: !1, write: !0 },
|
|
3030
3041
|
mint: { sign: !1, write: !1 },
|
|
@@ -3039,14 +3050,14 @@ ct(Cn, T, {
|
|
|
3039
3050
|
}
|
|
3040
3051
|
});
|
|
3041
3052
|
p({
|
|
3042
|
-
version:
|
|
3043
|
-
state:
|
|
3044
|
-
authority:
|
|
3045
|
-
nonce:
|
|
3053
|
+
version: ve,
|
|
3054
|
+
state: ve,
|
|
3055
|
+
authority: y,
|
|
3056
|
+
nonce: y,
|
|
3046
3057
|
lamportPerSignature: v
|
|
3047
3058
|
});
|
|
3048
|
-
const
|
|
3049
|
-
|
|
3059
|
+
const Rs = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
3060
|
+
dt(Rs, $s(0), {
|
|
3050
3061
|
create: {
|
|
3051
3062
|
coder: p({}),
|
|
3052
3063
|
keys: {
|
|
@@ -3054,37 +3065,37 @@ ct(Us, As(0), {
|
|
|
3054
3065
|
account: { sign: !1, write: !0 },
|
|
3055
3066
|
wallet: { sign: !1, write: !1 },
|
|
3056
3067
|
mint: { sign: !1, write: !1 },
|
|
3057
|
-
_sys: { address:
|
|
3058
|
-
_token: { address:
|
|
3068
|
+
_sys: { address: yn, sign: !1, write: !1 },
|
|
3069
|
+
_token: { address: xn, sign: !1, write: !1 },
|
|
3059
3070
|
_rent: { address: V, sign: !1, write: !1 }
|
|
3060
3071
|
},
|
|
3061
3072
|
hint: (t, e) => `Initialize associated token account=${t.account} with owner=${t.wallet} for token=${W(t.mint, e)}, payed by ${t.source}`
|
|
3062
3073
|
}
|
|
3063
3074
|
});
|
|
3064
|
-
const
|
|
3075
|
+
const Re = mn(4, Xe, () => 0);
|
|
3065
3076
|
p({
|
|
3066
|
-
mint:
|
|
3067
|
-
owner:
|
|
3077
|
+
mint: y,
|
|
3078
|
+
owner: y,
|
|
3068
3079
|
amount: v,
|
|
3069
|
-
delegate: se(
|
|
3070
|
-
state:
|
|
3080
|
+
delegate: se(Re, y, "11111111111111111111111111111111"),
|
|
3081
|
+
state: lt(N, {
|
|
3071
3082
|
uninitialized: 0,
|
|
3072
3083
|
initialized: 1,
|
|
3073
3084
|
frozen: 2
|
|
3074
3085
|
}),
|
|
3075
|
-
isNative: se(
|
|
3086
|
+
isNative: se(Re, v, 0n),
|
|
3076
3087
|
delegateAmount: v,
|
|
3077
|
-
closeAuthority: se(
|
|
3088
|
+
closeAuthority: se(Re, y, "11111111111111111111111111111111")
|
|
3078
3089
|
});
|
|
3079
|
-
function
|
|
3090
|
+
function Pt(t, e, n) {
|
|
3080
3091
|
if (!e.length)
|
|
3081
3092
|
throw new Error("SOLPublic: empty instructions array");
|
|
3082
|
-
return
|
|
3093
|
+
return ds.encode(Ge.encode({
|
|
3083
3094
|
msg: { feePayer: t, blockhash: n, instructions: e },
|
|
3084
3095
|
signatures: {}
|
|
3085
3096
|
}));
|
|
3086
3097
|
}
|
|
3087
|
-
function
|
|
3098
|
+
function Os(t) {
|
|
3088
3099
|
if (t.length >= 255)
|
|
3089
3100
|
throw new TypeError("Alphabet too long");
|
|
3090
3101
|
const e = new Uint8Array(256);
|
|
@@ -3106,22 +3117,22 @@ function Ms(t) {
|
|
|
3106
3117
|
const f = c.length;
|
|
3107
3118
|
for (; u !== f && c[u] === 0; )
|
|
3108
3119
|
u++, d++;
|
|
3109
|
-
const w = (f - u) * i + 1 >>> 0,
|
|
3120
|
+
const w = (f - u) * i + 1 >>> 0, C = new Uint8Array(w);
|
|
3110
3121
|
for (; u !== f; ) {
|
|
3111
|
-
let
|
|
3112
|
-
for (let
|
|
3113
|
-
|
|
3114
|
-
if (
|
|
3122
|
+
let b = c[u], g = 0;
|
|
3123
|
+
for (let S = w - 1; (b !== 0 || g < h) && S !== -1; S--, g++)
|
|
3124
|
+
b += 256 * C[S] >>> 0, C[S] = b % n >>> 0, b = b / n >>> 0;
|
|
3125
|
+
if (b !== 0)
|
|
3115
3126
|
throw new Error("Non-zero carry");
|
|
3116
3127
|
h = g, u++;
|
|
3117
3128
|
}
|
|
3118
|
-
let
|
|
3119
|
-
for (;
|
|
3120
|
-
|
|
3121
|
-
let
|
|
3122
|
-
for (;
|
|
3123
|
-
|
|
3124
|
-
return
|
|
3129
|
+
let m = w - h;
|
|
3130
|
+
for (; m !== w && C[m] === 0; )
|
|
3131
|
+
m++;
|
|
3132
|
+
let T = r.repeat(d);
|
|
3133
|
+
for (; m < w; ++m)
|
|
3134
|
+
T += t.charAt(C[m]);
|
|
3135
|
+
return T;
|
|
3125
3136
|
}
|
|
3126
3137
|
function a(c) {
|
|
3127
3138
|
if (typeof c != "string")
|
|
@@ -3133,27 +3144,27 @@ function Ms(t) {
|
|
|
3133
3144
|
h++, d++;
|
|
3134
3145
|
const f = (c.length - d) * s + 1 >>> 0, w = new Uint8Array(f);
|
|
3135
3146
|
for (; d < c.length; ) {
|
|
3136
|
-
const
|
|
3137
|
-
if (
|
|
3147
|
+
const b = c.charCodeAt(d);
|
|
3148
|
+
if (b > 255)
|
|
3138
3149
|
return;
|
|
3139
|
-
let g = e[
|
|
3150
|
+
let g = e[b];
|
|
3140
3151
|
if (g === 255)
|
|
3141
3152
|
return;
|
|
3142
|
-
let
|
|
3143
|
-
for (let
|
|
3144
|
-
g += n * w[
|
|
3153
|
+
let S = 0;
|
|
3154
|
+
for (let _ = f - 1; (g !== 0 || S < u) && _ !== -1; _--, S++)
|
|
3155
|
+
g += n * w[_] >>> 0, w[_] = g % 256 >>> 0, g = g / 256 >>> 0;
|
|
3145
3156
|
if (g !== 0)
|
|
3146
3157
|
throw new Error("Non-zero carry");
|
|
3147
|
-
u =
|
|
3158
|
+
u = S, d++;
|
|
3148
3159
|
}
|
|
3149
|
-
let
|
|
3150
|
-
for (;
|
|
3151
|
-
|
|
3152
|
-
const
|
|
3153
|
-
let
|
|
3154
|
-
for (;
|
|
3155
|
-
|
|
3156
|
-
return
|
|
3160
|
+
let C = f - u;
|
|
3161
|
+
for (; C !== f && w[C] === 0; )
|
|
3162
|
+
C++;
|
|
3163
|
+
const m = new Uint8Array(h + (f - C));
|
|
3164
|
+
let T = h;
|
|
3165
|
+
for (; C !== f; )
|
|
3166
|
+
m[T++] = w[C++];
|
|
3167
|
+
return m;
|
|
3157
3168
|
}
|
|
3158
3169
|
function l(c) {
|
|
3159
3170
|
const d = a(c);
|
|
@@ -3167,9 +3178,9 @@ function Ms(t) {
|
|
|
3167
3178
|
decode: l
|
|
3168
3179
|
};
|
|
3169
3180
|
}
|
|
3170
|
-
var
|
|
3171
|
-
|
|
3172
|
-
class
|
|
3181
|
+
var Fs = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
3182
|
+
Os(Fs);
|
|
3183
|
+
class ht {
|
|
3173
3184
|
_transaction;
|
|
3174
3185
|
signatures = [];
|
|
3175
3186
|
feePayer;
|
|
@@ -3182,15 +3193,15 @@ class lt {
|
|
|
3182
3193
|
return this._instructions.push(...e), this;
|
|
3183
3194
|
}
|
|
3184
3195
|
static from(e) {
|
|
3185
|
-
const n = e instanceof Uint8Array ? e : new Uint8Array(e), r =
|
|
3196
|
+
const n = e instanceof Uint8Array ? e : new Uint8Array(e), r = Ge.decode(n), s = new ht();
|
|
3186
3197
|
return s._transaction = r, s;
|
|
3187
3198
|
}
|
|
3188
3199
|
serialize(e) {
|
|
3189
3200
|
if (this._transaction)
|
|
3190
|
-
return Buffer.from(
|
|
3201
|
+
return Buffer.from(Ge.encode(this._transaction));
|
|
3191
3202
|
if (!this.feePayer || !this.recentBlockhash)
|
|
3192
3203
|
throw new Error("Transaction requires feePayer and recentBlockhash");
|
|
3193
|
-
const n =
|
|
3204
|
+
const n = Pt(
|
|
3194
3205
|
this.feePayer.toString(),
|
|
3195
3206
|
this._instructions,
|
|
3196
3207
|
this.recentBlockhash
|
|
@@ -3200,7 +3211,7 @@ class lt {
|
|
|
3200
3211
|
serializeMessage() {
|
|
3201
3212
|
if (!this.feePayer || !this.recentBlockhash)
|
|
3202
3213
|
throw new Error("Transaction requires feePayer and recentBlockhash");
|
|
3203
|
-
const e =
|
|
3214
|
+
const e = Pt(
|
|
3204
3215
|
this.feePayer.toString(),
|
|
3205
3216
|
this._instructions,
|
|
3206
3217
|
this.recentBlockhash
|
|
@@ -3208,7 +3219,7 @@ class lt {
|
|
|
3208
3219
|
return Buffer.from(e, "hex");
|
|
3209
3220
|
}
|
|
3210
3221
|
}
|
|
3211
|
-
class
|
|
3222
|
+
class zs {
|
|
3212
3223
|
type = "phantom";
|
|
3213
3224
|
platform = "solana";
|
|
3214
3225
|
account = void 0;
|
|
@@ -3276,7 +3287,7 @@ class Os {
|
|
|
3276
3287
|
if (!this.isAvailable() || !this.account)
|
|
3277
3288
|
throw new Error("Phantom is not connected");
|
|
3278
3289
|
try {
|
|
3279
|
-
const n =
|
|
3290
|
+
const n = ht.from(e), s = await this.getProvider().signAndSendTransaction(n);
|
|
3280
3291
|
return {
|
|
3281
3292
|
success: !0,
|
|
3282
3293
|
wallet: this.type,
|
|
@@ -3318,17 +3329,20 @@ class Os {
|
|
|
3318
3329
|
};
|
|
3319
3330
|
}
|
|
3320
3331
|
}
|
|
3321
|
-
class
|
|
3332
|
+
class js extends Ae {
|
|
3322
3333
|
type = "phantom-evm";
|
|
3323
3334
|
rdns = "app.phantom";
|
|
3324
3335
|
displayName = "Phantom";
|
|
3336
|
+
getFallbackProvider() {
|
|
3337
|
+
return window.phantom?.ethereum ?? null;
|
|
3338
|
+
}
|
|
3325
3339
|
}
|
|
3326
|
-
class
|
|
3340
|
+
class Hs extends Ae {
|
|
3327
3341
|
type = "rabby";
|
|
3328
3342
|
rdns = "io.rabby";
|
|
3329
3343
|
displayName = "Rabby";
|
|
3330
3344
|
}
|
|
3331
|
-
class
|
|
3345
|
+
class Ws {
|
|
3332
3346
|
type = "braavos";
|
|
3333
3347
|
platform = "starknet";
|
|
3334
3348
|
wallet = void 0;
|
|
@@ -3462,24 +3476,24 @@ class Fs {
|
|
|
3462
3476
|
this.removeAccountChangeListener(), this.wallet = void 0, this.account = void 0, this.connectedAccounts = [];
|
|
3463
3477
|
}
|
|
3464
3478
|
}
|
|
3465
|
-
class
|
|
3479
|
+
class qs {
|
|
3466
3480
|
walletAdapters;
|
|
3467
3481
|
constructor() {
|
|
3468
3482
|
if (this.walletAdapters = /* @__PURE__ */ new Map(), typeof window > "u")
|
|
3469
3483
|
return;
|
|
3470
|
-
const e = new
|
|
3484
|
+
const e = new ss();
|
|
3471
3485
|
this.walletAdapters.set("metamask", e);
|
|
3472
|
-
const n = new
|
|
3486
|
+
const n = new zs();
|
|
3473
3487
|
this.walletAdapters.set("phantom", n);
|
|
3474
|
-
const r = new
|
|
3488
|
+
const r = new js();
|
|
3475
3489
|
this.walletAdapters.set("phantom-evm", r);
|
|
3476
|
-
const s = new
|
|
3490
|
+
const s = new Jr();
|
|
3477
3491
|
this.walletAdapters.set("argent", s);
|
|
3478
|
-
const i = new
|
|
3492
|
+
const i = new Ws();
|
|
3479
3493
|
this.walletAdapters.set("braavos", i);
|
|
3480
|
-
const o = new
|
|
3494
|
+
const o = new Hs();
|
|
3481
3495
|
this.walletAdapters.set("rabby", o);
|
|
3482
|
-
const a = new
|
|
3496
|
+
const a = new rs();
|
|
3483
3497
|
this.walletAdapters.set("base", a), window.wallet_bridge = this;
|
|
3484
3498
|
}
|
|
3485
3499
|
getIFrameMethods() {
|
|
@@ -3542,7 +3556,7 @@ class Hs {
|
|
|
3542
3556
|
getConnectedWalletAdapter(e) {
|
|
3543
3557
|
let n, r;
|
|
3544
3558
|
try {
|
|
3545
|
-
r =
|
|
3559
|
+
r = F(e);
|
|
3546
3560
|
} catch {
|
|
3547
3561
|
if (n = this.walletAdapters.get(e), !n)
|
|
3548
3562
|
throw new Error(`Wallet ${e} is not connected or supported`);
|
|
@@ -3633,8 +3647,8 @@ class Hs {
|
|
|
3633
3647
|
}
|
|
3634
3648
|
}
|
|
3635
3649
|
}
|
|
3636
|
-
const
|
|
3637
|
-
class
|
|
3650
|
+
const Vs = 200;
|
|
3651
|
+
class Ds extends jr {
|
|
3638
3652
|
walletBridge;
|
|
3639
3653
|
onStarterpackPlay;
|
|
3640
3654
|
constructor({
|
|
@@ -3652,45 +3666,46 @@ class qs extends jr {
|
|
|
3652
3666
|
needsSessionCreation: u,
|
|
3653
3667
|
username: f,
|
|
3654
3668
|
onSessionCreated: w,
|
|
3655
|
-
onStarterpackPlay:
|
|
3656
|
-
encryptedBlob:
|
|
3657
|
-
propagateSessionErrors:
|
|
3658
|
-
errorDisplayMode:
|
|
3659
|
-
|
|
3669
|
+
onStarterpackPlay: C,
|
|
3670
|
+
encryptedBlob: m,
|
|
3671
|
+
propagateSessionErrors: T,
|
|
3672
|
+
errorDisplayMode: b,
|
|
3673
|
+
webauthnPopup: g,
|
|
3674
|
+
...S
|
|
3660
3675
|
}) {
|
|
3661
|
-
let
|
|
3662
|
-
const
|
|
3663
|
-
|
|
3676
|
+
let _;
|
|
3677
|
+
const x = new URL(e ?? Ut), X = new qs();
|
|
3678
|
+
T && x.searchParams.set("propagate_error", "true"), b && x.searchParams.set("error_display_mode", b), r && x.searchParams.set("v", encodeURIComponent(r)), s && x.searchParams.set("ps", encodeURIComponent(s)), i && x.searchParams.set("ns", encodeURIComponent(i)), o?.erc20 && x.searchParams.set(
|
|
3664
3679
|
"erc20",
|
|
3665
3680
|
encodeURIComponent(o.erc20.toString())
|
|
3666
|
-
), c &&
|
|
3681
|
+
), c && x.searchParams.set("rpc_url", encodeURIComponent(c)), d && x.searchParams.set("ref", encodeURIComponent(d)), h && x.searchParams.set("ref_group", encodeURIComponent(h)), u && x.searchParams.set("needs_session_creation", "true"), f && x.searchParams.set("username", encodeURIComponent(f)), a && x.searchParams.set("preset", a), l && x.searchParams.set("should_override_preset_policies", "true"), g && x.searchParams.set("webauthn_popup", "true"), (!a || l) && n ? x.searchParams.set(
|
|
3667
3682
|
"policies",
|
|
3668
3683
|
encodeURIComponent(JSON.stringify(n))
|
|
3669
3684
|
) : a && n && console.warn(
|
|
3670
3685
|
"[Controller] Both `preset` and `policies` provided to ControllerProvider. Policies are ignored when preset is set. Use `shouldOverridePresetPolicies: true` to override."
|
|
3671
|
-
),
|
|
3672
|
-
...
|
|
3686
|
+
), m && (x.hash = `kc=${encodeURIComponent(m)}`), super({
|
|
3687
|
+
...S,
|
|
3673
3688
|
id: "controller-keychain",
|
|
3674
|
-
url:
|
|
3689
|
+
url: x,
|
|
3675
3690
|
methods: {
|
|
3676
3691
|
...X.getIFrameMethods(),
|
|
3677
3692
|
// Expose callback for keychain to notify parent that session was created and storage access granted
|
|
3678
|
-
onSessionCreated: (
|
|
3679
|
-
onStarterpackPlay: (
|
|
3680
|
-
|
|
3693
|
+
onSessionCreated: (he) => () => w?.(),
|
|
3694
|
+
onStarterpackPlay: (he) => async () => {
|
|
3695
|
+
_ && await _();
|
|
3681
3696
|
}
|
|
3682
3697
|
}
|
|
3683
|
-
}), this.walletBridge = X, this.onStarterpackPlay =
|
|
3698
|
+
}), this.walletBridge = X, this.onStarterpackPlay = C, _ = async () => {
|
|
3684
3699
|
this.close();
|
|
3685
|
-
const
|
|
3686
|
-
if (this.onStarterpackPlay = void 0, !!
|
|
3700
|
+
const he = this.onStarterpackPlay;
|
|
3701
|
+
if (this.onStarterpackPlay = void 0, !!he) {
|
|
3687
3702
|
await new Promise(
|
|
3688
|
-
(
|
|
3703
|
+
(Le) => setTimeout(Le, Vs)
|
|
3689
3704
|
);
|
|
3690
3705
|
try {
|
|
3691
|
-
|
|
3692
|
-
} catch (
|
|
3693
|
-
console.error("Failed to run starterpack play callback:",
|
|
3706
|
+
he();
|
|
3707
|
+
} catch (Le) {
|
|
3708
|
+
console.error("Failed to run starterpack play callback:", Le);
|
|
3694
3709
|
}
|
|
3695
3710
|
}
|
|
3696
3711
|
}, typeof window < "u" && (window.external_wallets = this.walletBridge);
|
|
@@ -3702,11 +3717,11 @@ class qs extends jr {
|
|
|
3702
3717
|
this.onStarterpackPlay = e;
|
|
3703
3718
|
}
|
|
3704
3719
|
}
|
|
3705
|
-
const Y = /* @__PURE__ */ new Map(),
|
|
3706
|
-
async function
|
|
3720
|
+
const Y = /* @__PURE__ */ new Map(), Zs = `${Mt}/query`;
|
|
3721
|
+
async function kn(t) {
|
|
3707
3722
|
if (!t.addresses?.length && !t.usernames?.length)
|
|
3708
3723
|
return { results: [] };
|
|
3709
|
-
const e = await fetch(`${
|
|
3724
|
+
const e = await fetch(`${Mt}/lookup`, {
|
|
3710
3725
|
method: "POST",
|
|
3711
3726
|
headers: {
|
|
3712
3727
|
"Content-Type": "application/json"
|
|
@@ -3717,8 +3732,8 @@ async function bn(t) {
|
|
|
3717
3732
|
throw new Error(`HTTP error! status: ${e.status}`);
|
|
3718
3733
|
return e.json();
|
|
3719
3734
|
}
|
|
3720
|
-
async function
|
|
3721
|
-
const e = await fetch(
|
|
3735
|
+
async function Ks(t) {
|
|
3736
|
+
const e = await fetch(Zs, {
|
|
3722
3737
|
method: "POST",
|
|
3723
3738
|
headers: {
|
|
3724
3739
|
"Content-Type": "application/json"
|
|
@@ -3757,12 +3772,12 @@ async function Ds(t) {
|
|
|
3757
3772
|
throw new Error(`HTTP error! status: ${e.status}`);
|
|
3758
3773
|
return e.json();
|
|
3759
3774
|
}
|
|
3760
|
-
function
|
|
3775
|
+
function Xs(t) {
|
|
3761
3776
|
const e = t.toLowerCase();
|
|
3762
|
-
if (
|
|
3777
|
+
if (vn.includes(e))
|
|
3763
3778
|
return e;
|
|
3764
3779
|
}
|
|
3765
|
-
const
|
|
3780
|
+
const vn = [
|
|
3766
3781
|
"google",
|
|
3767
3782
|
"webauthn",
|
|
3768
3783
|
"discord",
|
|
@@ -3771,11 +3786,11 @@ const xn = [
|
|
|
3771
3786
|
"metamask",
|
|
3772
3787
|
"rabby",
|
|
3773
3788
|
"phantom-evm"
|
|
3774
|
-
].filter((t) =>
|
|
3775
|
-
function
|
|
3789
|
+
].filter((t) => Ln.includes(t));
|
|
3790
|
+
function Gs(t, e) {
|
|
3776
3791
|
if (!t || t.length === 0)
|
|
3777
3792
|
return [];
|
|
3778
|
-
const n = e ===
|
|
3793
|
+
const n = e === ge.StarknetChainId.SN_MAIN, r = t.filter(
|
|
3779
3794
|
(i) => !i.isRevoked && (n || i.isOriginal)
|
|
3780
3795
|
), s = /* @__PURE__ */ new Set();
|
|
3781
3796
|
for (const i of r)
|
|
@@ -3788,15 +3803,15 @@ function Ks(t, e) {
|
|
|
3788
3803
|
break;
|
|
3789
3804
|
case "Eip191Credentials":
|
|
3790
3805
|
i.metadata.eip191?.forEach((o) => {
|
|
3791
|
-
const a =
|
|
3806
|
+
const a = Xs(o.provider);
|
|
3792
3807
|
a && s.add(a);
|
|
3793
3808
|
});
|
|
3794
3809
|
break;
|
|
3795
3810
|
}
|
|
3796
|
-
return
|
|
3811
|
+
return vn.filter((i) => s.has(i));
|
|
3797
3812
|
}
|
|
3798
|
-
async function
|
|
3799
|
-
const n = await
|
|
3813
|
+
async function Ys(t, e) {
|
|
3814
|
+
const n = await Ks(t);
|
|
3800
3815
|
if (n.errors?.length)
|
|
3801
3816
|
throw new Error(n.errors[0].message || "Lookup query failed");
|
|
3802
3817
|
const r = n.data?.account;
|
|
@@ -3806,7 +3821,7 @@ async function Xs(t, e) {
|
|
|
3806
3821
|
exists: !1,
|
|
3807
3822
|
signers: []
|
|
3808
3823
|
};
|
|
3809
|
-
const s = r.controllers?.edges?.[0]?.node, i =
|
|
3824
|
+
const s = r.controllers?.edges?.[0]?.node, i = Gs(
|
|
3810
3825
|
s?.signers ?? void 0,
|
|
3811
3826
|
e
|
|
3812
3827
|
);
|
|
@@ -3816,18 +3831,18 @@ async function Xs(t, e) {
|
|
|
3816
3831
|
signers: i
|
|
3817
3832
|
};
|
|
3818
3833
|
}
|
|
3819
|
-
async function
|
|
3834
|
+
async function Li(t) {
|
|
3820
3835
|
const e = t.filter((n) => !Y.has(n));
|
|
3821
|
-
return e.length > 0 && (await
|
|
3836
|
+
return e.length > 0 && (await kn({ usernames: e })).results.forEach((r) => {
|
|
3822
3837
|
Y.set(r.username, r.addresses[0]);
|
|
3823
3838
|
}), new Map(
|
|
3824
3839
|
t.map((n) => [n, Y.get(n)]).filter((n) => n[1] !== void 0)
|
|
3825
3840
|
);
|
|
3826
3841
|
}
|
|
3827
|
-
async function
|
|
3828
|
-
t = t.map(
|
|
3842
|
+
async function _i(t) {
|
|
3843
|
+
t = t.map(Bt.toHex);
|
|
3829
3844
|
const e = t.filter((n) => !Y.has(n));
|
|
3830
|
-
return e.length > 0 && (await
|
|
3845
|
+
return e.length > 0 && (await kn({
|
|
3831
3846
|
addresses: e
|
|
3832
3847
|
})).results.forEach((r) => {
|
|
3833
3848
|
Y.set(r.addresses[0], r.username);
|
|
@@ -3835,7 +3850,7 @@ async function $i(t) {
|
|
|
3835
3850
|
t.map((n) => [n, Y.get(n)]).filter((n) => n[1] !== void 0)
|
|
3836
3851
|
);
|
|
3837
3852
|
}
|
|
3838
|
-
function
|
|
3853
|
+
function Js(t) {
|
|
3839
3854
|
if (!t || t.trim() === "")
|
|
3840
3855
|
return { isValid: !1, error: "Redirect URL is empty" };
|
|
3841
3856
|
let e;
|
|
@@ -3867,7 +3882,7 @@ function Gs(t) {
|
|
|
3867
3882
|
}
|
|
3868
3883
|
return { isValid: !0 };
|
|
3869
3884
|
}
|
|
3870
|
-
class
|
|
3885
|
+
class Ii extends _n {
|
|
3871
3886
|
keychain;
|
|
3872
3887
|
options;
|
|
3873
3888
|
iframes;
|
|
@@ -3883,7 +3898,7 @@ class Li extends Ln {
|
|
|
3883
3898
|
const r = [...[
|
|
3884
3899
|
{ rpcUrl: "https://api.cartridge.gg/x/starknet/sepolia/rpc/v0_9" },
|
|
3885
3900
|
{ rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet/rpc/v0_9" }
|
|
3886
|
-
], ...e.chains || []], s = e.defaultChainId ||
|
|
3901
|
+
], ...e.chains || []], s = e.defaultChainId || ge.StarknetChainId.SN_MAIN;
|
|
3887
3902
|
this.selectedChain = s, this.chains = /* @__PURE__ */ new Map();
|
|
3888
3903
|
const i = typeof window < "u" ? new URLSearchParams(window.location.search) : null;
|
|
3889
3904
|
if (this.referral = {
|
|
@@ -3917,7 +3932,7 @@ class Li extends Ln {
|
|
|
3917
3932
|
}
|
|
3918
3933
|
async logout() {
|
|
3919
3934
|
if (!this.keychain) {
|
|
3920
|
-
console.error(new
|
|
3935
|
+
console.error(new $().message);
|
|
3921
3936
|
return;
|
|
3922
3937
|
}
|
|
3923
3938
|
try {
|
|
@@ -3935,12 +3950,12 @@ class Li extends Ln {
|
|
|
3935
3950
|
if (this.iframes) {
|
|
3936
3951
|
try {
|
|
3937
3952
|
if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe()), await this.waitForKeychain(), !this.keychain) {
|
|
3938
|
-
console.error(new
|
|
3953
|
+
console.error(new $().message);
|
|
3939
3954
|
return;
|
|
3940
3955
|
}
|
|
3941
3956
|
const e = await this.keychain.probe(this.rpcUrl());
|
|
3942
3957
|
let n = e?.rpcUrl || this.rpcUrl();
|
|
3943
|
-
this.account = new
|
|
3958
|
+
this.account = new _e(
|
|
3944
3959
|
this,
|
|
3945
3960
|
n,
|
|
3946
3961
|
e.address,
|
|
@@ -3965,7 +3980,7 @@ class Li extends Ln {
|
|
|
3965
3980
|
if (this.account)
|
|
3966
3981
|
return this.account;
|
|
3967
3982
|
if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe()), await this.waitForKeychain(), !this.keychain || !this.iframes.keychain) {
|
|
3968
|
-
console.error(new
|
|
3983
|
+
console.error(new $().message);
|
|
3969
3984
|
return;
|
|
3970
3985
|
}
|
|
3971
3986
|
try {
|
|
@@ -3975,18 +3990,18 @@ class Li extends Ln {
|
|
|
3975
3990
|
signer: r.signer,
|
|
3976
3991
|
password: r.password
|
|
3977
3992
|
});
|
|
3978
|
-
if (o.code !==
|
|
3979
|
-
throw new
|
|
3993
|
+
if (o.code !== R.SUCCESS)
|
|
3994
|
+
throw new ue(
|
|
3980
3995
|
"message" in o && o.message ? o.message : "Headless authentication failed"
|
|
3981
3996
|
);
|
|
3982
3997
|
if (this.account)
|
|
3983
3998
|
return this.account;
|
|
3984
3999
|
const a = "address" in o && o.address ? o.address : null;
|
|
3985
4000
|
if (!a)
|
|
3986
|
-
throw new
|
|
4001
|
+
throw new ue(
|
|
3987
4002
|
"Headless authentication failed"
|
|
3988
4003
|
);
|
|
3989
|
-
return this.account = new
|
|
4004
|
+
return this.account = new _e(
|
|
3990
4005
|
this,
|
|
3991
4006
|
this.rpcUrl(),
|
|
3992
4007
|
a,
|
|
@@ -3995,14 +4010,14 @@ class Li extends Ln {
|
|
|
3995
4010
|
this.iframes.keychain
|
|
3996
4011
|
), this.emitAccountsChanged([a]), this.account;
|
|
3997
4012
|
}
|
|
3998
|
-
this.iframes.keychain.open();
|
|
4013
|
+
r || this.iframes.keychain.open();
|
|
3999
4014
|
const s = Array.isArray(e) ? e : n?.signupOptions ?? this.options.signupOptions;
|
|
4000
4015
|
let i = await this.keychain.connect({
|
|
4001
4016
|
signupOptions: s
|
|
4002
4017
|
});
|
|
4003
|
-
if (i.code !==
|
|
4018
|
+
if (i.code !== R.SUCCESS)
|
|
4004
4019
|
throw new Error(i.message);
|
|
4005
|
-
return i = i, this.account = new
|
|
4020
|
+
return i = i, this.account = new _e(
|
|
4006
4021
|
this,
|
|
4007
4022
|
this.rpcUrl(),
|
|
4008
4023
|
i.address,
|
|
@@ -4012,10 +4027,10 @@ class Li extends Ln {
|
|
|
4012
4027
|
), this.account;
|
|
4013
4028
|
} catch (s) {
|
|
4014
4029
|
if (r) {
|
|
4015
|
-
if (s instanceof
|
|
4030
|
+
if (s instanceof ue)
|
|
4016
4031
|
throw s;
|
|
4017
4032
|
const i = s instanceof Error ? s.message : typeof s == "object" && s && "message" in s ? String(s.message) : "Headless authentication failed";
|
|
4018
|
-
throw new
|
|
4033
|
+
throw new ue(i);
|
|
4019
4034
|
}
|
|
4020
4035
|
console.log(s);
|
|
4021
4036
|
} finally {
|
|
@@ -4027,7 +4042,7 @@ class Li extends Ln {
|
|
|
4027
4042
|
if (!this.iframes)
|
|
4028
4043
|
return !1;
|
|
4029
4044
|
if (!this.keychain || !this.iframes.keychain)
|
|
4030
|
-
return console.error(new
|
|
4045
|
+
return console.error(new $().message), !1;
|
|
4031
4046
|
const n = this.selectedChain;
|
|
4032
4047
|
try {
|
|
4033
4048
|
this.selectedChain = e, await this.keychain.switchChain(this.rpcUrl());
|
|
@@ -4052,16 +4067,16 @@ class Li extends Ln {
|
|
|
4052
4067
|
} catch {
|
|
4053
4068
|
}
|
|
4054
4069
|
if (!this.keychain) {
|
|
4055
|
-
console.error(new
|
|
4070
|
+
console.error(new $().message);
|
|
4056
4071
|
return;
|
|
4057
4072
|
}
|
|
4058
|
-
return this.keychain.disconnect();
|
|
4073
|
+
return await this.keychain.disconnect(), this.close();
|
|
4059
4074
|
}
|
|
4060
4075
|
async openProfile(e = "inventory") {
|
|
4061
4076
|
if (!this.iframes)
|
|
4062
4077
|
return;
|
|
4063
4078
|
if (!this.keychain || !this.iframes.keychain) {
|
|
4064
|
-
console.error(new
|
|
4079
|
+
console.error(new $().message);
|
|
4065
4080
|
return;
|
|
4066
4081
|
}
|
|
4067
4082
|
if (!this.account) {
|
|
@@ -4077,7 +4092,7 @@ class Li extends Ln {
|
|
|
4077
4092
|
if (!this.iframes)
|
|
4078
4093
|
return;
|
|
4079
4094
|
if (!this.keychain || !this.iframes.keychain) {
|
|
4080
|
-
console.error(new
|
|
4095
|
+
console.error(new $().message);
|
|
4081
4096
|
return;
|
|
4082
4097
|
}
|
|
4083
4098
|
if (!this.account) {
|
|
@@ -4092,7 +4107,7 @@ class Li extends Ln {
|
|
|
4092
4107
|
async openProfileAt(e) {
|
|
4093
4108
|
if (this.iframes) {
|
|
4094
4109
|
if (!this.keychain || !this.iframes.keychain) {
|
|
4095
|
-
console.error(new
|
|
4110
|
+
console.error(new $().message);
|
|
4096
4111
|
return;
|
|
4097
4112
|
}
|
|
4098
4113
|
if (!this.account) {
|
|
@@ -4105,7 +4120,7 @@ class Li extends Ln {
|
|
|
4105
4120
|
openSettings() {
|
|
4106
4121
|
if (this.iframes) {
|
|
4107
4122
|
if (!this.keychain || !this.iframes.keychain) {
|
|
4108
|
-
console.error(new
|
|
4123
|
+
console.error(new $().message);
|
|
4109
4124
|
return;
|
|
4110
4125
|
}
|
|
4111
4126
|
this.iframes.keychain.open(), this.keychain.openSettings();
|
|
@@ -4114,24 +4129,48 @@ class Li extends Ln {
|
|
|
4114
4129
|
async close() {
|
|
4115
4130
|
!this.iframes || !this.iframes.keychain || this.iframes.keychain.close();
|
|
4116
4131
|
}
|
|
4132
|
+
async updateSession(e = {}) {
|
|
4133
|
+
if (!e.policies && !e.preset)
|
|
4134
|
+
throw new Error("Either `policies` or `preset` must be provided");
|
|
4135
|
+
if (this.iframes) {
|
|
4136
|
+
if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe()), await this.waitForKeychain(), !this.keychain || !this.iframes.keychain) {
|
|
4137
|
+
console.error(new $().message);
|
|
4138
|
+
return;
|
|
4139
|
+
}
|
|
4140
|
+
this.iframes.keychain.open();
|
|
4141
|
+
try {
|
|
4142
|
+
const n = await this.keychain.updateSession(
|
|
4143
|
+
e.policies,
|
|
4144
|
+
e.preset
|
|
4145
|
+
);
|
|
4146
|
+
if (n.code !== R.SUCCESS)
|
|
4147
|
+
throw new Error(n.message);
|
|
4148
|
+
return n;
|
|
4149
|
+
} catch (n) {
|
|
4150
|
+
console.error(n);
|
|
4151
|
+
} finally {
|
|
4152
|
+
this.iframes.keychain.close();
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
}
|
|
4117
4156
|
revoke(e, n) {
|
|
4118
|
-
return this.keychain ? this.keychain.revoke(e) : (console.error(new
|
|
4157
|
+
return this.keychain ? this.keychain.revoke(e) : (console.error(new $().message), null);
|
|
4119
4158
|
}
|
|
4120
4159
|
rpcUrl() {
|
|
4121
4160
|
const e = this.chains.get(this.selectedChain);
|
|
4122
4161
|
if (!e) {
|
|
4123
4162
|
const n = Array.from(this.chains.keys()).map(
|
|
4124
|
-
(r) =>
|
|
4163
|
+
(r) => ft.decodeShortString(r)
|
|
4125
4164
|
);
|
|
4126
4165
|
throw new Error(
|
|
4127
|
-
`Chain not found: ${
|
|
4166
|
+
`Chain not found: ${ft.decodeShortString(this.selectedChain)}. Available chains: ${n.join(", ")}`
|
|
4128
4167
|
);
|
|
4129
4168
|
}
|
|
4130
4169
|
return e.rpcUrl;
|
|
4131
4170
|
}
|
|
4132
4171
|
username() {
|
|
4133
4172
|
if (!this.keychain) {
|
|
4134
|
-
console.error(new
|
|
4173
|
+
console.error(new $().message);
|
|
4135
4174
|
return;
|
|
4136
4175
|
}
|
|
4137
4176
|
return this.keychain.username();
|
|
@@ -4140,12 +4179,12 @@ class Li extends Ln {
|
|
|
4140
4179
|
const n = e.trim();
|
|
4141
4180
|
if (!n)
|
|
4142
4181
|
throw new Error("Username is required");
|
|
4143
|
-
return
|
|
4182
|
+
return Ys(n, this.selectedChain);
|
|
4144
4183
|
}
|
|
4145
4184
|
openPurchaseCredits() {
|
|
4146
4185
|
if (this.iframes) {
|
|
4147
4186
|
if (!this.keychain || !this.iframes.keychain) {
|
|
4148
|
-
console.error(new
|
|
4187
|
+
console.error(new $().message);
|
|
4149
4188
|
return;
|
|
4150
4189
|
}
|
|
4151
4190
|
this.keychain.navigate("/purchase/credits").then(() => {
|
|
@@ -4157,7 +4196,7 @@ class Li extends Ln {
|
|
|
4157
4196
|
if (!this.iframes)
|
|
4158
4197
|
return;
|
|
4159
4198
|
if (!this.keychain || !this.iframes.keychain) {
|
|
4160
|
-
console.error(new
|
|
4199
|
+
console.error(new $().message);
|
|
4161
4200
|
return;
|
|
4162
4201
|
}
|
|
4163
4202
|
const { onPurchaseComplete: r, ...s } = n ?? {};
|
|
@@ -4169,19 +4208,19 @@ class Li extends Ln {
|
|
|
4169
4208
|
if (!this.iframes)
|
|
4170
4209
|
return;
|
|
4171
4210
|
if (!this.keychain || !this.iframes.keychain) {
|
|
4172
|
-
console.error(new
|
|
4211
|
+
console.error(new $().message);
|
|
4173
4212
|
return;
|
|
4174
4213
|
}
|
|
4175
4214
|
let r = this.selectedChain;
|
|
4176
4215
|
n && this.switchStarknetChain(n), this.iframes.keychain.open();
|
|
4177
4216
|
const s = await this.keychain.execute(e, void 0, void 0, !0);
|
|
4178
4217
|
return this.iframes.keychain.close(), n && this.switchStarknetChain(r), {
|
|
4179
|
-
status: !(s && (s.code ===
|
|
4218
|
+
status: !(s && (s.code === R.NOT_CONNECTED || s.code === R.CANCELED)),
|
|
4180
4219
|
transactionHash: s?.transaction_hash
|
|
4181
4220
|
};
|
|
4182
4221
|
}
|
|
4183
4222
|
async delegateAccount() {
|
|
4184
|
-
return this.keychain ? await this.keychain.delegateAccount() : (console.error(new
|
|
4223
|
+
return this.keychain ? await this.keychain.delegateAccount() : (console.error(new $().message), null);
|
|
4185
4224
|
}
|
|
4186
4225
|
/**
|
|
4187
4226
|
* Returns a wallet standard interface for the controller.
|
|
@@ -4191,7 +4230,7 @@ class Li extends Ln {
|
|
|
4191
4230
|
typeof window < "u" && console.warn(
|
|
4192
4231
|
"Casting Controller to WalletWithStarknetFeatures is an experimental feature. Please report any issues at https://github.com/cartridge-gg/controller/issues"
|
|
4193
4232
|
);
|
|
4194
|
-
const e = this, n = new
|
|
4233
|
+
const e = this, n = new wr(e), r = {
|
|
4195
4234
|
"standard:disconnect": {
|
|
4196
4235
|
version: "1.0.0",
|
|
4197
4236
|
disconnect: async () => {
|
|
@@ -4230,7 +4269,7 @@ class Li extends Ln {
|
|
|
4230
4269
|
console.error("open can only be called in browser context");
|
|
4231
4270
|
return;
|
|
4232
4271
|
}
|
|
4233
|
-
const n = new URL(this.options.url ||
|
|
4272
|
+
const n = new URL(this.options.url || Ut), r = e.redirectUrl || window.location.href, s = Js(r);
|
|
4234
4273
|
if (!s.isValid) {
|
|
4235
4274
|
console.error(
|
|
4236
4275
|
`Invalid redirect URL: ${s.error}`,
|
|
@@ -4246,7 +4285,7 @@ class Li extends Ln {
|
|
|
4246
4285
|
initializeChains(e) {
|
|
4247
4286
|
for (const n of e)
|
|
4248
4287
|
try {
|
|
4249
|
-
const r = new URL(n.rpcUrl), s =
|
|
4288
|
+
const r = new URL(n.rpcUrl), s = In(r);
|
|
4250
4289
|
this.chains.set(s, n);
|
|
4251
4290
|
} catch (r) {
|
|
4252
4291
|
throw console.error(`Failed to parse chainId for ${n.rpcUrl}:`, r), r;
|
|
@@ -4258,7 +4297,7 @@ class Li extends Ln {
|
|
|
4258
4297
|
createKeychainIframe() {
|
|
4259
4298
|
const e = typeof window < "u" && typeof sessionStorage < "u" && sessionStorage.getItem("controller_standalone") === "1", r = (typeof window < "u" ? new URLSearchParams(window.location.search) : void 0)?.get("username") ?? void 0, s = this.encryptedBlob;
|
|
4260
4299
|
e && sessionStorage.removeItem("controller_standalone"), s && (this.encryptedBlob = void 0);
|
|
4261
|
-
const i = new
|
|
4300
|
+
const i = new Ds({
|
|
4262
4301
|
...this.options,
|
|
4263
4302
|
rpcUrl: this.rpcUrl(),
|
|
4264
4303
|
onClose: () => {
|
|
@@ -4267,7 +4306,7 @@ class Li extends Ln {
|
|
|
4267
4306
|
onConnect: (o) => {
|
|
4268
4307
|
this.keychain = o;
|
|
4269
4308
|
},
|
|
4270
|
-
version:
|
|
4309
|
+
version: Pn,
|
|
4271
4310
|
ref: this.referral.ref,
|
|
4272
4311
|
refGroup: this.referral.refGroup,
|
|
4273
4312
|
needsSessionCreation: e,
|
|
@@ -4297,18 +4336,18 @@ class Li extends Ln {
|
|
|
4297
4336
|
});
|
|
4298
4337
|
}
|
|
4299
4338
|
}
|
|
4300
|
-
const k = "cartridge-toast-container",
|
|
4301
|
-
function
|
|
4339
|
+
const k = "cartridge-toast-container", Qs = 3e3, ei = "bottom-right", En = "cartridge-toast-show";
|
|
4340
|
+
function ut() {
|
|
4302
4341
|
try {
|
|
4303
4342
|
return typeof window < "u" && window.self !== window.top;
|
|
4304
4343
|
} catch {
|
|
4305
4344
|
return !0;
|
|
4306
4345
|
}
|
|
4307
4346
|
}
|
|
4308
|
-
function
|
|
4347
|
+
function ti() {
|
|
4309
4348
|
if (typeof document > "u")
|
|
4310
4349
|
return null;
|
|
4311
|
-
if (
|
|
4350
|
+
if (ut())
|
|
4312
4351
|
try {
|
|
4313
4352
|
if (window.parent && window.parent.document)
|
|
4314
4353
|
return window.parent.document;
|
|
@@ -4317,22 +4356,22 @@ function Qs() {
|
|
|
4317
4356
|
}
|
|
4318
4357
|
return document;
|
|
4319
4358
|
}
|
|
4320
|
-
function
|
|
4359
|
+
function ni(t, e) {
|
|
4321
4360
|
let n = t.getElementById(k);
|
|
4322
4361
|
return n || (n = t.createElement("div"), n.id = k, t.body && t.body.appendChild(n)), n.className = e, n;
|
|
4323
4362
|
}
|
|
4324
|
-
function
|
|
4363
|
+
function ri(t) {
|
|
4325
4364
|
t.classList.add("closing"), setTimeout(() => {
|
|
4326
4365
|
t.parentNode && t.parentNode.removeChild(t);
|
|
4327
4366
|
}, 200);
|
|
4328
4367
|
}
|
|
4329
|
-
function
|
|
4368
|
+
function si(t) {
|
|
4330
4369
|
if (t.getElementById("cartridge-toast-styles"))
|
|
4331
4370
|
return;
|
|
4332
4371
|
const e = t.createElement("style");
|
|
4333
|
-
e.id = "cartridge-toast-styles", e.textContent =
|
|
4372
|
+
e.id = "cartridge-toast-styles", e.textContent = ii(), t.head.appendChild(e);
|
|
4334
4373
|
}
|
|
4335
|
-
function
|
|
4374
|
+
function ii() {
|
|
4336
4375
|
return `
|
|
4337
4376
|
#${k} {
|
|
4338
4377
|
position: fixed;
|
|
@@ -4508,7 +4547,7 @@ const de = (t = !1) => {
|
|
|
4508
4547
|
}
|
|
4509
4548
|
return e.appendChild(n), e;
|
|
4510
4549
|
};
|
|
4511
|
-
function
|
|
4550
|
+
function oi(t) {
|
|
4512
4551
|
if (t.getElementById("cartridge-toast-error-styles"))
|
|
4513
4552
|
return;
|
|
4514
4553
|
const e = t.createElement("style");
|
|
@@ -4582,7 +4621,7 @@ function si(t) {
|
|
|
4582
4621
|
}
|
|
4583
4622
|
`, t.head.appendChild(e);
|
|
4584
4623
|
}
|
|
4585
|
-
function
|
|
4624
|
+
function ai(t) {
|
|
4586
4625
|
const e = document.createElement("div");
|
|
4587
4626
|
e.className = "cartridge-toast error";
|
|
4588
4627
|
const n = document.createElement("div");
|
|
@@ -4602,7 +4641,7 @@ function ii(t) {
|
|
|
4602
4641
|
const a = de(!0);
|
|
4603
4642
|
return o.appendChild(a), e.appendChild(o), e;
|
|
4604
4643
|
}
|
|
4605
|
-
function
|
|
4644
|
+
function ci(t) {
|
|
4606
4645
|
if (t.getElementById("cartridge-toast-transaction-styles"))
|
|
4607
4646
|
return;
|
|
4608
4647
|
const e = t.createElement("style");
|
|
@@ -4739,7 +4778,7 @@ function oi(t) {
|
|
|
4739
4778
|
}
|
|
4740
4779
|
`, t.head.appendChild(e);
|
|
4741
4780
|
}
|
|
4742
|
-
function
|
|
4781
|
+
function li(t) {
|
|
4743
4782
|
const e = document.createElement("div");
|
|
4744
4783
|
if (e.className = `cartridge-toast transaction ${t.isExpanded ? "expanded" : "collapsed"}`, t.isExpanded) {
|
|
4745
4784
|
const n = document.createElement("div");
|
|
@@ -4794,7 +4833,7 @@ function ai(t) {
|
|
|
4794
4833
|
}
|
|
4795
4834
|
return e;
|
|
4796
4835
|
}
|
|
4797
|
-
function
|
|
4836
|
+
function di(t) {
|
|
4798
4837
|
if (t.getElementById("cartridge-toast-network-switch-styles"))
|
|
4799
4838
|
return;
|
|
4800
4839
|
const e = t.createElement("style");
|
|
@@ -4818,15 +4857,15 @@ function ci(t) {
|
|
|
4818
4857
|
}
|
|
4819
4858
|
`, t.head.appendChild(e);
|
|
4820
4859
|
}
|
|
4821
|
-
function
|
|
4860
|
+
function hi(t) {
|
|
4822
4861
|
const e = document.createElement("div");
|
|
4823
4862
|
e.className = "cartridge-toast network-switch";
|
|
4824
4863
|
const n = document.createElement(t.networkIcon ? "img" : "div");
|
|
4825
|
-
n.className = "icon", n.style.width = "24px", n.style.height = "24px", n.style.aspectRatio = "1/1", t.networkIcon ? (n.src =
|
|
4864
|
+
n.className = "icon", n.style.width = "24px", n.style.height = "24px", n.style.aspectRatio = "1/1", t.networkIcon ? (n.src = Rt(t.networkIcon), n.alt = t.networkName) : (n.style.backgroundColor = "#161A17", n.innerHTML = t.networkName.charAt(0).toUpperCase(), n.style.color = "#ffffff", n.style.fontWeight = "600", n.style.fontSize = "12px", n.style.lineHeight = "16px", n.style.textAlign = "center", n.style.textTransform = "uppercase", n.style.borderRadius = "4px", n.style.padding = "4px");
|
|
4826
4865
|
const r = document.createElement("p");
|
|
4827
4866
|
return r.className = "content", r.textContent = `Switched to ${t.networkName}`, e.appendChild(n), e.appendChild(r), e;
|
|
4828
4867
|
}
|
|
4829
|
-
function
|
|
4868
|
+
function ui(t) {
|
|
4830
4869
|
if (t.getElementById("cartridge-toast-achievement-styles"))
|
|
4831
4870
|
return;
|
|
4832
4871
|
const e = t.createElement("style");
|
|
@@ -4929,14 +4968,14 @@ function di(t) {
|
|
|
4929
4968
|
}
|
|
4930
4969
|
`, t.head.appendChild(e);
|
|
4931
4970
|
}
|
|
4932
|
-
function
|
|
4971
|
+
function fi(t) {
|
|
4933
4972
|
const e = document.createElement("div");
|
|
4934
4973
|
e.className = "cartridge-toast achievement";
|
|
4935
4974
|
const n = document.createElement("div");
|
|
4936
4975
|
n.className = "image-content-container";
|
|
4937
4976
|
const r = document.createElement("div");
|
|
4938
4977
|
r.className = "image-container";
|
|
4939
|
-
const s =
|
|
4978
|
+
const s = pi(t.isDraft);
|
|
4940
4979
|
s.className = "image", r.appendChild(s);
|
|
4941
4980
|
const i = document.createElement("div");
|
|
4942
4981
|
i.className = "content";
|
|
@@ -4948,14 +4987,14 @@ function hi(t) {
|
|
|
4948
4987
|
l.className = "xp-section-container";
|
|
4949
4988
|
const c = document.createElement("div");
|
|
4950
4989
|
c.className = "xp-section";
|
|
4951
|
-
const d =
|
|
4990
|
+
const d = wi(!t.isDraft);
|
|
4952
4991
|
d.setAttribute("class", "xp-icon"), c.appendChild(d);
|
|
4953
4992
|
const h = document.createElement("span");
|
|
4954
4993
|
h.className = "xp-amount", h.textContent = `${t.xpAmount}`, c.appendChild(h), l.appendChild(c);
|
|
4955
4994
|
const u = de(!1);
|
|
4956
4995
|
return e.appendChild(n), e.appendChild(l), e.appendChild(u), e;
|
|
4957
4996
|
}
|
|
4958
|
-
const
|
|
4997
|
+
const pi = (t = !1) => {
|
|
4959
4998
|
const e = document.createElement("div"), n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
4960
4999
|
switch (n.setAttribute("width", "34"), n.setAttribute("height", "34"), n.setAttribute("viewBox", "0 0 30 30"), n.style.width = "100%", n.style.height = "100%", t) {
|
|
4961
5000
|
case !0:
|
|
@@ -4969,7 +5008,7 @@ const ui = (t = !1) => {
|
|
|
4969
5008
|
`;
|
|
4970
5009
|
}
|
|
4971
5010
|
return e.appendChild(n), e;
|
|
4972
|
-
},
|
|
5011
|
+
}, wi = (t) => {
|
|
4973
5012
|
const e = document.createElementNS(
|
|
4974
5013
|
"http://www.w3.org/2000/svg",
|
|
4975
5014
|
"svg"
|
|
@@ -5005,7 +5044,7 @@ const ui = (t = !1) => {
|
|
|
5005
5044
|
}
|
|
5006
5045
|
return e;
|
|
5007
5046
|
};
|
|
5008
|
-
function
|
|
5047
|
+
function gi(t) {
|
|
5009
5048
|
if (t.getElementById("cartridge-toast-marketplace-styles"))
|
|
5010
5049
|
return;
|
|
5011
5050
|
const e = t.createElement("style");
|
|
@@ -5089,7 +5128,7 @@ function pi(t) {
|
|
|
5089
5128
|
}
|
|
5090
5129
|
`, t.head.appendChild(e);
|
|
5091
5130
|
}
|
|
5092
|
-
function
|
|
5131
|
+
function mi(t) {
|
|
5093
5132
|
const e = document.createElement("div");
|
|
5094
5133
|
e.className = "cartridge-toast marketplace";
|
|
5095
5134
|
const n = document.createElement("div");
|
|
@@ -5097,7 +5136,7 @@ function wi(t) {
|
|
|
5097
5136
|
const r = document.createElement("div");
|
|
5098
5137
|
r.className = "image-container";
|
|
5099
5138
|
const s = document.createElement("img");
|
|
5100
|
-
s.className = "image", s.src =
|
|
5139
|
+
s.className = "image", s.src = Rt(t.itemImages[0]), s.alt = t.itemNames[0], r.appendChild(s);
|
|
5101
5140
|
const i = document.createElement("div");
|
|
5102
5141
|
i.className = "content";
|
|
5103
5142
|
const o = {
|
|
@@ -5115,7 +5154,7 @@ function wi(t) {
|
|
|
5115
5154
|
const d = de(!1);
|
|
5116
5155
|
return c.appendChild(d), e.appendChild(n), e.appendChild(c), e;
|
|
5117
5156
|
}
|
|
5118
|
-
function
|
|
5157
|
+
function yi(t) {
|
|
5119
5158
|
if (t.getElementById("cartridge-toast-quest-styles"))
|
|
5120
5159
|
return;
|
|
5121
5160
|
const e = t.createElement("style");
|
|
@@ -5218,14 +5257,14 @@ function gi(t) {
|
|
|
5218
5257
|
}
|
|
5219
5258
|
`, t.head.appendChild(e);
|
|
5220
5259
|
}
|
|
5221
|
-
function
|
|
5260
|
+
function Ci(t) {
|
|
5222
5261
|
const e = document.createElement("div");
|
|
5223
5262
|
e.className = "cartridge-toast quest";
|
|
5224
5263
|
const n = document.createElement("div");
|
|
5225
5264
|
n.className = "image-content-container";
|
|
5226
5265
|
const r = document.createElement("div");
|
|
5227
5266
|
r.className = "image-container";
|
|
5228
|
-
const s =
|
|
5267
|
+
const s = bi();
|
|
5229
5268
|
s.className = "image", r.appendChild(s);
|
|
5230
5269
|
const i = document.createElement("div");
|
|
5231
5270
|
i.className = "content";
|
|
@@ -5236,10 +5275,10 @@ function mi(t) {
|
|
|
5236
5275
|
const l = de(!1);
|
|
5237
5276
|
return e.appendChild(n), e.appendChild(l), e;
|
|
5238
5277
|
}
|
|
5239
|
-
const
|
|
5278
|
+
const bi = () => {
|
|
5240
5279
|
const t = document.createElement("div"), e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
5241
5280
|
return e.setAttribute("width", "34"), e.setAttribute("height", "34"), e.setAttribute("viewBox", "0 0 30 30"), e.style.width = "100%", e.style.height = "100%", e.innerHTML = '<path d="M3 6.5V8C3 8.55312 3.44687 9 4 9H4.5H6V6.5C6 5.67188 5.32812 5 4.5 5C3.67188 5 3 5.67188 3 6.5ZM6.5 5C6.8125 5.41875 7 5.9375 7 6.5V16C7 17.1031 7.89687 18 9 18C10.1031 18 11 17.1031 11 16V15.8344C11 14.8219 11.8219 14 12.8344 14H18V8C18 6.34375 16.6562 5 15 5H6.5ZM17.5 19C19.4344 19 21 17.4344 21 15.5C21 15.225 20.775 15 20.5 15H12.8344C12.375 15 12 15.3719 12 15.8344V16C12 17.6562 10.6562 19 9 19H14.5H17.5Z" fill="white"/>', t.appendChild(e), t;
|
|
5242
|
-
},
|
|
5281
|
+
}, xi = (t) => {
|
|
5243
5282
|
const e = t.borderRadius ?? 8, n = !isFinite(t.duration) || t.duration <= 0, r = document.createElement("div");
|
|
5244
5283
|
r.className = "cartridge-toast-progress-bar", r.style.position = "absolute", r.style.bottom = "0", r.style.left = "0", r.style.right = "0", r.style.height = "4px", r.style.overflow = "hidden", r.style.borderBottomLeftRadius = `${e}px`, r.style.borderBottomRightRadius = `${e}px`, r.style.backgroundColor = "rgba(255, 255, 255, 0.2)";
|
|
5245
5284
|
const s = document.createElement("div");
|
|
@@ -5251,55 +5290,55 @@ const yi = () => {
|
|
|
5251
5290
|
t.onComplete?.();
|
|
5252
5291
|
}, t.duration)), r.appendChild(s), r;
|
|
5253
5292
|
};
|
|
5254
|
-
function
|
|
5255
|
-
const s =
|
|
5293
|
+
function Tt(t, e, n, r) {
|
|
5294
|
+
const s = xi({
|
|
5256
5295
|
duration: e,
|
|
5257
5296
|
onComplete: n,
|
|
5258
5297
|
borderRadius: r
|
|
5259
5298
|
});
|
|
5260
5299
|
t.appendChild(s);
|
|
5261
5300
|
}
|
|
5262
|
-
function
|
|
5301
|
+
function ki(t) {
|
|
5263
5302
|
switch (t.variant) {
|
|
5264
5303
|
case "error":
|
|
5265
|
-
return ii(t);
|
|
5266
|
-
case "transaction":
|
|
5267
5304
|
return ai(t);
|
|
5268
|
-
case "
|
|
5305
|
+
case "transaction":
|
|
5269
5306
|
return li(t);
|
|
5270
|
-
case "
|
|
5307
|
+
case "network-switch":
|
|
5271
5308
|
return hi(t);
|
|
5309
|
+
case "achievement":
|
|
5310
|
+
return fi(t);
|
|
5272
5311
|
case "quest":
|
|
5273
|
-
return
|
|
5312
|
+
return Ci(t);
|
|
5274
5313
|
case "marketplace":
|
|
5275
|
-
return
|
|
5314
|
+
return mi(t);
|
|
5276
5315
|
}
|
|
5277
5316
|
}
|
|
5278
|
-
function
|
|
5317
|
+
function vi(t, e) {
|
|
5279
5318
|
switch (e) {
|
|
5280
5319
|
case "error":
|
|
5281
|
-
|
|
5320
|
+
oi(t);
|
|
5282
5321
|
break;
|
|
5283
5322
|
case "transaction":
|
|
5284
|
-
|
|
5323
|
+
ci(t);
|
|
5285
5324
|
break;
|
|
5286
5325
|
case "network-switch":
|
|
5287
|
-
|
|
5326
|
+
di(t);
|
|
5288
5327
|
break;
|
|
5289
5328
|
case "achievement":
|
|
5290
|
-
|
|
5329
|
+
ui(t);
|
|
5291
5330
|
break;
|
|
5292
5331
|
case "quest":
|
|
5293
|
-
|
|
5332
|
+
yi(t);
|
|
5294
5333
|
break;
|
|
5295
5334
|
case "marketplace":
|
|
5296
|
-
|
|
5335
|
+
gi(t);
|
|
5297
5336
|
break;
|
|
5298
5337
|
}
|
|
5299
5338
|
}
|
|
5300
|
-
function
|
|
5301
|
-
|
|
5302
|
-
const n = e.position ||
|
|
5339
|
+
function Ye(t, e) {
|
|
5340
|
+
si(t), vi(t, e.variant);
|
|
5341
|
+
const n = e.position || ei, r = ni(t, n), s = ki(e), i = () => ri(s);
|
|
5303
5342
|
r.appendChild(s), e.onClick && (s.style.cursor = "pointer", s.addEventListener("click", (d) => {
|
|
5304
5343
|
!d.target.closest("#close-button") && e.onClick && e.onClick();
|
|
5305
5344
|
}));
|
|
@@ -5308,37 +5347,37 @@ function Xe(t, e) {
|
|
|
5308
5347
|
d.stopPropagation(), i();
|
|
5309
5348
|
});
|
|
5310
5349
|
let a = null;
|
|
5311
|
-
const l = e.duration ??
|
|
5350
|
+
const l = e.duration ?? Qs, c = !isFinite(l) || l <= 0;
|
|
5312
5351
|
if (e.variant !== "network-switch") {
|
|
5313
5352
|
const d = e.variant === "error" || e.variant === "transaction" ? 8 : 4;
|
|
5314
|
-
c ?
|
|
5315
|
-
}, d) :
|
|
5353
|
+
c ? Tt(s, 1 / 0, () => {
|
|
5354
|
+
}, d) : Tt(s, l, i, d);
|
|
5316
5355
|
} else c || (a = setTimeout(i, l));
|
|
5317
5356
|
return () => {
|
|
5318
5357
|
a && clearTimeout(a), i();
|
|
5319
5358
|
};
|
|
5320
5359
|
}
|
|
5321
|
-
let
|
|
5322
|
-
function
|
|
5323
|
-
|
|
5324
|
-
if (t.data?.type ===
|
|
5360
|
+
let Nt = !1;
|
|
5361
|
+
function An() {
|
|
5362
|
+
Nt || typeof window > "u" || ut() || (window.addEventListener("message", (t) => {
|
|
5363
|
+
if (t.data?.type === En && t.data?.options) {
|
|
5325
5364
|
const e = document;
|
|
5326
|
-
e &&
|
|
5365
|
+
e && Ye(e, t.data.options);
|
|
5327
5366
|
}
|
|
5328
|
-
}),
|
|
5367
|
+
}), Nt = !0);
|
|
5329
5368
|
}
|
|
5330
|
-
function
|
|
5369
|
+
function Ei(t) {
|
|
5331
5370
|
if (typeof window > "u" || typeof document > "u")
|
|
5332
5371
|
return console.warn("Toast can only be used in a browser environment"), () => {
|
|
5333
5372
|
};
|
|
5334
|
-
if (
|
|
5335
|
-
const e =
|
|
5373
|
+
if (An(), ut()) {
|
|
5374
|
+
const e = ti();
|
|
5336
5375
|
if (e)
|
|
5337
|
-
return
|
|
5376
|
+
return Ye(e, t);
|
|
5338
5377
|
try {
|
|
5339
5378
|
window.parent && window.parent.postMessage(
|
|
5340
5379
|
{
|
|
5341
|
-
type:
|
|
5380
|
+
type: En,
|
|
5342
5381
|
options: t
|
|
5343
5382
|
},
|
|
5344
5383
|
"*"
|
|
@@ -5350,56 +5389,55 @@ function ki(t) {
|
|
|
5350
5389
|
return () => {
|
|
5351
5390
|
};
|
|
5352
5391
|
} else
|
|
5353
|
-
return
|
|
5392
|
+
return Ye(document, t);
|
|
5354
5393
|
}
|
|
5355
|
-
typeof window < "u" &&
|
|
5356
|
-
const
|
|
5394
|
+
typeof window < "u" && An();
|
|
5395
|
+
const Ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5357
5396
|
__proto__: null,
|
|
5358
|
-
toast:
|
|
5397
|
+
toast: Ei
|
|
5359
5398
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5360
5399
|
export {
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
ki as toast
|
|
5400
|
+
Ni as ALL_AUTH_OPTIONS,
|
|
5401
|
+
Bi as AUTH_EXTERNAL_WALLETS,
|
|
5402
|
+
Jr as ArgentWallet,
|
|
5403
|
+
rs as BaseWallet,
|
|
5404
|
+
Ws as BraavosWallet,
|
|
5405
|
+
Ui as EMBEDDED_WALLETS,
|
|
5406
|
+
Mi as EXTERNAL_WALLETS,
|
|
5407
|
+
Ri as EXTRA_EXTERNAL_WALLETS,
|
|
5408
|
+
Ae as EthereumWalletBase,
|
|
5409
|
+
Oi as FeeSource,
|
|
5410
|
+
ue as HeadlessAuthenticationError,
|
|
5411
|
+
Fi as HeadlessModeNotSupportedError,
|
|
5412
|
+
Ln as IMPLEMENTED_AUTH_OPTIONS,
|
|
5413
|
+
zi as InvalidCredentialsError,
|
|
5414
|
+
ss as MetaMaskWallet,
|
|
5415
|
+
$ as NotReadyToConnect,
|
|
5416
|
+
js as PhantomEVMWallet,
|
|
5417
|
+
zs as PhantomWallet,
|
|
5418
|
+
Hs as RabbyWallet,
|
|
5419
|
+
R as ResponseCodes,
|
|
5420
|
+
qs as WalletBridge,
|
|
5421
|
+
Ie as chainIdToPlatform,
|
|
5422
|
+
Ii as default,
|
|
5423
|
+
ji as defaultTheme,
|
|
5424
|
+
Hi as erc20Metadata,
|
|
5425
|
+
Wi as getAvailableConfigs,
|
|
5426
|
+
qi as getConfigsIndex,
|
|
5427
|
+
Vi as getPresetSessionPolicies,
|
|
5428
|
+
Di as humanizeString,
|
|
5429
|
+
Zi as loadAllConfigs,
|
|
5430
|
+
Ki as loadConfig,
|
|
5431
|
+
_i as lookupAddresses,
|
|
5432
|
+
Ys as lookupUsername,
|
|
5433
|
+
Li as lookupUsernames,
|
|
5434
|
+
Xi as normalizeCalls,
|
|
5435
|
+
In as parseChainId,
|
|
5436
|
+
Gi as parsePolicies,
|
|
5437
|
+
Rt as sanitizeImageSrc,
|
|
5438
|
+
$n as toArray,
|
|
5439
|
+
Yi as toSessionPolicies,
|
|
5440
|
+
Ji as toWasmPolicies,
|
|
5441
|
+
Ei as toast
|
|
5404
5442
|
};
|
|
5405
5443
|
//# sourceMappingURL=index.js.map
|