Skip to content

refactor: migrate LedgerSelectAccount to useHardwareWallet#26864

Open
mathieuartu wants to merge 17 commits into
mainfrom
feat/hw-overhaul-5
Open

refactor: migrate LedgerSelectAccount to useHardwareWallet#26864
mathieuartu wants to merge 17 commits into
mainfrom
feat/hw-overhaul-5

Conversation

@mathieuartu
Copy link
Copy Markdown
Contributor

@mathieuartu mathieuartu commented Mar 3, 2026

Description

Wires the new hardware wallet management system to the "Create new Ledger account" flow.
This PR is part of the hardware wallet connection & error management overhaul.

Reference feature branch: #25519

Changelog

CHANGELOG entry: refactor: migrate LedgerSelectAccount to useHardwareWallet

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MUL-1497

Manual testing steps

Feature: Ledger account creation redesign

  Scenario: user wants to add a new ledger account
    Given the user is on the home page

    When user taps the account menu, then taps "add wallet", then "add hardware wallet", and then "Ledger"
    Then user sees the new connection flow, and is guided through all steps to get to the account selection view

Screenshots/Recordings

Before

After

Enregistrement.de.l.ecran.2026-03-03.a.10.15.14.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
Updates the Ledger add-account flow to rely on the new hardware wallet provider and readiness gating, which can affect device connection, navigation, and error handling across a key user path. Also wraps the app in HardwareWalletProvider, introducing new global context dependency at the root.

Overview
LedgerSelectAccount is refactored to use useHardwareWallet instead of LedgerConnect/useLedgerBluetooth. On mount it sets the target wallet type, calls ensureDeviceReady, and automatically fetches the first page of Ledger accounts; if readiness fails/cancels it navigates back, and while waiting it shows a new loading state.

Pagination, HD-path refetch, and unlock now call Ledger operations directly with simpler error handling (inline error messages + blocking modal during operations), add a guard to prevent double-unlock, and re-check ensureDeviceReady(deviceId) before unlocking. Analytics tracking is updated to fire once when accounts load and uses the sanitized selected device name for device_model.

App root is updated to mount HardwareWalletProvider around App, and the LedgerSelectAccount test suite is rewritten to mock useHardwareWallet and validate the new readiness/loading/error behaviors.

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

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

github-actions Bot commented Mar 3, 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/Views/LedgerSelectAccount/index.tsx Outdated
Comment thread app/components/Views/LedgerSelectAccount/index.tsx Outdated
Comment thread app/components/Views/LedgerSelectAccount/index.tsx Outdated
@mathieuartu mathieuartu changed the title feat: replace legacy with new hw system on Ledger create account flow feat: replace legacy "Ledger create account flow" with new hw system Mar 3, 2026
Comment thread app/components/Views/LedgerSelectAccount/index.tsx
Comment thread app/components/Views/LedgerSelectAccount/index.test.tsx Outdated
Comment thread app/components/Views/LedgerSelectAccount/index.styles.ts
Comment thread app/components/Views/LedgerSelectAccount/index.tsx
@mathieuartu mathieuartu changed the title feat: replace legacy "Ledger create account flow" with new hw system refactor: migrate LedgerSelectAccount to useHardwareWallet Mar 4, 2026
Comment thread app/components/Views/LedgerSelectAccount/index.tsx
Comment thread app/components/Views/LedgerSelectAccount/index.tsx
Comment thread app/components/Views/LedgerSelectAccount/index.test.tsx Outdated
Comment thread app/components/Views/LedgerSelectAccount/index.tsx
Comment thread app/components/Views/LedgerSelectAccount/index.tsx
montelaidev
montelaidev previously approved these changes Mar 6, 2026
Comment thread app/components/Views/LedgerSelectAccount/index.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.

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/Views/LedgerSelectAccount/index.tsx
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 9, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 78%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR significantly refactors the LedgerSelectAccount flow and introduces a new HardwareWalletProvider at the app root. The Ledger account selection screen now relies on useHardwareWallet (ensureDeviceReady, deviceSelection, setTargetWalletType) instead of the previous useLedgerBluetooth + LedgerConnect flow. It also changes unlock behavior, error handling, pagination calls, and initial device readiness logic.

These changes directly impact hardware wallet account import flows, which are covered under SmokeAccounts (QR-based hardware wallet accounts, account creation/import flows, account selector integration). The refactor affects how Ledger accounts are discovered, unlocked, and added to the wallet, and modifies navigation behavior (pop(2), goBack on cancel), which can impact multi-account workflows.

The Root component now wraps the entire app in HardwareWalletProvider, which changes global context initialization and could affect any flow that depends on hardware wallet context. Although most E2E tests do not use hardware wallets, SmokeAccounts is the only tag that explicitly covers hardware wallet account flows and account management integration.

No changes were made to confirmations, swaps, networks, perps, predictions, snaps, or multi-chain APIs. Therefore, additional tags (e.g., SmokeConfirmations, SmokeTrade, SmokeNetworkExpansion, FlaskBuildTests) are not required.

Given the architectural change (new provider at root + async initialization logic in LedgerSelectAccount), risk is medium and focused on account/hardware wallet flows.

Performance Test Selection:
Changes are limited to hardware wallet connection flow, async device readiness, and UI state handling for Ledger account selection. There are no modifications to large lists, asset loading, onboarding, login, swaps, predictions, perps, or app launch timing logic. The new provider wrapper is lightweight context wiring and unlikely to affect measurable performance metrics. Therefore, no performance tests are required.

View GitHub Actions results

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 9, 2026

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

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 9, 2026

@gantunesr gantunesr added the DO-NOT-MERGE Pull requests that should not be merged label Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DO-NOT-MERGE Pull requests that should not be merged size-XL team-accounts-framework Accounts team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants