app-monorepo icon indicating copy to clipboard operation
app-monorepo copied to clipboard

[BUG]: wallet_addEthereumChain throws error: Error JSON PRC response: the method wallet_addEthereumChain does not exist/is not available

Open songkeys opened this issue 1 year ago • 6 comments
trafficstars

Prerequisites Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • [x] I checked to make sure that this issue has not already been filed
  • [ ] I've asked for help in the OneKey Discord before filing this issue.

Describe the bug

wallet_addEthereumChain does not seem to work any more.

Example code:

  window.ethereum.request({
      method: 'wallet_addEthereumChain',
      params: [{
        chainId: '0x64',
        chainName: 'Gnosis Chain',
        nativeCurrency: {
          name: 'xDAI',
          symbol: 'xDAI',
          decimals: 18
        },
        rpcUrls: ['https://rpc.gnosischain.com/'],
        blockExplorerUrls: ['https://gnosisscan.io/']
      }]
    });

Error:

{
    "name": "Error",
    "message": "Error JSON PRC response: the method wallet_addEthereumChain does not exist/is not available",
    "stack": "Error: Error JSON PRC response: the method wallet_addEthereumChain does not exist/is not available\n    at parseRPCResponse (chrome-extension://jnmbobjmhlngoefaiojfljckilhhlhcj/background.bundle.js:8:3585179)\n    at chrome-extension://jnmbobjmhlngoefaiojfljckilhhlhcj/background.bundle.js:8:1453930\n    at Array.map (<anonymous>)\n    at ServiceDApp.<anonymous> (chrome-extension://jnmbobjmhlngoefaiojfljckilhhlhcj/background.bundle.js:8:1453890)\n    at Generator.next (<anonymous>)\n    at asyncGeneratorStep (chrome-extension://jnmbobjmhlngoefaiojfljckilhhlhcj/background.bundle.js:8:11373261)\n    at _next (chrome-extension://jnmbobjmhlngoefaiojfljckilhhlhcj/background.bundle.js:8:11373506)"
}

To Reproduce Go to console and execute the above code or the sample code in your repo.

Expected behavior This will prompt the "Add chain to wallet" window to appear.

Screenshots The video below demonstrates me: 1) successfully using the same code to bring up Rainbow Wallet; 2) attempting to use the same code but failing to bring up OneKey Wallet.

https://github.com/user-attachments/assets/8f571764-bc6b-4dbb-b53a-9c7530f551c9

Desktop (please complete the following information):

  • OS: macOS
  • Browser: arc
  • Version: latest

Additional context I have just tested the Chrome extension. Some users are reporting that they are unable to do the same in the app too.


edit: I was trying to make a PR to fix this but found this endpoint is not open source? Btw, you should definitely fix the disturbing PRC typo.

songkeys avatar Sep 01 '24 17:09 songkeys