Skip to content

Commit

Permalink
feat : updated wagmi and provider
Browse files Browse the repository at this point in the history
  • Loading branch information
surajhub255 committed Oct 12, 2024
1 parent 6e4fe91 commit 435f4c4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
34 changes: 15 additions & 19 deletions src/lib/providers.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<WagmiProvider config={config} initialState={initialState}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
<QueryClientProvider client={queryClient}>
{children}
</QueryClientProvider>
</WagmiProvider>
)
}
}
21 changes: 12 additions & 9 deletions src/lib/wagmi.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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
})
});
})

0 comments on commit 435f4c4

Please sign in to comment.