TxnLab / use-wallet

A framework agnostic wallet integration library for Algorand dApps
https://txnlab.gitbook.io/use-wallet
MIT License
81 stars 32 forks source link

WalletConnect provider includes all supported chains in new session proposals #281

Closed drichar closed 5 days ago

drichar commented 5 days ago

Bug Description

The WalletConnect provider in @txnlab/use-wallet incorrectly includes all Algorand networks supported by the library (mainnet, testnet, betanet, fnet, etc.) in the requiredNamespaces in new session proposals via the Sign Client's connect method.

Expected Behavior

The WalletConnect session proposal should only include the CAIP-2 chain ID for the currently active network in requiredNamespaces.

Current Behavior

The session proposal includes chain IDs for all supported networks in requiredNamespaces, causing issues with wallets that don't support all of the included networks.

Reproduction

  1. Configure @txnlab/use-wallet to connect to mainnet (network: NetworkId.MAINNET)
  2. Attempt to connect with Edge Wallet using the WalletConnect provider
  3. The app will throw an error since the wallet does not support testnet, betanet, etc

Environment

Suggested Solution

Implement a new activeChainId getter in the WalletConnect class that returns the CAIP-2 chain ID for the currently active network. Use this getter when creating the session proposal to ensure only the active network's chain ID is included in requiredNamespaces.