Skip to content

feat: hw signing tracker#43302

Open
montelaidev wants to merge 9 commits into
mainfrom
feat/mul-1717-4
Open

feat: hw signing tracker#43302
montelaidev wants to merge 9 commits into
mainfrom
feat/mul-1717-4

Conversation

@montelaidev

@montelaidev montelaidev commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces a new hardware wallet signing tracker hook and improves retry logic for sequential hardware wallet signing.

Key changes:

  1. New useHwSignTracker hook - A comprehensive tracker that subscribes to TransactionController events to monitor hardware wallet signing progress for bridge/swap transactions. It supports both batch mode (STX enabled, keyed by batchId) and sequential mode (STX disabled, keyed by tx ID), and provides a cancelCurrentBatch function to abort in-flight signing.
  2. Smart retry for sequential signing - Enhanced useHwSwapSubmission with a firstSignatureDoneRef that allows retrying failed trades without re-signing the approval when it's already confirmed on-chain. The ref tracks whether the first signature (approval) was completed and is reset when a new requestId is detected.
  3. Activity status fix - Fixed the bridge activity status logic to correctly handle same-chain swaps that can leave bridge status pending after the local transaction confirms. This prevents incorrect "pending" states for completed same-chain transactions.

Changelog

CHANGELOG entry: null

Related issues

Related to: https://consensyssoftware.atlassian.net/browse/MUL-1717

Manual testing steps

Not applicable

Screenshots/Recordings

Not applicable

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Touches hardware-wallet swap submission and transaction abort/state-machine events; behavior is complex but isolated to new hook + retry path and heavily unit-tested, with UI not yet wired per PR notes.

Overview
Adds useHwSignTracker, which listens to TransactionController events for bridge/swap HW flows and drives the hardware-wallet signature state machine (FirstSignatureSubmitted, TransactionSubmitted, reject/fail). It supports batch tracking (batchId, STX-style) and sequential tracking (per tx id), filters stale batches/retries via retryGenerationRef, and exposes cancelCurrentBatch to call abortTransactionSigning with guarded cleanup.

useHwSwapSubmission gains optional firstSignatureDoneRef: on retrySubmission, approval is omitted from the submitted quote when the first signature is already done; the ref resets when the locked quote requestId changes. The hook is exported from the hardware-wallets index with types. Large unit test coverage accompanies both areas.

Reviewed by Cursor Bugbot for commit 17043d1. Bugbot is set up for automated code reviews on this repo. Configure here.

@montelaidev montelaidev self-assigned this Jun 8, 2026
@montelaidev montelaidev requested a review from a team as a code owner June 8, 2026 09:21
@montelaidev montelaidev added the team-accounts-framework Accounts team label Jun 8, 2026
@github-actions

github-actions Bot commented Jun 8, 2026

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

mm-token-exchange-service Bot commented Jun 8, 2026

Copy link
Copy Markdown

✨ Files requiring CODEOWNER review ✨

🔑 @MetaMask/accounts-engineers (6 files, +2016 -2)
  • 📁 ui/
    • 📁 hooks/
      • 📁 hardware-wallets/
        • 📄 index.ts +5 -0
        • 📄 useHwSignTracker.test.ts +1247 -0
        • 📄 useHwSignTracker.ts +578 -0
        • 📄 useHwSwapSubmission.test.ts +169 -0
        • 📄 useHwSwapSubmission.ts +16 -2
        • 📄 useHwSwapSubmission.types.ts +1 -0

Comment thread ui/hooks/hardware-wallets/useHwSignTracker.ts
Comment thread ui/hooks/hardware-wallets/useHwSignTracker.ts
Comment thread ui/hooks/hardware-wallets/useHwSignTracker.ts Outdated
Comment thread ui/hooks/hardware-wallets/useHwSignTracker.ts
Comment thread ui/hooks/hardware-wallets/useHwSignTracker.ts Outdated
Comment thread ui/hooks/hardware-wallets/useHwSignTracker.ts
Comment thread ui/hooks/hardware-wallets/useHwSignTracker.ts
@metamaskbotv2

metamaskbotv2 Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor
Builds ready [664a41e]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 20 pass · 🟡 5 warn · 🔴 0 fail)

Baseline (latest main): 51036da | Date: 5/2/2026 | Pipeline: 27131349134 | Baseline logs

Interaction Benchmarks · Samples: 5
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
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: -72%
  • loadNewAccount/total: -72%
  • bridgeUserActions/bridge_load_page: -73%
  • bridgeUserActions/bridge_load_asset_picker: -64%
  • bridgeUserActions/bridge_search_token: -32%
  • bridgeUserActions/total: -46%
  • loadNewAccount/load_new_account: -54%
  • loadNewAccount/total: -54%
  • bridgeUserActions/bridge_search_token: -27%
  • bridgeUserActions/total: -17%

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

  • 🟡 bridgeUserActions/INP: p75 208ms
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
startupPowerUserHome
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/uiStartup: -25%
  • startupStandardHome/load: -28%
  • startupStandardHome/domContentLoaded: -28%
  • startupStandardHome/domInteractive: -39%
  • startupStandardHome/firstPaint: -11%
  • startupStandardHome/backgroundConnect: -16%
  • startupStandardHome/loadScripts: -28%
  • startupStandardHome/setupStore: -14%
  • startupStandardHome/numNetworkReqs: -67%
  • startupPowerUserHome/uiStartup: -16%
  • startupPowerUserHome/load: -18%
  • startupPowerUserHome/domContentLoaded: -17%
  • startupPowerUserHome/domInteractive: -42%
  • startupPowerUserHome/firstPaint: -30%
  • startupPowerUserHome/firstReactRender: +21%
  • startupPowerUserHome/loadScripts: -18%
  • startupPowerUserHome/setupStore: +24%
  • startupPowerUserHome/numNetworkReqs: -72%
  • startupStandardHome/domInteractive: -47%
  • startupStandardHome/backgroundConnect: +12%
  • startupStandardHome/firstReactRender: +39%
  • startupStandardHome/initialActions: +20%
  • startupStandardHome/setupStore: -51%
  • startupStandardHome/numNetworkReqs: -37%
  • startupPowerUserHome/uiStartup: -27%
  • startupPowerUserHome/domInteractive: -72%
  • startupPowerUserHome/backgroundConnect: -66%
  • startupPowerUserHome/firstReactRender: +33%
  • startupPowerUserHome/setupStore: -76%
  • startupPowerUserHome/numNetworkReqs: -72%

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

  • 🟡 startupPowerUserHome/INP: p75 432ms
  • 🟡 startupPowerUserHome/LCP: p75 3.0s
User Journey Benchmarks · Samples: 5 · mock API
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]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/importWalletToSocialScreen: +10%
  • onboardingImportWallet/srpButtonToSrpForm: -63%
  • onboardingImportWallet/pwFormToMetricsScreen: +532%
  • onboardingImportWallet/metricsToWalletReadyScreen: -24%
  • onboardingImportWallet/doneButtonToHomeScreen: -74%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: -12%
  • onboardingImportWallet/total: -42%
  • onboardingNewWallet/srpButtonToPwForm: -77%
  • onboardingNewWallet/createPwToRecoveryScreen: +1036%
  • onboardingNewWallet/skipBackupToMetricsScreen: -66%
  • onboardingNewWallet/agreeButtonToOnboardingSuccess: +22%
  • onboardingNewWallet/doneButtonToAssetList: -38%
  • onboardingNewWallet/total: -29%
  • assetDetails/assetClickToPriceChart: -58%
  • assetDetails/total: -58%
  • solanaAssetDetails/assetClickToPriceChart: -72%
  • solanaAssetDetails/total: -72%
  • importSrpHome/loginToHomeScreen: -42%
  • importSrpHome/openAccountMenuAfterLogin: -73%
  • importSrpHome/homeAfterImportWithNewWallet: -89%
  • importSrpHome/total: -83%

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

  • 🟡 sendTransactions/INP: p75 208ms
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 5 Bytes (0%)
  • common: 20 Bytes (0%)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 ddbd5ea. Configure here.

Comment thread ui/hooks/hardware-wallets/useHwSignTracker.ts Outdated
@metamaskbotv2

metamaskbotv2 Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor
Builds ready [17043d1]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 19 pass · 🟡 6 warn · 🔴 0 fail)

Baseline (latest main): 51036da | Date: 5/2/2026 | Pipeline: 27141287877 | Baseline logs

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: -66%
  • loadNewAccount/total: -66%
  • bridgeUserActions/bridge_load_page: -72%
  • bridgeUserActions/bridge_load_asset_picker: -50%
  • bridgeUserActions/bridge_search_token: -28%
  • bridgeUserActions/total: -41%
  • loadNewAccount/load_new_account: +93%
  • loadNewAccount/total: +93%
  • bridgeUserActions/bridge_load_page: -12%
  • bridgeUserActions/bridge_load_asset_picker: -37%
  • bridgeUserActions/bridge_search_token: -30%
  • bridgeUserActions/total: -27%

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

  • 🟡 loadNewAccount/FCP: p75 1.9s
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
startupPowerUserHome
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/uiStartup: -26%
  • startupStandardHome/load: -29%
  • startupStandardHome/domContentLoaded: -29%
  • startupStandardHome/domInteractive: -37%
  • startupStandardHome/firstPaint: -17%
  • startupStandardHome/backgroundConnect: -17%
  • startupStandardHome/loadScripts: -28%
  • startupStandardHome/setupStore: -14%
  • startupStandardHome/numNetworkReqs: -67%
  • startupPowerUserHome/uiStartup: -19%
  • startupPowerUserHome/load: -22%
  • startupPowerUserHome/domContentLoaded: -22%
  • startupPowerUserHome/domInteractive: -46%
  • startupPowerUserHome/firstPaint: -33%
  • startupPowerUserHome/firstReactRender: +17%
  • startupPowerUserHome/loadScripts: -22%
  • startupPowerUserHome/numNetworkReqs: -71%
  • startupStandardHome/domInteractive: -38%
  • startupStandardHome/backgroundConnect: +18%
  • startupStandardHome/firstReactRender: +44%
  • startupStandardHome/initialActions: +20%
  • startupStandardHome/setupStore: -51%
  • startupStandardHome/numNetworkReqs: -37%
  • startupPowerUserHome/uiStartup: -23%
  • startupPowerUserHome/domInteractive: -72%
  • startupPowerUserHome/backgroundConnect: -65%
  • startupPowerUserHome/firstReactRender: +37%
  • startupPowerUserHome/setupStore: -72%
  • startupPowerUserHome/numNetworkReqs: -72%

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

  • 🟡 startupPowerUserHome/INP: p75 408ms
  • 🟡 startupPowerUserHome/INP: p75 224ms
  • 🟡 startupPowerUserHome/LCP: p75 2.9s
User Journey Benchmarks · Samples: 5 · mock API
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]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/srpButtonToSrpForm: -63%
  • onboardingImportWallet/pwFormToMetricsScreen: +539%
  • onboardingImportWallet/metricsToWalletReadyScreen: -29%
  • onboardingImportWallet/doneButtonToHomeScreen: -66%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: -15%
  • onboardingImportWallet/total: -43%
  • onboardingNewWallet/srpButtonToPwForm: -77%
  • onboardingNewWallet/createPwToRecoveryScreen: +1040%
  • onboardingNewWallet/skipBackupToMetricsScreen: -67%
  • onboardingNewWallet/agreeButtonToOnboardingSuccess: -20%
  • assetDetails/assetClickToPriceChart: -65%
  • assetDetails/total: -65%
  • solanaAssetDetails/assetClickToPriceChart: -78%
  • solanaAssetDetails/total: -78%
  • importSrpHome/loginToHomeScreen: -47%
  • importSrpHome/openAccountMenuAfterLogin: -77%
  • importSrpHome/homeAfterImportWithNewWallet: -83%
  • importSrpHome/total: -78%

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

  • 🟡 sendTransactions/INP: p75 256ms
  • 🟡 importSrpHome/FCP: p75 1.9s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • dappPageLoad/pageLoadTime: +17%
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -336.71 KiB (-5.83%)
  • ui: -414 Bytes (0%)
  • common: -32.8 KiB (-0.27%)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant