Skip to content

feat(ledger): wire ledgerDmk flag to offscreen mode switching#43488

Draft
montelaidev wants to merge 1 commit into
feat/ledger-offscreen-routerfrom
feat/ledger-dmk-flag
Draft

feat(ledger): wire ledgerDmk flag to offscreen mode switching#43488
montelaidev wants to merge 1 commit into
feat/ledger-offscreen-routerfrom
feat/ledger-dmk-flag

Conversation

@montelaidev

Copy link
Copy Markdown
Contributor

Description

Adds the ledgerDmk remote feature flag and runtime wiring so the background can tell the offscreen document which Ledger handler mode to use.

PR 2 of 3 (stacked on #43487):

  1. Router + legacy refactor
  2. Feature flag + mode switching (this PR)
  3. Real DMK handler + dependencies

Changes:

  • ENABLE_DMK_FEATURE_FLAG constant, UI selector, and E2E feature-flag registry entry
  • getLedgerMode() on MetaMaskController (merges manifest overrides)
  • Background pushes initial mode and subscribes to flag changes via switchLedgerMode
  • Offscreen listenForModeSwitches() + race-condition guards in the router

DMK handler remains a stub delegating to legacy until PR 3.

Changelog Entry

CHANGELOG entry: null

Related Issues

Fixes: N/A

Manual Testing Steps

  1. Build and load the extension (yarn start or yarn build:test).
  2. With ledgerDmk disabled (default), connect a Ledger and verify signing works via legacy.
  3. In .manifest-overrides.json, set "remoteFeatureFlags": { "ledgerDmk": { "enabled": true, "minimumVersion": "<your-version>", "featureVersion": "<your-version>" } } and reload.
  4. Confirm the offscreen hot-swaps to DMK mode (still legacy behavior until PR 3) without reloading the extension.
  5. Toggle the flag off and confirm it switches back to legacy mode.

Pre-merge Author Checklist

Made with Cursor

Add the ledgerDmk remote feature flag constant, UI selector, and CI registry
entry. Expose getLedgerMode on the controller and push switchLedgerMode events
from the background when the flag changes so the offscreen router can hot-swap
handlers at runtime while DMK still delegates to legacy.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@mm-token-exchange-service

Copy link
Copy Markdown

✨ Files requiring CODEOWNER review ✨

🔑 @MetaMask/accounts-engineers (5 files, +382 -3)
  • 📁 app/
    • 📁 offscreen/
      • 📁 hardware-wallets/
        • 📄 ledger-router.test.ts +158 -0
        • 📄 ledger-router.ts +42 -3
  • 📁 shared/
    • 📁 lib/
      • 📁 hardware-wallets/
        • 📄 feature-flags.ts +20 -0
  • 📁 ui/
    • 📁 selectors/
      • 📁 hardware-wallets/
        • 📄 feature-flags.test.ts +127 -0
        • 📄 feature-flags.ts +35 -0

@metamaskbotv2

metamaskbotv2 Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor
Builds ready [48ec59e]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 18 pass · 🟡 4 warn · 🔴 1 fail)

Baseline (latest main): 99a3b1f | Date: 6/12/2026 | Pipeline: 27404443496 | Baseline logs

Metricschrome-webpackfirefox-webpack
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]

Regressions (🔴 1 failure)

Interaction Benchmarks · Samples: 5
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
🔴 load_new_account
confirmTx
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/load_new_account: +437%
  • loadNewAccount/longTaskCount: -100%
  • loadNewAccount/longTaskTotalDuration: -100%
  • loadNewAccount/longTaskMaxDuration: -100%
  • loadNewAccount/tbt: -100%
  • loadNewAccount/total: +437%
  • loadNewAccount/inp: -17%
  • loadNewAccount/lcp: +337%
  • confirmTx/longTaskCount: -100%
  • confirmTx/longTaskTotalDuration: -100%
  • confirmTx/longTaskMaxDuration: -100%
  • confirmTx/tbt: -100%
  • confirmTx/inp: +45%
  • confirmTx/lcp: +1144%
  • bridgeUserActions/bridge_load_page: +99%
  • bridgeUserActions/bridge_load_asset_picker: +160%
  • bridgeUserActions/longTaskCount: -100%
  • bridgeUserActions/longTaskTotalDuration: -100%
  • bridgeUserActions/longTaskMaxDuration: -100%
  • bridgeUserActions/tbt: -100%
  • bridgeUserActions/total: +186%
  • bridgeUserActions/inp: +23%
  • bridgeUserActions/lcp: +1032%
Startup Benchmarks · Samples: 100
Benchmarkfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]
startupPowerUserHome
[Sentry log · main/release]
🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/domInteractive: +27%
  • startupStandardHome/inp: -23%
  • startupPowerUserHome/domInteractive: +24%
  • startupPowerUserHome/setupStore: -27%
  • startupPowerUserHome/fcp: +16%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 startupPowerUserHome/LCP: p75 2.9s
User Journey Benchmarks · Samples: 5 · mock API 🔴 1
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]
🔴 total
assetDetails
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
solanaAssetDetails
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
importSrpHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
sendTransactions
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
swap
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 assetDetails/FCP: p75 1.9s
  • 🟡 solanaAssetDetails/FCP: p75 1.9s
  • 🟡 sendTransactions/FCP: p75 1.9s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 2.27 KiB (0.03%)
  • ui: -16 Bytes (0%)
  • common: 168 Bytes (0%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template size-L team-accounts-framework Accounts team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant