Skip to content

refactor: migrate all Ledger paths to useHardwareWallet#26970

Merged
mathieuartu merged 86 commits into
mainfrom
feat/hw-overhaul-ledger
Mar 20, 2026
Merged

refactor: migrate all Ledger paths to useHardwareWallet#26970
mathieuartu merged 86 commits into
mainfrom
feat/hw-overhaul-ledger

Conversation

@mathieuartu
Copy link
Copy Markdown
Contributor

@mathieuartu mathieuartu commented Mar 4, 2026

Description

This PR enables redesigned HW wallet flows for Ledger.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: Verify new Ledger flows

  Scenario: user wants to interact with MetaMask and Dapps
    Given user has a Ledger device at hand

    When user wants to either create an account, send, swap or bridge, or even interact with dapps using their Ledger account
    Then user sees the new Ledger flow, and is guided through all steps to get their device ready and confirm the interaction

Screenshots/Recordings

Before

After

dapp-flow.mov
Ledger-select-account.mov
send-flow.mov
swap-flow.mov

Pre-merge author checklist

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.

Note

Medium Risk
Moderate risk because it rewires Ledger signing/connection flows and modal dismissal logic to the new hardware-wallet provider, which can affect transaction/message approval UX and error handling across navigation paths.

Overview
Migrates Ledger confirmation and signing modals to the unified useHardwareWallet flow: LedgerConfirmationModal now runs a one-shot ensureDeviceReady + showAwaitingConfirmation signing sequence (with optional operationType) and renders no local step UI.

Updates LedgerMessageSignModal and LedgerTransactionModal to remove ReusableModal usage, close via navigation goBack with double-navigation guards, and (for transactions) explicitly reject pending approvals on user rejection.

Refactors LedgerSelectAccount to initialize via useHardwareWallet (setTargetWalletType, ensureDeviceReady), replace the old LedgerConnect/Bluetooth hook path with a loading state + direct account fetch/pagination/unlock calls, and adjusts analytics/model-name derivation accordingly; adds/updates unit tests and removes obsolete step components, styles, and snapshots.

Wraps the app Root in HardwareWalletProvider so the bottom-sheet driven hardware wallet UX is available globally.

Written by Cursor Bugbot for commit d126e19. This will update automatically on new commits. Configure here.

@mathieuartu mathieuartu self-assigned this Mar 4, 2026
@mathieuartu mathieuartu requested review from a team as code owners March 4, 2026 09:28
@mathieuartu mathieuartu added the team-accounts-framework Accounts team label Mar 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 4, 2026

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.

Comment thread app/components/UI/LedgerModals/LedgerMessageSignModal.tsx
Comment thread app/components/UI/LedgerModals/LedgerConfirmationModal.tsx
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 19, 2026
Copy link
Copy Markdown
Member

@cortisiko cortisiko left a comment

Choose a reason for hiding this comment

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

signing off from a QA perspective 🌮 🌮

OGPoyraz
OGPoyraz previously approved these changes Mar 20, 2026
Copy link
Copy Markdown
Member

@OGPoyraz OGPoyraz left a comment

Choose a reason for hiding this comment

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

Confirmation changes LGTM

Comment thread app/components/Views/confirmations/hooks/useConfirmActions.ts
OGPoyraz
OGPoyraz previously approved these changes Mar 20, 2026
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 20, 2026
Comment thread app/components/UI/LedgerModals/LedgerTransactionModal.test.tsx
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread app/components/UI/LedgerModals/LedgerTransactionModal.tsx
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeConfirmations, SmokeAccounts, SmokeTrade, SmokeWalletPlatform
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: high
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR is a major refactoring of the Ledger hardware wallet integration across the entire confirmation and account management system.

Key changes and their impact:

  1. useConfirmActions refactored - This hook is used by ALL confirmation types (transactions, signatures, approvals). The Ledger flow is now handled via new useLedgerConfirm + useIsConfirmationFromLedgerAccount hooks instead of the old LedgerContextProvider. Any regression here would break ALL confirmations for Ledger accounts, and potentially affect the general confirmation flow.

  2. LedgerContextProvider deleted - Removed from confirm-component.tsx. This is a breaking change if any component still depends on it (though the PR removes those dependencies).

  3. useTransactionConfirm signature changed - Now accepts an optional options parameter with onError callback. This is used in the Ledger flow and could affect transaction confirmation behavior.

  4. Root/index.tsx - Added HardwareWalletProvider at the app root level. This is a global change that wraps the entire app, and any issues with this provider could affect all app functionality.

  5. LedgerSelectAccount heavily refactored - The account selection flow for Ledger hardware wallets is completely rewritten. This affects the SmokeAccounts tag which covers 'adding QR-based hardware wallet accounts'.

  6. LedgerConfirmationModal rewritten - Now renders null (UI delegated to HardwareWalletBottomSheet). This is a significant behavioral change.

  7. LedgerMessageSignModal and LedgerTransactionModal - Both simplified, removing ReusableModal dependency and using navigation directly.

Why these tags:

  • SmokeConfirmations: Core confirmation hooks (useConfirmActions, useTransactionConfirm) are modified. All confirmation types (transactions, signatures, approvals) go through these hooks. The Ledger path in onConfirm is now completely different.
  • SmokeAccounts: LedgerSelectAccount is heavily refactored - this is the flow for adding QR/hardware wallet accounts, which is explicitly covered by SmokeAccounts.
  • SmokeTrade: Swap/bridge flows go through useTransactionConfirm which has been modified. Per tag description, SmokeTrade requires SmokeConfirmations.
  • SmokeWalletPlatform: The Root provider change (HardwareWalletProvider) wraps the entire app. Any issues could affect wallet platform features.

No Ledger-specific E2E tests exist (hardware requires physical device), but the changes affect the general confirmation infrastructure that all E2E tests exercise.

Performance Test Selection:
The changes are focused on Ledger hardware wallet integration refactoring - replacing context providers with hooks and restructuring the signing flow. While HardwareWalletProvider is added at the root level, it's a lightweight context provider that only activates for Ledger-specific flows. There are no changes to rendering performance, list components, data loading, or other performance-sensitive areas. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
16 value mismatches detected (expected — fixture represents an existing user).
View details

@mathieuartu mathieuartu enabled auto-merge March 20, 2026 11:12
Copy link
Copy Markdown
Contributor

@tommasini tommasini left a comment

Choose a reason for hiding this comment

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

We need to review the fact that the providers are not wrapped by the error boundary

@mathieuartu mathieuartu added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit 4e179e0 Mar 20, 2026
104 of 105 checks passed
@mathieuartu mathieuartu deleted the feat/hw-overhaul-ledger branch March 20, 2026 12:00
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 20, 2026
@metamaskbot metamaskbot added the release-7.72.0 Issue or pull request that will be included in release 7.72.0 label Mar 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.72.0 Issue or pull request that will be included in release 7.72.0 risk-high Extensive testing required · High bug introduction risk size-XL team-accounts-framework Accounts team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants