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

Account: unable to connect account locally #1368

Closed
macor161 opened this issue Mar 20, 2020 · 10 comments · Fixed by #1463
Closed

Account: unable to connect account locally #1368

macor161 opened this issue Mar 20, 2020 · 10 comments · Fixed by #1463

Comments

@macor161
Copy link
Contributor

Describe the bug

When run locally, it is currently not possible to connect an account by clicking the Metamask icon. The following error is thrown in the console:

MetaMask - RPC Error: The method undefined does not exist/is not available

Everything seems to work fine when using the Rinkeby build though.

Mainnet or testnet?
Local build

To Reproduce
Steps to reproduce the behavior:

  1. npm run start:local
  2. Click on 'Connect account'
  3. Click on the Metamask button

Desktop (please complete the following information):

  • OS and OS version: macOS Mojave
  • Browser and browser version: Chrome latest
@sohkai
Copy link
Contributor

sohkai commented Mar 20, 2020

This seems like a further regression of #1203.

@macor161
Copy link
Contributor Author

Yes I think so, though I wasn't able to confirm if both are related.

@sohkai sohkai changed the title Account: Unable to connect account locally Account: unable to connect account locally Mar 21, 2020
@macor161
Copy link
Contributor Author

I investigated the problem further today and the issue seems to be coming from web3-react

@Evalir
Copy link
Contributor

Evalir commented Apr 2, 2020

As this is a problem in web3-react, should we move this to the ignore column?

@macor161
Copy link
Contributor Author

macor161 commented Apr 2, 2020

@Evalir I'm still not 100% sure the problem is coming from web3-react. Will have another look this week.

@sohkai
Copy link
Contributor

sohkai commented Apr 8, 2020

As this is a problem in web3-react, should we move this to the ignore column?

No, that is not the intention. The intention is to dig into web3-react to understand the underlying problem and fix it :).

@fabriziovigevani fabriziovigevani self-assigned this Apr 9, 2020
@fabriziovigevani
Copy link
Contributor

Having a look at this, i think that part of the issue is coming from the web3 library.

Apparently. it fails to perform the window.ethereum.send('eth_chainId') method (if you perform it in the console you can see the error). Even also calling it with sendAsync fails.
This causes web3-react to fallback to the ethereum.chainId when getting the chainId which is 0xNaN and web3-react throws an error if this is the case.

This doesn't happen for example with ether.js.

Regarding #1203, assuming we can fix the first issue, then i think by setting explicitly the chainId in the settings of the local env https://github.com/aragon/aragon/blob/8b46de67c4e4ec11e55f48d01ca235e2817ef131/src/network-config.js#L71 to what window.ethereum.send('chainId') returns (converted to decimal), should fix the error.
For example, this is what we do in the court dashboard :D

@sohkai
Copy link
Contributor

sohkai commented Apr 10, 2020

The below may still be useful, but this comment was insightful:

trufflesuite/ganache#515 (comment)

What we need to do (and will do in our v3 release) is expose a customisable chainId option in ganache-core and ganache-cli. We'll also update the default chainId from 1 to 1337 at the same time. Currently the RPC method eth_chainId returns 1337, but all transactions are signed as if they were on a chain with an Id of 1.

This is honestly just 🤯but if things have been working in the Court with 1337 as the chain id without any issues on the signer, then let's do it!


by setting explicitly the chainId in the settings of the local env

Interesting... unfortunately this is somewhat complicated by the client not knowing its devchain's chainId at build time (the tooling decides that on its own).

Apparently. it fails to perform the window.ethereum.send('eth_chainId') method (if you perform it in the console you can see the error). Even also calling it with sendAsync fails.

This seems weird, maybe it's the current devchain version not supporting eth_chainId? We may be using different versions of ganache, which doesn't have support for it (it was istanbul that added it). cc @0xGabi @macor161

The web3.js source makes this pretty hard to wiff on: https://github.com/ethereum/web3.js/blob/1.x/packages/web3-eth/src/index.js#L521-L522

@davidmurdoch
Copy link

Ganache-cli (and ganache-core) now have a configurable chainId.

For ganache-cli: ganache-cli --chainId 1337 --networkId 1337 will align the eth_chainId RPC and the CHAIN_ID opcode, and will also align the net_version RPC with the chainId.

Sorry for the headache this has caused!

@sohkai
Copy link
Contributor

sohkai commented Sep 29, 2020

So glad to hear @davidmurdoch 🎉

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

Successfully merging a pull request may close this issue.

5 participants