MetaMask / core

This monorepo is a collection of packages used across multiple MetaMask clients
MIT License
287 stars 178 forks source link

NetworkControllers chainId list breaks Optimism on Mobile. #740

Open patniemeyer opened 2 years ago

patniemeyer commented 2 years ago

Metamask Mobile throws an exception on wallet_switchEthereumChain for Optimism and suggests adding the chain. However NetworksChainId in NetworkControllers.ts inconsistently includes Optimism, which causes MetaMask Mobile to fail onwallet_addEthereumChain. So it appears that there is currently no way to use Optimism from MetaMask mobile.

https://github.com/MetaMask/controllers/blob/365191875a22ab5c94d81b464734e8adff7dbad3/src/network/NetworkController.ts#L23-L33

EDIT: Note that MetaMask extension does not reference NetworkControllers in this way and does not suffer from this problem. (It is possible to add and switch to Optimism on desktop).

mcmire commented 2 years ago

I looked in our company Slack and it looks like this is a known issue (as of a month ago). I was looking at NetworkController recently and noticed that optimism and optimismTest aren't valid subdomains on Infura. According to https://docs.infura.io/infura/networks/optimism/getting-started/send-request, it should be optimism-mainnet and optimism-kovan. It's possible this is why it's failing.