Uniswap / web3-react

A simple, maximally extensible, dependency minimized framework for building modern Ethereum dApps
https://web3-react-mu.vercel.app/
GNU General Public License v3.0
5.56k stars 1.52k forks source link

WalletConnect v2 doesn't support optional chains - Make sure default chain is included in "chains" #845

Open torreyatcitty opened 1 year ago

torreyatcitty commented 1 year ago

See the example app here: https://web3-react-mu.vercel.app/

If you try to select any other chain under walletConnectV2 besides mainnet you see the following error:

Error: Invalid chainId 10. Make sure default chain is included in "chains" - chains specified in "optionalChains" may not be selected as the default, as they may not be supported by the wallet.
gurukishore111 commented 1 year ago

+1, I am just trying to connect the Polygon testnet to the MetaMask mobile app, but the Polygon testnet is available. However, I am still encountering an error.

rayQuadrata commented 1 year ago

@torreyatcitty @gurukishore111 in chains.ts you can add the following to be used for the WalletConnectV2 chainIds for it to work properly.

export const DEFAULT_MAIN_CHAINS = [
  // mainnets
  "eip155:1",
  "eip155:10",
  "eip155:100",
  "eip155:137",
  "eip155:324",
  "eip155:42161",
  "eip155:42220",
  "cosmos:cosmoshub-4",
  "solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",
  "polkadot:91b171bb158e2d3848fa23a9f1c25182",
  "mvx:1",
  "tron:0x2b6653dc",
  "tezos:mainnet",
  "kadena:mainnet01",
];

export const DEFAULT_TEST_CHAINS = [
  // testnets
  "eip155:5",
  "eip155:280",
  "eip155:420",
  "eip155:80001",
  "eip155:421611",
  "eip155:44787",
  "solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K",
  "polkadot:e143f23803ac50e8f6f8e62695d1ce9e",
  "near:testnet",
  "mvx:D",
  "tron:0xcd8690dc",
  "tezos:testnet",
  "kadena:testnet04",
];

export const DEFAULT_CHAINS = [...DEFAULT_MAIN_CHAINS, ...DEFAULT_TEST_CHAINS];

reference: https://github.com/WalletConnect/web-examples/blob/main/dapps/react-dapp-v2/src/constants/default.ts

gurukishore111 commented 1 year ago

@rayQuadrata, thanks for the reply. I have added those chain IDs in the format recommended by web3-react link. However, it's still throwing the same issue.

rayQuadrata commented 1 year ago

@rayQuadrata, thanks for the reply. I have added those chain IDs in the format recommended by web3-react link. However, it's still throwing the same issue.

@gurukishore111 as you can see from the web3-react example, the format provided results in an error. However, if you use the format list in my example above, you can select the other networks for WallConnectV2. This alternate format is only for WalletConnectV2

damianlluch commented 9 months ago

same issue