1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/selectors/approvals.ts
2023-04-25 10:47:49 +01:00

20 lines
550 B
TypeScript

import { ApprovalControllerState } from '@metamask/approval-controller';
import { ApprovalType } from '@metamask/controller-utils';
type ApprovalsMetaMaskState = {
metamask: {
pendingApprovals: ApprovalControllerState['pendingApprovals'];
};
};
export function hasPendingApprovalsSelector(
state: ApprovalsMetaMaskState,
approvalType: ApprovalType,
) {
const pendingApprovalRequests = Object.values(
state.metamask.pendingApprovals,
).filter(({ type }) => type === approvalType);
return pendingApprovalRequests.length > 0;
}