Skip to content

Commit

Permalink
add check approval request exists before rejecting (#6838)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistevam authored Jul 20, 2023
1 parent 1e8e955 commit 499860f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions app/components/Views/Approval/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ class Approval extends PureComponent {
try {
const { transactionHandled } = this.state;
const { transaction, selectedAddress } = this.props;
const { KeyringController } = Engine.context;
const { KeyringController, ApprovalController } = Engine.context;
if (!transactionHandled) {
if (isQRHardwareAccount(selectedAddress)) {
KeyringController.cancelQRSignRequest();
} else {
Engine.context.ApprovalController.reject(
transaction.id,
} else if (ApprovalController.has({ id: transaction?.id })) {
ApprovalController.reject(
transaction?.id,
ethErrors.provider.userRejectedRequest(),
);
}
Expand Down Expand Up @@ -177,17 +177,21 @@ class Approval extends PureComponent {
try {
if (appState !== 'active') {
const { transaction, transactions } = this.props;
const { ApprovalController } = Engine.context;
const currentTransaction = transactions.find(
(tx) => tx.id === transaction.id,
);

transaction &&
transaction.id &&
this.isTxStatusCancellable(currentTransaction) &&
Engine.context.ApprovalController.reject(
if (
transaction?.id &&
ApprovalController.has({ id: transaction?.id }) &&
this.isTxStatusCancellable(currentTransaction)
) {
ApprovalController.reject(
transaction.id,
ethErrors.provider.userRejectedRequest(),
);
}
this.props.hideModal();
}
} catch (e) {
Expand Down

0 comments on commit 499860f

Please sign in to comment.