metamask-mobile icon indicating copy to clipboard operation
metamask-mobile copied to clipboard

WalletConnect v2 implementation does not support Optional Namespaces.

Open jxom opened this issue 2 years ago • 12 comments

Describe the bug

MetaMask Mobile's WalletConnect v2 implementation does not support Optional Namespaces, thus breaking multichain DApps - users cannot switch network. This was previously working in MM Mobile + WalletConnect v1.

To Reproduce

  1. Head to https://stackblitz.com/edit/vitejs-vite-bhhzgv
  2. Connect
  3. Try switch to Polygon
  4. Error.

Expected behavior

You are able to switch chains.

jxom avatar Jun 25 '23 22:06 jxom

I would like to add more precision. This bug is due to the fact that Metamask ignores (or misshandle) the optionalChains parameter and therefore does not include these chains in the "allowed" chains of the session.

This is resulting in an error when we try to request chain switch:

error={ "message": "Chain 'eip155:137' not approved. Please use one of the following: eip155:1"}

How the connection is initiated client-side:

await EthereumProvider.init({
  projectId: process.env.TEST_PROJECT_ID,
  chains: [1], // chains added to required namespaces
  optionalChains: [77, 99, 137] // chains added to optional namespaces
  ...
})

0xWhiteleaf avatar Jun 28 '23 08:06 0xWhiteleaf

Any updates on this?

iketw avatar Jul 24 '23 22:07 iketw

Any update? Too many dApps are already broken.

mohandesjiri avatar Jul 31 '23 10:07 mohandesjiri

I'm still having issues with this. It seems MetaMask is indifferent whether Optional Namespaces are sent in the Proposal Namespace. Further, when the Required Namespace "chains" array length is greater than 1, MetaMask won't even connect...

mccabe-david avatar Dec 07 '23 22:12 mccabe-david

Am I crazy or does setting chains undefined when the array length is not 1 make no sense? Like at least fall back on defaultChain if it exists. https://github.com/ElvisKrop/wagmi-dev-references/blob/020fc97e276e8d7fbbb918e840029593fa05e7e9/packages/connectors/src/walletConnect.ts#L304

mccabe-david avatar Dec 07 '23 22:12 mccabe-david

Im also facing this issue

mthinh avatar Dec 19 '23 09:12 mthinh

Any updates on this?

siosio34 avatar Feb 16 '24 03:02 siosio34

This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.

github-actions[bot] avatar May 16 '24 04:05 github-actions[bot]

This issue was closed because there has been no follow activity in 7 days. If you feel this was closed in error please provide evidence on the current production app in a new issue or comment in the existing issue to a maintainer. Thank you for your contributions.

github-actions[bot] avatar May 23 '24 04:05 github-actions[bot]

I believe this is closed by accident, the issue is still present @gauthierpetetin

microHoffman avatar May 29 '24 13:05 microHoffman

Thanks for flagging @microHoffman , I'll re-open it.

gauthierpetetin avatar May 29 '24 13:05 gauthierpetetin