metamask-mobile
metamask-mobile copied to clipboard
Can't add Optimism network on MetaMask mobile
Describe the bug
Calling wallet_addEthereumChain to add Optimism network on MetaMask mobile will throw exception with message: May not specify default MetaMask chain.
To Reproduce
Send request from a dApp running within MetaMask mobile browser:
window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [
{
chainId: "0xa",
chainName: "Optimism",
rpcUrls: ["https://mainnet.optimism.io"],
blockExplorerUrls: ["https://optimistic.etherscan.io"],
nativeCurrency: {
"name": "ETH",
"symbol": "ETH",
"decimals": 18
}
}
]
})
Expected behavior
Optimism is added successfully as a custom network.
Smartphone (please complete the following information):
- Device: Pixel 5a
- OS: Android 12
- App Version: 5.2.0
to be added after bug submission by internal support / PM Severity
- How critical is the impact of this bug on a user?
- Add stats if available on % of customers impacted
- Is this visible to all users?
- Is this tech debt?
From what I can see, the exception is thrown from this line in wallet_addEthereumChain.js, where it checks the chainId against this list NetworksChainId.
The list contains optimism network, therefore it rejects the request.
I think the condition is incorrect, it should checks if the network has been added to the local network lists, instead of NetworksChainId. The list contains networks that are not really added as default networks (which is optimism and optimismTest.
Having the same problem with my web3 app on MetaMask Mobile. Also noticed that bug with other web3 apps such as 1inch. Can you please fix this?
still can not use mobile app for Calling wallet_addEthereumChain to add Optimism chain
ios app v5.12.3
same issue for May not specify default MetaMask chain.
Describe the bug Calling
wallet_addEthereumChainto add Optimism network on MetaMask mobile will throw exception with message:May not specify default MetaMask chain.To Reproduce
Send request from a dApp running within MetaMask mobile browser:
window.ethereum.request({ method: 'wallet_addEthereumChain', params: [ { chainId: "0xa", chainName: "Optimism", rpcUrls: ["https://mainnet.optimism.io"], blockExplorerUrls: ["https://optimistic.etherscan.io"], nativeCurrency: { "name": "ETH", "symbol": "ETH", "decimals": 18 } } ] })Expected behavior
Optimism is added successfully as a custom network.
Smartphone (please complete the following information):
- Device: Pixel 5a
- OS: Android 12
- App Version: 5.2.0
to be added after bug submission by internal support / PM Severity
- How critical is the impact of this bug on a user?
- Add stats if available on % of customers impacted
- Is this visible to all users?
- Is this tech debt?