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,6 +1,15 @@ // @flow -import { configureChains, createClient } from 'wagmi'; +import { connectorsForWallets } from '@rainbow-me/rainbowkit'; +import { + injectedWallet, + metaMaskWallet, + rainbowWallet, + walletConnectWallet, + // eslint-disable-next-line import/extensions +} from '@rainbow-me/rainbowkit/wallets'; +import * as React from 'react'; +import { configureChains, createClient, useProvider } from 'wagmi'; // eslint-disable-next-line import/extensions import { mainnet } from 'wagmi/chains'; // eslint-disable-next-line import/extensions @@ -8,6 +17,8 @@ // eslint-disable-next-line import/extensions import { publicProvider } from 'wagmi/providers/public'; +import { ENSCacheProvider } from '../components/ens-cache-provider.react.js'; + // details can be found at https://wagmi.sh/core/providers/configuring-chains type WagmiChainConfiguration = { @@ -35,4 +46,36 @@ }); } -export { configureWagmiChains, createWagmiClient }; +const { chains, provider } = configureWagmiChains(process.env.COMM_ALCHEMY_KEY); +const connectors = connectorsForWallets([ + { + groupName: 'Recommended', + wallets: [ + injectedWallet({ chains }), + rainbowWallet({ chains }), + metaMaskWallet({ chains }), + walletConnectWallet({ 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 { + configureWagmiChains, + createWagmiClient, + wagmiClient, + wagmiChains, + WagmiENSCacheProvider, +}; 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.js'; import type { Dispatch } from 'lib/types/redux-types.js'; import { registerConfig } from 'lib/utils/config.js'; +import { WagmiENSCacheProvider, wagmiClient } from 'lib/utils/wagmi-utils.js'; import AppsDirectory from './apps/apps-directory.react.js'; import Calendar from './calendar/calendar.react.js'; @@ -59,7 +60,6 @@ import getTitle from './title/getTitle.js'; import { type NavInfo } from './types/nav-types.js'; import { canonicalURLFromReduxState, navInfoFromURL } from './url-utils.js'; -import { WagmiENSCacheProvider, wagmiClient } from './utils/wagmi-utils.js'; // 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,9 +4,10 @@ import _merge from 'lodash/fp/merge.js'; import * as React from 'react'; +import { wagmiChains } from 'lib/utils/wagmi-utils.js'; + import css from './splash.css'; import LoginForm from '../account/log-in-form.react.js'; -import { wagmiChains } from '../utils/wagmi-utils.js'; function Splash(): React.Node { const rainbowKitTheme = React.useMemo(() => { 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,46 +0,0 @@ -// @flow - -import { connectorsForWallets } from '@rainbow-me/rainbowkit'; -import { - injectedWallet, - rainbowWallet, - metaMaskWallet, - walletConnectWallet, - // eslint-disable-next-line import/extensions -} from '@rainbow-me/rainbowkit/wallets'; -import * as React from 'react'; -import { useProvider } from 'wagmi'; - -import { ENSCacheProvider } from 'lib/components/ens-cache-provider.react.js'; -import { - configureWagmiChains, - createWagmiClient, -} from 'lib/utils/wagmi-utils.js'; - -const { chains, provider } = configureWagmiChains(process.env.COMM_ALCHEMY_KEY); -const connectors = connectorsForWallets([ - { - groupName: 'Recommended', - wallets: [ - injectedWallet({ chains }), - rainbowWallet({ chains }), - metaMaskWallet({ chains }), - walletConnectWallet({ 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 };