1
- import React , { useCallback , useEffect } from 'react' ;
2
1
import { ButtonVariant } from '@metamask/snaps-sdk' ;
3
-
4
- import { SecurityProvider } from '../../../../../shared/constants/security-provider' ;
2
+ import React , { useCallback , useEffect } from 'react' ;
3
+ import {
4
+ BlockaidReason ,
5
+ SecurityProvider ,
6
+ } from '../../../../../shared/constants/security-provider' ;
7
+ import { Alert } from '../../../../ducks/confirm-alerts/confirm-alerts' ;
8
+ import {
9
+ AlignItems ,
10
+ BackgroundColor ,
11
+ BlockSize ,
12
+ BorderRadius ,
13
+ Display ,
14
+ FlexDirection ,
15
+ IconColor ,
16
+ Severity ,
17
+ TextAlign ,
18
+ TextColor ,
19
+ TextVariant ,
20
+ } from '../../../../helpers/constants/design-system' ;
21
+ import useAlerts from '../../../../hooks/useAlerts' ;
22
+ import { useI18nContext } from '../../../../hooks/useI18nContext' ;
23
+ import { useConfirmContext } from '../../../../pages/confirmations/context/confirm' ;
5
24
import {
6
25
Box ,
7
26
Button ,
@@ -18,22 +37,6 @@ import {
18
37
ModalOverlay ,
19
38
Text ,
20
39
} from '../../../component-library' ;
21
- import {
22
- AlignItems ,
23
- BackgroundColor ,
24
- BlockSize ,
25
- BorderRadius ,
26
- Display ,
27
- FlexDirection ,
28
- IconColor ,
29
- Severity ,
30
- TextAlign ,
31
- TextColor ,
32
- TextVariant ,
33
- } from '../../../../helpers/constants/design-system' ;
34
- import { useI18nContext } from '../../../../hooks/useI18nContext' ;
35
- import useAlerts from '../../../../hooks/useAlerts' ;
36
- import { Alert } from '../../../../ducks/confirm-alerts/confirm-alerts' ;
37
40
import { useAlertActionHandler } from '../contexts/alertActionHandler' ;
38
41
import { useAlertMetrics } from '../contexts/alertMetricsContext' ;
39
42
@@ -137,9 +140,42 @@ function AlertHeader({
137
140
138
141
function BlockaidAlertDetails ( ) {
139
142
const t = useI18nContext ( ) ;
143
+ const { currentConfirmation } = useConfirmContext ( ) ;
144
+ const securityAlertResponse = currentConfirmation . securityAlertResponse ;
145
+
146
+ let copy ;
147
+ switch ( securityAlertResponse ?. reason ) {
148
+ case BlockaidReason . rawSignatureFarming :
149
+ copy = t ( 'blockaidAlertInfoDescription3' ) ;
150
+ break ;
151
+ case BlockaidReason . approvalFarming :
152
+ case BlockaidReason . setApprovalForAll :
153
+ case BlockaidReason . permitFarming :
154
+ copy = t ( 'blockaidAlertInfoDescription2' ) ;
155
+ break ;
156
+ case BlockaidReason . transferFarming :
157
+ case BlockaidReason . transferFromFarming :
158
+ case BlockaidReason . rawNativeTokenTransfer :
159
+ copy = t ( 'blockaidAlertInfoDescription' ) ;
160
+ break ;
161
+ case BlockaidReason . seaportFarming :
162
+ copy = t ( 'blockaidAlertInfoDescription4' ) ;
163
+ break ;
164
+ case BlockaidReason . blurFarming :
165
+ copy = t ( 'blockaidAlertInfoDescription5' ) ;
166
+ break ;
167
+ case BlockaidReason . maliciousDomain :
168
+ copy = t ( 'blockaidAlertInfoDescription6' ) ;
169
+ break ;
170
+ case BlockaidReason . tradeOrderFarming :
171
+ case BlockaidReason . other :
172
+ default :
173
+ copy = t ( 'blockaidAlertInfoDescription7' ) ;
174
+ }
175
+
140
176
return (
141
177
< Text textAlign = { TextAlign . Center } variant = { TextVariant . bodyMd } >
142
- { t ( 'blockaidAlertInfoDescription' ) }
178
+ { copy }
143
179
</ Text >
144
180
) ;
145
181
}
0 commit comments