-
-
Notifications
You must be signed in to change notification settings - Fork 256
fix: controller send transaction approved when user reject transaction in hardware devices. #7214
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: controller send transaction approved when user reject transaction in hardware devices. #7214
Conversation
Updated the transaction approval logic to check the status of the transaction. If the transaction fails due to user rejection or other errors, it now publishes a failure message with the error details. This change improves error handling and user feedback during transaction processing.
|
@metamaskbot publish-preview |
| transactionMeta: updatedTransactionMeta, | ||
| actionId, | ||
| error: updatedTransactionMeta?.error?.message ?? 'Unknown error', | ||
| }); |
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 transaction failed event publication
The transactionFailed event is published twice when a transaction fails during approval. The #approveTransaction method already calls #failTransaction which publishes the transactionFailed event, but the new code checks the status and publishes it again. This creates duplicate event emissions that could cause incorrect analytics tracking and unexpected behavior in event listeners.
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
|
||
| // need to check status of updatedTransactionMeta to see if it is approved | ||
| // for special case like user reject request in hardware wallet, the transactionMeta is failed with error "user rejected request" | ||
| if (updatedTransactionMeta.status === TransactionStatus.failed) { |
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.
However the approval is rejected, it should already throw from this.#requestApproval above and be caught in the below catch meaning the approval event wouldn't fire?
This PR will fix some issue caused by user reject transaction in hardware wallet, which cause a lot of incorrect event log in segment.
Updated the transaction approval logic to check the status of the transaction. If the transaction fails due to user rejection or other errors, it now publishes a failure message with the error details. This change improves error handling and user feedback during transaction processing.
Explanation
References
Checklist
Note
Ensure post-approval emits transactionFailed (with error) instead of transactionApproved when the transaction ends in failed status (e.g., hardware wallet rejection).
packages/transaction-controller/src/TransactionController.ts):updatedTransactionMeta.status; iffailed, publish${controllerName}:transactionFailedwitherrormessage, else publish${controllerName}:transactionApproved.Written by Cursor Bugbot for commit e0caebb. This will update automatically on new commits. Configure here.