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

(REACT-NATIVE) JSON RPC response format is invalid #930

Closed
NoahsArk02 opened this issue Apr 9, 2022 · 4 comments · Fixed by #976
Closed

(REACT-NATIVE) JSON RPC response format is invalid #930

NoahsArk02 opened this issue Apr 9, 2022 · 4 comments · Fixed by #976

Comments

@NoahsArk02
Copy link

I tried to use the sendCustomRequest and the method is wallet_switchEthereumChain to request to switch the network on the metamask mobile, when I press switch network button on the metamask app it return me this error on my dApp JSON RPC response format is invalid. Here is my sample code

 const requestSwitchNetwork = async () => {
    try {
      await connector.sendCustomRequest({
        id: 0,
        jsonrpc: '2.0',
        method: 'wallet_switchEthereumChain',
        params: [ { chainId: ethers.utils.hexlify(CHAIN_ID) } ],
      });
    } catch (error) {
      // Always getting error
      console.log(error);
    }
  };

I tried this on the metamask API playground and it works fine.
https://metamask.github.io/api-playground/api-documentation/#wallet_switchEthereumChain

@saiyam-sage
Copy link

@NoahsArk02 I am getting the same issue. Did you find any solution?

@duyta7598
Copy link

Same issue, any update?

@Songkeys
Copy link

looks like the response is parsed to {id: 1650610281723940, jsonrpc: '2.0', result: null}. i believe this is an sdk bug.

@NoahsArk02
Copy link
Author

@NoahsArk02 I am getting the same issue. Did you find any solution?

NO, I didn't find any solution yet for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants