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