Skip to content

feat: add DMK error tag mappings and resolver#597

Open
montelaidev wants to merge 4 commits into
mainfrom
feat/dmk-error-mappings
Open

feat: add DMK error tag mappings and resolver#597
montelaidev wants to merge 4 commits into
mainfrom
feat/dmk-error-mappings

Conversation

@montelaidev

@montelaidev montelaidev commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This PR adds new dmk related errors to the @hw-wallet-sdk and used in the ledger keyring.

Examples


Note

Medium Risk
Changes how DMK connection/session errors are classified at signing and transport boundaries; mis-mapped tags could show wrong user-facing messages, but scope is limited to DMK error translation with extensive tests.

Overview
Adds shared Ledger DMK error handling in @metamask/hw-wallet-sdk and wires it through the Ledger DMK bridge so connection/session failures surface as typed HardwareWalletErrors instead of generic transport errors.

The SDK introduces DMK_ERROR_MAPPINGS (full severity/category/userMessage), derived DMK_ERROR_TAG_MAPPINGS, message-pattern fallbacks (DMK_MESSAGE_PATTERNS), and getDMKErrorFromTag for parsing DMK’s non-standard _tag field. These are re-exported from the package entrypoint.

In keyring-eth-ledger-bridge, createDMKError builds HardwareWalletError from a DMK tag. translateDmkError now resolves _tag first (returning HardwareWalletError), then existing hex DeviceExchangeErrorTransportStatusError behavior, with _tag winning when both are present. LedgerDmkBridge.#toError applies the same tag resolution for sendCommand failures. Tests and changelogs cover the new paths; the bridge bumps @metamask/hw-wallet-sdk to ^0.11.0.

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

Add DMK_ERROR_TAG_MAPPINGS, DMK_MESSAGE_PATTERNS, and
getDMKErrorFromTag() to support parsing Ledger Device Management
Kit (DMK) errors by their non-standard _tag property.

These will be consumed by MetaMask Mobile to replace locally-defined
DMK mappings in app/core/HardwareWallet/errors/.
@montelaidev montelaidev self-assigned this Jul 10, 2026
@montelaidev montelaidev added the team-accounts This should be handled by the Accounts Team label Jul 10, 2026
@montelaidev montelaidev requested a review from a team as a code owner July 10, 2026 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-accounts This should be handled by the Accounts Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant