File tree 4 files changed +28
-19
lines changed
pages/confirmations/confirmation/alerts
4 files changed +28
-19
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,21 @@ import { useCallback } from 'react';
3
3
import { useSelector } from 'react-redux' ;
4
4
5
5
import { AlertActionKey } from '../../../../components/app/confirm/info/row/constants' ;
6
- import { getApprovalsByOrigin } from '../../../../selectors' ;
7
6
import { useConfirmationNavigation } from '../../hooks/useConfirmationNavigation' ;
7
+ import {
8
+ ApprovalsMetaMaskState ,
9
+ getApprovalsByOrigin ,
10
+ } from '../../../../selectors' ;
8
11
9
12
export const useAlertsActions = (
10
13
hideAlertModal : ( ) => void ,
11
14
pendingConfirmation : ApprovalRequest < { id : string } > ,
12
15
) => {
13
16
const pendingConfirmationsFromOrigin = useSelector ( ( state ) =>
14
- getApprovalsByOrigin ( state , pendingConfirmation ?. origin ) ,
17
+ getApprovalsByOrigin (
18
+ state as ApprovalsMetaMaskState ,
19
+ pendingConfirmation ?. origin ,
20
+ ) ,
15
21
) ;
16
22
17
23
const { getIndex, navigateToIndex } = useConfirmationNavigation ( ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,10 @@ import { useSelector } from 'react-redux';
6
6
import { Alert } from '../../../../ducks/confirm-alerts/confirm-alerts' ;
7
7
import { AlertActionKey } from '../../../../components/app/confirm/info/row/constants' ;
8
8
import { Severity } from '../../../../helpers/constants/design-system' ;
9
- import { getApprovalsByOrigin } from '../../../../selectors' ;
9
+ import {
10
+ ApprovalsMetaMaskState ,
11
+ getApprovalsByOrigin ,
12
+ } from '../../../../selectors' ;
10
13
import { useI18nContext } from '../../../../hooks/useI18nContext' ;
11
14
12
15
const VALIDATED_APPROVAL_TYPES = [
@@ -18,7 +21,10 @@ export function useUpdateEthereumChainAlerts(
18
21
pendingConfirmation : ApprovalRequest < { id : string } > ,
19
22
) : Alert [ ] {
20
23
const pendingConfirmationsFromOrigin = useSelector ( ( state ) =>
21
- getApprovalsByOrigin ( state , pendingConfirmation ?. origin ) ,
24
+ getApprovalsByOrigin (
25
+ state as ApprovalsMetaMaskState ,
26
+ pendingConfirmation ?. origin ,
27
+ ) ,
22
28
) ;
23
29
24
30
const t = useI18nContext ( ) ;
Original file line number Diff line number Diff line change @@ -99,6 +99,18 @@ export const selectPendingApproval = createDeepEqualSelector(
99
99
( approval ) => approval ,
100
100
) ;
101
101
102
+ export const getApprovalsByOrigin = (
103
+ state : ApprovalsMetaMaskState ,
104
+ origin : string ,
105
+ ) => {
106
+ const pendingApprovals = getPendingApprovals ( state ) ;
107
+
108
+ return pendingApprovals ?. filter (
109
+ ( confirmation : ApprovalRequest < Record < string , Json > > ) =>
110
+ confirmation . origin === origin ,
111
+ ) ;
112
+ } ;
113
+
102
114
function isWatchTokenApproval ( approval : ApprovalRequest < Record < string , Json > > ) {
103
115
const tokenId = ( approval . requestData ?. asset as Record < string , string > )
104
116
?. tokenId ;
Original file line number Diff line number Diff line change @@ -1502,21 +1502,6 @@ export const getMemoizedUnapprovedConfirmations = createDeepEqualSelector(
1502
1502
( confirmations ) => confirmations ,
1503
1503
) ;
1504
1504
1505
- /**
1506
- * Get pending confirmation from specified origin.
1507
- *
1508
- * @param state - Redux state object.
1509
- * @param origin - Origin to ger approvals from.
1510
- * @returns array of approvals from an origin
1511
- */
1512
- export const getApprovalsByOrigin = ( state , origin ) => {
1513
- const pendingApprovals = getMemoizedUnapprovedConfirmations ( state ) ;
1514
-
1515
- return pendingApprovals ?. filter (
1516
- ( confirmation ) => confirmation . origin === origin ,
1517
- ) ;
1518
- } ;
1519
-
1520
1505
/**
1521
1506
* Get a memoized version of the unapproved templated confirmations.
1522
1507
*/
You can’t perform that action at this time.
0 commit comments