fix(walletconnect): advertise the required chain in optionalNamespaces - #12540
Merged
Conversation
Some wallets resolve their currently selected network against optionalNamespaces and reject the whole session with UNSUPPORTED_CHAINS (5100) when it isn't listed there, ignoring requiredNamespaces entirely. eip155:1 was only ever sent as a required chain, never an optional one, so Bridge Wallet users sitting on Ethereum could not pair at all, while every other network connected fine. Sending the required chain in both namespaces keeps those wallets connectable. requiredNamespaces is unchanged, so the session still defaults to mainnet for conformant wallets. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
📝 WalkthroughWalkthroughWalletConnect V2 now includes both required and optional chain IDs in ChangesWalletConnect chain advertisement
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Bridge Wallet could not pair over WalletConnect whenever its selected network was Ethereum. It rejected the session proposal with
UNSUPPORTED_CHAINS(code 5100) and showed "The chain Ethereum is not supported", while the same wallet on any other network paired fine.Root cause is in what we advertise.
eip155:1was sent only as a required chain:requiredNamespaces: { eip155: { chains: ["eip155:1"], ... } } optionalNamespaces: { eip155: { chains: ["eip155:10","eip155:56","eip155:100", ...] } } // no eip155:1Bridge Wallet resolves its selected network against
optionalNamespaces, doesn't findeip155:1there, and rejects the entire session — ignoringrequiredNamespaces. That is non-conformant on their side (optionalNamespacesexists so wallets can ignore what they don't support), but it's cheap for us to accommodate, and@walletconnect/ethereum-provideralready mirrors required chains into optional under some configurations.Confirmed by bisecting the advertised chain list against a real device:
bip122eip155:1The fix sends the required chain in both namespaces.
chains(and thereforerequiredNamespaces) is untouched, sosetChainIds()still pins the session to mainnet and behaviour for conformant wallets is unchanged.Issue (if applicable)
closes #12531
Closes SS-5720 — Trying to connect to bridge wallet via wallet connect on eth network
Risk
Low.
Scope is a single field in the WalletConnect session proposal — it widens what we advertise as acceptable, without changing what we require or what we default to. No transaction construction, signing, or broadcast path is touched.
WalletConnect v2 pairing only. Every WalletConnect wallet sees
eip155:1added to the optional chain list;@walletconnect/ethereum-providerde-dupes it vianew Set, and the resulting proposal is the same shape the SDK produces natively when itsmflag is set. No effect on injected wallets, Ledger, KeepKey, or native.Testing
Engineering
pnpm dev:weband open the WalletConnect connect flow.logger: 'debug'towalletConnectV2ProviderConfig.optionalNamespaces.eip155.chainsshould now lead witheip155:1followed by the other 12;requiredNamespacesshould be unchanged at["eip155:1"].patchSignerForNonEvmNamespacesstill graftsbip122onto the proposal, so a wallet supporting BTC over WalletConnect should still expose it (_supportsBTC).Operations
Not behind a flag — user-facing.
Screenshots (if applicable)
n/a
Follow-ups (not in this PR)
Found while investigating, deliberately left out to keep this surgical:
packages/hdwallet-walletconnectv2/src/adapter.ts:41logs'Could not pair WalletConnectV2'without the error object, anduseWalletConnectV2Pairing.ts:63-66flattens everything to a generic i18n string with no logging. The wallet's actual rejection reason never reaches the console, which is what made this bug hard to diagnose.rpcMapentry.eip155:1329is advertised inoptionalChainsbut has no URL inrpcMap— the only advertised chain in that state.ethVerifyMessageis not a JSON-RPC method. It appears inoptionalMethodsbut is hdwallet-core's local message-verification API, not something any wallet implements over the wire.