feat: implement DMK bridge handler - #45558
Conversation
✨ Files requiring CODEOWNER review ✨🔑 @MetaMask/accounts-engineers (2 files, +1576 -0)
|
Builds ready [c331259]
⚡ Performance Benchmarks (Total: 🟢 10 pass · 🟡 10 warn · 🔴 4 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [74dc5a5]
⚡ Performance Benchmarks (Total: 🟢 2 pass · 🟡 7 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [39810b7]
⚡ Performance Benchmarks (Total: 🟢 11 pass · 🟡 9 warn · 🔴 3 fail)
Bundle size diffs [🚀 Bundle size reduced!]
|
Builds ready [8afb992]
⚡ Performance Benchmarks (Total: 🟢 13 pass · 🟡 9 warn · 🔴 2 fail)
Bundle size diffs [🚀 Bundle size reduced!]
|
Builds ready [23adfa0]
⚡ Performance Benchmarks (Total: 🟢 12 pass · 🟡 9 warn · 🔴 3 fail)
Bundle size diffs [🚀 Bundle size reduced!]
|
Builds ready [23adfa0]
⚡ Performance Benchmarks (Total: 🟢 12 pass · 🟡 9 warn · 🔴 3 fail)
Bundle size diffs [🚀 Bundle size reduced!]
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ffa811e. Configure here.
|
Builds ready [ffa811e]
⚡ Performance Benchmarks (Total: 🟢 13 pass · 🟡 7 warn · 🔴 4 fail)
Bundle size diffs
|




Description
This is PR 4 of 5 of the DMK. It introduces the full
LedgerDmkBridgeHandler— DMK session lifecycle, WebHID transport wrapper (listenToAvailableDevices(), since the offscreen document has no user gesture forrequestDevice()), device discovery with timeout, action routing incl. EIP-7702signDelegationAuthorization, and structured error mapping — as a new, unwired module plus its unit tests.Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/MUL-2133
Manual testing steps
N/A
Screenshots/Recordings
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches hardware-wallet connection and signing flows, but the handler is not production-wired yet, limiting immediate user impact; lifecycle race handling is complex and will matter once integrated.
Overview
Adds
LedgerDmkBridgeHandleras a new offscreen Ledger implementation backed byLedgerDmkBridge, plus a large Jest suite. The module is not wired into the extension bundle yet (only tests import it), so DMK/LavaMoat policy work is deferred to a follow-up.The handler introduces an offscreen WebHID transport wrapper that routes discovery through
listenToAvailableDevices()/ permitted devices instead ofrequestDevice(), with discovery timeout andHardwareWalletErrornormalization. It caches a single bridge withbridgeGeneration/tearDownBridge()vsdestroy()semantics so disconnect/replug keeps HID listeners while hot-swap cleans them up, and routes standard Ledger actions (keys, tx, personal message, typed data) with param validation and serialized errors overchrome.runtimemessages.Note:
LedgerAction.signDelegationAuthorizationis not implemented here; callers get an unknown-action error (covered by tests), which differs from the PR description’s mention of EIP-7702 support.Reviewed by Cursor Bugbot for commit 8afb992. Bugbot is set up for automated code reviews on this repo. Configure here.