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

fix(clerk-js): Always invoke an injected Web3 Wallet provider #4734

Merged

Conversation

chanioxaris
Copy link
Member

Description

If we weren't able to find the exact requested Web3 Wallet provider, then we should fallback and use the injected provider in order for the user to be able to continue the flow

Before

before.mov

After

after.mov

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Copy link

changeset-bot bot commented Dec 9, 2024

🦋 Changeset detected

Latest commit: e1ae09e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Dec 9, 2024

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

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 10:52am

Comment on lines 56 to 64
const ethProvider = this.#providers.find(p => p.info.name === this.#providerIdMap[provider])?.provider;
if (ethProvider !== undefined) {
return ethProvider;
}
return this.#providers.find(p => p.info.name === this.#providerIdMap[provider])?.provider;

// In case we weren't able to find the requested provider, fallback to the
// global injected provider instead, if any, to allow the user to continue
// the flow rather than be a no-op
return window.ethereum;
Copy link
Member

Choose a reason for hiding this comment

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

  1. Maybe i'm mistaken, but i think we were doing this and we removed it.
  2. Is there a scenario where if want to request with metamask but the browser does not have it i should throw an error instead ? If yes, maybe the fallback needs to happen at the component level.

Copy link
Member Author

@chanioxaris chanioxaris Dec 9, 2024

Choose a reason for hiding this comment

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

  1. That's not what we were doing before. We were explicitly trying to find the requested provider (e.g. MetaMask, OKX Wallet etc) and if we couldn't, we weren't initiated the flow, giving the user the impression that the application is broken. If you mean even before the injected web3 provider logic, that was needed in order to avoid multiple web3 wallets to conflict
  2. Maybe we are looking to throw an error if there isn't a web3 provider available, but we are looking to investigate that in a different effort

.changeset/nine-penguins-grab.md Outdated Show resolved Hide resolved
When the requested Web3 provider cannot be found, use any other available injected
Web3 Wallet provider, instead of blocking the sign-in/sign-up flow
@chanioxaris chanioxaris force-pushed the haris/user-1133-always-invoke-an-injected-web3-wallet branch from 78283ea to e1ae09e Compare December 10, 2024 10:50
@chanioxaris chanioxaris merged commit 80f2402 into main Dec 10, 2024
28 checks passed
@chanioxaris chanioxaris deleted the haris/user-1133-always-invoke-an-injected-web3-wallet branch December 10, 2024 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants