Skip to content

Commit

Permalink
Merge pull request #2 from MyriadFlow/ui
Browse files Browse the repository at this point in the history
changed connect button in the navbar
  • Loading branch information
adetyaz authored Jun 22, 2024
2 parents 14aaeb2 + dd77f90 commit cc5f843
Show file tree
Hide file tree
Showing 7 changed files with 14,128 additions and 97 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@readyplayerme/visage": "^5.2.1",
"@tanstack/react-query": "^5.45.1",
"@uploadthing/react": "^6.6.0",
"@web3modal/wagmi": "^5.0.3",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"lucide-react": "^0.394.0",
Expand All @@ -40,8 +41,8 @@
"tailwindcss-animate": "^1.0.7",
"three": "^0.165.0",
"uploadthing": "^6.12.0",
"viem": "^2.15.1",
"wagmi": "^2.10.2",
"viem": "^2.16.1",
"wagmi": "^2.10.4",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
14,057 changes: 14,057 additions & 0 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import './globals.css'
import 'react-toastify/dist/ReactToastify.css'

import { cn } from '@/lib/utils'
import { Providers } from '@/lib/providers'

import { headers } from 'next/headers'

import { cookieToInitialState } from 'wagmi'
import Providers from '@/lib/providers'
import Web3ModalProvider from '@/lib/providers'
import { config } from '@/lib/wagmi'


const fontSans = FontSans({
subsets: ['latin'],
Expand All @@ -21,6 +28,7 @@ export default function RootLayout({
}: Readonly<{
children: React.ReactNode
}>) {
const initialState = cookieToInitialState(config, headers().get('cookie'))
return (
<html lang='en' suppressHydrationWarning>
<Providers>
Expand All @@ -30,7 +38,7 @@ export default function RootLayout({
fontSans.variable
)}
>
{children}
<Web3ModalProvider initialState={initialState}>{children}</Web3ModalProvider>
</body>
</Providers>
</html>
Expand Down
60 changes: 0 additions & 60 deletions src/components/ui/create-wallet.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/ui/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { Logo } from './logo'
import { Button } from './button'
import Link from 'next/link'
import { CreateWallet } from './create-wallet'


export const Navbar = () => {
type NavLink = {
Expand Down Expand Up @@ -45,7 +45,7 @@ export const Navbar = () => {
{/* <Button className='connect-button rounded-full hover:text-white'>
Connect Wallet
</Button> */}
<CreateWallet />
<w3m-button />
</NavigationMenuList>
</NavigationMenu>
)
Expand Down
44 changes: 32 additions & 12 deletions src/lib/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
'use client'

import React, { ReactNode } from 'react'


import { createWeb3Modal } from '@web3modal/wagmi/react'

import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { useState, type ReactNode } from 'react'
import { WagmiProvider } from 'wagmi'

import { config } from './wagmi'
import { State, WagmiProvider } from 'wagmi'
import { config, projectId } from './wagmi'


// Setup queryClient
const queryClient = new QueryClient()

if (!projectId) throw new Error('Wallet Connect Project ID is not defined')

export function Providers(props: { children: ReactNode }) {
const [queryClient] = useState(() => new QueryClient())
// Create modal
createWeb3Modal({
wagmiConfig: config,
projectId,
enableAnalytics: true, // Optional - defaults to your Cloud configuration
enableOnramp: true // Optional - false as default
})

return (
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
{props.children}
</QueryClientProvider>
</WagmiProvider>
)
export default function Web3ModalProvider({
children,
initialState
}: {
children: ReactNode
initialState?: State
}) {
return (
<WagmiProvider config={config} initialState={initialState}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</WagmiProvider>
)
}
43 changes: 24 additions & 19 deletions src/lib/wagmi.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import { http, createConfig } from 'wagmi'
import { mainnet, sepolia, baseSepolia } from 'wagmi/chains'
import { coinbaseWallet, injected, walletConnect } from 'wagmi/connectors'
import { defaultWagmiConfig } from '@web3modal/wagmi/react/config'

export const config = createConfig({
chains: [
// mainnet,
import { cookieStorage, createStorage } from 'wagmi'
import { baseSepolia } from 'wagmi/chains'

baseSepolia,
],
connectors: [injected(), coinbaseWallet({ appName: 'Myriadflow' })],
ssr: true,
transports: {
// [mainnet.id]: http(),
[baseSepolia.id]: http(),
},
})
// Get projectId from https://cloud.walletconnect.com
export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID

if (!projectId) throw new Error('Project ID is not defined')

declare module 'wagmi' {
interface Register {
config: typeof config
}
const metadata = {
name: 'Web3Modal',
description: 'Web3Modal Example',
url: 'https://web3modal.com',
icons: ['https://avatars.githubusercontent.com/u/37784886']
}

// Create wagmiConfig
const chains = [baseSepolia] as const
export const config = defaultWagmiConfig({
chains,
projectId,
metadata,
ssr: true,
storage: createStorage({
storage: cookieStorage
}),
})

0 comments on commit cc5f843

Please sign in to comment.