MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.87k stars 4.85k forks source link

Can't connect to network created using "truffle develop" #6211

Closed jgege closed 5 years ago

jgege commented 5 years ago

Describe the bug Metamask shows "Not eth network" error when I try to send eth on a network created using "truffle develop". The "truffle develop" command creates a network with id 4447 by default but due to a check in metamask's utils.js this does not count as a valid network anymore. See the changes here:

https://github.com/MetaMask/metamask-extension/commit/8dddf48904323d47685516ccc76f9e267dbd188a#diff-955188925f3e95eb36c7ed4284fe5bfcR67

It does work if I set the network id to one on the white list (1, 3, 4, 42, 5777)

To Reproduce Steps to reproduce the behavior:

  1. Run the "truffle develop" command (truffle needs to be installed OFC)
  2. Connect to the network using Metamask
  3. Import the accounts
  4. Try to send eth from one account to the other

Expected behavior Should be able to use a custom network with Metamask.

davidmurdoch commented 5 years ago

This bug affects all Ganache and ganache-cli users as well. Can you revert this change ASAP, @jonathansmirnoff and @frankiebee?

gnidan commented 5 years ago

This whitelist strategy also means that ganache-cli won't work by default, since that uses the current timestamp as the network ID.

bdresser commented 5 years ago

thanks for filing @jgege, we're taking a look

tmashuang commented 5 years ago

Issue is closed from the referenced PRs fixed by in Truffle. Truffle v5.0.7, but believe that v5.0.6 will also work. We could have also added the networkId on our end.

gnidan commented 5 years ago

Please consider a solution other than a whitelist. A whitelist seems quite contrary to the spirit of decentralization, and I cannot guarantee that Truffle won't change network IDs in the future. The fix on our end to accommodate the problem here should not be considered an endorsement of this whitelist, but instead it is just meant as a stopgap solution.

Also, besides truffle develop, there is still the problem of ganache-cli not working with MetaMask by default anymore, now that the whitelist is in place.

davidmurdoch commented 5 years ago

In addition to what @gnidan said, network ids in ganache-cli are based on the timestamp at startup by default. This issue is not fixed for ganache-cli.

tmashuang commented 5 years ago

There's a issue open for ganache-cli https://github.com/MetaMask/metamask-extension/issues/6214.

davidmurdoch commented 5 years ago

Ah, thanks @tmashuang.