feat: add DMK error tag mappings and resolver#597
Open
montelaidev wants to merge 6 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/.
Contributor
Author
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
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
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 sharedHardwareWalletErrortypes instead of generic APDU/TransportStatusErrorwrappers.@metamask/hw-wallet-sdkaddsDMK_ERROR_MAPPINGS(fullErrorMapping+ user messages), derivedDMK_ERROR_TAG_MAPPINGS, message fallback patternsDMK_MESSAGE_PATTERNS, andgetDmkErrorFromTag, all re-exported from the package entry.keyring-eth-ledger-bridgeaddscreateDmkErrorand wires tag resolution intotranslateDmkError(_tagfirst, then hexDeviceExchangeError, then0x6f00fallback) andLedgerDmkBridge.#toErrorsosendCommand/ device-action failures get the right codes. The bridge depends on@metamask/hw-wallet-sdk^0.11.0. Bridge tests calldestroy()inafterEachto 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.