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