feat: enable hardware wallet error management for swaps.#39985
feat: enable hardware wallet error management for swaps.#39985montelaidev merged 21 commits intomainfrom
Conversation
|
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. |
✨ Files requiring CODEOWNER review ✨🔄 @MetaMask/swaps-engineers (6 files, +243 -22)
|
d4bc609 to
c96d2e3
Compare
…ement-12' into feat/hardware-wallet-state-management-13
Builds ready [e2fd836]
UI Startup Metrics (1375 ± 99 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
|
…state-management-13
Builds ready [eb61081]
UI Startup Metrics (1363 ± 95 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| const keyringType = fromAccount?.metadata?.keyring?.type; | ||
| const detectedWalletType = | ||
| keyringTypeToHardwareWalletType(keyringType ?? '') ?? | ||
| HardwareWalletType.Ledger; |
There was a problem hiding this comment.
Unknown keyring type silently defaults to Ledger wallet
Medium Severity
When keyringTypeToHardwareWalletType returns null (unrecognized or missing keyring type), the fallback ?? HardwareWalletType.Ledger silently treats the account as a Ledger device. For non-Ledger hardware wallets with an unrecognized keyring type, this causes the wrong hardware wallet error flow to execute, potentially showing Ledger-specific error messages and connection steps to Trezor, Lattice, or QR wallet users.
Builds ready [0c34fb4]
UI Startup Metrics (1398 ± 115 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| import { createSentryError } from '../../shared/modules/error'; | ||
| import { | ||
| toHardwareWalletError, | ||
| // eslint-disable-next-line import/no-restricted-paths |


Description
This is the 12th pr to enable the usage of hardware wallet error management for swaps. It manages the connection lifecycle, permission handling, error states, and provides a clean interface for UI components to interact with hardware wallets.
Changelog
CHANGELOG entry: Enable hardware wallet error management for the swaps flow.
Related issues
Related to: https://consensyssoftware.atlassian.net/browse/MUL-1299?atlOrigin=eyJpIjoiZWZlYjE4M2NiOWVmNDk0N2I3MzA4MzMzZTg2M2U1YzYiLCJwIjoiaiJ9
Manual testing steps
Screenshots/Recordings
Before
After
Dapp interaction
Screen.Recording.2026-02-11.at.20.45.31.mov
Send
Screen.Recording.2026-02-11.at.10.00.29.AM.mov
Swap/Bridge
Screen.Recording.2026-02-11.at.10.01.58.AM.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches core approval resolution/RPC error serialization and changes the bridge submission gating logic, which could affect transaction confirmation and error handling paths for hardware wallet users.
Overview
Adds hardware-wallet-aware approval resolution by normalizing
resolvePendingApprovaloptions, stripping non-ApprovalController fields, and converting hardware wallet SDK errors into serializedJsonRpcErrorinternal errors (plus a newapproveHardwareWalletTransactionhelper exposed via controller actions).Updates the Bridge/Swap CTA to gate submission on
ensureDeviceReady, display a wallet-specific "Connect " label, and avoid state updates after unmount; bridge submission now detects user-rejection via structured hardware wallet RPC error data instead of string matching.Wraps the app in
HardwareWalletErrorProvider, adds the newconnectHardwareDevicei18n string, and extends/adjusts unit tests and background action tests for the new hardware-wallet flows and background methods (getAppNameAndVersion,getLedgerPublicKey).Written by Cursor Bugbot for commit 0c34fb4. This will update automatically on new commits. Configure here.