wagmi icon indicating copy to clipboard operation
wagmi copied to clipboard

switch chain on connect in walletconnect connector

Open frolic opened this issue 7 months ago • 3 comments

I noticed that connecting Rainbow wallet app via WalletConnect would fail for my local app when attempting to use the connected account, because Rainbow doesn't support adding networks. This appears to happen because the walletConnect connector calls switchChain inside getProvider, whereas other connectors appear to do their chain check and switchChain call inside of connect: https://github.com/wevm/wagmi/blob/f5b717ccf8a5b283263cadc984ba00b354bcefae/packages/core/src/connectors/injected.ts#L174 https://github.com/wevm/wagmi/blob/f5b717ccf8a5b283263cadc984ba00b354bcefae/packages/connectors/src/coinbaseWallet.ts#L132 https://github.com/wevm/wagmi/blob/f5b717ccf8a5b283263cadc984ba00b354bcefae/packages/connectors/src/metaMask.ts#L147

For my app, I've set initialChainId to 0 to kinda bypass the chain switching step here, which works because my app only needs signatures from the connected wallet, regardless of the chain it's connected to.

I'm not really sure how to go about testing this new behavior.

frolic avatar May 29 '25 15:05 frolic

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
wagmi Ready Ready Preview Comment Aug 26, 2025 10:52pm

vercel[bot] avatar May 29 '25 15:05 vercel[bot]

🦋 Changeset detected

Latest commit: c0a91494b30d743f9e67c8844dfa529611e450f0

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

This PR includes changesets to release 3 packages
Name Type
@wagmi/connectors Patch
wagmi Patch
@wagmi/vue 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

changeset-bot[bot] avatar May 29 '25 15:05 changeset-bot[bot]

I forked this connector with these changes and I was able to connect without issues!

frolic avatar May 30 '25 08:05 frolic