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

fix(18709): fix error when switching to linea testnet using wallet_sw… #18710

Merged
merged 2 commits into from
Apr 28, 2023

Conversation

VGau
Copy link
Contributor

@VGau VGau commented Apr 21, 2023

Explanation

Fixed the error when we use the MM API wallet_switchEthereumChain endpoint to switch to linea testnet network.
image

A new condition has been added in app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js file in findExistingNetwork function.

Screenshots/Screencaps

Before

After

Manual Testing Steps

  • Open this website : https://testnet.cashmere.exchange/swap
  • Connect your metamask wallet.
  • Select the Linea zkEVM testnet in the from dropdown.
  • Click on the Switch network button at the bottom of the page.
  • Check if the network switching worked

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

@VGau VGau requested a review from a team as a code owner April 21, 2023 07:49
@VGau VGau requested a review from mcmire April 21, 2023 07:49
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@VGau VGau force-pushed the fix/18709-error-switching-to-linea branch from 2a9c9b6 to 158d487 Compare April 21, 2023 08:11
@mcmire
Copy link
Contributor

mcmire commented Apr 21, 2023

This error message is coming from a change we made recently where we moved custom networks from PreferencesController to NetworkController: #17421

I'm trying to understand why this bug exists. Is Linea testnet a network we regard as "built-in", or is something that users need to add themselves?

@VGau
Copy link
Contributor Author

VGau commented Apr 23, 2023

This error message is coming from a change we made recently where we moved custom networks from PreferencesController to NetworkController: #17421

I'm trying to understand why this bug exists. Is Linea testnet a network we regard as "built-in", or is something that users need to add themselves?

This bug exits because we are not getting the network info using this function findNetworkConfigurationBy in this file app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js.

We regard Linea testnet as "built-in" as "Sepolia" and "Goerli". The difference is that we use the network type RPC for the linea testnet. That's why we need to use findNetworkConfigurationBy function to get the linea testnet information and then get the networkconfigurationId.

My PR fixed this issue :)

@danjm danjm added release-blocker This bug is blocking the next release release-10.30.0 Issue or pull request that will be included in release 10.30.0 labels Apr 24, 2023
@Gudahtt
Copy link
Member

Gudahtt commented Apr 25, 2023

I'm trying to understand why this bug exists. Is Linea testnet a network we regard as "built-in", or is something that users need to add themselves?

We regard Linea testnet as "built-in" as "Sepolia" and "Goerli". The difference is that we use the network type RPC for the linea testnet.

This conversation is highlighting why "built-in network" is not a great term 😅

We have this unfortunate split between certain built-in Infura networks and all other networks that affects how we interact with the network controller. Built-in Infura networks require calling setProviderType whereas other networks require using setActiveNetwork).

Ideally we'd remove this split at some point, but that's the purpose of these conditions that are being changed in this PR.

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Gudahtt Gudahtt merged commit 7f585a1 into MetaMask:develop Apr 28, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-10.30.0 Issue or pull request that will be included in release 10.30.0 release-blocker This bug is blocking the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Cannot switch to linea testnet network using "wallet_switchEthereumChain"
4 participants