@cartridge/controller 0.9.3 → 0.10.0-alpha.0
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 +18 -18
- package/.turbo/turbo-build.log +18 -18
- package/dist/controller.d.ts +1 -0
- package/dist/index.js +852 -356
- 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 +4 -1
- package/dist/node/index.d.ts +4 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/{provider-D7ialTEP.js → provider-j8mBYXim.js} +2 -2
- package/dist/provider-j8mBYXim.js.map +1 -0
- package/dist/session.js +2 -2
- package/dist/stats.html +1 -1
- package/dist/types.d.ts +4 -2
- package/dist/wallets/argent/index.d.ts +4 -3
- package/dist/wallets/base/index.d.ts +20 -0
- package/dist/wallets/braavos/index.d.ts +18 -0
- package/dist/wallets/bridge.d.ts +3 -0
- package/dist/wallets/index.d.ts +2 -0
- package/dist/wallets/metamask/index.d.ts +3 -2
- package/dist/wallets/phantom/index.d.ts +1 -0
- package/dist/wallets/platform.d.ts +2 -0
- package/dist/wallets/rabby/index.d.ts +3 -2
- package/dist/wallets/types.d.ts +3 -2
- package/package.json +4 -5
- package/src/__tests__/setup.ts +5 -9
- package/src/controller.ts +27 -12
- package/src/types.ts +4 -1
- package/src/wallets/argent/index.ts +64 -19
- package/src/wallets/base/index.ts +306 -0
- package/src/wallets/braavos/index.ts +177 -0
- package/src/wallets/bridge.ts +36 -0
- package/src/wallets/index.ts +2 -0
- package/src/wallets/metamask/index.ts +85 -10
- package/src/wallets/phantom/index.ts +11 -0
- package/src/wallets/platform.ts +26 -0
- package/src/wallets/rabby/index.ts +89 -7
- package/src/wallets/types.ts +12 -2
- package/vite.config.js +11 -3
- package/dist/provider-D7ialTEP.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { WalletAccount as
|
|
2
|
-
import { R
|
|
3
|
-
import { F as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { Transaction as Pe } from "@solana/web3.js";
|
|
8
|
-
class K extends we {
|
|
1
|
+
import { WalletAccount as ve, constants as B, num as ae, shortString as K } from "starknet";
|
|
2
|
+
import { R, t as ke, K as Ae, B as Ee, N as m, p as Ie, v as xe, A as Ce } from "./provider-j8mBYXim.js";
|
|
3
|
+
import { F as ir, h as cr, n as lr, a as dr, b as hr } from "./provider-j8mBYXim.js";
|
|
4
|
+
import { MetaMaskSDK as Se } from "@metamask/sdk";
|
|
5
|
+
import { Transaction as Re } from "@solana/web3.js";
|
|
6
|
+
class j extends ve {
|
|
9
7
|
keychain;
|
|
10
8
|
modal;
|
|
11
9
|
options;
|
|
@@ -33,11 +31,11 @@ class K extends we {
|
|
|
33
31
|
!1,
|
|
34
32
|
this.options?.feeSource
|
|
35
33
|
);
|
|
36
|
-
if (s.code ===
|
|
34
|
+
if (s.code === R.SUCCESS) {
|
|
37
35
|
t(s);
|
|
38
36
|
return;
|
|
39
37
|
}
|
|
40
|
-
if (this.options?.propagateSessionErrors && s.code !==
|
|
38
|
+
if (this.options?.propagateSessionErrors && s.code !== R.USER_INTERACTION_REQUIRED) {
|
|
41
39
|
n(s.error);
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
@@ -49,7 +47,7 @@ class K extends we {
|
|
|
49
47
|
!0,
|
|
50
48
|
s.error
|
|
51
49
|
);
|
|
52
|
-
if (o.code ===
|
|
50
|
+
if (o.code === R.SUCCESS) {
|
|
53
51
|
t(o), this.modal.close();
|
|
54
52
|
return;
|
|
55
53
|
}
|
|
@@ -77,27 +75,27 @@ class K extends we {
|
|
|
77
75
|
});
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
|
-
var
|
|
78
|
+
var w;
|
|
81
79
|
(function(r) {
|
|
82
80
|
r.Call = "call", r.Reply = "reply", r.Syn = "syn", r.SynAck = "synAck", r.Ack = "ack";
|
|
83
|
-
})(
|
|
84
|
-
var
|
|
81
|
+
})(w || (w = {}));
|
|
82
|
+
var I;
|
|
85
83
|
(function(r) {
|
|
86
84
|
r.Fulfilled = "fulfilled", r.Rejected = "rejected";
|
|
87
|
-
})(
|
|
85
|
+
})(I || (I = {}));
|
|
88
86
|
var N;
|
|
89
87
|
(function(r) {
|
|
90
88
|
r.ConnectionDestroyed = "ConnectionDestroyed", r.ConnectionTimeout = "ConnectionTimeout", r.NoIframeSrc = "NoIframeSrc";
|
|
91
89
|
})(N || (N = {}));
|
|
92
|
-
var
|
|
90
|
+
var F;
|
|
93
91
|
(function(r) {
|
|
94
92
|
r.DataCloneError = "DataCloneError";
|
|
95
|
-
})(
|
|
93
|
+
})(F || (F = {}));
|
|
96
94
|
var A;
|
|
97
95
|
(function(r) {
|
|
98
96
|
r.Message = "message";
|
|
99
97
|
})(A || (A = {}));
|
|
100
|
-
const
|
|
98
|
+
const Pe = (r, e) => {
|
|
101
99
|
const t = [];
|
|
102
100
|
let n = !1;
|
|
103
101
|
return {
|
|
@@ -110,96 +108,96 @@ const De = (r, e) => {
|
|
|
110
108
|
n ? s() : t.push(s);
|
|
111
109
|
}
|
|
112
110
|
};
|
|
113
|
-
},
|
|
111
|
+
}, Me = (r) => (...e) => {
|
|
114
112
|
r && console.log("[Penpal]", ...e);
|
|
115
|
-
},
|
|
113
|
+
}, De = {
|
|
116
114
|
"http:": "80",
|
|
117
115
|
"https:": "443"
|
|
118
|
-
}, Be = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/,
|
|
119
|
-
if (r &&
|
|
116
|
+
}, Be = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, Ne = ["file:", "data:"], Te = (r) => {
|
|
117
|
+
if (r && Ne.find((i) => r.startsWith(i)))
|
|
120
118
|
return "null";
|
|
121
119
|
const e = document.location, t = Be.exec(r);
|
|
122
120
|
let n, s, o;
|
|
123
121
|
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 !==
|
|
122
|
+
const a = o && o !== De[n] ? `:${o}` : "";
|
|
125
123
|
return `${n}//${s}${a}`;
|
|
126
|
-
},
|
|
124
|
+
}, X = ({ name: r, message: e, stack: t }) => ({
|
|
127
125
|
name: r,
|
|
128
126
|
message: e,
|
|
129
127
|
stack: t
|
|
130
128
|
}), Ue = (r) => {
|
|
131
129
|
const e = new Error();
|
|
132
130
|
return Object.keys(r).forEach((t) => e[t] = r[t]), e;
|
|
133
|
-
},
|
|
131
|
+
}, Qe = (r, e, t) => {
|
|
134
132
|
const { localName: n, local: s, remote: o, originForSending: a, originForReceiving: i } = r;
|
|
135
133
|
let c = !1;
|
|
136
134
|
const l = (d) => {
|
|
137
|
-
if (d.source !== o || d.data.penpal !==
|
|
135
|
+
if (d.source !== o || d.data.penpal !== w.Call)
|
|
138
136
|
return;
|
|
139
137
|
if (i !== "*" && d.origin !== i) {
|
|
140
138
|
t(`${n} received message from origin ${d.origin} which did not match expected origin ${i}`);
|
|
141
139
|
return;
|
|
142
140
|
}
|
|
143
|
-
const
|
|
141
|
+
const u = d.data, { methodName: g, args: f, id: v } = u;
|
|
144
142
|
t(`${n}: Received ${g}() call`);
|
|
145
|
-
const k = (y) => (
|
|
143
|
+
const k = (y) => (E) => {
|
|
146
144
|
if (t(`${n}: Sending ${g}() reply`), c) {
|
|
147
145
|
t(`${n}: Unable to send ${g}() reply due to destroyed connection`);
|
|
148
146
|
return;
|
|
149
147
|
}
|
|
150
|
-
const
|
|
151
|
-
penpal:
|
|
152
|
-
id:
|
|
148
|
+
const b = {
|
|
149
|
+
penpal: w.Reply,
|
|
150
|
+
id: v,
|
|
153
151
|
resolution: y,
|
|
154
|
-
returnValue:
|
|
152
|
+
returnValue: E
|
|
155
153
|
};
|
|
156
|
-
y ===
|
|
154
|
+
y === I.Rejected && E instanceof Error && (b.returnValue = X(E), b.returnValueIsError = !0);
|
|
157
155
|
try {
|
|
158
|
-
o.postMessage(
|
|
159
|
-
} catch (
|
|
160
|
-
if (
|
|
161
|
-
const
|
|
162
|
-
penpal:
|
|
163
|
-
id:
|
|
164
|
-
resolution:
|
|
165
|
-
returnValue:
|
|
156
|
+
o.postMessage(b, a);
|
|
157
|
+
} catch (p) {
|
|
158
|
+
if (p.name === F.DataCloneError) {
|
|
159
|
+
const x = {
|
|
160
|
+
penpal: w.Reply,
|
|
161
|
+
id: v,
|
|
162
|
+
resolution: I.Rejected,
|
|
163
|
+
returnValue: X(p),
|
|
166
164
|
returnValueIsError: !0
|
|
167
165
|
};
|
|
168
|
-
o.postMessage(
|
|
166
|
+
o.postMessage(x, a);
|
|
169
167
|
}
|
|
170
|
-
throw
|
|
168
|
+
throw p;
|
|
171
169
|
}
|
|
172
170
|
};
|
|
173
|
-
new Promise((y) => y(e[g].call(e, d.origin).apply(e,
|
|
171
|
+
new Promise((y) => y(e[g].call(e, d.origin).apply(e, f))).then(k(I.Fulfilled), k(I.Rejected));
|
|
174
172
|
};
|
|
175
173
|
return s.addEventListener(A.Message, l), () => {
|
|
176
174
|
c = !0, s.removeEventListener(A.Message, l);
|
|
177
175
|
};
|
|
178
176
|
};
|
|
179
|
-
let
|
|
180
|
-
const
|
|
181
|
-
const t =
|
|
182
|
-
return t.push(r),
|
|
183
|
-
},
|
|
184
|
-
const n =
|
|
177
|
+
let $e = 0;
|
|
178
|
+
const ze = () => ++$e, ie = ".", ce = (r) => r ? r.split(ie) : [], Oe = (r) => r.join(ie), Fe = (r, e) => {
|
|
179
|
+
const t = ce(e || "");
|
|
180
|
+
return t.push(r), Oe(t);
|
|
181
|
+
}, Le = (r, e, t) => {
|
|
182
|
+
const n = ce(e);
|
|
185
183
|
return n.reduce((s, o, a) => (typeof s[o] > "u" && (s[o] = {}), a === n.length - 1 && (s[o] = t), s[o]), r), r;
|
|
186
|
-
},
|
|
184
|
+
}, le = (r, e) => {
|
|
187
185
|
const t = {};
|
|
188
186
|
return Object.keys(r).forEach((n) => {
|
|
189
|
-
const s = r[n], o =
|
|
190
|
-
typeof s == "object" && Object.assign(t,
|
|
187
|
+
const s = r[n], o = Fe(n, e);
|
|
188
|
+
typeof s == "object" && Object.assign(t, le(s, o)), typeof s == "function" && (t[o] = s);
|
|
191
189
|
}), t;
|
|
192
190
|
}, We = (r) => {
|
|
193
191
|
const e = {};
|
|
194
192
|
for (const t in r)
|
|
195
|
-
|
|
193
|
+
Le(e, t, r[t]);
|
|
196
194
|
return e;
|
|
197
|
-
},
|
|
195
|
+
}, Ye = (r, e, t, n, s) => {
|
|
198
196
|
const { localName: o, local: a, remote: i, originForSending: c, originForReceiving: l } = e;
|
|
199
197
|
let d = !1;
|
|
200
198
|
s(`${o}: Connecting call sender`);
|
|
201
|
-
const
|
|
202
|
-
s(`${o}: Sending ${
|
|
199
|
+
const u = (f) => (...v) => {
|
|
200
|
+
s(`${o}: Sending ${f}() call`);
|
|
203
201
|
let k;
|
|
204
202
|
try {
|
|
205
203
|
i.closed && (k = !0);
|
|
@@ -207,36 +205,36 @@ const Oe = () => ++ze, se = ".", oe = (r) => r ? r.split(se) : [], Le = (r) => r
|
|
|
207
205
|
k = !0;
|
|
208
206
|
}
|
|
209
207
|
if (k && n(), d) {
|
|
210
|
-
const y = new Error(`Unable to send ${
|
|
208
|
+
const y = new Error(`Unable to send ${f}() call due to destroyed connection`);
|
|
211
209
|
throw y.code = N.ConnectionDestroyed, y;
|
|
212
210
|
}
|
|
213
|
-
return new Promise((y,
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
211
|
+
return new Promise((y, E) => {
|
|
212
|
+
const b = ze(), p = (C) => {
|
|
213
|
+
if (C.source !== i || C.data.penpal !== w.Reply || C.data.id !== b)
|
|
216
214
|
return;
|
|
217
|
-
if (l !== "*" &&
|
|
218
|
-
s(`${o} received message from origin ${
|
|
215
|
+
if (l !== "*" && C.origin !== l) {
|
|
216
|
+
s(`${o} received message from origin ${C.origin} which did not match expected origin ${l}`);
|
|
219
217
|
return;
|
|
220
218
|
}
|
|
221
|
-
const
|
|
222
|
-
s(`${o}: Received ${
|
|
223
|
-
let
|
|
224
|
-
|
|
219
|
+
const z = C.data;
|
|
220
|
+
s(`${o}: Received ${f}() reply`), a.removeEventListener(A.Message, p);
|
|
221
|
+
let O = z.returnValue;
|
|
222
|
+
z.returnValueIsError && (O = Ue(O)), (z.resolution === I.Fulfilled ? y : E)(O);
|
|
225
223
|
};
|
|
226
|
-
a.addEventListener(A.Message,
|
|
227
|
-
const
|
|
228
|
-
penpal:
|
|
229
|
-
id:
|
|
230
|
-
methodName:
|
|
231
|
-
args:
|
|
224
|
+
a.addEventListener(A.Message, p);
|
|
225
|
+
const x = {
|
|
226
|
+
penpal: w.Call,
|
|
227
|
+
id: b,
|
|
228
|
+
methodName: f,
|
|
229
|
+
args: v
|
|
232
230
|
};
|
|
233
|
-
i.postMessage(
|
|
231
|
+
i.postMessage(x, c);
|
|
234
232
|
});
|
|
235
|
-
}, g = t.reduce((
|
|
233
|
+
}, g = t.reduce((f, v) => (f[v] = u(v), f), {});
|
|
236
234
|
return Object.assign(r, We(g)), () => {
|
|
237
235
|
d = !0;
|
|
238
236
|
};
|
|
239
|
-
},
|
|
237
|
+
}, He = (r, e, t, n, s) => {
|
|
240
238
|
const { destroy: o, onDestroy: a } = n;
|
|
241
239
|
let i, c;
|
|
242
240
|
const l = {};
|
|
@@ -246,20 +244,20 @@ const Oe = () => ++ze, se = ".", oe = (r) => r ? r.split(se) : [], Le = (r) => r
|
|
|
246
244
|
return;
|
|
247
245
|
}
|
|
248
246
|
s("Parent: Handshake - Received ACK");
|
|
249
|
-
const
|
|
247
|
+
const u = {
|
|
250
248
|
localName: "Parent",
|
|
251
249
|
local: window,
|
|
252
250
|
remote: d.source,
|
|
253
251
|
originForSending: t,
|
|
254
252
|
originForReceiving: e
|
|
255
253
|
};
|
|
256
|
-
i && i(), i =
|
|
257
|
-
delete l[
|
|
254
|
+
i && i(), i = Qe(u, r, s), a(i), c && c.forEach((f) => {
|
|
255
|
+
delete l[f];
|
|
258
256
|
}), c = d.data.methodNames;
|
|
259
|
-
const g =
|
|
257
|
+
const g = Ye(l, u, c, o, s);
|
|
260
258
|
return a(g), l;
|
|
261
259
|
};
|
|
262
|
-
},
|
|
260
|
+
}, qe = (r, e, t, n) => (s) => {
|
|
263
261
|
if (!s.source)
|
|
264
262
|
return;
|
|
265
263
|
if (t !== "*" && s.origin !== t) {
|
|
@@ -268,18 +266,18 @@ const Oe = () => ++ze, se = ".", oe = (r) => r ? r.split(se) : [], Le = (r) => r
|
|
|
268
266
|
}
|
|
269
267
|
r("Parent: Handshake - Received SYN, responding with SYN-ACK");
|
|
270
268
|
const o = {
|
|
271
|
-
penpal:
|
|
269
|
+
penpal: w.SynAck,
|
|
272
270
|
methodNames: Object.keys(e)
|
|
273
271
|
};
|
|
274
272
|
s.source.postMessage(o, n);
|
|
275
|
-
},
|
|
273
|
+
}, Ke = 6e4, je = (r, e) => {
|
|
276
274
|
const { destroy: t, onDestroy: n } = e, s = setInterval(() => {
|
|
277
275
|
r.isConnected || (clearInterval(s), t());
|
|
278
|
-
},
|
|
276
|
+
}, Ke);
|
|
279
277
|
n(() => {
|
|
280
278
|
clearInterval(s);
|
|
281
279
|
});
|
|
282
|
-
},
|
|
280
|
+
}, Xe = (r, e) => {
|
|
283
281
|
let t;
|
|
284
282
|
return r !== void 0 && (t = window.setTimeout(() => {
|
|
285
283
|
const n = new Error(`Connection timed out after ${r}ms`);
|
|
@@ -287,33 +285,33 @@ const Oe = () => ++ze, se = ".", oe = (r) => r ? r.split(se) : [], Le = (r) => r
|
|
|
287
285
|
}, r)), () => {
|
|
288
286
|
clearTimeout(t);
|
|
289
287
|
};
|
|
290
|
-
},
|
|
288
|
+
}, Ve = (r) => {
|
|
291
289
|
if (!r.src && !r.srcdoc) {
|
|
292
290
|
const e = new Error("Iframe must have src or srcdoc property defined.");
|
|
293
291
|
throw e.code = N.NoIframeSrc, e;
|
|
294
292
|
}
|
|
295
|
-
},
|
|
293
|
+
}, Ge = (r) => {
|
|
296
294
|
let { iframe: e, methods: t = {}, childOrigin: n, timeout: s, debug: o = !1 } = r;
|
|
297
|
-
const a =
|
|
298
|
-
n || (
|
|
299
|
-
const d = n === "null" ? "*" : n,
|
|
295
|
+
const a = Me(o), i = Pe("Parent", a), { onDestroy: c, destroy: l } = i;
|
|
296
|
+
n || (Ve(e), n = Te(e.src));
|
|
297
|
+
const d = n === "null" ? "*" : n, u = le(t), g = qe(a, u, n, d), f = He(u, n, d, i, a);
|
|
300
298
|
return {
|
|
301
299
|
promise: new Promise((k, y) => {
|
|
302
|
-
const
|
|
303
|
-
if (!(
|
|
304
|
-
if (
|
|
305
|
-
g(
|
|
300
|
+
const E = Xe(s, l), b = (p) => {
|
|
301
|
+
if (!(p.source !== e.contentWindow || !p.data)) {
|
|
302
|
+
if (p.data.penpal === w.Syn) {
|
|
303
|
+
g(p);
|
|
306
304
|
return;
|
|
307
305
|
}
|
|
308
|
-
if (
|
|
309
|
-
const
|
|
310
|
-
|
|
306
|
+
if (p.data.penpal === w.Ack) {
|
|
307
|
+
const x = f(p);
|
|
308
|
+
x && (E(), k(x));
|
|
311
309
|
return;
|
|
312
310
|
}
|
|
313
311
|
}
|
|
314
312
|
};
|
|
315
|
-
window.addEventListener(A.Message,
|
|
316
|
-
window.removeEventListener(A.Message,
|
|
313
|
+
window.addEventListener(A.Message, b), a("Parent: Awaiting handshake"), je(e, i), c((p) => {
|
|
314
|
+
window.removeEventListener(A.Message, b), p && y(p);
|
|
317
315
|
});
|
|
318
316
|
}),
|
|
319
317
|
destroy() {
|
|
@@ -321,7 +319,7 @@ const Oe = () => ++ze, se = ".", oe = (r) => r ? r.split(se) : [], Le = (r) => r
|
|
|
321
319
|
}
|
|
322
320
|
};
|
|
323
321
|
};
|
|
324
|
-
class
|
|
322
|
+
class Je {
|
|
325
323
|
url;
|
|
326
324
|
iframe;
|
|
327
325
|
container;
|
|
@@ -342,22 +340,22 @@ class Ze {
|
|
|
342
340
|
const i = document.createElement("iframe");
|
|
343
341
|
i.src = t.toString(), i.id = e, i.style.border = "none", i.sandbox.add("allow-forms"), i.sandbox.add("allow-popups"), i.sandbox.add("allow-popups-to-escape-sandbox"), i.sandbox.add("allow-scripts"), i.sandbox.add("allow-same-origin"), i.allow = "publickey-credentials-create *; publickey-credentials-get *; clipboard-write", document.hasStorageAccess && i.sandbox.add("allow-storage-access-by-user-activation");
|
|
344
342
|
const c = document.createElement("div");
|
|
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", (
|
|
346
|
-
|
|
347
|
-
}), this.iframe = i, this.container = c,
|
|
343
|
+
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", (u) => {
|
|
344
|
+
u.target === c && (e === "controller-keychain" && this.child && this.child.reset?.().catch((g) => console.error("Error resetting context:", g)), this.close());
|
|
345
|
+
}), this.iframe = i, this.container = c, Ge({
|
|
348
346
|
iframe: this.iframe,
|
|
349
347
|
methods: {
|
|
350
|
-
close: (
|
|
351
|
-
reload: (
|
|
348
|
+
close: (u) => () => this.close(),
|
|
349
|
+
reload: (u) => () => window.location.reload(),
|
|
352
350
|
...a
|
|
353
351
|
}
|
|
354
|
-
}).promise.then((
|
|
355
|
-
this.child =
|
|
352
|
+
}).promise.then((u) => {
|
|
353
|
+
this.child = u, o(u);
|
|
356
354
|
}), this.resize(), window.addEventListener("resize", () => this.resize());
|
|
357
355
|
const l = new MutationObserver(() => {
|
|
358
356
|
if (typeof document > "u") return;
|
|
359
|
-
const
|
|
360
|
-
document.body && e === "controller-keychain" && !
|
|
357
|
+
const u = document.getElementById("controller");
|
|
358
|
+
document.body && e === "controller-keychain" && !u && (document.body.appendChild(c), l.disconnect());
|
|
361
359
|
});
|
|
362
360
|
l.observe(document.documentElement, {
|
|
363
361
|
childList: !0,
|
|
@@ -395,18 +393,18 @@ class Ze {
|
|
|
395
393
|
return this.container?.style.display !== "none";
|
|
396
394
|
}
|
|
397
395
|
}
|
|
398
|
-
const
|
|
399
|
-
function
|
|
396
|
+
const Ze = "6.13.7";
|
|
397
|
+
function V(r, e, t) {
|
|
400
398
|
for (let n in e) {
|
|
401
399
|
let s = e[n];
|
|
402
400
|
Object.defineProperty(r, n, { enumerable: !0, value: s, writable: !1 });
|
|
403
401
|
}
|
|
404
402
|
}
|
|
405
|
-
function
|
|
403
|
+
function S(r) {
|
|
406
404
|
if (r == null)
|
|
407
405
|
return "null";
|
|
408
406
|
if (Array.isArray(r))
|
|
409
|
-
return "[ " + r.map(
|
|
407
|
+
return "[ " + r.map(S).join(", ") + " ]";
|
|
410
408
|
if (r instanceof Uint8Array) {
|
|
411
409
|
const e = "0123456789abcdef";
|
|
412
410
|
let t = "0x";
|
|
@@ -415,7 +413,7 @@ function C(r) {
|
|
|
415
413
|
return t;
|
|
416
414
|
}
|
|
417
415
|
if (typeof r == "object" && typeof r.toJSON == "function")
|
|
418
|
-
return
|
|
416
|
+
return S(r.toJSON());
|
|
419
417
|
switch (typeof r) {
|
|
420
418
|
case "boolean":
|
|
421
419
|
case "symbol":
|
|
@@ -428,26 +426,26 @@ function C(r) {
|
|
|
428
426
|
return JSON.stringify(r);
|
|
429
427
|
case "object": {
|
|
430
428
|
const e = Object.keys(r);
|
|
431
|
-
return e.sort(), "{ " + e.map((t) => `${
|
|
429
|
+
return e.sort(), "{ " + e.map((t) => `${S(t)}: ${S(r[t])}`).join(", ") + " }";
|
|
432
430
|
}
|
|
433
431
|
}
|
|
434
432
|
return "[ COULD NOT SERIALIZE ]";
|
|
435
433
|
}
|
|
436
|
-
function
|
|
434
|
+
function et(r, e, t) {
|
|
437
435
|
let n = r;
|
|
438
436
|
{
|
|
439
437
|
const o = [];
|
|
440
438
|
if (t) {
|
|
441
439
|
if ("message" in t || "code" in t || "name" in t)
|
|
442
|
-
throw new Error(`value will overwrite populated values: ${
|
|
440
|
+
throw new Error(`value will overwrite populated values: ${S(t)}`);
|
|
443
441
|
for (const a in t) {
|
|
444
442
|
if (a === "shortMessage")
|
|
445
443
|
continue;
|
|
446
444
|
const i = t[a];
|
|
447
|
-
o.push(a + "=" +
|
|
445
|
+
o.push(a + "=" + S(i));
|
|
448
446
|
}
|
|
449
447
|
}
|
|
450
|
-
o.push(`code=${e}`), o.push(`version=${
|
|
448
|
+
o.push(`code=${e}`), o.push(`version=${Ze}`), o.length && (r += " (" + o.join(", ") + ")");
|
|
451
449
|
}
|
|
452
450
|
let s;
|
|
453
451
|
switch (e) {
|
|
@@ -461,14 +459,14 @@ function tt(r, e, t) {
|
|
|
461
459
|
default:
|
|
462
460
|
s = new Error(r);
|
|
463
461
|
}
|
|
464
|
-
return
|
|
462
|
+
return V(s, { code: e }), t && Object.assign(s, t), s.shortMessage == null && V(s, { shortMessage: n }), s;
|
|
465
463
|
}
|
|
466
|
-
function
|
|
464
|
+
function tt(r, e, t, n) {
|
|
467
465
|
if (!r)
|
|
468
|
-
throw
|
|
466
|
+
throw et(e, t, n);
|
|
469
467
|
}
|
|
470
468
|
function D(r, e, t, n) {
|
|
471
|
-
|
|
469
|
+
tt(r, e, "INVALID_ARGUMENT", { argument: t, value: n });
|
|
472
470
|
}
|
|
473
471
|
["NFD", "NFC", "NFKD", "NFKC"].reduce((r, e) => {
|
|
474
472
|
try {
|
|
@@ -481,7 +479,7 @@ function D(r, e, t, n) {
|
|
|
481
479
|
}
|
|
482
480
|
return r;
|
|
483
481
|
}, []);
|
|
484
|
-
function
|
|
482
|
+
function rt(r, e, t) {
|
|
485
483
|
if (r instanceof Uint8Array)
|
|
486
484
|
return r;
|
|
487
485
|
if (typeof r == "string" && r.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
|
|
@@ -494,110 +492,110 @@ function nt(r, e, t) {
|
|
|
494
492
|
D(!1, "invalid BytesLike value", e || "value", r);
|
|
495
493
|
}
|
|
496
494
|
function L(r, e) {
|
|
497
|
-
return
|
|
495
|
+
return rt(r, e);
|
|
498
496
|
}
|
|
499
|
-
const
|
|
500
|
-
function
|
|
497
|
+
const G = "0123456789abcdef";
|
|
498
|
+
function nt(r) {
|
|
501
499
|
const e = L(r);
|
|
502
500
|
let t = "0x";
|
|
503
501
|
for (let n = 0; n < e.length; n++) {
|
|
504
502
|
const s = e[n];
|
|
505
|
-
t +=
|
|
503
|
+
t += G[(s & 240) >> 4] + G[s & 15];
|
|
506
504
|
}
|
|
507
505
|
return t;
|
|
508
506
|
}
|
|
509
507
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
510
|
-
function
|
|
508
|
+
function st(r) {
|
|
511
509
|
return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
|
|
512
510
|
}
|
|
513
|
-
function
|
|
511
|
+
function J(r) {
|
|
514
512
|
if (!Number.isSafeInteger(r) || r < 0)
|
|
515
513
|
throw new Error("positive integer expected, got " + r);
|
|
516
514
|
}
|
|
517
|
-
function
|
|
518
|
-
if (!
|
|
515
|
+
function Q(r, ...e) {
|
|
516
|
+
if (!st(r))
|
|
519
517
|
throw new Error("Uint8Array expected");
|
|
520
518
|
if (e.length > 0 && !e.includes(r.length))
|
|
521
519
|
throw new Error("Uint8Array expected of length " + e + ", got length=" + r.length);
|
|
522
520
|
}
|
|
523
|
-
function
|
|
521
|
+
function Z(r, e = !0) {
|
|
524
522
|
if (r.destroyed)
|
|
525
523
|
throw new Error("Hash instance has been destroyed");
|
|
526
524
|
if (e && r.finished)
|
|
527
525
|
throw new Error("Hash#digest() has already been called");
|
|
528
526
|
}
|
|
529
|
-
function
|
|
530
|
-
|
|
527
|
+
function ot(r, e) {
|
|
528
|
+
Q(r);
|
|
531
529
|
const t = e.outputLen;
|
|
532
530
|
if (r.length < t)
|
|
533
531
|
throw new Error("digestInto() expects output buffer of length at least " + t);
|
|
534
532
|
}
|
|
535
|
-
function
|
|
533
|
+
function at(r) {
|
|
536
534
|
return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
|
|
537
535
|
}
|
|
538
|
-
function
|
|
536
|
+
function de(...r) {
|
|
539
537
|
for (let e = 0; e < r.length; e++)
|
|
540
538
|
r[e].fill(0);
|
|
541
539
|
}
|
|
542
|
-
const
|
|
543
|
-
function
|
|
540
|
+
const it = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
541
|
+
function ct(r) {
|
|
544
542
|
return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
|
|
545
543
|
}
|
|
546
|
-
function
|
|
544
|
+
function lt(r) {
|
|
547
545
|
for (let e = 0; e < r.length; e++)
|
|
548
|
-
r[e] =
|
|
546
|
+
r[e] = ct(r[e]);
|
|
549
547
|
return r;
|
|
550
548
|
}
|
|
551
|
-
const
|
|
552
|
-
function
|
|
549
|
+
const ee = it ? (r) => r : lt;
|
|
550
|
+
function dt(r) {
|
|
553
551
|
if (typeof r != "string")
|
|
554
552
|
throw new Error("string expected");
|
|
555
553
|
return new Uint8Array(new TextEncoder().encode(r));
|
|
556
554
|
}
|
|
557
|
-
function
|
|
558
|
-
return typeof r == "string" && (r =
|
|
555
|
+
function he(r) {
|
|
556
|
+
return typeof r == "string" && (r = dt(r)), Q(r), r;
|
|
559
557
|
}
|
|
560
|
-
class
|
|
558
|
+
class ht {
|
|
561
559
|
}
|
|
562
|
-
function
|
|
563
|
-
const e = (n) => r().update(
|
|
560
|
+
function ut(r) {
|
|
561
|
+
const e = (n) => r().update(he(n)).digest(), t = r();
|
|
564
562
|
return e.outputLen = t.outputLen, e.blockLen = t.blockLen, e.create = () => r(), e;
|
|
565
563
|
}
|
|
566
|
-
const
|
|
567
|
-
function
|
|
568
|
-
return e ? { h: Number(r &
|
|
564
|
+
const U = /* @__PURE__ */ BigInt(2 ** 32 - 1), te = /* @__PURE__ */ BigInt(32);
|
|
565
|
+
function ft(r, e = !1) {
|
|
566
|
+
return e ? { h: Number(r & U), l: Number(r >> te & U) } : { h: Number(r >> te & U) | 0, l: Number(r & U) | 0 };
|
|
569
567
|
}
|
|
570
|
-
function
|
|
568
|
+
function pt(r, e = !1) {
|
|
571
569
|
const t = r.length;
|
|
572
570
|
let n = new Uint32Array(t), s = new Uint32Array(t);
|
|
573
571
|
for (let o = 0; o < t; o++) {
|
|
574
|
-
const { h: a, l: i } =
|
|
572
|
+
const { h: a, l: i } = ft(r[o], e);
|
|
575
573
|
[n[o], s[o]] = [a, i];
|
|
576
574
|
}
|
|
577
575
|
return [n, s];
|
|
578
576
|
}
|
|
579
|
-
const
|
|
580
|
-
for (let r = 0, e =
|
|
581
|
-
[t, n] = [n, (2 * t + 3 * n) % 5],
|
|
582
|
-
let s =
|
|
577
|
+
const mt = (r, e, t) => r << t | e >>> 32 - t, gt = (r, e, t) => e << t | r >>> 32 - t, yt = (r, e, t) => e << t - 32 | r >>> 64 - t, wt = (r, e, t) => r << t - 32 | e >>> 64 - t, bt = BigInt(0), M = BigInt(1), _t = BigInt(2), vt = BigInt(7), kt = BigInt(256), At = BigInt(113), ue = [], fe = [], pe = [];
|
|
578
|
+
for (let r = 0, e = M, t = 1, n = 0; r < 24; r++) {
|
|
579
|
+
[t, n] = [n, (2 * t + 3 * n) % 5], ue.push(2 * (5 * n + t)), fe.push((r + 1) * (r + 2) / 2 % 64);
|
|
580
|
+
let s = bt;
|
|
583
581
|
for (let o = 0; o < 7; o++)
|
|
584
|
-
e = (e <<
|
|
585
|
-
|
|
582
|
+
e = (e << M ^ (e >> vt) * At) % kt, e & _t && (s ^= M << (M << /* @__PURE__ */ BigInt(o)) - M);
|
|
583
|
+
pe.push(s);
|
|
586
584
|
}
|
|
587
|
-
const
|
|
588
|
-
function
|
|
585
|
+
const me = pt(pe, !0), Et = me[0], It = me[1], re = (r, e, t) => t > 32 ? yt(r, e, t) : mt(r, e, t), ne = (r, e, t) => t > 32 ? wt(r, e, t) : gt(r, e, t);
|
|
586
|
+
function xt(r, e = 24) {
|
|
589
587
|
const t = new Uint32Array(10);
|
|
590
588
|
for (let n = 24 - e; n < 24; n++) {
|
|
591
589
|
for (let a = 0; a < 10; a++)
|
|
592
590
|
t[a] = r[a] ^ r[a + 10] ^ r[a + 20] ^ r[a + 30] ^ r[a + 40];
|
|
593
591
|
for (let a = 0; a < 10; a += 2) {
|
|
594
|
-
const i = (a + 8) % 10, c = (a + 2) % 10, l = t[c], d = t[c + 1],
|
|
595
|
-
for (let
|
|
596
|
-
r[a +
|
|
592
|
+
const i = (a + 8) % 10, c = (a + 2) % 10, l = t[c], d = t[c + 1], u = re(l, d, 1) ^ t[i], g = ne(l, d, 1) ^ t[i + 1];
|
|
593
|
+
for (let f = 0; f < 50; f += 10)
|
|
594
|
+
r[a + f] ^= u, r[a + f + 1] ^= g;
|
|
597
595
|
}
|
|
598
596
|
let s = r[2], o = r[3];
|
|
599
597
|
for (let a = 0; a < 24; a++) {
|
|
600
|
-
const i =
|
|
598
|
+
const i = fe[a], c = re(s, o, i), l = ne(s, o, i), d = ue[a];
|
|
601
599
|
s = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
|
|
602
600
|
}
|
|
603
601
|
for (let a = 0; a < 50; a += 10) {
|
|
@@ -606,25 +604,25 @@ function Ct(r, e = 24) {
|
|
|
606
604
|
for (let i = 0; i < 10; i++)
|
|
607
605
|
r[a + i] ^= ~t[(i + 2) % 10] & t[(i + 4) % 10];
|
|
608
606
|
}
|
|
609
|
-
r[0] ^= Et[n], r[1] ^=
|
|
607
|
+
r[0] ^= Et[n], r[1] ^= It[n];
|
|
610
608
|
}
|
|
611
|
-
|
|
609
|
+
de(t);
|
|
612
610
|
}
|
|
613
|
-
class
|
|
611
|
+
class W extends ht {
|
|
614
612
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
615
613
|
constructor(e, t, n, s = !1, o = 24) {
|
|
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,
|
|
614
|
+
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, J(n), !(0 < e && e < 200))
|
|
617
615
|
throw new Error("only keccak-f1600 function is supported");
|
|
618
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
616
|
+
this.state = new Uint8Array(200), this.state32 = at(this.state);
|
|
619
617
|
}
|
|
620
618
|
clone() {
|
|
621
619
|
return this._cloneInto();
|
|
622
620
|
}
|
|
623
621
|
keccak() {
|
|
624
|
-
|
|
622
|
+
ee(this.state32), xt(this.state32, this.rounds), ee(this.state32), this.posOut = 0, this.pos = 0;
|
|
625
623
|
}
|
|
626
624
|
update(e) {
|
|
627
|
-
|
|
625
|
+
Z(this), e = he(e), Q(e);
|
|
628
626
|
const { blockLen: t, state: n } = this, s = e.length;
|
|
629
627
|
for (let o = 0; o < s; ) {
|
|
630
628
|
const a = Math.min(t - this.pos, s - o);
|
|
@@ -642,7 +640,7 @@ class Y extends ut {
|
|
|
642
640
|
e[n] ^= t, (t & 128) !== 0 && n === s - 1 && this.keccak(), e[s - 1] ^= 128, this.keccak();
|
|
643
641
|
}
|
|
644
642
|
writeInto(e) {
|
|
645
|
-
|
|
643
|
+
Z(this, !1), Q(e), this.finish();
|
|
646
644
|
const t = this.state, { blockLen: n } = this;
|
|
647
645
|
for (let s = 0, o = e.length; s < o; ) {
|
|
648
646
|
this.posOut >= n && this.keccak();
|
|
@@ -657,10 +655,10 @@ class Y extends ut {
|
|
|
657
655
|
return this.writeInto(e);
|
|
658
656
|
}
|
|
659
657
|
xof(e) {
|
|
660
|
-
return
|
|
658
|
+
return J(e), this.xofInto(new Uint8Array(e));
|
|
661
659
|
}
|
|
662
660
|
digestInto(e) {
|
|
663
|
-
if (
|
|
661
|
+
if (ot(e, this), this.finished)
|
|
664
662
|
throw new Error("digest() was already called");
|
|
665
663
|
return this.writeInto(e), this.destroy(), e;
|
|
666
664
|
}
|
|
@@ -668,55 +666,55 @@ class Y extends ut {
|
|
|
668
666
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
669
667
|
}
|
|
670
668
|
destroy() {
|
|
671
|
-
this.destroyed = !0,
|
|
669
|
+
this.destroyed = !0, de(this.state);
|
|
672
670
|
}
|
|
673
671
|
_cloneInto(e) {
|
|
674
672
|
const { blockLen: t, suffix: n, outputLen: s, rounds: o, enableXOF: a } = this;
|
|
675
|
-
return e || (e = new
|
|
673
|
+
return e || (e = new W(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;
|
|
676
674
|
}
|
|
677
675
|
}
|
|
678
|
-
const
|
|
679
|
-
let
|
|
680
|
-
const
|
|
681
|
-
return
|
|
676
|
+
const Ct = (r, e, t) => ut(() => new W(e, r, t)), St = Ct(1, 136, 256 / 8);
|
|
677
|
+
let ge = !1;
|
|
678
|
+
const ye = function(r) {
|
|
679
|
+
return St(r);
|
|
682
680
|
};
|
|
683
|
-
let
|
|
684
|
-
function
|
|
681
|
+
let we = ye;
|
|
682
|
+
function T(r) {
|
|
685
683
|
const e = L(r, "data");
|
|
686
|
-
return
|
|
684
|
+
return nt(we(e));
|
|
687
685
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
686
|
+
T._ = ye;
|
|
687
|
+
T.lock = function() {
|
|
688
|
+
ge = !0;
|
|
691
689
|
};
|
|
692
|
-
|
|
693
|
-
if (
|
|
690
|
+
T.register = function(r) {
|
|
691
|
+
if (ge)
|
|
694
692
|
throw new TypeError("keccak256 is locked");
|
|
695
|
-
|
|
693
|
+
we = r;
|
|
696
694
|
};
|
|
697
|
-
Object.freeze(
|
|
698
|
-
const
|
|
699
|
-
function
|
|
695
|
+
Object.freeze(T);
|
|
696
|
+
const Rt = BigInt(0), Pt = BigInt(36);
|
|
697
|
+
function se(r) {
|
|
700
698
|
r = r.toLowerCase();
|
|
701
699
|
const e = r.substring(2).split(""), t = new Uint8Array(40);
|
|
702
700
|
for (let s = 0; s < 40; s++)
|
|
703
701
|
t[s] = e[s].charCodeAt(0);
|
|
704
|
-
const n = L(
|
|
702
|
+
const n = L(T(t));
|
|
705
703
|
for (let s = 0; s < 40; s += 2)
|
|
706
704
|
n[s >> 1] >> 4 >= 8 && (e[s] = e[s].toUpperCase()), (n[s >> 1] & 15) >= 8 && (e[s + 1] = e[s + 1].toUpperCase());
|
|
707
705
|
return "0x" + e.join("");
|
|
708
706
|
}
|
|
709
|
-
const
|
|
707
|
+
const Y = {};
|
|
710
708
|
for (let r = 0; r < 10; r++)
|
|
711
|
-
|
|
709
|
+
Y[String(r)] = String(r);
|
|
712
710
|
for (let r = 0; r < 26; r++)
|
|
713
|
-
|
|
714
|
-
const
|
|
715
|
-
function
|
|
711
|
+
Y[String.fromCharCode(65 + r)] = String(10 + r);
|
|
712
|
+
const oe = 15;
|
|
713
|
+
function Mt(r) {
|
|
716
714
|
r = r.toUpperCase(), r = r.substring(4) + r.substring(0, 2) + "00";
|
|
717
|
-
let e = r.split("").map((n) =>
|
|
718
|
-
for (; e.length >=
|
|
719
|
-
let n = e.substring(0,
|
|
715
|
+
let e = r.split("").map((n) => Y[n]).join("");
|
|
716
|
+
for (; e.length >= oe; ) {
|
|
717
|
+
let n = e.substring(0, oe);
|
|
720
718
|
e = parseInt(n, 10) % 97 + e.substring(n.length);
|
|
721
719
|
}
|
|
722
720
|
let t = String(98 - parseInt(e, 10) % 97);
|
|
@@ -724,7 +722,7 @@ function Nt(r) {
|
|
|
724
722
|
t = "0" + t;
|
|
725
723
|
return t;
|
|
726
724
|
}
|
|
727
|
-
const
|
|
725
|
+
const Dt = function() {
|
|
728
726
|
const r = {};
|
|
729
727
|
for (let e = 0; e < 36; e++) {
|
|
730
728
|
const t = "0123456789abcdefghijklmnopqrstuvwxyz"[e];
|
|
@@ -734,27 +732,27 @@ const Mt = function() {
|
|
|
734
732
|
}();
|
|
735
733
|
function Bt(r) {
|
|
736
734
|
r = r.toLowerCase();
|
|
737
|
-
let e =
|
|
735
|
+
let e = Rt;
|
|
738
736
|
for (let t = 0; t < r.length; t++)
|
|
739
|
-
e = e *
|
|
737
|
+
e = e * Pt + Dt[r[t]];
|
|
740
738
|
return e;
|
|
741
739
|
}
|
|
742
|
-
function
|
|
740
|
+
function h(r) {
|
|
743
741
|
if (D(typeof r == "string", "invalid address", "address", r), r.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
|
|
744
742
|
r.startsWith("0x") || (r = "0x" + r);
|
|
745
|
-
const e =
|
|
743
|
+
const e = se(r);
|
|
746
744
|
return D(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || e === r, "bad address checksum", "address", r), e;
|
|
747
745
|
}
|
|
748
746
|
if (r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
|
749
|
-
D(r.substring(2, 4) ===
|
|
747
|
+
D(r.substring(2, 4) === Mt(r), "bad icap checksum", "address", r);
|
|
750
748
|
let e = Bt(r.substring(4)).toString(16);
|
|
751
749
|
for (; e.length < 40; )
|
|
752
750
|
e = "0" + e;
|
|
753
|
-
return
|
|
751
|
+
return se("0x" + e);
|
|
754
752
|
}
|
|
755
753
|
D(!1, "invalid address", "address", r);
|
|
756
754
|
}
|
|
757
|
-
class
|
|
755
|
+
class Nt {
|
|
758
756
|
type = "argent";
|
|
759
757
|
platform = "starknet";
|
|
760
758
|
wallet = void 0;
|
|
@@ -780,12 +778,16 @@ class Tt {
|
|
|
780
778
|
try {
|
|
781
779
|
if (!this.isAvailable())
|
|
782
780
|
throw new Error("Argent is not available");
|
|
783
|
-
const
|
|
784
|
-
connectors: [new Se({ options: { id: "argentX" } })]
|
|
785
|
-
});
|
|
781
|
+
const e = window.starknet_argentX;
|
|
786
782
|
if (!e)
|
|
787
783
|
throw new Error("No wallet found");
|
|
788
|
-
|
|
784
|
+
const t = await e.request({
|
|
785
|
+
type: "wallet_requestAccounts",
|
|
786
|
+
params: { silent_mode: !1 }
|
|
787
|
+
});
|
|
788
|
+
if (!t || t.length === 0)
|
|
789
|
+
throw new Error("No accounts found");
|
|
790
|
+
return this.wallet = e, this.account = t[0], this.connectedAccounts = t, { success: !0, wallet: this.type, account: this.account };
|
|
789
791
|
} catch (e) {
|
|
790
792
|
return console.error("Error connecting to Argent:", e), {
|
|
791
793
|
success: !1,
|
|
@@ -815,16 +817,37 @@ class Tt {
|
|
|
815
817
|
}
|
|
816
818
|
}
|
|
817
819
|
async sendTransaction(e) {
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
820
|
+
if (!this.wallet)
|
|
821
|
+
throw new Error("No wallet found");
|
|
822
|
+
try {
|
|
823
|
+
const t = await this.wallet.request({
|
|
824
|
+
type: "wallet_addInvokeTransaction",
|
|
825
|
+
params: {
|
|
826
|
+
calls: e
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
return {
|
|
830
|
+
success: !0,
|
|
831
|
+
wallet: this.type,
|
|
832
|
+
result: t
|
|
833
|
+
};
|
|
834
|
+
} catch (t) {
|
|
835
|
+
return console.error("Error sending transaction with Argent:", t), {
|
|
836
|
+
success: !1,
|
|
837
|
+
wallet: this.type,
|
|
838
|
+
error: t.message || "Unknown error"
|
|
839
|
+
};
|
|
840
|
+
}
|
|
823
841
|
}
|
|
824
842
|
async switchChain(e) {
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
843
|
+
if (!this.wallet)
|
|
844
|
+
throw new Error("No wallet found");
|
|
845
|
+
return await this.wallet.request({
|
|
846
|
+
type: "wallet_switchStarknetChain",
|
|
847
|
+
params: {
|
|
848
|
+
chainId: e
|
|
849
|
+
}
|
|
850
|
+
});
|
|
828
851
|
}
|
|
829
852
|
async getBalance(e) {
|
|
830
853
|
try {
|
|
@@ -843,17 +866,24 @@ class Tt {
|
|
|
843
866
|
};
|
|
844
867
|
}
|
|
845
868
|
}
|
|
869
|
+
async waitForTransaction(e, t) {
|
|
870
|
+
return {
|
|
871
|
+
success: !1,
|
|
872
|
+
wallet: this.type,
|
|
873
|
+
error: "waitForTransaction not supported for Argent wallet"
|
|
874
|
+
};
|
|
875
|
+
}
|
|
846
876
|
}
|
|
847
|
-
function
|
|
877
|
+
function Tt(r) {
|
|
848
878
|
if (typeof window > "u")
|
|
849
879
|
return;
|
|
850
880
|
const e = (t) => r(t.detail);
|
|
851
881
|
return window.addEventListener("eip6963:announceProvider", e), window.dispatchEvent(new CustomEvent("eip6963:requestProvider")), () => window.removeEventListener("eip6963:announceProvider", e);
|
|
852
882
|
}
|
|
853
|
-
function
|
|
883
|
+
function H() {
|
|
854
884
|
const r = /* @__PURE__ */ new Set();
|
|
855
885
|
let e = [];
|
|
856
|
-
const t = () =>
|
|
886
|
+
const t = () => Tt((s) => {
|
|
857
887
|
e.some(({ info: o }) => o.uuid === s.info.uuid) || (e = [...e, s], r.forEach((o) => o(e, { added: [s] })));
|
|
858
888
|
});
|
|
859
889
|
let n = t();
|
|
@@ -881,15 +911,233 @@ function ge() {
|
|
|
881
911
|
}
|
|
882
912
|
};
|
|
883
913
|
}
|
|
884
|
-
|
|
914
|
+
const Ut = {
|
|
915
|
+
"0x1": "ethereum",
|
|
916
|
+
// ethereum mainnet
|
|
917
|
+
"0xaa36a7": "ethereum",
|
|
918
|
+
// ethereum sepolia
|
|
919
|
+
"0x14a34": "base",
|
|
920
|
+
// base mainnet
|
|
921
|
+
"0x2105": "base",
|
|
922
|
+
// base sepolia
|
|
923
|
+
"0x66eee": "arbitrum",
|
|
924
|
+
// arbitrum mainnet
|
|
925
|
+
"0xa4b1": "arbitrum",
|
|
926
|
+
// arbitrum sepolia
|
|
927
|
+
"0xa": "optimism",
|
|
928
|
+
// op mainnet
|
|
929
|
+
"0xaa37dc": "optimism",
|
|
930
|
+
// op sepolia
|
|
931
|
+
[B.StarknetChainId.SN_MAIN]: "starknet",
|
|
932
|
+
[B.StarknetChainId.SN_SEPOLIA]: "starknet"
|
|
933
|
+
}, _ = (r) => {
|
|
934
|
+
const e = ae.toHex(r), t = Ut[e];
|
|
935
|
+
return t || console.warn(`Unknown chain ID: ${e}`), t;
|
|
936
|
+
}, Qt = "com.coinbase.wallet";
|
|
937
|
+
class $t {
|
|
938
|
+
type = "base";
|
|
939
|
+
platform;
|
|
940
|
+
account = void 0;
|
|
941
|
+
store = H();
|
|
942
|
+
provider;
|
|
943
|
+
connectedAccounts = [];
|
|
944
|
+
constructor() {
|
|
945
|
+
this.provider = this.store.getProviders().find((e) => e.info.rdns === Qt), this.provider?.provider.request({
|
|
946
|
+
method: "eth_accounts"
|
|
947
|
+
}).then((e) => {
|
|
948
|
+
this.connectedAccounts = e.map(h), e.length > 0 && (this.account = h(e?.[0]));
|
|
949
|
+
}), this.provider?.provider.request({
|
|
950
|
+
method: "eth_chainId"
|
|
951
|
+
}).then((e) => {
|
|
952
|
+
this.platform = _(e);
|
|
953
|
+
}), this.provider?.provider?.on("chainChanged", (e) => {
|
|
954
|
+
this.platform = _(e);
|
|
955
|
+
}), this.provider?.provider?.on("accountsChanged", (e) => {
|
|
956
|
+
e && (this.connectedAccounts = e.map((t) => h(t)), this.account = h(e?.[0]));
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
isAvailable() {
|
|
960
|
+
return typeof window < "u" && !!this.provider;
|
|
961
|
+
}
|
|
962
|
+
getInfo() {
|
|
963
|
+
const e = this.isAvailable();
|
|
964
|
+
return {
|
|
965
|
+
type: this.type,
|
|
966
|
+
available: e,
|
|
967
|
+
version: e ? window.ethereum?.version || "Unknown" : void 0,
|
|
968
|
+
chainId: e ? window.ethereum?.chainId : void 0,
|
|
969
|
+
name: "Base Wallet",
|
|
970
|
+
platform: this.platform,
|
|
971
|
+
connectedAccounts: this.connectedAccounts
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
getConnectedAccounts() {
|
|
975
|
+
return this.connectedAccounts;
|
|
976
|
+
}
|
|
977
|
+
async connect(e) {
|
|
978
|
+
if (e && this.connectedAccounts.includes(h(e)) && (this.account = h(e)), this.account)
|
|
979
|
+
return { success: !0, wallet: this.type, account: this.account };
|
|
980
|
+
try {
|
|
981
|
+
if (!this.isAvailable())
|
|
982
|
+
throw new Error("Base Wallet is not available");
|
|
983
|
+
const t = await this.provider?.provider.request({
|
|
984
|
+
method: "eth_requestAccounts"
|
|
985
|
+
});
|
|
986
|
+
if (t && t.length > 0)
|
|
987
|
+
return this.account = h(t[0]), this.connectedAccounts = t.map(h), { success: !0, wallet: this.type, account: this.account };
|
|
988
|
+
throw new Error("No accounts found");
|
|
989
|
+
} catch (t) {
|
|
990
|
+
return console.error("Error connecting to Base Wallet:", t), {
|
|
991
|
+
success: !1,
|
|
992
|
+
wallet: this.type,
|
|
993
|
+
error: t.message || "Unknown error"
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
async signMessage(e, t) {
|
|
998
|
+
try {
|
|
999
|
+
if (!this.isAvailable() || !this.account)
|
|
1000
|
+
throw new Error("Base Wallet is not connected");
|
|
1001
|
+
const n = await this.provider?.provider.request({
|
|
1002
|
+
method: "personal_sign",
|
|
1003
|
+
params: [e, t || this.account]
|
|
1004
|
+
});
|
|
1005
|
+
return { success: !0, wallet: this.type, result: n };
|
|
1006
|
+
} catch (n) {
|
|
1007
|
+
return console.error("Error signing message with Base Wallet:", n), {
|
|
1008
|
+
success: !1,
|
|
1009
|
+
wallet: this.type,
|
|
1010
|
+
error: n.message || "Unknown error"
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
async signTypedData(e) {
|
|
1015
|
+
try {
|
|
1016
|
+
if (!this.isAvailable() || !this.account)
|
|
1017
|
+
throw new Error("Base Wallet is not connected");
|
|
1018
|
+
const t = this.provider?.provider;
|
|
1019
|
+
if (!t)
|
|
1020
|
+
throw new Error("Base Wallet is not connected");
|
|
1021
|
+
const n = await t.request({
|
|
1022
|
+
method: "eth_signTypedData_v4",
|
|
1023
|
+
params: [this.account, JSON.stringify(e)]
|
|
1024
|
+
});
|
|
1025
|
+
return { success: !0, wallet: this.type, result: n };
|
|
1026
|
+
} catch (t) {
|
|
1027
|
+
return console.error("Error signing typed data with Base Wallet:", t), {
|
|
1028
|
+
success: !1,
|
|
1029
|
+
wallet: this.type,
|
|
1030
|
+
error: t.message || "Unknown error"
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
async sendTransaction(e) {
|
|
1035
|
+
try {
|
|
1036
|
+
if (!this.isAvailable() || !this.account)
|
|
1037
|
+
throw new Error("Base Wallet is not connected");
|
|
1038
|
+
const t = this.provider?.provider;
|
|
1039
|
+
if (!t)
|
|
1040
|
+
throw new Error("Base Wallet is not connected");
|
|
1041
|
+
const n = await t.request({
|
|
1042
|
+
method: "eth_sendTransaction",
|
|
1043
|
+
params: [e]
|
|
1044
|
+
});
|
|
1045
|
+
return { success: !0, wallet: this.type, result: n };
|
|
1046
|
+
} catch (t) {
|
|
1047
|
+
return console.error("Error sending transaction with Base Wallet:", t), {
|
|
1048
|
+
success: !1,
|
|
1049
|
+
wallet: this.type,
|
|
1050
|
+
error: t.message || "Unknown error"
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
async switchChain(e) {
|
|
1055
|
+
try {
|
|
1056
|
+
if (!this.isAvailable())
|
|
1057
|
+
throw new Error("Base Wallet is not available");
|
|
1058
|
+
const t = this.provider?.provider;
|
|
1059
|
+
if (!t)
|
|
1060
|
+
throw new Error("Base Wallet is not connected");
|
|
1061
|
+
try {
|
|
1062
|
+
return await t.request({
|
|
1063
|
+
method: "wallet_switchEthereumChain",
|
|
1064
|
+
params: [{ chainId: e }]
|
|
1065
|
+
}), this.platform = _(e), !0;
|
|
1066
|
+
} catch (n) {
|
|
1067
|
+
throw n.code === 4902 && console.warn("Chain not added to Base Wallet"), n;
|
|
1068
|
+
}
|
|
1069
|
+
} catch (t) {
|
|
1070
|
+
return console.error("Error switching chain for Base Wallet:", t), !1;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
async getBalance(e) {
|
|
1074
|
+
try {
|
|
1075
|
+
if (!this.isAvailable() || !this.account)
|
|
1076
|
+
throw new Error("Base Wallet is not connected");
|
|
1077
|
+
if (e)
|
|
1078
|
+
return {
|
|
1079
|
+
success: !1,
|
|
1080
|
+
wallet: this.type,
|
|
1081
|
+
error: "Not implemented for ERC20"
|
|
1082
|
+
};
|
|
1083
|
+
{
|
|
1084
|
+
const t = this.provider?.provider;
|
|
1085
|
+
if (!t)
|
|
1086
|
+
throw new Error("Base Wallet is not connected");
|
|
1087
|
+
const n = await t.request({
|
|
1088
|
+
method: "eth_getBalance",
|
|
1089
|
+
params: [this.account, "latest"]
|
|
1090
|
+
});
|
|
1091
|
+
return { success: !0, wallet: this.type, result: n };
|
|
1092
|
+
}
|
|
1093
|
+
} catch (t) {
|
|
1094
|
+
return console.error("Error getting balance from Base Wallet:", t), {
|
|
1095
|
+
success: !1,
|
|
1096
|
+
wallet: this.type,
|
|
1097
|
+
error: t.message || "Unknown error"
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
async waitForTransaction(e, t = 6e4) {
|
|
1102
|
+
try {
|
|
1103
|
+
if (!this.isAvailable())
|
|
1104
|
+
throw new Error("Base Wallet is not connected");
|
|
1105
|
+
const n = this.provider?.provider;
|
|
1106
|
+
if (!n)
|
|
1107
|
+
throw new Error("Base Wallet is not connected");
|
|
1108
|
+
const s = Date.now(), o = 1e3;
|
|
1109
|
+
for (; Date.now() - s < t; ) {
|
|
1110
|
+
const a = await n.request({
|
|
1111
|
+
method: "eth_getTransactionReceipt",
|
|
1112
|
+
params: [e]
|
|
1113
|
+
});
|
|
1114
|
+
if (a)
|
|
1115
|
+
return {
|
|
1116
|
+
success: !0,
|
|
1117
|
+
wallet: this.type,
|
|
1118
|
+
result: a
|
|
1119
|
+
};
|
|
1120
|
+
await new Promise((i) => setTimeout(i, o));
|
|
1121
|
+
}
|
|
1122
|
+
throw new Error("Transaction confirmation timed out");
|
|
1123
|
+
} catch (n) {
|
|
1124
|
+
return console.error("Error waiting for transaction with Base Wallet:", n), {
|
|
1125
|
+
success: !1,
|
|
1126
|
+
wallet: this.type,
|
|
1127
|
+
error: n.message || "Unknown error"
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
class zt {
|
|
885
1133
|
type = "metamask";
|
|
886
|
-
platform
|
|
1134
|
+
platform;
|
|
887
1135
|
MMSDK;
|
|
888
|
-
store =
|
|
1136
|
+
store = H();
|
|
889
1137
|
account = void 0;
|
|
890
1138
|
connectedAccounts = [];
|
|
891
1139
|
constructor() {
|
|
892
|
-
this.MMSDK = new
|
|
1140
|
+
this.MMSDK = new Se({
|
|
893
1141
|
dappMetadata: {
|
|
894
1142
|
name: "Cartridge Controller",
|
|
895
1143
|
url: window.location.href
|
|
@@ -897,11 +1145,15 @@ class Ut {
|
|
|
897
1145
|
}), this.isAvailable() && this.MMSDK.sdkInitPromise?.then(() => {
|
|
898
1146
|
this.MMSDK.getProvider()?.request({
|
|
899
1147
|
method: "eth_accounts"
|
|
900
|
-
}).then((
|
|
901
|
-
|
|
902
|
-
}), this.MMSDK.getProvider()?.on("accountsChanged", (
|
|
903
|
-
Array.isArray(
|
|
1148
|
+
}).then((t) => {
|
|
1149
|
+
t && t.length > 0 && (this.account = h(t[0]), this.connectedAccounts = t.map(h));
|
|
1150
|
+
}), this.MMSDK.getProvider()?.on("accountsChanged", (t) => {
|
|
1151
|
+
Array.isArray(t) && t.length > 0 && (this.account = h(t?.[0]), this.connectedAccounts = t.map(h));
|
|
1152
|
+
}), this.MMSDK.getProvider()?.on("chainChanged", (t) => {
|
|
1153
|
+
this.platform = _(t);
|
|
904
1154
|
});
|
|
1155
|
+
const e = this.MMSDK.getProvider()?.chainId;
|
|
1156
|
+
this.platform = e ? _(e) : void 0;
|
|
905
1157
|
});
|
|
906
1158
|
}
|
|
907
1159
|
isAvailable() {
|
|
@@ -927,8 +1179,8 @@ class Ut {
|
|
|
927
1179
|
throw new Error("MetaMask is not available");
|
|
928
1180
|
const e = await this.MMSDK.connect();
|
|
929
1181
|
if (e && e.length > 0)
|
|
930
|
-
return this.account =
|
|
931
|
-
(t) =>
|
|
1182
|
+
return this.account = h(e[0]), this.connectedAccounts = e.map(
|
|
1183
|
+
(t) => h(t)
|
|
932
1184
|
), { success: !0, wallet: this.type, account: this.account };
|
|
933
1185
|
throw new Error("No accounts found");
|
|
934
1186
|
} catch (e) {
|
|
@@ -1000,11 +1252,24 @@ class Ut {
|
|
|
1000
1252
|
}
|
|
1001
1253
|
}
|
|
1002
1254
|
async sendTransaction(e) {
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1255
|
+
try {
|
|
1256
|
+
if (!this.isAvailable() || !this.account)
|
|
1257
|
+
throw new Error("MetaMask is not connected");
|
|
1258
|
+
const t = this.MMSDK.getProvider();
|
|
1259
|
+
if (!t)
|
|
1260
|
+
throw new Error("MetaMask is not connected");
|
|
1261
|
+
const n = await t.request({
|
|
1262
|
+
method: "eth_sendTransaction",
|
|
1263
|
+
params: [e]
|
|
1264
|
+
});
|
|
1265
|
+
return { success: !0, wallet: this.type, result: n };
|
|
1266
|
+
} catch (t) {
|
|
1267
|
+
return console.error("Error sending transaction with MetaMask:", t), {
|
|
1268
|
+
success: !1,
|
|
1269
|
+
wallet: this.type,
|
|
1270
|
+
error: t.message || "Unknown error"
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1008
1273
|
}
|
|
1009
1274
|
async switchChain(e) {
|
|
1010
1275
|
try {
|
|
@@ -1017,7 +1282,7 @@ class Ut {
|
|
|
1017
1282
|
return await t.request({
|
|
1018
1283
|
method: "wallet_switchEthereumChain",
|
|
1019
1284
|
params: [{ chainId: e }]
|
|
1020
|
-
}), !0;
|
|
1285
|
+
}), this.platform = _(e), !0;
|
|
1021
1286
|
} catch (n) {
|
|
1022
1287
|
throw n.code === 4902 && console.warn("Chain not added to MetaMask"), n;
|
|
1023
1288
|
}
|
|
@@ -1053,8 +1318,38 @@ class Ut {
|
|
|
1053
1318
|
};
|
|
1054
1319
|
}
|
|
1055
1320
|
}
|
|
1321
|
+
async waitForTransaction(e, t = 6e4) {
|
|
1322
|
+
try {
|
|
1323
|
+
if (!this.isAvailable())
|
|
1324
|
+
throw new Error("MetaMask is not connected");
|
|
1325
|
+
const n = this.MMSDK.getProvider();
|
|
1326
|
+
if (!n)
|
|
1327
|
+
throw new Error("MetaMask is not connected");
|
|
1328
|
+
const s = Date.now(), o = 1e3;
|
|
1329
|
+
for (; Date.now() - s < t; ) {
|
|
1330
|
+
const a = await n.request({
|
|
1331
|
+
method: "eth_getTransactionReceipt",
|
|
1332
|
+
params: [e]
|
|
1333
|
+
});
|
|
1334
|
+
if (a)
|
|
1335
|
+
return {
|
|
1336
|
+
success: !0,
|
|
1337
|
+
wallet: this.type,
|
|
1338
|
+
result: a
|
|
1339
|
+
};
|
|
1340
|
+
await new Promise((i) => setTimeout(i, o));
|
|
1341
|
+
}
|
|
1342
|
+
throw new Error("Transaction confirmation timed out");
|
|
1343
|
+
} catch (n) {
|
|
1344
|
+
return console.error("Error waiting for transaction with MetaMask:", n), {
|
|
1345
|
+
success: !1,
|
|
1346
|
+
wallet: this.type,
|
|
1347
|
+
error: n.message || "Unknown error"
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1056
1351
|
}
|
|
1057
|
-
class
|
|
1352
|
+
class Ot {
|
|
1058
1353
|
type = "phantom";
|
|
1059
1354
|
platform = "solana";
|
|
1060
1355
|
account = void 0;
|
|
@@ -1122,7 +1417,7 @@ class $t {
|
|
|
1122
1417
|
if (!this.isAvailable() || !this.account)
|
|
1123
1418
|
throw new Error("Phantom is not connected");
|
|
1124
1419
|
try {
|
|
1125
|
-
const t =
|
|
1420
|
+
const t = Re.from(e), s = await this.getProvider().signAndSendTransaction(t);
|
|
1126
1421
|
return {
|
|
1127
1422
|
success: !0,
|
|
1128
1423
|
wallet: this.type,
|
|
@@ -1156,22 +1451,35 @@ class $t {
|
|
|
1156
1451
|
};
|
|
1157
1452
|
}
|
|
1158
1453
|
}
|
|
1454
|
+
async waitForTransaction(e, t) {
|
|
1455
|
+
return {
|
|
1456
|
+
success: !1,
|
|
1457
|
+
wallet: this.type,
|
|
1458
|
+
error: "waitForTransaction not supported for Phantom wallet"
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1159
1461
|
}
|
|
1160
|
-
const
|
|
1161
|
-
class
|
|
1462
|
+
const Ft = "io.rabby";
|
|
1463
|
+
class Lt {
|
|
1162
1464
|
type = "rabby";
|
|
1163
|
-
platform
|
|
1465
|
+
platform;
|
|
1164
1466
|
account = void 0;
|
|
1165
|
-
store =
|
|
1467
|
+
store = H();
|
|
1166
1468
|
provider;
|
|
1167
1469
|
connectedAccounts = [];
|
|
1168
1470
|
constructor() {
|
|
1169
|
-
this.provider = this.store.getProviders().find((e) => e.info.rdns ===
|
|
1471
|
+
this.provider = this.store.getProviders().find((e) => e.info.rdns === Ft), this.provider?.provider.request({
|
|
1170
1472
|
method: "eth_accounts"
|
|
1171
1473
|
}).then((e) => {
|
|
1172
|
-
this.connectedAccounts = e.map(
|
|
1474
|
+
this.connectedAccounts = e.map(h), e.length > 0 && (this.account = h(e?.[0]));
|
|
1475
|
+
}), this.provider?.provider.request({
|
|
1476
|
+
method: "eth_chainId"
|
|
1477
|
+
}).then((e) => {
|
|
1478
|
+
this.platform = _(e);
|
|
1479
|
+
}), this.provider?.provider?.on("chainChanged", (e) => {
|
|
1480
|
+
this.platform = _(e);
|
|
1173
1481
|
}), this.provider?.provider?.on("accountsChanged", (e) => {
|
|
1174
|
-
e && (this.connectedAccounts = e.map((t) =>
|
|
1482
|
+
e && (this.connectedAccounts = e.map((t) => h(t)), this.account = h(e?.[0]));
|
|
1175
1483
|
});
|
|
1176
1484
|
}
|
|
1177
1485
|
isAvailable() {
|
|
@@ -1190,7 +1498,7 @@ class Ot {
|
|
|
1190
1498
|
};
|
|
1191
1499
|
}
|
|
1192
1500
|
async connect(e) {
|
|
1193
|
-
if (e && this.connectedAccounts.includes(
|
|
1501
|
+
if (e && this.connectedAccounts.includes(h(e)) && (this.account = h(e)), this.account)
|
|
1194
1502
|
return { success: !0, wallet: this.type, account: this.account };
|
|
1195
1503
|
try {
|
|
1196
1504
|
if (!this.isAvailable())
|
|
@@ -1199,7 +1507,7 @@ class Ot {
|
|
|
1199
1507
|
method: "eth_requestAccounts"
|
|
1200
1508
|
});
|
|
1201
1509
|
if (t && t.length > 0)
|
|
1202
|
-
return this.account =
|
|
1510
|
+
return this.account = h(t[0]), this.connectedAccounts = t.map(h), { success: !0, wallet: this.type, account: this.account };
|
|
1203
1511
|
throw new Error("No accounts found");
|
|
1204
1512
|
} catch (t) {
|
|
1205
1513
|
return console.error("Error connecting to Rabby:", t), {
|
|
@@ -1270,11 +1578,24 @@ class Ot {
|
|
|
1270
1578
|
}
|
|
1271
1579
|
}
|
|
1272
1580
|
async sendTransaction(e) {
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1581
|
+
try {
|
|
1582
|
+
if (!this.isAvailable() || !this.account)
|
|
1583
|
+
throw new Error("Rabby is not connected");
|
|
1584
|
+
const t = this.provider?.provider;
|
|
1585
|
+
if (!t)
|
|
1586
|
+
throw new Error("Rabby is not connected");
|
|
1587
|
+
const n = await t.request({
|
|
1588
|
+
method: "eth_sendTransaction",
|
|
1589
|
+
params: [e]
|
|
1590
|
+
});
|
|
1591
|
+
return { success: !0, wallet: this.type, result: n };
|
|
1592
|
+
} catch (t) {
|
|
1593
|
+
return console.error("Error sending transaction with Rabby:", t), {
|
|
1594
|
+
success: !1,
|
|
1595
|
+
wallet: this.type,
|
|
1596
|
+
error: t.message || "Unknown error"
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1278
1599
|
}
|
|
1279
1600
|
async switchChain(e) {
|
|
1280
1601
|
try {
|
|
@@ -1287,7 +1608,7 @@ class Ot {
|
|
|
1287
1608
|
return await t.request({
|
|
1288
1609
|
method: "wallet_switchEthereumChain",
|
|
1289
1610
|
params: [{ chainId: e }]
|
|
1290
|
-
}), !0;
|
|
1611
|
+
}), this.platform = _(e), !0;
|
|
1291
1612
|
} catch (n) {
|
|
1292
1613
|
throw n.code === 4902 && console.warn("Chain not added to Rabby"), n;
|
|
1293
1614
|
}
|
|
@@ -1323,20 +1644,176 @@ class Ot {
|
|
|
1323
1644
|
};
|
|
1324
1645
|
}
|
|
1325
1646
|
}
|
|
1647
|
+
async waitForTransaction(e, t = 6e4) {
|
|
1648
|
+
try {
|
|
1649
|
+
if (!this.isAvailable())
|
|
1650
|
+
throw new Error("Rabby is not connected");
|
|
1651
|
+
const n = this.provider?.provider;
|
|
1652
|
+
if (!n)
|
|
1653
|
+
throw new Error("Rabby is not connected");
|
|
1654
|
+
const s = Date.now(), o = 1e3;
|
|
1655
|
+
for (; Date.now() - s < t; ) {
|
|
1656
|
+
const a = await n.request({
|
|
1657
|
+
method: "eth_getTransactionReceipt",
|
|
1658
|
+
params: [e]
|
|
1659
|
+
});
|
|
1660
|
+
if (a)
|
|
1661
|
+
return {
|
|
1662
|
+
success: !0,
|
|
1663
|
+
wallet: this.type,
|
|
1664
|
+
result: a
|
|
1665
|
+
};
|
|
1666
|
+
await new Promise((i) => setTimeout(i, o));
|
|
1667
|
+
}
|
|
1668
|
+
throw new Error("Transaction confirmation timed out");
|
|
1669
|
+
} catch (n) {
|
|
1670
|
+
return console.error("Error waiting for transaction with Rabby:", n), {
|
|
1671
|
+
success: !1,
|
|
1672
|
+
wallet: this.type,
|
|
1673
|
+
error: n.message || "Unknown error"
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1326
1677
|
}
|
|
1327
|
-
class
|
|
1678
|
+
class Wt {
|
|
1679
|
+
type = "braavos";
|
|
1680
|
+
platform = "starknet";
|
|
1681
|
+
wallet = void 0;
|
|
1682
|
+
account = void 0;
|
|
1683
|
+
connectedAccounts = [];
|
|
1684
|
+
isAvailable() {
|
|
1685
|
+
return typeof window < "u" && !!window.starknet_braavos;
|
|
1686
|
+
}
|
|
1687
|
+
getInfo() {
|
|
1688
|
+
const e = this.isAvailable();
|
|
1689
|
+
return {
|
|
1690
|
+
type: this.type,
|
|
1691
|
+
available: e,
|
|
1692
|
+
version: e ? window.starknet_braavos?.version || "Unknown" : void 0,
|
|
1693
|
+
chainId: e ? window.starknet_braavos?.chainId : void 0,
|
|
1694
|
+
name: "Braavos",
|
|
1695
|
+
platform: this.platform
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
async connect() {
|
|
1699
|
+
if (this.account)
|
|
1700
|
+
return { success: !0, wallet: this.type, account: this.account };
|
|
1701
|
+
try {
|
|
1702
|
+
if (!this.isAvailable())
|
|
1703
|
+
throw new Error("Braavos is not available");
|
|
1704
|
+
const e = window.starknet_braavos;
|
|
1705
|
+
if (!e)
|
|
1706
|
+
throw new Error("No wallet found");
|
|
1707
|
+
const t = await e.request({
|
|
1708
|
+
type: "wallet_requestAccounts",
|
|
1709
|
+
params: { silent_mode: !1 }
|
|
1710
|
+
});
|
|
1711
|
+
if (!t || t.length === 0)
|
|
1712
|
+
throw new Error("No accounts found");
|
|
1713
|
+
return this.wallet = e, this.account = t[0], this.connectedAccounts = t, { success: !0, wallet: this.type, account: this.account };
|
|
1714
|
+
} catch (e) {
|
|
1715
|
+
return console.error("Error connecting to Braavos:", e), {
|
|
1716
|
+
success: !1,
|
|
1717
|
+
wallet: this.type,
|
|
1718
|
+
error: e.message || "Unknown error"
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
getConnectedAccounts() {
|
|
1723
|
+
return this.connectedAccounts;
|
|
1724
|
+
}
|
|
1725
|
+
async signTypedData(e) {
|
|
1726
|
+
try {
|
|
1727
|
+
if (!this.isAvailable() || !this.wallet)
|
|
1728
|
+
throw new Error("Braavos is not connected");
|
|
1729
|
+
const t = await this.wallet.request({
|
|
1730
|
+
type: "wallet_signTypedData",
|
|
1731
|
+
params: e
|
|
1732
|
+
});
|
|
1733
|
+
return { success: !0, wallet: this.type, result: t };
|
|
1734
|
+
} catch (t) {
|
|
1735
|
+
return console.error("Error signing typed data with Braavos:", t), {
|
|
1736
|
+
success: !1,
|
|
1737
|
+
wallet: this.type,
|
|
1738
|
+
error: t.message || "Unknown error"
|
|
1739
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
async sendTransaction(e) {
|
|
1743
|
+
if (!this.wallet)
|
|
1744
|
+
throw new Error("No wallet found");
|
|
1745
|
+
try {
|
|
1746
|
+
const t = await this.wallet.request({
|
|
1747
|
+
type: "wallet_addInvokeTransaction",
|
|
1748
|
+
params: {
|
|
1749
|
+
calls: e
|
|
1750
|
+
}
|
|
1751
|
+
});
|
|
1752
|
+
return {
|
|
1753
|
+
success: !0,
|
|
1754
|
+
wallet: this.type,
|
|
1755
|
+
result: t
|
|
1756
|
+
};
|
|
1757
|
+
} catch (t) {
|
|
1758
|
+
return console.error("Error sending transaction with Braavos:", t), {
|
|
1759
|
+
success: !1,
|
|
1760
|
+
wallet: this.type,
|
|
1761
|
+
error: t.message || "Unknown error"
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
async switchChain(e) {
|
|
1766
|
+
if (!this.wallet)
|
|
1767
|
+
throw new Error("No wallet found");
|
|
1768
|
+
return await this.wallet.request({
|
|
1769
|
+
type: "wallet_switchStarknetChain",
|
|
1770
|
+
params: {
|
|
1771
|
+
chainId: e
|
|
1772
|
+
}
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
async getBalance(e) {
|
|
1776
|
+
try {
|
|
1777
|
+
if (!this.isAvailable() || !this.wallet)
|
|
1778
|
+
throw new Error("Braavos is not connected");
|
|
1779
|
+
return {
|
|
1780
|
+
success: !0,
|
|
1781
|
+
wallet: this.type,
|
|
1782
|
+
result: "Implement based on Braavos API"
|
|
1783
|
+
};
|
|
1784
|
+
} catch (t) {
|
|
1785
|
+
return console.error("Error getting balance from Braavos:", t), {
|
|
1786
|
+
success: !1,
|
|
1787
|
+
wallet: this.type,
|
|
1788
|
+
error: t.message || "Unknown error"
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
async waitForTransaction(e, t) {
|
|
1793
|
+
return {
|
|
1794
|
+
success: !1,
|
|
1795
|
+
wallet: this.type,
|
|
1796
|
+
error: "waitForTransaction not supported for Braavos wallet"
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
class Yt {
|
|
1328
1801
|
walletAdapters;
|
|
1329
1802
|
constructor() {
|
|
1330
1803
|
if (this.walletAdapters = /* @__PURE__ */ new Map(), typeof window > "u")
|
|
1331
1804
|
return;
|
|
1332
|
-
const e = new
|
|
1805
|
+
const e = new zt();
|
|
1333
1806
|
e.isAvailable() && this.walletAdapters.set("metamask", e);
|
|
1334
|
-
const t = new
|
|
1807
|
+
const t = new Ot();
|
|
1335
1808
|
t.isAvailable() && this.walletAdapters.set("phantom", t);
|
|
1336
|
-
const n = new
|
|
1809
|
+
const n = new Nt();
|
|
1337
1810
|
n.isAvailable() && this.walletAdapters.set("argent", n);
|
|
1338
|
-
const s = new
|
|
1339
|
-
s.isAvailable() && this.walletAdapters.set("
|
|
1811
|
+
const s = new Wt();
|
|
1812
|
+
s.isAvailable() && this.walletAdapters.set("braavos", s);
|
|
1813
|
+
const o = new Lt();
|
|
1814
|
+
o.isAvailable() && this.walletAdapters.set("rabby", o);
|
|
1815
|
+
const a = new $t();
|
|
1816
|
+
a.isAvailable() && this.walletAdapters.set("base", a), window.wallet_bridge = this;
|
|
1340
1817
|
}
|
|
1341
1818
|
getIFrameMethods() {
|
|
1342
1819
|
return {
|
|
@@ -1346,7 +1823,8 @@ class Lt {
|
|
|
1346
1823
|
externalSignTypedData: (e) => (t, n) => this.signTypedData(t, n),
|
|
1347
1824
|
externalSendTransaction: (e) => (t, n) => this.sendTransaction(t, n),
|
|
1348
1825
|
externalGetBalance: (e) => (t, n) => this.getBalance(t, n),
|
|
1349
|
-
externalSwitchChain: (e) => (t, n) => this.switchChain(t, n)
|
|
1826
|
+
externalSwitchChain: (e) => (t, n) => this.switchChain(t, n),
|
|
1827
|
+
externalWaitForTransaction: (e) => (t, n, s) => this.waitForTransaction(t, n, s)
|
|
1350
1828
|
};
|
|
1351
1829
|
}
|
|
1352
1830
|
async detectWallets() {
|
|
@@ -1397,7 +1875,7 @@ class Lt {
|
|
|
1397
1875
|
getConnectedWalletAdapter(e) {
|
|
1398
1876
|
let t, n;
|
|
1399
1877
|
try {
|
|
1400
|
-
n =
|
|
1878
|
+
n = h(e);
|
|
1401
1879
|
} catch {
|
|
1402
1880
|
if (t = this.walletAdapters.get(e), !t)
|
|
1403
1881
|
throw new Error(`Wallet ${e} is not connected or supported`);
|
|
@@ -1474,8 +1952,21 @@ class Lt {
|
|
|
1474
1952
|
return console.error(`Error switching chain for ${e} wallet:`, n), !1;
|
|
1475
1953
|
}
|
|
1476
1954
|
}
|
|
1955
|
+
async waitForTransaction(e, t, n) {
|
|
1956
|
+
let s;
|
|
1957
|
+
try {
|
|
1958
|
+
return s = this.getConnectedWalletAdapter(e), await s.waitForTransaction(t, n);
|
|
1959
|
+
} catch (o) {
|
|
1960
|
+
return this.handleError(
|
|
1961
|
+
e,
|
|
1962
|
+
o,
|
|
1963
|
+
"waiting for transaction with",
|
|
1964
|
+
s?.type
|
|
1965
|
+
);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1477
1968
|
}
|
|
1478
|
-
class
|
|
1969
|
+
class Ht extends Je {
|
|
1479
1970
|
walletBridge;
|
|
1480
1971
|
constructor({
|
|
1481
1972
|
url: e,
|
|
@@ -1486,7 +1977,7 @@ class Yt extends Ze {
|
|
|
1486
1977
|
tokens: a,
|
|
1487
1978
|
...i
|
|
1488
1979
|
}) {
|
|
1489
|
-
const c = new URL(e ?? Ae), l = new
|
|
1980
|
+
const c = new URL(e ?? Ae), l = new Yt();
|
|
1490
1981
|
t && c.searchParams.set(
|
|
1491
1982
|
"policies",
|
|
1492
1983
|
encodeURIComponent(JSON.stringify(t))
|
|
@@ -1504,7 +1995,7 @@ class Yt extends Ze {
|
|
|
1504
1995
|
return this.walletBridge;
|
|
1505
1996
|
}
|
|
1506
1997
|
}
|
|
1507
|
-
class
|
|
1998
|
+
class Gt extends Ee {
|
|
1508
1999
|
keychain;
|
|
1509
2000
|
options;
|
|
1510
2001
|
iframes;
|
|
@@ -1518,21 +2009,14 @@ class Vt extends Ie {
|
|
|
1518
2009
|
const n = [...[
|
|
1519
2010
|
{ rpcUrl: "https://api.cartridge.gg/x/starknet/sepolia" },
|
|
1520
2011
|
{ rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet" }
|
|
1521
|
-
], ...e.chains || []], s = e.defaultChainId ||
|
|
1522
|
-
this.selectedChain = s, this.chains = /* @__PURE__ */ new Map(), this.iframes = {
|
|
1523
|
-
keychain:
|
|
1524
|
-
|
|
1525
|
-
onClose: this.keychain?.reset,
|
|
1526
|
-
onConnect: (o) => {
|
|
1527
|
-
this.keychain = o;
|
|
1528
|
-
},
|
|
1529
|
-
version: ve
|
|
1530
|
-
})
|
|
1531
|
-
}, this.options = { ...e, chains: n, defaultChainId: s }, this.initializeChains(n), typeof window < "u" && (window.starknet_controller = this);
|
|
2012
|
+
], ...e.chains || []], s = e.defaultChainId || B.StarknetChainId.SN_MAIN;
|
|
2013
|
+
this.selectedChain = s, this.chains = /* @__PURE__ */ new Map(), this.options = { ...e, chains: n, defaultChainId: s }, this.iframes = {
|
|
2014
|
+
keychain: e.lazyload ? void 0 : this.createKeychainIframe()
|
|
2015
|
+
}, this.initializeChains(n), typeof window < "u" && (window.starknet_controller = this);
|
|
1532
2016
|
}
|
|
1533
2017
|
async logout() {
|
|
1534
2018
|
if (!this.keychain) {
|
|
1535
|
-
console.error(new
|
|
2019
|
+
console.error(new m().message);
|
|
1536
2020
|
return;
|
|
1537
2021
|
}
|
|
1538
2022
|
try {
|
|
@@ -1548,13 +2032,13 @@ class Vt extends Ie {
|
|
|
1548
2032
|
}
|
|
1549
2033
|
async probe() {
|
|
1550
2034
|
try {
|
|
1551
|
-
if (await this.waitForKeychain(), !this.keychain) {
|
|
1552
|
-
console.error(new
|
|
2035
|
+
if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe()), await this.waitForKeychain(), !this.keychain) {
|
|
2036
|
+
console.error(new m().message);
|
|
1553
2037
|
return;
|
|
1554
2038
|
}
|
|
1555
2039
|
const e = await this.keychain.probe(this.rpcUrl());
|
|
1556
2040
|
let t = e?.rpcUrl || this.rpcUrl();
|
|
1557
|
-
this.account = new
|
|
2041
|
+
this.account = new j(
|
|
1558
2042
|
this,
|
|
1559
2043
|
t,
|
|
1560
2044
|
e.address,
|
|
@@ -1571,8 +2055,8 @@ class Vt extends Ie {
|
|
|
1571
2055
|
async connect() {
|
|
1572
2056
|
if (this.account)
|
|
1573
2057
|
return this.account;
|
|
1574
|
-
if (!this.keychain || !this.iframes.keychain) {
|
|
1575
|
-
console.error(new
|
|
2058
|
+
if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe(), await this.waitForKeychain()), !this.keychain || !this.iframes.keychain) {
|
|
2059
|
+
console.error(new m().message);
|
|
1576
2060
|
return;
|
|
1577
2061
|
}
|
|
1578
2062
|
typeof document < "u" && document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.iframes.keychain.open();
|
|
@@ -1586,9 +2070,9 @@ class Vt extends Ie {
|
|
|
1586
2070
|
this.rpcUrl(),
|
|
1587
2071
|
this.options.signupOptions
|
|
1588
2072
|
);
|
|
1589
|
-
if (e.code !==
|
|
2073
|
+
if (e.code !== R.SUCCESS)
|
|
1590
2074
|
throw new Error(e.message);
|
|
1591
|
-
return e = e, this.account = new
|
|
2075
|
+
return e = e, this.account = new j(
|
|
1592
2076
|
this,
|
|
1593
2077
|
this.rpcUrl(),
|
|
1594
2078
|
e.address,
|
|
@@ -1604,7 +2088,7 @@ class Vt extends Ie {
|
|
|
1604
2088
|
}
|
|
1605
2089
|
async switchStarknetChain(e) {
|
|
1606
2090
|
if (!this.keychain || !this.iframes.keychain)
|
|
1607
|
-
return console.error(new
|
|
2091
|
+
return console.error(new m().message), !1;
|
|
1608
2092
|
try {
|
|
1609
2093
|
if (this.selectedChain = e, (await this.keychain.probe(this.rpcUrl())).rpcUrl === this.rpcUrl())
|
|
1610
2094
|
return !0;
|
|
@@ -1619,14 +2103,14 @@ class Vt extends Ie {
|
|
|
1619
2103
|
}
|
|
1620
2104
|
async disconnect() {
|
|
1621
2105
|
if (!this.keychain) {
|
|
1622
|
-
console.error(new
|
|
2106
|
+
console.error(new m().message);
|
|
1623
2107
|
return;
|
|
1624
2108
|
}
|
|
1625
2109
|
return typeof document < "u" && document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.account = void 0, this.keychain.disconnect();
|
|
1626
2110
|
}
|
|
1627
2111
|
async openProfile(e = "inventory") {
|
|
1628
2112
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1629
|
-
console.error(new
|
|
2113
|
+
console.error(new m().message);
|
|
1630
2114
|
return;
|
|
1631
2115
|
}
|
|
1632
2116
|
if (!this.account) {
|
|
@@ -1640,7 +2124,7 @@ class Vt extends Ie {
|
|
|
1640
2124
|
}
|
|
1641
2125
|
async openProfileTo(e) {
|
|
1642
2126
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1643
|
-
console.error(new
|
|
2127
|
+
console.error(new m().message);
|
|
1644
2128
|
return;
|
|
1645
2129
|
}
|
|
1646
2130
|
if (!this.account) {
|
|
@@ -1654,7 +2138,7 @@ class Vt extends Ie {
|
|
|
1654
2138
|
}
|
|
1655
2139
|
async openProfileAt(e) {
|
|
1656
2140
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1657
|
-
console.error(new
|
|
2141
|
+
console.error(new m().message);
|
|
1658
2142
|
return;
|
|
1659
2143
|
}
|
|
1660
2144
|
if (!this.account) {
|
|
@@ -1665,71 +2149,71 @@ class Vt extends Ie {
|
|
|
1665
2149
|
}
|
|
1666
2150
|
openSettings() {
|
|
1667
2151
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1668
|
-
console.error(new
|
|
2152
|
+
console.error(new m().message);
|
|
1669
2153
|
return;
|
|
1670
2154
|
}
|
|
1671
2155
|
this.iframes.keychain.open(), this.keychain.openSettings();
|
|
1672
2156
|
}
|
|
1673
2157
|
revoke(e, t) {
|
|
1674
|
-
return this.keychain ? this.keychain.revoke(e) : (console.error(new
|
|
2158
|
+
return this.keychain ? this.keychain.revoke(e) : (console.error(new m().message), null);
|
|
1675
2159
|
}
|
|
1676
2160
|
rpcUrl() {
|
|
1677
2161
|
const e = this.chains.get(this.selectedChain);
|
|
1678
2162
|
if (!e) {
|
|
1679
2163
|
const t = Array.from(this.chains.keys()).map(
|
|
1680
|
-
(n) =>
|
|
2164
|
+
(n) => K.decodeShortString(n)
|
|
1681
2165
|
);
|
|
1682
2166
|
throw new Error(
|
|
1683
|
-
`Chain not found: ${
|
|
2167
|
+
`Chain not found: ${K.decodeShortString(this.selectedChain)}. Available chains: ${t.join(", ")}`
|
|
1684
2168
|
);
|
|
1685
2169
|
}
|
|
1686
2170
|
return e.rpcUrl;
|
|
1687
2171
|
}
|
|
1688
2172
|
username() {
|
|
1689
2173
|
if (!this.keychain) {
|
|
1690
|
-
console.error(new
|
|
2174
|
+
console.error(new m().message);
|
|
1691
2175
|
return;
|
|
1692
2176
|
}
|
|
1693
2177
|
return this.keychain.username();
|
|
1694
2178
|
}
|
|
1695
2179
|
openPurchaseCredits() {
|
|
1696
2180
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1697
|
-
console.error(new
|
|
2181
|
+
console.error(new m().message);
|
|
1698
2182
|
return;
|
|
1699
2183
|
}
|
|
1700
2184
|
this.keychain.navigate("/purchase/credits").then(() => {
|
|
1701
|
-
this.iframes.keychain
|
|
2185
|
+
this.iframes.keychain?.open();
|
|
1702
2186
|
});
|
|
1703
2187
|
}
|
|
1704
2188
|
openStarterPack(e) {
|
|
1705
2189
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1706
|
-
console.error(new
|
|
2190
|
+
console.error(new m().message);
|
|
1707
2191
|
return;
|
|
1708
2192
|
}
|
|
1709
2193
|
this.keychain.navigate(`/purchase/starterpack/${e}`).then(() => {
|
|
1710
|
-
this.iframes.keychain
|
|
2194
|
+
this.iframes.keychain?.open();
|
|
1711
2195
|
});
|
|
1712
2196
|
}
|
|
1713
2197
|
async openExecute(e, t) {
|
|
1714
2198
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1715
|
-
console.error(new
|
|
2199
|
+
console.error(new m().message);
|
|
1716
2200
|
return;
|
|
1717
2201
|
}
|
|
1718
2202
|
let n = this.selectedChain;
|
|
1719
2203
|
t && this.switchStarknetChain(t), this.iframes.keychain.open();
|
|
1720
2204
|
const s = await this.keychain.execute(e, void 0, void 0, !0);
|
|
1721
2205
|
return this.iframes.keychain.close(), t && this.switchStarknetChain(n), {
|
|
1722
|
-
status: !(s && (s.code ===
|
|
2206
|
+
status: !(s && (s.code === R.NOT_CONNECTED || s.code === R.CANCELED)),
|
|
1723
2207
|
transactionHash: s?.transaction_hash
|
|
1724
2208
|
};
|
|
1725
2209
|
}
|
|
1726
2210
|
async delegateAccount() {
|
|
1727
|
-
return this.keychain ? await this.keychain.delegateAccount() : (console.error(new
|
|
2211
|
+
return this.keychain ? await this.keychain.delegateAccount() : (console.error(new m().message), null);
|
|
1728
2212
|
}
|
|
1729
2213
|
initializeChains(e) {
|
|
1730
2214
|
for (const t of e)
|
|
1731
2215
|
try {
|
|
1732
|
-
const n = new URL(t.rpcUrl), s =
|
|
2216
|
+
const n = new URL(t.rpcUrl), s = Ie(n), o = s === B.StarknetChainId.SN_MAIN, a = s === B.StarknetChainId.SN_SEPOLIA, i = n.hostname === "api.cartridge.gg", c = n.hostname === "localhost" || n.hostname === "127.0.0.1";
|
|
1733
2217
|
if ((o || a) && !(i || c))
|
|
1734
2218
|
throw new Error(
|
|
1735
2219
|
`Only Cartridge RPC providers are allowed for ${o ? "mainnet" : "sepolia"}. Please use: https://api.cartridge.gg/x/starknet/${o ? "mainnet" : "sepolia"}`
|
|
@@ -1742,6 +2226,16 @@ class Vt extends Ie {
|
|
|
1742
2226
|
`Selected chain ${this.selectedChain} not found in configured chains. Available chains: ${Array.from(this.chains.keys()).join(", ")}`
|
|
1743
2227
|
);
|
|
1744
2228
|
}
|
|
2229
|
+
createKeychainIframe() {
|
|
2230
|
+
return new Ht({
|
|
2231
|
+
...this.options,
|
|
2232
|
+
onClose: this.keychain?.reset,
|
|
2233
|
+
onConnect: (e) => {
|
|
2234
|
+
this.keychain = e;
|
|
2235
|
+
},
|
|
2236
|
+
version: xe
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
1745
2239
|
waitForKeychain({
|
|
1746
2240
|
timeout: e = 5e4,
|
|
1747
2241
|
interval: t = 100
|
|
@@ -1757,11 +2251,11 @@ class Vt extends Ie {
|
|
|
1757
2251
|
});
|
|
1758
2252
|
}
|
|
1759
2253
|
}
|
|
1760
|
-
const
|
|
1761
|
-
async function
|
|
2254
|
+
const P = /* @__PURE__ */ new Map();
|
|
2255
|
+
async function be(r) {
|
|
1762
2256
|
if (!r.addresses?.length && !r.usernames?.length)
|
|
1763
2257
|
return { results: [] };
|
|
1764
|
-
const e = await fetch(`${
|
|
2258
|
+
const e = await fetch(`${Ce}/lookup`, {
|
|
1765
2259
|
method: "POST",
|
|
1766
2260
|
headers: {
|
|
1767
2261
|
"Content-Type": "application/json"
|
|
@@ -1772,26 +2266,26 @@ async function ye(r) {
|
|
|
1772
2266
|
throw new Error(`HTTP error! status: ${e.status}`);
|
|
1773
2267
|
return e.json();
|
|
1774
2268
|
}
|
|
1775
|
-
async function
|
|
1776
|
-
const e = r.filter((t) => !
|
|
1777
|
-
return e.length > 0 && (await
|
|
1778
|
-
|
|
2269
|
+
async function Jt(r) {
|
|
2270
|
+
const e = r.filter((t) => !P.has(t));
|
|
2271
|
+
return e.length > 0 && (await be({ usernames: e })).results.forEach((n) => {
|
|
2272
|
+
P.set(n.username, n.addresses[0]);
|
|
1779
2273
|
}), new Map(
|
|
1780
|
-
r.map((t) => [t,
|
|
2274
|
+
r.map((t) => [t, P.get(t)]).filter((t) => t[1] !== void 0)
|
|
1781
2275
|
);
|
|
1782
2276
|
}
|
|
1783
|
-
async function
|
|
1784
|
-
r = r.map(
|
|
1785
|
-
const e = r.filter((t) => !
|
|
1786
|
-
return e.length > 0 && (await
|
|
2277
|
+
async function Zt(r) {
|
|
2278
|
+
r = r.map(ae.toHex);
|
|
2279
|
+
const e = r.filter((t) => !P.has(t));
|
|
2280
|
+
return e.length > 0 && (await be({
|
|
1787
2281
|
addresses: e
|
|
1788
2282
|
})).results.forEach((n) => {
|
|
1789
|
-
|
|
2283
|
+
P.set(n.addresses[0], n.username);
|
|
1790
2284
|
}), new Map(
|
|
1791
|
-
r.map((t) => [t,
|
|
2285
|
+
r.map((t) => [t, P.get(t)]).filter((t) => t[1] !== void 0)
|
|
1792
2286
|
);
|
|
1793
2287
|
}
|
|
1794
|
-
var
|
|
2288
|
+
var qt = [
|
|
1795
2289
|
{
|
|
1796
2290
|
name: "Wrapped BTC",
|
|
1797
2291
|
symbol: "WBTC",
|
|
@@ -2355,28 +2849,28 @@ var Ft = [
|
|
|
2355
2849
|
total_supply: null,
|
|
2356
2850
|
logo_url: "https://assets.underware.gg/pistols/fame.svg"
|
|
2357
2851
|
}
|
|
2358
|
-
],
|
|
2852
|
+
], _e = {
|
|
2359
2853
|
theme: {
|
|
2360
2854
|
name: "Cartridge",
|
|
2361
2855
|
icon: "icon.svg"
|
|
2362
2856
|
}
|
|
2363
|
-
},
|
|
2364
|
-
async function
|
|
2857
|
+
}, $ = "https://static.cartridge.gg/presets";
|
|
2858
|
+
async function q() {
|
|
2365
2859
|
try {
|
|
2366
|
-
const r = await fetch(`${
|
|
2860
|
+
const r = await fetch(`${$}/index.json`);
|
|
2367
2861
|
if (!r.ok)
|
|
2368
2862
|
throw new Error(`Failed to load configs index: ${r.statusText}`);
|
|
2369
2863
|
return await r.json();
|
|
2370
2864
|
} catch (r) {
|
|
2371
|
-
return console.error("Error loading configs index:", r), { configs: [], baseUrl:
|
|
2865
|
+
return console.error("Error loading configs index:", r), { configs: [], baseUrl: $ };
|
|
2372
2866
|
}
|
|
2373
2867
|
}
|
|
2374
|
-
async function
|
|
2375
|
-
return (await
|
|
2868
|
+
async function er() {
|
|
2869
|
+
return (await q()).configs;
|
|
2376
2870
|
}
|
|
2377
|
-
async function
|
|
2871
|
+
async function tr(r) {
|
|
2378
2872
|
try {
|
|
2379
|
-
const n = `${(await
|
|
2873
|
+
const n = `${(await q()).baseUrl || $}/${r}`, s = await fetch(`${n}/config.json`);
|
|
2380
2874
|
if (!s.ok)
|
|
2381
2875
|
throw new Error(
|
|
2382
2876
|
`Failed to load config ${r}: ${s.statusText}`
|
|
@@ -2406,8 +2900,8 @@ async function er(r) {
|
|
|
2406
2900
|
return console.error(`Error loading config ${r}:`, e), null;
|
|
2407
2901
|
}
|
|
2408
2902
|
}
|
|
2409
|
-
async function
|
|
2410
|
-
const r = await
|
|
2903
|
+
async function rr() {
|
|
2904
|
+
const r = await q(), e = r.configs, t = r.baseUrl || $, n = {};
|
|
2411
2905
|
return await Promise.all(
|
|
2412
2906
|
e.map(async (s) => {
|
|
2413
2907
|
try {
|
|
@@ -2422,31 +2916,33 @@ async function tr() {
|
|
|
2422
2916
|
})
|
|
2423
2917
|
), n;
|
|
2424
2918
|
}
|
|
2425
|
-
|
|
2426
|
-
var
|
|
2919
|
+
_e.theme.icon = "https://static.cartridge.gg/presets/cartridge/icon.svg";
|
|
2920
|
+
var nr = qt, sr = _e.theme;
|
|
2427
2921
|
export {
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
Ot as
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2922
|
+
Nt as ArgentWallet,
|
|
2923
|
+
Wt as BraavosWallet,
|
|
2924
|
+
ir as FeeSource,
|
|
2925
|
+
zt as MetaMaskWallet,
|
|
2926
|
+
m as NotReadyToConnect,
|
|
2927
|
+
Ot as PhantomWallet,
|
|
2928
|
+
Lt as RabbyWallet,
|
|
2929
|
+
R as ResponseCodes,
|
|
2930
|
+
Yt as WalletBridge,
|
|
2931
|
+
_ as chainIdToPlatform,
|
|
2932
|
+
Gt as default,
|
|
2933
|
+
sr as defaultTheme,
|
|
2934
|
+
nr as erc20Metadata,
|
|
2935
|
+
er as getAvailableConfigs,
|
|
2936
|
+
q as getConfigsIndex,
|
|
2937
|
+
cr as humanizeString,
|
|
2938
|
+
rr as loadAllConfigs,
|
|
2939
|
+
tr as loadConfig,
|
|
2940
|
+
Zt as lookupAddresses,
|
|
2941
|
+
Jt as lookupUsernames,
|
|
2942
|
+
lr as normalizeCalls,
|
|
2943
|
+
Ie as parseChainId,
|
|
2448
2944
|
ke as toArray,
|
|
2449
|
-
|
|
2450
|
-
|
|
2945
|
+
dr as toSessionPolicies,
|
|
2946
|
+
hr as toWasmPolicies
|
|
2451
2947
|
};
|
|
2452
2948
|
//# sourceMappingURL=index.js.map
|