@@ -51,33 +51,29 @@ import Connect from "../components/Connect.astro";
5151 >
5252</div >
5353<script >
54- import { wagmiAdapter } from "../scripts/appkit";
55- import { getMessage } from "../lib/message";
56- import { toXnodeAddress } from "../lib/xnode-address";
57- import { appkitStore } from "../store/appkit";
58- import { signMessage } from "@wagmi/core";
54+ const urlParams = new URLSearchParams(window.location.search);
55+ const redirect = urlParams.get("redirect") ?? window.location.origin;
56+ const rejected = urlParams.get("rejected");
5957
60- function setRedirect(redirect: string) {
58+ export function setRedirect(redirect: string) {
6159 const node = document.getElementById("redirect");
6260 if (node) {
6361 node.textContent = redirect;
6462 }
6563 }
6664
67- function setError(error: string) {
65+ export function setError(error: string) {
6866 const node = document.getElementById("error");
6967 if (node) {
7068 node.style.display = error ? "flex" : "none";
7169 node.textContent = error;
7270 }
7371 }
7472
75- let signingState = false;
76- function setSigning(signing: boolean) {
77- signingState = signing;
78- updateDisplay();
79- }
73+ setRedirect(redirect);
74+ setError(rejected ?? "");
8075
76+ const { appkitStore } = await import("../store/appkit");
8177 function updateDisplay() {
8278 // Signing indicator
8379 {
@@ -98,13 +94,11 @@ import Connect from "../components/Connect.astro";
9894 }
9995 }
10096
101- const urlParams = new URLSearchParams(window.location.search);
102-
103- const redirect = urlParams.get("redirect") ?? window.location.origin;
104- setRedirect(redirect);
105-
106- const rejected = urlParams.get("rejected");
107- setError(rejected ?? "");
97+ let signingState = false;
98+ function setSigning(signing: boolean) {
99+ signingState = signing;
100+ updateDisplay();
101+ }
108102
109103 appkitStore.account.subscribe((account) => {
110104 if (!account) {
@@ -113,6 +107,10 @@ import Connect from "../components/Connect.astro";
113107 updateDisplay();
114108 });
115109
110+ const { wagmiAdapter } = await import("../scripts/wagmi");
111+ const { getMessage } = await import("../lib/message");
112+ const { toXnodeAddress } = await import("../lib/xnode-address");
113+ const { signMessage } = await import("@wagmi/core");
116114 document
117115 .getElementById("authenticate")
118116 ?.addEventListener("click", async () => {
@@ -164,8 +162,7 @@ import Connect from "../components/Connect.astro";
164162 setSigning(false);
165163 }
166164 });
167- </script >
168- <script >
169- import sdk from "@farcaster/miniapp-sdk";
165+
166+ const { sdk } = await import("@farcaster/miniapp-sdk");
170167 sdk.actions.ready();
171168</script >
0 commit comments