Skip to content

feat: add DMK error tag mappings and resolver#597

Merged
montelaidev merged 6 commits into
mainfrom
feat/dmk-error-mappings
Jul 16, 2026
Merged

feat: add DMK error tag mappings and resolver#597
montelaidev merged 6 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
Error handling on the Ledger DMK path changes for connection/session failures, which affects what users see and how callers branch on error codes; coverage is broad but misclassification could still slip through for unmapped tags.

Overview
Ledger Device Management Kit failures that expose a _tag (e.g. DeviceSessionNotFound, DeviceLockedError) can now be turned into shared HardwareWalletError types instead of generic APDU/TransportStatusError wrappers.

@metamask/hw-wallet-sdk adds DMK_ERROR_MAPPINGS (full ErrorMapping + user messages), derived DMK_ERROR_TAG_MAPPINGS, message fallback patterns DMK_MESSAGE_PATTERNS, and getDmkErrorFromTag, all re-exported from the package entry.

keyring-eth-ledger-bridge adds createDmkError and wires tag resolution into translateDmkError (_tag first, then hex DeviceExchangeError, then 0x6f00 fallback) and LedgerDmkBridge.#toError so sendCommand / device-action failures get the right codes. The bridge depends on @metamask/hw-wallet-sdk ^0.11.0. Bridge tests call destroy() in afterEach to avoid flaky session-retry timers.

Reviewed by Cursor Bugbot for commit 89c00ee. 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
@montelaidev

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown

Preview builds have been published. See these instructions (from the core monorepo) for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/account-api": "1.1.0-1fa477f",
  "@metamask-previews/hw-wallet-sdk": "0.10.0-1fa477f",
  "@metamask-previews/keyring-api": "23.5.0-1fa477f",
  "@metamask-previews/eth-hd-keyring": "14.1.1-1fa477f",
  "@metamask-previews/eth-ledger-bridge-keyring": "12.3.0-1fa477f",
  "@metamask-previews/eth-money-keyring": "3.0.0-1fa477f",
  "@metamask-previews/eth-qr-keyring": "2.1.0-1fa477f",
  "@metamask-previews/eth-simple-keyring": "12.0.2-1fa477f",
  "@metamask-previews/eth-trezor-keyring": "10.1.1-1fa477f",
  "@metamask-previews/keyring-internal-api": "11.0.1-1fa477f",
  "@metamask-previews/keyring-internal-snap-client": "10.0.5-1fa477f",
  "@metamask-previews/keyring-sdk": "2.2.0-1fa477f",
  "@metamask-previews/eth-snap-keyring": "23.0.1-1fa477f",
  "@metamask-previews/keyring-snap-client": "9.2.0-1fa477f",
  "@metamask-previews/keyring-snap-sdk": "9.2.0-1fa477f",
  "@metamask-previews/keyring-utils": "3.3.1-1fa477f"
}

@montelaidev montelaidev enabled auto-merge July 14, 2026 08:12
mathieuartu
mathieuartu previously approved these changes Jul 15, 2026

@mathieuartu mathieuartu 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.

Looks good!

@montelaidev montelaidev added this pull request to the merge queue Jul 16, 2026
Merged via the queue into main with commit b60bced Jul 16, 2026
40 checks passed
@montelaidev montelaidev deleted the feat/dmk-error-mappings branch July 16, 2026 08:59
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.

2 participants