MetaMask / metamask-android-sdk

MetaMask SDK for Android
Other
37 stars 14 forks source link

"eth_getEncryptionPublicKey" in android SDK #119

Closed Rathore2696 closed 2 weeks ago

Rathore2696 commented 4 weeks ago

Bug Report

There is a method in MetaMask SDK that gets the encryptionpublic key using the "eth_getEncryptionPublicKey" method in the request

How to use this in the Android application? Is this feature implemented but removed in the latest version of the MetaMask SDK for Android, if so which version should I have to use this method? Is there any alternative way to get the same result in the MetaMask SDK for Android?

elefantel commented 3 weeks ago

Hi @Rathore2696 see the MetaMask documentation regarding that RPC method https://docs.metamask.io/wallet/reference/eth_getencryptionpublickey/

How do you wish to use the wallet's public key?

Rathore2696 commented 3 weeks ago

Hi @elefantel,

I am using MetaMask SDK v5.4 for Android in Android Studio - Koala

Below is the code I use to connect with the MetaMask(Wallet) mobile application in an Android smartphone from my Android application:

image_2024_07_09T12_18_31_032Z

And the MetaMask wallet gets connected to my application and in the callback I am storing the result that contains my wallet address in a variable of type LiveData . When I try to get the public encryption key from my connected wallet in my Android application, it returns the result as follows:-

image_2024_07_09T12_03_05_773Z

With the help of the JSON RPC API(https://docs.metamask.io/wallet/reference/eth_getencryptionpublickey/) I am able to get the encrypted public key but not via the SDK. How to get it in my mobile app?. Please suggest a way, thank you in advance.

elefantel commented 3 weeks ago

Ok I see what the issue is. We did not include eth_getEncryptionPublicKey among the supported methods for working with the wallet because it is marked as deprecated in that MetaMask documentation I sent you.

The way you can make it to work in the meantime would be to not provide the SDKOptions and then all traffic will default to the wallet. Currently that RPC call is going via Infura and Infura does not support it.

Rathore2696 commented 2 weeks ago

I tried as per your suggestion by removing the SDKOptions from the parameters passed in the Ethereum constructor to create the Ethereum instance, but still the same error message is received after calling the eth_getEncryptionPublicKey logic I am using in the Android Studio.

Screenshot_1

elefantel commented 2 weeks ago

@Rathore2696 ok that means MetaMask no longer supports that method. As you can see in the documentation in the link above I shared the method is marked as deprecated, with a note: "This method is deprecated and may be removed in the future." I will close this ticket.

Rathore2696 commented 2 weeks ago

I need to retrieve that encryption public key. If it is not supported in the MetaMask mobile SDK for android, then how do I get that key?