@latticexyz/entrykit 2.2.18-90aac1d4acce19ac592d47a090732dd11c1c3e7a → 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2
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/dist/tsup/bin/deploy.cjs +132 -0
- package/dist/tsup/bin/deploy.cjs.map +1 -0
- package/dist/tsup/bin/deploy.d.cts +2 -0
- package/dist/tsup/bin/deploy.js +117 -8
- package/dist/tsup/bin/deploy.js.map +1 -1
- package/dist/tsup/exports/index.cjs +2 -0
- package/dist/tsup/exports/index.cjs.map +1 -0
- package/dist/tsup/exports/index.d.cts +2 -0
- package/dist/tsup/exports/internal.cjs +2287 -0
- package/dist/tsup/exports/internal.cjs.map +1 -0
- package/dist/tsup/exports/internal.d.cts +123 -0
- package/dist/tsup/exports/internal.js +2238 -1382
- package/dist/tsup/exports/internal.js.map +1 -1
- package/package.json +28 -11
|
@@ -1,1398 +1,2254 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
--tw-ordinal: ;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
/*
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/*
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
[
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
cursor: pointer;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/*
|
|
457
|
-
Make sure disabled buttons don't get the pointer cursor.
|
|
458
|
-
*/
|
|
459
|
-
:disabled {
|
|
460
|
-
cursor: default;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
/*
|
|
464
|
-
1. Make replaced elements \`display: block\` by default. (https://github.com/mozdevs/cssremedy/issues/14)
|
|
465
|
-
2. Add \`vertical-align: middle\` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
|
|
466
|
-
This can trigger a poorly considered lint error in some tools but is included by design.
|
|
467
|
-
*/
|
|
468
|
-
|
|
469
|
-
img,
|
|
470
|
-
svg,
|
|
471
|
-
video,
|
|
472
|
-
canvas,
|
|
473
|
-
audio,
|
|
474
|
-
iframe,
|
|
475
|
-
embed,
|
|
476
|
-
object {
|
|
477
|
-
display: block; /* 1 */
|
|
478
|
-
vertical-align: middle; /* 2 */
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
/*
|
|
482
|
-
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
|
|
483
|
-
*/
|
|
484
|
-
|
|
485
|
-
img,
|
|
486
|
-
video {
|
|
487
|
-
max-width: 100%;
|
|
488
|
-
height: auto;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/* Make elements with the HTML hidden attribute stay hidden by default */
|
|
492
|
-
[hidden] {
|
|
493
|
-
display: none;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
.container {
|
|
497
|
-
width: 100%;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
@media (min-width: 640px) {
|
|
501
|
-
|
|
502
|
-
.container {
|
|
503
|
-
max-width: 640px;
|
|
1
|
+
// src/config/defineConfig.ts
|
|
2
|
+
function defineConfig(input) {
|
|
3
|
+
return {
|
|
4
|
+
...input,
|
|
5
|
+
appName: input.appName ?? document.title,
|
|
6
|
+
appIcon: input.appIcon ?? document.querySelector("link[rel~='icon']")?.getAttribute("href") ?? "/favico.ico"
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// src/ui/Modal.tsx
|
|
11
|
+
import { Root as DialogRoot, DialogPortal, DialogContent } from "@radix-ui/react-dialog";
|
|
12
|
+
|
|
13
|
+
// src/ui/Shadow.tsx
|
|
14
|
+
import { forwardRef, useEffect, useRef, useState } from "react";
|
|
15
|
+
import ReactDOM from "react-dom";
|
|
16
|
+
|
|
17
|
+
// ../../node_modules/.pnpm/tailwindcss@3.4.13/node_modules/tailwindcss/tailwind.css?inline
|
|
18
|
+
var tailwind_default = '*, ::before, ::after {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: ;\n}\n\n::backdrop {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: ;\n}/*\n! tailwindcss v3.4.13 | MIT License | https://tailwindcss.com\n*//*\n1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)\n*/\n\n*,\n::before,\n::after {\n box-sizing: border-box; /* 1 */\n border-width: 0; /* 2 */\n border-style: solid; /* 2 */\n border-color: #e5e7eb; /* 2 */\n}\n\n::before,\n::after {\n --tw-content: \'\';\n}\n\n/*\n1. Use a consistent sensible line-height in all browsers.\n2. Prevent adjustments of font size after orientation changes in iOS.\n3. Use a more readable tab size.\n4. Use the user\'s configured `sans` font-family by default.\n5. Use the user\'s configured `sans` font-feature-settings by default.\n6. Use the user\'s configured `sans` font-variation-settings by default.\n7. Disable tap highlights on iOS\n*/\n\nhtml,\n:host {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */ /* 3 */\n tab-size: 4; /* 3 */\n font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; /* 4 */\n font-feature-settings: normal; /* 5 */\n font-variation-settings: normal; /* 6 */\n -webkit-tap-highlight-color: transparent; /* 7 */\n}\n\n/*\n1. Remove the margin in all browsers.\n2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.\n*/\n\nbody {\n margin: 0; /* 1 */\n line-height: inherit; /* 2 */\n}\n\n/*\n1. Add the correct height in Firefox.\n2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n3. Ensure horizontal rules are visible by default.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\nAdd the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\nRemove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\nReset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n text-decoration: inherit;\n}\n\n/*\nAdd the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n1. Use the user\'s configured `mono` font-family by default.\n2. Use the user\'s configured `mono` font-feature-settings by default.\n3. Use the user\'s configured `mono` font-variation-settings by default.\n4. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; /* 1 */\n font-feature-settings: normal; /* 2 */\n font-variation-settings: normal; /* 3 */\n font-size: 1em; /* 4 */\n}\n\n/*\nAdd the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\nPrevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n1. Change the font styles in all browsers.\n2. Remove the margin in Firefox and Safari.\n3. Remove default padding in all browsers.\n*/\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-feature-settings: inherit; /* 1 */\n font-variation-settings: inherit; /* 1 */\n font-size: 100%; /* 1 */\n font-weight: inherit; /* 1 */\n line-height: inherit; /* 1 */\n letter-spacing: inherit; /* 1 */\n color: inherit; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 3 */\n}\n\n/*\nRemove the inheritance of text transform in Edge and Firefox.\n*/\n\nbutton,\nselect {\n text-transform: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Remove default button styles.\n*/\n\nbutton,\ninput:where([type=\'button\']),\ninput:where([type=\'reset\']),\ninput:where([type=\'submit\']) {\n -webkit-appearance: button; /* 1 */\n background-color: transparent; /* 2 */\n background-image: none; /* 2 */\n}\n\n/*\nUse the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring {\n outline: auto;\n}\n\n/*\nRemove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\nAdd the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\nCorrect the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n1. Correct the odd appearance in Chrome and Safari.\n2. Correct the outline style in Safari.\n*/\n\n[type=\'search\'] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/*\nRemove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Change font properties to `inherit` in Safari.\n*/\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/*\nAdd the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\nRemoves the default spacing and border for appropriate elements.\n*/\n\nblockquote,\ndl,\ndd,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\nhr,\nfigure,\np,\npre {\n margin: 0;\n}\n\nfieldset {\n margin: 0;\n padding: 0;\n}\n\nlegend {\n padding: 0;\n}\n\nol,\nul,\nmenu {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n/*\nReset default styling for dialogs.\n*/\ndialog {\n padding: 0;\n}\n\n/*\nPrevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n2. Set the default placeholder color to the user\'s configured gray 400 color.\n*/\n\ninput::placeholder,\ntextarea::placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\n/*\nSet the default cursor for buttons.\n*/\n\nbutton,\n[role="button"] {\n cursor: pointer;\n}\n\n/*\nMake sure disabled buttons don\'t get the pointer cursor.\n*/\n:disabled {\n cursor: default;\n}\n\n/*\n1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\nConstrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/* Make elements with the HTML hidden attribute stay hidden by default */\n[hidden] {\n display: none;\n}\n\n.container {\n width: 100%;\n}\n\n@media (min-width: 640px) {\n\n .container {\n max-width: 640px;\n }\n}\n\n@media (min-width: 768px) {\n\n .container {\n max-width: 768px;\n }\n}\n\n@media (min-width: 1024px) {\n\n .container {\n max-width: 1024px;\n }\n}\n\n@media (min-width: 1280px) {\n\n .container {\n max-width: 1280px;\n }\n}\n\n@media (min-width: 1536px) {\n\n .container {\n max-width: 1536px;\n }\n}\n\n.grid-cols-2.divide-y > :not([hidden]) ~ :not([hidden]):nth-child(-n + 2) {\n border-top-width: 0;\n border-bottom-width: 0;\n}\n\n.sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0;\n}\n\n.pointer-events-none {\n pointer-events: none;\n}\n\n.pointer-events-auto {\n pointer-events: auto;\n}\n\n.fixed {\n position: fixed;\n}\n\n.absolute {\n position: absolute;\n}\n\n.relative {\n position: relative;\n}\n\n.inset-0 {\n inset: 0px;\n}\n\n.right-0 {\n right: 0px;\n}\n\n.top-0 {\n top: 0px;\n}\n\n.col-start-1 {\n grid-column-start: 1;\n}\n\n.row-start-1 {\n grid-row-start: 1;\n}\n\n.m-0 {\n margin: 0px;\n}\n\n.m-2 {\n margin: 0.5rem;\n}\n\n.-mx-0\\.5 {\n margin-left: -0.125rem;\n margin-right: -0.125rem;\n}\n\n.-my-1 {\n margin-top: -0.25rem;\n margin-bottom: -0.25rem;\n}\n\n.-my-\\[0\\.125em\\] {\n margin-top: -0.125em;\n margin-bottom: -0.125em;\n}\n\n.mx-auto {\n margin-left: auto;\n margin-right: auto;\n}\n\n.-ml-3 {\n margin-left: -0.75rem;\n}\n\n.block {\n display: block;\n}\n\n.flex {\n display: flex;\n}\n\n.inline-flex {\n display: inline-flex;\n}\n\n.table {\n display: table;\n}\n\n.grid {\n display: grid;\n}\n\n.inline-grid {\n display: inline-grid;\n}\n\n.contents {\n display: contents;\n}\n\n.h-16 {\n height: 4rem;\n}\n\n.h-4 {\n height: 1rem;\n}\n\n.h-6 {\n height: 1.5rem;\n}\n\n.h-\\[1\\.25em\\] {\n height: 1.25em;\n}\n\n.h-\\[1em\\] {\n height: 1em;\n}\n\n.h-full {\n height: 100%;\n}\n\n.max-h-32 {\n max-height: 8rem;\n}\n\n.min-h-\\[22rem\\] {\n min-height: 22rem;\n}\n\n.min-h-\\[26rem\\] {\n min-height: 26rem;\n}\n\n.w-16 {\n width: 4rem;\n}\n\n.w-28 {\n width: 7rem;\n}\n\n.w-4 {\n width: 1rem;\n}\n\n.w-48 {\n width: 12rem;\n}\n\n.w-6 {\n width: 1.5rem;\n}\n\n.w-60 {\n width: 15rem;\n}\n\n.w-\\[0\\.6em\\] {\n width: 0.6em;\n}\n\n.w-\\[1\\.25em\\] {\n width: 1.25em;\n}\n\n.w-full {\n width: 100%;\n}\n\n.max-w-\\[26rem\\] {\n max-width: 26rem;\n}\n\n.flex-shrink-0 {\n flex-shrink: 0;\n}\n\n.flex-grow {\n flex-grow: 1;\n}\n\n.translate-x-2 {\n --tw-translate-x: 0.5rem;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n\n.scale-100 {\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n\n.scale-50 {\n --tw-scale-x: .5;\n --tw-scale-y: .5;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n\n@keyframes spin {\n\n to {\n transform: rotate(360deg);\n }\n}\n\n.animate-spin {\n animation: spin 1s linear infinite;\n}\n\n.cursor-pointer {\n cursor: pointer;\n}\n\n.grid-cols-\\[1fr_auto_1fr\\] {\n grid-template-columns: 1fr auto 1fr;\n}\n\n.flex-col {\n flex-direction: column;\n}\n\n.place-items-center {\n place-items: center;\n}\n\n.items-end {\n align-items: flex-end;\n}\n\n.items-center {\n align-items: center;\n}\n\n.justify-end {\n justify-content: flex-end;\n}\n\n.justify-center {\n justify-content: center;\n}\n\n.justify-between {\n justify-content: space-between;\n}\n\n.gap-1 {\n gap: 0.25rem;\n}\n\n.gap-2 {\n gap: 0.5rem;\n}\n\n.gap-2\\.5 {\n gap: 0.625rem;\n}\n\n.gap-4 {\n gap: 1rem;\n}\n\n.gap-6 {\n gap: 1.5rem;\n}\n\n.divide-y > :not([hidden]) ~ :not([hidden]) {\n --tw-divide-y-reverse: 0;\n border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));\n border-bottom-width: calc(1px * var(--tw-divide-y-reverse));\n}\n\n.divide-neutral-700 > :not([hidden]) ~ :not([hidden]) {\n --tw-divide-opacity: 1;\n border-color: rgb(64 64 64 / var(--tw-divide-opacity));\n}\n\n.divide-neutral-800 > :not([hidden]) ~ :not([hidden]) {\n --tw-divide-opacity: 1;\n border-color: rgb(38 38 38 / var(--tw-divide-opacity));\n}\n\n.self-auto {\n align-self: auto;\n}\n\n.self-end {\n align-self: flex-end;\n}\n\n.self-center {\n align-self: center;\n}\n\n.overflow-y-scroll {\n overflow-y: scroll;\n}\n\n.whitespace-break-spaces {\n white-space: break-spaces;\n}\n\n.break-all {\n word-break: break-all;\n}\n\n.rounded-full {\n border-radius: 9999px;\n}\n\n.border {\n border-width: 1px;\n}\n\n.border-4 {\n border-width: 4px;\n}\n\n.border-l-4 {\n border-left-width: 4px;\n}\n\n.border-neutral-300 {\n --tw-border-opacity: 1;\n border-color: rgb(212 212 212 / var(--tw-border-opacity));\n}\n\n.border-red-500 {\n --tw-border-opacity: 1;\n border-color: rgb(239 68 68 / var(--tw-border-opacity));\n}\n\n.border-transparent {\n border-color: transparent;\n}\n\n.bg-black\\/10 {\n background-color: rgb(0 0 0 / 0.1);\n}\n\n.bg-neutral-100 {\n --tw-bg-opacity: 1;\n background-color: rgb(245 245 245 / var(--tw-bg-opacity));\n}\n\n.bg-neutral-700 {\n --tw-bg-opacity: 1;\n background-color: rgb(64 64 64 / var(--tw-bg-opacity));\n}\n\n.bg-neutral-800 {\n --tw-bg-opacity: 1;\n background-color: rgb(38 38 38 / var(--tw-bg-opacity));\n}\n\n.bg-neutral-800\\/85 {\n background-color: rgb(38 38 38 / 0.85);\n}\n\n.bg-neutral-900 {\n --tw-bg-opacity: 1;\n background-color: rgb(23 23 23 / var(--tw-bg-opacity));\n}\n\n.bg-orange-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(249 115 22 / var(--tw-bg-opacity));\n}\n\n.bg-orange-600 {\n --tw-bg-opacity: 1;\n background-color: rgb(234 88 12 / var(--tw-bg-opacity));\n}\n\n.bg-red-100 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 226 226 / var(--tw-bg-opacity));\n}\n\n.bg-cover {\n background-size: cover;\n}\n\n.bg-center {\n background-position: center;\n}\n\n.bg-no-repeat {\n background-repeat: no-repeat;\n}\n\n.object-cover {\n object-fit: cover;\n}\n\n.p-1 {\n padding: 0.25rem;\n}\n\n.p-2 {\n padding: 0.5rem;\n}\n\n.p-3 {\n padding: 0.75rem;\n}\n\n.p-4 {\n padding: 1rem;\n}\n\n.p-5 {\n padding: 1.25rem;\n}\n\n.p-6 {\n padding: 1.5rem;\n}\n\n.p-\\[\\.75em\\] {\n padding: .75em;\n}\n\n.px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem;\n}\n\n.px-8 {\n padding-left: 2rem;\n padding-right: 2rem;\n}\n\n.py-2 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n\n.py-8 {\n padding-top: 2rem;\n padding-bottom: 2rem;\n}\n\n.text-left {\n text-align: left;\n}\n\n.text-center {\n text-align: center;\n}\n\n.font-mono {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;\n}\n\n.text-2xl {\n font-size: 1.5rem;\n line-height: 2rem;\n}\n\n.text-\\[\\.75em\\] {\n font-size: .75em;\n}\n\n.text-base {\n font-size: 1rem;\n line-height: 1.5rem;\n}\n\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n\n.text-xs {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n\n.font-medium {\n font-weight: 500;\n}\n\n.font-semibold {\n font-weight: 600;\n}\n\n.leading-none {\n line-height: 1;\n}\n\n.tracking-\\[-1ch\\] {\n letter-spacing: -1ch;\n}\n\n.text-black {\n --tw-text-opacity: 1;\n color: rgb(0 0 0 / var(--tw-text-opacity));\n}\n\n.text-neutral-400 {\n --tw-text-opacity: 1;\n color: rgb(163 163 163 / var(--tw-text-opacity));\n}\n\n.text-neutral-500 {\n --tw-text-opacity: 1;\n color: rgb(115 115 115 / var(--tw-text-opacity));\n}\n\n.text-neutral-700 {\n --tw-text-opacity: 1;\n color: rgb(64 64 64 / var(--tw-text-opacity));\n}\n\n.text-orange-500 {\n --tw-text-opacity: 1;\n color: rgb(249 115 22 / var(--tw-text-opacity));\n}\n\n.text-red-900 {\n --tw-text-opacity: 1;\n color: rgb(127 29 29 / var(--tw-text-opacity));\n}\n\n.text-transparent {\n color: transparent;\n}\n\n.text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity));\n}\n\n.opacity-0 {\n opacity: 0;\n}\n\n.opacity-100 {\n opacity: 1;\n}\n\n.opacity-25 {\n opacity: 0.25;\n}\n\n.opacity-30 {\n opacity: 0.3;\n}\n\n.opacity-75 {\n opacity: 0.75;\n}\n\n.outline-none {\n outline: 2px solid transparent;\n outline-offset: 2px;\n}\n\n.ring-1 {\n --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);\n --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);\n box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);\n}\n\n.ring-neutral-700\\/50 {\n --tw-ring-color: rgb(64 64 64 / 0.5);\n}\n\n.filter {\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n\n.transition {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n\n.duration-100 {\n transition-duration: 100ms;\n}\n\n.duration-300 {\n transition-duration: 300ms;\n}\n\n@keyframes enter {\n\n from {\n opacity: var(--tw-enter-opacity, 1);\n transform: translate3d(var(--tw-enter-translate-x, 0), var(--tw-enter-translate-y, 0), 0) scale3d(var(--tw-enter-scale, 1), var(--tw-enter-scale, 1), var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0));\n }\n}\n\n@keyframes exit {\n\n to {\n opacity: var(--tw-exit-opacity, 1);\n transform: translate3d(var(--tw-exit-translate-x, 0), var(--tw-exit-translate-y, 0), 0) scale3d(var(--tw-exit-scale, 1), var(--tw-exit-scale, 1), var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0));\n }\n}\n\n.animate-in {\n animation-name: enter;\n animation-duration: 150ms;\n --tw-enter-opacity: initial;\n --tw-enter-scale: initial;\n --tw-enter-rotate: initial;\n --tw-enter-translate-x: initial;\n --tw-enter-translate-y: initial;\n}\n\n.fade-in {\n --tw-enter-opacity: 0;\n}\n\n.slide-in-from-bottom-16 {\n --tw-enter-translate-y: 4rem;\n}\n\n.slide-in-from-bottom-8 {\n --tw-enter-translate-y: 2rem;\n}\n\n.animate-duration-300 {\n animation-duration: 300ms;\n}\n\n@property --tw-border-gradient-angle {\n syntax: \'<angle>\';\n inherits: true;\n initial-value: 0deg;\n}\n\n@property --tw-conic-gradient-angle {\n syntax: \'<angle>\';\n inherits: true;\n initial-value: 0deg;\n}\n\n@keyframes border-gradient {\n\n to {\n --tw-border-gradient-angle: 360deg;\n }\n}\n\n.after\\:select-none::after {\n content: var(--tw-content);\n -webkit-user-select: none;\n user-select: none;\n}\n\n.after\\:content-\\[\\\'\\2026\\\'\\]::after {\n --tw-content: \'\u2026\';\n content: var(--tw-content);\n}\n\n.hover\\:bg-neutral-200:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(229 229 229 / var(--tw-bg-opacity));\n}\n\n.hover\\:bg-orange-400:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(251 146 60 / var(--tw-bg-opacity));\n}\n\n.hover\\:text-neutral-500:hover {\n --tw-text-opacity: 1;\n color: rgb(115 115 115 / var(--tw-text-opacity));\n}\n\n.hover\\:text-white:hover {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity));\n}\n\n.hover\\:brightness-125:hover {\n --tw-brightness: brightness(1.25);\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n\n.focus\\:border-orange-500:focus {\n --tw-border-opacity: 1;\n border-color: rgb(249 115 22 / var(--tw-border-opacity));\n}\n\n.focus\\:border-yellow-400:focus {\n --tw-border-opacity: 1;\n border-color: rgb(250 204 21 / var(--tw-border-opacity));\n}\n\n.active\\:bg-orange-600:active {\n --tw-bg-opacity: 1;\n background-color: rgb(234 88 12 / var(--tw-bg-opacity));\n}\n\n.active\\:brightness-150:active {\n --tw-brightness: brightness(1.5);\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n\n.group:hover .group-hover\\:rotate-90 {\n --tw-rotate: 90deg;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n\n.group:hover .group-hover\\:text-black {\n --tw-text-opacity: 1;\n color: rgb(0 0 0 / var(--tw-text-opacity));\n}\n\n.aria-busy\\:pointer-events-none[aria-busy="true"] {\n pointer-events: none;\n}\n\n.aria-disabled\\:pointer-events-none[aria-disabled="true"] {\n pointer-events: none;\n}\n\n.aria-disabled\\:opacity-50[aria-disabled="true"] {\n opacity: 0.5;\n}\n\n.group\\/button[aria-busy="true"] .group-aria-busy\\/button\\:translate-x-0 {\n --tw-translate-x: 0px;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n\n.group[aria-busy="true"] .group-aria-busy\\:scale-100 {\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n\n.group[aria-busy="true"] .group-aria-busy\\:scale-125 {\n --tw-scale-x: 1.25;\n --tw-scale-y: 1.25;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n\n.group\\/button[aria-busy="true"] .group-aria-busy\\/button\\:opacity-100 {\n opacity: 1;\n}\n\n.group[aria-busy="true"] .group-aria-busy\\:opacity-0 {\n opacity: 0;\n}\n\n.group[aria-busy="true"] .group-aria-busy\\:opacity-100 {\n opacity: 1;\n}\n\n.group\\/button[aria-busy="true"] .group-aria-busy\\/button\\:duration-300 {\n transition-duration: 300ms;\n}\n\n.data-\\[highlighted\\]\\:bg-neutral-200[data-highlighted] {\n --tw-bg-opacity: 1;\n background-color: rgb(229 229 229 / var(--tw-bg-opacity));\n}\n\n.links\\:font-medium a[href]:not(.links-unset) {\n font-weight: 500;\n}\n\n.links\\:text-white a[href]:not(.links-unset) {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity));\n}\n\n.links\\:underline a[href]:not(.links-unset) {\n text-decoration-line: underline;\n}\n\n.links\\:decoration-neutral-500 a[href]:not(.links-unset) {\n text-decoration-color: #737373;\n}\n\n.links\\:underline-offset-4 a[href]:not(.links-unset) {\n text-underline-offset: 4px;\n}\n\n.hover\\:links\\:decoration-orange-500 a[href]:not(.links-unset):hover {\n text-decoration-color: #f97316;\n}\n\n@media (min-width: 640px) {\n\n .sm\\:items-center {\n align-items: center;\n }\n}\n\n.dark\\:border-neutral-700:where([data-theme="dark"], [data-theme="dark"] *) {\n --tw-border-opacity: 1;\n border-color: rgb(64 64 64 / var(--tw-border-opacity));\n}\n\n.dark\\:bg-neutral-800:where([data-theme="dark"], [data-theme="dark"] *) {\n --tw-bg-opacity: 1;\n background-color: rgb(38 38 38 / var(--tw-bg-opacity));\n}\n\n.dark\\:bg-red-900:where([data-theme="dark"], [data-theme="dark"] *) {\n --tw-bg-opacity: 1;\n background-color: rgb(127 29 29 / var(--tw-bg-opacity));\n}\n\n.dark\\:bg-white\\/10:where([data-theme="dark"], [data-theme="dark"] *) {\n background-color: rgb(255 255 255 / 0.1);\n}\n\n.dark\\:text-neutral-400:where([data-theme="dark"], [data-theme="dark"] *) {\n --tw-text-opacity: 1;\n color: rgb(163 163 163 / var(--tw-text-opacity));\n}\n\n.dark\\:text-red-50:where([data-theme="dark"], [data-theme="dark"] *) {\n --tw-text-opacity: 1;\n color: rgb(254 242 242 / var(--tw-text-opacity));\n}\n\n.dark\\:text-white:where([data-theme="dark"], [data-theme="dark"] *) {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity));\n}\n\n.dark\\:hover\\:bg-neutral-700:hover:where([data-theme="dark"], [data-theme="dark"] *) {\n --tw-bg-opacity: 1;\n background-color: rgb(64 64 64 / var(--tw-bg-opacity));\n}\n\n.group:hover .dark\\:group-hover\\:text-white:where([data-theme="dark"], [data-theme="dark"] *) {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity));\n}\n';
|
|
19
|
+
|
|
20
|
+
// src/ui/Shadow.tsx
|
|
21
|
+
import { useResizeObserver } from "usehooks-ts";
|
|
22
|
+
import { mergeRefs } from "react-merge-refs";
|
|
23
|
+
|
|
24
|
+
// src/ui/FrameProvider.tsx
|
|
25
|
+
import { createContext, useContext } from "react";
|
|
26
|
+
import { jsx } from "react/jsx-runtime";
|
|
27
|
+
var Context = createContext(null);
|
|
28
|
+
function FrameProvider({ frame, children }) {
|
|
29
|
+
const value = useContext(Context);
|
|
30
|
+
if (value) throw new Error("`FrameProvider` can only be used once.");
|
|
31
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: { frame }, children });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/useTheme.ts
|
|
35
|
+
import { useMediaQuery } from "usehooks-ts";
|
|
36
|
+
|
|
37
|
+
// src/EntryKitConfigProvider.tsx
|
|
38
|
+
import "@rainbow-me/rainbowkit/styles.css";
|
|
39
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
40
|
+
import { RainbowKitProvider, midnightTheme } from "@rainbow-me/rainbowkit";
|
|
41
|
+
import { useChains } from "wagmi";
|
|
42
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
43
|
+
var Context2 = createContext2(null);
|
|
44
|
+
function EntryKitConfigProvider({ config, children }) {
|
|
45
|
+
const currentConfig = useContext2(Context2);
|
|
46
|
+
if (currentConfig) throw new Error("`EntryKitProvider` can only be used once.");
|
|
47
|
+
const chains = useChains();
|
|
48
|
+
const chain = chains.find(({ id }) => id === config.chainId);
|
|
49
|
+
if (!chain) throw new Error(`Could not find configured chain for chain ID ${config.chainId}.`);
|
|
50
|
+
return /* @__PURE__ */ jsx2(
|
|
51
|
+
RainbowKitProvider,
|
|
52
|
+
{
|
|
53
|
+
initialChain: 0,
|
|
54
|
+
appInfo: {
|
|
55
|
+
appName: config.appName
|
|
56
|
+
// TODO: learn more and disclaimer
|
|
57
|
+
},
|
|
58
|
+
theme: midnightTheme({ borderRadius: "none" }),
|
|
59
|
+
children: /* @__PURE__ */ jsx2(Context2.Provider, { value: { ...config, chain }, children })
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
function useEntryKitConfig() {
|
|
64
|
+
const config = useContext2(Context2);
|
|
65
|
+
if (!config) throw new Error("`useEntryKitConfig` can only be used within a `EntryKitProvider`.");
|
|
66
|
+
return config;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/useTheme.ts
|
|
70
|
+
function useTheme() {
|
|
71
|
+
const { theme: initialTheme } = useEntryKitConfig();
|
|
72
|
+
const darkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
73
|
+
const theme = initialTheme ?? (darkMode ? "dark" : "light");
|
|
74
|
+
return theme;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/ui/Shadow.tsx
|
|
78
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
79
|
+
function Resizer({
|
|
80
|
+
onSize,
|
|
81
|
+
...props
|
|
82
|
+
}) {
|
|
83
|
+
const ref = useRef(null);
|
|
84
|
+
useResizeObserver({ ref, onResize: onSize });
|
|
85
|
+
return /* @__PURE__ */ jsx3("div", { ref, ...props, style: { ...props.style, display: "inline-grid" } });
|
|
86
|
+
}
|
|
87
|
+
var Shadow = forwardRef(function Shadow2({ mode, children }, forwardedRef) {
|
|
88
|
+
const frameRef = useRef(null);
|
|
89
|
+
const [loaded, setLoaded] = useState(false);
|
|
90
|
+
const frame = loaded ? frameRef.current : null;
|
|
91
|
+
const [frameSize, setFrameSize] = useState({
|
|
92
|
+
width: void 0,
|
|
93
|
+
height: void 0
|
|
94
|
+
});
|
|
95
|
+
const frameDocument = frame?.contentDocument;
|
|
96
|
+
const theme = useTheme();
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (frameDocument) {
|
|
99
|
+
frameDocument.body.setAttribute("data-theme", theme);
|
|
100
|
+
}
|
|
101
|
+
}, [frameDocument, theme]);
|
|
102
|
+
const frameStyle = mode === "modal" ? {
|
|
103
|
+
all: "unset",
|
|
104
|
+
display: "block",
|
|
105
|
+
position: "fixed",
|
|
106
|
+
inset: "0",
|
|
107
|
+
width: "100%",
|
|
108
|
+
height: "100%",
|
|
109
|
+
zIndex: "2147483646"
|
|
110
|
+
} : frameSize.width && frameSize.height ? {
|
|
111
|
+
all: "unset",
|
|
112
|
+
display: "inline-grid",
|
|
113
|
+
width: `${frameSize.width}px`,
|
|
114
|
+
height: `${frameSize.height}px`
|
|
115
|
+
} : {
|
|
116
|
+
all: "unset",
|
|
117
|
+
display: "block",
|
|
118
|
+
position: "fixed",
|
|
119
|
+
inset: "0",
|
|
120
|
+
width: "100%",
|
|
121
|
+
height: "100%",
|
|
122
|
+
opacity: 0,
|
|
123
|
+
pointerEvents: "none"
|
|
124
|
+
};
|
|
125
|
+
return /* @__PURE__ */ jsx3(
|
|
126
|
+
"iframe",
|
|
127
|
+
{
|
|
128
|
+
ref: mergeRefs([forwardedRef, frameRef]),
|
|
129
|
+
style: frameStyle,
|
|
130
|
+
onLoad: () => setLoaded(true),
|
|
131
|
+
srcDoc: "<!doctype html><title>\u2026</title>",
|
|
132
|
+
children: frameDocument ? ReactDOM.createPortal(
|
|
133
|
+
/* @__PURE__ */ jsxs(FrameProvider, { frame, children: [
|
|
134
|
+
/* @__PURE__ */ jsx3("div", { children: mode === "modal" ? children : /* @__PURE__ */ jsx3(Resizer, { onSize: setFrameSize, children }) }),
|
|
135
|
+
/* @__PURE__ */ jsx3("style", { dangerouslySetInnerHTML: { __html: tailwind_default } })
|
|
136
|
+
] }),
|
|
137
|
+
frameDocument.body
|
|
138
|
+
) : null
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// src/ui/Modal.tsx
|
|
144
|
+
import { twMerge } from "tailwind-merge";
|
|
145
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
146
|
+
function Modal({ open, onOpenChange, children }) {
|
|
147
|
+
return /* @__PURE__ */ jsx4(DialogRoot, { open, onOpenChange, children: /* @__PURE__ */ jsx4(DialogPortal, { children: /* @__PURE__ */ jsxs2(Shadow, { mode: "modal", children: [
|
|
148
|
+
/* @__PURE__ */ jsx4("div", { className: twMerge("fixed inset-0", "bg-neutral-800/85", "animate-in animate-duration-300 fade-in") }),
|
|
149
|
+
/* @__PURE__ */ jsx4(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
className: twMerge(
|
|
153
|
+
"fixed inset-0",
|
|
154
|
+
"grid items-end sm:items-center",
|
|
155
|
+
"animate-in animate-duration-300 fade-in slide-in-from-bottom-16"
|
|
156
|
+
),
|
|
157
|
+
children: /* @__PURE__ */ jsx4("div", { children: /* @__PURE__ */ jsx4(
|
|
158
|
+
DialogContent,
|
|
159
|
+
{
|
|
160
|
+
className: "outline-none w-full max-w-[26rem] mx-auto",
|
|
161
|
+
"aria-describedby": void 0,
|
|
162
|
+
onOpenAutoFocus: (event) => {
|
|
163
|
+
event.preventDefault();
|
|
164
|
+
},
|
|
165
|
+
children
|
|
166
|
+
}
|
|
167
|
+
) })
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
] }) }) });
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// src/useAccountModal.ts
|
|
174
|
+
import { useCallback, useMemo } from "react";
|
|
175
|
+
import { useStore } from "zustand";
|
|
176
|
+
import { createStore } from "zustand/vanilla";
|
|
177
|
+
var store = createStore(() => ({ open: false }));
|
|
178
|
+
function useAccountModal() {
|
|
179
|
+
const accountModalOpen = useStore(store, (state) => state.open);
|
|
180
|
+
const openAccountModal = useCallback(() => {
|
|
181
|
+
store.setState({ open: true });
|
|
182
|
+
}, []);
|
|
183
|
+
const closeAccountModal = useCallback(() => {
|
|
184
|
+
store.setState({ open: false });
|
|
185
|
+
}, []);
|
|
186
|
+
const toggleAccountModal = useCallback((open) => {
|
|
187
|
+
store.setState({ open });
|
|
188
|
+
}, []);
|
|
189
|
+
return useMemo(
|
|
190
|
+
() => ({
|
|
191
|
+
accountModalOpen,
|
|
192
|
+
openAccountModal,
|
|
193
|
+
closeAccountModal,
|
|
194
|
+
toggleAccountModal
|
|
195
|
+
}),
|
|
196
|
+
[accountModalOpen, openAccountModal, closeAccountModal, toggleAccountModal]
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// src/AccountModal.tsx
|
|
201
|
+
import { twMerge as twMerge11 } from "tailwind-merge";
|
|
202
|
+
|
|
203
|
+
// src/AccountModalContent.tsx
|
|
204
|
+
import { useAccount as useAccount2, useConnectorClient } from "wagmi";
|
|
205
|
+
|
|
206
|
+
// src/ConnectWallet.tsx
|
|
207
|
+
import { useAccount } from "wagmi";
|
|
208
|
+
|
|
209
|
+
// src/ui/Button.tsx
|
|
210
|
+
import { twMerge as twMerge3 } from "tailwind-merge";
|
|
211
|
+
|
|
212
|
+
// src/icons/PendingIcon.tsx
|
|
213
|
+
import { twMerge as twMerge2 } from "tailwind-merge";
|
|
214
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
215
|
+
function PendingIcon({ className, ...props }) {
|
|
216
|
+
return /* @__PURE__ */ jsxs3(
|
|
217
|
+
"svg",
|
|
218
|
+
{
|
|
219
|
+
className: twMerge2("-my-[0.125em] h-[1.25em] w-[1.25em] animate-spin", className),
|
|
220
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
221
|
+
fill: "none",
|
|
222
|
+
viewBox: "0 0 24 24",
|
|
223
|
+
...props,
|
|
224
|
+
children: [
|
|
225
|
+
/* @__PURE__ */ jsx5("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
226
|
+
/* @__PURE__ */ jsx5(
|
|
227
|
+
"path",
|
|
228
|
+
{
|
|
229
|
+
className: "opacity-75",
|
|
230
|
+
fill: "currentColor",
|
|
231
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// src/ui/Button.tsx
|
|
240
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
241
|
+
var buttonClassName = ({ variant = "secondary" } = {}) => twMerge3(
|
|
242
|
+
"group/button self-center leading-none outline-none border-4 border-transparent",
|
|
243
|
+
"transition hover:brightness-125 active:brightness-150",
|
|
244
|
+
"focus:border-orange-500",
|
|
245
|
+
"aria-disabled:pointer-events-none aria-busy:pointer-events-none",
|
|
246
|
+
// TODO: better disabled state
|
|
247
|
+
"aria-disabled:opacity-50",
|
|
248
|
+
"p-[.75em] font-medium",
|
|
249
|
+
{
|
|
250
|
+
primary: twMerge3("bg-orange-600 text-white focus:border-yellow-400"),
|
|
251
|
+
secondary: twMerge3("bg-neutral-700 text-white focus:border-orange-500"),
|
|
252
|
+
tertiary: twMerge3("bg-neutral-800 text-white focus:border-orange-500")
|
|
253
|
+
}[variant]
|
|
254
|
+
);
|
|
255
|
+
var Button = ({ pending, variant, type, className, children, disabled, ...props }) => {
|
|
256
|
+
return /* @__PURE__ */ jsx6(
|
|
257
|
+
"button",
|
|
258
|
+
{
|
|
259
|
+
type: type || "button",
|
|
260
|
+
className: twMerge3(buttonClassName({ variant, pending }), className),
|
|
261
|
+
"aria-busy": pending,
|
|
262
|
+
"aria-disabled": disabled,
|
|
263
|
+
disabled: disabled || pending,
|
|
264
|
+
...props,
|
|
265
|
+
children: /* @__PURE__ */ jsxs4("span", { className: "grid grid-cols-[1fr_auto_1fr] gap-2", children: [
|
|
266
|
+
/* @__PURE__ */ jsx6("span", { className: "flex items-center justify-end text-[.75em]", children: /* @__PURE__ */ jsx6("span", { className: "transition opacity-0 translate-x-2 group-aria-busy/button:opacity-100 group-aria-busy/button:translate-x-0 duration-100 group-aria-busy/button:duration-300", children: /* @__PURE__ */ jsx6(PendingIcon, {}) }) }),
|
|
267
|
+
/* @__PURE__ */ jsx6("span", { children })
|
|
268
|
+
] })
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// src/ConnectWallet.tsx
|
|
274
|
+
import { useConnectModal } from "@rainbow-me/rainbowkit";
|
|
275
|
+
|
|
276
|
+
// src/icons/Logo.tsx
|
|
277
|
+
import { twMerge as twMerge4 } from "tailwind-merge";
|
|
278
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
279
|
+
function Logo({ className, ...props }) {
|
|
280
|
+
return /* @__PURE__ */ jsxs5(
|
|
281
|
+
"svg",
|
|
282
|
+
{
|
|
283
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
284
|
+
viewBox: "0 0 8 8",
|
|
285
|
+
fill: "currentColor",
|
|
286
|
+
shapeRendering: "crispEdges",
|
|
287
|
+
className: twMerge4("-my-[0.125em] h-[1.25em] w-[1.25em]", className),
|
|
288
|
+
...props,
|
|
289
|
+
children: [
|
|
290
|
+
/* @__PURE__ */ jsx7("path", { d: "M0 0h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm2-1h1v1H7zm0 1h1v1H7zM6 7h1v1H6zm1-2h1v1H7zm0-1h1v1H7zm0-1h1v1H7z" }),
|
|
291
|
+
/* @__PURE__ */ jsx7(
|
|
292
|
+
"path",
|
|
293
|
+
{
|
|
294
|
+
d: "M2 2h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm1-3h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm0 1h1v1H5zm0 1h1v1H5zm0 1h1v1H5zM4 5h1v1H4zM3 5h1v1H3z",
|
|
295
|
+
opacity: ".5"
|
|
296
|
+
}
|
|
297
|
+
),
|
|
298
|
+
/* @__PURE__ */ jsx7("path", { d: "M7 2h1v1H7zm0-1h1v1H7zM1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm1 0h1v1H6zm1 0h1v1H7z" })
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// src/usePreloadImage.tsx
|
|
305
|
+
import { useQuery } from "@tanstack/react-query";
|
|
306
|
+
function usePreloadImage(url) {
|
|
307
|
+
return useQuery({
|
|
308
|
+
enabled: !!url,
|
|
309
|
+
retry: false,
|
|
310
|
+
retryOnMount: false,
|
|
311
|
+
refetchOnMount: false,
|
|
312
|
+
refetchOnWindowFocus: false,
|
|
313
|
+
queryKey: ["preloadImage", url],
|
|
314
|
+
queryFn: () => new Promise((resolve, reject) => {
|
|
315
|
+
if (!url) throw new Error("usePreloadImage: Must provide `url` to preload image.");
|
|
316
|
+
const image = new Image();
|
|
317
|
+
image.onload = () => resolve(image);
|
|
318
|
+
image.onerror = () => reject(new Error(`usePreloadImage: Could not load image.
|
|
319
|
+
|
|
320
|
+
URL: ${url}`));
|
|
321
|
+
image.src = url;
|
|
322
|
+
})
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// src/AppInfo.tsx
|
|
327
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
328
|
+
function AppInfo() {
|
|
329
|
+
const { appName, appIcon } = useEntryKitConfig();
|
|
330
|
+
const { data: hasAppIcon, isLoading: appIconLoading } = usePreloadImage(appIcon);
|
|
331
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex-grow flex flex-col items-center justify-center gap-2", children: [
|
|
332
|
+
/* @__PURE__ */ jsx8("div", { className: "w-16 h-16 m-2", children: !appIconLoading ? hasAppIcon ? /* @__PURE__ */ jsx8("img", { src: appIcon, className: "w-full h-full object-cover" }) : (
|
|
333
|
+
// TODO: swap with favicon
|
|
334
|
+
/* @__PURE__ */ jsx8(Logo, { className: "w-full h-full text-orange-500 dark:bg-neutral-800" })
|
|
335
|
+
) : null }),
|
|
336
|
+
/* @__PURE__ */ jsx8("div", { className: "text-2xl text-white text-center", children: appName })
|
|
337
|
+
] });
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/ConnectWallet.tsx
|
|
341
|
+
import { twMerge as twMerge5 } from "tailwind-merge";
|
|
342
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
343
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
344
|
+
function ConnectWallet() {
|
|
345
|
+
const userAccount = useAccount();
|
|
346
|
+
const { openConnectModal, connectModalOpen } = useConnectModal();
|
|
347
|
+
const [hasAutoOpened, setHasAutoOpened] = useState2(false);
|
|
348
|
+
useEffect2(() => {
|
|
349
|
+
if (!connectModalOpen && !hasAutoOpened) {
|
|
350
|
+
openConnectModal?.();
|
|
351
|
+
setHasAutoOpened(true);
|
|
352
|
+
}
|
|
353
|
+
}, [connectModalOpen, hasAutoOpened, openConnectModal]);
|
|
354
|
+
return /* @__PURE__ */ jsxs7(
|
|
355
|
+
"div",
|
|
356
|
+
{
|
|
357
|
+
className: twMerge5("flex flex-col gap-6 p-6", "animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),
|
|
358
|
+
children: [
|
|
359
|
+
/* @__PURE__ */ jsx9("div", { className: "p-4", children: /* @__PURE__ */ jsx9(AppInfo, {}) }),
|
|
360
|
+
/* @__PURE__ */ jsx9("div", { className: "self-center flex flex-col gap-2 w-60", children: /* @__PURE__ */ jsx9(
|
|
361
|
+
Button,
|
|
362
|
+
{
|
|
363
|
+
variant: "secondary",
|
|
364
|
+
className: "self-auto flex justify-center",
|
|
365
|
+
disabled: userAccount.status === "connecting",
|
|
366
|
+
onClick: openConnectModal,
|
|
367
|
+
autoFocus: true,
|
|
368
|
+
children: "Connect wallet"
|
|
369
|
+
},
|
|
370
|
+
"create"
|
|
371
|
+
) })
|
|
372
|
+
]
|
|
373
|
+
}
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// src/onboarding/ConnectedSteps.tsx
|
|
378
|
+
import { useEffect as useEffect7, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
379
|
+
import { twMerge as twMerge7 } from "tailwind-merge";
|
|
380
|
+
|
|
381
|
+
// src/onboarding/common.ts
|
|
382
|
+
import { parseEther } from "viem";
|
|
383
|
+
var minGasBalance = parseEther("0.01");
|
|
384
|
+
|
|
385
|
+
// src/onboarding/quarry/useAllowance.ts
|
|
386
|
+
import { useClient } from "wagmi";
|
|
387
|
+
import { queryOptions, useQuery as useQuery2 } from "@tanstack/react-query";
|
|
388
|
+
|
|
389
|
+
// src/quarry/getAllowance.ts
|
|
390
|
+
import { numberToHex } from "viem";
|
|
391
|
+
|
|
392
|
+
// src/quarry/common.ts
|
|
393
|
+
import { defineStore } from "@latticexyz/store";
|
|
394
|
+
import { parseAbi } from "viem";
|
|
395
|
+
var paymasterAbi = parseAbi([
|
|
396
|
+
"error SpenderSystem_AlreadyRegistered(address spender, address user)",
|
|
397
|
+
"error SpenderSystem_HasOwnBalance(address spender)",
|
|
398
|
+
"function registerSpender(address spender)"
|
|
399
|
+
]);
|
|
400
|
+
var paymasterConfig = defineStore({
|
|
401
|
+
namespaces: {
|
|
402
|
+
root: {
|
|
403
|
+
namespace: "",
|
|
404
|
+
tables: {
|
|
405
|
+
Allowance: {
|
|
406
|
+
schema: {
|
|
407
|
+
user: "address",
|
|
408
|
+
allowance: "uint256"
|
|
409
|
+
},
|
|
410
|
+
key: ["user"]
|
|
411
|
+
},
|
|
412
|
+
Grantor: {
|
|
413
|
+
schema: {
|
|
414
|
+
grantor: "address",
|
|
415
|
+
allowance: "uint256"
|
|
416
|
+
},
|
|
417
|
+
key: ["grantor"]
|
|
418
|
+
},
|
|
419
|
+
PassHolder: {
|
|
420
|
+
schema: {
|
|
421
|
+
user: "address",
|
|
422
|
+
passId: "bytes32",
|
|
423
|
+
lastRenewed: "uint256",
|
|
424
|
+
lastClaimed: "uint256"
|
|
425
|
+
},
|
|
426
|
+
key: ["user", "passId"]
|
|
427
|
+
},
|
|
428
|
+
PassConfig: {
|
|
429
|
+
schema: {
|
|
430
|
+
passId: "bytes32",
|
|
431
|
+
claimAmount: "uint256",
|
|
432
|
+
claimInterval: "uint256",
|
|
433
|
+
validityPeriod: "uint256",
|
|
434
|
+
grantor: "address"
|
|
435
|
+
},
|
|
436
|
+
key: ["passId"]
|
|
437
|
+
},
|
|
438
|
+
Spender: {
|
|
439
|
+
schema: {
|
|
440
|
+
spender: "address",
|
|
441
|
+
user: "address"
|
|
442
|
+
},
|
|
443
|
+
key: ["spender"]
|
|
444
|
+
},
|
|
445
|
+
SystemConfig: {
|
|
446
|
+
schema: {
|
|
447
|
+
entryPoint: "address"
|
|
448
|
+
},
|
|
449
|
+
key: []
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
504
453
|
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
454
|
+
});
|
|
455
|
+
var paymasterTables = paymasterConfig.namespaces.root.tables;
|
|
456
|
+
|
|
457
|
+
// src/quarry/getAllowance.ts
|
|
458
|
+
import { getRecord, getStaticDataLocation } from "@latticexyz/store/internal";
|
|
459
|
+
import { getKeyTuple } from "@latticexyz/protocol-parser/internal";
|
|
460
|
+
import { setStorageAt } from "viem/actions";
|
|
461
|
+
|
|
462
|
+
// src/getPaymaster.ts
|
|
463
|
+
function getPaymaster(chain) {
|
|
464
|
+
const contracts = chain.contracts ?? {};
|
|
465
|
+
if ("quarryPaymaster" in contracts && contracts.quarryPaymaster != null) {
|
|
466
|
+
if ("address" in contracts.quarryPaymaster) {
|
|
467
|
+
return {
|
|
468
|
+
type: "quarry",
|
|
469
|
+
address: contracts.quarryPaymaster.address
|
|
470
|
+
};
|
|
471
|
+
}
|
|
511
472
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
473
|
+
if ("paymaster" in contracts && contracts.paymaster != null) {
|
|
474
|
+
if ("address" in contracts.paymaster) {
|
|
475
|
+
return {
|
|
476
|
+
type: "simple",
|
|
477
|
+
address: contracts.paymaster.address
|
|
478
|
+
};
|
|
479
|
+
}
|
|
518
480
|
}
|
|
519
481
|
}
|
|
520
482
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
.
|
|
524
|
-
|
|
483
|
+
// src/quarry/getAllowance.ts
|
|
484
|
+
async function getAllowance({ client, userAddress }) {
|
|
485
|
+
const paymaster = getPaymaster(client.chain);
|
|
486
|
+
if (paymaster?.type !== "quarry") return null;
|
|
487
|
+
const record = await getRecord(client, {
|
|
488
|
+
address: paymaster.address,
|
|
489
|
+
table: paymasterTables.Allowance,
|
|
490
|
+
key: { user: userAddress },
|
|
491
|
+
blockTag: "pending"
|
|
492
|
+
});
|
|
493
|
+
return record.allowance;
|
|
494
|
+
}
|
|
495
|
+
async function setAllowanceSlot({ client, userAddress, allowance }) {
|
|
496
|
+
const paymaster = getPaymaster(client.chain);
|
|
497
|
+
if (paymaster?.type !== "quarry") return;
|
|
498
|
+
const slot = getStaticDataLocation(
|
|
499
|
+
paymasterTables.Allowance.tableId,
|
|
500
|
+
getKeyTuple(paymasterTables.Allowance, { user: userAddress })
|
|
501
|
+
);
|
|
502
|
+
await setStorageAt(
|
|
503
|
+
client.extend(() => ({ mode: "anvil" })),
|
|
504
|
+
{
|
|
505
|
+
address: paymaster.address,
|
|
506
|
+
index: slot,
|
|
507
|
+
value: numberToHex(allowance, { size: 32 })
|
|
508
|
+
}
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// src/onboarding/quarry/useAllowance.ts
|
|
513
|
+
function getAllowanceQueryOptions({
|
|
514
|
+
client,
|
|
515
|
+
userAddress
|
|
516
|
+
}) {
|
|
517
|
+
const queryKey = ["getAllowance", client?.chain.id, userAddress];
|
|
518
|
+
return queryOptions(
|
|
519
|
+
client && userAddress ? {
|
|
520
|
+
queryKey,
|
|
521
|
+
queryFn: () => getAllowance({ client, userAddress })
|
|
522
|
+
} : { queryKey, enabled: false }
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
function useAllowance(userAddress) {
|
|
526
|
+
const { chainId } = useEntryKitConfig();
|
|
527
|
+
const client = useClient({ chainId });
|
|
528
|
+
return useQuery2(getAllowanceQueryOptions({ client, userAddress }));
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// src/onboarding/quarry/useSpender.ts
|
|
532
|
+
import { useClient as useClient2 } from "wagmi";
|
|
533
|
+
import { queryOptions as queryOptions2, useQuery as useQuery3 } from "@tanstack/react-query";
|
|
534
|
+
|
|
535
|
+
// src/onboarding/quarry/getSpender.ts
|
|
536
|
+
import { getRecord as getRecord2 } from "@latticexyz/store/internal";
|
|
537
|
+
async function getSpender({ client, userAddress, sessionAddress }) {
|
|
538
|
+
const paymaster = getPaymaster(client.chain);
|
|
539
|
+
if (paymaster?.type !== "quarry") return null;
|
|
540
|
+
const record = await getRecord2(client, {
|
|
541
|
+
address: paymaster.address,
|
|
542
|
+
table: paymasterTables.Spender,
|
|
543
|
+
key: { spender: sessionAddress },
|
|
544
|
+
blockTag: "pending"
|
|
545
|
+
});
|
|
546
|
+
return record.user.toLowerCase() === userAddress.toLowerCase();
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// src/onboarding/quarry/useSpender.ts
|
|
550
|
+
function getSpenderQueryOptions({
|
|
551
|
+
client,
|
|
552
|
+
userAddress,
|
|
553
|
+
sessionAddress
|
|
554
|
+
}) {
|
|
555
|
+
const queryKey = ["getSpender", client?.chain.id, userAddress, sessionAddress];
|
|
556
|
+
return queryOptions2(
|
|
557
|
+
client && userAddress && sessionAddress ? {
|
|
558
|
+
queryKey,
|
|
559
|
+
queryFn: () => getSpender({ client, userAddress, sessionAddress })
|
|
560
|
+
} : { queryKey, enabled: false }
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// src/onboarding/useDelegation.ts
|
|
565
|
+
import { useClient as useClient3 } from "wagmi";
|
|
566
|
+
import { queryOptions as queryOptions3, useQuery as useQuery4 } from "@tanstack/react-query";
|
|
567
|
+
|
|
568
|
+
// src/onboarding/getDelegation.ts
|
|
569
|
+
import { getRecord as getRecord3 } from "@latticexyz/store/internal";
|
|
570
|
+
|
|
571
|
+
// src/common.ts
|
|
572
|
+
import { resourceToHex } from "@latticexyz/common";
|
|
573
|
+
import { parseAbi as parseAbi2 } from "viem";
|
|
574
|
+
import worldConfig from "@latticexyz/world/mud.config";
|
|
575
|
+
var defaultClientConfig = {
|
|
576
|
+
pollingInterval: 250
|
|
577
|
+
};
|
|
578
|
+
var unlimitedDelegationControlId = resourceToHex({ type: "system", namespace: "", name: "unlimited" });
|
|
579
|
+
var worldTables = worldConfig.namespaces.world.tables;
|
|
580
|
+
var worldAbi = parseAbi2([
|
|
581
|
+
"function registerDelegation(address delegatee, bytes32 delegationControlId, bytes initCallData)"
|
|
582
|
+
]);
|
|
583
|
+
|
|
584
|
+
// src/onboarding/getDelegation.ts
|
|
585
|
+
async function getDelegation({ client, worldAddress, userAddress, sessionAddress }) {
|
|
586
|
+
const record = await getRecord3(client, {
|
|
587
|
+
address: worldAddress,
|
|
588
|
+
table: worldTables.UserDelegationControl,
|
|
589
|
+
key: { delegator: userAddress, delegatee: sessionAddress },
|
|
590
|
+
blockTag: "pending"
|
|
591
|
+
});
|
|
592
|
+
return record.delegationControlId === unlimitedDelegationControlId;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// src/onboarding/useDelegation.ts
|
|
596
|
+
function getDelegationQueryOptions({
|
|
597
|
+
client,
|
|
598
|
+
worldAddress,
|
|
599
|
+
userAddress,
|
|
600
|
+
sessionAddress
|
|
601
|
+
}) {
|
|
602
|
+
const queryKey = ["getDelegation", client?.chain.id, worldAddress, userAddress, sessionAddress];
|
|
603
|
+
return queryOptions3(
|
|
604
|
+
client && userAddress && sessionAddress ? {
|
|
605
|
+
queryKey,
|
|
606
|
+
queryFn: () => getDelegation({ client, worldAddress, userAddress, sessionAddress })
|
|
607
|
+
} : { queryKey, enabled: false }
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// src/onboarding/usePrerequisites.ts
|
|
612
|
+
import { queryOptions as queryOptions5, useQuery as useQuery6, useQueryClient } from "@tanstack/react-query";
|
|
613
|
+
import { useClient as useClient5, useConfig } from "wagmi";
|
|
614
|
+
|
|
615
|
+
// src/useSessionAccount.ts
|
|
616
|
+
import { useClient as useClient4 } from "wagmi";
|
|
617
|
+
import { queryOptions as queryOptions4, useQuery as useQuery5 } from "@tanstack/react-query";
|
|
618
|
+
|
|
619
|
+
// src/getSessionAccount.ts
|
|
620
|
+
import { toSimpleSmartAccount } from "permissionless/accounts";
|
|
621
|
+
|
|
622
|
+
// src/getSessionSigner.ts
|
|
623
|
+
import { isHex } from "viem";
|
|
624
|
+
|
|
625
|
+
// src/store.ts
|
|
626
|
+
import { createStore as createStore2 } from "zustand/vanilla";
|
|
627
|
+
import { persist } from "zustand/middleware";
|
|
628
|
+
var store2 = createStore2(
|
|
629
|
+
persist(
|
|
630
|
+
() => ({
|
|
631
|
+
signers: {}
|
|
632
|
+
}),
|
|
633
|
+
{
|
|
634
|
+
name: "mud:entrykit",
|
|
635
|
+
partialize: ({ signers }) => ({ signers })
|
|
636
|
+
}
|
|
637
|
+
)
|
|
638
|
+
);
|
|
639
|
+
function listener(event) {
|
|
640
|
+
if (event.key === store2.persist.getOptions().name) {
|
|
641
|
+
store2.persist.rehydrate();
|
|
525
642
|
}
|
|
526
643
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
.
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
.
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
.
|
|
653
|
-
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
.h-\\[1\\.25em\\] {
|
|
665
|
-
height: 1.25em;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
.h-\\[1em\\] {
|
|
669
|
-
height: 1em;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
.h-full {
|
|
673
|
-
height: 100%;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
.max-h-32 {
|
|
677
|
-
max-height: 8rem;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
.min-h-\\[22rem\\] {
|
|
681
|
-
min-height: 22rem;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
.min-h-\\[26rem\\] {
|
|
685
|
-
min-height: 26rem;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
.w-16 {
|
|
689
|
-
width: 4rem;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
.w-28 {
|
|
693
|
-
width: 7rem;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
.w-4 {
|
|
697
|
-
width: 1rem;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
.w-48 {
|
|
701
|
-
width: 12rem;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
.w-6 {
|
|
705
|
-
width: 1.5rem;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
.w-60 {
|
|
709
|
-
width: 15rem;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
.w-\\[0\\.6em\\] {
|
|
713
|
-
width: 0.6em;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
.w-\\[1\\.25em\\] {
|
|
717
|
-
width: 1.25em;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
.w-full {
|
|
721
|
-
width: 100%;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
.max-w-\\[26rem\\] {
|
|
725
|
-
max-width: 26rem;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
.flex-shrink-0 {
|
|
729
|
-
flex-shrink: 0;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
.flex-grow {
|
|
733
|
-
flex-grow: 1;
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
.translate-x-2 {
|
|
737
|
-
--tw-translate-x: 0.5rem;
|
|
738
|
-
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
.scale-100 {
|
|
742
|
-
--tw-scale-x: 1;
|
|
743
|
-
--tw-scale-y: 1;
|
|
744
|
-
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
.scale-50 {
|
|
748
|
-
--tw-scale-x: .5;
|
|
749
|
-
--tw-scale-y: .5;
|
|
750
|
-
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
@keyframes spin {
|
|
754
|
-
|
|
755
|
-
to {
|
|
756
|
-
transform: rotate(360deg);
|
|
644
|
+
window.addEventListener("storage", listener);
|
|
645
|
+
|
|
646
|
+
// src/getSessionSigner.ts
|
|
647
|
+
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
|
|
648
|
+
function getSessionSigner(userAddress) {
|
|
649
|
+
const label = userAddress.toLowerCase();
|
|
650
|
+
const sessionSignerPrivateKey = store2.getState().signers[label] ?? (() => {
|
|
651
|
+
const deprecatedPrivateKey = localStorage.getItem(`mud:appSigner:privateKey:${userAddress.toLowerCase()}`)?.replace(/^"(.*)"$/, "$1");
|
|
652
|
+
const privateKey = isHex(deprecatedPrivateKey) ? deprecatedPrivateKey : generatePrivateKey();
|
|
653
|
+
store2.setState((state) => ({
|
|
654
|
+
signers: {
|
|
655
|
+
...state.signers,
|
|
656
|
+
[label]: privateKey
|
|
657
|
+
}
|
|
658
|
+
}));
|
|
659
|
+
return privateKey;
|
|
660
|
+
})();
|
|
661
|
+
return privateKeyToAccount(sessionSignerPrivateKey);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// src/getSessionAccount.ts
|
|
665
|
+
async function getSessionAccount({
|
|
666
|
+
client,
|
|
667
|
+
userAddress
|
|
668
|
+
}) {
|
|
669
|
+
const signer = getSessionSigner(userAddress);
|
|
670
|
+
const account = await toSimpleSmartAccount({ client, owner: signer });
|
|
671
|
+
return account;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// src/useSessionAccount.ts
|
|
675
|
+
function getSessionAccountQueryOptions({
|
|
676
|
+
client,
|
|
677
|
+
userAddress
|
|
678
|
+
}) {
|
|
679
|
+
const queryKey = ["getSessionAccount", client?.chain.id, userAddress];
|
|
680
|
+
return queryOptions4(
|
|
681
|
+
client && userAddress ? {
|
|
682
|
+
queryKey,
|
|
683
|
+
queryFn: () => getSessionAccount({ client, userAddress }),
|
|
684
|
+
staleTime: Infinity
|
|
685
|
+
} : { queryKey, enabled: false }
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
function useSessionAccount(userAddress) {
|
|
689
|
+
const { chainId } = useEntryKitConfig();
|
|
690
|
+
const client = useClient4({ chainId });
|
|
691
|
+
return useQuery5(getSessionAccountQueryOptions({ userAddress, client }));
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// src/onboarding/usePrerequisites.ts
|
|
695
|
+
import { getBalanceQueryOptions } from "wagmi/query";
|
|
696
|
+
function getPrequisitesQueryOptions({
|
|
697
|
+
queryClient,
|
|
698
|
+
config,
|
|
699
|
+
client,
|
|
700
|
+
userAddress,
|
|
701
|
+
worldAddress
|
|
702
|
+
}) {
|
|
703
|
+
const queryKey = ["getPrerequisites", client?.chain.id, userAddress];
|
|
704
|
+
return queryOptions5(
|
|
705
|
+
client && userAddress ? {
|
|
706
|
+
queryKey,
|
|
707
|
+
queryFn: async () => {
|
|
708
|
+
const paymaster = getPaymaster(client.chain);
|
|
709
|
+
const { address: sessionAddress } = await queryClient.fetchQuery(
|
|
710
|
+
getSessionAccountQueryOptions({ client, userAddress })
|
|
711
|
+
);
|
|
712
|
+
const [sessionBalance, allowance, spender, hasDelegation] = await Promise.all([
|
|
713
|
+
!paymaster ? queryClient.fetchQuery(
|
|
714
|
+
getBalanceQueryOptions(config, { chainId: client.chain.id, address: sessionAddress })
|
|
715
|
+
) : null,
|
|
716
|
+
paymaster?.type === "quarry" ? queryClient.fetchQuery(getAllowanceQueryOptions({ client, userAddress })) : null,
|
|
717
|
+
paymaster?.type === "quarry" ? queryClient.fetchQuery(getSpenderQueryOptions({ client, userAddress, sessionAddress })) : null,
|
|
718
|
+
queryClient.fetchQuery(getDelegationQueryOptions({ client, worldAddress, userAddress, sessionAddress }))
|
|
719
|
+
]);
|
|
720
|
+
const hasAllowance = allowance == null || allowance >= minGasBalance;
|
|
721
|
+
const isSpender = spender == null ? true : spender;
|
|
722
|
+
const hasGasBalance = sessionBalance == null || sessionBalance.value >= minGasBalance;
|
|
723
|
+
return {
|
|
724
|
+
sessionAddress,
|
|
725
|
+
hasAllowance,
|
|
726
|
+
isSpender,
|
|
727
|
+
hasGasBalance,
|
|
728
|
+
hasDelegation,
|
|
729
|
+
complete: hasAllowance && isSpender && hasDelegation
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
} : { queryKey, enabled: false }
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
function usePrerequisites(userAddress) {
|
|
736
|
+
const queryClient = useQueryClient();
|
|
737
|
+
const { chainId, worldAddress } = useEntryKitConfig();
|
|
738
|
+
const config = useConfig();
|
|
739
|
+
const client = useClient5({ chainId });
|
|
740
|
+
const prereqs = useQuery6(
|
|
741
|
+
getPrequisitesQueryOptions({
|
|
742
|
+
config,
|
|
743
|
+
queryClient,
|
|
744
|
+
client,
|
|
745
|
+
userAddress,
|
|
746
|
+
worldAddress
|
|
747
|
+
}),
|
|
748
|
+
queryClient
|
|
749
|
+
);
|
|
750
|
+
return prereqs;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
// src/onboarding/Wallet.tsx
|
|
754
|
+
import { useDisconnect } from "wagmi";
|
|
755
|
+
|
|
756
|
+
// src/useENS.ts
|
|
757
|
+
import { useQuery as useQuery7 } from "@tanstack/react-query";
|
|
758
|
+
function useENS(address) {
|
|
759
|
+
const normalizedAddress = address?.toLowerCase();
|
|
760
|
+
return useQuery7({
|
|
761
|
+
enabled: !!normalizedAddress,
|
|
762
|
+
queryKey: ["ens", normalizedAddress],
|
|
763
|
+
queryFn: async () => {
|
|
764
|
+
const data = await fetch(`https://api.ensideas.com/ens/resolve/${normalizedAddress}`).then((res) => res.json());
|
|
765
|
+
return {
|
|
766
|
+
address: data.address ?? void 0,
|
|
767
|
+
name: data.name ?? void 0,
|
|
768
|
+
displayName: data.displayName ?? void 0,
|
|
769
|
+
avatar: data.avatar ?? void 0
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// src/ui/TruncatedHex.tsx
|
|
776
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
777
|
+
function TruncatedHex({ hex }) {
|
|
778
|
+
if (hex.length <= 10) {
|
|
779
|
+
return /* @__PURE__ */ jsx10("span", { title: hex, children: hex });
|
|
757
780
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
.
|
|
761
|
-
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
.
|
|
773
|
-
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
.
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
.
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
.
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
.
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
.
|
|
869
|
-
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
.
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
.
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
.
|
|
910
|
-
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
.
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
.
|
|
946
|
-
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
.
|
|
958
|
-
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
.
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
.
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
.
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
.
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
.
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
.
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
.
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
.
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
.
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
781
|
+
return /* @__PURE__ */ jsxs8("span", { title: hex, children: [
|
|
782
|
+
/* @__PURE__ */ jsx10("span", { className: "after:select-none after:content-['\u2026']", children: hex.slice(0, 6) }),
|
|
783
|
+
/* @__PURE__ */ jsx10("span", { className: "tracking-[-1ch] text-transparent", children: hex.slice(6, -4) }),
|
|
784
|
+
hex.slice(-4)
|
|
785
|
+
] });
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// src/onboarding/Wallet.tsx
|
|
789
|
+
import { useEffect as useEffect3 } from "react";
|
|
790
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
791
|
+
function Wallet({ isActive, isExpanded, userAddress }) {
|
|
792
|
+
const { data: ens, error: ensError } = useENS(userAddress);
|
|
793
|
+
useEffect3(() => {
|
|
794
|
+
if (ensError) {
|
|
795
|
+
console.log("Could not get ENS", ensError);
|
|
796
|
+
}
|
|
797
|
+
}, [ensError]);
|
|
798
|
+
const { disconnect, isPending: disconnectIsPending } = useDisconnect();
|
|
799
|
+
const { closeAccountModal } = useAccountModal();
|
|
800
|
+
return /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-4", children: [
|
|
801
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex justify-between gap-4", children: [
|
|
802
|
+
/* @__PURE__ */ jsxs9("div", { children: [
|
|
803
|
+
/* @__PURE__ */ jsx11("div", { children: "Account" }),
|
|
804
|
+
/* @__PURE__ */ jsx11("div", { className: "font-mono text-white", children: ens?.name ?? /* @__PURE__ */ jsx11(TruncatedHex, { hex: userAddress }) })
|
|
805
|
+
] }),
|
|
806
|
+
/* @__PURE__ */ jsx11(
|
|
807
|
+
Button,
|
|
808
|
+
{
|
|
809
|
+
variant: isActive ? "primary" : "tertiary",
|
|
810
|
+
className: "flex-shrink-0 text-sm p-1 w-28",
|
|
811
|
+
autoFocus: isActive,
|
|
812
|
+
pending: disconnectIsPending,
|
|
813
|
+
onClick: () => {
|
|
814
|
+
closeAccountModal();
|
|
815
|
+
disconnect();
|
|
816
|
+
},
|
|
817
|
+
children: "Sign out"
|
|
818
|
+
}
|
|
819
|
+
)
|
|
820
|
+
] }),
|
|
821
|
+
isExpanded ? /* @__PURE__ */ jsx11("p", { className: "text-sm", children: "Each of your onchain actions in this app is associated with your account." }) : null
|
|
822
|
+
] });
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// src/onboarding/quarry/useClaimGasPass.ts
|
|
826
|
+
import { parseEther as parseEther2 } from "viem";
|
|
827
|
+
import { useMutation, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
828
|
+
|
|
829
|
+
// src/quarry/transports/quarryPassIssuer.ts
|
|
830
|
+
import { http } from "viem";
|
|
831
|
+
function quarryPassIssuer() {
|
|
832
|
+
return ({ chain }) => {
|
|
833
|
+
if (!chain) throw new Error("No chain provided to issuer transport.");
|
|
834
|
+
const url = "quarryPassIssuer" in chain.rpcUrls ? chain.rpcUrls.quarryPassIssuer.http[0] : void 0;
|
|
835
|
+
if (!url) throw new Error(`No \`quarryPassIssuer\` RPC URL found for chain ${chain.id}.`);
|
|
836
|
+
return http(url)({ chain, retryCount: 0 });
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// src/debug.ts
|
|
841
|
+
import createDebug from "debug";
|
|
842
|
+
var debug = createDebug("mud:entrykit");
|
|
843
|
+
var error = createDebug("mud:entrykit");
|
|
844
|
+
debug.log = console.debug.bind(console);
|
|
845
|
+
error.log = console.error.bind(console);
|
|
846
|
+
|
|
847
|
+
// src/quarry/debug.ts
|
|
848
|
+
var debug2 = debug.extend("quarry");
|
|
849
|
+
|
|
850
|
+
// src/quarry/claimGasPass.ts
|
|
851
|
+
async function claimGasPass({ chain, userAddress }) {
|
|
852
|
+
const transport = quarryPassIssuer()({ chain });
|
|
853
|
+
debug2("Issuing gas pass to", userAddress);
|
|
854
|
+
await transport.request({
|
|
855
|
+
method: "quarry_issuePass",
|
|
856
|
+
params: ["0x01", userAddress]
|
|
857
|
+
});
|
|
858
|
+
debug2("Claiming gas allowance for", userAddress);
|
|
859
|
+
await transport.request({
|
|
860
|
+
method: "quarry_claimAllowance",
|
|
861
|
+
params: ["0x01", userAddress]
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// src/onboarding/quarry/useClaimGasPass.ts
|
|
866
|
+
import { useClient as useClient6 } from "wagmi";
|
|
867
|
+
function useClaimGasPass() {
|
|
868
|
+
const queryClient = useQueryClient2();
|
|
869
|
+
const { chain } = useEntryKitConfig();
|
|
870
|
+
const client = useClient6({ chainId: chain.id });
|
|
871
|
+
const mutationKey = ["claimGasPass", chain.id];
|
|
872
|
+
return useMutation({
|
|
873
|
+
mutationKey,
|
|
874
|
+
onError: (error2) => console.error(error2),
|
|
875
|
+
mutationFn: async (userAddress) => {
|
|
876
|
+
if (chain.id === 31337) {
|
|
877
|
+
if (!client) throw new Error("No client?");
|
|
878
|
+
await setAllowanceSlot({ client, userAddress, allowance: parseEther2("1") });
|
|
879
|
+
} else {
|
|
880
|
+
await claimGasPass({ chain, userAddress });
|
|
881
|
+
}
|
|
882
|
+
await Promise.all([
|
|
883
|
+
queryClient.invalidateQueries({ queryKey: ["getAllowance"] }),
|
|
884
|
+
queryClient.invalidateQueries({ queryKey: ["getPrerequisites"] })
|
|
885
|
+
]);
|
|
886
|
+
},
|
|
887
|
+
retry: 0
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// src/icons/EthIcon.tsx
|
|
892
|
+
import { twMerge as twMerge6 } from "tailwind-merge";
|
|
893
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
894
|
+
function EthIcon({ className, ...props }) {
|
|
895
|
+
return /* @__PURE__ */ jsxs10(
|
|
896
|
+
"svg",
|
|
897
|
+
{
|
|
898
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
899
|
+
viewBox: "0 0 263 428",
|
|
900
|
+
fill: "currentColor",
|
|
901
|
+
className: twMerge6("w-[0.6em] h-[1em]", className),
|
|
902
|
+
...props,
|
|
903
|
+
children: [
|
|
904
|
+
/* @__PURE__ */ jsx12("path", { d: "M132 321V428L263 243L132 321Z" }),
|
|
905
|
+
/* @__PURE__ */ jsx12("path", { d: "M0 243L132 321V428", fillOpacity: "0.5" }),
|
|
906
|
+
/* @__PURE__ */ jsx12("path", { d: "M132 0V296L263 218" }),
|
|
907
|
+
/* @__PURE__ */ jsx12("path", { d: "M0 218L132 296V0L0 218Z", fillOpacity: "0.5" })
|
|
908
|
+
]
|
|
909
|
+
}
|
|
910
|
+
);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
// src/formatBalance.ts
|
|
914
|
+
import { formatEther } from "viem";
|
|
915
|
+
function formatBalance(wei) {
|
|
916
|
+
const formatted = formatEther(wei);
|
|
917
|
+
const magnitude = Math.floor(parseFloat(formatted)).toString().length;
|
|
918
|
+
return parseFloat(formatted).toLocaleString("en-US", { maximumFractionDigits: Math.max(0, 6 - magnitude) });
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
// src/ui/Balance.tsx
|
|
922
|
+
import { formatEther as formatEther2 } from "viem";
|
|
923
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
924
|
+
function Balance({ wei }) {
|
|
925
|
+
return /* @__PURE__ */ jsxs11("span", { className: "inline-flex items-center gap-1", title: formatEther2(wei), children: [
|
|
926
|
+
formatBalance(wei),
|
|
927
|
+
" ",
|
|
928
|
+
/* @__PURE__ */ jsx13(EthIcon, {})
|
|
929
|
+
] });
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// src/onboarding/quarry/Allowance.tsx
|
|
933
|
+
import { useEffect as useEffect4 } from "react";
|
|
934
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
935
|
+
function Allowance({ isActive, isExpanded, userAddress }) {
|
|
936
|
+
const allowance = useAllowance(userAddress);
|
|
937
|
+
const claimGasPass2 = useClaimGasPass();
|
|
938
|
+
useEffect4(() => {
|
|
939
|
+
const timer = setTimeout(() => {
|
|
940
|
+
if (isActive && claimGasPass2.status === "idle" && allowance.isSuccess && allowance.data != null && allowance.data < minGasBalance) {
|
|
941
|
+
claimGasPass2.mutate(userAddress);
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
return () => clearTimeout(timer);
|
|
945
|
+
}, [allowance.data, allowance.isSuccess, claimGasPass2, isActive, userAddress]);
|
|
946
|
+
return /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-4", children: [
|
|
947
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex justify-between gap-4", children: [
|
|
948
|
+
/* @__PURE__ */ jsxs12("div", { children: [
|
|
949
|
+
/* @__PURE__ */ jsx14("div", { children: "Allowance" }),
|
|
950
|
+
/* @__PURE__ */ jsx14("div", { className: "font-mono text-white", children: allowance.data != null ? /* @__PURE__ */ jsx14(Balance, { wei: allowance.data }) : /* @__PURE__ */ jsx14(PendingIcon, { className: "text-sm" }) })
|
|
951
|
+
] }),
|
|
952
|
+
/* @__PURE__ */ jsx14(
|
|
953
|
+
Button,
|
|
954
|
+
{
|
|
955
|
+
variant: isActive ? "primary" : "tertiary",
|
|
956
|
+
className: "flex-shrink-0 text-sm p-1 w-28",
|
|
957
|
+
autoFocus: isActive || isExpanded,
|
|
958
|
+
pending: allowance.status === "pending" || claimGasPass2.status === "pending",
|
|
959
|
+
onClick: () => claimGasPass2.mutate(userAddress),
|
|
960
|
+
children: "Top up"
|
|
961
|
+
}
|
|
962
|
+
)
|
|
963
|
+
] }),
|
|
964
|
+
isExpanded ? /* @__PURE__ */ jsx14("p", { className: "text-sm", children: "Your allowance is used to pay for onchain computation." }) : null
|
|
965
|
+
] });
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// src/onboarding/useSetupSession.ts
|
|
969
|
+
import { encodeFunctionData } from "viem";
|
|
970
|
+
import { useMutation as useMutation2, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
971
|
+
import { getAction as getAction3 } from "viem/utils";
|
|
972
|
+
import { sendUserOperation, waitForUserOperationReceipt } from "viem/account-abstraction";
|
|
973
|
+
import { waitForTransactionReceipt } from "viem/actions";
|
|
974
|
+
|
|
975
|
+
// src/utils/defineCall.ts
|
|
976
|
+
function defineCall(call) {
|
|
977
|
+
return call;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// src/onboarding/useSetupSession.ts
|
|
981
|
+
import { useClient as useClient7 } from "wagmi";
|
|
982
|
+
import { resourceToHex as resourceToHex2 } from "@latticexyz/common";
|
|
983
|
+
import IBaseWorldAbi from "@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json";
|
|
984
|
+
|
|
985
|
+
// src/utils/callWithSignature.ts
|
|
986
|
+
import { writeContract as viem_writeContract } from "viem/actions";
|
|
987
|
+
import { getAction as getAction2 } from "viem/utils";
|
|
988
|
+
|
|
989
|
+
// src/utils/signCall.ts
|
|
990
|
+
import { toHex } from "viem";
|
|
991
|
+
import { signTypedData } from "viem/actions";
|
|
992
|
+
import { callWithSignatureTypes } from "@latticexyz/world-module-callwithsignature/internal";
|
|
993
|
+
import { getRecord as getRecord4 } from "@latticexyz/store/internal";
|
|
994
|
+
import moduleConfig from "@latticexyz/world-module-callwithsignature/mud.config";
|
|
995
|
+
import { hexToResource } from "@latticexyz/common";
|
|
996
|
+
import { getAction } from "viem/utils";
|
|
997
|
+
async function signCall({
|
|
998
|
+
userClient,
|
|
999
|
+
worldAddress,
|
|
1000
|
+
systemId,
|
|
1001
|
+
callData,
|
|
1002
|
+
nonce: initialNonce,
|
|
1003
|
+
client
|
|
1004
|
+
}) {
|
|
1005
|
+
const nonce = initialNonce ?? (client ? (await getRecord4(client, {
|
|
1006
|
+
address: worldAddress,
|
|
1007
|
+
table: moduleConfig.tables.CallWithSignatureNonces,
|
|
1008
|
+
key: { signer: userClient.account.address },
|
|
1009
|
+
blockTag: "pending"
|
|
1010
|
+
})).nonce : 0n);
|
|
1011
|
+
const { namespace: systemNamespace, name: systemName } = hexToResource(systemId);
|
|
1012
|
+
return await getAction(
|
|
1013
|
+
userClient,
|
|
1014
|
+
signTypedData,
|
|
1015
|
+
"signTypedData"
|
|
1016
|
+
)({
|
|
1017
|
+
account: userClient.account,
|
|
1018
|
+
domain: {
|
|
1019
|
+
verifyingContract: worldAddress,
|
|
1020
|
+
salt: toHex(userClient.chain.id, { size: 32 })
|
|
1021
|
+
},
|
|
1022
|
+
types: callWithSignatureTypes,
|
|
1023
|
+
primaryType: "Call",
|
|
1024
|
+
message: {
|
|
1025
|
+
signer: userClient.account.address,
|
|
1026
|
+
systemNamespace,
|
|
1027
|
+
systemName,
|
|
1028
|
+
callData,
|
|
1029
|
+
nonce
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// src/utils/callWithSignature.ts
|
|
1035
|
+
import CallWithSignatureAbi from "@latticexyz/world-module-callwithsignature/out/CallWithSignatureSystem.sol/CallWithSignatureSystem.abi.json";
|
|
1036
|
+
async function callWithSignature({
|
|
1037
|
+
sessionClient,
|
|
1038
|
+
...opts
|
|
1039
|
+
}) {
|
|
1040
|
+
const signature = await signCall(opts);
|
|
1041
|
+
return getAction2(
|
|
1042
|
+
sessionClient,
|
|
1043
|
+
viem_writeContract,
|
|
1044
|
+
"writeContract"
|
|
1045
|
+
)({
|
|
1046
|
+
address: opts.worldAddress,
|
|
1047
|
+
abi: CallWithSignatureAbi,
|
|
1048
|
+
functionName: "callWithSignature",
|
|
1049
|
+
args: [opts.userClient.account.address, opts.systemId, opts.callData, signature]
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// src/onboarding/useSetupSession.ts
|
|
1054
|
+
function useSetupSession({ userClient }) {
|
|
1055
|
+
const queryClient = useQueryClient3();
|
|
1056
|
+
const { chainId, worldAddress } = useEntryKitConfig();
|
|
1057
|
+
const client = useClient7({ chainId });
|
|
1058
|
+
const mutationKey = ["setupSession", client?.chain.id, userClient.account.address];
|
|
1059
|
+
return useMutation2({
|
|
1060
|
+
mutationKey,
|
|
1061
|
+
onError: (error2) => console.error(error2),
|
|
1062
|
+
mutationFn: async ({
|
|
1063
|
+
sessionClient,
|
|
1064
|
+
registerSpender,
|
|
1065
|
+
registerDelegation
|
|
1066
|
+
}) => {
|
|
1067
|
+
if (!client) throw new Error("Client not ready.");
|
|
1068
|
+
const paymaster = getPaymaster(client.chain);
|
|
1069
|
+
const sessionAddress = sessionClient.account.address;
|
|
1070
|
+
console.log("setting up session");
|
|
1071
|
+
if (userClient.account.type === "smart") {
|
|
1072
|
+
const calls = [];
|
|
1073
|
+
if (registerSpender && paymaster?.type === "quarry") {
|
|
1074
|
+
console.log("registering spender");
|
|
1075
|
+
calls.push(
|
|
1076
|
+
defineCall({
|
|
1077
|
+
to: paymaster.address,
|
|
1078
|
+
abi: paymasterAbi,
|
|
1079
|
+
functionName: "registerSpender",
|
|
1080
|
+
args: [sessionAddress]
|
|
1081
|
+
})
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
if (registerDelegation) {
|
|
1085
|
+
console.log("registering delegation");
|
|
1086
|
+
calls.push(
|
|
1087
|
+
defineCall({
|
|
1088
|
+
to: worldAddress,
|
|
1089
|
+
abi: worldAbi,
|
|
1090
|
+
functionName: "registerDelegation",
|
|
1091
|
+
args: [sessionAddress, unlimitedDelegationControlId, "0x"]
|
|
1092
|
+
})
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
if (!calls.length) return;
|
|
1096
|
+
console.log("setting up account with", calls, userClient);
|
|
1097
|
+
const hash = await getAction3(userClient, sendUserOperation, "sendUserOperation")({ calls });
|
|
1098
|
+
console.log("got user op hash", hash);
|
|
1099
|
+
const receipt = await getAction3(
|
|
1100
|
+
userClient,
|
|
1101
|
+
waitForUserOperationReceipt,
|
|
1102
|
+
"waitForUserOperationReceipt"
|
|
1103
|
+
)({ hash });
|
|
1104
|
+
console.log("got user op receipt", receipt);
|
|
1105
|
+
if (!receipt.success) {
|
|
1106
|
+
console.error("not successful?", receipt);
|
|
1107
|
+
}
|
|
1108
|
+
} else {
|
|
1109
|
+
const txs = [];
|
|
1110
|
+
if (registerSpender && paymaster?.type === "quarry") {
|
|
1111
|
+
console.log("registering spender");
|
|
1112
|
+
const tx = await callWithSignature({
|
|
1113
|
+
client,
|
|
1114
|
+
userClient,
|
|
1115
|
+
sessionClient,
|
|
1116
|
+
worldAddress: paymaster.address,
|
|
1117
|
+
systemId: resourceToHex2({ type: "system", namespace: "", name: "SpenderSystem" }),
|
|
1118
|
+
callData: encodeFunctionData({
|
|
1119
|
+
abi: paymasterAbi,
|
|
1120
|
+
functionName: "registerSpender",
|
|
1121
|
+
args: [sessionAddress]
|
|
1122
|
+
})
|
|
1123
|
+
});
|
|
1124
|
+
console.log("got spender tx", tx);
|
|
1125
|
+
txs.push(tx);
|
|
1126
|
+
}
|
|
1127
|
+
if (registerDelegation) {
|
|
1128
|
+
console.log("registering delegation");
|
|
1129
|
+
const tx = await callWithSignature({
|
|
1130
|
+
client,
|
|
1131
|
+
userClient,
|
|
1132
|
+
sessionClient,
|
|
1133
|
+
worldAddress,
|
|
1134
|
+
systemId: resourceToHex2({ type: "system", namespace: "", name: "Registration" }),
|
|
1135
|
+
callData: encodeFunctionData({
|
|
1136
|
+
abi: IBaseWorldAbi,
|
|
1137
|
+
functionName: "registerDelegation",
|
|
1138
|
+
args: [sessionAddress, unlimitedDelegationControlId, "0x"]
|
|
1139
|
+
})
|
|
1140
|
+
});
|
|
1141
|
+
console.log("got delegation tx", tx);
|
|
1142
|
+
txs.push(tx);
|
|
1143
|
+
}
|
|
1144
|
+
if (!txs.length) return;
|
|
1145
|
+
console.log("waiting for", txs.length, "receipts");
|
|
1146
|
+
for (const hash of txs) {
|
|
1147
|
+
const receipt = await getAction3(client, waitForTransactionReceipt, "waitForTransactionReceipt")({ hash });
|
|
1148
|
+
console.log("got tx receipt", receipt);
|
|
1149
|
+
if (receipt.status === "reverted") {
|
|
1150
|
+
console.error("tx reverted?", receipt);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
await Promise.all([
|
|
1155
|
+
queryClient.invalidateQueries({ queryKey: ["getSpender"] }),
|
|
1156
|
+
queryClient.invalidateQueries({ queryKey: ["getDelegation"] }),
|
|
1157
|
+
queryClient.invalidateQueries({ queryKey: ["getPrerequisites"] })
|
|
1158
|
+
]);
|
|
1159
|
+
},
|
|
1160
|
+
retry: 0
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
// src/onboarding/Session.tsx
|
|
1165
|
+
import { useEffect as useEffect6 } from "react";
|
|
1166
|
+
|
|
1167
|
+
// src/useSessionClient.ts
|
|
1168
|
+
import { useClient as useClient8 } from "wagmi";
|
|
1169
|
+
import { queryOptions as queryOptions6, useQuery as useQuery8 } from "@tanstack/react-query";
|
|
1170
|
+
|
|
1171
|
+
// src/getSessionClient.ts
|
|
1172
|
+
import { smartAccountActions } from "permissionless";
|
|
1173
|
+
import { callFrom } from "@latticexyz/world/internal";
|
|
1174
|
+
|
|
1175
|
+
// src/createBundlerClient.ts
|
|
1176
|
+
import {
|
|
1177
|
+
createBundlerClient as viem_createBundlerClient
|
|
1178
|
+
} from "viem/account-abstraction";
|
|
1179
|
+
var knownChainFees = /* @__PURE__ */ new Set([
|
|
1180
|
+
// anvil hardcodes fee returned by `eth_maxPriorityFeePerGas`
|
|
1181
|
+
// so we have to override it here
|
|
1182
|
+
// https://github.com/foundry-rs/foundry/pull/8081#issuecomment-2402002485
|
|
1183
|
+
31337,
|
|
1184
|
+
// rhodolite
|
|
1185
|
+
17420,
|
|
1186
|
+
// garnet
|
|
1187
|
+
17069,
|
|
1188
|
+
// redstone
|
|
1189
|
+
690
|
|
1190
|
+
]);
|
|
1191
|
+
function createBundlerClient(config) {
|
|
1192
|
+
const chain = config.chain ?? config.client?.chain;
|
|
1193
|
+
const paymaster = chain ? getPaymaster(chain) : void 0;
|
|
1194
|
+
return viem_createBundlerClient({
|
|
1195
|
+
...defaultClientConfig,
|
|
1196
|
+
paymaster: paymaster ? {
|
|
1197
|
+
getPaymasterData: async () => ({
|
|
1198
|
+
paymaster: paymaster.address,
|
|
1199
|
+
paymasterData: "0x"
|
|
1200
|
+
})
|
|
1201
|
+
} : void 0,
|
|
1202
|
+
// TODO: figure out why viem isn't falling back to `chain.fees.estimateFeesPerGas` when this isn't set
|
|
1203
|
+
userOperation: {
|
|
1204
|
+
estimateFeesPerGas: (
|
|
1205
|
+
// TODO: move this to gas estimator transport?
|
|
1206
|
+
chain && knownChainFees.has(chain.id) ? async () => ({
|
|
1207
|
+
maxFeePerGas: 100000n,
|
|
1208
|
+
maxPriorityFeePerGas: 0n
|
|
1209
|
+
}) : void 0
|
|
1210
|
+
)
|
|
1211
|
+
},
|
|
1212
|
+
...config
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
// src/getBundlerTransport.ts
|
|
1217
|
+
import { transactionQueue } from "@latticexyz/common/actions";
|
|
1218
|
+
import { createClient, fallback, http as http2, keccak256, stringToHex, webSocket } from "viem";
|
|
1219
|
+
import { privateKeyToAccount as privateKeyToAccount2 } from "viem/accounts";
|
|
1220
|
+
|
|
1221
|
+
// src/quarry/transports/userOpExecutor.ts
|
|
1222
|
+
import {
|
|
1223
|
+
createTransport,
|
|
1224
|
+
numberToHex as numberToHex2,
|
|
1225
|
+
parseEther as parseEther3
|
|
1226
|
+
} from "viem";
|
|
1227
|
+
import { entryPoint07Address as entryPoint07Address2 } from "viem/account-abstraction";
|
|
1228
|
+
|
|
1229
|
+
// src/quarry/transports/methods/estimateUserOperationGas.ts
|
|
1230
|
+
import { formatUserOperationRequest } from "viem/account-abstraction";
|
|
1231
|
+
async function estimateUserOperationGas(_params) {
|
|
1232
|
+
return formatUserOperationRequest({
|
|
1233
|
+
callGasLimit: 20000000n,
|
|
1234
|
+
preVerificationGas: 200000n,
|
|
1235
|
+
verificationGasLimit: 2000000n,
|
|
1236
|
+
paymasterVerificationGasLimit: 200000n,
|
|
1237
|
+
paymasterPostOpGasLimit: 200000n
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// src/quarry/transports/methods/sendUserOperation.ts
|
|
1242
|
+
import { parseEventLogs } from "viem";
|
|
1243
|
+
import {
|
|
1244
|
+
formatUserOperation,
|
|
1245
|
+
toPackedUserOperation,
|
|
1246
|
+
getUserOperationHash,
|
|
1247
|
+
entryPoint07Address,
|
|
1248
|
+
entryPoint07Abi
|
|
1249
|
+
} from "viem/account-abstraction";
|
|
1250
|
+
import { waitForTransactionReceipt as waitForTransactionReceipt2, writeContract } from "viem/actions";
|
|
1251
|
+
import { getAction as getAction4 } from "viem/utils";
|
|
1252
|
+
async function sendUserOperation2({
|
|
1253
|
+
executor,
|
|
1254
|
+
rpcUserOp
|
|
1255
|
+
}) {
|
|
1256
|
+
const userOp = formatUserOperation(rpcUserOp);
|
|
1257
|
+
const packedUserOp = toPackedUserOperation(userOp);
|
|
1258
|
+
const userOpHash = getUserOperationHash({
|
|
1259
|
+
userOperation: userOp,
|
|
1260
|
+
chainId: executor.chain.id,
|
|
1261
|
+
entryPointVersion: "0.7",
|
|
1262
|
+
entryPointAddress: entryPoint07Address
|
|
1263
|
+
});
|
|
1264
|
+
const transactionHash = await getAction4(
|
|
1265
|
+
executor,
|
|
1266
|
+
writeContract,
|
|
1267
|
+
"writeContract"
|
|
1268
|
+
)({
|
|
1269
|
+
abi: entryPoint07Abi,
|
|
1270
|
+
address: entryPoint07Address,
|
|
1271
|
+
functionName: "handleOps",
|
|
1272
|
+
args: [[packedUserOp], executor.account.address],
|
|
1273
|
+
chain: executor.chain,
|
|
1274
|
+
account: executor.account
|
|
1275
|
+
});
|
|
1276
|
+
const receipt = await getAction4(
|
|
1277
|
+
executor,
|
|
1278
|
+
waitForTransactionReceipt2,
|
|
1279
|
+
"waitForTransactionReceipt"
|
|
1280
|
+
)({ hash: transactionHash });
|
|
1281
|
+
const parsedLogs = parseEventLogs({
|
|
1282
|
+
logs: receipt.logs,
|
|
1283
|
+
abi: entryPoint07Abi,
|
|
1284
|
+
eventName: "UserOperationEvent"
|
|
1285
|
+
});
|
|
1286
|
+
return {
|
|
1287
|
+
success: parsedLogs[0].args.success,
|
|
1288
|
+
userOpHash,
|
|
1289
|
+
receipt
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// src/quarry/transports/userOpExecutor.ts
|
|
1294
|
+
import { setBalance } from "viem/actions";
|
|
1295
|
+
function userOpExecutor({ executor }) {
|
|
1296
|
+
return () => {
|
|
1297
|
+
debug2("using a local user op executor", executor.account.address);
|
|
1298
|
+
if (executor.chain.id === 31337) {
|
|
1299
|
+
debug2("setting executor balance");
|
|
1300
|
+
setBalance(
|
|
1301
|
+
executor.extend(() => ({ mode: "anvil" })),
|
|
1302
|
+
{
|
|
1303
|
+
address: executor.account.address,
|
|
1304
|
+
value: parseEther3("100")
|
|
1305
|
+
}
|
|
1306
|
+
);
|
|
1307
|
+
}
|
|
1308
|
+
const receipts = /* @__PURE__ */ new Map();
|
|
1309
|
+
const request = async ({ method, params }) => {
|
|
1310
|
+
if (method === "eth_chainId") {
|
|
1311
|
+
return numberToHex2(executor.chain.id);
|
|
1312
|
+
}
|
|
1313
|
+
if (method === "eth_supportedEntryPoints") {
|
|
1314
|
+
return [entryPoint07Address2];
|
|
1315
|
+
}
|
|
1316
|
+
if (method === "eth_sendUserOperation") {
|
|
1317
|
+
const [rpcUserOp, entrypoint] = params;
|
|
1318
|
+
if (entrypoint === entryPoint07Address2) {
|
|
1319
|
+
const result = await sendUserOperation2({ executor, rpcUserOp });
|
|
1320
|
+
receipts.set(result.userOpHash, result);
|
|
1321
|
+
return result.userOpHash;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
if (method === "eth_getUserOperationReceipt") {
|
|
1325
|
+
const [hash] = params;
|
|
1326
|
+
return receipts.get(hash) ?? null;
|
|
1327
|
+
}
|
|
1328
|
+
if (method === "eth_estimateUserOperationGas") {
|
|
1329
|
+
return await estimateUserOperationGas(params);
|
|
1330
|
+
}
|
|
1331
|
+
throw new Error("Method not implemented.");
|
|
1332
|
+
};
|
|
1333
|
+
return createTransport({
|
|
1334
|
+
key: "userOpExecutor",
|
|
1335
|
+
type: "userOpExecutor",
|
|
1336
|
+
name: "User Operation Executor Transport",
|
|
1337
|
+
request
|
|
1338
|
+
});
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
// src/getBundlerTransport.ts
|
|
1343
|
+
function getBundlerTransport(chain) {
|
|
1344
|
+
const bundlerHttpUrl = chain.rpcUrls.bundler?.http[0];
|
|
1345
|
+
const bundlerTransport = bundlerHttpUrl ? http2(bundlerHttpUrl) : chain.id === 31337 ? userOpExecutor({
|
|
1346
|
+
executor: createClient({
|
|
1347
|
+
chain,
|
|
1348
|
+
transport: fallback([webSocket(), http2()]),
|
|
1349
|
+
account: privateKeyToAccount2(keccak256(stringToHex("local user op executor"))),
|
|
1350
|
+
pollingInterval: 10
|
|
1351
|
+
}).extend(transactionQueue())
|
|
1352
|
+
}) : null;
|
|
1353
|
+
if (!bundlerTransport) {
|
|
1354
|
+
throw new Error(`Chain ${chain.id} config did not include a bundler RPC URL.`);
|
|
1148
1355
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1356
|
+
return bundlerTransport;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
// src/getSessionClient.ts
|
|
1360
|
+
async function getSessionClient({
|
|
1361
|
+
client,
|
|
1362
|
+
userAddress,
|
|
1363
|
+
sessionAccount,
|
|
1364
|
+
worldAddress
|
|
1365
|
+
}) {
|
|
1366
|
+
const bundlerTransport = getBundlerTransport(client.chain);
|
|
1367
|
+
const bundlerClient = createBundlerClient({
|
|
1368
|
+
transport: bundlerTransport,
|
|
1369
|
+
client,
|
|
1370
|
+
account: sessionAccount
|
|
1371
|
+
});
|
|
1372
|
+
const sessionClient = bundlerClient.extend(smartAccountActions).extend(callFrom({ worldAddress, delegatorAddress: userAddress, publicClient: client })).extend(() => ({ userAddress }));
|
|
1373
|
+
return sessionClient;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// src/useSessionClient.ts
|
|
1377
|
+
import { useEffect as useEffect5 } from "react";
|
|
1378
|
+
function getSessionClientQueryOptions({
|
|
1379
|
+
sessionAccount,
|
|
1380
|
+
client,
|
|
1381
|
+
userAddress,
|
|
1382
|
+
worldAddress
|
|
1383
|
+
}) {
|
|
1384
|
+
const queryKey = ["getSessionClient", client?.uid, userAddress, sessionAccount?.address, worldAddress];
|
|
1385
|
+
return queryOptions6(
|
|
1386
|
+
client && userAddress && sessionAccount ? {
|
|
1387
|
+
queryKey,
|
|
1388
|
+
queryFn: () => getSessionClient({
|
|
1389
|
+
sessionAccount,
|
|
1390
|
+
client,
|
|
1391
|
+
userAddress,
|
|
1392
|
+
worldAddress
|
|
1393
|
+
}),
|
|
1394
|
+
staleTime: Infinity
|
|
1395
|
+
} : { queryKey, enabled: false }
|
|
1396
|
+
);
|
|
1397
|
+
}
|
|
1398
|
+
function useSessionClient(userAddress) {
|
|
1399
|
+
const { chainId, worldAddress } = useEntryKitConfig();
|
|
1400
|
+
const client = useClient8({ chainId });
|
|
1401
|
+
const { data: sessionAccount, error: sessionAccountError } = useSessionAccount(userAddress);
|
|
1402
|
+
useEffect5(() => {
|
|
1403
|
+
if (sessionAccountError) {
|
|
1404
|
+
console.error("Could not get session account", sessionAccountError);
|
|
1405
|
+
}
|
|
1406
|
+
}, [sessionAccountError]);
|
|
1407
|
+
return useQuery8(
|
|
1408
|
+
getSessionClientQueryOptions({
|
|
1409
|
+
sessionAccount,
|
|
1410
|
+
userAddress,
|
|
1411
|
+
client,
|
|
1412
|
+
worldAddress
|
|
1413
|
+
})
|
|
1414
|
+
);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
// src/onboarding/Session.tsx
|
|
1418
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1419
|
+
function Session({ isActive, isExpanded, userClient, registerSpender, registerDelegation }) {
|
|
1420
|
+
const sessionClient = useSessionClient(userClient.account.address);
|
|
1421
|
+
const setup = useSetupSession({ userClient });
|
|
1422
|
+
const hasSession = !registerDelegation && !registerDelegation;
|
|
1423
|
+
useEffect6(() => {
|
|
1424
|
+
const timer = setTimeout(() => {
|
|
1425
|
+
if (isActive && setup.status === "idle" && sessionClient.data && !hasSession) {
|
|
1426
|
+
setup.mutate({
|
|
1427
|
+
sessionClient: sessionClient.data,
|
|
1428
|
+
registerSpender,
|
|
1429
|
+
registerDelegation
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
});
|
|
1433
|
+
return () => clearTimeout(timer);
|
|
1434
|
+
}, [hasSession, isActive, registerDelegation, registerSpender, sessionClient, setup]);
|
|
1435
|
+
return /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-4", children: [
|
|
1436
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex justify-between gap-4", children: [
|
|
1437
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1438
|
+
/* @__PURE__ */ jsx15("div", { children: "Session" }),
|
|
1439
|
+
/* @__PURE__ */ jsx15("div", { className: "font-mono text-white", children: hasSession ? "Enabled" : "Set up" })
|
|
1440
|
+
] }),
|
|
1441
|
+
hasSession ? /* @__PURE__ */ jsx15(Button, { variant: "tertiary", className: "flex-shrink-0 text-sm p-1 w-28", autoFocus: isActive, disabled: true, children: "Enabled" }) : /* @__PURE__ */ jsx15(
|
|
1442
|
+
Button,
|
|
1443
|
+
{
|
|
1444
|
+
variant: isActive ? "primary" : "tertiary",
|
|
1445
|
+
className: "flex-shrink-0 text-sm p-1 w-28",
|
|
1446
|
+
autoFocus: isActive,
|
|
1447
|
+
pending: !sessionClient.data || setup.status === "pending",
|
|
1448
|
+
onClick: sessionClient.data ? () => setup.mutate({
|
|
1449
|
+
sessionClient: sessionClient.data,
|
|
1450
|
+
registerSpender,
|
|
1451
|
+
registerDelegation
|
|
1452
|
+
}) : void 0,
|
|
1453
|
+
children: "Enable"
|
|
1454
|
+
}
|
|
1455
|
+
)
|
|
1456
|
+
] }),
|
|
1457
|
+
isExpanded ? /* @__PURE__ */ jsx15("p", { className: "text-sm", children: "You can perform actions in this app without interruptions for approvals." }) : null
|
|
1458
|
+
] });
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
// src/onboarding/GasBalance.tsx
|
|
1462
|
+
import { useBalance } from "wagmi";
|
|
1463
|
+
|
|
1464
|
+
// src/data/relayChains.json
|
|
1465
|
+
var relayChains_default = {
|
|
1466
|
+
"1": {
|
|
1467
|
+
bridgeUrl: "https://relay.link/bridge/ethereum"
|
|
1468
|
+
},
|
|
1469
|
+
"10": {
|
|
1470
|
+
bridgeUrl: "https://relay.link/bridge/optimism"
|
|
1471
|
+
},
|
|
1472
|
+
"56": {
|
|
1473
|
+
bridgeUrl: "https://relay.link/bridge/bnb"
|
|
1474
|
+
},
|
|
1475
|
+
"100": {
|
|
1476
|
+
bridgeUrl: "https://relay.link/bridge/gnosis"
|
|
1477
|
+
},
|
|
1478
|
+
"111": {
|
|
1479
|
+
bridgeUrl: "https://testnets.relay.link/bridge/bob"
|
|
1480
|
+
},
|
|
1481
|
+
"137": {
|
|
1482
|
+
bridgeUrl: "https://relay.link/bridge/polygon"
|
|
1483
|
+
},
|
|
1484
|
+
"185": {
|
|
1485
|
+
bridgeUrl: "https://relay.link/bridge/mint"
|
|
1486
|
+
},
|
|
1487
|
+
"288": {
|
|
1488
|
+
bridgeUrl: "https://relay.link/bridge/boba"
|
|
1489
|
+
},
|
|
1490
|
+
"324": {
|
|
1491
|
+
bridgeUrl: "https://relay.link/bridge/zksync"
|
|
1492
|
+
},
|
|
1493
|
+
"360": {
|
|
1494
|
+
bridgeUrl: "https://relay.link/bridge/shape"
|
|
1495
|
+
},
|
|
1496
|
+
"480": {
|
|
1497
|
+
bridgeUrl: "https://relay.link/bridge/world-chain"
|
|
1498
|
+
},
|
|
1499
|
+
"690": {
|
|
1500
|
+
bridgeUrl: "https://relay.link/bridge/redstone"
|
|
1501
|
+
},
|
|
1502
|
+
"919": {
|
|
1503
|
+
bridgeUrl: "https://testnets.relay.link/bridge/mode-testnet"
|
|
1504
|
+
},
|
|
1505
|
+
"1101": {
|
|
1506
|
+
bridgeUrl: "https://relay.link/bridge/polygon-zkevm"
|
|
1507
|
+
},
|
|
1508
|
+
"1135": {
|
|
1509
|
+
bridgeUrl: "https://relay.link/bridge/lisk"
|
|
1510
|
+
},
|
|
1511
|
+
"1301": {
|
|
1512
|
+
bridgeUrl: "https://testnets.relay.link/bridge/unichain-sepolia"
|
|
1513
|
+
},
|
|
1514
|
+
"1329": {
|
|
1515
|
+
bridgeUrl: "https://relay.link/bridge/sei"
|
|
1516
|
+
},
|
|
1517
|
+
"1625": {
|
|
1518
|
+
bridgeUrl: "https://relay.link/bridge/gravity"
|
|
1519
|
+
},
|
|
1520
|
+
"1868": {
|
|
1521
|
+
bridgeUrl: "https://relay.link/bridge/soneium"
|
|
1522
|
+
},
|
|
1523
|
+
"1993": {
|
|
1524
|
+
bridgeUrl: "https://testnets.relay.link/bridge/b3"
|
|
1525
|
+
},
|
|
1526
|
+
"1996": {
|
|
1527
|
+
bridgeUrl: "https://relay.link/bridge/sanko"
|
|
1528
|
+
},
|
|
1529
|
+
"2741": {
|
|
1530
|
+
bridgeUrl: "https://relay.link/bridge/abstract"
|
|
1531
|
+
},
|
|
1532
|
+
"2911": {
|
|
1533
|
+
bridgeUrl: "https://relay.link/bridge/hychain"
|
|
1534
|
+
},
|
|
1535
|
+
"4202": {
|
|
1536
|
+
bridgeUrl: "https://testnets.relay.link/bridge/lisk-sepolia"
|
|
1537
|
+
},
|
|
1538
|
+
"4321": {
|
|
1539
|
+
bridgeUrl: "https://relay.link/bridge/echos"
|
|
1540
|
+
},
|
|
1541
|
+
"5000": {
|
|
1542
|
+
bridgeUrl: "https://relay.link/bridge/mantle"
|
|
1543
|
+
},
|
|
1544
|
+
"5112": {
|
|
1545
|
+
bridgeUrl: "https://relay.link/bridge/ham"
|
|
1546
|
+
},
|
|
1547
|
+
"7560": {
|
|
1548
|
+
bridgeUrl: "https://relay.link/bridge/cyber"
|
|
1549
|
+
},
|
|
1550
|
+
"7865": {
|
|
1551
|
+
bridgeUrl: "https://relay.link/bridge/powerloom"
|
|
1552
|
+
},
|
|
1553
|
+
"7897": {
|
|
1554
|
+
bridgeUrl: "https://relay.link/bridge/arena-z"
|
|
1555
|
+
},
|
|
1556
|
+
"8333": {
|
|
1557
|
+
bridgeUrl: "https://relay.link/bridge/B3"
|
|
1558
|
+
},
|
|
1559
|
+
"8453": {
|
|
1560
|
+
bridgeUrl: "https://relay.link/bridge/base"
|
|
1561
|
+
},
|
|
1562
|
+
"9897": {
|
|
1563
|
+
bridgeUrl: "https://testnets.relay.link/bridge/arena-z-testnet"
|
|
1564
|
+
},
|
|
1565
|
+
"11011": {
|
|
1566
|
+
bridgeUrl: "https://testnets.relay.link/bridge/shape-sepolia"
|
|
1567
|
+
},
|
|
1568
|
+
"11124": {
|
|
1569
|
+
bridgeUrl: "https://testnets.relay.link/bridge/abstract"
|
|
1570
|
+
},
|
|
1571
|
+
"13746": {
|
|
1572
|
+
bridgeUrl: "https://testnets.relay.link/bridge/game7-testnet"
|
|
1573
|
+
},
|
|
1574
|
+
"17000": {
|
|
1575
|
+
bridgeUrl: "https://testnets.relay.link/bridge/holesky"
|
|
1576
|
+
},
|
|
1577
|
+
"17069": {
|
|
1578
|
+
bridgeUrl: "https://testnets.relay.link/bridge/garnet"
|
|
1579
|
+
},
|
|
1580
|
+
"17071": {
|
|
1581
|
+
bridgeUrl: "https://relay.link/bridge/onchain-points"
|
|
1582
|
+
},
|
|
1583
|
+
"33139": {
|
|
1584
|
+
bridgeUrl: "https://relay.link/bridge/apechain"
|
|
1585
|
+
},
|
|
1586
|
+
"33979": {
|
|
1587
|
+
bridgeUrl: "https://relay.link/bridge/funki"
|
|
1588
|
+
},
|
|
1589
|
+
"34443": {
|
|
1590
|
+
bridgeUrl: "https://relay.link/bridge/mode"
|
|
1591
|
+
},
|
|
1592
|
+
"42161": {
|
|
1593
|
+
bridgeUrl: "https://relay.link/bridge/arbitrum"
|
|
1594
|
+
},
|
|
1595
|
+
"42170": {
|
|
1596
|
+
bridgeUrl: "https://relay.link/bridge/arbitrum-nova"
|
|
1597
|
+
},
|
|
1598
|
+
"43114": {
|
|
1599
|
+
bridgeUrl: "https://relay.link/bridge/avalanche"
|
|
1600
|
+
},
|
|
1601
|
+
"55244": {
|
|
1602
|
+
bridgeUrl: "https://relay.link/bridge/superposition"
|
|
1603
|
+
},
|
|
1604
|
+
"57073": {
|
|
1605
|
+
bridgeUrl: "https://relay.link/bridge/ink"
|
|
1606
|
+
},
|
|
1607
|
+
"59144": {
|
|
1608
|
+
bridgeUrl: "https://relay.link/bridge/linea"
|
|
1609
|
+
},
|
|
1610
|
+
"60808": {
|
|
1611
|
+
bridgeUrl: "https://relay.link/bridge/bob"
|
|
1612
|
+
},
|
|
1613
|
+
"70700": {
|
|
1614
|
+
bridgeUrl: "https://relay.link/bridge/apex"
|
|
1615
|
+
},
|
|
1616
|
+
"70701": {
|
|
1617
|
+
bridgeUrl: "https://relay.link/bridge/boss"
|
|
1618
|
+
},
|
|
1619
|
+
"70800": {
|
|
1620
|
+
bridgeUrl: "https://testnets.relay.link/bridge/apex-testnet"
|
|
1621
|
+
},
|
|
1622
|
+
"70805": {
|
|
1623
|
+
bridgeUrl: "https://testnets.relay.link/bridge/cloud"
|
|
1624
|
+
},
|
|
1625
|
+
"80002": {
|
|
1626
|
+
bridgeUrl: "https://testnets.relay.link/bridge/amoy"
|
|
1627
|
+
},
|
|
1628
|
+
"81457": {
|
|
1629
|
+
bridgeUrl: "https://relay.link/bridge/blast"
|
|
1630
|
+
},
|
|
1631
|
+
"84532": {
|
|
1632
|
+
bridgeUrl: "https://testnets.relay.link/bridge/base-sepolia"
|
|
1633
|
+
},
|
|
1634
|
+
"167009": {
|
|
1635
|
+
bridgeUrl: "https://testnets.relay.link/bridge/hekla"
|
|
1636
|
+
},
|
|
1637
|
+
"421614": {
|
|
1638
|
+
bridgeUrl: "https://testnets.relay.link/bridge/arbitrum-sepolia"
|
|
1639
|
+
},
|
|
1640
|
+
"534352": {
|
|
1641
|
+
bridgeUrl: "https://relay.link/bridge/scroll"
|
|
1642
|
+
},
|
|
1643
|
+
"543210": {
|
|
1644
|
+
bridgeUrl: "https://relay.link/bridge/zero-network"
|
|
1645
|
+
},
|
|
1646
|
+
"660279": {
|
|
1647
|
+
bridgeUrl: "https://relay.link/bridge/xai"
|
|
1648
|
+
},
|
|
1649
|
+
"911867": {
|
|
1650
|
+
bridgeUrl: "https://testnets.relay.link/bridge/odyssey"
|
|
1651
|
+
},
|
|
1652
|
+
"984122": {
|
|
1653
|
+
bridgeUrl: "https://relay.link/bridge/forma"
|
|
1654
|
+
},
|
|
1655
|
+
"1118190": {
|
|
1656
|
+
bridgeUrl: "https://testnets.relay.link/bridge/eclipse-testnet"
|
|
1657
|
+
},
|
|
1658
|
+
"3397901": {
|
|
1659
|
+
bridgeUrl: "https://testnets.relay.link/bridge/funki-testnet"
|
|
1660
|
+
},
|
|
1661
|
+
"4457845": {
|
|
1662
|
+
bridgeUrl: "https://testnets.relay.link/bridge/zero-sepolia"
|
|
1663
|
+
},
|
|
1664
|
+
"7777777": {
|
|
1665
|
+
bridgeUrl: "https://relay.link/bridge/zora"
|
|
1666
|
+
},
|
|
1667
|
+
"8253038": {
|
|
1668
|
+
bridgeUrl: "https://relay.link/bridge/bitcoin"
|
|
1669
|
+
},
|
|
1670
|
+
"9092725": {
|
|
1671
|
+
bridgeUrl: "https://testnets.relay.link/bridge/bitcoin-testnet4"
|
|
1672
|
+
},
|
|
1673
|
+
"9286185": {
|
|
1674
|
+
bridgeUrl: "https://relay.link/bridge/eclipse"
|
|
1675
|
+
},
|
|
1676
|
+
"11155111": {
|
|
1677
|
+
bridgeUrl: "https://testnets.relay.link/bridge/sepolia"
|
|
1678
|
+
},
|
|
1679
|
+
"11155420": {
|
|
1680
|
+
bridgeUrl: "https://testnets.relay.link/bridge/op-sepolia"
|
|
1681
|
+
},
|
|
1682
|
+
"666666666": {
|
|
1683
|
+
bridgeUrl: "https://relay.link/bridge/degen"
|
|
1684
|
+
},
|
|
1685
|
+
"792703809": {
|
|
1686
|
+
bridgeUrl: "https://relay.link/bridge/solana"
|
|
1687
|
+
},
|
|
1688
|
+
"888888888": {
|
|
1689
|
+
bridgeUrl: "https://relay.link/bridge/ancient8"
|
|
1690
|
+
},
|
|
1691
|
+
"999999999": {
|
|
1692
|
+
bridgeUrl: "https://testnets.relay.link/bridge/zora-sepolia"
|
|
1693
|
+
},
|
|
1694
|
+
"1380012617": {
|
|
1695
|
+
bridgeUrl: "https://relay.link/bridge/rari"
|
|
1696
|
+
},
|
|
1697
|
+
"1936682084": {
|
|
1698
|
+
bridgeUrl: "https://testnets.relay.link/bridge/solana-devnet"
|
|
1699
|
+
},
|
|
1700
|
+
"88153591557": {
|
|
1701
|
+
bridgeUrl: "https://testnets.relay.link/bridge/arbitrum-blueberry"
|
|
1156
1702
|
}
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
.
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
.
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
.
|
|
1174
|
-
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
@
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1703
|
+
};
|
|
1704
|
+
|
|
1705
|
+
// src/onboarding/useSetBalance.ts
|
|
1706
|
+
import { useQueryClient as useQueryClient4, useMutation as useMutation3 } from "@tanstack/react-query";
|
|
1707
|
+
import { setBalance as setBalance2 } from "viem/actions";
|
|
1708
|
+
import { useClient as useClient9 } from "wagmi";
|
|
1709
|
+
function useSetBalance() {
|
|
1710
|
+
const queryClient = useQueryClient4();
|
|
1711
|
+
const { chainId } = useEntryKitConfig();
|
|
1712
|
+
const client = useClient9({ chainId });
|
|
1713
|
+
return useMutation3({
|
|
1714
|
+
mutationKey: ["setBalance", chainId],
|
|
1715
|
+
onError: (error2) => console.error(error2),
|
|
1716
|
+
mutationFn: async (params) => {
|
|
1717
|
+
if (!client) return null;
|
|
1718
|
+
await setBalance2({ ...client, mode: "anvil" }, params);
|
|
1719
|
+
await Promise.all([
|
|
1720
|
+
queryClient.invalidateQueries({ queryKey: ["balance"] }),
|
|
1721
|
+
queryClient.invalidateQueries({ queryKey: ["getPrerequisites"] })
|
|
1722
|
+
]);
|
|
1723
|
+
return null;
|
|
1724
|
+
},
|
|
1725
|
+
retry: 0
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
// src/onboarding/GasBalance.tsx
|
|
1730
|
+
import { Fragment, jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1731
|
+
function GasBalance({ isActive, isExpanded, sessionAddress }) {
|
|
1732
|
+
const { chain } = useEntryKitConfig();
|
|
1733
|
+
const balance = useBalance({ chainId: chain.id, address: sessionAddress, query: { refetchInterval: 2e3 } });
|
|
1734
|
+
const setBalance3 = useSetBalance();
|
|
1735
|
+
const relayChain = relayChains_default[chain.id];
|
|
1736
|
+
return /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-4", children: [
|
|
1737
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex justify-between gap-4", children: [
|
|
1738
|
+
/* @__PURE__ */ jsxs14("div", { children: [
|
|
1739
|
+
/* @__PURE__ */ jsx16("div", { children: "Gas balance" }),
|
|
1740
|
+
/* @__PURE__ */ jsx16("div", { className: "font-mono text-white", children: balance.data != null ? /* @__PURE__ */ jsx16(Balance, { wei: balance.data.value }) : /* @__PURE__ */ jsx16(PendingIcon, { className: "text-sm" }) })
|
|
1741
|
+
] }),
|
|
1742
|
+
chain.id === 31337 ? /* @__PURE__ */ jsx16(
|
|
1743
|
+
Button,
|
|
1744
|
+
{
|
|
1745
|
+
variant: isActive ? "primary" : "tertiary",
|
|
1746
|
+
className: "flex-shrink-0 text-sm p-1 w-28",
|
|
1747
|
+
autoFocus: isActive || isExpanded,
|
|
1748
|
+
pending: balance.status === "pending" || setBalance3.status === "pending",
|
|
1749
|
+
onClick: () => setBalance3.mutate({
|
|
1750
|
+
address: sessionAddress,
|
|
1751
|
+
value: minGasBalance + (balance.data?.value ?? 0n)
|
|
1752
|
+
}),
|
|
1753
|
+
children: "Top up"
|
|
1754
|
+
}
|
|
1755
|
+
) : relayChain != null ? (
|
|
1756
|
+
// TODO: convert this to a <ButtonLink>
|
|
1757
|
+
/* @__PURE__ */ jsx16(
|
|
1758
|
+
"a",
|
|
1759
|
+
{
|
|
1760
|
+
href: `${relayChain.bridgeUrl}?${new URLSearchParams({ toAddress: sessionAddress })}`,
|
|
1761
|
+
target: "_blank",
|
|
1762
|
+
rel: "noopener noreferrer",
|
|
1763
|
+
children: /* @__PURE__ */ jsx16(
|
|
1764
|
+
Button,
|
|
1765
|
+
{
|
|
1766
|
+
variant: isActive ? "primary" : "tertiary",
|
|
1767
|
+
className: "flex-shrink-0 text-sm p-1 w-28",
|
|
1768
|
+
autoFocus: isActive || isExpanded,
|
|
1769
|
+
pending: balance.status === "pending",
|
|
1770
|
+
children: "Top up"
|
|
1771
|
+
}
|
|
1772
|
+
)
|
|
1773
|
+
}
|
|
1774
|
+
)
|
|
1775
|
+
) : null
|
|
1776
|
+
] }),
|
|
1777
|
+
isExpanded ? /* @__PURE__ */ jsxs14(Fragment, { children: [
|
|
1778
|
+
/* @__PURE__ */ jsx16("p", { className: "text-sm", children: "Your session's gas balance is used to pay for onchain computation." }),
|
|
1779
|
+
/* @__PURE__ */ jsxs14("p", { className: "text-sm", children: [
|
|
1780
|
+
"Send funds to",
|
|
1781
|
+
" ",
|
|
1782
|
+
/* @__PURE__ */ jsx16("span", { className: "font-mono text-white", children: /* @__PURE__ */ jsx16(TruncatedHex, { hex: sessionAddress }) }),
|
|
1783
|
+
" ",
|
|
1784
|
+
"on ",
|
|
1785
|
+
chain.name,
|
|
1786
|
+
" to top up your session balance."
|
|
1787
|
+
] })
|
|
1788
|
+
] }) : null
|
|
1789
|
+
] });
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
// src/onboarding/ConnectedSteps.tsx
|
|
1793
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1794
|
+
function ConnectedSteps({ userClient, initialUserAddress }) {
|
|
1795
|
+
const { chain } = useEntryKitConfig();
|
|
1796
|
+
const paymaster = getPaymaster(chain);
|
|
1797
|
+
const userAddress = userClient.account.address;
|
|
1798
|
+
const { data: prerequisites, error: prerequisitesError } = usePrerequisites(userAddress);
|
|
1799
|
+
useEffect7(() => {
|
|
1800
|
+
if (prerequisitesError) {
|
|
1801
|
+
console.error("Could not get prerequisites", prerequisitesError);
|
|
1802
|
+
}
|
|
1803
|
+
}, [prerequisitesError]);
|
|
1804
|
+
const { closeAccountModal } = useAccountModal();
|
|
1805
|
+
const isNewConnection = userAddress !== initialUserAddress;
|
|
1806
|
+
const initialPrerequisites = useRef2(prerequisites);
|
|
1807
|
+
useEffect7(() => {
|
|
1808
|
+
if (prerequisites == null) return;
|
|
1809
|
+
if (initialPrerequisites.current == null) {
|
|
1810
|
+
initialPrerequisites.current = prerequisites;
|
|
1811
|
+
}
|
|
1812
|
+
if (prerequisites.complete) {
|
|
1813
|
+
if (isNewConnection || !initialPrerequisites.current.complete) {
|
|
1814
|
+
closeAccountModal();
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
}, [closeAccountModal, isNewConnection, prerequisites]);
|
|
1818
|
+
const { sessionAddress, hasAllowance, isSpender, hasDelegation, hasGasBalance } = prerequisites ?? {};
|
|
1819
|
+
const steps = useMemo2(() => {
|
|
1820
|
+
if (!userAddress) {
|
|
1821
|
+
return [
|
|
1822
|
+
{
|
|
1823
|
+
id: "wallet",
|
|
1824
|
+
isComplete: false,
|
|
1825
|
+
content: () => null
|
|
1826
|
+
}
|
|
1827
|
+
];
|
|
1828
|
+
}
|
|
1829
|
+
const steps2 = [
|
|
1830
|
+
{
|
|
1831
|
+
id: "wallet",
|
|
1832
|
+
isComplete: true,
|
|
1833
|
+
content: (props) => /* @__PURE__ */ jsx17(Wallet, { ...props, userAddress })
|
|
1834
|
+
}
|
|
1835
|
+
];
|
|
1836
|
+
if (!paymaster) {
|
|
1837
|
+
if (sessionAddress != null) {
|
|
1838
|
+
steps2.push({
|
|
1839
|
+
id: "gasBalance",
|
|
1840
|
+
isComplete: !!hasGasBalance,
|
|
1841
|
+
content: (props) => /* @__PURE__ */ jsx17(GasBalance, { ...props, sessionAddress })
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
} else if (paymaster.type === "quarry") {
|
|
1845
|
+
steps2.push({
|
|
1846
|
+
id: "allowance",
|
|
1847
|
+
isComplete: !!hasAllowance,
|
|
1848
|
+
content: (props) => /* @__PURE__ */ jsx17(Allowance, { ...props, userAddress })
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
steps2.push({
|
|
1852
|
+
id: "session",
|
|
1853
|
+
isComplete: !!isSpender && !!hasDelegation,
|
|
1854
|
+
content: (props) => /* @__PURE__ */ jsx17(Session, { ...props, userClient, registerSpender: !isSpender, registerDelegation: !hasDelegation })
|
|
1855
|
+
});
|
|
1856
|
+
return steps2;
|
|
1857
|
+
}, [hasAllowance, hasDelegation, hasGasBalance, isSpender, paymaster, sessionAddress, userAddress, userClient]);
|
|
1858
|
+
const [selectedStepId] = useState3(null);
|
|
1859
|
+
const nextStep = steps.find((step) => step.content != null && !step.isComplete);
|
|
1860
|
+
const completedSteps = steps.filter((step) => step.isComplete);
|
|
1861
|
+
const activeStep = (selectedStepId != null ? steps.find((step) => step.id === selectedStepId) : null) ?? nextStep ?? (completedSteps.length < steps.length ? completedSteps.at(-1) : null);
|
|
1862
|
+
const activeStepIndex = activeStep ? steps.indexOf(activeStep) : -1;
|
|
1863
|
+
return /* @__PURE__ */ jsx17(
|
|
1864
|
+
"div",
|
|
1865
|
+
{
|
|
1866
|
+
className: twMerge7(
|
|
1867
|
+
// steps.length === 2 ? "min-h-[22rem]" : "min-h-[26rem]",
|
|
1868
|
+
"px-8 flex flex-col divide-y divide-neutral-800",
|
|
1869
|
+
"animate-in animate-duration-300 fade-in slide-in-from-bottom-8"
|
|
1870
|
+
),
|
|
1871
|
+
children: steps.map((step, i) => {
|
|
1872
|
+
const isActive = step === activeStep;
|
|
1873
|
+
const isExpanded = isActive || completedSteps.length === steps.length;
|
|
1874
|
+
const isDisabled = !step.isComplete && activeStepIndex !== -1 && i > activeStepIndex;
|
|
1875
|
+
return /* @__PURE__ */ jsx17("div", { className: twMerge7("py-8 flex flex-col justify-center", isActive ? "flex-grow" : null), children: /* @__PURE__ */ jsx17("div", { className: twMerge7("flex flex-col", isDisabled ? "opacity-30 pointer-events-none" : null), children: step.content({ isActive, isExpanded }) }) }, step.id);
|
|
1876
|
+
})
|
|
1877
|
+
}
|
|
1878
|
+
);
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
// src/AccountModalContent.tsx
|
|
1882
|
+
import { useRef as useRef3 } from "react";
|
|
1883
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1884
|
+
function AccountModalContent() {
|
|
1885
|
+
const { chainId } = useEntryKitConfig();
|
|
1886
|
+
const userClient = useConnectorClient({ chainId });
|
|
1887
|
+
const { address: userAddress } = useAccount2();
|
|
1888
|
+
const initialUserAddress = useRef3(userAddress);
|
|
1889
|
+
if (userClient.status !== "success") {
|
|
1890
|
+
return /* @__PURE__ */ jsx18(ConnectWallet, {});
|
|
1201
1891
|
}
|
|
1892
|
+
return /* @__PURE__ */ jsx18(ConnectedSteps, { userClient: userClient.data, initialUserAddress: initialUserAddress.current });
|
|
1202
1893
|
}
|
|
1203
1894
|
|
|
1204
|
-
.
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
user-select: none;
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
.after\\:content-\\[\\'\\2026\\'\\]::after {
|
|
1211
|
-
--tw-content: '\u2026';
|
|
1212
|
-
content: var(--tw-content);
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
.hover\\:bg-neutral-200:hover {
|
|
1216
|
-
--tw-bg-opacity: 1;
|
|
1217
|
-
background-color: rgb(229 229 229 / var(--tw-bg-opacity));
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
.hover\\:bg-orange-400:hover {
|
|
1221
|
-
--tw-bg-opacity: 1;
|
|
1222
|
-
background-color: rgb(251 146 60 / var(--tw-bg-opacity));
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
.hover\\:text-neutral-500:hover {
|
|
1226
|
-
--tw-text-opacity: 1;
|
|
1227
|
-
color: rgb(115 115 115 / var(--tw-text-opacity));
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
.hover\\:text-white:hover {
|
|
1231
|
-
--tw-text-opacity: 1;
|
|
1232
|
-
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
.hover\\:brightness-125:hover {
|
|
1236
|
-
--tw-brightness: brightness(1.25);
|
|
1237
|
-
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
.focus\\:border-orange-500:focus {
|
|
1241
|
-
--tw-border-opacity: 1;
|
|
1242
|
-
border-color: rgb(249 115 22 / var(--tw-border-opacity));
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
.focus\\:border-yellow-400:focus {
|
|
1246
|
-
--tw-border-opacity: 1;
|
|
1247
|
-
border-color: rgb(250 204 21 / var(--tw-border-opacity));
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
.active\\:bg-orange-600:active {
|
|
1251
|
-
--tw-bg-opacity: 1;
|
|
1252
|
-
background-color: rgb(234 88 12 / var(--tw-bg-opacity));
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
.active\\:brightness-150:active {
|
|
1256
|
-
--tw-brightness: brightness(1.5);
|
|
1257
|
-
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
.group:hover .group-hover\\:rotate-90 {
|
|
1261
|
-
--tw-rotate: 90deg;
|
|
1262
|
-
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
.group:hover .group-hover\\:text-black {
|
|
1266
|
-
--tw-text-opacity: 1;
|
|
1267
|
-
color: rgb(0 0 0 / var(--tw-text-opacity));
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
.aria-busy\\:pointer-events-none[aria-busy="true"] {
|
|
1271
|
-
pointer-events: none;
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
.aria-disabled\\:pointer-events-none[aria-disabled="true"] {
|
|
1275
|
-
pointer-events: none;
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
.aria-disabled\\:opacity-50[aria-disabled="true"] {
|
|
1279
|
-
opacity: 0.5;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
.group\\/button[aria-busy="true"] .group-aria-busy\\/button\\:translate-x-0 {
|
|
1283
|
-
--tw-translate-x: 0px;
|
|
1284
|
-
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
.group[aria-busy="true"] .group-aria-busy\\:scale-100 {
|
|
1288
|
-
--tw-scale-x: 1;
|
|
1289
|
-
--tw-scale-y: 1;
|
|
1290
|
-
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
.group[aria-busy="true"] .group-aria-busy\\:scale-125 {
|
|
1294
|
-
--tw-scale-x: 1.25;
|
|
1295
|
-
--tw-scale-y: 1.25;
|
|
1296
|
-
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
.group\\/button[aria-busy="true"] .group-aria-busy\\/button\\:opacity-100 {
|
|
1300
|
-
opacity: 1;
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
.group[aria-busy="true"] .group-aria-busy\\:opacity-0 {
|
|
1304
|
-
opacity: 0;
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
.group[aria-busy="true"] .group-aria-busy\\:opacity-100 {
|
|
1308
|
-
opacity: 1;
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
.group\\/button[aria-busy="true"] .group-aria-busy\\/button\\:duration-300 {
|
|
1312
|
-
transition-duration: 300ms;
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
.data-\\[highlighted\\]\\:bg-neutral-200[data-highlighted] {
|
|
1316
|
-
--tw-bg-opacity: 1;
|
|
1317
|
-
background-color: rgb(229 229 229 / var(--tw-bg-opacity));
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
.links\\:font-medium a[href]:not(.links-unset) {
|
|
1321
|
-
font-weight: 500;
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
.links\\:text-white a[href]:not(.links-unset) {
|
|
1325
|
-
--tw-text-opacity: 1;
|
|
1326
|
-
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
1327
|
-
}
|
|
1895
|
+
// src/AccountModalErrorBoundary.tsx
|
|
1896
|
+
import { useState as useState4 } from "react";
|
|
1897
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
1328
1898
|
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
.links\\:underline-offset-4 a[href]:not(.links-unset) {
|
|
1338
|
-
text-underline-offset: 4px;
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
.hover\\:links\\:decoration-orange-500 a[href]:not(.links-unset):hover {
|
|
1342
|
-
text-decoration-color: #f97316;
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
@media (min-width: 640px) {
|
|
1346
|
-
|
|
1347
|
-
.sm\\:items-center {
|
|
1348
|
-
align-items: center;
|
|
1899
|
+
// src/ErrorNotice.tsx
|
|
1900
|
+
import { twMerge as twMerge8 } from "tailwind-merge";
|
|
1901
|
+
import { BaseError, UserRejectedRequestError } from "viem";
|
|
1902
|
+
import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1903
|
+
function ErrorNotice({ title: initialTitle, error: error2 }) {
|
|
1904
|
+
if (!error2) return null;
|
|
1905
|
+
if (error2 instanceof BaseError && error2.walk((e) => e instanceof UserRejectedRequestError) != null) {
|
|
1906
|
+
return null;
|
|
1349
1907
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
.
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
.
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
URL: ${e}`)),o.src=e})})}import{jsx as W,jsxs as wr}from"react/jsx-runtime";function Oe(){let{appName:e,appIcon:t}=l(),{data:r,isLoading:o}=V(t);return wr("div",{className:"flex-grow flex flex-col items-center justify-center gap-2",children:[W("div",{className:"w-16 h-16 m-2",children:o?null:r?W("img",{src:t,className:"w-full h-full object-cover"}):W(A,{className:"w-full h-full text-orange-500 dark:bg-neutral-800"})}),W("div",{className:"text-2xl text-white text-center",children:e})]})}import{twMerge as Cr}from"tailwind-merge";import{useEffect as kr,useState as Sr}from"react";import{jsx as _,jsxs as Ar}from"react/jsx-runtime";function ze(){let e=xr(),{openConnectModal:t,connectModalOpen:r}=vr(),[o,n]=Sr(!1);return kr(()=>{!r&&!o&&(t?.(),n(!0))},[r,o,t]),Ar("div",{className:Cr("flex flex-col gap-6 p-6","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:[_("div",{className:"p-4",children:_(Oe,{})}),_("div",{className:"self-center flex flex-col gap-2 w-60",children:_(y,{variant:"secondary",className:"self-auto flex justify-center",disabled:e.status==="connecting",onClick:t,autoFocus:!0,children:"Connect wallet"},"create")})]})}import{useEffect as kn,useMemo as Sn,useRef as An,useState as Pn}from"react";import{twMerge as ye}from"tailwind-merge";import{parseEther as Pr}from"viem";var P=Pr("0.01");import{useClient as Or}from"wagmi";import{queryOptions as zr,useQuery as qr}from"@tanstack/react-query";import{numberToHex as Er}from"viem";import{defineStore as Ur}from"@latticexyz/store";import{parseAbi as Nr}from"viem";var se=Nr(["error SpenderSystem_AlreadyRegistered(address spender, address user)","error SpenderSystem_HasOwnBalance(address spender)","function registerSpender(address spender)"]),Rr=Ur({namespaces:{root:{namespace:"",tables:{Allowance:{schema:{user:"address",allowance:"uint256"},key:["user"]},Grantor:{schema:{grantor:"address",allowance:"uint256"},key:["grantor"]},PassHolder:{schema:{user:"address",passId:"bytes32",lastRenewed:"uint256",lastClaimed:"uint256"},key:["user","passId"]},PassConfig:{schema:{passId:"bytes32",claimAmount:"uint256",claimInterval:"uint256",validityPeriod:"uint256",grantor:"address"},key:["passId"]},Spender:{schema:{spender:"address",user:"address"},key:["spender"]},SystemConfig:{schema:{entryPoint:"address"},key:[]}}}}}),E=Rr.namespaces.root.tables;import{getRecord as Tr,getStaticDataLocation as Mr}from"@latticexyz/store/internal";import{getKeyTuple as Ir}from"@latticexyz/protocol-parser/internal";import{setStorageAt as Hr}from"viem/actions";function h(e){let t=e.contracts??{};if("quarryPaymaster"in t&&t.quarryPaymaster!=null&&"address"in t.quarryPaymaster)return{type:"quarry",address:t.quarryPaymaster.address};if("paymaster"in t&&t.paymaster!=null&&"address"in t.paymaster)return{type:"simple",address:t.paymaster.address}}async function qe({client:e,userAddress:t}){let r=h(e.chain);return r?.type!=="quarry"?null:(await Tr(e,{address:r.address,table:E.Allowance,key:{user:t},blockTag:"pending"})).allowance}async function Be({client:e,userAddress:t,allowance:r}){let o=h(e.chain);if(o?.type!=="quarry")return;let n=Mr(E.Allowance.tableId,Ir(E.Allowance,{user:t}));await Hr(e.extend(()=>({mode:"anvil"})),{address:o.address,index:n,value:Er(r,{size:32})})}function le({client:e,userAddress:t}){let r=["getAllowance",e?.chain.id,t];return zr(e&&t?{queryKey:r,queryFn:()=>qe({client:e,userAddress:t})}:{queryKey:r,enabled:!1})}function Le(e){let{chainId:t}=l(),r=Or({chainId:t});return qr(le({client:r,userAddress:e}))}import{useClient as Li}from"wagmi";import{queryOptions as Lr,useQuery as Ki}from"@tanstack/react-query";import{getRecord as Br}from"@latticexyz/store/internal";async function Fe({client:e,userAddress:t,sessionAddress:r}){let o=h(e.chain);return o?.type!=="quarry"?null:(await Br(e,{address:o.address,table:E.Spender,key:{spender:r},blockTag:"pending"})).user.toLowerCase()===t.toLowerCase()}function Ke({client:e,userAddress:t,sessionAddress:r}){let o=["getSpender",e?.chain.id,t,r];return Lr(e&&t&&r?{queryKey:o,queryFn:()=>Fe({client:e,userAddress:t,sessionAddress:r})}:{queryKey:o,enabled:!1})}import{useClient as as}from"wagmi";import{queryOptions as Qr,useQuery as ss}from"@tanstack/react-query";import{getRecord as Gr}from"@latticexyz/store/internal";import{resourceToHex as Fr}from"@latticexyz/common";import{parseAbi as Kr}from"viem";import Dr from"@latticexyz/world/mud.config";var De={pollingInterval:250},B=Fr({type:"system",namespace:"",name:"unlimited"}),Ge=Dr.namespaces.world.tables,Qe=Kr(["function registerDelegation(address delegatee, bytes32 delegationControlId, bytes initCallData)"]);async function Ve({client:e,worldAddress:t,userAddress:r,sessionAddress:o}){return(await Gr(e,{address:t,table:Ge.UserDelegationControl,key:{delegator:r,delegatee:o},blockTag:"pending"})).delegationControlId===B}function We({client:e,worldAddress:t,userAddress:r,sessionAddress:o}){let n=["getDelegation",e?.chain.id,t,r,o];return Qr(e&&r&&o?{queryKey:n,queryFn:()=>Ve({client:e,worldAddress:t,userAddress:r,sessionAddress:o})}:{queryKey:n,enabled:!1})}import{queryOptions as to,useQuery as ro,useQueryClient as oo}from"@tanstack/react-query";import{useClient as no,useConfig as ao}from"wagmi";import{useClient as Zr}from"wagmi";import{queryOptions as Jr,useQuery as eo}from"@tanstack/react-query";import{toSimpleSmartAccount as $r}from"permissionless/accounts";import{isHex as Yr}from"viem";import{createStore as Vr}from"zustand/vanilla";import{persist as Wr}from"zustand/middleware";var L=Vr(Wr(()=>({signers:{}}),{name:"mud:entrykit",partialize:({signers:e})=>({signers:e})}));function _r(e){e.key===L.persist.getOptions().name&&L.persist.rehydrate()}window.addEventListener("storage",_r);import{generatePrivateKey as Xr,privateKeyToAccount as jr}from"viem/accounts";function _e(e){let t=e.toLowerCase(),r=L.getState().signers[t]??(()=>{let o=localStorage.getItem(`mud:appSigner:privateKey:${e.toLowerCase()}`)?.replace(/^"(.*)"$/,"$1"),n=Yr(o)?o:Xr();return L.setState(a=>({signers:{...a.signers,[t]:n}})),n})();return jr(r)}async function Ye({client:e,userAddress:t}){let r=_e(t);return await $r({client:e,owner:r})}function de({client:e,userAddress:t}){let r=["getSessionAccount",e?.chain.id,t];return Jr(e&&t?{queryKey:r,queryFn:()=>Ye({client:e,userAddress:t}),staleTime:1/0}:{queryKey:r,enabled:!1})}function Xe(e){let{chainId:t}=l(),r=Zr({chainId:t});return eo(de({userAddress:e,client:r}))}import{getBalanceQueryOptions as io}from"wagmi/query";function so({queryClient:e,config:t,client:r,userAddress:o,worldAddress:n}){let a=["getPrerequisites",r?.chain.id,o];return to(r&&o?{queryKey:a,queryFn:async()=>{let i=h(r.chain),{address:s}=await e.fetchQuery(de({client:r,userAddress:o})),[c,g,m,d]=await Promise.all([i?null:e.fetchQuery(io(t,{chainId:r.chain.id,address:s})),i?.type==="quarry"?e.fetchQuery(le({client:r,userAddress:o})):null,i?.type==="quarry"?e.fetchQuery(Ke({client:r,userAddress:o,sessionAddress:s})):null,e.fetchQuery(We({client:r,worldAddress:n,userAddress:o,sessionAddress:s}))]),p=g==null||g>=P,f=m??!0,x=c==null||c.value>=P;return{sessionAddress:s,hasAllowance:p,isSpender:f,hasGasBalance:x,hasDelegation:d,complete:p&&f&&d}}}:{queryKey:a,enabled:!1})}function T(e){let t=oo(),{chainId:r,worldAddress:o}=l(),n=ao(),a=no({chainId:r});return ro(so({config:n,queryClient:t,client:a,userAddress:e,worldAddress:o}),t)}import{useDisconnect as po}from"wagmi";import{useQuery as lo}from"@tanstack/react-query";function Y(e){let t=e?.toLowerCase();return lo({enabled:!!t,queryKey:["ens",t],queryFn:async()=>{let r=await fetch(`https://api.ensideas.com/ens/resolve/${t}`).then(o=>o.json());return{address:r.address??void 0,name:r.name??void 0,displayName:r.displayName??void 0,avatar:r.avatar??void 0}}})}import{jsx as ce,jsxs as co}from"react/jsx-runtime";function M({hex:e}){return e.length<=10?ce("span",{title:e,children:e}):co("span",{title:e,children:[ce("span",{className:"after:select-none after:content-['\u2026']",children:e.slice(0,6)}),ce("span",{className:"tracking-[-1ch] text-transparent",children:e.slice(6,-4)}),e.slice(-4)]})}import{jsx as F,jsxs as pe}from"react/jsx-runtime";function je({isActive:e,isExpanded:t,userAddress:r}){let{data:o}=Y(r),{disconnect:n,isPending:a}=po(),{closeAccountModal:i}=C();return pe("div",{className:"flex flex-col gap-4",children:[pe("div",{className:"flex justify-between gap-4",children:[pe("div",{children:[F("div",{children:"Account"}),F("div",{className:"font-mono text-white",children:o?.name??F(M,{hex:r})})]}),F(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,pending:a,onClick:()=>{i(),n()},children:"Sign out"})]}),t?F("p",{className:"text-sm",children:"Each of your onchain actions in this app is associated with your account."}):null]})}import{parseEther as go}from"viem";import{useMutation as fo,useQueryClient as ho}from"@tanstack/react-query";import{http as mo}from"viem";function $e(){return({chain:e})=>{if(!e)throw new Error("No chain provided to issuer transport.");let t="quarryPassIssuer"in e.rpcUrls?e.rpcUrls.quarryPassIssuer.http[0]:void 0;if(!t)throw new Error(`No \`quarryPassIssuer\` RPC URL found for chain ${e.id}.`);return mo(t)({chain:e,retryCount:0})}}import Ze from"debug";var me=Ze("mud:entrykit"),uo=Ze("mud:entrykit");me.log=console.debug.bind(console);uo.log=console.error.bind(console);var I=me.extend("quarry");async function Je({chain:e,userAddress:t}){let r=$e()({chain:e});I("Issuing gas pass to",t),await r.request({method:"quarry_issuePass",params:["0x01",t]}),I("Claiming gas allowance for",t),await r.request({method:"quarry_claimAllowance",params:["0x01",t]})}import{useClient as yo}from"wagmi";function et(){let e=ho(),{chain:t}=l(),r=yo({chainId:t.id}),o=["claimGasPass",t.id];return fo({mutationKey:o,onError:n=>console.error(n),mutationFn:async n=>{if(t.id===31337){if(!r)throw new Error("No client?");await Be({client:r,userAddress:n,allowance:go("1")})}else await Je({chain:t,userAddress:n});await Promise.all([e.invalidateQueries({queryKey:["getAllowance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{twMerge as bo}from"tailwind-merge";import{jsx as X,jsxs as wo}from"react/jsx-runtime";function tt({className:e,...t}){return wo("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 263 428",fill:"currentColor",className:bo("w-[0.6em] h-[1em]",e),...t,children:[X("path",{d:"M132 321V428L263 243L132 321Z"}),X("path",{d:"M0 243L132 321V428",fillOpacity:"0.5"}),X("path",{d:"M132 0V296L263 218"}),X("path",{d:"M0 218L132 296V0L0 218Z",fillOpacity:"0.5"})]})}import{formatEther as xo}from"viem";function rt(e){let t=xo(e),r=Math.floor(parseFloat(t)).toString().length;return parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:Math.max(0,6-r)})}import{formatEther as vo}from"viem";import{jsx as Co,jsxs as ko}from"react/jsx-runtime";function j({wei:e}){return ko("span",{className:"inline-flex items-center gap-1",title:vo(e),children:[rt(e)," ",Co(tt,{})]})}import{useEffect as So}from"react";import{jsx as H,jsxs as ue}from"react/jsx-runtime";function ot({isActive:e,isExpanded:t,userAddress:r}){let o=Le(r),n=et();return So(()=>{let a=setTimeout(()=>{e&&n.status==="idle"&&o.isSuccess&&o.data!=null&&o.data<P&&n.mutate(r)});return()=>clearTimeout(a)},[o.data,o.isSuccess,n,e,r]),ue("div",{className:"flex flex-col gap-4",children:[ue("div",{className:"flex justify-between gap-4",children:[ue("div",{children:[H("div",{children:"Allowance"}),H("div",{className:"font-mono text-white",children:o.data!=null?H(j,{wei:o.data}):H(b,{className:"text-sm"})})]}),H(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:o.status==="pending"||n.status==="pending",onClick:()=>n.mutate(r),children:"Top up"})]}),t?H("p",{className:"text-sm",children:"Your allowance is used to pay for onchain computation."}):null]})}import{encodeFunctionData as at}from"viem";import{useMutation as Oo,useQueryClient as zo}from"@tanstack/react-query";import{getAction as fe}from"viem/utils";import{sendUserOperation as qo,waitForUserOperationReceipt as Bo}from"viem/account-abstraction";import{waitForTransactionReceipt as Lo}from"viem/actions";import{useClient as Fo}from"wagmi";import{resourceToHex as it}from"@latticexyz/common";import Ko from"@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json";import{writeContract as Mo}from"viem/actions";import{getAction as Io}from"viem/utils";import{toHex as Ao}from"viem";import{signTypedData as Po}from"viem/actions";import{callWithSignatureTypes as Uo}from"@latticexyz/world-module-callwithsignature/internal";import{getRecord as No}from"@latticexyz/store/internal";import Ro from"@latticexyz/world-module-callwithsignature/mud.config";import{hexToResource as Eo}from"@latticexyz/common";import{getAction as To}from"viem/utils";async function nt({userClient:e,worldAddress:t,systemId:r,callData:o,nonce:n,client:a}){let i=n??(a?(await No(a,{address:t,table:Ro.tables.CallWithSignatureNonces,key:{signer:e.account.address},blockTag:"pending"})).nonce:0n),{namespace:s,name:c}=Eo(r);return await To(e,Po,"signTypedData")({account:e.account,domain:{verifyingContract:t,salt:Ao(e.chain.id,{size:32})},types:Uo,primaryType:"Call",message:{signer:e.account.address,systemNamespace:s,systemName:c,callData:o,nonce:i}})}import Ho from"@latticexyz/world-module-callwithsignature/out/CallWithSignatureSystem.sol/CallWithSignatureSystem.abi.json";async function ge({sessionClient:e,...t}){let r=await nt(t);return Io(e,Mo,"writeContract")({address:t.worldAddress,abi:Ho,functionName:"callWithSignature",args:[t.userClient.account.address,t.systemId,t.callData,r]})}function st({userClient:e}){let t=zo(),{chainId:r,worldAddress:o}=l(),n=Fo({chainId:r}),a=["setupSession",n?.chain.id,e.account.address];return Oo({mutationKey:a,onError:i=>console.error(i),mutationFn:async({sessionClient:i,registerSpender:s,registerDelegation:c})=>{if(!n)throw new Error("Client not ready.");let g=h(n.chain),m=i.account.address;if(console.log("setting up session"),e.account.type==="smart"){let d=[];if(s&&g?.type==="quarry"&&(console.log("registering spender"),d.push({to:g.address,abi:se,functionName:"registerSpender",args:[m]})),c&&(console.log("registering delegation"),d.push({to:o,abi:Qe,functionName:"registerDelegation",args:[m,B,"0x"]})),!d.length)return;console.log("setting up account with",d,e);let p=await fe(e,qo,"sendUserOperation")({calls:d});console.log("got user op hash",p);let f=await fe(e,Bo,"waitForUserOperationReceipt")({hash:p});console.log("got user op receipt",f),f.success||console.error("not successful?",f)}else{let d=[];if(s&&g?.type==="quarry"){console.log("registering spender");let p=await ge({client:n,userClient:e,sessionClient:i,worldAddress:g.address,systemId:it({type:"system",namespace:"",name:"SpenderSystem"}),callData:at({abi:se,functionName:"registerSpender",args:[m]})});console.log("got spender tx",p),d.push(p)}if(c){console.log("registering delegation");let p=await ge({client:n,userClient:e,sessionClient:i,worldAddress:o,systemId:it({type:"system",namespace:"",name:"Registration"}),callData:at({abi:Ko,functionName:"registerDelegation",args:[m,B,"0x"]})});console.log("got delegation tx",p),d.push(p)}if(!d.length)return;console.log("waiting for",d.length,"receipts");for(let p of d){let f=await fe(n,Lo,"waitForTransactionReceipt")({hash:p});console.log("got tx receipt",f),f.status==="reverted"&&console.error("tx reverted?",f)}}await Promise.all([t.invalidateQueries({queryKey:["getSpender"]}),t.invalidateQueries({queryKey:["getDelegation"]}),t.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{useEffect as fn}from"react";import{useClient as pn}from"wagmi";import{queryOptions as mn,useQuery as un}from"@tanstack/react-query";import{smartAccountActions as dn}from"permissionless";import{callFrom as cn}from"@latticexyz/world/internal";import{createBundlerClient as Do}from"viem/account-abstraction";var Go=new Set([31337,17420,17069,690]);function lt(e){let t=e.chain??e.client?.chain,r=t?h(t):void 0;return Do({...De,paymaster:r?{getPaymasterData:async()=>({paymaster:r.address,paymasterData:"0x"})}:void 0,userOperation:{estimateFeesPerGas:t&&Go.has(t.id)?async()=>({maxFeePerGas:100000n,maxPriorityFeePerGas:0n}):void 0},...e})}import{transactionQueue as tn}from"@latticexyz/common/actions";import{createClient as rn,fallback as on,http as ht,keccak256 as nn,stringToHex as an,webSocket as sn}from"viem";import{privateKeyToAccount as ln}from"viem/accounts";import{createTransport as $o,numberToHex as Zo,parseEther as Jo}from"viem";import{entryPoint07Address as gt}from"viem/account-abstraction";import{formatUserOperationRequest as Qo}from"viem/account-abstraction";async function dt(e){return Qo({callGasLimit:20000000n,preVerificationGas:200000n,verificationGasLimit:2000000n,paymasterVerificationGasLimit:200000n,paymasterPostOpGasLimit:200000n})}import{parseEventLogs as Vo}from"viem";import{formatUserOperation as Wo,toPackedUserOperation as _o,getUserOperationHash as Yo,entryPoint07Address as ct,entryPoint07Abi as pt}from"viem/account-abstraction";import{waitForTransactionReceipt as Xo,writeContract as jo}from"viem/actions";import{getAction as mt}from"viem/utils";async function ut({executor:e,rpcUserOp:t}){let r=Wo(t),o=_o(r),n=Yo({userOperation:r,chainId:e.chain.id,entryPointVersion:"0.7",entryPointAddress:ct}),a=await mt(e,jo,"writeContract")({abi:pt,address:ct,functionName:"handleOps",args:[[o],e.account.address],chain:e.chain,account:e.account}),i=await mt(e,Xo,"waitForTransactionReceipt")({hash:a});return{success:Vo({logs:i.logs,abi:pt,eventName:"UserOperationEvent"})[0].args.success,userOpHash:n,receipt:i}}import{setBalance as en}from"viem/actions";function ft({executor:e}){return()=>{I("using a local user op executor",e.account.address),e.chain.id===31337&&(I("setting executor balance"),en(e.extend(()=>({mode:"anvil"})),{address:e.account.address,value:Jo("100")}));let t=new Map;return $o({key:"userOpExecutor",type:"userOpExecutor",name:"User Operation Executor Transport",request:async({method:o,params:n})=>{if(o==="eth_chainId")return Zo(e.chain.id);if(o==="eth_supportedEntryPoints")return[gt];if(o==="eth_sendUserOperation"){let[a,i]=n;if(i===gt){let s=await ut({executor:e,rpcUserOp:a});return t.set(s.userOpHash,s),s.userOpHash}}if(o==="eth_getUserOperationReceipt"){let[a]=n;return t.get(a)??null}if(o==="eth_estimateUserOperationGas")return await dt(n);throw new Error("Method not implemented.")}})}}function yt(e){let t=e.rpcUrls.bundler?.http[0],r=t?ht(t):e.id===31337?ft({executor:rn({chain:e,transport:on([sn(),ht()]),account:ln(nn(an("local user op executor"))),pollingInterval:10}).extend(tn())}):null;if(!r)throw new Error(`Chain ${e.id} config did not include a bundler RPC URL.`);return r}async function bt({client:e,userAddress:t,sessionAccount:r,worldAddress:o}){let n=yt(e.chain);return lt({transport:n,client:e,account:r}).extend(dn).extend(cn({worldAddress:o,delegatorAddress:t,publicClient:e})).extend(()=>({userAddress:t}))}function gn({sessionAccount:e,client:t,userAddress:r,worldAddress:o}){let n=["getSessionClient",t?.uid,r,e?.address,o];return mn(t&&r&&e?{queryKey:n,queryFn:()=>bt({sessionAccount:e,client:t,userAddress:r,worldAddress:o}),staleTime:1/0}:{queryKey:n,enabled:!1})}function $(e){let{chainId:t,worldAddress:r}=l(),o=pn({chainId:t}),{data:n}=Xe(e);return un(gn({sessionAccount:n,userAddress:e,client:o,worldAddress:r}))}import{jsx as K,jsxs as he}from"react/jsx-runtime";function wt({isActive:e,isExpanded:t,userClient:r,registerSpender:o,registerDelegation:n}){let a=$(r.account.address),i=st({userClient:r}),s=!n&&!n;return fn(()=>{let c=setTimeout(()=>{e&&i.status==="idle"&&a.data&&!s&&i.mutate({sessionClient:a.data,registerSpender:o,registerDelegation:n})});return()=>clearTimeout(c)},[s,e,n,o,a,i]),he("div",{className:"flex flex-col gap-4",children:[he("div",{className:"flex justify-between gap-4",children:[he("div",{children:[K("div",{children:"Session"}),K("div",{className:"font-mono text-white",children:s?"Enabled":"Set up"})]}),s?K(y,{variant:"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,disabled:!0,children:"Enabled"}):K(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,pending:!a.data||i.status==="pending",onClick:a.data?()=>i.mutate({sessionClient:a.data,registerSpender:o,registerDelegation:n}):void 0,children:"Enable"})]}),t?K("p",{className:"text-sm",children:"You can perform actions in this app without interruptions for approvals."}):null]})}import{useBalance as vn}from"wagmi";var xt={"1":{bridgeUrl:"https://relay.link/bridge/ethereum"},"10":{bridgeUrl:"https://relay.link/bridge/optimism"},"56":{bridgeUrl:"https://relay.link/bridge/bnb"},"100":{bridgeUrl:"https://relay.link/bridge/gnosis"},"111":{bridgeUrl:"https://testnets.relay.link/bridge/bob"},"137":{bridgeUrl:"https://relay.link/bridge/polygon"},"185":{bridgeUrl:"https://relay.link/bridge/mint"},"288":{bridgeUrl:"https://relay.link/bridge/boba"},"324":{bridgeUrl:"https://relay.link/bridge/zksync"},"360":{bridgeUrl:"https://relay.link/bridge/shape"},"480":{bridgeUrl:"https://relay.link/bridge/world-chain"},"690":{bridgeUrl:"https://relay.link/bridge/redstone"},"919":{bridgeUrl:"https://testnets.relay.link/bridge/mode-testnet"},"1101":{bridgeUrl:"https://relay.link/bridge/polygon-zkevm"},"1135":{bridgeUrl:"https://relay.link/bridge/lisk"},"1301":{bridgeUrl:"https://testnets.relay.link/bridge/unichain-sepolia"},"1329":{bridgeUrl:"https://relay.link/bridge/sei"},"1625":{bridgeUrl:"https://relay.link/bridge/gravity"},"1868":{bridgeUrl:"https://relay.link/bridge/soneium"},"1993":{bridgeUrl:"https://testnets.relay.link/bridge/b3"},"1996":{bridgeUrl:"https://relay.link/bridge/sanko"},"2741":{bridgeUrl:"https://relay.link/bridge/abstract"},"2911":{bridgeUrl:"https://relay.link/bridge/hychain"},"4202":{bridgeUrl:"https://testnets.relay.link/bridge/lisk-sepolia"},"4321":{bridgeUrl:"https://relay.link/bridge/echos"},"5000":{bridgeUrl:"https://relay.link/bridge/mantle"},"5112":{bridgeUrl:"https://relay.link/bridge/ham"},"7560":{bridgeUrl:"https://relay.link/bridge/cyber"},"7865":{bridgeUrl:"https://relay.link/bridge/powerloom"},"7897":{bridgeUrl:"https://relay.link/bridge/arena-z"},"8333":{bridgeUrl:"https://relay.link/bridge/B3"},"8453":{bridgeUrl:"https://relay.link/bridge/base"},"9897":{bridgeUrl:"https://testnets.relay.link/bridge/arena-z-testnet"},"11011":{bridgeUrl:"https://testnets.relay.link/bridge/shape-sepolia"},"11124":{bridgeUrl:"https://testnets.relay.link/bridge/abstract"},"13746":{bridgeUrl:"https://testnets.relay.link/bridge/game7-testnet"},"17000":{bridgeUrl:"https://testnets.relay.link/bridge/holesky"},"17069":{bridgeUrl:"https://testnets.relay.link/bridge/garnet"},"17071":{bridgeUrl:"https://relay.link/bridge/onchain-points"},"33139":{bridgeUrl:"https://relay.link/bridge/apechain"},"33979":{bridgeUrl:"https://relay.link/bridge/funki"},"34443":{bridgeUrl:"https://relay.link/bridge/mode"},"42161":{bridgeUrl:"https://relay.link/bridge/arbitrum"},"42170":{bridgeUrl:"https://relay.link/bridge/arbitrum-nova"},"43114":{bridgeUrl:"https://relay.link/bridge/avalanche"},"55244":{bridgeUrl:"https://relay.link/bridge/superposition"},"57073":{bridgeUrl:"https://relay.link/bridge/ink"},"59144":{bridgeUrl:"https://relay.link/bridge/linea"},"60808":{bridgeUrl:"https://relay.link/bridge/bob"},"70700":{bridgeUrl:"https://relay.link/bridge/apex"},"70701":{bridgeUrl:"https://relay.link/bridge/boss"},"70800":{bridgeUrl:"https://testnets.relay.link/bridge/apex-testnet"},"70805":{bridgeUrl:"https://testnets.relay.link/bridge/cloud"},"80002":{bridgeUrl:"https://testnets.relay.link/bridge/amoy"},"81457":{bridgeUrl:"https://relay.link/bridge/blast"},"84532":{bridgeUrl:"https://testnets.relay.link/bridge/base-sepolia"},"167009":{bridgeUrl:"https://testnets.relay.link/bridge/hekla"},"421614":{bridgeUrl:"https://testnets.relay.link/bridge/arbitrum-sepolia"},"534352":{bridgeUrl:"https://relay.link/bridge/scroll"},"543210":{bridgeUrl:"https://relay.link/bridge/zero-network"},"660279":{bridgeUrl:"https://relay.link/bridge/xai"},"911867":{bridgeUrl:"https://testnets.relay.link/bridge/odyssey"},"984122":{bridgeUrl:"https://relay.link/bridge/forma"},"1118190":{bridgeUrl:"https://testnets.relay.link/bridge/eclipse-testnet"},"3397901":{bridgeUrl:"https://testnets.relay.link/bridge/funki-testnet"},"4457845":{bridgeUrl:"https://testnets.relay.link/bridge/zero-sepolia"},"7777777":{bridgeUrl:"https://relay.link/bridge/zora"},"8253038":{bridgeUrl:"https://relay.link/bridge/bitcoin"},"9092725":{bridgeUrl:"https://testnets.relay.link/bridge/bitcoin-testnet4"},"9286185":{bridgeUrl:"https://relay.link/bridge/eclipse"},"11155111":{bridgeUrl:"https://testnets.relay.link/bridge/sepolia"},"11155420":{bridgeUrl:"https://testnets.relay.link/bridge/op-sepolia"},"666666666":{bridgeUrl:"https://relay.link/bridge/degen"},"792703809":{bridgeUrl:"https://relay.link/bridge/solana"},"888888888":{bridgeUrl:"https://relay.link/bridge/ancient8"},"999999999":{bridgeUrl:"https://testnets.relay.link/bridge/zora-sepolia"},"1380012617":{bridgeUrl:"https://relay.link/bridge/rari"},"1936682084":{bridgeUrl:"https://testnets.relay.link/bridge/solana-devnet"},"88153591557":{bridgeUrl:"https://testnets.relay.link/bridge/arbitrum-blueberry"}};import{useQueryClient as yn,useMutation as bn}from"@tanstack/react-query";import{setBalance as wn}from"viem/actions";import{useClient as xn}from"wagmi";function vt(){let e=yn(),{chainId:t}=l(),r=xn({chainId:t});return bn({mutationKey:["setBalance",t],onError:o=>console.error(o),mutationFn:async o=>(r&&(await wn({...r,mode:"anvil"},o),await Promise.all([e.invalidateQueries({queryKey:["balance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])),null),retry:0})}import{Fragment as Cn,jsx as w,jsxs as D}from"react/jsx-runtime";function Ct({isActive:e,isExpanded:t,sessionAddress:r}){let{chain:o}=l(),n=vn({chainId:o.id,address:r,query:{refetchInterval:2e3}}),a=vt(),i=xt[o.id];return D("div",{className:"flex flex-col gap-4",children:[D("div",{className:"flex justify-between gap-4",children:[D("div",{children:[w("div",{children:"Gas balance"}),w("div",{className:"font-mono text-white",children:n.data!=null?w(j,{wei:n.data.value}):w(b,{className:"text-sm"})})]}),o.id===31337?w(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:n.status==="pending"||a.status==="pending",onClick:()=>a.mutate({address:r,value:P+(n.data?.value??0n)}),children:"Top up"}):i!=null?w("a",{href:`${i.bridgeUrl}?${new URLSearchParams({toAddress:r})}`,target:"_blank",rel:"noopener noreferrer",children:w(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:n.status==="pending",children:"Top up"})}):null]}),t?D(Cn,{children:[w("p",{className:"text-sm",children:"Your session's gas balance is used to pay for onchain computation."}),D("p",{className:"text-sm",children:["Send funds to"," ",w("span",{className:"font-mono text-white",children:w(M,{hex:r})})," ","on ",o.name," to top up your session balance."]})]}):null]})}import{jsx as U}from"react/jsx-runtime";function kt({userClient:e,initialUserAddress:t}){let{chain:r}=l(),o=h(r),n=e.account.address,{data:a}=T(n),{closeAccountModal:i}=C(),s=n!==t,c=An(a);kn(()=>{a!=null&&(c.current==null&&(c.current=a),a.complete&&(s||!c.current.complete)&&i())},[i,s,a]);let{sessionAddress:g,hasAllowance:m,isSpender:d,hasDelegation:p,hasGasBalance:f}=a??{},x=Sn(()=>{if(!n)return[{id:"wallet",isComplete:!1,content:()=>null}];let u=[{id:"wallet",isComplete:!0,content:v=>U(je,{...v,userAddress:n})}];return o?o.type==="quarry"&&u.push({id:"allowance",isComplete:!!m,content:v=>U(ot,{...v,userAddress:n})}):g!=null&&u.push({id:"gasBalance",isComplete:!!f,content:v=>U(Ct,{...v,sessionAddress:g})}),u.push({id:"session",isComplete:!!d&&!!p,content:v=>U(wt,{...v,userClient:e,registerSpender:!d,registerDelegation:!p})}),u},[m,p,f,d,o,g,n,e]),[we]=Pn(null),Ft=x.find(u=>u.content!=null&&!u.isComplete),te=x.filter(u=>u.isComplete),re=(we!=null?x.find(u=>u.id===we):null)??Ft??(te.length<x.length?te.at(-1):null),xe=re?x.indexOf(re):-1;return U("div",{className:ye("px-8 flex flex-col divide-y divide-neutral-800","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:x.map((u,v)=>{let oe=u===re,Kt=oe||te.length===x.length,Dt=!u.isComplete&&xe!==-1&&v>xe;return U("div",{className:ye("py-8 flex flex-col justify-center",oe?"flex-grow":null),children:U("div",{className:ye("flex flex-col",Dt?"opacity-30 pointer-events-none":null),children:u.content({isActive:oe,isExpanded:Kt})})},u.id)})})}import{useRef as Rn}from"react";import{jsx as St}from"react/jsx-runtime";function At(){let{chainId:e}=l(),t=Nn({chainId:e}),{address:r}=Un(),o=Rn(r);return t.status!=="success"?St(ze,{}):St(kt,{userClient:t.data,initialUserAddress:o.current})}import{useState as Hn}from"react";import{ErrorBoundary as On}from"react-error-boundary";import{twMerge as En}from"tailwind-merge";import{BaseError as Tn,UserRejectedRequestError as Mn}from"viem";import{jsx as Pt,jsxs as In}from"react/jsx-runtime";function Ut({title:e,error:t}){if(!t||t instanceof Tn&&t.walk(n=>n instanceof Mn)!=null)return null;let r=e??"Error",o=typeof t=="string"?t:t instanceof Error?String(t):"Something unexpected happened.";return In("div",{className:En("text-sm border-l-4 border-red-500","bg-red-100 text-red-900","dark:bg-red-900 dark:text-red-50"),children:[Pt("div",{className:"p-3 font-semibold",children:r}),Pt("div",{className:"px-3 whitespace-break-spaces break-all max-h-32 overflow-y-scroll",children:o})]})}import{wait as zn}from"@latticexyz/common/utils";import{twMerge as qn}from"tailwind-merge";import{useIsMounted as Bn}from"usehooks-ts";import{jsx as Z,jsxs as Nt}from"react/jsx-runtime";function Rt({children:e}){let t=Bn(),[r,o]=Hn(1);return Z(On,{fallbackRender:({error:n,resetErrorBoundary:a})=>Nt("div",{className:qn("flex-grow flex flex-col justify-center p-5 gap-2"),children:[Z(Ut,{error:n instanceof Error?n.stack??n.message:n}),r>0?Nt("button",{type:"button",onClick:async i=>{i.currentTarget.ariaBusy="true",await zn(1e3),a(),t()&&(o(s=>s-1),i.currentTarget.ariaBusy=null)},className:"group aria-busy:pointer-events-none self-end flex items-center gap-1",children:[Z(b,{className:"transition opacity-0 group-aria-busy:opacity-100 text-xs text-neutral-500 dark:text-neutral-400"}),Z("span",{className:"text-sm text-neutral-500 dark:text-neutral-400 group-hover:text-black dark:group-hover:text-white",children:"Retry?"})]}):null]}),children:e})}import{DialogClose as Kn,DialogTitle as Dn}from"@radix-ui/react-dialog";import{twMerge as Ln}from"tailwind-merge";import{jsx as Fn}from"react/jsx-runtime";function Et({className:e,children:t,...r}){return Fn("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:Ln("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...r,children:t})}import{jsx as Tt}from"react/jsx-runtime";function Mt(e){return Tt(Et,{strokeWidth:"2",stroke:"currentColor",...e,children:Tt("path",{d:"M6 18L18 6M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as k,jsxs as be}from"react/jsx-runtime";function Ht(){let{accountModalOpen:e,toggleAccountModal:t}=C();return be(Ie,{open:e,onOpenChange:t,children:[k(Dn,{className:"sr-only",children:"Connect with EntryKit"}),e?be("div",{className:It("relative py-2 ring-1","bg-neutral-900 text-neutral-400 ring-neutral-700/50 divide-neutral-700","links:font-medium links:underline links:underline-offset-4","links:text-white","links:decoration-neutral-500 hover:links:decoration-orange-500"),children:[k(Rt,{children:k(At,{})}),be("a",{href:"https://mud.dev",target:"_blank",rel:"noreferrer noopener",className:"group self-center p-3 flex items-center justify-center gap-2 links-unset text-sm font-mono transition text-neutral-400 hover:text-white",children:[k("span",{className:"block w-4 h-4",children:k(A,{className:"w-full h-full text-orange-500 group-hover:rotate-90 transition duration-300"})}),k("span",{children:"Powered by MUD"})]}),k("div",{className:"absolute top-0 right-0",children:k(Kn,{className:It("pointer-events-auto leading-none p-2 transition","text-neutral-700 hover:text-neutral-500"),title:"Close",children:k(Mt,{className:"m-0"})})})]}):null]})}import{jsx as Qn,jsxs as Vn}from"react/jsx-runtime";function Gn({config:e,children:t}){return Vn(Ne,{config:e,children:[t,Qn(Ht,{})]})}import{useAccount as _n}from"wagmi";import{twMerge as N}from"tailwind-merge";import{twMerge as Ot}from"tailwind-merge";import{Fragment as Wn,jsx as J,jsxs as zt}from"react/jsx-runtime";function qt({address:e}){let{data:t}=Y(e),r=V(t?.avatar);return zt(Wn,{children:[zt("span",{className:"flex-shrink-0 w-6 h-6 -my-1 -mx-0.5 grid place-items-center",children:[J("img",{src:t?.avatar&&r.isSuccess?t.avatar:void 0,className:Ot("col-start-1 row-start-1","inline-flex w-full h-full rounded-full bg-black/10 dark:bg-white/10 bg-cover bg-no-repeat bg-center","transtion duration-300",r.isSuccess?"opacity-100":"opacity-0")}),J(A,{className:Ot("col-start-1 row-start-1 text-orange-500","transition duration-300",t&&(!t.avatar||r.isError)?"opacity-100":"opacity-0")})]}),J("span",{className:"flex-grow",children:t?.name??J(M,{hex:e})})]})}import{useRef as Yn}from"react";import{jsx as S,jsxs as Lt}from"react/jsx-runtime";var Bt=N("w-48 p-3 inline-flex outline-none transition","border border-transparent","text-base leading-none"),Xn=N("bg-neutral-100 border-neutral-300 text-black","dark:bg-neutral-800 dark:border-neutral-700 dark:text-white"),jn=N("cursor-pointer outline-none hover:bg-neutral-200 data-[highlighted]:bg-neutral-200 dark:hover:bg-neutral-700");function $n(){let{openAccountModal:e,accountModalOpen:t}=C(),{status:r,address:o}=_n(),n=Yn(o),a=T(o),i=r==="connected"||r==="reconnecting"&&o,s=o!==n.current,c=a.isSuccess?a.data.complete:s?!1:i,g=(()=>{if(a.isSuccess){if(!a.data.hasAllowance)return"Top up";if(!a.data.hasDelegation||!a.data.isSpender)return"Set up"}return"Sign in"})();return S(G,{mode:"child",children:c?S("button",{type:"button",className:N(Bt,Xn,jn),onClick:e,children:S("span",{className:"flex-grow inline-flex gap-2.5 items-center text-left font-medium",children:o?S(qt,{address:o}):null})},"connected"):Lt("button",{type:"button",className:N(Bt,"group","items-center justify-center gap-2.5","bg-orange-500 text-white font-medium","hover:bg-orange-400","active:bg-orange-600"),"aria-busy":t,onClick:e,children:[Lt("span",{className:"pointer-events-none inline-grid place-items-center -ml-3",children:[S("span",{className:N("col-start-1 row-start-1 leading-none","scale-100 opacity-100 transition duration-300","group-aria-busy:scale-125 group-aria-busy:opacity-0"),children:S(A,{})}),S("span",{"aria-hidden":!0,className:N("col-start-1 row-start-1","scale-50 opacity-0 transition duration-300 delay-50","group-aria-busy:scale-100 group-aria-busy:opacity-100"),children:S(b,{})})]}),S("span",{className:"font-medium",children:g})]},"sign in")})}import{useConnectorClient as Zn}from"wagmi";function Jn(){let{chainId:e}=l(),t=Zn({chainId:e});t.error&&console.error("Error retrieving user client",t.error);let r=t.data?.account.address,o=T(r),n=$(r);return t.isSuccess?!o.isSuccess||!o.data.complete?{...o,data:void 0}:n:{...t,data:void 0}}import{connectorsForWallets as ta}from"@rainbow-me/rainbowkit";import{createConfig as ra}from"wagmi";import{getDefaultWallets as ea}from"@rainbow-me/rainbowkit";function ee(e){let{wallets:t}=ea();return[...t]}function oa(e){let t=ee(e),r=ta(t,{appName:e.appName,projectId:e.walletConnectProjectId});return ra({connectors:r,chains:e.chains,transports:e.transports,pollingInterval:e.pollingInterval})}import{connectorsForWallets as na}from"@rainbow-me/rainbowkit";function wm({wallets:e,...t}){return na(e??ee(t),{appName:t.appName,projectId:t.walletConnectProjectId})}export{$n as AccountButton,Gn as EntryKitProvider,oa as createWagmiConfig,Gt as defineConfig,wm as getConnectors,ee as getWallets,C as useAccountModal,l as useEntryKitConfig,Jn as useSessionClient};
|
|
1908
|
+
const title = initialTitle ?? "Error";
|
|
1909
|
+
const message = typeof error2 === "string" ? error2 : error2 instanceof Error ? String(error2) : "Something unexpected happened.";
|
|
1910
|
+
return /* @__PURE__ */ jsxs15(
|
|
1911
|
+
"div",
|
|
1912
|
+
{
|
|
1913
|
+
className: twMerge8(
|
|
1914
|
+
"text-sm border-l-4 border-red-500",
|
|
1915
|
+
"bg-red-100 text-red-900",
|
|
1916
|
+
"dark:bg-red-900 dark:text-red-50"
|
|
1917
|
+
),
|
|
1918
|
+
children: [
|
|
1919
|
+
/* @__PURE__ */ jsx19("div", { className: "p-3 font-semibold", children: title }),
|
|
1920
|
+
/* @__PURE__ */ jsx19("div", { className: "px-3 whitespace-break-spaces break-all max-h-32 overflow-y-scroll", children: message })
|
|
1921
|
+
]
|
|
1922
|
+
}
|
|
1923
|
+
);
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
// src/AccountModalErrorBoundary.tsx
|
|
1927
|
+
import { wait } from "@latticexyz/common/utils";
|
|
1928
|
+
import { twMerge as twMerge9 } from "tailwind-merge";
|
|
1929
|
+
import { useIsMounted } from "usehooks-ts";
|
|
1930
|
+
import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1931
|
+
function AccountModalErrorBoundary({ children }) {
|
|
1932
|
+
const isMounted = useIsMounted();
|
|
1933
|
+
const [retries, setRetries] = useState4(1);
|
|
1934
|
+
return /* @__PURE__ */ jsx20(
|
|
1935
|
+
ErrorBoundary,
|
|
1936
|
+
{
|
|
1937
|
+
fallbackRender: ({ error: error2, resetErrorBoundary }) => /* @__PURE__ */ jsxs16("div", { className: twMerge9("flex-grow flex flex-col justify-center p-5 gap-2"), children: [
|
|
1938
|
+
/* @__PURE__ */ jsx20(ErrorNotice, { error: error2 instanceof Error ? error2.stack ?? error2.message : error2 }),
|
|
1939
|
+
retries > 0 ? /* @__PURE__ */ jsxs16(
|
|
1940
|
+
"button",
|
|
1941
|
+
{
|
|
1942
|
+
type: "button",
|
|
1943
|
+
onClick: async (event) => {
|
|
1944
|
+
event.currentTarget.ariaBusy = "true";
|
|
1945
|
+
await wait(1e3);
|
|
1946
|
+
resetErrorBoundary();
|
|
1947
|
+
if (isMounted()) {
|
|
1948
|
+
setRetries((value) => value - 1);
|
|
1949
|
+
event.currentTarget.ariaBusy = null;
|
|
1950
|
+
}
|
|
1951
|
+
},
|
|
1952
|
+
className: "group aria-busy:pointer-events-none self-end flex items-center gap-1",
|
|
1953
|
+
children: [
|
|
1954
|
+
/* @__PURE__ */ jsx20(PendingIcon, { className: "transition opacity-0 group-aria-busy:opacity-100 text-xs text-neutral-500 dark:text-neutral-400" }),
|
|
1955
|
+
/* @__PURE__ */ jsx20("span", { className: "text-sm text-neutral-500 dark:text-neutral-400 group-hover:text-black dark:group-hover:text-white", children: "Retry?" })
|
|
1956
|
+
]
|
|
1957
|
+
}
|
|
1958
|
+
) : null
|
|
1959
|
+
] }),
|
|
1960
|
+
children
|
|
1961
|
+
}
|
|
1962
|
+
);
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
// src/AccountModal.tsx
|
|
1966
|
+
import { DialogClose, DialogTitle } from "@radix-ui/react-dialog";
|
|
1967
|
+
|
|
1968
|
+
// src/icons/IconSVG.tsx
|
|
1969
|
+
import { twMerge as twMerge10 } from "tailwind-merge";
|
|
1970
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
1971
|
+
function IconSVG({ className, children, ...props }) {
|
|
1972
|
+
return /* @__PURE__ */ jsx21(
|
|
1973
|
+
"svg",
|
|
1974
|
+
{
|
|
1975
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1976
|
+
viewBox: "0 0 24 24",
|
|
1977
|
+
fill: "currentColor",
|
|
1978
|
+
className: twMerge10("-my-[0.125em] h-[1.25em] w-[1.25em]", className),
|
|
1979
|
+
...props,
|
|
1980
|
+
children
|
|
1981
|
+
}
|
|
1982
|
+
);
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
// src/icons/CloseIcon.tsx
|
|
1986
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1987
|
+
function CloseIcon(props) {
|
|
1988
|
+
return /* @__PURE__ */ jsx22(IconSVG, { strokeWidth: "2", stroke: "currentColor", ...props, children: /* @__PURE__ */ jsx22(
|
|
1989
|
+
"path",
|
|
1990
|
+
{
|
|
1991
|
+
d: "M6 18L18 6M6 6L18 18",
|
|
1992
|
+
fill: "none",
|
|
1993
|
+
stroke: "currentColor",
|
|
1994
|
+
strokeWidth: "2",
|
|
1995
|
+
strokeLinecap: "round",
|
|
1996
|
+
strokeLinejoin: "round"
|
|
1997
|
+
}
|
|
1998
|
+
) });
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
// src/AccountModal.tsx
|
|
2002
|
+
import { jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2003
|
+
function AccountModal() {
|
|
2004
|
+
const { accountModalOpen, toggleAccountModal } = useAccountModal();
|
|
2005
|
+
return /* @__PURE__ */ jsxs17(Modal, { open: accountModalOpen, onOpenChange: toggleAccountModal, children: [
|
|
2006
|
+
/* @__PURE__ */ jsx23(DialogTitle, { className: "sr-only", children: "Connect with EntryKit" }),
|
|
2007
|
+
accountModalOpen ? /* @__PURE__ */ jsxs17(
|
|
2008
|
+
"div",
|
|
2009
|
+
{
|
|
2010
|
+
className: twMerge11(
|
|
2011
|
+
"relative py-2 ring-1",
|
|
2012
|
+
"bg-neutral-900 text-neutral-400 ring-neutral-700/50 divide-neutral-700",
|
|
2013
|
+
"links:font-medium links:underline links:underline-offset-4",
|
|
2014
|
+
"links:text-white",
|
|
2015
|
+
"links:decoration-neutral-500 hover:links:decoration-orange-500"
|
|
2016
|
+
),
|
|
2017
|
+
children: [
|
|
2018
|
+
/* @__PURE__ */ jsx23(AccountModalErrorBoundary, { children: /* @__PURE__ */ jsx23(AccountModalContent, {}) }),
|
|
2019
|
+
/* @__PURE__ */ jsxs17(
|
|
2020
|
+
"a",
|
|
2021
|
+
{
|
|
2022
|
+
href: "https://mud.dev",
|
|
2023
|
+
target: "_blank",
|
|
2024
|
+
rel: "noreferrer noopener",
|
|
2025
|
+
className: "group self-center p-3 flex items-center justify-center gap-2 links-unset text-sm font-mono transition text-neutral-400 hover:text-white",
|
|
2026
|
+
children: [
|
|
2027
|
+
/* @__PURE__ */ jsx23("span", { className: "block w-4 h-4", children: /* @__PURE__ */ jsx23(Logo, { className: "w-full h-full text-orange-500 group-hover:rotate-90 transition duration-300" }) }),
|
|
2028
|
+
/* @__PURE__ */ jsx23("span", { children: "Powered by MUD" })
|
|
2029
|
+
]
|
|
2030
|
+
}
|
|
2031
|
+
),
|
|
2032
|
+
/* @__PURE__ */ jsx23("div", { className: "absolute top-0 right-0", children: /* @__PURE__ */ jsx23(
|
|
2033
|
+
DialogClose,
|
|
2034
|
+
{
|
|
2035
|
+
className: twMerge11(
|
|
2036
|
+
"pointer-events-auto leading-none p-2 transition",
|
|
2037
|
+
"text-neutral-700 hover:text-neutral-500"
|
|
2038
|
+
),
|
|
2039
|
+
title: "Close",
|
|
2040
|
+
children: /* @__PURE__ */ jsx23(CloseIcon, { className: "m-0" })
|
|
2041
|
+
}
|
|
2042
|
+
) })
|
|
2043
|
+
]
|
|
2044
|
+
}
|
|
2045
|
+
) : null
|
|
2046
|
+
] });
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
// src/EntryKitProvider.tsx
|
|
2050
|
+
import { jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2051
|
+
function EntryKitProvider({ config, children }) {
|
|
2052
|
+
return /* @__PURE__ */ jsxs18(EntryKitConfigProvider, { config, children: [
|
|
2053
|
+
children,
|
|
2054
|
+
/* @__PURE__ */ jsx24(AccountModal, {})
|
|
2055
|
+
] });
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
// src/AccountButton.tsx
|
|
2059
|
+
import { useAccount as useAccount3 } from "wagmi";
|
|
2060
|
+
import { twMerge as twMerge13 } from "tailwind-merge";
|
|
2061
|
+
|
|
2062
|
+
// src/AccountName.tsx
|
|
2063
|
+
import { twMerge as twMerge12 } from "tailwind-merge";
|
|
2064
|
+
import { useEffect as useEffect8 } from "react";
|
|
2065
|
+
import { Fragment as Fragment2, jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2066
|
+
function AccountName({ address }) {
|
|
2067
|
+
const { data: ens, error: ensError } = useENS(address);
|
|
2068
|
+
const avatar = usePreloadImage(ens?.avatar);
|
|
2069
|
+
useEffect8(() => {
|
|
2070
|
+
if (ensError) {
|
|
2071
|
+
console.log("Could not get ENS", ensError);
|
|
2072
|
+
}
|
|
2073
|
+
}, [ensError]);
|
|
2074
|
+
return /* @__PURE__ */ jsxs19(Fragment2, { children: [
|
|
2075
|
+
/* @__PURE__ */ jsxs19("span", { className: "flex-shrink-0 w-6 h-6 -my-1 -mx-0.5 grid place-items-center", children: [
|
|
2076
|
+
/* @__PURE__ */ jsx25(
|
|
2077
|
+
"img",
|
|
2078
|
+
{
|
|
2079
|
+
src: ens?.avatar && avatar.isSuccess ? ens.avatar : void 0,
|
|
2080
|
+
className: twMerge12(
|
|
2081
|
+
"col-start-1 row-start-1",
|
|
2082
|
+
"inline-flex w-full h-full rounded-full bg-black/10 dark:bg-white/10 bg-cover bg-no-repeat bg-center",
|
|
2083
|
+
"transtion duration-300",
|
|
2084
|
+
avatar.isSuccess ? "opacity-100" : "opacity-0"
|
|
2085
|
+
)
|
|
2086
|
+
}
|
|
2087
|
+
),
|
|
2088
|
+
/* @__PURE__ */ jsx25(
|
|
2089
|
+
Logo,
|
|
2090
|
+
{
|
|
2091
|
+
className: twMerge12(
|
|
2092
|
+
"col-start-1 row-start-1 text-orange-500",
|
|
2093
|
+
"transition duration-300",
|
|
2094
|
+
ens && (!ens.avatar || avatar.isError) ? "opacity-100" : "opacity-0"
|
|
2095
|
+
)
|
|
2096
|
+
}
|
|
2097
|
+
)
|
|
2098
|
+
] }),
|
|
2099
|
+
/* @__PURE__ */ jsx25("span", { className: "flex-grow", children: ens?.name ?? /* @__PURE__ */ jsx25(TruncatedHex, { hex: address }) })
|
|
2100
|
+
] });
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
// src/AccountButton.tsx
|
|
2104
|
+
import { useRef as useRef4 } from "react";
|
|
2105
|
+
import { jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2106
|
+
var containerClassNames = twMerge13(
|
|
2107
|
+
"w-48 p-3 inline-flex outline-none transition",
|
|
2108
|
+
"border border-transparent",
|
|
2109
|
+
"text-base leading-none"
|
|
2110
|
+
);
|
|
2111
|
+
var secondaryClassNames = twMerge13(
|
|
2112
|
+
"bg-neutral-100 border-neutral-300 text-black",
|
|
2113
|
+
"dark:bg-neutral-800 dark:border-neutral-700 dark:text-white"
|
|
2114
|
+
);
|
|
2115
|
+
var secondaryInteractiveClassNames = twMerge13(
|
|
2116
|
+
"cursor-pointer outline-none hover:bg-neutral-200 data-[highlighted]:bg-neutral-200 dark:hover:bg-neutral-700"
|
|
2117
|
+
);
|
|
2118
|
+
function AccountButton() {
|
|
2119
|
+
const { openAccountModal, accountModalOpen } = useAccountModal();
|
|
2120
|
+
const { status, address: userAddress } = useAccount3();
|
|
2121
|
+
const initialUserAddress = useRef4(userAddress);
|
|
2122
|
+
const prereqs = usePrerequisites(userAddress);
|
|
2123
|
+
const isConnected = status === "connected" || status === "reconnecting" && userAddress;
|
|
2124
|
+
const isNewConnection = userAddress !== initialUserAddress.current;
|
|
2125
|
+
const isSignedIn = prereqs.isSuccess ? prereqs.data.complete : isNewConnection ? false : isConnected;
|
|
2126
|
+
const buttonLabel = (() => {
|
|
2127
|
+
if (prereqs.isSuccess) {
|
|
2128
|
+
if (!prereqs.data.hasAllowance) return "Top up";
|
|
2129
|
+
if (!prereqs.data.hasDelegation || !prereqs.data.isSpender) return "Set up";
|
|
2130
|
+
}
|
|
2131
|
+
return "Sign in";
|
|
2132
|
+
})();
|
|
2133
|
+
return /* @__PURE__ */ jsx26(Shadow, { mode: "child", children: isSignedIn ? /* @__PURE__ */ jsx26(
|
|
2134
|
+
"button",
|
|
2135
|
+
{
|
|
2136
|
+
type: "button",
|
|
2137
|
+
className: twMerge13(containerClassNames, secondaryClassNames, secondaryInteractiveClassNames),
|
|
2138
|
+
onClick: openAccountModal,
|
|
2139
|
+
children: /* @__PURE__ */ jsx26("span", { className: "flex-grow inline-flex gap-2.5 items-center text-left font-medium", children: userAddress ? /* @__PURE__ */ jsx26(AccountName, { address: userAddress }) : null })
|
|
2140
|
+
},
|
|
2141
|
+
"connected"
|
|
2142
|
+
) : /* @__PURE__ */ jsxs20(
|
|
2143
|
+
"button",
|
|
2144
|
+
{
|
|
2145
|
+
type: "button",
|
|
2146
|
+
className: twMerge13(
|
|
2147
|
+
containerClassNames,
|
|
2148
|
+
"group",
|
|
2149
|
+
"items-center justify-center gap-2.5",
|
|
2150
|
+
"bg-orange-500 text-white font-medium",
|
|
2151
|
+
"hover:bg-orange-400",
|
|
2152
|
+
"active:bg-orange-600"
|
|
2153
|
+
),
|
|
2154
|
+
"aria-busy": accountModalOpen,
|
|
2155
|
+
onClick: openAccountModal,
|
|
2156
|
+
children: [
|
|
2157
|
+
/* @__PURE__ */ jsxs20("span", { className: "pointer-events-none inline-grid place-items-center -ml-3", children: [
|
|
2158
|
+
/* @__PURE__ */ jsx26(
|
|
2159
|
+
"span",
|
|
2160
|
+
{
|
|
2161
|
+
className: twMerge13(
|
|
2162
|
+
"col-start-1 row-start-1 leading-none",
|
|
2163
|
+
"scale-100 opacity-100 transition duration-300",
|
|
2164
|
+
"group-aria-busy:scale-125 group-aria-busy:opacity-0"
|
|
2165
|
+
),
|
|
2166
|
+
children: /* @__PURE__ */ jsx26(Logo, {})
|
|
2167
|
+
}
|
|
2168
|
+
),
|
|
2169
|
+
/* @__PURE__ */ jsx26(
|
|
2170
|
+
"span",
|
|
2171
|
+
{
|
|
2172
|
+
"aria-hidden": true,
|
|
2173
|
+
className: twMerge13(
|
|
2174
|
+
"col-start-1 row-start-1",
|
|
2175
|
+
"scale-50 opacity-0 transition duration-300 delay-50",
|
|
2176
|
+
"group-aria-busy:scale-100 group-aria-busy:opacity-100"
|
|
2177
|
+
),
|
|
2178
|
+
children: /* @__PURE__ */ jsx26(PendingIcon, {})
|
|
2179
|
+
}
|
|
2180
|
+
)
|
|
2181
|
+
] }),
|
|
2182
|
+
/* @__PURE__ */ jsx26("span", { className: "font-medium", children: buttonLabel })
|
|
2183
|
+
]
|
|
2184
|
+
},
|
|
2185
|
+
"sign in"
|
|
2186
|
+
) });
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
// src/useSessionClientReady.ts
|
|
2190
|
+
import { useConnectorClient as useConnectorClient2 } from "wagmi";
|
|
2191
|
+
function useSessionClientReady() {
|
|
2192
|
+
const { chainId } = useEntryKitConfig();
|
|
2193
|
+
const userClient = useConnectorClient2({ chainId });
|
|
2194
|
+
if (userClient.error) console.error("Error retrieving user client", userClient.error);
|
|
2195
|
+
const userAddress = userClient.data?.account.address;
|
|
2196
|
+
const prerequisites = usePrerequisites(userAddress);
|
|
2197
|
+
const sessionClient = useSessionClient(userAddress);
|
|
2198
|
+
if (!userClient.isSuccess) return { ...userClient, data: void 0 };
|
|
2199
|
+
if (!prerequisites.isSuccess || !prerequisites.data.complete) return { ...prerequisites, data: void 0 };
|
|
2200
|
+
return sessionClient;
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
// src/createWagmiConfig.ts
|
|
2204
|
+
import { connectorsForWallets } from "@rainbow-me/rainbowkit";
|
|
2205
|
+
import { createConfig } from "wagmi";
|
|
2206
|
+
|
|
2207
|
+
// src/getWallets.ts
|
|
2208
|
+
import { getDefaultWallets } from "@rainbow-me/rainbowkit";
|
|
2209
|
+
function getWallets(_config) {
|
|
2210
|
+
const { wallets: defaultWallets } = getDefaultWallets();
|
|
2211
|
+
return [
|
|
2212
|
+
// TODO: passkey wallet
|
|
2213
|
+
...defaultWallets
|
|
2214
|
+
];
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
// src/createWagmiConfig.ts
|
|
2218
|
+
function createWagmiConfig(config) {
|
|
2219
|
+
const wallets = getWallets(config);
|
|
2220
|
+
const connectors = connectorsForWallets(wallets, {
|
|
2221
|
+
appName: config.appName,
|
|
2222
|
+
projectId: config.walletConnectProjectId
|
|
2223
|
+
});
|
|
2224
|
+
return createConfig({
|
|
2225
|
+
connectors,
|
|
2226
|
+
chains: config.chains,
|
|
2227
|
+
transports: config.transports,
|
|
2228
|
+
pollingInterval: config.pollingInterval
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
// src/getConnectors.ts
|
|
2233
|
+
import { connectorsForWallets as connectorsForWallets2 } from "@rainbow-me/rainbowkit";
|
|
2234
|
+
function getConnectors({
|
|
2235
|
+
wallets,
|
|
2236
|
+
...config
|
|
2237
|
+
}) {
|
|
2238
|
+
return connectorsForWallets2(wallets ?? getWallets(config), {
|
|
2239
|
+
appName: config.appName,
|
|
2240
|
+
projectId: config.walletConnectProjectId
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
export {
|
|
2244
|
+
AccountButton,
|
|
2245
|
+
EntryKitProvider,
|
|
2246
|
+
createWagmiConfig,
|
|
2247
|
+
defineConfig,
|
|
2248
|
+
getConnectors,
|
|
2249
|
+
getWallets,
|
|
2250
|
+
useAccountModal,
|
|
2251
|
+
useEntryKitConfig,
|
|
2252
|
+
useSessionClientReady as useSessionClient
|
|
2253
|
+
};
|
|
1398
2254
|
//# sourceMappingURL=internal.js.map
|