merigo-labs / solana-wallet-adapter

MIT License
6 stars 1 forks source link

[Flutter - Android]Unable to sign message. Throwing :- Error: [JsonRpcException<dynamic>] -3 : sign request declined #5

Closed Rohitbagul003 closed 1 year ago

Rohitbagul003 commented 1 year ago

I have used the same code that is given in the pub.dev example I am using solana_wallet_adapter: 0.0.7 as my other packages are dependent on lower version Am not able to find what am doing wrong can someone help me asap? This is the code i wrote:

createSolanaInstance() {
    solanaWalletAdapter = SolanaWalletAdapter(
        AppIdentity(
          uri: Uri.https('www.hashmail.dev'), // YOUR_APP_DOMAIN.
          icon: Uri.parse('wagmi.sh/icon.png'), // YOUR_ICON_PATH relative to `uri`
          name: 'hashmail', // YOUR_APP_NAME.
        ),
        cluster: Cluster.mainnet);
    debugPrint("Solana Wallet Instance Created");
  }

    connectSolana() async {
    await solanaWalletAdapter?.authorize().then((result) {
      debugPrint("connected ---> ${result.toJson()}");
      _signMessages();
    }).catchError((error) {
      debugPrint("catch error on solana -> $error");
    });
  }

   void _signMessages() async {
    const String description = "Sign Messages";
    try {
      debugPrint("Create $description...");

      debugPrint("description -> $description...");
      SignMessagesResult? result = await solanaWalletAdapter?.signMessages(
        messages: [description],
        addresses: [solanaWalletAdapter!.connectedAccount!.addressBase58],
      );

      debugPrint("Signed Messages ${result?.signedPayloads.join('\n')}");
    } catch (error, stack) {
      print('$description Error: $error');
      print('$description Stack: $stack');
      debugPrint("catch error in sign ${error.toString()}, $stack");
    }
  }
Rohitbagul003 commented 1 year ago

This issue is tested with phantom and solflare And am getting the same error if i run the example application from solana-wallet-adaptor repo

Here is the screenshot:-

image

Rohitbagul003 commented 1 year ago

Closing this issue as mobile/Android need base64 instead of base58 to work

Just replace or convert the base58 to base64 and it will start working