Skip to content

[pull] main from MetaMask:main#317

Merged
pull[bot] merged 2 commits into
Reality2byte:mainfrom
MetaMask:main
Nov 12, 2025
Merged

[pull] main from MetaMask:main#317
pull[bot] merged 2 commits into
Reality2byte:mainfrom
MetaMask:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Nov 12, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

khanti42 and others added 2 commits November 12, 2025 00:16
<!--
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 bumps the network-enablement-controller to version 3.1.0 that
includes monad in the constant.
This allows monad to be selected when clicking on the `All popular
networks` button in the Networks Modal.

<!--
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?
-->

## **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: bumps network-enablement-controller and apply patch
similar to patch on 3.0.0

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]
```

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->
<img width="384" height="792" alt="Screenshot 2025-11-11 at 17 01 05"
src="https://github.com/user-attachments/assets/0726e0c3-eb8a-4817-9e4a-f101a664274b"
/>



### **After**

<!-- [screenshots/recordings] -->

<img width="384" height="792" alt="Screenshot 2025-11-11 at 17 11 43"
src="https://github.com/user-attachments/assets/83bc4ca7-adf1-42ef-be11-3db8842deef0"
/>


## **Pre-merge author checklist**

- [ ] 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).
- [ ] 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-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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Updates @metamask/network-enablement-controller to 3.1.0 with a patch
that enables additional EVM networks by default.
> 
> - **Dependencies**:
> - Bump `@metamask/network-enablement-controller` from `3.0.0` to
`3.1.0` using a Yarn patch.
> - **Network defaults** (`dist/NetworkEnablementController.cjs`):
> - Extend default-enabled EVM networks by adding `ArbitrumOne`,
`BscMainnet`, `OptimismMainnet`, `PolygonMainnet`, and `SeiMainnet`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
b41bb09. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
…21990)

<!--
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**

<!--
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?
-->


When Redux state migrations fail, redux-persist resets the state to
defaults and updates the version number to the latest, preventing
migrations from re-running. This leaves users stuck on the onboarding
screen unable to access their wallets, even though their vault backup
exists in secure storage.

## Implementation

### 1. Vault Recovery Detection on Onboarding Screen

Added automatic detection when users land on the onboarding screen with
an existing vault backup:
- Detects migration failure scenario: `!existingUser` (Redux reset) +
vault backup exists
- Skips detection if user explicitly deleted their wallet
(`route.params.delete`)
- Automatically navigates to vault recovery screen
- Users can restore their wallet using their password
- Prevents data loss from failed migrations

**Files Changed:**
- `app/components/Views/Onboarding/index.js` - Added vault recovery
detection
- `app/components/Views/RestoreWallet/WalletRestored.tsx` - Sets
`existingUser` flag after restore

### 2. Fixed Vault Recovery Persistence Bug

Fixed critical bug where vault recovery didn't persist controller state
changes:
- Added `setupEnginePersistence()` call in `initializeVaultFromBackup()`
path
- Ensures controller state changes are saved to individual files after
vault recovery
- Previously caused infinite vault recovery loops after successful
restore
- Consolidated persistence setup in `initializeControllers()` for
consistency

**Files Changed:**
- `app/core/EngineService/EngineService.ts` - Fixed persistence setup in
vault recovery path

### 3. Fixed Race Condition in Wallet Deletion

Prevents temporary wallets (created during reset) from being backed up:
- Added `disableAutomaticVaultBackup` flag to temporarily disable vault
backups during wallet reset
- Clears all vault backups before creating temporary wallet
- Re-enables automatic backups in `finally` block for robustness
- Applies to both manual wallet deletion and OAuth error recovery
- Prevents false vault recovery prompts after intentional wallet resets

**Files Changed:**
- `app/core/Engine/Engine.ts` - Added circuit breaker flag
- `app/components/hooks/DeleteWallet/useDeleteWallet.ts` - Manual
deletion fix
- `app/core/Authentication/Authentication.ts` - Uncommented
`setExistingUser(true)` for new wallets
- `app/core/BackupVault/backupVault.ts` - Vault backup utilities

### 4. Fixed Migration Inflation/Deflation Logic

Corrected conditions for the new file-based persistence system
(migrations 104-105):
- **Inflation**: `> 106` - Only migrations 106+ need to inflate from
individual controller files
- **Deflation**: `>= 106` - Migration 106 is the first to deflate into
individual controller files
- Only future migrations require inflation, that will follow this PR
- Ensures smooth transition to new persistence system without breaking
app on restart

**Files Changed:**
- `app/store/migrations/index.ts` - Fixed inflation/deflation conditions
and removed debug logs
- `app/store/migrations/index.test.ts` - Updated tests to reflect
correct logic

### 5. Code Cleanup

Removed all debugging logs added during investigation:
- `app/components/Views/Onboarding/index.js` - Removed migration
detection logs
- `app/core/EngineService/EngineService.ts` - Removed persistence setup
logs
- `app/store/migrations/index.ts` - Removed KeyringController debug logs
- `app/core/BackupVault/backupVault.ts` - Simplified error handling
- `app/core/Engine/Engine.ts` - Removed vault backup logs

### 6. Test Compliance

Fixed unit test naming violations to comply with project guidelines:
- Updated 19 tests in `EngineService.test.ts` to remove "should" from
test names
- Ensured all tests follow action-oriented naming convention

## **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:

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]
```

**Feature: Vault Recovery After Migration Failure**

  Scenario: user restores wallet after migration failure
    Given user has MetaMask installed with wallet data
    And a state migration fails during app startup
    And redux state is reset to defaults
    And vault backup exists in secure storage

    When user opens the app
    Then user sees the vault recovery screen automatically
    
    When user enters their wallet password
    Then user successfully restores their wallet
    And user can access their accounts and assets


**Feature: Manual Wallet Deletion**

  Scenario: user deletes wallet without false vault recovery
    Given user has MetaMask installed with an active wallet
    And user is on the Settings screen

    When user navigates to "Security & Privacy"
    And user taps "Delete Wallet"
    And user confirms the deletion
    And user restarts the app
    Then user sees the onboarding screen
    And user does NOT see the vault recovery screen


**Feature: OAuth Login Error Recovery**

  Feature: Vault Recovery After Migration Failure

  Scenario: user restores wallet after migration failure
    Given user has MetaMask installed with wallet data
    And a state migration fails during app startup
    And redux state is reset to defaults
    And vault backup exists in secure storage

    When user opens the app
    Then user sees the vault recovery screen automatically
    
    When user enters their wallet password
    Then user successfully restores their wallet
    And user can access their accounts and assets


**Feature: Manual Wallet Deletion**

  Scenario: user deletes wallet without false vault recovery
    Given user has MetaMask installed with an active wallet
    And user is on the Settings screen

    When user navigates to "Security & Privacy"
    And user taps "Delete Wallet"
    And user confirms the deletion
    And user restarts the app
    Then user sees the onboarding screen
    And user does NOT see the vault recovery screen


**Feature: OAuth Login Error Recovery**

Scenario: user experiences OAuth backup failure without false vault
recovery
    Given user is creating a new wallet with OAuth (Google/Apple login)
    And local wallet creation succeeds
    And cloud backup fails during OAuth process

    When the error handler resets the wallet state
    And user restarts the app
    Then user sees the onboarding screen
    And user does NOT see the vault recovery screen
    And user can retry OAuth login or import with seed phrase


**Feature: Migration System Upgrade Path**

  Scenario: user upgrades from version 103 to version 104+
    Given user has MetaMask version with migrations up to 103
    And controller data is stored in redux-persist
    And user has an active wallet

    When user upgrades to version 104 or higher
    Then migrations 104+ run successfully
    And controller data is deflated to individual files
    And user's wallet remains accessible
    And app functions normally after restart


  Scenario: user upgrades from version 104 to version 105+
    Given user has MetaMask version 104
    And controller data is in individual files
    And user has an active wallet

    When user upgrades to version 105 or higher
    Then controller data is inflated for migrations
    And new migrations run successfully
    And controller data is deflated back to individual files
    And user's wallet remains accessible
And app functions normally after restart**: user experiences OAuth
backup failure without false vault recovery
    Given user is creating a new wallet with OAuth (Google/Apple login)
    And local wallet creation succeeds
    And cloud backup fails during OAuth process

    When the error handler resets the wallet state
    And user restarts the app
    Then user sees the onboarding screen
    And user does NOT see the vault recovery screen
    And user can retry OAuth login or import with seed phrase


**Feature: Migration System Upgrade Path**

  Scenario: user upgrades from version 103 to version 104+
    Given user has MetaMask version with migrations up to 103
    And controller data is stored in redux-persist
    And user has an active wallet

    When user upgrades to version 104 or higher
    Then migrations 104+ run successfully
    And controller data is deflated to individual files
    And user's wallet remains accessible
    And app functions normally after restart


  Scenario: user upgrades from version 104 to version 105+
    Given user has MetaMask version 104
    And controller data is in individual files
    And user has an active wallet

    When user upgrades to version 105 or higher
    Then controller data is inflated for migrations
    And new migrations run successfully
    And controller data is deflated back to individual files
    And user's wallet remains accessible
    And app functions normally after restart

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [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**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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]
> Detects migration failure and routes to vault recovery, ensures
controller persistence after recovery, prevents backing up temporary
wallets during resets, and updates login/recovery flows with tests.
> 
> - **Onboarding/Recovery**:
> - Detects migration failure on `Onboarding` by checking vault backup
and `existingUser`; skips in E2E and explicit delete, then navigates to
`Routes.VAULT_RECOVERY.RESTORE_WALLET`.
> - `WalletRestored` now routes to `Routes.ONBOARDING.LOGIN` with
`isVaultRecovery` instead of auto-auth; adds tests.
> - `Login` sets `existingUser` via `setExistingUser(true)` after
successful unlock when `isVaultRecovery` is true; adds tests.
> - **Engine/Authentication**:
> - Adds `Engine.disableAutomaticVaultBackup` and skips `backupVault`
when true.
> - Clears vault backups and temporarily disables auto-backup during
wallet reset and OAuth error recovery; always re-enables.
> - `EngineService` moves filesystem persistence setup to
`initializeControllers` and ensures it runs after vault recovery;
updates batching and tests.
> - **Hooks/Tests**:
> - `useDeleteWallet` clears backups first, disables auto-backup during
reset, re-enables in `finally`, and resets controllers; adds robust
tests.
> - Renames and tightens numerous test titles/expectations; snapshot
names updated.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ed1a8a7. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@pull pull Bot locked and limited conversation to collaborators Nov 12, 2025
@pull pull Bot added the ⤵️ pull label Nov 12, 2025
@pull pull Bot merged commit af57390 into Reality2byte:main Nov 12, 2025
5 of 15 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants