@cartridge/controller 0.9.0 → 0.9.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 +18 -18
- package/.turbo/turbo-build.log +18 -18
- package/dist/controller.d.ts +1 -2
- package/dist/iframe/base.d.ts +1 -0
- package/dist/iframe/index.d.ts +0 -1
- package/dist/iframe/keychain.d.ts +1 -1
- package/dist/index.js +456 -507
- package/dist/index.js.map +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/{provider-B9Ikz5hr.js → provider-iltRv2Q1.js} +21 -22
- package/dist/provider-iltRv2Q1.js.map +1 -0
- package/dist/session.js +3 -3
- package/dist/session.js.map +1 -1
- package/dist/stats.html +1 -1
- package/dist/types.d.ts +3 -7
- package/package.json +4 -3
- package/src/controller.ts +30 -72
- package/src/iframe/base.ts +6 -24
- package/src/iframe/index.ts +0 -1
- package/src/iframe/keychain.ts +18 -0
- package/src/types.ts +3 -10
- package/dist/iframe/profile.d.ts +0 -12
- package/dist/provider-B9Ikz5hr.js.map +0 -1
- package/src/iframe/profile.ts +0 -59
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { WalletAccount as
|
|
2
|
-
import { R
|
|
3
|
-
import { F as
|
|
4
|
-
import { connect as
|
|
5
|
-
import { InjectedConnector as
|
|
6
|
-
import { MetaMaskSDK as
|
|
7
|
-
import { Transaction as
|
|
8
|
-
class H extends
|
|
1
|
+
import { WalletAccount as me, constants as $, shortString as W, num as ye } from "starknet";
|
|
2
|
+
import { R, t as be, K as we, B as _e, v as ke, N as p, p as Ae, A as Ie } from "./provider-iltRv2Q1.js";
|
|
3
|
+
import { F as tr, h as rr, n as nr, a as sr, b as or } from "./provider-iltRv2Q1.js";
|
|
4
|
+
import { connect as ve } from "starknetkit";
|
|
5
|
+
import { InjectedConnector as Ee } from "starknetkit/injected";
|
|
6
|
+
import { MetaMaskSDK as xe } from "@metamask/sdk";
|
|
7
|
+
import { Transaction as Ce } from "@solana/web3.js";
|
|
8
|
+
class H extends me {
|
|
9
9
|
keychain;
|
|
10
10
|
modal;
|
|
11
11
|
options;
|
|
12
|
-
constructor(e, t, n,
|
|
13
|
-
super({ nodeUrl: t }, e, n), this.keychain =
|
|
12
|
+
constructor(e, t, n, s, o, a) {
|
|
13
|
+
super({ nodeUrl: t }, e, n), this.keychain = s, this.options = o, this.modal = a;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Invoke execute function in account contract
|
|
@@ -25,35 +25,35 @@ class H extends ye {
|
|
|
25
25
|
* @returns response from addTransaction
|
|
26
26
|
*/
|
|
27
27
|
async execute(e) {
|
|
28
|
-
return e =
|
|
29
|
-
const
|
|
28
|
+
return e = be(e), new Promise(async (t, n) => {
|
|
29
|
+
const s = await this.keychain.execute(
|
|
30
30
|
e,
|
|
31
31
|
void 0,
|
|
32
32
|
void 0,
|
|
33
33
|
!1,
|
|
34
34
|
this.options?.feeSource
|
|
35
35
|
);
|
|
36
|
-
if (
|
|
37
|
-
t(
|
|
36
|
+
if (s.code === R.SUCCESS) {
|
|
37
|
+
t(s);
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
if (this.options?.propagateSessionErrors &&
|
|
41
|
-
n(
|
|
40
|
+
if (this.options?.propagateSessionErrors && s.code !== R.USER_INTERACTION_REQUIRED) {
|
|
41
|
+
n(s.error);
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
this.modal.open();
|
|
45
|
-
const
|
|
45
|
+
const o = await this.keychain.execute(
|
|
46
46
|
e,
|
|
47
47
|
void 0,
|
|
48
48
|
void 0,
|
|
49
49
|
!0,
|
|
50
|
-
|
|
50
|
+
s.error
|
|
51
51
|
);
|
|
52
|
-
if (
|
|
53
|
-
t(
|
|
52
|
+
if (o.code === R.SUCCESS) {
|
|
53
|
+
t(o), this.modal.close();
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
n(
|
|
56
|
+
n(o.error);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
@@ -66,29 +66,29 @@ class H extends ye {
|
|
|
66
66
|
*/
|
|
67
67
|
async signMessage(e) {
|
|
68
68
|
return new Promise(async (t, n) => {
|
|
69
|
-
const
|
|
70
|
-
if (!("code" in
|
|
71
|
-
t(
|
|
69
|
+
const s = await this.keychain.signMessage(e, "", !0);
|
|
70
|
+
if (!("code" in s)) {
|
|
71
|
+
t(s);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
this.modal.open();
|
|
75
|
-
const
|
|
76
|
-
"code" in
|
|
75
|
+
const o = await this.keychain.signMessage(e, "", !1);
|
|
76
|
+
"code" in o ? n(o.error) : t(o), this.modal.close();
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
var
|
|
80
|
+
var b;
|
|
81
81
|
(function(r) {
|
|
82
82
|
r.Call = "call", r.Reply = "reply", r.Syn = "syn", r.SynAck = "synAck", r.Ack = "ack";
|
|
83
|
-
})(
|
|
84
|
-
var
|
|
83
|
+
})(b || (b = {}));
|
|
84
|
+
var v;
|
|
85
85
|
(function(r) {
|
|
86
86
|
r.Fulfilled = "fulfilled", r.Rejected = "rejected";
|
|
87
|
-
})(
|
|
88
|
-
var
|
|
87
|
+
})(v || (v = {}));
|
|
88
|
+
var N;
|
|
89
89
|
(function(r) {
|
|
90
90
|
r.ConnectionDestroyed = "ConnectionDestroyed", r.ConnectionTimeout = "ConnectionTimeout", r.NoIframeSrc = "NoIframeSrc";
|
|
91
|
-
})(
|
|
91
|
+
})(N || (N = {}));
|
|
92
92
|
var z;
|
|
93
93
|
(function(r) {
|
|
94
94
|
r.DataCloneError = "DataCloneError";
|
|
@@ -97,231 +97,231 @@ var A;
|
|
|
97
97
|
(function(r) {
|
|
98
98
|
r.Message = "message";
|
|
99
99
|
})(A || (A = {}));
|
|
100
|
-
const
|
|
100
|
+
const Re = (r, e) => {
|
|
101
101
|
const t = [];
|
|
102
102
|
let n = !1;
|
|
103
103
|
return {
|
|
104
|
-
destroy(
|
|
105
|
-
n || (n = !0, e(`${r}: Destroying connection`), t.forEach((
|
|
106
|
-
s
|
|
104
|
+
destroy(s) {
|
|
105
|
+
n || (n = !0, e(`${r}: Destroying connection`), t.forEach((o) => {
|
|
106
|
+
o(s);
|
|
107
107
|
}));
|
|
108
108
|
},
|
|
109
|
-
onDestroy(
|
|
110
|
-
n ?
|
|
109
|
+
onDestroy(s) {
|
|
110
|
+
n ? s() : t.push(s);
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
|
-
},
|
|
113
|
+
}, Se = (r) => (...e) => {
|
|
114
114
|
r && console.log("[Penpal]", ...e);
|
|
115
|
-
},
|
|
115
|
+
}, Pe = {
|
|
116
116
|
"http:": "80",
|
|
117
117
|
"https:": "443"
|
|
118
|
-
},
|
|
119
|
-
if (r &&
|
|
118
|
+
}, De = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, Ne = ["file:", "data:"], Me = (r) => {
|
|
119
|
+
if (r && Ne.find((i) => r.startsWith(i)))
|
|
120
120
|
return "null";
|
|
121
|
-
const e = document.location, t =
|
|
122
|
-
let n,
|
|
123
|
-
t ? (n = t[1] ? t[1] : e.protocol,
|
|
124
|
-
const a =
|
|
125
|
-
return `${n}//${
|
|
121
|
+
const e = document.location, t = De.exec(r);
|
|
122
|
+
let n, s, o;
|
|
123
|
+
t ? (n = t[1] ? t[1] : e.protocol, s = t[2], o = t[4]) : (n = e.protocol, s = e.hostname, o = e.port);
|
|
124
|
+
const a = o && o !== Pe[n] ? `:${o}` : "";
|
|
125
|
+
return `${n}//${s}${a}`;
|
|
126
126
|
}, K = ({ name: r, message: e, stack: t }) => ({
|
|
127
127
|
name: r,
|
|
128
128
|
message: e,
|
|
129
129
|
stack: t
|
|
130
|
-
}),
|
|
130
|
+
}), Be = (r) => {
|
|
131
131
|
const e = new Error();
|
|
132
132
|
return Object.keys(r).forEach((t) => e[t] = r[t]), e;
|
|
133
|
-
},
|
|
134
|
-
const { localName: n, local:
|
|
133
|
+
}, Qe = (r, e, t) => {
|
|
134
|
+
const { localName: n, local: s, remote: o, originForSending: a, originForReceiving: i } = r;
|
|
135
135
|
let c = !1;
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
136
|
+
const l = (d) => {
|
|
137
|
+
if (d.source !== o || d.data.penpal !== b.Call)
|
|
138
138
|
return;
|
|
139
|
-
if (i !== "*" &&
|
|
140
|
-
t(`${n} received message from origin ${
|
|
139
|
+
if (i !== "*" && d.origin !== i) {
|
|
140
|
+
t(`${n} received message from origin ${d.origin} which did not match expected origin ${i}`);
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
-
const h =
|
|
144
|
-
t(`${n}: Received ${
|
|
143
|
+
const h = d.data, { methodName: m, args: u, id: _ } = h;
|
|
144
|
+
t(`${n}: Received ${m}() call`);
|
|
145
145
|
const k = (y) => (I) => {
|
|
146
|
-
if (t(`${n}: Sending ${
|
|
147
|
-
t(`${n}: Unable to send ${
|
|
146
|
+
if (t(`${n}: Sending ${m}() reply`), c) {
|
|
147
|
+
t(`${n}: Unable to send ${m}() reply due to destroyed connection`);
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
|
-
const
|
|
151
|
-
penpal:
|
|
152
|
-
id:
|
|
150
|
+
const w = {
|
|
151
|
+
penpal: b.Reply,
|
|
152
|
+
id: _,
|
|
153
153
|
resolution: y,
|
|
154
154
|
returnValue: I
|
|
155
155
|
};
|
|
156
|
-
y ===
|
|
156
|
+
y === v.Rejected && I instanceof Error && (w.returnValue = K(I), w.returnValueIsError = !0);
|
|
157
157
|
try {
|
|
158
|
-
|
|
159
|
-
} catch (
|
|
160
|
-
if (
|
|
161
|
-
const
|
|
162
|
-
penpal:
|
|
163
|
-
id:
|
|
164
|
-
resolution:
|
|
165
|
-
returnValue: K(
|
|
158
|
+
o.postMessage(w, a);
|
|
159
|
+
} catch (f) {
|
|
160
|
+
if (f.name === z.DataCloneError) {
|
|
161
|
+
const E = {
|
|
162
|
+
penpal: b.Reply,
|
|
163
|
+
id: _,
|
|
164
|
+
resolution: v.Rejected,
|
|
165
|
+
returnValue: K(f),
|
|
166
166
|
returnValueIsError: !0
|
|
167
167
|
};
|
|
168
|
-
|
|
168
|
+
o.postMessage(E, a);
|
|
169
169
|
}
|
|
170
|
-
throw
|
|
170
|
+
throw f;
|
|
171
171
|
}
|
|
172
172
|
};
|
|
173
|
-
new Promise((y) => y(e[
|
|
173
|
+
new Promise((y) => y(e[m].call(e, d.origin).apply(e, u))).then(k(v.Fulfilled), k(v.Rejected));
|
|
174
174
|
};
|
|
175
|
-
return
|
|
176
|
-
c = !0,
|
|
175
|
+
return s.addEventListener(A.Message, l), () => {
|
|
176
|
+
c = !0, s.removeEventListener(A.Message, l);
|
|
177
177
|
};
|
|
178
178
|
};
|
|
179
|
-
let
|
|
180
|
-
const
|
|
179
|
+
let Ue = 0;
|
|
180
|
+
const Te = () => ++Ue, re = ".", ne = (r) => r ? r.split(re) : [], $e = (r) => r.join(re), ze = (r, e) => {
|
|
181
181
|
const t = ne(e || "");
|
|
182
|
-
return t.push(r),
|
|
183
|
-
},
|
|
182
|
+
return t.push(r), $e(t);
|
|
183
|
+
}, Oe = (r, e, t) => {
|
|
184
184
|
const n = ne(e);
|
|
185
|
-
return n.reduce((
|
|
186
|
-
},
|
|
185
|
+
return n.reduce((s, o, a) => (typeof s[o] > "u" && (s[o] = {}), a === n.length - 1 && (s[o] = t), s[o]), r), r;
|
|
186
|
+
}, se = (r, e) => {
|
|
187
187
|
const t = {};
|
|
188
188
|
return Object.keys(r).forEach((n) => {
|
|
189
|
-
const
|
|
190
|
-
typeof
|
|
189
|
+
const s = r[n], o = ze(n, e);
|
|
190
|
+
typeof s == "object" && Object.assign(t, se(s, o)), typeof s == "function" && (t[o] = s);
|
|
191
191
|
}), t;
|
|
192
|
-
},
|
|
192
|
+
}, Le = (r) => {
|
|
193
193
|
const e = {};
|
|
194
194
|
for (const t in r)
|
|
195
|
-
|
|
195
|
+
Oe(e, t, r[t]);
|
|
196
196
|
return e;
|
|
197
|
-
},
|
|
198
|
-
const { localName:
|
|
199
|
-
let
|
|
200
|
-
|
|
201
|
-
const h = (
|
|
202
|
-
|
|
197
|
+
}, Ye = (r, e, t, n, s) => {
|
|
198
|
+
const { localName: o, local: a, remote: i, originForSending: c, originForReceiving: l } = e;
|
|
199
|
+
let d = !1;
|
|
200
|
+
s(`${o}: Connecting call sender`);
|
|
201
|
+
const h = (u) => (..._) => {
|
|
202
|
+
s(`${o}: Sending ${u}() call`);
|
|
203
203
|
let k;
|
|
204
204
|
try {
|
|
205
205
|
i.closed && (k = !0);
|
|
206
206
|
} catch {
|
|
207
207
|
k = !0;
|
|
208
208
|
}
|
|
209
|
-
if (k && n(),
|
|
210
|
-
const y = new Error(`Unable to send ${
|
|
211
|
-
throw y.code =
|
|
209
|
+
if (k && n(), d) {
|
|
210
|
+
const y = new Error(`Unable to send ${u}() call due to destroyed connection`);
|
|
211
|
+
throw y.code = N.ConnectionDestroyed, y;
|
|
212
212
|
}
|
|
213
213
|
return new Promise((y, I) => {
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
214
|
+
const w = Te(), f = (x) => {
|
|
215
|
+
if (x.source !== i || x.data.penpal !== b.Reply || x.data.id !== w)
|
|
216
216
|
return;
|
|
217
|
-
if (
|
|
218
|
-
|
|
217
|
+
if (l !== "*" && x.origin !== l) {
|
|
218
|
+
s(`${o} received message from origin ${x.origin} which did not match expected origin ${l}`);
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
let T =
|
|
224
|
-
|
|
221
|
+
const U = x.data;
|
|
222
|
+
s(`${o}: Received ${u}() reply`), a.removeEventListener(A.Message, f);
|
|
223
|
+
let T = U.returnValue;
|
|
224
|
+
U.returnValueIsError && (T = Be(T)), (U.resolution === v.Fulfilled ? y : I)(T);
|
|
225
225
|
};
|
|
226
|
-
a.addEventListener(A.Message,
|
|
227
|
-
const
|
|
228
|
-
penpal:
|
|
229
|
-
id:
|
|
230
|
-
methodName:
|
|
231
|
-
args:
|
|
226
|
+
a.addEventListener(A.Message, f);
|
|
227
|
+
const E = {
|
|
228
|
+
penpal: b.Call,
|
|
229
|
+
id: w,
|
|
230
|
+
methodName: u,
|
|
231
|
+
args: _
|
|
232
232
|
};
|
|
233
|
-
i.postMessage(
|
|
233
|
+
i.postMessage(E, c);
|
|
234
234
|
});
|
|
235
|
-
},
|
|
236
|
-
return Object.assign(r,
|
|
237
|
-
|
|
235
|
+
}, m = t.reduce((u, _) => (u[_] = h(_), u), {});
|
|
236
|
+
return Object.assign(r, Le(m)), () => {
|
|
237
|
+
d = !0;
|
|
238
238
|
};
|
|
239
|
-
},
|
|
240
|
-
const { destroy:
|
|
239
|
+
}, Fe = (r, e, t, n, s) => {
|
|
240
|
+
const { destroy: o, onDestroy: a } = n;
|
|
241
241
|
let i, c;
|
|
242
|
-
const
|
|
243
|
-
return (
|
|
244
|
-
if (e !== "*" &&
|
|
245
|
-
|
|
242
|
+
const l = {};
|
|
243
|
+
return (d) => {
|
|
244
|
+
if (e !== "*" && d.origin !== e) {
|
|
245
|
+
s(`Parent: Handshake - Received ACK message from origin ${d.origin} which did not match expected origin ${e}`);
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
s("Parent: Handshake - Received ACK");
|
|
249
249
|
const h = {
|
|
250
250
|
localName: "Parent",
|
|
251
251
|
local: window,
|
|
252
|
-
remote:
|
|
252
|
+
remote: d.source,
|
|
253
253
|
originForSending: t,
|
|
254
254
|
originForReceiving: e
|
|
255
255
|
};
|
|
256
|
-
i && i(), i =
|
|
257
|
-
delete
|
|
258
|
-
}), c =
|
|
259
|
-
const
|
|
260
|
-
return a(
|
|
256
|
+
i && i(), i = Qe(h, r, s), a(i), c && c.forEach((u) => {
|
|
257
|
+
delete l[u];
|
|
258
|
+
}), c = d.data.methodNames;
|
|
259
|
+
const m = Ye(l, h, c, o, s);
|
|
260
|
+
return a(m), l;
|
|
261
261
|
};
|
|
262
|
-
},
|
|
263
|
-
if (!
|
|
262
|
+
}, We = (r, e, t, n) => (s) => {
|
|
263
|
+
if (!s.source)
|
|
264
264
|
return;
|
|
265
|
-
if (t !== "*" &&
|
|
266
|
-
r(`Parent: Handshake - Received SYN message from origin ${
|
|
265
|
+
if (t !== "*" && s.origin !== t) {
|
|
266
|
+
r(`Parent: Handshake - Received SYN message from origin ${s.origin} which did not match expected origin ${t}`);
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
269
269
|
r("Parent: Handshake - Received SYN, responding with SYN-ACK");
|
|
270
|
-
const
|
|
271
|
-
penpal:
|
|
270
|
+
const o = {
|
|
271
|
+
penpal: b.SynAck,
|
|
272
272
|
methodNames: Object.keys(e)
|
|
273
273
|
};
|
|
274
|
-
|
|
275
|
-
},
|
|
276
|
-
const { destroy: t, onDestroy: n } = e,
|
|
277
|
-
r.isConnected || (clearInterval(
|
|
278
|
-
},
|
|
274
|
+
s.source.postMessage(o, n);
|
|
275
|
+
}, He = 6e4, Ke = (r, e) => {
|
|
276
|
+
const { destroy: t, onDestroy: n } = e, s = setInterval(() => {
|
|
277
|
+
r.isConnected || (clearInterval(s), t());
|
|
278
|
+
}, He);
|
|
279
279
|
n(() => {
|
|
280
|
-
clearInterval(
|
|
280
|
+
clearInterval(s);
|
|
281
281
|
});
|
|
282
|
-
},
|
|
282
|
+
}, je = (r, e) => {
|
|
283
283
|
let t;
|
|
284
284
|
return r !== void 0 && (t = window.setTimeout(() => {
|
|
285
285
|
const n = new Error(`Connection timed out after ${r}ms`);
|
|
286
|
-
n.code =
|
|
286
|
+
n.code = N.ConnectionTimeout, e(n);
|
|
287
287
|
}, r)), () => {
|
|
288
288
|
clearTimeout(t);
|
|
289
289
|
};
|
|
290
|
-
},
|
|
290
|
+
}, qe = (r) => {
|
|
291
291
|
if (!r.src && !r.srcdoc) {
|
|
292
292
|
const e = new Error("Iframe must have src or srcdoc property defined.");
|
|
293
|
-
throw e.code =
|
|
293
|
+
throw e.code = N.NoIframeSrc, e;
|
|
294
294
|
}
|
|
295
|
-
},
|
|
296
|
-
let { iframe: e, methods: t = {}, childOrigin: n, timeout:
|
|
297
|
-
const a =
|
|
298
|
-
n || (
|
|
299
|
-
const
|
|
295
|
+
}, Xe = (r) => {
|
|
296
|
+
let { iframe: e, methods: t = {}, childOrigin: n, timeout: s, debug: o = !1 } = r;
|
|
297
|
+
const a = Se(o), i = Re("Parent", a), { onDestroy: c, destroy: l } = i;
|
|
298
|
+
n || (qe(e), n = Me(e.src));
|
|
299
|
+
const d = n === "null" ? "*" : n, h = se(t), m = We(a, h, n, d), u = Fe(h, n, d, i, a);
|
|
300
300
|
return {
|
|
301
301
|
promise: new Promise((k, y) => {
|
|
302
|
-
const I =
|
|
303
|
-
if (!(
|
|
304
|
-
if (
|
|
305
|
-
|
|
302
|
+
const I = je(s, l), w = (f) => {
|
|
303
|
+
if (!(f.source !== e.contentWindow || !f.data)) {
|
|
304
|
+
if (f.data.penpal === b.Syn) {
|
|
305
|
+
m(f);
|
|
306
306
|
return;
|
|
307
307
|
}
|
|
308
|
-
if (
|
|
309
|
-
const
|
|
310
|
-
|
|
308
|
+
if (f.data.penpal === b.Ack) {
|
|
309
|
+
const E = u(f);
|
|
310
|
+
E && (I(), k(E));
|
|
311
311
|
return;
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
};
|
|
315
|
-
window.addEventListener(A.Message,
|
|
316
|
-
window.removeEventListener(A.Message,
|
|
315
|
+
window.addEventListener(A.Message, w), a("Parent: Awaiting handshake"), Ke(e, i), c((f) => {
|
|
316
|
+
window.removeEventListener(A.Message, w), f && y(f);
|
|
317
317
|
});
|
|
318
318
|
}),
|
|
319
319
|
destroy() {
|
|
320
|
-
|
|
320
|
+
l();
|
|
321
321
|
}
|
|
322
322
|
};
|
|
323
323
|
};
|
|
324
|
-
class
|
|
324
|
+
class Ge {
|
|
325
325
|
url;
|
|
326
326
|
iframe;
|
|
327
327
|
container;
|
|
@@ -331,8 +331,8 @@ class se {
|
|
|
331
331
|
id: e,
|
|
332
332
|
url: t,
|
|
333
333
|
preset: n,
|
|
334
|
-
onClose:
|
|
335
|
-
onConnect:
|
|
334
|
+
onClose: s,
|
|
335
|
+
onConnect: o,
|
|
336
336
|
methods: a = {}
|
|
337
337
|
}) {
|
|
338
338
|
if (typeof document > "u" || typeof window > "u")
|
|
@@ -342,36 +342,28 @@ class se {
|
|
|
342
342
|
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");
|
|
343
343
|
const c = document.createElement("div");
|
|
344
344
|
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 = "flex", c.style.alignItems = "center", c.style.justifyContent = "center", c.style.visibility = "hidden", c.style.opacity = "0", c.style.transition = "opacity 0.2s ease", c.style.pointerEvents = "auto", c.appendChild(i), c.addEventListener("click", (h) => {
|
|
345
|
-
h.target === c && (e === "controller-keychain" && this.child && this.child.reset?.().catch((
|
|
346
|
-
}), this.iframe = i, this.container = c,
|
|
345
|
+
h.target === c && (e === "controller-keychain" && this.child && this.child.reset?.().catch((m) => console.error("Error resetting context:", m)), this.close());
|
|
346
|
+
}), this.iframe = i, this.container = c, Xe({
|
|
347
347
|
iframe: this.iframe,
|
|
348
348
|
methods: {
|
|
349
349
|
close: (h) => () => this.close(),
|
|
350
|
-
closeAll: (h) => () => {
|
|
351
|
-
document.querySelectorAll(
|
|
352
|
-
'iframe[id^="controller-"]'
|
|
353
|
-
).forEach((f) => {
|
|
354
|
-
const g = f.parentElement;
|
|
355
|
-
g && (g.style.visibility = "hidden", g.style.opacity = "0");
|
|
356
|
-
}), document.body && (document.body.style.overflow = "auto");
|
|
357
|
-
},
|
|
358
350
|
reload: (h) => () => window.location.reload(),
|
|
359
351
|
...a
|
|
360
352
|
}
|
|
361
353
|
}).promise.then((h) => {
|
|
362
|
-
this.child = h,
|
|
354
|
+
this.child = h, o(h);
|
|
363
355
|
}), this.resize(), window.addEventListener("resize", () => this.resize());
|
|
364
|
-
const
|
|
356
|
+
const l = new MutationObserver(() => {
|
|
365
357
|
if (typeof document > "u") return;
|
|
366
358
|
const h = document.getElementById("controller");
|
|
367
|
-
document.body &&
|
|
359
|
+
document.body && e === "controller-keychain" && !h && (document.body.appendChild(c), l.disconnect());
|
|
368
360
|
});
|
|
369
|
-
|
|
361
|
+
l.observe(document.documentElement, {
|
|
370
362
|
childList: !0,
|
|
371
363
|
subtree: !0
|
|
372
364
|
});
|
|
373
|
-
const
|
|
374
|
-
document.body &&
|
|
365
|
+
const d = document.getElementById("controller");
|
|
366
|
+
document.body && e === "controller-keychain" && !d && document.body.appendChild(c), this.onClose = s;
|
|
375
367
|
}
|
|
376
368
|
open() {
|
|
377
369
|
!this.container || typeof document > "u" || !document.body || (document.body.style.overflow = "hidden", this.container.style.visibility = "visible", this.container.style.opacity = "1");
|
|
@@ -394,19 +386,22 @@ class se {
|
|
|
394
386
|
this.iframe.style.height = "600px", this.iframe.style.width = "432px", this.iframe.style.borderRadius = "8px";
|
|
395
387
|
}
|
|
396
388
|
}
|
|
389
|
+
isOpen() {
|
|
390
|
+
return this.iframe?.style.display !== "none";
|
|
391
|
+
}
|
|
397
392
|
}
|
|
398
|
-
const
|
|
393
|
+
const Ve = "6.13.7";
|
|
399
394
|
function j(r, e, t) {
|
|
400
395
|
for (let n in e) {
|
|
401
|
-
let
|
|
402
|
-
Object.defineProperty(r, n, { enumerable: !0, value:
|
|
396
|
+
let s = e[n];
|
|
397
|
+
Object.defineProperty(r, n, { enumerable: !0, value: s, writable: !1 });
|
|
403
398
|
}
|
|
404
399
|
}
|
|
405
|
-
function
|
|
400
|
+
function C(r) {
|
|
406
401
|
if (r == null)
|
|
407
402
|
return "null";
|
|
408
403
|
if (Array.isArray(r))
|
|
409
|
-
return "[ " + r.map(
|
|
404
|
+
return "[ " + r.map(C).join(", ") + " ]";
|
|
410
405
|
if (r instanceof Uint8Array) {
|
|
411
406
|
const e = "0123456789abcdef";
|
|
412
407
|
let t = "0x";
|
|
@@ -415,7 +410,7 @@ function P(r) {
|
|
|
415
410
|
return t;
|
|
416
411
|
}
|
|
417
412
|
if (typeof r == "object" && typeof r.toJSON == "function")
|
|
418
|
-
return
|
|
413
|
+
return C(r.toJSON());
|
|
419
414
|
switch (typeof r) {
|
|
420
415
|
case "boolean":
|
|
421
416
|
case "symbol":
|
|
@@ -428,47 +423,47 @@ function P(r) {
|
|
|
428
423
|
return JSON.stringify(r);
|
|
429
424
|
case "object": {
|
|
430
425
|
const e = Object.keys(r);
|
|
431
|
-
return e.sort(), "{ " + e.map((t) => `${
|
|
426
|
+
return e.sort(), "{ " + e.map((t) => `${C(t)}: ${C(r[t])}`).join(", ") + " }";
|
|
432
427
|
}
|
|
433
428
|
}
|
|
434
429
|
return "[ COULD NOT SERIALIZE ]";
|
|
435
430
|
}
|
|
436
|
-
function
|
|
431
|
+
function Je(r, e, t) {
|
|
437
432
|
let n = r;
|
|
438
433
|
{
|
|
439
|
-
const
|
|
434
|
+
const o = [];
|
|
440
435
|
if (t) {
|
|
441
436
|
if ("message" in t || "code" in t || "name" in t)
|
|
442
|
-
throw new Error(`value will overwrite populated values: ${
|
|
437
|
+
throw new Error(`value will overwrite populated values: ${C(t)}`);
|
|
443
438
|
for (const a in t) {
|
|
444
439
|
if (a === "shortMessage")
|
|
445
440
|
continue;
|
|
446
441
|
const i = t[a];
|
|
447
|
-
|
|
442
|
+
o.push(a + "=" + C(i));
|
|
448
443
|
}
|
|
449
444
|
}
|
|
450
|
-
|
|
445
|
+
o.push(`code=${e}`), o.push(`version=${Ve}`), o.length && (r += " (" + o.join(", ") + ")");
|
|
451
446
|
}
|
|
452
|
-
let
|
|
447
|
+
let s;
|
|
453
448
|
switch (e) {
|
|
454
449
|
case "INVALID_ARGUMENT":
|
|
455
|
-
|
|
450
|
+
s = new TypeError(r);
|
|
456
451
|
break;
|
|
457
452
|
case "NUMERIC_FAULT":
|
|
458
453
|
case "BUFFER_OVERRUN":
|
|
459
|
-
|
|
454
|
+
s = new RangeError(r);
|
|
460
455
|
break;
|
|
461
456
|
default:
|
|
462
|
-
|
|
457
|
+
s = new Error(r);
|
|
463
458
|
}
|
|
464
|
-
return j(
|
|
459
|
+
return j(s, { code: e }), t && Object.assign(s, t), s.shortMessage == null && j(s, { shortMessage: n }), s;
|
|
465
460
|
}
|
|
466
|
-
function
|
|
461
|
+
function Ze(r, e, t, n) {
|
|
467
462
|
if (!r)
|
|
468
|
-
throw
|
|
463
|
+
throw Je(e, t, n);
|
|
469
464
|
}
|
|
470
|
-
function
|
|
471
|
-
|
|
465
|
+
function D(r, e, t, n) {
|
|
466
|
+
Ze(r, e, "INVALID_ARGUMENT", { argument: t, value: n });
|
|
472
467
|
}
|
|
473
468
|
["NFD", "NFC", "NFKD", "NFKC"].reduce((r, e) => {
|
|
474
469
|
try {
|
|
@@ -481,28 +476,28 @@ function N(r, e, t, n) {
|
|
|
481
476
|
}
|
|
482
477
|
return r;
|
|
483
478
|
}, []);
|
|
484
|
-
function
|
|
479
|
+
function et(r, e, t) {
|
|
485
480
|
if (r instanceof Uint8Array)
|
|
486
481
|
return r;
|
|
487
482
|
if (typeof r == "string" && r.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
|
|
488
483
|
const n = new Uint8Array((r.length - 2) / 2);
|
|
489
|
-
let
|
|
490
|
-
for (let
|
|
491
|
-
n[
|
|
484
|
+
let s = 2;
|
|
485
|
+
for (let o = 0; o < n.length; o++)
|
|
486
|
+
n[o] = parseInt(r.substring(s, s + 2), 16), s += 2;
|
|
492
487
|
return n;
|
|
493
488
|
}
|
|
494
|
-
|
|
489
|
+
D(!1, "invalid BytesLike value", e || "value", r);
|
|
495
490
|
}
|
|
496
491
|
function O(r, e) {
|
|
497
|
-
return
|
|
492
|
+
return et(r, e);
|
|
498
493
|
}
|
|
499
494
|
const q = "0123456789abcdef";
|
|
500
|
-
function
|
|
495
|
+
function tt(r) {
|
|
501
496
|
const e = O(r);
|
|
502
497
|
let t = "0x";
|
|
503
498
|
for (let n = 0; n < e.length; n++) {
|
|
504
|
-
const
|
|
505
|
-
t += q[(
|
|
499
|
+
const s = e[n];
|
|
500
|
+
t += q[(s & 240) >> 4] + q[s & 15];
|
|
506
501
|
}
|
|
507
502
|
return t;
|
|
508
503
|
}
|
|
@@ -510,7 +505,7 @@ function X(r) {
|
|
|
510
505
|
if (!Number.isSafeInteger(r) || r < 0)
|
|
511
506
|
throw new Error(`Wrong positive integer: ${r}`);
|
|
512
507
|
}
|
|
513
|
-
function
|
|
508
|
+
function oe(r, ...e) {
|
|
514
509
|
if (!(r instanceof Uint8Array))
|
|
515
510
|
throw new Error("Expected Uint8Array");
|
|
516
511
|
if (e.length > 0 && !e.includes(r.length))
|
|
@@ -522,71 +517,71 @@ function G(r, e = !0) {
|
|
|
522
517
|
if (e && r.finished)
|
|
523
518
|
throw new Error("Hash#digest() has already been called");
|
|
524
519
|
}
|
|
525
|
-
function
|
|
526
|
-
|
|
520
|
+
function rt(r, e) {
|
|
521
|
+
oe(r);
|
|
527
522
|
const t = e.outputLen;
|
|
528
523
|
if (r.length < t)
|
|
529
524
|
throw new Error(`digestInto() expects output buffer of length at least ${t}`);
|
|
530
525
|
}
|
|
531
526
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
532
|
-
const
|
|
533
|
-
if (!
|
|
527
|
+
const nt = (r) => r instanceof Uint8Array, st = (r) => new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4)), ot = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
528
|
+
if (!ot)
|
|
534
529
|
throw new Error("Non little-endian hardware is not supported");
|
|
535
|
-
function
|
|
530
|
+
function at(r) {
|
|
536
531
|
if (typeof r != "string")
|
|
537
532
|
throw new Error(`utf8ToBytes expected string, got ${typeof r}`);
|
|
538
533
|
return new Uint8Array(new TextEncoder().encode(r));
|
|
539
534
|
}
|
|
540
|
-
function
|
|
541
|
-
if (typeof r == "string" && (r =
|
|
535
|
+
function ae(r) {
|
|
536
|
+
if (typeof r == "string" && (r = at(r)), !nt(r))
|
|
542
537
|
throw new Error(`expected Uint8Array, got ${typeof r}`);
|
|
543
538
|
return r;
|
|
544
539
|
}
|
|
545
|
-
class
|
|
540
|
+
class it {
|
|
546
541
|
// Safe version that clones internal state
|
|
547
542
|
clone() {
|
|
548
543
|
return this._cloneInto();
|
|
549
544
|
}
|
|
550
545
|
}
|
|
551
|
-
function
|
|
552
|
-
const e = (n) => r().update(
|
|
546
|
+
function ct(r) {
|
|
547
|
+
const e = (n) => r().update(ae(n)).digest(), t = r();
|
|
553
548
|
return e.outputLen = t.outputLen, e.blockLen = t.blockLen, e.create = () => r(), e;
|
|
554
549
|
}
|
|
555
550
|
const B = /* @__PURE__ */ BigInt(2 ** 32 - 1), V = /* @__PURE__ */ BigInt(32);
|
|
556
|
-
function
|
|
551
|
+
function lt(r, e = !1) {
|
|
557
552
|
return e ? { h: Number(r & B), l: Number(r >> V & B) } : { h: Number(r >> V & B) | 0, l: Number(r & B) | 0 };
|
|
558
553
|
}
|
|
559
|
-
function
|
|
554
|
+
function dt(r, e = !1) {
|
|
560
555
|
let t = new Uint32Array(r.length), n = new Uint32Array(r.length);
|
|
561
|
-
for (let
|
|
562
|
-
const { h:
|
|
563
|
-
[t[
|
|
556
|
+
for (let s = 0; s < r.length; s++) {
|
|
557
|
+
const { h: o, l: a } = lt(r[s], e);
|
|
558
|
+
[t[s], n[s]] = [o, a];
|
|
564
559
|
}
|
|
565
560
|
return [t, n];
|
|
566
561
|
}
|
|
567
|
-
const
|
|
568
|
-
for (let r = 0, e =
|
|
569
|
-
[t, n] = [n, (2 * t + 3 * n) % 5],
|
|
570
|
-
let
|
|
571
|
-
for (let
|
|
572
|
-
e = (e <<
|
|
573
|
-
|
|
562
|
+
const ht = (r, e, t) => r << t | e >>> 32 - t, ut = (r, e, t) => e << t | r >>> 32 - t, ft = (r, e, t) => e << t - 32 | r >>> 64 - t, pt = (r, e, t) => r << t - 32 | e >>> 64 - t, [ie, ce, le] = [[], [], []], gt = /* @__PURE__ */ BigInt(0), P = /* @__PURE__ */ BigInt(1), mt = /* @__PURE__ */ BigInt(2), yt = /* @__PURE__ */ BigInt(7), bt = /* @__PURE__ */ BigInt(256), wt = /* @__PURE__ */ BigInt(113);
|
|
563
|
+
for (let r = 0, e = P, t = 1, n = 0; r < 24; r++) {
|
|
564
|
+
[t, n] = [n, (2 * t + 3 * n) % 5], ie.push(2 * (5 * n + t)), ce.push((r + 1) * (r + 2) / 2 % 64);
|
|
565
|
+
let s = gt;
|
|
566
|
+
for (let o = 0; o < 7; o++)
|
|
567
|
+
e = (e << P ^ (e >> yt) * wt) % bt, e & mt && (s ^= P << (P << /* @__PURE__ */ BigInt(o)) - P);
|
|
568
|
+
le.push(s);
|
|
574
569
|
}
|
|
575
|
-
const [
|
|
576
|
-
function
|
|
570
|
+
const [_t, kt] = /* @__PURE__ */ dt(le, !0), J = (r, e, t) => t > 32 ? ft(r, e, t) : ht(r, e, t), Z = (r, e, t) => t > 32 ? pt(r, e, t) : ut(r, e, t);
|
|
571
|
+
function At(r, e = 24) {
|
|
577
572
|
const t = new Uint32Array(10);
|
|
578
573
|
for (let n = 24 - e; n < 24; n++) {
|
|
579
574
|
for (let a = 0; a < 10; a++)
|
|
580
575
|
t[a] = r[a] ^ r[a + 10] ^ r[a + 20] ^ r[a + 30] ^ r[a + 40];
|
|
581
576
|
for (let a = 0; a < 10; a += 2) {
|
|
582
|
-
const i = (a + 8) % 10, c = (a + 2) % 10,
|
|
583
|
-
for (let
|
|
584
|
-
r[a +
|
|
577
|
+
const i = (a + 8) % 10, c = (a + 2) % 10, l = t[c], d = t[c + 1], h = J(l, d, 1) ^ t[i], m = Z(l, d, 1) ^ t[i + 1];
|
|
578
|
+
for (let u = 0; u < 50; u += 10)
|
|
579
|
+
r[a + u] ^= h, r[a + u + 1] ^= m;
|
|
585
580
|
}
|
|
586
|
-
let
|
|
581
|
+
let s = r[2], o = r[3];
|
|
587
582
|
for (let a = 0; a < 24; a++) {
|
|
588
|
-
const i =
|
|
589
|
-
|
|
583
|
+
const i = ce[a], c = J(s, o, i), l = Z(s, o, i), d = ie[a];
|
|
584
|
+
s = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
|
|
590
585
|
}
|
|
591
586
|
for (let a = 0; a < 50; a += 10) {
|
|
592
587
|
for (let i = 0; i < 10; i++)
|
|
@@ -594,29 +589,29 @@ function It(r, e = 24) {
|
|
|
594
589
|
for (let i = 0; i < 10; i++)
|
|
595
590
|
r[a + i] ^= ~t[(i + 2) % 10] & t[(i + 4) % 10];
|
|
596
591
|
}
|
|
597
|
-
r[0] ^=
|
|
592
|
+
r[0] ^= _t[n], r[1] ^= kt[n];
|
|
598
593
|
}
|
|
599
594
|
t.fill(0);
|
|
600
595
|
}
|
|
601
|
-
class L extends
|
|
596
|
+
class L extends it {
|
|
602
597
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
603
|
-
constructor(e, t, n,
|
|
604
|
-
if (super(), this.blockLen = e, this.suffix = t, this.outputLen = n, this.enableXOF =
|
|
598
|
+
constructor(e, t, n, s = !1, o = 24) {
|
|
599
|
+
if (super(), this.blockLen = e, this.suffix = t, this.outputLen = n, this.enableXOF = s, this.rounds = o, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, X(n), 0 >= this.blockLen || this.blockLen >= 200)
|
|
605
600
|
throw new Error("Sha3 supports only keccak-f1600 function");
|
|
606
601
|
this.state = new Uint8Array(200), this.state32 = st(this.state);
|
|
607
602
|
}
|
|
608
603
|
keccak() {
|
|
609
|
-
|
|
604
|
+
At(this.state32, this.rounds), this.posOut = 0, this.pos = 0;
|
|
610
605
|
}
|
|
611
606
|
update(e) {
|
|
612
607
|
G(this);
|
|
613
608
|
const { blockLen: t, state: n } = this;
|
|
614
|
-
e =
|
|
615
|
-
const
|
|
616
|
-
for (let
|
|
617
|
-
const a = Math.min(t - this.pos,
|
|
609
|
+
e = ae(e);
|
|
610
|
+
const s = e.length;
|
|
611
|
+
for (let o = 0; o < s; ) {
|
|
612
|
+
const a = Math.min(t - this.pos, s - o);
|
|
618
613
|
for (let i = 0; i < a; i++)
|
|
619
|
-
n[this.pos++] ^= e[
|
|
614
|
+
n[this.pos++] ^= e[o++];
|
|
620
615
|
this.pos === t && this.keccak();
|
|
621
616
|
}
|
|
622
617
|
return this;
|
|
@@ -625,16 +620,16 @@ class L extends ct {
|
|
|
625
620
|
if (this.finished)
|
|
626
621
|
return;
|
|
627
622
|
this.finished = !0;
|
|
628
|
-
const { state: e, suffix: t, pos: n, blockLen:
|
|
629
|
-
e[n] ^= t, (t & 128) !== 0 && n ===
|
|
623
|
+
const { state: e, suffix: t, pos: n, blockLen: s } = this;
|
|
624
|
+
e[n] ^= t, (t & 128) !== 0 && n === s - 1 && this.keccak(), e[s - 1] ^= 128, this.keccak();
|
|
630
625
|
}
|
|
631
626
|
writeInto(e) {
|
|
632
|
-
G(this, !1),
|
|
627
|
+
G(this, !1), oe(e), this.finish();
|
|
633
628
|
const t = this.state, { blockLen: n } = this;
|
|
634
|
-
for (let
|
|
629
|
+
for (let s = 0, o = e.length; s < o; ) {
|
|
635
630
|
this.posOut >= n && this.keccak();
|
|
636
|
-
const a = Math.min(n - this.posOut,
|
|
637
|
-
e.set(t.subarray(this.posOut, this.posOut + a),
|
|
631
|
+
const a = Math.min(n - this.posOut, o - s);
|
|
632
|
+
e.set(t.subarray(this.posOut, this.posOut + a), s), this.posOut += a, s += a;
|
|
638
633
|
}
|
|
639
634
|
return e;
|
|
640
635
|
}
|
|
@@ -647,7 +642,7 @@ class L extends ct {
|
|
|
647
642
|
return X(e), this.xofInto(new Uint8Array(e));
|
|
648
643
|
}
|
|
649
644
|
digestInto(e) {
|
|
650
|
-
if (
|
|
645
|
+
if (rt(e, this), this.finished)
|
|
651
646
|
throw new Error("digest() was already called");
|
|
652
647
|
return this.writeInto(e), this.destroy(), e;
|
|
653
648
|
}
|
|
@@ -658,39 +653,39 @@ class L extends ct {
|
|
|
658
653
|
this.destroyed = !0, this.state.fill(0);
|
|
659
654
|
}
|
|
660
655
|
_cloneInto(e) {
|
|
661
|
-
const { blockLen: t, suffix: n, outputLen:
|
|
662
|
-
return e || (e = new L(t, n,
|
|
656
|
+
const { blockLen: t, suffix: n, outputLen: s, rounds: o, enableXOF: a } = this;
|
|
657
|
+
return e || (e = new L(t, n, s, a, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = n, e.outputLen = s, e.enableXOF = a, e.destroyed = this.destroyed, e;
|
|
663
658
|
}
|
|
664
659
|
}
|
|
665
|
-
const
|
|
666
|
-
let
|
|
667
|
-
const
|
|
668
|
-
return
|
|
660
|
+
const It = (r, e, t) => ct(() => new L(e, r, t)), vt = /* @__PURE__ */ It(1, 136, 256 / 8);
|
|
661
|
+
let de = !1;
|
|
662
|
+
const he = function(r) {
|
|
663
|
+
return vt(r);
|
|
669
664
|
};
|
|
670
|
-
let ue =
|
|
665
|
+
let ue = he;
|
|
671
666
|
function M(r) {
|
|
672
667
|
const e = O(r, "data");
|
|
673
|
-
return
|
|
668
|
+
return tt(ue(e));
|
|
674
669
|
}
|
|
675
|
-
M._ =
|
|
670
|
+
M._ = he;
|
|
676
671
|
M.lock = function() {
|
|
677
|
-
|
|
672
|
+
de = !0;
|
|
678
673
|
};
|
|
679
674
|
M.register = function(r) {
|
|
680
|
-
if (
|
|
675
|
+
if (de)
|
|
681
676
|
throw new TypeError("keccak256 is locked");
|
|
682
677
|
ue = r;
|
|
683
678
|
};
|
|
684
679
|
Object.freeze(M);
|
|
685
|
-
const
|
|
680
|
+
const Et = BigInt(0), xt = BigInt(36);
|
|
686
681
|
function ee(r) {
|
|
687
682
|
r = r.toLowerCase();
|
|
688
683
|
const e = r.substring(2).split(""), t = new Uint8Array(40);
|
|
689
|
-
for (let
|
|
690
|
-
t[
|
|
684
|
+
for (let s = 0; s < 40; s++)
|
|
685
|
+
t[s] = e[s].charCodeAt(0);
|
|
691
686
|
const n = O(M(t));
|
|
692
|
-
for (let
|
|
693
|
-
n[
|
|
687
|
+
for (let s = 0; s < 40; s += 2)
|
|
688
|
+
n[s >> 1] >> 4 >= 8 && (e[s] = e[s].toUpperCase()), (n[s >> 1] & 15) >= 8 && (e[s + 1] = e[s + 1].toUpperCase());
|
|
694
689
|
return "0x" + e.join("");
|
|
695
690
|
}
|
|
696
691
|
const Y = {};
|
|
@@ -699,7 +694,7 @@ for (let r = 0; r < 10; r++)
|
|
|
699
694
|
for (let r = 0; r < 26; r++)
|
|
700
695
|
Y[String.fromCharCode(65 + r)] = String(10 + r);
|
|
701
696
|
const te = 15;
|
|
702
|
-
function
|
|
697
|
+
function Ct(r) {
|
|
703
698
|
r = r.toUpperCase(), r = r.substring(4) + r.substring(0, 2) + "00";
|
|
704
699
|
let e = r.split("").map((n) => Y[n]).join("");
|
|
705
700
|
for (; e.length >= te; ) {
|
|
@@ -721,27 +716,27 @@ const Rt = function() {
|
|
|
721
716
|
}();
|
|
722
717
|
function St(r) {
|
|
723
718
|
r = r.toLowerCase();
|
|
724
|
-
let e =
|
|
719
|
+
let e = Et;
|
|
725
720
|
for (let t = 0; t < r.length; t++)
|
|
726
|
-
e = e *
|
|
721
|
+
e = e * xt + Rt[r[t]];
|
|
727
722
|
return e;
|
|
728
723
|
}
|
|
729
|
-
function
|
|
730
|
-
if (
|
|
724
|
+
function g(r) {
|
|
725
|
+
if (D(typeof r == "string", "invalid address", "address", r), r.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
|
|
731
726
|
r.startsWith("0x") || (r = "0x" + r);
|
|
732
727
|
const e = ee(r);
|
|
733
|
-
return
|
|
728
|
+
return D(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || e === r, "bad address checksum", "address", r), e;
|
|
734
729
|
}
|
|
735
730
|
if (r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
|
736
|
-
|
|
731
|
+
D(r.substring(2, 4) === Ct(r), "bad icap checksum", "address", r);
|
|
737
732
|
let e = St(r.substring(4)).toString(16);
|
|
738
733
|
for (; e.length < 40; )
|
|
739
734
|
e = "0" + e;
|
|
740
735
|
return ee("0x" + e);
|
|
741
736
|
}
|
|
742
|
-
|
|
737
|
+
D(!1, "invalid address", "address", r);
|
|
743
738
|
}
|
|
744
|
-
class
|
|
739
|
+
class Pt {
|
|
745
740
|
type = "argent";
|
|
746
741
|
platform = "starknet";
|
|
747
742
|
wallet = void 0;
|
|
@@ -767,8 +762,8 @@ class Nt {
|
|
|
767
762
|
try {
|
|
768
763
|
if (!this.isAvailable())
|
|
769
764
|
throw new Error("Argent is not available");
|
|
770
|
-
const { wallet: e, connectorData: t } = await
|
|
771
|
-
connectors: [new
|
|
765
|
+
const { wallet: e, connectorData: t } = await ve({
|
|
766
|
+
connectors: [new Ee({ options: { id: "argentX" } })]
|
|
772
767
|
});
|
|
773
768
|
if (!e)
|
|
774
769
|
throw new Error("No wallet found");
|
|
@@ -837,11 +832,11 @@ function Dt(r) {
|
|
|
837
832
|
const e = (t) => r(t.detail);
|
|
838
833
|
return window.addEventListener("eip6963:announceProvider", e), window.dispatchEvent(new CustomEvent("eip6963:requestProvider")), () => window.removeEventListener("eip6963:announceProvider", e);
|
|
839
834
|
}
|
|
840
|
-
function
|
|
835
|
+
function fe() {
|
|
841
836
|
const r = /* @__PURE__ */ new Set();
|
|
842
837
|
let e = [];
|
|
843
|
-
const t = () => Dt((
|
|
844
|
-
e.some(({ info:
|
|
838
|
+
const t = () => Dt((s) => {
|
|
839
|
+
e.some(({ info: o }) => o.uuid === s.info.uuid) || (e = [...e, s], r.forEach((o) => o(e, { added: [s] })));
|
|
845
840
|
});
|
|
846
841
|
let n = t();
|
|
847
842
|
return {
|
|
@@ -849,13 +844,13 @@ function pe() {
|
|
|
849
844
|
return r;
|
|
850
845
|
},
|
|
851
846
|
clear() {
|
|
852
|
-
r.forEach((
|
|
847
|
+
r.forEach((s) => s([], { removed: [...e] })), e = [];
|
|
853
848
|
},
|
|
854
849
|
destroy() {
|
|
855
850
|
this.clear(), r.clear(), n?.();
|
|
856
851
|
},
|
|
857
|
-
findProvider({ rdns:
|
|
858
|
-
return e.find((
|
|
852
|
+
findProvider({ rdns: s }) {
|
|
853
|
+
return e.find((o) => o.info.rdns === s);
|
|
859
854
|
},
|
|
860
855
|
getProviders() {
|
|
861
856
|
return e;
|
|
@@ -863,20 +858,20 @@ function pe() {
|
|
|
863
858
|
reset() {
|
|
864
859
|
this.clear(), n?.(), n = t();
|
|
865
860
|
},
|
|
866
|
-
subscribe(
|
|
867
|
-
return r.add(
|
|
861
|
+
subscribe(s, { emitImmediately: o } = {}) {
|
|
862
|
+
return r.add(s), o && s(e, { added: e }), () => r.delete(s);
|
|
868
863
|
}
|
|
869
864
|
};
|
|
870
865
|
}
|
|
871
|
-
class
|
|
866
|
+
class Nt {
|
|
872
867
|
type = "metamask";
|
|
873
868
|
platform = "ethereum";
|
|
874
869
|
MMSDK;
|
|
875
|
-
store =
|
|
870
|
+
store = fe();
|
|
876
871
|
account = void 0;
|
|
877
872
|
connectedAccounts = [];
|
|
878
873
|
constructor() {
|
|
879
|
-
this.MMSDK = new
|
|
874
|
+
this.MMSDK = new xe({
|
|
880
875
|
dappMetadata: {
|
|
881
876
|
name: "Cartridge Controller",
|
|
882
877
|
url: window.location.href
|
|
@@ -885,9 +880,9 @@ class Mt {
|
|
|
885
880
|
this.MMSDK.getProvider()?.request({
|
|
886
881
|
method: "eth_accounts"
|
|
887
882
|
}).then((e) => {
|
|
888
|
-
e && e.length > 0 && (this.account =
|
|
883
|
+
e && e.length > 0 && (this.account = g(e[0]), this.connectedAccounts = e.map(g));
|
|
889
884
|
}), this.MMSDK.getProvider()?.on("accountsChanged", (e) => {
|
|
890
|
-
Array.isArray(e) && e.length > 0 && (this.account =
|
|
885
|
+
Array.isArray(e) && e.length > 0 && (this.account = g(e?.[0]), this.connectedAccounts = e.map(g));
|
|
891
886
|
});
|
|
892
887
|
});
|
|
893
888
|
}
|
|
@@ -914,8 +909,8 @@ class Mt {
|
|
|
914
909
|
throw new Error("MetaMask is not available");
|
|
915
910
|
const e = await this.MMSDK.connect();
|
|
916
911
|
if (e && e.length > 0)
|
|
917
|
-
return this.account =
|
|
918
|
-
(t) =>
|
|
912
|
+
return this.account = g(e[0]), this.connectedAccounts = e.map(
|
|
913
|
+
(t) => g(t)
|
|
919
914
|
), { success: !0, wallet: this.type, account: this.account };
|
|
920
915
|
throw new Error("No accounts found");
|
|
921
916
|
} catch (e) {
|
|
@@ -1041,7 +1036,7 @@ class Mt {
|
|
|
1041
1036
|
}
|
|
1042
1037
|
}
|
|
1043
1038
|
}
|
|
1044
|
-
class
|
|
1039
|
+
class Mt {
|
|
1045
1040
|
type = "phantom";
|
|
1046
1041
|
platform = "solana";
|
|
1047
1042
|
account = void 0;
|
|
@@ -1109,11 +1104,11 @@ class Bt {
|
|
|
1109
1104
|
if (!this.isAvailable() || !this.account)
|
|
1110
1105
|
throw new Error("Phantom is not connected");
|
|
1111
1106
|
try {
|
|
1112
|
-
const t =
|
|
1107
|
+
const t = Ce.from(e), s = await this.getProvider().signAndSendTransaction(t);
|
|
1113
1108
|
return {
|
|
1114
1109
|
success: !0,
|
|
1115
1110
|
wallet: this.type,
|
|
1116
|
-
result:
|
|
1111
|
+
result: s
|
|
1117
1112
|
};
|
|
1118
1113
|
} catch (t) {
|
|
1119
1114
|
return console.error("Error sending transaction with Phantom:", t), {
|
|
@@ -1144,21 +1139,21 @@ class Bt {
|
|
|
1144
1139
|
}
|
|
1145
1140
|
}
|
|
1146
1141
|
}
|
|
1147
|
-
const
|
|
1142
|
+
const Bt = "io.rabby";
|
|
1148
1143
|
class Qt {
|
|
1149
1144
|
type = "rabby";
|
|
1150
1145
|
platform = "ethereum";
|
|
1151
1146
|
account = void 0;
|
|
1152
|
-
store =
|
|
1147
|
+
store = fe();
|
|
1153
1148
|
provider;
|
|
1154
1149
|
connectedAccounts = [];
|
|
1155
1150
|
constructor() {
|
|
1156
|
-
this.provider = this.store.getProviders().find((e) => e.info.rdns ===
|
|
1151
|
+
this.provider = this.store.getProviders().find((e) => e.info.rdns === Bt), this.provider?.provider.request({
|
|
1157
1152
|
method: "eth_accounts"
|
|
1158
1153
|
}).then((e) => {
|
|
1159
|
-
this.connectedAccounts = e.map(
|
|
1154
|
+
this.connectedAccounts = e.map(g), e.length > 0 && (this.account = g(e?.[0]));
|
|
1160
1155
|
}), this.provider?.provider?.on("accountsChanged", (e) => {
|
|
1161
|
-
e && (this.connectedAccounts = e.map((t) =>
|
|
1156
|
+
e && (this.connectedAccounts = e.map((t) => g(t)), this.account = g(e?.[0]));
|
|
1162
1157
|
});
|
|
1163
1158
|
}
|
|
1164
1159
|
isAvailable() {
|
|
@@ -1177,7 +1172,7 @@ class Qt {
|
|
|
1177
1172
|
};
|
|
1178
1173
|
}
|
|
1179
1174
|
async connect(e) {
|
|
1180
|
-
if (e && this.connectedAccounts.includes(
|
|
1175
|
+
if (e && this.connectedAccounts.includes(g(e)) && (this.account = g(e)), this.account)
|
|
1181
1176
|
return { success: !0, wallet: this.type, account: this.account };
|
|
1182
1177
|
try {
|
|
1183
1178
|
if (!this.isAvailable())
|
|
@@ -1186,7 +1181,7 @@ class Qt {
|
|
|
1186
1181
|
method: "eth_requestAccounts"
|
|
1187
1182
|
});
|
|
1188
1183
|
if (t && t.length > 0)
|
|
1189
|
-
return this.account =
|
|
1184
|
+
return this.account = g(t[0]), this.connectedAccounts = t.map(g), { success: !0, wallet: this.type, account: this.account };
|
|
1190
1185
|
throw new Error("No accounts found");
|
|
1191
1186
|
} catch (t) {
|
|
1192
1187
|
return console.error("Error connecting to Rabby:", t), {
|
|
@@ -1311,19 +1306,19 @@ class Qt {
|
|
|
1311
1306
|
}
|
|
1312
1307
|
}
|
|
1313
1308
|
}
|
|
1314
|
-
class
|
|
1309
|
+
class Ut {
|
|
1315
1310
|
walletAdapters;
|
|
1316
1311
|
constructor() {
|
|
1317
1312
|
if (this.walletAdapters = /* @__PURE__ */ new Map(), typeof window > "u")
|
|
1318
1313
|
return;
|
|
1319
|
-
const e = new
|
|
1314
|
+
const e = new Nt();
|
|
1320
1315
|
e.isAvailable() && this.walletAdapters.set("metamask", e);
|
|
1321
|
-
const t = new
|
|
1316
|
+
const t = new Mt();
|
|
1322
1317
|
t.isAvailable() && this.walletAdapters.set("phantom", t);
|
|
1323
|
-
const n = new
|
|
1318
|
+
const n = new Pt();
|
|
1324
1319
|
n.isAvailable() && this.walletAdapters.set("argent", n);
|
|
1325
|
-
const
|
|
1326
|
-
|
|
1320
|
+
const s = new Qt();
|
|
1321
|
+
s.isAvailable() && this.walletAdapters.set("rabby", s), window.wallet_bridge = this;
|
|
1327
1322
|
}
|
|
1328
1323
|
getIFrameMethods() {
|
|
1329
1324
|
return {
|
|
@@ -1346,18 +1341,18 @@ class Tt {
|
|
|
1346
1341
|
throw new Error(`Unsupported wallet type: ${e}`);
|
|
1347
1342
|
return t;
|
|
1348
1343
|
}
|
|
1349
|
-
handleError(e, t, n,
|
|
1350
|
-
const
|
|
1344
|
+
handleError(e, t, n, s) {
|
|
1345
|
+
const o = t instanceof Error ? t.message : "Unknown error";
|
|
1351
1346
|
let a = "unknown";
|
|
1352
1347
|
if (typeof e == "string") {
|
|
1353
1348
|
const i = this.getConnectedWalletAdapter(e);
|
|
1354
|
-
a =
|
|
1349
|
+
a = s ?? i?.type ?? e;
|
|
1355
1350
|
} else
|
|
1356
1351
|
a = e;
|
|
1357
1352
|
return console.error(`Error ${n} with ${e} wallet:`, t), {
|
|
1358
1353
|
success: !1,
|
|
1359
1354
|
wallet: a,
|
|
1360
|
-
error:
|
|
1355
|
+
error: o
|
|
1361
1356
|
};
|
|
1362
1357
|
}
|
|
1363
1358
|
async connectWallet(e) {
|
|
@@ -1383,8 +1378,8 @@ class Tt {
|
|
|
1383
1378
|
getConnectedWalletAdapter(e) {
|
|
1384
1379
|
let t;
|
|
1385
1380
|
if (typeof e == "string") {
|
|
1386
|
-
const n =
|
|
1387
|
-
t = this.walletAdapters.values().find((
|
|
1381
|
+
const n = g(e);
|
|
1382
|
+
t = this.walletAdapters.values().find((s) => s.getConnectedAccounts().includes(n));
|
|
1388
1383
|
} else
|
|
1389
1384
|
t = this.walletAdapters.get(e);
|
|
1390
1385
|
if (!t)
|
|
@@ -1401,10 +1396,10 @@ class Tt {
|
|
|
1401
1396
|
`Wallet type ${n.type} (identifier: ${e}) does not support signing messages`
|
|
1402
1397
|
);
|
|
1403
1398
|
return await n.signMessage(t, e);
|
|
1404
|
-
} catch (
|
|
1399
|
+
} catch (s) {
|
|
1405
1400
|
return this.handleError(
|
|
1406
1401
|
e,
|
|
1407
|
-
|
|
1402
|
+
s,
|
|
1408
1403
|
"signing message with",
|
|
1409
1404
|
n?.type
|
|
1410
1405
|
);
|
|
@@ -1418,10 +1413,10 @@ class Tt {
|
|
|
1418
1413
|
`Wallet type ${n.type} (identifier: ${e}) does not support signing typed data`
|
|
1419
1414
|
);
|
|
1420
1415
|
return await n.signTypedData(t);
|
|
1421
|
-
} catch (
|
|
1416
|
+
} catch (s) {
|
|
1422
1417
|
return this.handleError(
|
|
1423
1418
|
e,
|
|
1424
|
-
|
|
1419
|
+
s,
|
|
1425
1420
|
"signing typed data with",
|
|
1426
1421
|
n?.type
|
|
1427
1422
|
);
|
|
@@ -1431,10 +1426,10 @@ class Tt {
|
|
|
1431
1426
|
let n;
|
|
1432
1427
|
try {
|
|
1433
1428
|
return n = this.getConnectedWalletAdapter(e), await n.sendTransaction(t);
|
|
1434
|
-
} catch (
|
|
1429
|
+
} catch (s) {
|
|
1435
1430
|
return this.handleError(
|
|
1436
1431
|
e,
|
|
1437
|
-
|
|
1432
|
+
s,
|
|
1438
1433
|
"sending transaction with",
|
|
1439
1434
|
n?.type
|
|
1440
1435
|
);
|
|
@@ -1444,67 +1439,47 @@ class Tt {
|
|
|
1444
1439
|
let n;
|
|
1445
1440
|
try {
|
|
1446
1441
|
return n = this.getConnectedWalletAdapter(e), await n.getBalance(t);
|
|
1447
|
-
} catch (
|
|
1442
|
+
} catch (s) {
|
|
1448
1443
|
return this.handleError(
|
|
1449
1444
|
e,
|
|
1450
|
-
|
|
1445
|
+
s,
|
|
1451
1446
|
"getting balance from",
|
|
1452
1447
|
n?.type
|
|
1453
1448
|
);
|
|
1454
1449
|
}
|
|
1455
1450
|
}
|
|
1456
1451
|
}
|
|
1457
|
-
class
|
|
1452
|
+
class Tt extends Ge {
|
|
1458
1453
|
walletBridge;
|
|
1459
1454
|
constructor({
|
|
1460
1455
|
url: e,
|
|
1461
1456
|
policies: t,
|
|
1462
1457
|
version: n,
|
|
1463
|
-
|
|
1458
|
+
slot: s,
|
|
1459
|
+
namespace: o,
|
|
1460
|
+
tokens: a,
|
|
1461
|
+
...i
|
|
1464
1462
|
}) {
|
|
1465
|
-
const
|
|
1466
|
-
t &&
|
|
1463
|
+
const c = new URL(e ?? we), l = new Ut();
|
|
1464
|
+
t && c.searchParams.set(
|
|
1467
1465
|
"policies",
|
|
1468
1466
|
encodeURIComponent(JSON.stringify(t))
|
|
1469
|
-
), n &&
|
|
1470
|
-
|
|
1467
|
+
), n && c.searchParams.set("v", encodeURIComponent(n)), s && c.searchParams.set("ps", encodeURIComponent(s)), o && c.searchParams.set("ns", encodeURIComponent(o)), a?.erc20 && c.searchParams.set(
|
|
1468
|
+
"erc20",
|
|
1469
|
+
encodeURIComponent(a.erc20.toString())
|
|
1470
|
+
), super({
|
|
1471
|
+
...i,
|
|
1471
1472
|
id: "controller-keychain",
|
|
1472
|
-
url:
|
|
1473
|
-
methods:
|
|
1474
|
-
}), this.walletBridge =
|
|
1473
|
+
url: c,
|
|
1474
|
+
methods: l.getIFrameMethods()
|
|
1475
|
+
}), this.walletBridge = l, typeof window < "u" && (window.external_wallets = this.walletBridge);
|
|
1475
1476
|
}
|
|
1476
1477
|
getWalletBridge() {
|
|
1477
1478
|
return this.walletBridge;
|
|
1478
1479
|
}
|
|
1479
1480
|
}
|
|
1480
|
-
class
|
|
1481
|
-
constructor({
|
|
1482
|
-
profileUrl: e,
|
|
1483
|
-
rpcUrl: t,
|
|
1484
|
-
version: n,
|
|
1485
|
-
username: o,
|
|
1486
|
-
slot: s,
|
|
1487
|
-
namespace: a,
|
|
1488
|
-
tokens: i,
|
|
1489
|
-
...c
|
|
1490
|
-
}) {
|
|
1491
|
-
const d = (e || ke).replace(/\/$/, "");
|
|
1492
|
-
let l = new URL(
|
|
1493
|
-
s ? `${d}/account/${o}/slot/${s}` : `${d}/account/${o}`
|
|
1494
|
-
);
|
|
1495
|
-
s && l.searchParams.set("ps", encodeURIComponent(s)), a && l.searchParams.set("ns", encodeURIComponent(a)), n && l.searchParams.set("v", encodeURIComponent(n)), l.searchParams.set("rpcUrl", encodeURIComponent(t)), i?.erc20 && l.searchParams.set(
|
|
1496
|
-
"erc20",
|
|
1497
|
-
encodeURIComponent(i.erc20.toString())
|
|
1498
|
-
), super({
|
|
1499
|
-
...c,
|
|
1500
|
-
id: "controller-profile",
|
|
1501
|
-
url: l
|
|
1502
|
-
});
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
class jt extends Ae {
|
|
1481
|
+
class Ht extends _e {
|
|
1506
1482
|
keychain;
|
|
1507
|
-
profile;
|
|
1508
1483
|
options;
|
|
1509
1484
|
iframes;
|
|
1510
1485
|
selectedChain;
|
|
@@ -1517,21 +1492,21 @@ class jt extends Ae {
|
|
|
1517
1492
|
const n = [...[
|
|
1518
1493
|
{ rpcUrl: "https://api.cartridge.gg/x/starknet/sepolia" },
|
|
1519
1494
|
{ rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet" }
|
|
1520
|
-
], ...e.chains || []],
|
|
1521
|
-
this.selectedChain =
|
|
1522
|
-
keychain: new
|
|
1495
|
+
], ...e.chains || []], s = e.defaultChainId || $.StarknetChainId.SN_MAIN;
|
|
1496
|
+
this.selectedChain = s, this.chains = /* @__PURE__ */ new Map(), this.iframes = {
|
|
1497
|
+
keychain: new Tt({
|
|
1523
1498
|
...e,
|
|
1524
1499
|
onClose: this.keychain?.reset,
|
|
1525
|
-
onConnect: (
|
|
1526
|
-
this.keychain =
|
|
1500
|
+
onConnect: (o) => {
|
|
1501
|
+
this.keychain = o;
|
|
1527
1502
|
},
|
|
1528
|
-
version:
|
|
1503
|
+
version: ke
|
|
1529
1504
|
})
|
|
1530
|
-
}, this.options = { ...e, chains: n, defaultChainId:
|
|
1505
|
+
}, this.options = { ...e, chains: n, defaultChainId: s }, this.initializeChains(n), typeof window < "u" && (window.starknet_controller = this);
|
|
1531
1506
|
}
|
|
1532
1507
|
async logout() {
|
|
1533
1508
|
if (!this.keychain) {
|
|
1534
|
-
console.error(new
|
|
1509
|
+
console.error(new p().message);
|
|
1535
1510
|
return;
|
|
1536
1511
|
}
|
|
1537
1512
|
try {
|
|
@@ -1546,7 +1521,7 @@ class jt extends Ae {
|
|
|
1546
1521
|
async probe() {
|
|
1547
1522
|
try {
|
|
1548
1523
|
if (await this.waitForKeychain(), !this.keychain) {
|
|
1549
|
-
console.error(new
|
|
1524
|
+
console.error(new p().message);
|
|
1550
1525
|
return;
|
|
1551
1526
|
}
|
|
1552
1527
|
const e = await this.keychain.probe(this.rpcUrl());
|
|
@@ -1563,31 +1538,13 @@ class jt extends Ae {
|
|
|
1563
1538
|
console.error(e);
|
|
1564
1539
|
return;
|
|
1565
1540
|
}
|
|
1566
|
-
if (!this.iframes.profile) {
|
|
1567
|
-
const e = await this.keychain.username();
|
|
1568
|
-
this.iframes.profile = new zt({
|
|
1569
|
-
...this.options,
|
|
1570
|
-
onConnect: (t) => {
|
|
1571
|
-
this.profile = t;
|
|
1572
|
-
},
|
|
1573
|
-
methods: {
|
|
1574
|
-
openSettings: () => this.openSettings.bind(this),
|
|
1575
|
-
openPurchaseCredits: () => this.openPurchaseCredits.bind(this),
|
|
1576
|
-
openExecute: () => this.openExecute.bind(this),
|
|
1577
|
-
logout: () => this.logout.bind(this)
|
|
1578
|
-
},
|
|
1579
|
-
rpcUrl: this.rpcUrl(),
|
|
1580
|
-
username: e,
|
|
1581
|
-
version: this.version
|
|
1582
|
-
});
|
|
1583
|
-
}
|
|
1584
1541
|
return this.account;
|
|
1585
1542
|
}
|
|
1586
1543
|
async connect() {
|
|
1587
1544
|
if (this.account)
|
|
1588
1545
|
return this.account;
|
|
1589
1546
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1590
|
-
console.error(new
|
|
1547
|
+
console.error(new p().message);
|
|
1591
1548
|
return;
|
|
1592
1549
|
}
|
|
1593
1550
|
typeof document < "u" && document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.iframes.keychain.open();
|
|
@@ -1601,7 +1558,7 @@ class jt extends Ae {
|
|
|
1601
1558
|
this.rpcUrl(),
|
|
1602
1559
|
this.options.signupOptions
|
|
1603
1560
|
);
|
|
1604
|
-
if (e.code !==
|
|
1561
|
+
if (e.code !== R.SUCCESS)
|
|
1605
1562
|
throw new Error(e.message);
|
|
1606
1563
|
return e = e, this.account = new H(
|
|
1607
1564
|
this,
|
|
@@ -1619,11 +1576,11 @@ class jt extends Ae {
|
|
|
1619
1576
|
}
|
|
1620
1577
|
async switchStarknetChain(e) {
|
|
1621
1578
|
if (!this.keychain || !this.iframes.keychain)
|
|
1622
|
-
return console.error(new
|
|
1579
|
+
return console.error(new p().message), !1;
|
|
1623
1580
|
try {
|
|
1624
1581
|
if (this.selectedChain = e, (await this.keychain.probe(this.rpcUrl())).rpcUrl === this.rpcUrl())
|
|
1625
1582
|
return !0;
|
|
1626
|
-
await this.keychain.switchChain(this.rpcUrl())
|
|
1583
|
+
await this.keychain.switchChain(this.rpcUrl());
|
|
1627
1584
|
} catch (t) {
|
|
1628
1585
|
return console.error(t), !1;
|
|
1629
1586
|
}
|
|
@@ -1634,53 +1591,55 @@ class jt extends Ae {
|
|
|
1634
1591
|
}
|
|
1635
1592
|
async disconnect() {
|
|
1636
1593
|
if (!this.keychain) {
|
|
1637
|
-
console.error(new
|
|
1594
|
+
console.error(new p().message);
|
|
1638
1595
|
return;
|
|
1639
1596
|
}
|
|
1640
1597
|
return typeof document < "u" && document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.account = void 0, this.keychain.disconnect();
|
|
1641
1598
|
}
|
|
1642
1599
|
async openProfile(e = "inventory") {
|
|
1643
|
-
if (!this.
|
|
1644
|
-
console.error(
|
|
1600
|
+
if (!this.keychain || !this.iframes.keychain) {
|
|
1601
|
+
console.error(new p().message);
|
|
1645
1602
|
return;
|
|
1646
1603
|
}
|
|
1647
1604
|
if (!this.account) {
|
|
1648
1605
|
console.error("Account is not ready");
|
|
1649
1606
|
return;
|
|
1650
1607
|
}
|
|
1651
|
-
|
|
1608
|
+
const t = await this.keychain.username();
|
|
1609
|
+
await this.keychain.navigate(`/account/${t}/${e}`), this.iframes.keychain.open();
|
|
1652
1610
|
}
|
|
1653
1611
|
async openProfileTo(e) {
|
|
1654
|
-
if (!this.
|
|
1655
|
-
console.error(
|
|
1612
|
+
if (!this.keychain || !this.iframes.keychain) {
|
|
1613
|
+
console.error(new p().message);
|
|
1656
1614
|
return;
|
|
1657
1615
|
}
|
|
1658
1616
|
if (!this.account) {
|
|
1659
1617
|
console.error("Account is not ready");
|
|
1660
1618
|
return;
|
|
1661
1619
|
}
|
|
1662
|
-
|
|
1620
|
+
const t = await this.keychain.username();
|
|
1621
|
+
await this.keychain.navigate(`/account/${t}/${e}`), this.iframes.keychain.open();
|
|
1663
1622
|
}
|
|
1664
1623
|
async openProfileAt(e) {
|
|
1665
|
-
if (!this.
|
|
1666
|
-
console.error(
|
|
1624
|
+
if (!this.keychain || !this.iframes.keychain) {
|
|
1625
|
+
console.error(new p().message);
|
|
1667
1626
|
return;
|
|
1668
1627
|
}
|
|
1669
1628
|
if (!this.account) {
|
|
1670
1629
|
console.error("Account is not ready");
|
|
1671
1630
|
return;
|
|
1672
1631
|
}
|
|
1673
|
-
this.
|
|
1632
|
+
await this.keychain.navigate(e), this.iframes.keychain.open();
|
|
1674
1633
|
}
|
|
1675
|
-
|
|
1676
|
-
if (!this.keychain || !this.iframes.keychain)
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1634
|
+
openSettings() {
|
|
1635
|
+
if (!this.keychain || !this.iframes.keychain) {
|
|
1636
|
+
console.error(new p().message);
|
|
1637
|
+
return;
|
|
1638
|
+
}
|
|
1639
|
+
this.iframes.keychain.open(), this.keychain.openSettings();
|
|
1681
1640
|
}
|
|
1682
1641
|
revoke(e, t) {
|
|
1683
|
-
return this.keychain ? this.keychain.revoke(e) : (console.error(new
|
|
1642
|
+
return this.keychain ? this.keychain.revoke(e) : (console.error(new p().message), null);
|
|
1684
1643
|
}
|
|
1685
1644
|
rpcUrl() {
|
|
1686
1645
|
const e = this.chains.get(this.selectedChain);
|
|
@@ -1696,62 +1655,52 @@ class jt extends Ae {
|
|
|
1696
1655
|
}
|
|
1697
1656
|
username() {
|
|
1698
1657
|
if (!this.keychain) {
|
|
1699
|
-
console.error(new
|
|
1658
|
+
console.error(new p().message);
|
|
1700
1659
|
return;
|
|
1701
1660
|
}
|
|
1702
1661
|
return this.keychain.username();
|
|
1703
1662
|
}
|
|
1704
1663
|
openPurchaseCredits() {
|
|
1705
1664
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1706
|
-
console.error(new
|
|
1707
|
-
return;
|
|
1708
|
-
}
|
|
1709
|
-
if (!this.iframes.profile) {
|
|
1710
|
-
console.error("Profile is not ready");
|
|
1665
|
+
console.error(new p().message);
|
|
1711
1666
|
return;
|
|
1712
1667
|
}
|
|
1713
|
-
this.iframes.
|
|
1668
|
+
this.iframes.keychain.open(), this.keychain.openPurchaseCredits();
|
|
1714
1669
|
}
|
|
1715
1670
|
openStarterPack(e) {
|
|
1716
1671
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1717
|
-
console.error(new
|
|
1672
|
+
console.error(new p().message);
|
|
1718
1673
|
return;
|
|
1719
1674
|
}
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
}
|
|
1724
|
-
this.iframes.profile.close(), this.iframes.keychain.open(), this.keychain.openStarterPack(e);
|
|
1675
|
+
this.keychain.navigate(`/starter-pack/${e}`).then(() => {
|
|
1676
|
+
this.iframes.keychain.open();
|
|
1677
|
+
});
|
|
1725
1678
|
}
|
|
1726
1679
|
async openExecute(e, t) {
|
|
1727
1680
|
if (!this.keychain || !this.iframes.keychain) {
|
|
1728
|
-
console.error(new
|
|
1729
|
-
return;
|
|
1730
|
-
}
|
|
1731
|
-
if (!this.iframes.profile) {
|
|
1732
|
-
console.error("Profile is not ready");
|
|
1681
|
+
console.error(new p().message);
|
|
1733
1682
|
return;
|
|
1734
1683
|
}
|
|
1735
1684
|
let n = this.selectedChain;
|
|
1736
|
-
t && this.switchStarknetChain(t), this.iframes.
|
|
1737
|
-
const
|
|
1738
|
-
return this.iframes.
|
|
1739
|
-
status: !(
|
|
1740
|
-
transactionHash:
|
|
1685
|
+
t && this.switchStarknetChain(t), this.iframes.keychain.open();
|
|
1686
|
+
const s = await this.keychain.execute(e, void 0, void 0, !0);
|
|
1687
|
+
return this.iframes.keychain.close(), t && this.switchStarknetChain(n), {
|
|
1688
|
+
status: !(s && (s.code === R.NOT_CONNECTED || s.code === R.CANCELED)),
|
|
1689
|
+
transactionHash: s?.transaction_hash
|
|
1741
1690
|
};
|
|
1742
1691
|
}
|
|
1743
1692
|
async delegateAccount() {
|
|
1744
|
-
return this.keychain ? await this.keychain.delegateAccount() : (console.error(new
|
|
1693
|
+
return this.keychain ? await this.keychain.delegateAccount() : (console.error(new p().message), null);
|
|
1745
1694
|
}
|
|
1746
1695
|
initializeChains(e) {
|
|
1747
1696
|
for (const t of e)
|
|
1748
1697
|
try {
|
|
1749
|
-
const n = new URL(t.rpcUrl),
|
|
1750
|
-
if ((
|
|
1698
|
+
const n = new URL(t.rpcUrl), s = Ae(n), o = s === $.StarknetChainId.SN_MAIN, a = s === $.StarknetChainId.SN_SEPOLIA, i = n.hostname === "api.cartridge.gg", c = n.hostname === "localhost" || n.hostname === "127.0.0.1";
|
|
1699
|
+
if ((o || a) && !(i || c))
|
|
1751
1700
|
throw new Error(
|
|
1752
|
-
`Only Cartridge RPC providers are allowed for ${
|
|
1701
|
+
`Only Cartridge RPC providers are allowed for ${o ? "mainnet" : "sepolia"}. Please use: https://api.cartridge.gg/x/starknet/${o ? "mainnet" : "sepolia"}`
|
|
1753
1702
|
);
|
|
1754
|
-
this.chains.set(
|
|
1703
|
+
this.chains.set(s, t);
|
|
1755
1704
|
} catch (n) {
|
|
1756
1705
|
throw console.error(`Failed to parse chainId for ${t.rpcUrl}:`, n), n;
|
|
1757
1706
|
}
|
|
@@ -1763,10 +1712,10 @@ class jt extends Ae {
|
|
|
1763
1712
|
timeout: e = 5e4,
|
|
1764
1713
|
interval: t = 100
|
|
1765
1714
|
} = {}) {
|
|
1766
|
-
return new Promise((n,
|
|
1767
|
-
const
|
|
1768
|
-
if (Date.now() -
|
|
1769
|
-
clearInterval(a),
|
|
1715
|
+
return new Promise((n, s) => {
|
|
1716
|
+
const o = Date.now(), a = setInterval(() => {
|
|
1717
|
+
if (Date.now() - o > e) {
|
|
1718
|
+
clearInterval(a), s(new Error("Timeout waiting for keychain"));
|
|
1770
1719
|
return;
|
|
1771
1720
|
}
|
|
1772
1721
|
this.keychain && (clearInterval(a), n());
|
|
@@ -1774,11 +1723,11 @@ class jt extends Ae {
|
|
|
1774
1723
|
});
|
|
1775
1724
|
}
|
|
1776
1725
|
}
|
|
1777
|
-
const
|
|
1778
|
-
async function
|
|
1726
|
+
const S = /* @__PURE__ */ new Map();
|
|
1727
|
+
async function pe(r) {
|
|
1779
1728
|
if (!r.addresses?.length && !r.usernames?.length)
|
|
1780
1729
|
return { results: [] };
|
|
1781
|
-
const e = await fetch(`${
|
|
1730
|
+
const e = await fetch(`${Ie}/lookup`, {
|
|
1782
1731
|
method: "POST",
|
|
1783
1732
|
headers: {
|
|
1784
1733
|
"Content-Type": "application/json"
|
|
@@ -1789,26 +1738,26 @@ async function me(r) {
|
|
|
1789
1738
|
throw new Error(`HTTP error! status: ${e.status}`);
|
|
1790
1739
|
return e.json();
|
|
1791
1740
|
}
|
|
1792
|
-
async function
|
|
1793
|
-
const e = r.filter((t) => !
|
|
1794
|
-
return e.length > 0 && (await
|
|
1795
|
-
|
|
1741
|
+
async function Kt(r) {
|
|
1742
|
+
const e = r.filter((t) => !S.has(t));
|
|
1743
|
+
return e.length > 0 && (await pe({ usernames: e })).results.forEach((n) => {
|
|
1744
|
+
S.set(n.username, n.addresses[0]);
|
|
1796
1745
|
}), new Map(
|
|
1797
|
-
r.map((t) => [t,
|
|
1746
|
+
r.map((t) => [t, S.get(t)]).filter((t) => t[1] !== void 0)
|
|
1798
1747
|
);
|
|
1799
1748
|
}
|
|
1800
|
-
async function
|
|
1801
|
-
r = r.map(
|
|
1802
|
-
const e = r.filter((t) => !
|
|
1803
|
-
return e.length > 0 && (await
|
|
1749
|
+
async function jt(r) {
|
|
1750
|
+
r = r.map(ye.toHex);
|
|
1751
|
+
const e = r.filter((t) => !S.has(t));
|
|
1752
|
+
return e.length > 0 && (await pe({
|
|
1804
1753
|
addresses: e
|
|
1805
1754
|
})).results.forEach((n) => {
|
|
1806
|
-
|
|
1755
|
+
S.set(n.addresses[0], n.username);
|
|
1807
1756
|
}), new Map(
|
|
1808
|
-
r.map((t) => [t,
|
|
1757
|
+
r.map((t) => [t, S.get(t)]).filter((t) => t[1] !== void 0)
|
|
1809
1758
|
);
|
|
1810
1759
|
}
|
|
1811
|
-
var
|
|
1760
|
+
var $t = [
|
|
1812
1761
|
{
|
|
1813
1762
|
name: "Wrapped BTC",
|
|
1814
1763
|
symbol: "WBTC",
|
|
@@ -2377,93 +2326,93 @@ var Ot = [
|
|
|
2377
2326
|
name: "Cartridge",
|
|
2378
2327
|
icon: "icon.svg"
|
|
2379
2328
|
}
|
|
2380
|
-
},
|
|
2329
|
+
}, Q = "https://static.cartridge.gg/presets";
|
|
2381
2330
|
async function F() {
|
|
2382
2331
|
try {
|
|
2383
|
-
const r = await fetch(`${
|
|
2332
|
+
const r = await fetch(`${Q}/index.json`);
|
|
2384
2333
|
if (!r.ok)
|
|
2385
2334
|
throw new Error(`Failed to load configs index: ${r.statusText}`);
|
|
2386
2335
|
return await r.json();
|
|
2387
2336
|
} catch (r) {
|
|
2388
|
-
return console.error("Error loading configs index:", r), { configs: [], baseUrl:
|
|
2337
|
+
return console.error("Error loading configs index:", r), { configs: [], baseUrl: Q };
|
|
2389
2338
|
}
|
|
2390
2339
|
}
|
|
2391
|
-
async function
|
|
2340
|
+
async function qt() {
|
|
2392
2341
|
return (await F()).configs;
|
|
2393
2342
|
}
|
|
2394
|
-
async function
|
|
2343
|
+
async function Xt(r) {
|
|
2395
2344
|
try {
|
|
2396
|
-
const n = `${(await F()).baseUrl ||
|
|
2397
|
-
if (!
|
|
2345
|
+
const n = `${(await F()).baseUrl || Q}/${r}`, s = await fetch(`${n}/config.json`);
|
|
2346
|
+
if (!s.ok)
|
|
2398
2347
|
throw new Error(
|
|
2399
|
-
`Failed to load config ${r}: ${
|
|
2348
|
+
`Failed to load config ${r}: ${s.statusText}`
|
|
2400
2349
|
);
|
|
2401
|
-
const
|
|
2402
|
-
if (
|
|
2403
|
-
|
|
2350
|
+
const o = await s.json();
|
|
2351
|
+
if (o && o.theme) {
|
|
2352
|
+
o.theme.icon && !o.theme.icon.startsWith("http") && (o.theme.icon = `${n}/${o.theme.icon}`), o.theme.cover && (typeof o.theme.cover == "string" ? o.theme.cover.startsWith("http") || (o.theme.cover = `${n}/${o.theme.cover}`) : (o.theme.cover.light && !o.theme.cover.light.startsWith("http") && (o.theme.cover.light = `${n}/${o.theme.cover.light}`), o.theme.cover.dark && !o.theme.cover.dark.startsWith("http") && (o.theme.cover.dark = `${n}/${o.theme.cover.dark}`)));
|
|
2404
2353
|
const a = (i) => {
|
|
2405
2354
|
if (i) {
|
|
2406
2355
|
for (const c in i)
|
|
2407
2356
|
if (i[c])
|
|
2408
|
-
for (const
|
|
2409
|
-
i[c][
|
|
2357
|
+
for (const l in i[c])
|
|
2358
|
+
i[c][l] && !i[c][l].startsWith("http") && (i[c][l] = `${n}/${i[c][l]}`);
|
|
2410
2359
|
}
|
|
2411
2360
|
};
|
|
2412
|
-
if (
|
|
2413
|
-
if (typeof
|
|
2414
|
-
|
|
2415
|
-
else if (
|
|
2416
|
-
const i =
|
|
2361
|
+
if (o.theme.optimizedIcon && a(o.theme.optimizedIcon), o.theme.optimizedCover)
|
|
2362
|
+
if (typeof o.theme.optimizedCover == "string")
|
|
2363
|
+
o.theme.optimizedCover.startsWith("http") || (o.theme.optimizedCover = `${n}/${o.theme.optimizedCover}`);
|
|
2364
|
+
else if (o.theme.optimizedCover.light || o.theme.optimizedCover.dark) {
|
|
2365
|
+
const i = o.theme.optimizedCover;
|
|
2417
2366
|
i.light && a(i.light), i.dark && a(i.dark);
|
|
2418
2367
|
} else
|
|
2419
|
-
a(
|
|
2368
|
+
a(o.theme.optimizedCover);
|
|
2420
2369
|
}
|
|
2421
|
-
return
|
|
2370
|
+
return o;
|
|
2422
2371
|
} catch (e) {
|
|
2423
2372
|
return console.error(`Error loading config ${r}:`, e), null;
|
|
2424
2373
|
}
|
|
2425
2374
|
}
|
|
2426
|
-
async function
|
|
2427
|
-
const r = await F(), e = r.configs, t = r.baseUrl ||
|
|
2375
|
+
async function Gt() {
|
|
2376
|
+
const r = await F(), e = r.configs, t = r.baseUrl || Q, n = {};
|
|
2428
2377
|
return await Promise.all(
|
|
2429
|
-
e.map(async (
|
|
2378
|
+
e.map(async (s) => {
|
|
2430
2379
|
try {
|
|
2431
|
-
const
|
|
2432
|
-
if (
|
|
2433
|
-
const a = await
|
|
2434
|
-
n[
|
|
2380
|
+
const o = await fetch(`${t}/${s}/config.json`);
|
|
2381
|
+
if (o.ok) {
|
|
2382
|
+
const a = await o.json();
|
|
2383
|
+
n[s] = a;
|
|
2435
2384
|
}
|
|
2436
|
-
} catch (
|
|
2437
|
-
console.error(`Error loading config ${
|
|
2385
|
+
} catch (o) {
|
|
2386
|
+
console.error(`Error loading config ${s}:`, o);
|
|
2438
2387
|
}
|
|
2439
2388
|
})
|
|
2440
2389
|
), n;
|
|
2441
2390
|
}
|
|
2442
2391
|
ge.theme.icon = "https://static.cartridge.gg/presets/cartridge/icon.svg";
|
|
2443
|
-
var
|
|
2392
|
+
var Vt = $t, Jt = ge.theme;
|
|
2444
2393
|
export {
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2394
|
+
Pt as ArgentWallet,
|
|
2395
|
+
tr as FeeSource,
|
|
2396
|
+
Nt as MetaMaskWallet,
|
|
2397
|
+
p as NotReadyToConnect,
|
|
2398
|
+
Mt as PhantomWallet,
|
|
2450
2399
|
Qt as RabbyWallet,
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2400
|
+
R as ResponseCodes,
|
|
2401
|
+
Ut as WalletBridge,
|
|
2402
|
+
Ht as default,
|
|
2403
|
+
Jt as defaultTheme,
|
|
2404
|
+
Vt as erc20Metadata,
|
|
2405
|
+
qt as getAvailableConfigs,
|
|
2457
2406
|
F as getConfigsIndex,
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2407
|
+
rr as humanizeString,
|
|
2408
|
+
Gt as loadAllConfigs,
|
|
2409
|
+
Xt as loadConfig,
|
|
2410
|
+
jt as lookupAddresses,
|
|
2411
|
+
Kt as lookupUsernames,
|
|
2412
|
+
nr as normalizeCalls,
|
|
2413
|
+
Ae as parseChainId,
|
|
2414
|
+
be as toArray,
|
|
2415
|
+
sr as toSessionPolicies,
|
|
2416
|
+
or as toWasmPolicies
|
|
2468
2417
|
};
|
|
2469
2418
|
//# sourceMappingURL=index.js.map
|