Last active
November 18, 2022 13:12
-
-
Save shakogegia/29de2156bbcabc39ad798a256f8c4043 to your computer and use it in GitHub Desktop.
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
import { connectorsForWallets, RainbowKitProvider } from '@rainbow-me/rainbowkit'; | |
import '@rainbow-me/rainbowkit/styles.css'; | |
import { braveWallet, coinbaseWallet, injectedWallet, metaMaskWallet } from '@rainbow-me/rainbowkit/wallets'; | |
import { useMemo } from 'react'; | |
import { chain, configureChains, createClient, WagmiConfig } from 'wagmi'; | |
import { alchemyProvider } from 'wagmi/providers/alchemy'; | |
import { publicProvider } from 'wagmi/providers/public'; | |
const { chains, provider, webSocketProvider } = configureChains( | |
[ | |
...(process.env.NEXT_PUBLIC_ENABLE_TESTNETS === 'true' | |
? [chain.goerli] | |
: [chain.mainnet]), | |
], | |
[ | |
...(process.env.NEXT_PUBLIC_ENABLE_GANACHE === 'true' | |
? [publicProvider()] | |
: [alchemyProvider({ apiKey: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY })]), | |
], | |
) | |
const connectors = connectorsForWallets([ | |
{ | |
groupName: 'Recommended', | |
wallets: [ | |
metaMaskWallet({ chains }), | |
coinbaseWallet({ chains }), | |
braveWallet({ chains }), | |
injectedWallet({ chains }), | |
], | |
}, | |
]); | |
export default function Wagmi({ children }) { | |
const wagmiClient = useMemo(() => { | |
return createClient({ | |
autoConnect: true, | |
connectors, | |
provider, | |
webSocketProvider, | |
}) | |
}, [autoConnect]) | |
return ( | |
<WagmiConfig client={wagmiClient}> | |
<RainbowKitProvider chains={chains}>{children}</RainbowKitProvider> | |
</WagmiConfig> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment