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