feat: add DMK error tag mappings and resolver#597
Open
montelaidev wants to merge 4 commits into
Open
Conversation
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/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-sdkand wires it through the Ledger DMK bridge so connection/session failures surface as typedHardwareWalletErrors instead of generic transport errors.The SDK introduces
DMK_ERROR_MAPPINGS(full severity/category/userMessage), derivedDMK_ERROR_TAG_MAPPINGS, message-pattern fallbacks (DMK_MESSAGE_PATTERNS), andgetDMKErrorFromTagfor parsing DMK’s non-standard_tagfield. These are re-exported from the package entrypoint.In
keyring-eth-ledger-bridge,createDMKErrorbuildsHardwareWalletErrorfrom a DMK tag.translateDmkErrornow resolves_tagfirst (returningHardwareWalletError), then existing hexDeviceExchangeError→TransportStatusErrorbehavior, with_tagwinning when both are present.LedgerDmkBridge.#toErrorapplies the same tag resolution forsendCommandfailures. Tests and changelogs cover the new paths; the bridge bumps@metamask/hw-wallet-sdkto^0.11.0.Reviewed by Cursor Bugbot for commit 1fa477f. Bugbot is set up for automated code reviews on this repo. Configure here.