From 9973f17343fa12d3fc6dd44f6b9a9075fecaf036 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:22:28 +0000 Subject: [PATCH] feat: add wagmiConfig and align provider setup with upstream template --- components/ScaffoldEthAppWithProviders.tsx | 112 +++++++-------------- services/web3/wagmiConfig.ts | 12 +++ 2 files changed, 47 insertions(+), 77 deletions(-) create mode 100644 services/web3/wagmiConfig.ts diff --git a/components/ScaffoldEthAppWithProviders.tsx b/components/ScaffoldEthAppWithProviders.tsx index 4b9f2f472..f67c2f7b6 100644 --- a/components/ScaffoldEthAppWithProviders.tsx +++ b/components/ScaffoldEthAppWithProviders.tsx @@ -1,103 +1,61 @@ "use client"; import { useEffect, useState } from "react"; -import { getDefaultConfig, RainbowKitProvider, darkTheme, lightTheme } from "@rainbow-me/rainbowkit"; -import type { AvatarComponent } from "@rainbow-me/rainbowkit"; +import { RainbowKitProvider, darkTheme, lightTheme } from "@rainbow-me/rainbowkit"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { useTheme } from "next-themes"; import { Toaster } from "react-hot-toast"; import { WagmiProvider } from "wagmi"; -import { base, baseSepolia } from 'viem/chains'; -import { http } from 'wagmi'; - -import { useInitializeNativeCurrencyPrice } from "../hooks/scaffold-eth"; -import { Footer } from "./Footer"; -import { Header } from "./Header"; -import { BlockieAvatar } from "./scaffold-eth"; -import { ProgressBar } from "./scaffold-eth/ProgressBar"; -import ErrorBoundary from "./ErrorBoundary"; - -import "@rainbow-me/rainbowkit/styles.css"; - -const queryClient = new QueryClient(); - -const config = getDefaultConfig({ - appName: 'MissionEnrollment', - projectId: process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID || 'YOUR_PROJECT_ID', - chains: [baseSepolia], // Temporarily use only Base Sepolia for testing - transports: { - [baseSepolia.id]: http('https://sepolia.base.org'), - }, -}); - -const ScaffoldEthApp = ({ children }: { children: React.ReactNode }): JSX.Element => { +import { Footer } from "~~/components/Footer"; +import { Header } from "~~/components/Header"; +import { BlockieAvatar } from "~~/components/scaffold-eth"; +import { ProgressBar } from "~~/components/scaffold-eth/ProgressBar"; +import { useInitializeNativeCurrencyPrice } from "~~/hooks/scaffold-eth"; +import { wagmiConfig } from "~~/services/web3/wagmiConfig"; + +const ScaffoldEthApp = ({ children }: { children: React.ReactNode }) => { useInitializeNativeCurrencyPrice(); - useEffect(() => { - console.log('ScaffoldEthApp mounted'); - return () => console.log('ScaffoldEthApp unmounted'); - }, []); - return ( - + <>
-
- {children} -
+
{children}
-
+ ); }; -export const ScaffoldEthAppWithProviders = ({ children }: { children: React.ReactNode }): JSX.Element => { +export const queryClient = new QueryClient({ + defaultOptions: { + queries: { + refetchOnWindowFocus: false, + }, + }, +}); + +export const ScaffoldEthAppWithProviders = ({ children }: { children: React.ReactNode }) => { + const { resolvedTheme } = useTheme(); + const isDarkMode = resolvedTheme === "dark"; const [mounted, setMounted] = useState(false); - const [error, setError] = useState(null); useEffect(() => { - console.log('ScaffoldEthAppWithProviders mounting...'); - try { - console.log('Initializing minimal setup...'); - setMounted(true); - console.log('Minimal setup complete'); - } catch (err) { - console.error('Error during initialization:', err); - setError(err as Error); - } - return () => { - console.log('ScaffoldEthAppWithProviders unmounting...'); - }; + setMounted(true); }, []); - if (error) { - return ( -
-
-

Initialization Error

-
{error.message}
-
-
- ); - } - - if (!mounted) { - return ( -
-
-
- ); - } - - // Return minimal setup for testing return ( - -
-
- {children} -
-
-
+ + + + + {children} + + + ); }; diff --git a/services/web3/wagmiConfig.ts b/services/web3/wagmiConfig.ts new file mode 100644 index 000000000..0ee88d2f6 --- /dev/null +++ b/services/web3/wagmiConfig.ts @@ -0,0 +1,12 @@ +import { getDefaultConfig } from "@rainbow-me/rainbowkit"; +import { baseSepolia } from "viem/chains"; +import { http } from "wagmi"; + +export const wagmiConfig = getDefaultConfig({ + appName: "MissionEnrollment", + projectId: process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID || "YOUR_PROJECT_ID", + chains: [baseSepolia], + transports: { + [baseSepolia.id]: http("https://sepolia.base.org"), + }, +});