WalletConnectModalFlutter icon indicating copy to clipboard operation
WalletConnectModalFlutter copied to clipboard

WalletConnect session expires

Open bselwe opened this issue 2 years ago • 0 comments

Describe the bug

We've observed that the WalletConnect session sometimes expires and returns that the connected wallet address is null, even if it was connected successfully before.

To Reproduce

Initialize the WalletConnect session
service = WalletConnectModalService(
  projectId: AppDotEnv.walletConnectProjectId,
  metadata: const PairingMetadata(
    name: 'orb',
    description: 'Everyday app for web3 social',
    url: 'https://orb.ac/',
    icons: ['https://i.ibb.co/w6sNHRC/launcher.png'],
    redirect: Redirect(
      native: 'orbapp://',
      universal: 'https://orb.ac/',
    ),
  ),
  recommendedWalletIds: {
    WalletUtils.metaMaskWalletId,
    WalletUtils.zerionWalletId,
    WalletUtils.trustWalletId,
    WalletUtils.rainbowWalletId,
    WalletUtils.bitgetWalletId,
    WalletUtils.imTokenWalletId,
    WalletUtils.omniWalletId,
    ...
  },
  requiredNamespaces: {
    'eip155': RequiredNamespace(
      methods: [
        'eth_sendTransaction',
        'personal_sign',
        'eth_sign',
        'eth_signTypedData',
      ],
      chains: ['eip155:137'],
      events: [
        'chainChanged',
        'accountsChanged',
      ],
    ),
  },
  excludedWalletState: ExcludedWalletState.list,
);

service!.addListener(_onWalletUpdated);

await service!.init();

Here's how I was able to reproduce it with a Metamask wallet:

  1. Connect a Metamask wallet using WalletConnectModalConnect widget.
  2. After connecting a wallet, you'll observe isConnected is true and address is not null (in _onWalletUpdated listener).
  3. Restart the app after connecting the wallet (within 10-15 seconds).
  4. After the app launches, you'll observe isConnected is false and address is null.

Expected behavior If the WalletConnect service returns isConnected as true and the connected address is not null, then at any point in the future, the session should stay connected unless I disconnect it manually.

bselwe avatar Oct 11 '23 10:10 bselwe