Skip to content

Commit

Permalink
feat : updated provider and wagmi
Browse files Browse the repository at this point in the history
  • Loading branch information
surajhub255 committed Oct 12, 2024
1 parent 872f1a8 commit 9e4389a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
48 changes: 25 additions & 23 deletions src/lib/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
'use client'
import { ReactNode } from 'react'

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
wagmiConfig: config,
projectId,
enableAnalytics: true, // Optional - defaults to your Cloud configuration
enableOnramp: true // Optional - false by default
})

export default function AppKitProvider({
children,
initialState,
}: {
children: ReactNode
initialState?: State
}) {
return (
<WagmiProvider config={config} initialState={initialState}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</WagmiProvider>
)
interface AppKitProviderProps {
children: ReactNode
initialState?: State
}

export default function AppKitProvider({ children, initialState }: AppKitProviderProps) {
return (
<WagmiProvider config={config} initialState={initialState}>
<QueryClientProvider client={queryClient}>
{children}
</QueryClientProvider>
</WagmiProvider>
)
}
34 changes: 18 additions & 16 deletions src/lib/wagmi.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
"use client";
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: 'AppKit',
description: 'AppKit Example',
url: 'https://web3modal.com', // origin must match your domain & subdomain
icons: ['https://avatars.githubusercontent.com/u/37784886']
}
export const metadata = {
name: 'Myriadflow',
description: 'Myriadflow',
url: 'https://webxr.myriadflow.com', // Origin must match your domain & subdomain
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 9e4389a

Please sign in to comment.