-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f942ce
commit 2cbd550
Showing
12 changed files
with
315 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
import './globals.css' | ||
import type { Metadata } from 'next' | ||
import { Inter } from 'next/font/google' | ||
import { headers } from 'next/headers' | ||
|
||
import { Web3Modal } from '@/context/Web3Modal' | ||
import './globals.css' | ||
import { cookieToInitialState } from 'wagmi' | ||
import { wagmiConfig } from '@/context/wagmiConfig' | ||
import { headers } from 'next/headers' | ||
import ContextProvider from '@/context' | ||
import { config } from '@/config' | ||
|
||
const inter = Inter({ subsets: ['latin'] }) | ||
|
||
export const metadata: Metadata = { | ||
title: 'Create Next App', | ||
description: 'Generated by create next app', | ||
title: 'Create Next App', | ||
description: 'Generated by create next app' | ||
} | ||
|
||
interface Props { | ||
export default function RootLayout({ | ||
children | ||
}: Readonly<{ | ||
children: React.ReactNode | ||
} | ||
|
||
export default async function RootLayout({ children }: Props) { | ||
const initialState = cookieToInitialState( | ||
wagmiConfig, | ||
headers().get('cookie') | ||
}>) { | ||
const initialState = cookieToInitialState(config, headers().get('cookie')) | ||
return ( | ||
<html lang="en"> | ||
<body className={inter.className}> | ||
<ContextProvider initialState={initialState}>{children}</ContextProvider> | ||
</body> | ||
</html> | ||
) | ||
return ( | ||
<html lang="en"> | ||
<body className={inter.className}> | ||
<Web3Modal initialState={initialState} >{children}</Web3Modal> | ||
</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import Connect from '@/components/Connect' | ||
import styles from './page.module.css' | ||
|
||
export default function Home() { | ||
return ( | ||
<main className={styles.main}> | ||
<w3m-button /> | ||
</main> | ||
) | ||
return ( | ||
<main className={styles.main}> | ||
<Connect /> | ||
</main> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use client' | ||
|
||
export default function Connect() { | ||
return <w3m-button /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { defaultWagmiConfig } from '@web3modal/wagmi/react/config' | ||
import { cookieStorage, createStorage } from 'wagmi' | ||
import { mainnet, sepolia } from 'wagmi/chains' | ||
|
||
export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID | ||
|
||
if (!projectId) throw new Error('Project ID is not defined') | ||
|
||
export const config = defaultWagmiConfig({ | ||
projectId, | ||
chains: [mainnet, sepolia], | ||
metadata: { | ||
name: 'My App', | ||
description: 'My app description', | ||
url: 'https://myapp.com', | ||
icons: ['https://myapp.com/favicon.ico'] | ||
}, | ||
storage: createStorage({ | ||
storage: cookieStorage | ||
}), | ||
ssr: true | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use client' | ||
|
||
import { config, projectId } from '@/config' | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import { createWeb3Modal } from '@web3modal/wagmi/react' | ||
import React, { ReactNode } from 'react' | ||
import { State, WagmiProvider } from 'wagmi' | ||
|
||
const queryClient = new QueryClient() | ||
|
||
if (!projectId) throw new Error('Project ID is not defined') | ||
|
||
createWeb3Modal({ | ||
wagmiConfig: config, | ||
projectId | ||
}) | ||
|
||
function ContextProvider({ | ||
children, | ||
initialState | ||
}: { | ||
children: ReactNode | ||
initialState: State | undefined | ||
}) { | ||
return ( | ||
<WagmiProvider config={config} initialState={initialState}> | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
</WagmiProvider> | ||
) | ||
} | ||
|
||
export default ContextProvider |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.