WalletConnectModalFlutter icon indicating copy to clipboard operation
WalletConnectModalFlutter copied to clipboard

Unable to sign a message with a Rainbow wallet

Open bselwe opened this issue 2 years ago • 1 comments

Describe the bug

It is not possible to sign a message or transaction when connected to a Rainbow wallet. The Rainbow wallet is launched but it doesn't show a pop-up to sign a message or transaction. It might be that the WalletConnect session is stale as it usually happens a few hours (or a day) after connecting the wallet.

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();
Sign a message
Future<String?> signMessage({required String message}) async {
    final web3App = service?.web3App;
    final address = service?.address?.toLowerCase() ?? '';
    final sessionData = web3App?.sessions.getAll().first;

    if (sessionData != null) {
      service?.launchCurrentWallet();
      await web3App!.request(
        topic: service!.session!.topic,
        chainId: 'eip155:137', // Polygon
        request: SessionRequestParams(
          method: 'personal_sign',
          params: [message, address],
        ),
      );
    }
  }

Expected behavior

A pop-up to sign a message should appear in the Rainbow wallet, after launching a wallet.

Videos

https://github.com/WalletConnect/WalletConnectModalFlutter/assets/26686598/e9d88f03-646b-46ec-8165-cd2d0f55d71c

Note: We use the above signMessage method when calling "Verify with Lens". Notice that the wallet is launched but there's no popup to sign a message.

bselwe avatar Oct 11 '23 11:10 bselwe

Hello @bselwe, I just tried your example, commented out 'eth_sign', 'eth_signTypedData' methods and I was able to sign a message properly using Rainbow.

This is your modified code https://gist.github.com/quetool/b9791ab2f1769fc03e95aa4443e58a68

I'll keep trying by waiting long enough and let you know.

https://github.com/WalletConnect/WalletConnectModalFlutter/assets/14978705/389074bb-5383-4faf-9d93-5115a3d3ece2

quetool avatar Nov 04 '23 11:11 quetool