Commit 85f4650
authored
fix: migration script of update MegaETH testnet v2 (#38573)
<!--
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 fix the migration script 184,
to not replace the network configuration for a user if he already has
megaETH testnet v2 exist
instead we only merge the information
<!--
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?
-->
[](https://codespaces.new/MetaMask/metamask-extension/pull/38573?quickstart=1)
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: Fixed the migration script for adding MegaETH testnet
v2
## **Related issues**
Fixes:
## **Manual testing steps**
1. Install a extension without MegaETH testnet v2
2. Manually add MegaETH testnet v2 config
```
MEGAETH_TESTNET_V2_CONFIG = {
chainId: '0x18c7', // 6343
name: 'MegaETH Testnet',
nativeCurrency: 'MegaETH',
blockExplorerUrls: ['https://megaeth-testnet-v2.blockscout.com'],
defaultRpcEndpointIndex: 0,
defaultBlockExplorerUrlIndex: 0,
rpcEndpoints: [
{
type: RpcEndpointType.Custom,
url: 'https://timothy.megaeth.com/rpc',
},
],
};
```
3. select the MegaETH testnet v2 as current network
4. update the extension to have the migration run
5. the network should remain the same
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<img width="300" alt="image"
src="https://github.com/user-attachments/assets/b5eba40d-f044-45a9-8c17-6349e56c886a"
/>
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
<img width="300" alt="image"
src="https://github.com/user-attachments/assets/f8de66ef-37f7-4762-a5f7-af129519b265"
/>
## **Pre-merge author checklist**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Update migration 184 to merge an existing MegaETH Testnet v2 config
instead of overwriting, add it to the enabled map only if missing, and
retain v1-to-mainnet switching; add a test for the merge path.
>
> - **Migration 184**:
> - Merge existing `MEGAETH_TESTNET_V2_CONFIG` instead of overwriting:
> - Update `name` and `nativeCurrency`.
> - Append missing RPC endpoint and block explorer URL; set default
indices accordingly.
> - Add v2 to `enabledNetworkMap` only if absent.
> - Keep logic to switch selected client from v1 to `mainnet` and remove
v1 config.
> - **Tests**:
> - Add test to verify merging behavior when v2 already exists.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9b4283d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent d058e75 commit 85f4650
2 files changed
+117
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
223 | 286 | | |
224 | 287 | | |
225 | 288 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
176 | | - | |
177 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
178 | 204 | | |
179 | | - | |
180 | | - | |
181 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
182 | 222 | | |
183 | | - | |
184 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
185 | 229 | | |
| 230 | + | |
| 231 | + | |
186 | 232 | | |
187 | 233 | | |
188 | 234 | | |
| |||
0 commit comments