diff --git a/src/lib/providers.tsx b/src/lib/providers.tsx index 69e7ce8..4da2db2 100644 --- a/src/lib/providers.tsx +++ b/src/lib/providers.tsx @@ -1,41 +1,37 @@ 'use client' import React, { ReactNode } from 'react' - - import { createWeb3Modal } from '@web3modal/wagmi/react' - import { QueryClient, QueryClientProvider } from '@tanstack/react-query' - import { State, WagmiProvider } from 'wagmi' -import { config } from './wagmi' - +import { config, projectId } from './wagmi' -// Setup queryClient +// Initialize React Query Client const queryClient = new QueryClient() -const projectId = "c26b357532f63f7ba31efebac88d0eed"; - -if (!projectId) throw new Error('Wallet Connect Project ID is not defined') +if (!projectId) { + throw new Error('Wallet Connect Project ID is not defined') +} -// Create modal +// Initialize Web3Modal createWeb3Modal({ wagmiConfig: config, projectId, enableAnalytics: true, // Optional - defaults to your Cloud configuration - enableOnramp: true // Optional - false as default + enableOnramp: true // Optional - false by default }) -export default function AppKitProvider({ - children, - initialState -}: { +interface AppKitProviderProps { children: ReactNode initialState?: State -}) { +} + +export default function AppKitProvider({ children, initialState }: AppKitProviderProps) { return ( - {children} + + {children} + ) -} +} \ No newline at end of file diff --git a/src/lib/wagmi.ts b/src/lib/wagmi.ts index 1371485..8f84211 100644 --- a/src/lib/wagmi.ts +++ b/src/lib/wagmi.ts @@ -1,12 +1,13 @@ import { defaultWagmiConfig } from '@web3modal/wagmi/react/config' - -import { cookieStorage, createStorage } from 'wagmi' +import { createStorage, cookieStorage } from 'wagmi' import { base } from 'wagmi/chains' -// Get projectId from https://cloud.walletconnect.com -export const projectId = "c26b357532f63f7ba31efebac88d0eed" +// Get projectId from environment variables +export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID -if (!projectId) throw new Error('Project ID is not defined') +if (!projectId) { + throw new Error('Project ID is not defined') +} export const metadata = { name: 'Myriadflow', @@ -15,20 +16,22 @@ export const metadata = { icons: ['https://avatars.githubusercontent.com/u/37784886'] } -// Create wagmiConfig +// Define supported chains const chains = [base] as const + +// Create Wagmi configuration export const config = defaultWagmiConfig({ chains, projectId, metadata, auth: { email: true, - socials: ["github", "google", "x", "discord", "apple"], - showWallets: true, // default to true + socials: ['github', 'google', 'x', 'discord', 'apple'], + showWallets: true, // Defaults to true walletFeatures: true }, ssr: true, storage: createStorage({ storage: cookieStorage }) -}); +}) \ No newline at end of file