@cartridge/controller 0.9.2 → 0.9.3
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 +19 -19
- package/.turbo/turbo-build.log +16 -16
- package/dist/index.js +293 -266
- 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.d.cts +3 -1
- package/dist/node/index.d.ts +3 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/{provider-C1UeMjUr.js → provider-D7ialTEP.js} +2 -2
- package/dist/provider-D7ialTEP.js.map +1 -0
- package/dist/session.js +3 -3
- package/dist/session.js.map +1 -1
- package/dist/stats.html +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/wallets/bridge.d.ts +2 -0
- package/dist/wallets/types.d.ts +2 -1
- package/package.json +3 -3
- package/src/controller.ts +22 -7
- package/src/types.ts +5 -0
- package/src/wallets/bridge.ts +33 -11
- package/src/wallets/types.ts +8 -1
- package/dist/provider-C1UeMjUr.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { WalletAccount as
|
|
2
|
-
import { R, t as
|
|
3
|
-
import { F as
|
|
4
|
-
import { connect as
|
|
5
|
-
import { InjectedConnector as
|
|
6
|
-
import { MetaMaskSDK as
|
|
7
|
-
import { Transaction as
|
|
8
|
-
class
|
|
1
|
+
import { WalletAccount as we, constants as z, shortString as H, num as _e } from "starknet";
|
|
2
|
+
import { R as S, t as ke, K as Ae, B as Ie, v as ve, N as p, p as Ee, A as xe } from "./provider-D7ialTEP.js";
|
|
3
|
+
import { F as ar, h as ir, n as cr, a as lr, b as dr } from "./provider-D7ialTEP.js";
|
|
4
|
+
import { connect as Ce } from "starknetkit";
|
|
5
|
+
import { InjectedConnector as Se } from "starknetkit/injected";
|
|
6
|
+
import { MetaMaskSDK as Re } from "@metamask/sdk";
|
|
7
|
+
import { Transaction as Pe } from "@solana/web3.js";
|
|
8
|
+
class K extends we {
|
|
9
9
|
keychain;
|
|
10
10
|
modal;
|
|
11
11
|
options;
|
|
@@ -25,7 +25,7 @@ class H extends ge {
|
|
|
25
25
|
* @returns response from addTransaction
|
|
26
26
|
*/
|
|
27
27
|
async execute(e) {
|
|
28
|
-
return e =
|
|
28
|
+
return e = ke(e), new Promise(async (t, n) => {
|
|
29
29
|
const s = await this.keychain.execute(
|
|
30
30
|
e,
|
|
31
31
|
void 0,
|
|
@@ -33,11 +33,11 @@ class H extends ge {
|
|
|
33
33
|
!1,
|
|
34
34
|
this.options?.feeSource
|
|
35
35
|
);
|
|
36
|
-
if (s.code ===
|
|
36
|
+
if (s.code === S.SUCCESS) {
|
|
37
37
|
t(s);
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
if (this.options?.propagateSessionErrors && s.code !==
|
|
40
|
+
if (this.options?.propagateSessionErrors && s.code !== S.USER_INTERACTION_REQUIRED) {
|
|
41
41
|
n(s.error);
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
@@ -49,7 +49,7 @@ class H extends ge {
|
|
|
49
49
|
!0,
|
|
50
50
|
s.error
|
|
51
51
|
);
|
|
52
|
-
if (o.code ===
|
|
52
|
+
if (o.code === S.SUCCESS) {
|
|
53
53
|
t(o), this.modal.close();
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
@@ -89,15 +89,15 @@ var N;
|
|
|
89
89
|
(function(r) {
|
|
90
90
|
r.ConnectionDestroyed = "ConnectionDestroyed", r.ConnectionTimeout = "ConnectionTimeout", r.NoIframeSrc = "NoIframeSrc";
|
|
91
91
|
})(N || (N = {}));
|
|
92
|
-
var
|
|
92
|
+
var O;
|
|
93
93
|
(function(r) {
|
|
94
94
|
r.DataCloneError = "DataCloneError";
|
|
95
|
-
})(
|
|
95
|
+
})(O || (O = {}));
|
|
96
96
|
var A;
|
|
97
97
|
(function(r) {
|
|
98
98
|
r.Message = "message";
|
|
99
99
|
})(A || (A = {}));
|
|
100
|
-
const
|
|
100
|
+
const De = (r, e) => {
|
|
101
101
|
const t = [];
|
|
102
102
|
let n = !1;
|
|
103
103
|
return {
|
|
@@ -110,27 +110,27 @@ const Re = (r, e) => {
|
|
|
110
110
|
n ? s() : t.push(s);
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
|
-
},
|
|
113
|
+
}, Ne = (r) => (...e) => {
|
|
114
114
|
r && console.log("[Penpal]", ...e);
|
|
115
|
-
},
|
|
115
|
+
}, Me = {
|
|
116
116
|
"http:": "80",
|
|
117
117
|
"https:": "443"
|
|
118
|
-
},
|
|
119
|
-
if (r &&
|
|
118
|
+
}, Be = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, Te = ["file:", "data:"], Qe = (r) => {
|
|
119
|
+
if (r && Te.find((i) => r.startsWith(i)))
|
|
120
120
|
return "null";
|
|
121
|
-
const e = document.location, t =
|
|
121
|
+
const e = document.location, t = Be.exec(r);
|
|
122
122
|
let n, s, o;
|
|
123
123
|
t ? (n = t[1] ? t[1] : e.protocol, s = t[2], o = t[4]) : (n = e.protocol, s = e.hostname, o = e.port);
|
|
124
|
-
const a = o && o !==
|
|
124
|
+
const a = o && o !== Me[n] ? `:${o}` : "";
|
|
125
125
|
return `${n}//${s}${a}`;
|
|
126
|
-
},
|
|
126
|
+
}, j = ({ name: r, message: e, stack: t }) => ({
|
|
127
127
|
name: r,
|
|
128
128
|
message: e,
|
|
129
129
|
stack: t
|
|
130
|
-
}),
|
|
130
|
+
}), Ue = (r) => {
|
|
131
131
|
const e = new Error();
|
|
132
132
|
return Object.keys(r).forEach((t) => e[t] = r[t]), e;
|
|
133
|
-
},
|
|
133
|
+
}, $e = (r, e, t) => {
|
|
134
134
|
const { localName: n, local: s, remote: o, originForSending: a, originForReceiving: i } = r;
|
|
135
135
|
let c = !1;
|
|
136
136
|
const l = (d) => {
|
|
@@ -153,16 +153,16 @@ const Re = (r, e) => {
|
|
|
153
153
|
resolution: y,
|
|
154
154
|
returnValue: I
|
|
155
155
|
};
|
|
156
|
-
y === v.Rejected && I instanceof Error && (w.returnValue =
|
|
156
|
+
y === v.Rejected && I instanceof Error && (w.returnValue = j(I), w.returnValueIsError = !0);
|
|
157
157
|
try {
|
|
158
158
|
o.postMessage(w, a);
|
|
159
159
|
} catch (f) {
|
|
160
|
-
if (f.name ===
|
|
160
|
+
if (f.name === O.DataCloneError) {
|
|
161
161
|
const E = {
|
|
162
162
|
penpal: b.Reply,
|
|
163
163
|
id: _,
|
|
164
164
|
resolution: v.Rejected,
|
|
165
|
-
returnValue:
|
|
165
|
+
returnValue: j(f),
|
|
166
166
|
returnValueIsError: !0
|
|
167
167
|
};
|
|
168
168
|
o.postMessage(E, a);
|
|
@@ -176,25 +176,25 @@ const Re = (r, e) => {
|
|
|
176
176
|
c = !0, s.removeEventListener(A.Message, l);
|
|
177
177
|
};
|
|
178
178
|
};
|
|
179
|
-
let
|
|
180
|
-
const
|
|
181
|
-
const t =
|
|
182
|
-
return t.push(r),
|
|
183
|
-
},
|
|
184
|
-
const n =
|
|
179
|
+
let ze = 0;
|
|
180
|
+
const Oe = () => ++ze, se = ".", oe = (r) => r ? r.split(se) : [], Le = (r) => r.join(se), Ye = (r, e) => {
|
|
181
|
+
const t = oe(e || "");
|
|
182
|
+
return t.push(r), Le(t);
|
|
183
|
+
}, Fe = (r, e, t) => {
|
|
184
|
+
const n = oe(e);
|
|
185
185
|
return n.reduce((s, o, a) => (typeof s[o] > "u" && (s[o] = {}), a === n.length - 1 && (s[o] = t), s[o]), r), r;
|
|
186
|
-
},
|
|
186
|
+
}, ae = (r, e) => {
|
|
187
187
|
const t = {};
|
|
188
188
|
return Object.keys(r).forEach((n) => {
|
|
189
|
-
const s = r[n], o =
|
|
190
|
-
typeof s == "object" && Object.assign(t,
|
|
189
|
+
const s = r[n], o = Ye(n, e);
|
|
190
|
+
typeof s == "object" && Object.assign(t, ae(s, o)), typeof s == "function" && (t[o] = s);
|
|
191
191
|
}), t;
|
|
192
|
-
},
|
|
192
|
+
}, We = (r) => {
|
|
193
193
|
const e = {};
|
|
194
194
|
for (const t in r)
|
|
195
|
-
|
|
195
|
+
Fe(e, t, r[t]);
|
|
196
196
|
return e;
|
|
197
|
-
},
|
|
197
|
+
}, He = (r, e, t, n, s) => {
|
|
198
198
|
const { localName: o, local: a, remote: i, originForSending: c, originForReceiving: l } = e;
|
|
199
199
|
let d = !1;
|
|
200
200
|
s(`${o}: Connecting call sender`);
|
|
@@ -211,17 +211,17 @@ const Ue = () => ++Qe, re = ".", ne = (r) => r ? r.split(re) : [], $e = (r) => r
|
|
|
211
211
|
throw y.code = N.ConnectionDestroyed, y;
|
|
212
212
|
}
|
|
213
213
|
return new Promise((y, I) => {
|
|
214
|
-
const w =
|
|
214
|
+
const w = Oe(), f = (x) => {
|
|
215
215
|
if (x.source !== i || x.data.penpal !== b.Reply || x.data.id !== w)
|
|
216
216
|
return;
|
|
217
217
|
if (l !== "*" && x.origin !== l) {
|
|
218
218
|
s(`${o} received message from origin ${x.origin} which did not match expected origin ${l}`);
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
const
|
|
221
|
+
const U = x.data;
|
|
222
222
|
s(`${o}: Received ${u}() reply`), a.removeEventListener(A.Message, f);
|
|
223
|
-
let
|
|
224
|
-
|
|
223
|
+
let $ = U.returnValue;
|
|
224
|
+
U.returnValueIsError && ($ = Ue($)), (U.resolution === v.Fulfilled ? y : I)($);
|
|
225
225
|
};
|
|
226
226
|
a.addEventListener(A.Message, f);
|
|
227
227
|
const E = {
|
|
@@ -233,10 +233,10 @@ const Ue = () => ++Qe, re = ".", ne = (r) => r ? r.split(re) : [], $e = (r) => r
|
|
|
233
233
|
i.postMessage(E, c);
|
|
234
234
|
});
|
|
235
235
|
}, g = t.reduce((u, _) => (u[_] = h(_), u), {});
|
|
236
|
-
return Object.assign(r,
|
|
236
|
+
return Object.assign(r, We(g)), () => {
|
|
237
237
|
d = !0;
|
|
238
238
|
};
|
|
239
|
-
},
|
|
239
|
+
}, Ke = (r, e, t, n, s) => {
|
|
240
240
|
const { destroy: o, onDestroy: a } = n;
|
|
241
241
|
let i, c;
|
|
242
242
|
const l = {};
|
|
@@ -253,13 +253,13 @@ const Ue = () => ++Qe, re = ".", ne = (r) => r ? r.split(re) : [], $e = (r) => r
|
|
|
253
253
|
originForSending: t,
|
|
254
254
|
originForReceiving: e
|
|
255
255
|
};
|
|
256
|
-
i && i(), i =
|
|
256
|
+
i && i(), i = $e(h, r, s), a(i), c && c.forEach((u) => {
|
|
257
257
|
delete l[u];
|
|
258
258
|
}), c = d.data.methodNames;
|
|
259
|
-
const g =
|
|
259
|
+
const g = He(l, h, c, o, s);
|
|
260
260
|
return a(g), l;
|
|
261
261
|
};
|
|
262
|
-
},
|
|
262
|
+
}, je = (r, e, t, n) => (s) => {
|
|
263
263
|
if (!s.source)
|
|
264
264
|
return;
|
|
265
265
|
if (t !== "*" && s.origin !== t) {
|
|
@@ -272,14 +272,14 @@ const Ue = () => ++Qe, re = ".", ne = (r) => r ? r.split(re) : [], $e = (r) => r
|
|
|
272
272
|
methodNames: Object.keys(e)
|
|
273
273
|
};
|
|
274
274
|
s.source.postMessage(o, n);
|
|
275
|
-
},
|
|
275
|
+
}, qe = 6e4, Xe = (r, e) => {
|
|
276
276
|
const { destroy: t, onDestroy: n } = e, s = setInterval(() => {
|
|
277
277
|
r.isConnected || (clearInterval(s), t());
|
|
278
|
-
},
|
|
278
|
+
}, qe);
|
|
279
279
|
n(() => {
|
|
280
280
|
clearInterval(s);
|
|
281
281
|
});
|
|
282
|
-
},
|
|
282
|
+
}, Ve = (r, e) => {
|
|
283
283
|
let t;
|
|
284
284
|
return r !== void 0 && (t = window.setTimeout(() => {
|
|
285
285
|
const n = new Error(`Connection timed out after ${r}ms`);
|
|
@@ -287,19 +287,19 @@ const Ue = () => ++Qe, re = ".", ne = (r) => r ? r.split(re) : [], $e = (r) => r
|
|
|
287
287
|
}, r)), () => {
|
|
288
288
|
clearTimeout(t);
|
|
289
289
|
};
|
|
290
|
-
},
|
|
290
|
+
}, Ge = (r) => {
|
|
291
291
|
if (!r.src && !r.srcdoc) {
|
|
292
292
|
const e = new Error("Iframe must have src or srcdoc property defined.");
|
|
293
293
|
throw e.code = N.NoIframeSrc, e;
|
|
294
294
|
}
|
|
295
|
-
},
|
|
295
|
+
}, Je = (r) => {
|
|
296
296
|
let { iframe: e, methods: t = {}, childOrigin: n, timeout: s, debug: o = !1 } = r;
|
|
297
|
-
const a =
|
|
298
|
-
n || (
|
|
299
|
-
const d = n === "null" ? "*" : n, h =
|
|
297
|
+
const a = Ne(o), i = De("Parent", a), { onDestroy: c, destroy: l } = i;
|
|
298
|
+
n || (Ge(e), n = Qe(e.src));
|
|
299
|
+
const d = n === "null" ? "*" : n, h = ae(t), g = je(a, h, n, d), u = Ke(h, n, d, i, a);
|
|
300
300
|
return {
|
|
301
301
|
promise: new Promise((k, y) => {
|
|
302
|
-
const I =
|
|
302
|
+
const I = Ve(s, l), w = (f) => {
|
|
303
303
|
if (!(f.source !== e.contentWindow || !f.data)) {
|
|
304
304
|
if (f.data.penpal === b.Syn) {
|
|
305
305
|
g(f);
|
|
@@ -312,7 +312,7 @@ const Ue = () => ++Qe, re = ".", ne = (r) => r ? r.split(re) : [], $e = (r) => r
|
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
};
|
|
315
|
-
window.addEventListener(A.Message, w), a("Parent: Awaiting handshake"),
|
|
315
|
+
window.addEventListener(A.Message, w), a("Parent: Awaiting handshake"), Xe(e, i), c((f) => {
|
|
316
316
|
window.removeEventListener(A.Message, w), f && y(f);
|
|
317
317
|
});
|
|
318
318
|
}),
|
|
@@ -321,7 +321,7 @@ const Ue = () => ++Qe, re = ".", ne = (r) => r ? r.split(re) : [], $e = (r) => r
|
|
|
321
321
|
}
|
|
322
322
|
};
|
|
323
323
|
};
|
|
324
|
-
class
|
|
324
|
+
class Ze {
|
|
325
325
|
url;
|
|
326
326
|
iframe;
|
|
327
327
|
container;
|
|
@@ -344,7 +344,7 @@ class Ge {
|
|
|
344
344
|
const c = document.createElement("div");
|
|
345
345
|
c.id = "controller", c.style.position = "fixed", c.style.height = "100%", c.style.width = "100%", c.style.top = "0", c.style.left = "0", c.style.zIndex = "10000", c.style.backgroundColor = "rgba(0,0,0,0.6)", c.style.display = "none", c.style.alignItems = "center", c.style.justifyContent = "center", c.style.transition = "opacity 0.2s ease", c.style.opacity = "0", c.style.pointerEvents = "auto", c.appendChild(i), c.addEventListener("click", (h) => {
|
|
346
346
|
h.target === c && (e === "controller-keychain" && this.child && this.child.reset?.().catch((g) => console.error("Error resetting context:", g)), this.close());
|
|
347
|
-
}), this.iframe = i, this.container = c,
|
|
347
|
+
}), this.iframe = i, this.container = c, Je({
|
|
348
348
|
iframe: this.iframe,
|
|
349
349
|
methods: {
|
|
350
350
|
close: (h) => () => this.close(),
|
|
@@ -395,8 +395,8 @@ class Ge {
|
|
|
395
395
|
return this.container?.style.display !== "none";
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
const
|
|
399
|
-
function
|
|
398
|
+
const et = "6.13.7";
|
|
399
|
+
function q(r, e, t) {
|
|
400
400
|
for (let n in e) {
|
|
401
401
|
let s = e[n];
|
|
402
402
|
Object.defineProperty(r, n, { enumerable: !0, value: s, writable: !1 });
|
|
@@ -433,7 +433,7 @@ function C(r) {
|
|
|
433
433
|
}
|
|
434
434
|
return "[ COULD NOT SERIALIZE ]";
|
|
435
435
|
}
|
|
436
|
-
function
|
|
436
|
+
function tt(r, e, t) {
|
|
437
437
|
let n = r;
|
|
438
438
|
{
|
|
439
439
|
const o = [];
|
|
@@ -447,7 +447,7 @@ function Je(r, e, t) {
|
|
|
447
447
|
o.push(a + "=" + C(i));
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
|
-
o.push(`code=${e}`), o.push(`version=${
|
|
450
|
+
o.push(`code=${e}`), o.push(`version=${et}`), o.length && (r += " (" + o.join(", ") + ")");
|
|
451
451
|
}
|
|
452
452
|
let s;
|
|
453
453
|
switch (e) {
|
|
@@ -461,14 +461,14 @@ function Je(r, e, t) {
|
|
|
461
461
|
default:
|
|
462
462
|
s = new Error(r);
|
|
463
463
|
}
|
|
464
|
-
return
|
|
464
|
+
return q(s, { code: e }), t && Object.assign(s, t), s.shortMessage == null && q(s, { shortMessage: n }), s;
|
|
465
465
|
}
|
|
466
|
-
function
|
|
466
|
+
function rt(r, e, t, n) {
|
|
467
467
|
if (!r)
|
|
468
|
-
throw
|
|
468
|
+
throw tt(e, t, n);
|
|
469
469
|
}
|
|
470
470
|
function D(r, e, t, n) {
|
|
471
|
-
|
|
471
|
+
rt(r, e, "INVALID_ARGUMENT", { argument: t, value: n });
|
|
472
472
|
}
|
|
473
473
|
["NFD", "NFC", "NFKD", "NFKC"].reduce((r, e) => {
|
|
474
474
|
try {
|
|
@@ -481,7 +481,7 @@ function D(r, e, t, n) {
|
|
|
481
481
|
}
|
|
482
482
|
return r;
|
|
483
483
|
}, []);
|
|
484
|
-
function
|
|
484
|
+
function nt(r, e, t) {
|
|
485
485
|
if (r instanceof Uint8Array)
|
|
486
486
|
return r;
|
|
487
487
|
if (typeof r == "string" && r.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
|
|
@@ -493,28 +493,32 @@ function et(r, e, t) {
|
|
|
493
493
|
}
|
|
494
494
|
D(!1, "invalid BytesLike value", e || "value", r);
|
|
495
495
|
}
|
|
496
|
-
function
|
|
497
|
-
return
|
|
496
|
+
function L(r, e) {
|
|
497
|
+
return nt(r, e);
|
|
498
498
|
}
|
|
499
|
-
const
|
|
500
|
-
function
|
|
501
|
-
const e =
|
|
499
|
+
const X = "0123456789abcdef";
|
|
500
|
+
function st(r) {
|
|
501
|
+
const e = L(r);
|
|
502
502
|
let t = "0x";
|
|
503
503
|
for (let n = 0; n < e.length; n++) {
|
|
504
504
|
const s = e[n];
|
|
505
|
-
t +=
|
|
505
|
+
t += X[(s & 240) >> 4] + X[s & 15];
|
|
506
506
|
}
|
|
507
507
|
return t;
|
|
508
508
|
}
|
|
509
|
-
|
|
509
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
510
|
+
function ot(r) {
|
|
511
|
+
return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
|
|
512
|
+
}
|
|
513
|
+
function V(r) {
|
|
510
514
|
if (!Number.isSafeInteger(r) || r < 0)
|
|
511
|
-
throw new Error(
|
|
515
|
+
throw new Error("positive integer expected, got " + r);
|
|
512
516
|
}
|
|
513
|
-
function
|
|
514
|
-
if (!(r
|
|
515
|
-
throw new Error("
|
|
517
|
+
function T(r, ...e) {
|
|
518
|
+
if (!ot(r))
|
|
519
|
+
throw new Error("Uint8Array expected");
|
|
516
520
|
if (e.length > 0 && !e.includes(r.length))
|
|
517
|
-
throw new Error(
|
|
521
|
+
throw new Error("Uint8Array expected of length " + e + ", got length=" + r.length);
|
|
518
522
|
}
|
|
519
523
|
function G(r, e = !0) {
|
|
520
524
|
if (r.destroyed)
|
|
@@ -522,70 +526,78 @@ function G(r, e = !0) {
|
|
|
522
526
|
if (e && r.finished)
|
|
523
527
|
throw new Error("Hash#digest() has already been called");
|
|
524
528
|
}
|
|
525
|
-
function
|
|
526
|
-
|
|
529
|
+
function at(r, e) {
|
|
530
|
+
T(r);
|
|
527
531
|
const t = e.outputLen;
|
|
528
532
|
if (r.length < t)
|
|
529
|
-
throw new Error(
|
|
533
|
+
throw new Error("digestInto() expects output buffer of length at least " + t);
|
|
530
534
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
535
|
+
function it(r) {
|
|
536
|
+
return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
|
|
537
|
+
}
|
|
538
|
+
function ie(...r) {
|
|
539
|
+
for (let e = 0; e < r.length; e++)
|
|
540
|
+
r[e].fill(0);
|
|
541
|
+
}
|
|
542
|
+
const ct = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
543
|
+
function lt(r) {
|
|
544
|
+
return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
|
|
545
|
+
}
|
|
546
|
+
function dt(r) {
|
|
547
|
+
for (let e = 0; e < r.length; e++)
|
|
548
|
+
r[e] = lt(r[e]);
|
|
549
|
+
return r;
|
|
550
|
+
}
|
|
551
|
+
const J = ct ? (r) => r : dt;
|
|
552
|
+
function ht(r) {
|
|
536
553
|
if (typeof r != "string")
|
|
537
|
-
throw new Error(
|
|
554
|
+
throw new Error("string expected");
|
|
538
555
|
return new Uint8Array(new TextEncoder().encode(r));
|
|
539
556
|
}
|
|
540
|
-
function
|
|
541
|
-
|
|
542
|
-
throw new Error(`expected Uint8Array, got ${typeof r}`);
|
|
543
|
-
return r;
|
|
557
|
+
function ce(r) {
|
|
558
|
+
return typeof r == "string" && (r = ht(r)), T(r), r;
|
|
544
559
|
}
|
|
545
|
-
class
|
|
546
|
-
// Safe version that clones internal state
|
|
547
|
-
clone() {
|
|
548
|
-
return this._cloneInto();
|
|
549
|
-
}
|
|
560
|
+
class ut {
|
|
550
561
|
}
|
|
551
|
-
function
|
|
552
|
-
const e = (n) => r().update(
|
|
562
|
+
function ft(r) {
|
|
563
|
+
const e = (n) => r().update(ce(n)).digest(), t = r();
|
|
553
564
|
return e.outputLen = t.outputLen, e.blockLen = t.blockLen, e.create = () => r(), e;
|
|
554
565
|
}
|
|
555
|
-
const B = /* @__PURE__ */ BigInt(2 ** 32 - 1),
|
|
556
|
-
function
|
|
557
|
-
return e ? { h: Number(r & B), l: Number(r >>
|
|
566
|
+
const B = /* @__PURE__ */ BigInt(2 ** 32 - 1), Z = /* @__PURE__ */ BigInt(32);
|
|
567
|
+
function pt(r, e = !1) {
|
|
568
|
+
return e ? { h: Number(r & B), l: Number(r >> Z & B) } : { h: Number(r >> Z & B) | 0, l: Number(r & B) | 0 };
|
|
558
569
|
}
|
|
559
|
-
function
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
570
|
+
function mt(r, e = !1) {
|
|
571
|
+
const t = r.length;
|
|
572
|
+
let n = new Uint32Array(t), s = new Uint32Array(t);
|
|
573
|
+
for (let o = 0; o < t; o++) {
|
|
574
|
+
const { h: a, l: i } = pt(r[o], e);
|
|
575
|
+
[n[o], s[o]] = [a, i];
|
|
576
|
+
}
|
|
577
|
+
return [n, s];
|
|
566
578
|
}
|
|
567
|
-
const
|
|
579
|
+
const gt = (r, e, t) => r << t | e >>> 32 - t, yt = (r, e, t) => e << t | r >>> 32 - t, bt = (r, e, t) => e << t - 32 | r >>> 64 - t, wt = (r, e, t) => r << t - 32 | e >>> 64 - t, _t = BigInt(0), P = BigInt(1), kt = BigInt(2), At = BigInt(7), It = BigInt(256), vt = BigInt(113), le = [], de = [], he = [];
|
|
568
580
|
for (let r = 0, e = P, t = 1, n = 0; r < 24; r++) {
|
|
569
|
-
[t, n] = [n, (2 * t + 3 * n) % 5],
|
|
570
|
-
let s =
|
|
581
|
+
[t, n] = [n, (2 * t + 3 * n) % 5], le.push(2 * (5 * n + t)), de.push((r + 1) * (r + 2) / 2 % 64);
|
|
582
|
+
let s = _t;
|
|
571
583
|
for (let o = 0; o < 7; o++)
|
|
572
|
-
e = (e << P ^ (e >>
|
|
573
|
-
|
|
584
|
+
e = (e << P ^ (e >> At) * vt) % It, e & kt && (s ^= P << (P << /* @__PURE__ */ BigInt(o)) - P);
|
|
585
|
+
he.push(s);
|
|
574
586
|
}
|
|
575
|
-
const
|
|
576
|
-
function
|
|
587
|
+
const ue = mt(he, !0), Et = ue[0], xt = ue[1], ee = (r, e, t) => t > 32 ? bt(r, e, t) : gt(r, e, t), te = (r, e, t) => t > 32 ? wt(r, e, t) : yt(r, e, t);
|
|
588
|
+
function Ct(r, e = 24) {
|
|
577
589
|
const t = new Uint32Array(10);
|
|
578
590
|
for (let n = 24 - e; n < 24; n++) {
|
|
579
591
|
for (let a = 0; a < 10; a++)
|
|
580
592
|
t[a] = r[a] ^ r[a + 10] ^ r[a + 20] ^ r[a + 30] ^ r[a + 40];
|
|
581
593
|
for (let a = 0; a < 10; a += 2) {
|
|
582
|
-
const i = (a + 8) % 10, c = (a + 2) % 10, l = t[c], d = t[c + 1], h =
|
|
594
|
+
const i = (a + 8) % 10, c = (a + 2) % 10, l = t[c], d = t[c + 1], h = ee(l, d, 1) ^ t[i], g = te(l, d, 1) ^ t[i + 1];
|
|
583
595
|
for (let u = 0; u < 50; u += 10)
|
|
584
596
|
r[a + u] ^= h, r[a + u + 1] ^= g;
|
|
585
597
|
}
|
|
586
598
|
let s = r[2], o = r[3];
|
|
587
599
|
for (let a = 0; a < 24; a++) {
|
|
588
|
-
const i =
|
|
600
|
+
const i = de[a], c = ee(s, o, i), l = te(s, o, i), d = le[a];
|
|
589
601
|
s = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
|
|
590
602
|
}
|
|
591
603
|
for (let a = 0; a < 50; a += 10) {
|
|
@@ -594,25 +606,26 @@ function At(r, e = 24) {
|
|
|
594
606
|
for (let i = 0; i < 10; i++)
|
|
595
607
|
r[a + i] ^= ~t[(i + 2) % 10] & t[(i + 4) % 10];
|
|
596
608
|
}
|
|
597
|
-
r[0] ^=
|
|
609
|
+
r[0] ^= Et[n], r[1] ^= xt[n];
|
|
598
610
|
}
|
|
599
|
-
t
|
|
611
|
+
ie(t);
|
|
600
612
|
}
|
|
601
|
-
class
|
|
613
|
+
class Y extends ut {
|
|
602
614
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
603
615
|
constructor(e, t, n, s = !1, o = 24) {
|
|
604
|
-
if (super(), this.
|
|
605
|
-
throw new Error("
|
|
606
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
616
|
+
if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = t, this.outputLen = n, this.enableXOF = s, this.rounds = o, V(n), !(0 < e && e < 200))
|
|
617
|
+
throw new Error("only keccak-f1600 function is supported");
|
|
618
|
+
this.state = new Uint8Array(200), this.state32 = it(this.state);
|
|
619
|
+
}
|
|
620
|
+
clone() {
|
|
621
|
+
return this._cloneInto();
|
|
607
622
|
}
|
|
608
623
|
keccak() {
|
|
609
|
-
|
|
624
|
+
J(this.state32), Ct(this.state32, this.rounds), J(this.state32), this.posOut = 0, this.pos = 0;
|
|
610
625
|
}
|
|
611
626
|
update(e) {
|
|
612
|
-
G(this);
|
|
613
|
-
const { blockLen: t, state: n } = this;
|
|
614
|
-
e = ae(e);
|
|
615
|
-
const s = e.length;
|
|
627
|
+
G(this), e = ce(e), T(e);
|
|
628
|
+
const { blockLen: t, state: n } = this, s = e.length;
|
|
616
629
|
for (let o = 0; o < s; ) {
|
|
617
630
|
const a = Math.min(t - this.pos, s - o);
|
|
618
631
|
for (let i = 0; i < a; i++)
|
|
@@ -629,7 +642,7 @@ class L extends it {
|
|
|
629
642
|
e[n] ^= t, (t & 128) !== 0 && n === s - 1 && this.keccak(), e[s - 1] ^= 128, this.keccak();
|
|
630
643
|
}
|
|
631
644
|
writeInto(e) {
|
|
632
|
-
G(this, !1),
|
|
645
|
+
G(this, !1), T(e), this.finish();
|
|
633
646
|
const t = this.state, { blockLen: n } = this;
|
|
634
647
|
for (let s = 0, o = e.length; s < o; ) {
|
|
635
648
|
this.posOut >= n && this.keccak();
|
|
@@ -644,10 +657,10 @@ class L extends it {
|
|
|
644
657
|
return this.writeInto(e);
|
|
645
658
|
}
|
|
646
659
|
xof(e) {
|
|
647
|
-
return
|
|
660
|
+
return V(e), this.xofInto(new Uint8Array(e));
|
|
648
661
|
}
|
|
649
662
|
digestInto(e) {
|
|
650
|
-
if (
|
|
663
|
+
if (at(e, this), this.finished)
|
|
651
664
|
throw new Error("digest() was already called");
|
|
652
665
|
return this.writeInto(e), this.destroy(), e;
|
|
653
666
|
}
|
|
@@ -655,55 +668,55 @@ class L extends it {
|
|
|
655
668
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
656
669
|
}
|
|
657
670
|
destroy() {
|
|
658
|
-
this.destroyed = !0, this.state
|
|
671
|
+
this.destroyed = !0, ie(this.state);
|
|
659
672
|
}
|
|
660
673
|
_cloneInto(e) {
|
|
661
674
|
const { blockLen: t, suffix: n, outputLen: s, rounds: o, enableXOF: a } = this;
|
|
662
|
-
return e || (e = new
|
|
675
|
+
return e || (e = new Y(t, n, s, a, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = n, e.outputLen = s, e.enableXOF = a, e.destroyed = this.destroyed, e;
|
|
663
676
|
}
|
|
664
677
|
}
|
|
665
|
-
const
|
|
666
|
-
let
|
|
667
|
-
const
|
|
668
|
-
return
|
|
678
|
+
const St = (r, e, t) => ft(() => new Y(e, r, t)), Rt = St(1, 136, 256 / 8);
|
|
679
|
+
let fe = !1;
|
|
680
|
+
const pe = function(r) {
|
|
681
|
+
return Rt(r);
|
|
669
682
|
};
|
|
670
|
-
let
|
|
683
|
+
let me = pe;
|
|
671
684
|
function M(r) {
|
|
672
|
-
const e =
|
|
673
|
-
return
|
|
685
|
+
const e = L(r, "data");
|
|
686
|
+
return st(me(e));
|
|
674
687
|
}
|
|
675
|
-
M._ =
|
|
688
|
+
M._ = pe;
|
|
676
689
|
M.lock = function() {
|
|
677
|
-
|
|
690
|
+
fe = !0;
|
|
678
691
|
};
|
|
679
692
|
M.register = function(r) {
|
|
680
|
-
if (
|
|
693
|
+
if (fe)
|
|
681
694
|
throw new TypeError("keccak256 is locked");
|
|
682
|
-
|
|
695
|
+
me = r;
|
|
683
696
|
};
|
|
684
697
|
Object.freeze(M);
|
|
685
|
-
const
|
|
686
|
-
function
|
|
698
|
+
const Pt = BigInt(0), Dt = BigInt(36);
|
|
699
|
+
function re(r) {
|
|
687
700
|
r = r.toLowerCase();
|
|
688
701
|
const e = r.substring(2).split(""), t = new Uint8Array(40);
|
|
689
702
|
for (let s = 0; s < 40; s++)
|
|
690
703
|
t[s] = e[s].charCodeAt(0);
|
|
691
|
-
const n =
|
|
704
|
+
const n = L(M(t));
|
|
692
705
|
for (let s = 0; s < 40; s += 2)
|
|
693
706
|
n[s >> 1] >> 4 >= 8 && (e[s] = e[s].toUpperCase()), (n[s >> 1] & 15) >= 8 && (e[s + 1] = e[s + 1].toUpperCase());
|
|
694
707
|
return "0x" + e.join("");
|
|
695
708
|
}
|
|
696
|
-
const
|
|
709
|
+
const F = {};
|
|
697
710
|
for (let r = 0; r < 10; r++)
|
|
698
|
-
|
|
711
|
+
F[String(r)] = String(r);
|
|
699
712
|
for (let r = 0; r < 26; r++)
|
|
700
|
-
|
|
701
|
-
const
|
|
702
|
-
function
|
|
713
|
+
F[String.fromCharCode(65 + r)] = String(10 + r);
|
|
714
|
+
const ne = 15;
|
|
715
|
+
function Nt(r) {
|
|
703
716
|
r = r.toUpperCase(), r = r.substring(4) + r.substring(0, 2) + "00";
|
|
704
|
-
let e = r.split("").map((n) =>
|
|
705
|
-
for (; e.length >=
|
|
706
|
-
let n = e.substring(0,
|
|
717
|
+
let e = r.split("").map((n) => F[n]).join("");
|
|
718
|
+
for (; e.length >= ne; ) {
|
|
719
|
+
let n = e.substring(0, ne);
|
|
707
720
|
e = parseInt(n, 10) % 97 + e.substring(n.length);
|
|
708
721
|
}
|
|
709
722
|
let t = String(98 - parseInt(e, 10) % 97);
|
|
@@ -711,7 +724,7 @@ function Ct(r) {
|
|
|
711
724
|
t = "0" + t;
|
|
712
725
|
return t;
|
|
713
726
|
}
|
|
714
|
-
const
|
|
727
|
+
const Mt = function() {
|
|
715
728
|
const r = {};
|
|
716
729
|
for (let e = 0; e < 36; e++) {
|
|
717
730
|
const t = "0123456789abcdefghijklmnopqrstuvwxyz"[e];
|
|
@@ -719,29 +732,29 @@ const Rt = function() {
|
|
|
719
732
|
}
|
|
720
733
|
return r;
|
|
721
734
|
}();
|
|
722
|
-
function
|
|
735
|
+
function Bt(r) {
|
|
723
736
|
r = r.toLowerCase();
|
|
724
|
-
let e =
|
|
737
|
+
let e = Pt;
|
|
725
738
|
for (let t = 0; t < r.length; t++)
|
|
726
|
-
e = e *
|
|
739
|
+
e = e * Dt + Mt[r[t]];
|
|
727
740
|
return e;
|
|
728
741
|
}
|
|
729
742
|
function m(r) {
|
|
730
743
|
if (D(typeof r == "string", "invalid address", "address", r), r.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
|
|
731
744
|
r.startsWith("0x") || (r = "0x" + r);
|
|
732
|
-
const e =
|
|
745
|
+
const e = re(r);
|
|
733
746
|
return D(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || e === r, "bad address checksum", "address", r), e;
|
|
734
747
|
}
|
|
735
748
|
if (r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
|
736
|
-
D(r.substring(2, 4) ===
|
|
737
|
-
let e =
|
|
749
|
+
D(r.substring(2, 4) === Nt(r), "bad icap checksum", "address", r);
|
|
750
|
+
let e = Bt(r.substring(4)).toString(16);
|
|
738
751
|
for (; e.length < 40; )
|
|
739
752
|
e = "0" + e;
|
|
740
|
-
return
|
|
753
|
+
return re("0x" + e);
|
|
741
754
|
}
|
|
742
755
|
D(!1, "invalid address", "address", r);
|
|
743
756
|
}
|
|
744
|
-
class
|
|
757
|
+
class Tt {
|
|
745
758
|
type = "argent";
|
|
746
759
|
platform = "starknet";
|
|
747
760
|
wallet = void 0;
|
|
@@ -767,8 +780,8 @@ class Pt {
|
|
|
767
780
|
try {
|
|
768
781
|
if (!this.isAvailable())
|
|
769
782
|
throw new Error("Argent is not available");
|
|
770
|
-
const { wallet: e, connectorData: t } = await
|
|
771
|
-
connectors: [new
|
|
783
|
+
const { wallet: e, connectorData: t } = await Ce({
|
|
784
|
+
connectors: [new Se({ options: { id: "argentX" } })]
|
|
772
785
|
});
|
|
773
786
|
if (!e)
|
|
774
787
|
throw new Error("No wallet found");
|
|
@@ -831,16 +844,16 @@ class Pt {
|
|
|
831
844
|
}
|
|
832
845
|
}
|
|
833
846
|
}
|
|
834
|
-
function
|
|
847
|
+
function Qt(r) {
|
|
835
848
|
if (typeof window > "u")
|
|
836
849
|
return;
|
|
837
850
|
const e = (t) => r(t.detail);
|
|
838
851
|
return window.addEventListener("eip6963:announceProvider", e), window.dispatchEvent(new CustomEvent("eip6963:requestProvider")), () => window.removeEventListener("eip6963:announceProvider", e);
|
|
839
852
|
}
|
|
840
|
-
function
|
|
853
|
+
function ge() {
|
|
841
854
|
const r = /* @__PURE__ */ new Set();
|
|
842
855
|
let e = [];
|
|
843
|
-
const t = () =>
|
|
856
|
+
const t = () => Qt((s) => {
|
|
844
857
|
e.some(({ info: o }) => o.uuid === s.info.uuid) || (e = [...e, s], r.forEach((o) => o(e, { added: [s] })));
|
|
845
858
|
});
|
|
846
859
|
let n = t();
|
|
@@ -868,15 +881,15 @@ function fe() {
|
|
|
868
881
|
}
|
|
869
882
|
};
|
|
870
883
|
}
|
|
871
|
-
class
|
|
884
|
+
class Ut {
|
|
872
885
|
type = "metamask";
|
|
873
886
|
platform = "ethereum";
|
|
874
887
|
MMSDK;
|
|
875
|
-
store =
|
|
888
|
+
store = ge();
|
|
876
889
|
account = void 0;
|
|
877
890
|
connectedAccounts = [];
|
|
878
891
|
constructor() {
|
|
879
|
-
this.MMSDK = new
|
|
892
|
+
this.MMSDK = new Re({
|
|
880
893
|
dappMetadata: {
|
|
881
894
|
name: "Cartridge Controller",
|
|
882
895
|
url: window.location.href
|
|
@@ -1041,7 +1054,7 @@ class Nt {
|
|
|
1041
1054
|
}
|
|
1042
1055
|
}
|
|
1043
1056
|
}
|
|
1044
|
-
class
|
|
1057
|
+
class $t {
|
|
1045
1058
|
type = "phantom";
|
|
1046
1059
|
platform = "solana";
|
|
1047
1060
|
account = void 0;
|
|
@@ -1109,7 +1122,7 @@ class Mt {
|
|
|
1109
1122
|
if (!this.isAvailable() || !this.account)
|
|
1110
1123
|
throw new Error("Phantom is not connected");
|
|
1111
1124
|
try {
|
|
1112
|
-
const t =
|
|
1125
|
+
const t = Pe.from(e), s = await this.getProvider().signAndSendTransaction(t);
|
|
1113
1126
|
return {
|
|
1114
1127
|
success: !0,
|
|
1115
1128
|
wallet: this.type,
|
|
@@ -1144,16 +1157,16 @@ class Mt {
|
|
|
1144
1157
|
}
|
|
1145
1158
|
}
|
|
1146
1159
|
}
|
|
1147
|
-
const
|
|
1148
|
-
class
|
|
1160
|
+
const zt = "io.rabby";
|
|
1161
|
+
class Ot {
|
|
1149
1162
|
type = "rabby";
|
|
1150
1163
|
platform = "ethereum";
|
|
1151
1164
|
account = void 0;
|
|
1152
|
-
store =
|
|
1165
|
+
store = ge();
|
|
1153
1166
|
provider;
|
|
1154
1167
|
connectedAccounts = [];
|
|
1155
1168
|
constructor() {
|
|
1156
|
-
this.provider = this.store.getProviders().find((e) => e.info.rdns ===
|
|
1169
|
+
this.provider = this.store.getProviders().find((e) => e.info.rdns === zt), this.provider?.provider.request({
|
|
1157
1170
|
method: "eth_accounts"
|
|
1158
1171
|
}).then((e) => {
|
|
1159
1172
|
this.connectedAccounts = e.map(m), e.length > 0 && (this.account = m(e?.[0]));
|
|
@@ -1311,18 +1324,18 @@ class Tt {
|
|
|
1311
1324
|
}
|
|
1312
1325
|
}
|
|
1313
1326
|
}
|
|
1314
|
-
class
|
|
1327
|
+
class Lt {
|
|
1315
1328
|
walletAdapters;
|
|
1316
1329
|
constructor() {
|
|
1317
1330
|
if (this.walletAdapters = /* @__PURE__ */ new Map(), typeof window > "u")
|
|
1318
1331
|
return;
|
|
1319
|
-
const e = new
|
|
1332
|
+
const e = new Ut();
|
|
1320
1333
|
e.isAvailable() && this.walletAdapters.set("metamask", e);
|
|
1321
|
-
const t = new
|
|
1334
|
+
const t = new $t();
|
|
1322
1335
|
t.isAvailable() && this.walletAdapters.set("phantom", t);
|
|
1323
|
-
const n = new
|
|
1336
|
+
const n = new Tt();
|
|
1324
1337
|
n.isAvailable() && this.walletAdapters.set("argent", n);
|
|
1325
|
-
const s = new
|
|
1338
|
+
const s = new Ot();
|
|
1326
1339
|
s.isAvailable() && this.walletAdapters.set("rabby", s), window.wallet_bridge = this;
|
|
1327
1340
|
}
|
|
1328
1341
|
getIFrameMethods() {
|
|
@@ -1332,7 +1345,8 @@ class Qt {
|
|
|
1332
1345
|
externalSignMessage: (e) => (t, n) => this.signMessage(t, n),
|
|
1333
1346
|
externalSignTypedData: (e) => (t, n) => this.signTypedData(t, n),
|
|
1334
1347
|
externalSendTransaction: (e) => (t, n) => this.sendTransaction(t, n),
|
|
1335
|
-
externalGetBalance: (e) => (t, n) => this.getBalance(t, n)
|
|
1348
|
+
externalGetBalance: (e) => (t, n) => this.getBalance(t, n),
|
|
1349
|
+
externalSwitchChain: (e) => (t, n) => this.switchChain(t, n)
|
|
1336
1350
|
};
|
|
1337
1351
|
}
|
|
1338
1352
|
async detectWallets() {
|
|
@@ -1381,16 +1395,16 @@ class Qt {
|
|
|
1381
1395
|
}
|
|
1382
1396
|
}
|
|
1383
1397
|
getConnectedWalletAdapter(e) {
|
|
1384
|
-
let t;
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
);
|
|
1398
|
+
let t, n;
|
|
1399
|
+
try {
|
|
1400
|
+
n = m(e);
|
|
1401
|
+
} catch {
|
|
1402
|
+
if (t = this.walletAdapters.get(e), !t)
|
|
1403
|
+
throw new Error(`Wallet ${e} is not connected or supported`);
|
|
1404
|
+
return t;
|
|
1405
|
+
}
|
|
1406
|
+
if (t = this.walletAdapters.values().find((s) => s.getConnectedAccounts().includes(n)), !t)
|
|
1407
|
+
throw new Error(`No wallet found with connected address ${e}`);
|
|
1394
1408
|
return t;
|
|
1395
1409
|
}
|
|
1396
1410
|
async signMessage(e, t) {
|
|
@@ -1453,8 +1467,15 @@ class Qt {
|
|
|
1453
1467
|
);
|
|
1454
1468
|
}
|
|
1455
1469
|
}
|
|
1470
|
+
async switchChain(e, t) {
|
|
1471
|
+
try {
|
|
1472
|
+
return await this.getConnectedWalletAdapter(e).switchChain(t);
|
|
1473
|
+
} catch (n) {
|
|
1474
|
+
return console.error(`Error switching chain for ${e} wallet:`, n), !1;
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1456
1477
|
}
|
|
1457
|
-
class
|
|
1478
|
+
class Yt extends Ze {
|
|
1458
1479
|
walletBridge;
|
|
1459
1480
|
constructor({
|
|
1460
1481
|
url: e,
|
|
@@ -1465,7 +1486,7 @@ class Ut extends Ge {
|
|
|
1465
1486
|
tokens: a,
|
|
1466
1487
|
...i
|
|
1467
1488
|
}) {
|
|
1468
|
-
const c = new URL(e ??
|
|
1489
|
+
const c = new URL(e ?? Ae), l = new Lt();
|
|
1469
1490
|
t && c.searchParams.set(
|
|
1470
1491
|
"policies",
|
|
1471
1492
|
encodeURIComponent(JSON.stringify(t))
|
|
@@ -1483,7 +1504,7 @@ class Ut extends Ge {
|
|
|
1483
1504
|
return this.walletBridge;
|
|
1484
1505
|
}
|
|
1485
1506
|
}
|
|
1486
|
-
class
|
|
1507
|
+
class Vt extends Ie {
|
|
1487
1508
|
keychain;
|
|
1488
1509
|
options;
|
|
1489
1510
|
iframes;
|
|
@@ -1497,15 +1518,15 @@ class Ht extends _e {
|
|
|
1497
1518
|
const n = [...[
|
|
1498
1519
|
{ rpcUrl: "https://api.cartridge.gg/x/starknet/sepolia" },
|
|
1499
1520
|
{ rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet" }
|
|
1500
|
-
], ...e.chains || []], s = e.defaultChainId ||
|
|
1521
|
+
], ...e.chains || []], s = e.defaultChainId || z.StarknetChainId.SN_MAIN;
|
|
1501
1522
|
this.selectedChain = s, this.chains = /* @__PURE__ */ new Map(), this.iframes = {
|
|
1502
|
-
keychain: new
|
|
1523
|
+
keychain: new Yt({
|
|
1503
1524
|
...e,
|
|
1504
1525
|
onClose: this.keychain?.reset,
|
|
1505
1526
|
onConnect: (o) => {
|
|
1506
1527
|
this.keychain = o;
|
|
1507
1528
|
},
|
|
1508
|
-
version:
|
|
1529
|
+
version: ve
|
|
1509
1530
|
})
|
|
1510
1531
|
}, this.options = { ...e, chains: n, defaultChainId: s }, this.initializeChains(n), typeof window < "u" && (window.starknet_controller = this);
|
|
1511
1532
|
}
|
|
@@ -1533,7 +1554,7 @@ class Ht extends _e {
|
|
|
1533
1554
|
}
|
|
1534
1555
|
const e = await this.keychain.probe(this.rpcUrl());
|
|
1535
1556
|
let t = e?.rpcUrl || this.rpcUrl();
|
|
1536
|
-
this.account = new
|
|
1557
|
+
this.account = new K(
|
|
1537
1558
|
this,
|
|
1538
1559
|
t,
|
|
1539
1560
|
e.address,
|
|
@@ -1565,9 +1586,9 @@ class Ht extends _e {
|
|
|
1565
1586
|
this.rpcUrl(),
|
|
1566
1587
|
this.options.signupOptions
|
|
1567
1588
|
);
|
|
1568
|
-
if (e.code !==
|
|
1589
|
+
if (e.code !== S.SUCCESS)
|
|
1569
1590
|
throw new Error(e.message);
|
|
1570
|
-
return e = e, this.account = new
|
|
1591
|
+
return e = e, this.account = new K(
|
|
1571
1592
|
this,
|
|
1572
1593
|
this.rpcUrl(),
|
|
1573
1594
|
e.address,
|
|
@@ -1612,8 +1633,10 @@ class Ht extends _e {
|
|
|
1612
1633
|
console.error("Account is not ready");
|
|
1613
1634
|
return;
|
|
1614
1635
|
}
|
|
1615
|
-
const t = await this.keychain.username();
|
|
1616
|
-
|
|
1636
|
+
const t = await this.keychain.username(), n = [];
|
|
1637
|
+
this.options.slot && n.push(`ps=${this.options.slot}`), await this.keychain.navigate(
|
|
1638
|
+
`/account/${t}/${e}?${n.join("&")}`
|
|
1639
|
+
), this.iframes.keychain.open();
|
|
1617
1640
|
}
|
|
1618
1641
|
async openProfileTo(e) {
|
|
1619
1642
|
if (!this.keychain || !this.iframes.keychain) {
|
|
@@ -1624,8 +1647,10 @@ class Ht extends _e {
|
|
|
1624
1647
|
console.error("Account is not ready");
|
|
1625
1648
|
return;
|
|
1626
1649
|
}
|
|
1627
|
-
const t = await this.keychain.username();
|
|
1628
|
-
|
|
1650
|
+
const t = await this.keychain.username(), n = [];
|
|
1651
|
+
this.options.slot && n.push(`ps=${this.options.slot}`), await this.keychain.navigate(
|
|
1652
|
+
`/account/${t}/${e}?${n.join("&")}`
|
|
1653
|
+
), this.iframes.keychain.open();
|
|
1629
1654
|
}
|
|
1630
1655
|
async openProfileAt(e) {
|
|
1631
1656
|
if (!this.keychain || !this.iframes.keychain) {
|
|
@@ -1652,10 +1677,10 @@ class Ht extends _e {
|
|
|
1652
1677
|
const e = this.chains.get(this.selectedChain);
|
|
1653
1678
|
if (!e) {
|
|
1654
1679
|
const t = Array.from(this.chains.keys()).map(
|
|
1655
|
-
(n) =>
|
|
1680
|
+
(n) => H.decodeShortString(n)
|
|
1656
1681
|
);
|
|
1657
1682
|
throw new Error(
|
|
1658
|
-
`Chain not found: ${
|
|
1683
|
+
`Chain not found: ${H.decodeShortString(this.selectedChain)}. Available chains: ${t.join(", ")}`
|
|
1659
1684
|
);
|
|
1660
1685
|
}
|
|
1661
1686
|
return e.rpcUrl;
|
|
@@ -1672,14 +1697,16 @@ class Ht extends _e {
|
|
|
1672
1697
|
console.error(new p().message);
|
|
1673
1698
|
return;
|
|
1674
1699
|
}
|
|
1675
|
-
this.
|
|
1700
|
+
this.keychain.navigate("/purchase/credits").then(() => {
|
|
1701
|
+
this.iframes.keychain.open();
|
|
1702
|
+
});
|
|
1676
1703
|
}
|
|
1677
1704
|
openStarterPack(e) {
|
|
1678
1705
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1679
1706
|
console.error(new p().message);
|
|
1680
1707
|
return;
|
|
1681
1708
|
}
|
|
1682
|
-
this.keychain.navigate(`/
|
|
1709
|
+
this.keychain.navigate(`/purchase/starterpack/${e}`).then(() => {
|
|
1683
1710
|
this.iframes.keychain.open();
|
|
1684
1711
|
});
|
|
1685
1712
|
}
|
|
@@ -1692,7 +1719,7 @@ class Ht extends _e {
|
|
|
1692
1719
|
t && this.switchStarknetChain(t), this.iframes.keychain.open();
|
|
1693
1720
|
const s = await this.keychain.execute(e, void 0, void 0, !0);
|
|
1694
1721
|
return this.iframes.keychain.close(), t && this.switchStarknetChain(n), {
|
|
1695
|
-
status: !(s && (s.code ===
|
|
1722
|
+
status: !(s && (s.code === S.NOT_CONNECTED || s.code === S.CANCELED)),
|
|
1696
1723
|
transactionHash: s?.transaction_hash
|
|
1697
1724
|
};
|
|
1698
1725
|
}
|
|
@@ -1702,7 +1729,7 @@ class Ht extends _e {
|
|
|
1702
1729
|
initializeChains(e) {
|
|
1703
1730
|
for (const t of e)
|
|
1704
1731
|
try {
|
|
1705
|
-
const n = new URL(t.rpcUrl), s =
|
|
1732
|
+
const n = new URL(t.rpcUrl), s = Ee(n), o = s === z.StarknetChainId.SN_MAIN, a = s === z.StarknetChainId.SN_SEPOLIA, i = n.hostname === "api.cartridge.gg", c = n.hostname === "localhost" || n.hostname === "127.0.0.1";
|
|
1706
1733
|
if ((o || a) && !(i || c))
|
|
1707
1734
|
throw new Error(
|
|
1708
1735
|
`Only Cartridge RPC providers are allowed for ${o ? "mainnet" : "sepolia"}. Please use: https://api.cartridge.gg/x/starknet/${o ? "mainnet" : "sepolia"}`
|
|
@@ -1730,11 +1757,11 @@ class Ht extends _e {
|
|
|
1730
1757
|
});
|
|
1731
1758
|
}
|
|
1732
1759
|
}
|
|
1733
|
-
const
|
|
1734
|
-
async function
|
|
1760
|
+
const R = /* @__PURE__ */ new Map();
|
|
1761
|
+
async function ye(r) {
|
|
1735
1762
|
if (!r.addresses?.length && !r.usernames?.length)
|
|
1736
1763
|
return { results: [] };
|
|
1737
|
-
const e = await fetch(`${
|
|
1764
|
+
const e = await fetch(`${xe}/lookup`, {
|
|
1738
1765
|
method: "POST",
|
|
1739
1766
|
headers: {
|
|
1740
1767
|
"Content-Type": "application/json"
|
|
@@ -1745,26 +1772,26 @@ async function pe(r) {
|
|
|
1745
1772
|
throw new Error(`HTTP error! status: ${e.status}`);
|
|
1746
1773
|
return e.json();
|
|
1747
1774
|
}
|
|
1748
|
-
async function
|
|
1749
|
-
const e = r.filter((t) => !
|
|
1750
|
-
return e.length > 0 && (await
|
|
1751
|
-
|
|
1775
|
+
async function Gt(r) {
|
|
1776
|
+
const e = r.filter((t) => !R.has(t));
|
|
1777
|
+
return e.length > 0 && (await ye({ usernames: e })).results.forEach((n) => {
|
|
1778
|
+
R.set(n.username, n.addresses[0]);
|
|
1752
1779
|
}), new Map(
|
|
1753
|
-
r.map((t) => [t,
|
|
1780
|
+
r.map((t) => [t, R.get(t)]).filter((t) => t[1] !== void 0)
|
|
1754
1781
|
);
|
|
1755
1782
|
}
|
|
1756
|
-
async function
|
|
1757
|
-
r = r.map(
|
|
1758
|
-
const e = r.filter((t) => !
|
|
1759
|
-
return e.length > 0 && (await
|
|
1783
|
+
async function Jt(r) {
|
|
1784
|
+
r = r.map(_e.toHex);
|
|
1785
|
+
const e = r.filter((t) => !R.has(t));
|
|
1786
|
+
return e.length > 0 && (await ye({
|
|
1760
1787
|
addresses: e
|
|
1761
1788
|
})).results.forEach((n) => {
|
|
1762
|
-
|
|
1789
|
+
R.set(n.addresses[0], n.username);
|
|
1763
1790
|
}), new Map(
|
|
1764
|
-
r.map((t) => [t,
|
|
1791
|
+
r.map((t) => [t, R.get(t)]).filter((t) => t[1] !== void 0)
|
|
1765
1792
|
);
|
|
1766
1793
|
}
|
|
1767
|
-
var
|
|
1794
|
+
var Ft = [
|
|
1768
1795
|
{
|
|
1769
1796
|
name: "Wrapped BTC",
|
|
1770
1797
|
symbol: "WBTC",
|
|
@@ -2328,28 +2355,28 @@ var $t = [
|
|
|
2328
2355
|
total_supply: null,
|
|
2329
2356
|
logo_url: "https://assets.underware.gg/pistols/fame.svg"
|
|
2330
2357
|
}
|
|
2331
|
-
],
|
|
2358
|
+
], be = {
|
|
2332
2359
|
theme: {
|
|
2333
2360
|
name: "Cartridge",
|
|
2334
2361
|
icon: "icon.svg"
|
|
2335
2362
|
}
|
|
2336
|
-
},
|
|
2337
|
-
async function
|
|
2363
|
+
}, Q = "https://static.cartridge.gg/presets";
|
|
2364
|
+
async function W() {
|
|
2338
2365
|
try {
|
|
2339
|
-
const r = await fetch(`${
|
|
2366
|
+
const r = await fetch(`${Q}/index.json`);
|
|
2340
2367
|
if (!r.ok)
|
|
2341
2368
|
throw new Error(`Failed to load configs index: ${r.statusText}`);
|
|
2342
2369
|
return await r.json();
|
|
2343
2370
|
} catch (r) {
|
|
2344
|
-
return console.error("Error loading configs index:", r), { configs: [], baseUrl:
|
|
2371
|
+
return console.error("Error loading configs index:", r), { configs: [], baseUrl: Q };
|
|
2345
2372
|
}
|
|
2346
2373
|
}
|
|
2347
|
-
async function
|
|
2348
|
-
return (await
|
|
2374
|
+
async function Zt() {
|
|
2375
|
+
return (await W()).configs;
|
|
2349
2376
|
}
|
|
2350
|
-
async function
|
|
2377
|
+
async function er(r) {
|
|
2351
2378
|
try {
|
|
2352
|
-
const n = `${(await
|
|
2379
|
+
const n = `${(await W()).baseUrl || Q}/${r}`, s = await fetch(`${n}/config.json`);
|
|
2353
2380
|
if (!s.ok)
|
|
2354
2381
|
throw new Error(
|
|
2355
2382
|
`Failed to load config ${r}: ${s.statusText}`
|
|
@@ -2379,8 +2406,8 @@ async function Xt(r) {
|
|
|
2379
2406
|
return console.error(`Error loading config ${r}:`, e), null;
|
|
2380
2407
|
}
|
|
2381
2408
|
}
|
|
2382
|
-
async function
|
|
2383
|
-
const r = await
|
|
2409
|
+
async function tr() {
|
|
2410
|
+
const r = await W(), e = r.configs, t = r.baseUrl || Q, n = {};
|
|
2384
2411
|
return await Promise.all(
|
|
2385
2412
|
e.map(async (s) => {
|
|
2386
2413
|
try {
|
|
@@ -2395,31 +2422,31 @@ async function Gt() {
|
|
|
2395
2422
|
})
|
|
2396
2423
|
), n;
|
|
2397
2424
|
}
|
|
2398
|
-
|
|
2399
|
-
var
|
|
2425
|
+
be.theme.icon = "https://static.cartridge.gg/presets/cartridge/icon.svg";
|
|
2426
|
+
var rr = Ft, nr = be.theme;
|
|
2400
2427
|
export {
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2428
|
+
Tt as ArgentWallet,
|
|
2429
|
+
ar as FeeSource,
|
|
2430
|
+
Ut as MetaMaskWallet,
|
|
2404
2431
|
p as NotReadyToConnect,
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2432
|
+
$t as PhantomWallet,
|
|
2433
|
+
Ot as RabbyWallet,
|
|
2434
|
+
S as ResponseCodes,
|
|
2435
|
+
Lt as WalletBridge,
|
|
2436
|
+
Vt as default,
|
|
2437
|
+
nr as defaultTheme,
|
|
2438
|
+
rr as erc20Metadata,
|
|
2439
|
+
Zt as getAvailableConfigs,
|
|
2440
|
+
W as getConfigsIndex,
|
|
2441
|
+
ir as humanizeString,
|
|
2442
|
+
tr as loadAllConfigs,
|
|
2443
|
+
er as loadConfig,
|
|
2444
|
+
Jt as lookupAddresses,
|
|
2445
|
+
Gt as lookupUsernames,
|
|
2446
|
+
cr as normalizeCalls,
|
|
2447
|
+
Ee as parseChainId,
|
|
2448
|
+
ke as toArray,
|
|
2449
|
+
lr as toSessionPolicies,
|
|
2450
|
+
dr as toWasmPolicies
|
|
2424
2451
|
};
|
|
2425
2452
|
//# sourceMappingURL=index.js.map
|