Skip to content

Conversation

@dawnseeker8
Copy link
Contributor

@dawnseeker8 dawnseeker8 commented Nov 21, 2025

Description

This PR fix incorrect transaction approved events log when user reject in hardware wallet, which relative to #18361

Basically this pr override the transactionApproved listener in Transaction-controller-init.ts and check the transactionMetadata return, if the metadata status is failed or rejected, then we should log transaction rejected event instead, which mean user reject in hardware wallet side which cause the transaction rejected.

This PR fix the incorrect

Open in GitHub Codespaces

Changelog

CHANGELOG entry: Override Transaction Approved event listener to handle hardware wallet user rejected event.

Related issues

Fixes: #18361
https://consensyssoftware.atlassian.net/browse/HWB-76

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

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

Ensure transactionApproved events with failed or rejected status invoke handleTransactionRejected instead of handleTransactionApproved, fixing hardware wallet rejection logging.

  • Confirmations controller (app/scripts/controller-init/confirmations/transaction-controller-init.ts):
    • Event handling: Replace direct handleTransactionApproved subscription with async handler that checks transactionMeta.status and routes to handleTransactionRejected when TransactionStatus.failed or TransactionStatus.rejected; otherwise calls handleTransactionApproved.
    • Imports: Add TransactionStatus import to support status checks.

Written by Cursor Bugbot for commit 65e499e. This will update automatically on new commits. Configure here.

…lets

- Updated the transaction controller to properly handle transaction approval and rejection events, particularly for hardware wallets.
- Added logic to differentiate between failed and rejected transactions, ensuring that the appropriate event handlers are invoked based on the transaction status.
- revert the createRPCMethodTrackingMiddleware.js back to main version.

This change aims to provide a more robust user experience when interacting with hardware wallets during transaction confirmations.
…ing middleware

- Adjusted the indentation of the error message status assignment in the createRPCMethodTrackingMiddleware.js file to improve code readability and maintain consistency with surrounding code structure.
@github-actions
Copy link
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.

@metamaskbot metamaskbot added the team-accounts-framework Accounts Framework team label Nov 21, 2025
@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

@MetaMask/confirmations (1 files, +18 -1)
  • 📁 app/
    • 📁 scripts/
      • 📁 controller-init/
        • 📁 confirmations/
          • 📄 transaction-controller-init.ts +18 -1

) {
await handleTransactionRejected(transactionMetricsRequest, {
transactionMeta,
});
Copy link

Choose a reason for hiding this comment

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

Bug: Duplicate metrics and incorrect event classification

Manually calling handleTransactionRejected here causes duplicate metrics, as the TransactionController emits separate transactionRejected and transactionFailed events that already trigger their own listeners. Additionally, treating TransactionStatus.failed as a user rejection (calling handleTransactionRejected) is semantically incorrect and will result in conflicting event data (both "rejected" and "failed" events for the same transaction). The handler should only skip the approved event logic when the status indicates failure.

Fix in Cursor Fix in Web

@metamaskbot
Copy link
Collaborator

Builds ready [65e499e]
UI Startup Metrics (1153 ± 94 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup115399815609412051308
load97782413398610301120
domContentLoaded97082213328610241113
domInteractive211382161874
firstPaint5587511393929841059
backgroundConnect18917424411194206
firstReactRender29174783344
getState321875123654
initialActions105113
loadScripts789646113284843923
setupStore1162631218
numNetworkReqs1257820573
BrowserifyPower User HomeuiStartup18751530300625820492382
load99586919401779951423
domContentLoaded98086419161759711413
domInteractive36162144129158
firstPaint5387719334289401423
backgroundConnect21919826212224242
firstReactRender78461491684109
getState17912930141200276
initialActions104112
loadScripts77866416861727711207
setupStore201061102742
numNetworkReqs1416729454181265
WebpackStandard HomeuiStartup818724136985850971
load617559113478620787
domContentLoaded613556112677616781
domInteractive241493182175
firstPaint233103735151219628
backgroundConnect1053361126
firstReactRender3020135123237
getState301364103845
initialActions104112
loadScripts610554111675614770
setupStore1273641419
numNetworkReqs1257819567
WebpackPower User HomeuiStartup14371082247424216001988
load67458412811296791002
domContentLoaded6645781270128664993
domInteractive36161873629139
firstPaint2621061008199233691
backgroundConnect1574271829
firstReactRender8254108119098
getState15412225028161215
initialActions103112
loadScripts6615761259125662984
setupStore23763133445
numNetworkReqs1487130554186278
FirefoxBrowserifyStandard HomeuiStartup11951029165411412491472
load101088712548010761177
domContentLoaded100988512548010751177
domInteractive53291902975111
firstPaint------
backgroundConnect3520114183679
firstReactRender20173432130
getState1167511919
initialActions103012
loadScripts98987211787610541152
setupStore105376925
numNetworkReqs1257617762
BrowserifyPower User HomeuiStartup25901891349330627603283
load1166959181717512221514
domContentLoaded1165957181717612221511
domInteractive16333829149193531
firstPaint------
backgroundConnect19423985207230723
firstReactRender83371391990125
getState23673822237186789
initialActions3133426
loadScripts1118920178916611671441
setupStore11910770172115678
numNetworkReqs965421342104208
WebpackStandard HomeuiStartup14081232184213314751675
load1198104214809312641377
domContentLoaded1198104214799312641376
domInteractive62232023983137
firstPaint------
backgroundConnect3819127194176
firstReactRender26204142834
getState156212281047
initialActions102122
loadScripts1176102814569012401348
setupStore12510516956
numNetworkReqs1156916661
WebpackPower User HomeuiStartup27432111353131729033397
load13781109192917414981722
domContentLoaded13781109192917414981722
domInteractive14231713133146486
firstPaint------
backgroundConnect15625659154180602
firstReactRender82391802090118
getState30072914280581828
initialActions41498228
loadScripts13431093189316814481683
setupStore102676216394627
numNetworkReqs985823345100214
📊 Page Load Benchmark Results

Current Commit: 65e499e | Date: 11/21/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±46ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 719ms (±63ms) 🟢 | historical mean value: 732ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 88ms (±128ms) 🟢 | historical mean value: 78ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 46ms 1.00s 1.39s 1.04s 1.39s
domContentLoaded 719ms 63ms 693ms 1.28s 732ms 1.28s
firstPaint 88ms 128ms 60ms 1.36s 88ms 1.36s
firstContentfulPaint 88ms 128ms 60ms 1.36s 88ms 1.36s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.39 KiB (0.03%)
  • ui: 9.56 KiB (0.14%)
  • common: 2.36 KiB (0.03%)

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.

(Ext) [Bug]: Sign types fire an Approved event when I reject the signature on Hardware Wallets

3 participants