@@ -51,33 +51,35 @@ 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
73+ setRedirect(redirect);
74+ setError(rejected ?? "");
75+
7576 let signingState = false;
7677 function setSigning(signing: boolean) {
7778 signingState = signing;
7879 updateDisplay();
7980 }
8081
82+ const { appkitStore } = await import("../store/appkit");
8183 function updateDisplay() {
8284 // Signing indicator
8385 {
@@ -98,21 +100,17 @@ import Connect from "../components/Connect.astro";
98100 }
99101 }
100102
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 ?? "");
108-
109103 appkitStore.account.subscribe((account) => {
110104 if (!account) {
111105 signingState = false;
112106 }
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