MetaMask / metamask-android-sdk

MetaMask SDK for Android
Other
46 stars 14 forks source link

[Bug]: ETH_GET_BALANCE and other json rpc ethereum request not returning any response. #63

Closed developerRojina closed 9 months ago

developerRojina commented 10 months ago

Provide environment information

OS- MAC OS Android studio version- Hedgehog

MetaMask Android SDK Version

0.2.1

MetaMask Mobile app Version

7.11.0

Android Version

12

Describe the Bug

ETH_GET_BALANCE and other json rpc ethereum request not returning any response. It does not return any error neither it returns any value.

Expected Behavior

I expect the method to return either an error or an response.

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

No response

To Reproduce

This is my method: ` private void getBalance() { Log.d("TAG", "inside get balance"); // ethereum.clearSession();

    List<String> params = new ArrayList<>();
    params.add(ethereum.getSelectedAddress());
    params.add("latest");

    ethereum.sendRequest(new EthereumRequest(UUID.randomUUID().toString(),
            EthereumMethod.ETH_GET_BALANCE.getValue(),
            params), result -> {
        if (result instanceof RequestError) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Log.d("TAG", "the errro ris:" + ((RequestError) result).getMessage());

                }
            });
            // handle error
        } else {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Log.d("TAG", "the show banace is:" + result);
                    tvShowBalance.setText("The balance is:" + result);
                }
            });

        }
        return null;
    });
}

`

And this is the log that the library prints

` Ethereum:: Sending request EthereumRequest(id=06f62570-f4ca-4cc7-9f9b-5882d8ccf7eb, method=eth_getBalance, params=[0x7aa8fdae92d1076c05654d96d0a38f1ace28f88e, latest])

CommunicationClient:: sending request EthereumRequest(id=06f62570-f4ca-4cc7-9f9b-5882d8ccf7eb, method=eth_getBalance, params=[0x7aa8fdae92d1076c05654d96d0a38f1ace28f88e, latest]) `

And it gives nothing, neither the error is logged nor the success response.

This is how I have initialized Ethereum

` dapp = new Dapp("Droid Dapp", "https://droiddapp.com"); ethereum = new Ethereum(getApplicationContext());

`

I aslo tried called ETH_CHAIN_ID but it is also same. I think there is some issue on read only callbacks

Cognacy commented 10 months ago

@developerRojina Are you still having this issues?

developerRojina commented 10 months ago

@Cognacy Yes, I am still having this issue. It's still stuck and doesn't give any response

christopherferreira9 commented 10 months ago

Hi all! We're are actively working on a fix for this. We'll keep you all posted when we're able to make some progress.

andreahaku commented 10 months ago

@developerRojina @Cognacy we are working on a double solution to that. The first one is to allow for "direct calls" like we do on the JS SDK via Infura API. The second one is to implement deeplinking to the MM mobile app also for those calls. This second solution is not the best in terms of UX but it should work anyway.

Once we've have implemented "direct calls" on Android SDK, we strongly suggest you to go this way as it'll be a seamless experience for the user.

Thanks

christopherferreira9 commented 9 months ago

Hi @developerRojina ! We've just released a new version of the Android SDK. You can check it out here.

You'll be able to do the call you want via Infura by setting an infuraApiKey. You can see how it works in the section of the readme.