-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: hwb 76 fix incorrect transaction approved events log when user reject in hardware wallet #38089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: hwb 76 fix incorrect transaction approved events log when user reject in hardware wallet #38089
Conversation
…nts-for-hardware-wallet
…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.
|
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. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (1 files, +18 -1)
|
app/scripts/controller-init/confirmations/transaction-controller-init.ts
Show resolved
Hide resolved
| ) { | ||
| await handleTransactionRejected(transactionMetricsRequest, { | ||
| transactionMeta, | ||
| }); |
There was a problem hiding this comment.
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.
Builds ready [65e499e]
UI Startup Metrics (1153 ± 94 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
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.tsand check the transactionMetadata return, if the metadata status isfailedorrejected, then we should logtransaction rejectedevent instead, which mean user reject in hardware wallet side which cause the transaction rejected.This PR fix the incorrect
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
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Ensure
transactionApprovedevents withfailedorrejectedstatus invokehandleTransactionRejectedinstead ofhandleTransactionApproved, fixing hardware wallet rejection logging.app/scripts/controller-init/confirmations/transaction-controller-init.ts):handleTransactionApprovedsubscription with async handler that checkstransactionMeta.statusand routes tohandleTransactionRejectedwhenTransactionStatus.failedorTransactionStatus.rejected; otherwise callshandleTransactionApproved.TransactionStatusimport to support status checks.Written by Cursor Bugbot for commit 65e499e. This will update automatically on new commits. Configure here.