WalletConnect / Web3ModalFlutter

The Web3Modal for WalletConnect built using Flutter.
https://pub.dev/packages/web3modal_flutter
Apache License 2.0
44 stars 44 forks source link

Failed to show the signMessage request prompt on Metamask #148

Closed Mindsetter closed 4 months ago

Mindsetter commented 4 months ago

Describe the bug After calling the signMessage() it launches the current wallet but fails to show up the request prompt

  void signMessage() async {
    w3mService!.launchConnectedWallet();
    await w3mService!.request(
      topic: w3mService!.session?.topic,
      chainId: 'eip155: ${w3mService!.session!.chainId}', // Connected chain id
      request: SessionRequestParams(
        method: 'personal_sign',
        params: ['Sign this', w3mService!.session!.address],
      ),
    );
  }

Meaningful logs I was able to print() the chainID and the Wallet Address without any issue

 onPressed: () {
      signMessage();
      print('ChainID: ${w3mService!.session!.chainId}');
      print('Wallet Address: ${w3mService!.session!.address}');
     },

I/flutter ( 3263): ChainID: 11155111
I/flutter ( 3263): Wallet Address: 0xc59a6ce391818cbc7b67020184f4f1df5031cae1

Version: web3modal_flutter: ^3.2.2

Mindsetter commented 4 months ago

Issue resolved

quetool commented 4 months ago

Hello! I suppose it could have been the chainId (chainId: 'eip155: ${w3mService!.session!.chainId}'), right?

Mindsetter commented 4 months ago

Since the sign request function in the documentation was not working for me I checked the example folder and refactored my code

static Future<dynamic> personalSign({
    required W3MService w3mService,
    required String message,
  }) async {
    w3mService.launchConnectedWallet();
    return await w3mService.request(
      topic: w3mService.session!.topic,
      chainId: w3mService.selectedChain!.chainId,
      request: SessionRequestParams(
        method: 'personal_sign',
        params: [
          message,
          w3mService.session!.address!,
        ],
      ),
    );
  }