diff --git a/app.config.ts b/app.config.ts
index 09526b8..4c72d68 100644
--- a/app.config.ts
+++ b/app.config.ts
@@ -18,5 +18,5 @@ export default defineConfig({
projects: ["./tsconfig.json"],
}),
],
- },
+ } as any,
});
diff --git a/app/components/DefaultCatchBoundary.tsx b/app/components/DefaultCatchBoundary.tsx
index 9bf60a0..c74028d 100644
--- a/app/components/DefaultCatchBoundary.tsx
+++ b/app/components/DefaultCatchBoundary.tsx
@@ -25,7 +25,7 @@ export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
onClick={() => {
router.invalidate();
}}
- className="rounded bg-gray-600 px-2 py-1 font-extrabold text-white uppercase dark:bg-gray-700"
+ className="cursor-pointer rounded bg-gray-600 px-2 py-1 font-extrabold text-white uppercase dark:bg-gray-700"
>
Try Again
diff --git a/app/components/LoadingSpinner.tsx b/app/components/LoadingSpinner.tsx
new file mode 100644
index 0000000..7afcda7
--- /dev/null
+++ b/app/components/LoadingSpinner.tsx
@@ -0,0 +1,7 @@
+export function LoadingSpinner() {
+ return (
+
+ );
+}
diff --git a/app/hooks/useConnectionState.ts b/app/hooks/useConnectionState.ts
index 9160f74..7ce8f1e 100644
--- a/app/hooks/useConnectionState.ts
+++ b/app/hooks/useConnectionState.ts
@@ -1,23 +1,27 @@
-import { useState } from "react";
-import { useConfig, useWatchBlockNumber } from "wagmi";
+import { useCallback } from "react";
+import { useWatchBlockNumber } from "wagmi";
+import { useConnectionStore } from "#/store/connection";
-export function useConnectionState() {
- const [blockNumber, setBlockNumber] = useState(null);
- const config = useConfig();
+export function useConnectionState({ rpc }: { rpc: string }) {
+ const { setState } = useConnectionStore();
- const interval = blockNumber ? 10000 : 1000;
+ const onBlockNumber = useCallback(
+ (b: bigint) => {
+ console.log("onblocknumber", b);
+ setState({ connected: true, blockNumber: b, rpc });
+ },
+ [rpc, setState],
+ );
+
+ const onError = useCallback(() => {
+ setState({ connected: false, blockNumber: null, rpc });
+ }, [rpc, setState]);
useWatchBlockNumber({
emitOnBegin: true,
poll: true,
- pollingInterval: interval,
- onBlockNumber: (b) => setBlockNumber(b),
- onError: () => setBlockNumber(null),
+ pollingInterval: 1000,
+ onBlockNumber,
+ onError,
});
-
- return {
- connected: blockNumber !== null,
- blockNumber,
- rpc: config.chains[0].rpcUrls.default.http,
- };
}
diff --git a/app/routes/__root.tsx b/app/routes/__root.tsx
index 5e4c8c3..6012968 100644
--- a/app/routes/__root.tsx
+++ b/app/routes/__root.tsx
@@ -1,14 +1,22 @@
+import { Form } from "@ethui/ui/components/form";
+import { Button } from "@ethui/ui/components/shadcn/button";
+import { zodResolver } from "@hookform/resolvers/zod";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import {
HeadContent,
Outlet,
Scripts,
createRootRouteWithContext,
+ useNavigate,
+ useParams,
} from "@tanstack/react-router";
import { Suspense, lazy } from "react";
+import { type FieldValues, useForm } from "react-hook-form";
+import { z } from "zod";
import appCss from "#/app.css?url";
import { DefaultCatchBoundary } from "#/components/DefaultCatchBoundary";
import { NotFound } from "#/components/NotFound";
+import { useConnectionStore } from "#/store/connection";
import { seo } from "#/utils/seo";
const TanStackRouterDevtools =
@@ -76,6 +84,7 @@ function RootComponent() {
return (
+
@@ -98,3 +107,57 @@ function RootDocument({ children }: { children: React.ReactNode }) {