Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions packages/transaction-controller/src/TransactionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3078,10 +3078,21 @@ export class TransactionController extends BaseController<
const updatedTransactionMeta = this.#getTransaction(
transactionId,
) as TransactionMeta;
this.messenger.publish(`${controllerName}:transactionApproved`, {
transactionMeta: updatedTransactionMeta,
actionId,
});

// 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) {
this.messenger.publish(`${controllerName}:transactionFailed`, {
Copy link
Member

Choose a reason for hiding this comment

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

This is already published in #failTransaction whenever the status is changed to failed.

So we can just check ApprovalState.Approved here instead, before publishing approved event.

transactionMeta: updatedTransactionMeta,
actionId,
error: updatedTransactionMeta?.error?.message ?? 'Unknown error',
});
} else {
this.messenger.publish(`${controllerName}:transactionApproved`, {
transactionMeta: updatedTransactionMeta,
actionId,
});
}
}
} catch (rawError: unknown) {
const error = rawError as Error & { code?: number; data?: Json };
Expand Down
Loading