Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing eth_getBalance on methods or optionalMethods #3411

Closed
hlopes-ledger opened this issue Aug 9, 2023 · 1 comment
Closed

Passing eth_getBalance on methods or optionalMethods #3411

hlopes-ledger opened this issue Aug 9, 2023 · 1 comment
Labels
type: bug Something isn't working

Comments

@hlopes-ledger
Copy link

hlopes-ledger commented Aug 9, 2023

Describe the bug

If we pass eth_getBalance on methods or optionalMethods to ethereum-provider's init(), the request to that method will not work. The only way it works is by not passing it at all, which is does not make much sense. Users have also reported the same problem with the eth_call method.

We've created a demo app to test the three scenarios: not passing it, passing it on methods and passing it on optionalMethods. These are the results that we get when using our Ledger Live app (mobile or desktop), you can see which parameters are being passed in the init options are line on the browser console when connecting

  1. if we don't pass eth_getBalance, neither in methods or optionalMethods, it works, the request is made and returns a response
  2. if we pass eth_getBalance on methods, it seems the request is made, at least we don't get any error, but no response is returned
  3. if we pass eth_getBalance on optionalMethods, we get the error 'Missing or invalid. request() method: eth_getBalance'

When connecting using the Trust wallet mobile app scenario 3 behaves like scenario 2, so I don't know how much this depends on the wallet implementation.

SDK Version (if relevant)

  • Client: JS
  • ethereum-provider version 2.9.2

To Reproduce

  1. Go to https://direct-integration-hlopes-ledger.vercel.app/ and open the browser console
  2. Click on the 'WalletConnect gB in optionalMethods' button, which passes eth_getBalance to ethereum-provider's init() in the optionalMethods property, you can see it on init options are on the browser console
  3. Accept the connection in the wallet
  4. If using Ledger Live you'll see 'Missing or invalid. request() method: eth_getBalance', if you're using for e.g. Trust mobile app it shows no error but you get no balance back

Expected behavior

To get a balance back when you call eth_getBalance and that method is passed to the ethereum-provider's init() function in either the methods or optionalMethods property.

Maybe to get the error if eth_getBalance is not passed in either methods or optionalMethods, but not when it is.

Screenshots

image

@ganchoradkov
Copy link
Member

ganchoradkov commented Aug 9, 2023

@hlopes-ledger hey, in optionalMethods (or even in required) you can set any method you wish.
It's up to the wallet to approve what they support.

I've tested your dapp with our example wallet & I'm able to receive the get_balance request
image

I guess Trust Wallet doesn't handle this method, hence the no response.
For Ledger Live, they have to approve this method to be able to receive requests for it

Closing as the protocol sends the request correctly as expected. It's up to wallets to decide which and how to handle different methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants