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

refactor: wallets #1869

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

refactor: wallets #1869

wants to merge 7 commits into from

Conversation

magiziz
Copy link
Contributor

@magiziz magiziz commented Mar 18, 2024

Changes

  • Refactored and improved wallets for much easier implementation

What to test

  1. Make sure the wallet behaviours work exactly the same as it does now
  2. Test WalletConnect wallets and injected wallets
  3. Test on mobile and desktop

@magiziz magiziz requested a review from a team as a code owner March 18, 2024 16:18
Copy link

vercel bot commented Mar 18, 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 Apr 7, 2024 6:25am
rainbowkit-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 7, 2024 6:25am

Comment on lines +100 to +102
id,
name,
provider,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those return types are required in wagmi. Reference to the docs here.

Copy link
Contributor

@DanielSinclair DanielSinclair left a comment

Choose a reason for hiding this comment

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

Seeing a new test error appear here after resolving the merge conflicts. I think it is related to either #1911 or #1913

id: 'rainbow',
name: 'Rainbow',
flag: 'isRainbow',
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

What are id and name used for here? Is there a way for us to prevent needing to implement id and name twice within the wallet connector?

Copy link
Contributor

Choose a reason for hiding this comment

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

Because we call createConnector, shouldn't we be able to pass in id at connect time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mhmm good point. We could, but then we would have to do something similar to what we do with mockWallet here which would add more logic on top. When doing createConnector we're creating a brand new connector, but don't append the id's to our created connectors like injected(), walletConnect(), safe() and etc (since they are in a created mode).

We could maybe generate random uuid's, but not sure if that would cause problems.

@@ -44,6 +44,8 @@ export const ramperWallet = (): Wallet => {
},
},
createConnector: getInjectedConnector({
id: 'ramper',
name: 'Ramper Wallet',
namespace: 'ramper2.provider',
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise, should we be moving namespace to the top-level wallet connector, instead of implementing it here? getInjectedConnector was previously a bit more of a simple util, and the added complexity might require a more in-depth refactor

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to refactor much of the code in the walletListItems for loop, as the spread operators and var naming is getting tough to understand. Need comments here too. Rewinding back to v1, it was a bit easier to read and had comments: https://github.com/rainbow-me/rainbowkit/blob/42b0661e622ba99ec98cdb0219431f90ca45d40d/packages/rainbowkit/src/wallets/connectorsForWallets.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored 🙏

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] connect modal not showing custom wallet button
2 participants