diff --git a/lib/utils/wagmi-utils.js b/lib/utils/wagmi-utils.js --- a/lib/utils/wagmi-utils.js +++ b/lib/utils/wagmi-utils.js @@ -1,9 +1,13 @@ // @flow -import { chain, configureChains, createClient } from 'wagmi'; +import { connectorsForWallets, wallet } from '@rainbow-me/rainbowkit'; +import * as React from 'react'; +import { chain, configureChains, createClient, useProvider } from 'wagmi'; import { alchemyProvider } from 'wagmi/providers/alchemy'; import { publicProvider } from 'wagmi/providers/public'; +import { ENSCacheProvider } from '../components/ens-cache-provider.react'; + // details can be found https://0.6.x.wagmi.sh/docs/providers/configuring-chains type WagmiChainConfiguration = { @@ -34,4 +38,36 @@ }); } -export { configureWagmiChains, createWagmiClient }; +const { chains, provider } = configureWagmiChains(process.env.COMM_ALCHEMY_KEY); +const connectors = connectorsForWallets([ + { + groupName: 'Recommended', + wallets: [ + wallet.injected({ chains }), + wallet.rainbow({ chains }), + wallet.metaMask({ chains }), + wallet.walletConnect({ chains }), + ], + }, +]); +const wagmiClient: mixed = createWagmiClient({ connectors, provider }); +const wagmiChains: mixed = chains; + +type Props = { + +children: React.Node, +}; +function WagmiENSCacheProvider(props: Props): React.Node { + const { children } = props; + const wagmiProvider = useProvider(); + return ( + {children} + ); +} + +export { + wagmiClient, + wagmiChains, + WagmiENSCacheProvider, + configureWagmiChains, + createWagmiClient, +}; diff --git a/web/app.react.js b/web/app.react.js --- a/web/app.react.js +++ b/web/app.react.js @@ -28,6 +28,7 @@ import type { LoadingStatus } from 'lib/types/loading-types'; import type { Dispatch } from 'lib/types/redux-types'; import { registerConfig } from 'lib/utils/config'; +import { WagmiENSCacheProvider, wagmiClient } from 'lib/utils/wagmi-utils'; import AppsDirectory from './apps/apps-directory.react'; import Calendar from './calendar/calendar.react'; @@ -57,7 +58,6 @@ import getTitle from './title/getTitle'; import { type NavInfo } from './types/nav-types'; import { canonicalURLFromReduxState, navInfoFromURL } from './url-utils'; -import { WagmiENSCacheProvider, wagmiClient } from './utils/wagmi-utils'; // We want Webpack's css-loader and style-loader to handle the Fontawesome CSS, // so we disable the autoAddCss logic and import the CSS file. Otherwise every diff --git a/web/splash/splash.react.js b/web/splash/splash.react.js --- a/web/splash/splash.react.js +++ b/web/splash/splash.react.js @@ -4,8 +4,9 @@ import _merge from 'lodash/fp/merge'; import * as React from 'react'; +import { wagmiChains } from 'lib/utils/wagmi-utils.js'; + import LoginForm from '../account/log-in-form.react'; -import { wagmiChains } from '../utils/wagmi-utils.js'; import css from './splash.css'; function Splash(): React.Node { diff --git a/web/utils/wagmi-utils.js b/web/utils/wagmi-utils.js deleted file mode 100644 --- a/web/utils/wagmi-utils.js +++ /dev/null @@ -1,36 +0,0 @@ -// @flow - -import { connectorsForWallets, wallet } from '@rainbow-me/rainbowkit'; -import * as React from 'react'; -import { useProvider } from 'wagmi'; - -import { ENSCacheProvider } from 'lib/components/ens-cache-provider.react'; -import { configureWagmiChains, createWagmiClient } from 'lib/utils/wagmi-utils'; - -const { chains, provider } = configureWagmiChains(process.env.COMM_ALCHEMY_KEY); -const connectors = connectorsForWallets([ - { - groupName: 'Recommended', - wallets: [ - wallet.injected({ chains }), - wallet.rainbow({ chains }), - wallet.metaMask({ chains }), - wallet.walletConnect({ chains }), - ], - }, -]); -const wagmiClient: mixed = createWagmiClient({ connectors, provider }); -const wagmiChains: mixed = chains; - -type Props = { - +children: React.Node, -}; -function WagmiENSCacheProvider(props: Props): React.Node { - const { children } = props; - const wagmiProvider = useProvider(); - return ( - {children} - ); -} - -export { wagmiClient, wagmiChains, WagmiENSCacheProvider };