Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: chain modal v2 #1709

Closed
wants to merge 2 commits into from
Closed

feat: chain modal v2 #1709

wants to merge 2 commits into from

Conversation

magiziz
Copy link
Contributor

@magiziz magiziz commented Jan 16, 2024

Changes

  • Now you can choose any chains even if your wallet is not connected.
  • Works with siwe.
  • During connection process, it automatically selects the chain you picked earlier. Or the one you set as your default initialChain instead.
  • If you've set initialChain, the option to change networks will be hidden to prevent accidental switches.

Screen recordings / screenshots

chain-modal-v2.mov

What to test

  1. Try switching chains without connecting your wallet to see if it works.
  2. While connecting your wallet, confirm it connects to the chain you chose.
  3. Set initialChain and check if the chain button is no longer visible.
  4. Make sure everything works well with siwe. Test this connecting to your wallet first and then you should see chain button dissapear. This prevents users from switching chains with their connected wallet when they are not signed in yet.

Copy link

vercel bot commented Jan 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rainbowkit-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 22, 2024 10:51pm
rainbowkit-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 22, 2024 10:51pm

@oxSaturn
Copy link

This is awesome to have. Another feature I'd like to have is the ability to pass a initialChain from url. For example, if I had a site with base, fantom supported, and base is the default connected chain. But I'd like to share a url to fantom user. Currently I have to implement it myself with something like ?chain=fantom, and pass fantom to initialChain when chain query founded in url. Just not sure if it belongs to rainbowkit or not.

@0xartcro
Copy link
Contributor

Thank you, great addition to RainbowKit!

@magiziz
Copy link
Contributor Author

magiziz commented Jan 17, 2024

@0xartcro We can probably add an extra prop that says initalChainFromUrl and we can look for the chain query like you said and check whether the chain is available or not.

Comment on lines 103 to +107
openChainModal:
connectionStatus === 'connected' ? openChainModal : undefined,
connectionStatus === 'connected' ||
connectionStatus === 'disconnected'
? openChainModal
: undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep it simple we don't want to open chain modal if the connection status is either loading or unauthenticated. This is primarily used for our authentication provider.

  • loading = fetching user

  • unauthenticated = when the user has connected their wallet, but hasn't signed in

  • connected = if user is logged in via siwe provider or has connected their wallet without using siwe auth provider

  • disconnected = if user's wallet is disconnected

@@ -133,7 +136,7 @@ export function ConnectButtonRenderer({
iconUrl: resolvedChainIconUrl,
id: chainId,
name: chainName,
unsupported: !isCurrentChainSupported,
unsupported: isConnected && !isCurrentChainSupported,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only show unsupported if a user is connected and if the chain is not supported

@akshatmittal
Copy link

Finally! Been asking for this for so long, ha! Looking forward to it!

Q: Will this retain the functionality to programmatically switch chains even if the users aren't connected? (if not, consider it a feature request!)

@@ -287,6 +289,7 @@ function RainbowKitApp({
...demoAppInfo,
...(showDisclaimer && { disclaimer: DisclaimerDemo }),
}}
ignoreChainModalOnConnect={ignoreChainModalOnConnect}
Copy link
Contributor Author

@magiziz magiziz Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If user doesn't want to have the chain modal before connection then they can provide ignoreChainModalOnConnect prop. This will sometimes help the UX since otherwise wallets have to connect + switch to the desired chain that they've choosen.

Some people are just interested to have the connect modal. This will prevent the switch chain prompt during wallet connection.

@Morgosh
Copy link

Morgosh commented Feb 8, 2024

So can this be merged so I can see whether it fixes the no chains issue? @kosmoskey

@shivam0x
Copy link

When is this expected to merge? We are planning to migrate to RainbowKit but waiting for this PR to be merged as this is open since long time now.

@magiziz
Copy link
Contributor Author

magiziz commented Feb 15, 2024

@Morgosh @ShivamDev31 This will be merged soon. We wanted to introduce less UI changes first during RainbowKit 2.0, but we will prioritise this.

@akshatmittal
Copy link

I have to ask, what happened to this? I'm very much looking forward to this @DanielSinclair.

@0xartcro
Copy link
Contributor

I have to ask, what happened to this? I'm very much looking forward to this @DanielSinclair.

Might be just auto-closed because beta branch was deleted? Weird though that it didn't automatically change destination branch 👀

@kosmoskey is it still planned to be merged?

@magiziz
Copy link
Contributor Author

magiziz commented Feb 22, 2024

@0xartcro Yes srry we will raise another PR to main branch. Please bear with us 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug]Active chain is not changed when changed to an unsupported chain
7 participants