Skip to content

feat(hw): add QR scan error handling#29388

Merged
montelaidev merged 17 commits into
mainfrom
feat/mul-1665-qr-scan-errors
May 4, 2026
Merged

feat(hw): add QR scan error handling#29388
montelaidev merged 17 commits into
mainfrom
feat/mul-1665-qr-scan-errors

Conversation

@montelaidev

@montelaidev montelaidev commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Description

Adds shared QR hardware scan error types and updates the animated QR scanner to classify non-UR payloads, decode failures, wrong UR types, and scan exceptions. This gives QR hardware flows user-facing retry/learn-more states and structured analytics instead of falling back to generic unknown QR errors.

This is PR 1 of 2. PR 2 stacks on this branch and wires the scanner errors into the connection/signing flows.

Changelog

CHANGELOG entry: Improved QR hardware wallet scan error messages and retry handling

Related issues

Refs: MUL-1665

Manual testing steps

Feature: QR hardware scan errors

  Scenario: user scans an unsupported QR code while pairing
    Given the user is pairing a QR-based hardware wallet
    When the user scans a QR code that is not in UR format
    Then the scanner shows a QR hardware scan error with Learn more and Try again actions

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.

Made with Cursor


Note

Medium Risk
Updates QR hardware scanning flow to gate scanning on UR format and introduces new error types/UI states; bugs here could block pairing/signing scans or skew hardware wallet error analytics.

Overview
Adds structured QR hardware scan errors and inline recovery UI. AnimatedQRScanner now classifies non-UR payloads, UR decode failures, wrong UR types, and scan exceptions into QRHardwareScanError objects, shows a dedicated error screen with Learn more and Try again, and prevents repeated error handling until reset (with optional onQRHardwareScanError and onModalHideComplete callbacks).

Improves analytics and error plumbing. Hardware wallet error metrics now include is_ur_format plus error_category/received_ur_type where relevant, adds new localized copy for QR scan errors and camera-permission-denied mapping (RecoveryAction.OPEN_SETTINGS), and introduces getReplacementGasFeeParams to normalize replacement transaction gas params (legacy vs EIP-1559) with tests.

Reviewed by Cursor Bugbot for commit c49a680. Bugbot is set up for automated code reviews on this repo. Configure here.

@montelaidev montelaidev self-assigned this Apr 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added size-XL and removed size-L labels Apr 28, 2026
@montelaidev montelaidev marked this pull request as ready for review April 28, 2026 08:12
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.tsx
Comment thread app/core/HardwareWallet/errors/qrScan.ts
Comment thread app/core/HardwareWallet/errors/qrScan.ts Outdated
Comment thread app/core/HardwareWallet/errors/qrScan.ts
Comment thread app/core/HardwareWallet/errors/qrScan.ts Outdated
Comment thread app/core/HardwareWallet/errors/qrScan.ts Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.tsx
@montelaidev montelaidev requested a review from ccharly April 29, 2026 09:07
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx Outdated
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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.

There are 2 total unresolved issues (including 1 from previous review).

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.

Reviewed by Cursor Bugbot for commit 77c9162. Configure here.

Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx Outdated
montelaidev and others added 2 commits April 30, 2026 08:23
Co-authored-by: Monte Lai <montelaidev@users.noreply.github.com>
ccharly
ccharly previously approved these changes Apr 30, 2026

@ccharly ccharly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! I left 2 comments about "error anylitics/metrics" cause I'm not sure I understood quite well this part. Though, some tests were already named that way, so that might be ok but if you can double-check that's better 😄

Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx
Comment thread app/components/UI/QRHardware/AnimatedQRScanner.test.tsx
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes are focused on QR Hardware Wallet error handling and the AnimatedQRScanner UI component:

  1. New QR scan error infrastructure (qrScan.ts, qrHardwareScanError.ts, qrScan.types.ts): New error types and factory functions for QR hardware wallet scanning flows. These are new files with no existing E2E test coverage found.

  2. AnimatedQRScanner.tsx: Significant UI refactor - the scanner now shows inline error states with 'Learn more' and 'Try again' buttons instead of just calling onScanError. New props added (onQRHardwareScanError, onModalHideComplete). This changes the UX flow for QR hardware wallet pairing and signing.

  3. Error mappings update: Added PermissionCameraDenied error with new OPEN_SETTINGS recovery action.

  4. transactionReplacementParams.ts: New utility for gas fee normalization in hardware wallet transaction replacement - currently only referenced in its test file.

  5. Localization: New strings for QR scan errors and camera permission.

SmokeAccounts is selected because its description explicitly covers 'adding QR-based hardware wallet accounts', which is the primary user flow affected by the AnimatedQRScanner changes. The QR scanner is used during the hardware wallet pairing flow (ConnectQRHardware) and signing flow (QRSigningDetails), both of which are part of the hardware wallet account management experience.

No other tags are directly impacted - the changes are isolated to hardware wallet QR scanning infrastructure and don't touch confirmations, network management, browser, snaps, or other flows.

Confidence is moderate (72) because no dedicated E2E tests for QR hardware wallet scanning were found in the test suite, so coverage validation is limited to the broader SmokeAccounts suite.

Performance Test Selection:
The changes are focused on error handling logic and UI state management within the QR scanner modal. There are no changes to rendering-heavy components, data loading, state management controllers, or critical performance paths. The AnimatedQRScanner changes add error state rendering but this is a modal component that only appears during hardware wallet flows, not in any performance-critical paths like account list rendering, app launch, or asset loading.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented May 4, 2026

Copy link
Copy Markdown

@montelaidev montelaidev added this pull request to the merge queue May 4, 2026
Merged via the queue into main with commit abe3349 May 4, 2026
294 of 301 checks passed
@montelaidev montelaidev deleted the feat/mul-1665-qr-scan-errors branch May 4, 2026 14:34
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.77.0 Issue or pull request that will be included in release 7.77.0 label May 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.77.0 Issue or pull request that will be included in release 7.77.0 size-XL team-accounts-framework Accounts team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants