Skip to content

[pull] main from MetaMask:main#564

Merged
pull[bot] merged 1 commit into
Reality2byte:mainfrom
MetaMask:main
Mar 2, 2026
Merged

[pull] main from MetaMask:main#564
pull[bot] merged 1 commit into
Reality2byte:mainfrom
MetaMask:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Mar 2, 2026

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 : )

#26484)

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

**Reason for the change:**
The `SwitchAccountTypeModal` component was using the `useRoute()` hook
internally to access route parameters. This approach has several
drawbacks:
- Tightly couples the component to the navigation context
- Makes type derivation less explicit (required unsafe type assertion:
`(route?.params as { address: Hex })?.address`)
- Reduces testability as tests needed to mock the `useRoute` hook
globally
- No graceful handling when address parameter is missing

**Improvement/Solution:**
- Refactored `SwitchAccountTypeModal` to receive `route` as a prop
instead of calling `useRoute()` internally
- Added proper TypeScript interfaces:
`SwitchAccountTypeModalRouteParams`, `SwitchAccountTypeModalParamList`,
and `SwitchAccountTypeModalProps`
- Added fallback UI with "No account selected" message when no address
is available from route params
- Added missing `key` prop to `AccountNetworkRow` component in the map
function (fixes React key warning)
- Significantly expanded test coverage:
- Organized tests into logical describe blocks (`rendering`, `route
params handling`, `navigation`, `hook integration`)
  - Added tests for empty network list, multiple networks, loading state
  - Added tests for address matching/non-matching scenarios
  - Added test for hook integration to verify correct address is passed

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes: N/A (internal refactoring)

## **Manual testing steps**

```gherkin
Feature: Switch Account Type Modal (EIP-7702)

  Scenario: User opens switch account type modal with valid address
    Given the user has an account upgraded to a smart account on a supported network
    And the user is viewing account details

    When user taps on "Switch account type"
    Then user should see the Switch Account Type modal
    And user should see their account name
    And user should see the list of networks where the account is upgraded
    And each network row should show "Smart account" status

  Scenario: User switches back to regular account
    Given the user is viewing the Switch Account Type modal
    And the account is currently a smart account on Sepolia

    When user taps "Switch back" on the Sepolia row
    Then the account should be downgraded to a regular account on Sepolia

  Scenario: User navigates back from modal
    Given the user is viewing the Switch Account Type modal

    When user taps the back button
    Then the modal should close
    And user should return to the previous screen

  Scenario: Modal shows loading state while fetching network data
    Given the network data is still being fetched

    When user opens the Switch Account Type modal
    Then user should see a loading spinner
    And the network list should not be visible
```

## **Screenshots/Recordings**

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

### **Before**

N/A - No visual changes (except for new fallback state)

### **After**

N/A - No visual changes (except for new fallback state when no address
is available)

## **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.
@pull pull Bot locked and limited conversation to collaborators Mar 2, 2026
@pull pull Bot added the ⤵️ pull label Mar 2, 2026
@pull pull Bot merged commit 847a6cb into Reality2byte:main Mar 2, 2026
3 of 37 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.

1 participant