diff --git a/.changeset/nine-penguins-grab.md b/.changeset/nine-penguins-grab.md new file mode 100644 index 00000000000..f1659583319 --- /dev/null +++ b/.changeset/nine-penguins-grab.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Bug fix: 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. diff --git a/packages/clerk-js/src/utils/injectedWeb3Providers.ts b/packages/clerk-js/src/utils/injectedWeb3Providers.ts index cd91072a55e..f61b113d34d 100644 --- a/packages/clerk-js/src/utils/injectedWeb3Providers.ts +++ b/packages/clerk-js/src/utils/injectedWeb3Providers.ts @@ -53,13 +53,15 @@ class InjectedWeb3Providers { } get = (provider: InjectedWeb3Provider) => { - // In case there is a single injected provider, use that directly. - // This is needed in order to support other compatible Web3 Wallets (e.g. Rabby Wallet) - // and maintain the previous behavior - if (this.#providers.length === 1) { - return this.#providers[0].provider; + 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 blocking it + return window.ethereum; }; #onAnnouncement = (event: EIP6963AnnounceProviderEvent) => {