-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Clicking on report link does not add external_link_clicked to si… #29969
base: main
Are you sure you want to change the base?
Changes from all commits
4bc69ef
b22bea6
990cc0d
a3f8f6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -91,6 +91,51 @@ export const getMetaMaskStateWithUnapprovedPermitSign = ( | |||||||||||
}; | ||||||||||||
}; | ||||||||||||
|
||||||||||||
export const getMetamaskStateWithMaliciousPermit = (accountAddress: string) => { | ||||||||||||
const pendingPermitId = '48a75190-45ca-11ef-9001-f3886ec2397c'; | ||||||||||||
Comment on lines
+94
to
+95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [minor nit] we can move this out to avoid reinstantiating for each getMetamaskStateWithMaliciousPermit call
Suggested change
|
||||||||||||
|
||||||||||||
const state = getMetaMaskStateWithUnapprovedPermitSign( | ||||||||||||
accountAddress, | ||||||||||||
'Permit', | ||||||||||||
); | ||||||||||||
const unapprovedTypedMessage = { | ||||||||||||
[pendingPermitId]: { | ||||||||||||
...state.unapprovedTypedMessages[pendingPermitId], | ||||||||||||
securityAlertResponse: { | ||||||||||||
block: 7596565, | ||||||||||||
result_type: 'Malicious', | ||||||||||||
reason: 'permit_farming', | ||||||||||||
description: | ||||||||||||
'permit_farming to spender 0x1661f1b207629e4f385da89cff535c8e5eb23ee3, classification: A known malicious address is involved in the transaction', | ||||||||||||
features: ['A known malicious address is involved in the transaction'], | ||||||||||||
source: 'api', | ||||||||||||
securityAlertId: 'ba944b14-aa65-45b5-ae92-f305cdba64c1', | ||||||||||||
}, | ||||||||||||
}, | ||||||||||||
}; | ||||||||||||
|
||||||||||||
state.unapprovedTypedMessages = { | ||||||||||||
...unapprovedTypedMessage, | ||||||||||||
}; | ||||||||||||
|
||||||||||||
console.log(state); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guessing this is forgotten |
||||||||||||
return { | ||||||||||||
...state, | ||||||||||||
signatureSecurityAlertResponses: { | ||||||||||||
'ba944b14-aa65-45b5-ae92-f305cdba64c1': { | ||||||||||||
block: 7596565, | ||||||||||||
result_type: 'Malicious', | ||||||||||||
reason: 'permit_farming', | ||||||||||||
description: | ||||||||||||
'permit_farming to spender 0x1661f1b207629e4f385da89cff535c8e5eb23ee3, classification: A known malicious address is involved in the transaction', | ||||||||||||
features: ['A known malicious address is involved in the transaction'], | ||||||||||||
source: 'api', | ||||||||||||
securityAlertId: 'ba944b14-aa65-45b5-ae92-f305cdba64c1', | ||||||||||||
}, | ||||||||||||
}, | ||||||||||||
}; | ||||||||||||
}; | ||||||||||||
|
||||||||||||
export const verifyDetails = (element: Element, expectedValues: string[]) => { | ||||||||||||
expectedValues.forEach((value) => { | ||||||||||||
expect(element).toHaveTextContent(value); | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ function ReportLink({ | |
<Text marginTop={1} display={Display.Flex}> | ||
{t('somethingDoesntLookRight', [ | ||
<ButtonLink | ||
data-testid="alert-provider-report-link" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We avoid adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this suggestion. I do like using findByText to also test text expectations simultaneously |
||
key={`security-provider-button-supporturl-${provider}`} | ||
size={ButtonLinkSize.Inherit} | ||
href={reportUrl ?? ZENDESK_URLS.SUPPORT_URL} | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -23,15 +23,29 @@ import { useIsNFT } from '../info/approve/hooks/use-is-nft'; | |||||||||||||||||||||||||||||||||||||
import { useTokenTransactionData } from '../info/hooks/useTokenTransactionData'; | ||||||||||||||||||||||||||||||||||||||
import { getIsRevokeSetApprovalForAll } from '../info/utils'; | ||||||||||||||||||||||||||||||||||||||
import { getIsRevokeDAIPermit } from '../utils'; | ||||||||||||||||||||||||||||||||||||||
import { useSignatureEventFragment } from '../../../hooks/useSignatureEventFragment'; | ||||||||||||||||||||||||||||||||||||||
import { useTransactionEventFragment } from '../../../hooks/useTransactionEventFragment'; | ||||||||||||||||||||||||||||||||||||||
import { useCurrentSpendingCap } from './hooks/useCurrentSpendingCap'; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
function ConfirmBannerAlert({ ownerId }: { ownerId: string }) { | ||||||||||||||||||||||||||||||||||||||
const { generalAlerts } = useAlerts(ownerId); | ||||||||||||||||||||||||||||||||||||||
const { updateSignatureEventFragment } = useSignatureEventFragment(); | ||||||||||||||||||||||||||||||||||||||
const { updateTransactionEventFragment } = useTransactionEventFragment(); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if (generalAlerts.length === 0) { | ||||||||||||||||||||||||||||||||||||||
return null; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
const onClickSupportLink = () => { | ||||||||||||||||||||||||||||||||||||||
const properties = { | ||||||||||||||||||||||||||||||||||||||
properties: { | ||||||||||||||||||||||||||||||||||||||
external_link_clicked: 'security_alert_support_link', | ||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||
updateSignatureEventFragment(properties); | ||||||||||||||||||||||||||||||||||||||
updateTransactionEventFragment(properties, ownerId); | ||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
Comment on lines
+39
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we create this callback with
Suggested change
|
||||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||||
<Box marginTop={3}> | ||||||||||||||||||||||||||||||||||||||
{generalAlerts.map((alert) => ( | ||||||||||||||||||||||||||||||||||||||
|
@@ -45,6 +59,7 @@ function ConfirmBannerAlert({ ownerId }: { ownerId: string }) { | |||||||||||||||||||||||||||||||||||||
details={alert.alertDetails} | ||||||||||||||||||||||||||||||||||||||
reportUrl={alert.reportUrl} | ||||||||||||||||||||||||||||||||||||||
children={alert.content} | ||||||||||||||||||||||||||||||||||||||
onClickSupportLink={onClickSupportLink} | ||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||
</Box> | ||||||||||||||||||||||||||||||||||||||
))} | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use Jest's matchers rather than relying on string comparisons?