Uh oh!
There was an error while loading. Please reload this page.
feat: add MegaETH Testnet to network-controller - #5527
Conversation
stanleyyconsensys
commented
Mar 24, 2025
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
stanleyyconsensys
commented
Mar 24, 2025
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
MegaETH Testnet to network controllerMegaETH Testnet to network controllerMegaETH Testnet to network-controllerstanleyyconsensys
commented
Mar 25, 2025
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
stanleyyconsensys
commented
Mar 26, 2025
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
57dc107 to
38ce0ecCompare
mcmire
left a comment
There was a problem hiding this comment.
Just one suggestion on this, otherwise this looks good.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- fix mock network hardcoded mock path when RPC has endpoint with '/rpc' - fix test result on token detection when megaETH network added as default
39d35a4 to
80be045Compare<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR is to add MegaETH as default network via NetworkController ( [5527](MetaMask/core#5527), [5495](MetaMask/core#5495) ) It also include a migration script to add/replace the MegaETH network for existing user ### **Change**: - Add MegaETH Testnet to default network via NetworkController options - `additionalDefaultNetworks` - Add migration script to replace/add MegaETH Testnet to the NetworkController state - Decouple the logic on method validateName from `NetworkSetting` to Network Utils `isValidNetworkName` for easier maintain and increase test coverage - Update Unit Test for MegaETH Testnet <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Related issues** Fixes: ## **Manual testing steps** 1. Setup a new wallet 2. Click on network menu and show test networks 3. You will see Sepolia , Linea Sepolia and Mega Testnet on test networks section 4. Click on Mega Testnet to switch the network 5. Send a transaction 6. Check the transaction result in the explorer ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <img width="300" alt="Screenshot 2025-03-21 at 12 49 13" src="https://github.com/user-attachments/assets/69c95b03-0c95-4cae-bf2f-445a8893d0bf" /> <img width="300" alt="Screenshot 2025-03-21 at 12 49 38" src="https://github.com/user-attachments/assets/9e7e2274-b83a-4f72-898a-32a7b19e847f" /> <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: wantedsystem <amine.harty@consensys.net> Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com> Co-authored-by: Mathieu Artu <mathieu.artu@consensys.net>
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR is to add MegaETH as default network via NetworkController ( [5527](MetaMask/core#5527), [5495](MetaMask/core#5495) ) It also include a migration script to add/replace the MegaETH network for existing user ### **Change**: - Add MegaETH Testnet to default network via NetworkController options - `additionalDefaultNetworks` - Add migration script to replace/add MegaETH Testnet to the NetworkController state - Decouple the logic on method validateName from `NetworkSetting` to Network Utils `isValidNetworkName` for easier maintain and increase test coverage - Update Unit Test for MegaETH Testnet <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Related issues** Fixes: ## **Manual testing steps** 1. Setup a new wallet 2. Click on network menu and show test networks 3. You will see Sepolia , Linea Sepolia and Mega Testnet on test networks section 4. Click on Mega Testnet to switch the network 5. Send a transaction 6. Check the transaction result in the explorer ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <img width="300" alt="Screenshot 2025-03-21 at 12 49 13" src="https://github.com/user-attachments/assets/69c95b03-0c95-4cae-bf2f-445a8893d0bf" /> <img width="300" alt="Screenshot 2025-03-21 at 12 49 38" src="https://github.com/user-attachments/assets/9e7e2274-b83a-4f72-898a-32a7b19e847f" /> <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: wantedsystem <amine.harty@consensys.net> Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com> Co-authored-by: Mathieu Artu <mathieu.artu@consensys.net>
Explanation
Further to Previous PR: #5495
We are adding MegaETH Testnet as default network on
Network Controllerdefault state -networkConfigurationsByChainIdwith the constants and type from the latestcontroller-utilsIn additional, a new constructor option
addtionalDefaultNetworkshas introduced inNetworkControllertoprevent client push the new network unintentionally
(such as bump up the network controller without support on the client side)
Changes:
Add Constructor Option
addtionalDefaultNetworksto specify the additional default networks to be included, which allows backward compatible and only include the Network if it has ready on client side (by developer specify)Refactor the logic to separate the construction of default network configurations to methods
getDefaultInfuraNetworkConfigurationsByChainIdandgetDefaultCustomNetworkConfigurationsByChainIdFix
mock-networknot support a use case when the RPC endpoint come with a path segment, e.g: 'https://carrot.megaeth.com/rpc'Add
MegaETH TestnetChainId into constantsCHAIN_IDSfromtransaction-controllerNote :
For everyone interested in testing this version in MM mobile you can use this branch to do so : https://github.com/MetaMask/metamask-mobile/tree/feat/add-megaeth-testnet


References
Changelog
@metamask/network-controlleraddtionalDefaultNetworksto specify the additional networks to be included as the default network.@metamask/transaction-controllerMegaETH TestnetChainId into constantsCHAIN_IDSChecklist