Closed mits87 closed 2 months ago
@mits87 Mhmm seems like you're using getDefaultConfig
within the component itself and not defining it outside of the component.
Can you try this code ?
"use client";
import { GetSiweMessageOptions, RainbowKitSiweNextAuthProvider } from "@rainbow-me/rainbowkit-siwe-next-auth";
import {
RainbowKitProvider as BaseRainbowKitProvider,
getDefaultWallets,
getDefaultConfig,
} from "@rainbow-me/rainbowkit";
import { mainnet } from "wagmi/chains";
import { WagmiProvider } from "wagmi";
const { wallets } = getDefaultWallets();
const getSiweMessageOptions: GetSiweMessageOptions = () => ({
statement: process.env.NEXT_PUBLIC_WALLET_SIGN_MESSAGE,
});
const config = getDefaultConfig({
ssr: true,
appName: 'App Name',
projectId: 'WALLET_CONNECT_PROJECT_ID',
chains: [mainnet],
wallets,
});
export default function RainbowKitProvider({ children }: React.PropsWithChildren): React.ReactElement {
return (
<WagmiProvider config={config}>
<RainbowKitSiweNextAuthProvider getSiweMessageOptions={getSiweMessageOptions}>
<BaseRainbowKitProvider modalSize="compact">
{children}
</BaseRainbowKitProvider>
</RainbowKitSiweNextAuthProvider>
</WagmiProvider>
);
}
You can also check out our example dApp here if it helps https://github.com/rainbow-me/rainbowkit/blob/main/examples/with-next/src/pages/_app.tsx
@mits87 Here is an example with app router as well https://github.com/rainbow-me/rainbowkit/blob/main/examples/with-next-app/src/app/providers.tsx
Hi @magiziz yes I tried also as you suggested. For the case when we have only mainnet
or only bsc
we have error as above. But in the other hand if I use other chains for example only arbitrum
then it works.
Also works when I use mainnet
AND arbitrum
. So for me it looks like a bug.
Btw. the example what you provided has more than one chain that's why it works correctly.
@mits87 Can you provide a minimal reproducible example with codesandbox or github repo ? I also realised you didn't add <SessionProvider>
to your <RainbowKitProvider>
component.
@mits87 Any updates ?
Closing this issue for now. Feel free to re-open this if you're still stuck.
Is there an existing issue for this?
RainbowKit Version
2.1.3
wagmi Version
2.10.9
Current Behavior
Currently when I'm creating the RainbowKit configuration like this:
I'm getting an error:
ChainNotConfiguredError: Chain not configured.
When I change my
chains
for example if I replacemainnet
toarbitrum
then everything works as expected.Expected Behavior
Application should NOT crash.
Steps To Reproduce
Just pass only
mainnet
to thechains
or an empty array.Anything else?
Also would be great if you can allow to provide empty array in chains - in that case we should see
Switch Networks
window with message like "No available networks" etc.Currently we can't provide empty array because application crash:
This could help to have better user experience and manage
chains
dynamically