-
-
Save Daltonic/88476a8b642f0d1f879644ce7521e735 to your computer and use it in GitHub Desktop.
Dapp Funds
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
'use client' | |
import * as React from 'react' | |
import { | |
GetSiweMessageOptions, | |
RainbowKitSiweNextAuthProvider, | |
} from '@rainbow-me/rainbowkit-siwe-next-auth' | |
import { WagmiConfig, configureChains, createConfig } from 'wagmi' | |
import { Chain, RainbowKitProvider, connectorsForWallets, darkTheme } from '@rainbow-me/rainbowkit' | |
import { | |
metaMaskWallet, | |
trustWallet, | |
coinbaseWallet, | |
rainbowWallet, | |
} from '@rainbow-me/rainbowkit/wallets' | |
import { mainnet, hardhat } from 'wagmi/chains' | |
import { alchemyProvider } from 'wagmi/providers/alchemy' | |
import { publicProvider } from 'wagmi/providers/public' | |
import { Session } from 'next-auth' | |
import { SessionProvider } from 'next-auth/react' | |
const bitfinity: Chain = { | |
id: 355113, | |
name: 'Bitfinity', | |
network: 'bitfinity', | |
iconUrl: 'https://bitfinity.network/logo.png', | |
iconBackground: '#000000', | |
nativeCurrency: { | |
decimals: 18, | |
name: 'Bitfinity', | |
symbol: 'BFT', | |
}, | |
rpcUrls: { | |
public: { http: ['https://testnet.bitfinity.network'] }, | |
default: { http: ['https://testnet.bitfinity.network'] }, | |
}, | |
blockExplorers: { | |
default: { name: 'Bitfinity Block Explorer', url: 'https://explorer.bitfinity.network/' }, | |
etherscan: { name: 'Bitfinity Block Explorer', url: 'https://explorer.bitfinity.network/' }, | |
}, | |
testnet: true, | |
} | |
const { chains, publicClient } = configureChains( | |
[mainnet, bitfinity, hardhat], | |
[alchemyProvider({ apiKey: process.env.NEXT_PUBLIC_ALCHEMY_ID as string }), publicProvider()] | |
) | |
const projectId = process.env.NEXT_PUBLIC_PROJECT_ID as string | |
const connectors = connectorsForWallets([ | |
{ | |
groupName: 'Recommended', | |
wallets: [ | |
metaMaskWallet({ projectId, chains }), | |
trustWallet({ projectId, chains }), | |
coinbaseWallet({ appName: 'Coinbase', chains }), | |
rainbowWallet({ projectId, chains }), | |
], | |
}, | |
]) | |
const wagmiConfig = createConfig({ | |
autoConnect: true, | |
connectors, | |
publicClient, | |
}) | |
const demoAppInfo = { | |
appName: 'Dapp Funds dApp', | |
} | |
const getSiweMessageOptions: GetSiweMessageOptions = () => ({ | |
statement: ` | |
Once you're signed in, you'll be able to access all of our dApp's features. | |
Thank you for partnering with CrowdFunding!`, | |
}) | |
export function Providers({ | |
children, | |
pageProps, | |
}: { | |
children: React.ReactNode | |
pageProps: { | |
session: Session | |
} | |
}) { | |
const [mounted, setMounted] = React.useState(false) | |
React.useEffect(() => setMounted(true), []) | |
return ( | |
<WagmiConfig config={wagmiConfig}> | |
<SessionProvider refetchInterval={0} session={pageProps.session}> | |
<RainbowKitSiweNextAuthProvider getSiweMessageOptions={getSiweMessageOptions}> | |
<RainbowKitProvider theme={darkTheme()} chains={chains} appInfo={demoAppInfo}> | |
{mounted && children} | |
</RainbowKitProvider> | |
</RainbowKitSiweNextAuthProvider> | |
</SessionProvider> | |
</WagmiConfig> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment