@@ -51,26 +51,17 @@ import Connect from "../components/Connect.astro";
5151 >
5252</div >
5353<script >
54- import { wagmiAdapter } from "../scripts/appkit";
54+ import sdk from "@farcaster/miniapp-sdk";
55+ sdk.actions.ready();
56+ </script >
57+ <script >
58+ import { wagmiAdapter } from "../scripts/wagmi";
5559 import { getMessage } from "../lib/message";
5660 import { toXnodeAddress } from "../lib/xnode-address";
57- import { appkitStore } from "../store/appkit";
5861 import { signMessage } from "@wagmi/core";
59-
60- function setRedirect(redirect: string) {
61- const node = document.getElementById("redirect");
62- if (node) {
63- node.textContent = redirect;
64- }
65- }
66-
67- function setError(error: string) {
68- const node = document.getElementById("error");
69- if (node) {
70- node.style.display = error ? "flex" : "none";
71- node.textContent = error;
72- }
73- }
62+ import { appkitStore } from "../store/appkit";
63+ import { setError } from "../scripts/reactive";
64+ import { redirect } from "../scripts/params";
7465
7566 let signingState = false;
7667 function setSigning(signing: boolean) {
@@ -98,14 +89,6 @@ import Connect from "../components/Connect.astro";
9889 }
9990 }
10091
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-
10992 appkitStore.account.subscribe((account) => {
11093 if (!account) {
11194 signingState = false;
@@ -166,6 +149,9 @@ import Connect from "../components/Connect.astro";
166149 });
167150</script >
168151<script >
169- import sdk from "@farcaster/miniapp-sdk";
170- sdk.actions.ready();
152+ import { setRedirect, setError } from "../scripts/reactive";
153+ import { redirect, rejected } from "../scripts/params";
154+
155+ setRedirect(redirect);
156+ setError(rejected ?? "");
171157</script >
0 commit comments