Skip to content
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

flow to report false positive for blockaid #20856

Merged
merged 18 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ exports[`Security Provider Banner Alert should match snapshot 1`] = `
List item
</li>
</ul>
<p
class="mm-box mm-text mm-text--body-md mm-box--margin-top-3 mm-box--display-flex mm-box--color-text-default"
>
[somethingDoesntLookRight]
</p>
</div>
<div
class="disclosure__footer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,24 @@ exports[`Blockaid Banner Alert should render details when provided 1`] = `
Operator is untrusted according to previous activity
</li>
</ul>
<p
class="mm-box mm-text mm-text--body-md mm-box--margin-top-3 mm-box--display-flex mm-box--color-text-default"
>
<span>

Something doesn't look right?
<a
class="mm-box mm-text mm-button-base mm-button-link mm-button-link--size-inherit mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-0 mm-box--padding-left-0 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-default mm-box--background-color-transparent"
href="https://support.metamask.io/hc/en-us"
rel="noopener noreferrer"
target="_blank"
>
Contact us
</a>


</span>
</p>
</div>
<div
class="disclosure__footer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ import {
SecurityProvider,
SECURITY_PROVIDER_CONFIG,
} from '../../../../shared/constants/security-provider';
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';

function SecurityProviderBannerAlert({
description,
details,
onClickSupportLink,
provider,
severity,
title,
Expand All @@ -49,6 +51,19 @@ function SecurityProviderBannerAlert({
{details && (
<Disclosure title={t('seeDetails')} variant={DisclosureVariant.Arrow}>
{details}
<Text marginTop={3} display={Display.Flex}>
{t('somethingDoesntLookRight', [
<ButtonLink
key={`security-provider-button-supporturl-${provider}`}
size={Size.inherit}
href={ZENDESK_URLS.SUPPORT_URL}
externalLink
onClick={onClickSupportLink}
>
{t('contactUs')}
</ButtonLink>,
])}
</Text>
</Disclosure>
)}

Expand Down Expand Up @@ -103,6 +118,9 @@ SecurityProviderBannerAlert.propTypes = {

/** Name of the security provider */
provider: PropTypes.oneOf(Object.values(SecurityProvider)),

/** Function to be called when the support link is clicked */
onClickSupportLink: PropTypes.func,
};

export default SecurityProviderBannerAlert;
27 changes: 25 additions & 2 deletions ui/components/app/signature-request/signature-request.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import React, { useContext, useState, useEffect } from 'react';
import React, {
useContext,
useState,
useEffect,
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
useCallback,
///: END:ONLY_INCLUDE_IN
} from 'react';
import {
useDispatch,
useSelector,
Expand Down Expand Up @@ -49,7 +56,7 @@ import ContractDetailsModal from '../modals/contract-details-modal';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import {
MetaMetricsEventCategory,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
///: BEGIN:ONLY_INCLUDE_IN(build-mmi,blockaid)
MetaMetricsEventName,
///: END:ONLY_INCLUDE_IN
} from '../../../../shared/constants/metametrics';
Expand Down Expand Up @@ -155,6 +162,21 @@ const SignatureRequest = ({ txData }) => {
return { sanitizedMessage, domain, primaryType };
});

///: BEGIN:ONLY_INCLUDE_IN(blockaid)
const onClickSupportLink = useCallback(() => {
trackEvent({
category: MetaMetricsEventCategory.Transactions,
event: MetaMetricsEventName.ExternalLinkClicked,
properties: {
action: 'Sign Request',
type,
version,
external_link_clicked: 'security_alert_support_link',
},
});
}, []);
///: END:ONLY_INCLUDE_IN

const onSign = async () => {
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
if (accountType === 'custody') {
Expand Down Expand Up @@ -250,6 +272,7 @@ const SignatureRequest = ({ txData }) => {
marginLeft={4}
marginRight={4}
marginBottom={4}
onClickSupportLink={onClickSupportLink}
/>
///: END:ONLY_INCLUDE_IN
}
Expand Down
39 changes: 36 additions & 3 deletions ui/components/app/transaction-alerts/transaction-alerts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import React from 'react';
import React, {
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
useCallback,
useContext,
///: END:ONLY_INCLUDE_IN
} from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { PriorityLevels } from '../../../../shared/constants/gas';
Expand All @@ -9,6 +14,9 @@ import { BannerAlert, ButtonLink, Text } from '../../component-library';
import SimulationErrorMessage from '../../ui/simulation-error-message';
import { SEVERITIES } from '../../../helpers/constants/design-system';
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
import { MetaMetricsContext } from '../../../contexts/metametrics';
///: END:ONLY_INCLUDE_IN

import { isSuspiciousResponse } from '../../../../shared/modules/security-provider.utils';
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
Expand All @@ -19,12 +27,18 @@ import { getNativeCurrency } from '../../../ducks/metamask/metamask';
import { TransactionType } from '../../../../shared/constants/transaction';
import { parseStandardTokenTransactionData } from '../../../../shared/modules/transaction.utils';
import { getTokenValueParam } from '../../../../shared/lib/metamask-controller-utils';
import {
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
MetaMetricsEventCategory,
MetaMetricsEventName,
///: END:ONLY_INCLUDE_IN
} from '../../../../shared/constants/metametrics';

const TransactionAlerts = ({
userAcknowledgedGasMissing,
setUserAcknowledgedGasMissing,
txData,
tokenSymbol,
txData,
}) => {
const { estimateUsed, hasSimulationError, supportsEIP1559, isNetworkBusy } =
useGasFeeContext();
Expand Down Expand Up @@ -54,11 +68,30 @@ const TransactionAlerts = ({
hasProperTxType &&
(currentTokenAmount === '0x0' || currentTokenAmount === '0');

///: BEGIN:ONLY_INCLUDE_IN(blockaid)
const trackEvent = useContext(MetaMetricsContext);
///: END:ONLY_INCLUDE_IN

///: BEGIN:ONLY_INCLUDE_IN(blockaid)
const onClickSupportLink = useCallback(() => {
trackEvent({
category: MetaMetricsEventCategory.Transactions,
event: MetaMetricsEventName.ExternalLinkClicked,
properties: {
action: 'Confirm Screen',
origin: txData?.origin,
external_link_clicked: 'security_alert_support_link',
},
});
}, []);
///: END:ONLY_INCLUDE_IN

return (
<div className="transaction-alerts">
{
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
<BlockaidBannerAlert
onClickSupportLink={onClickSupportLink}
securityAlertResponse={txData?.securityAlertResponse}
/>
///: END:ONLY_INCLUDE_IN
Expand Down Expand Up @@ -124,8 +157,8 @@ const TransactionAlerts = ({
TransactionAlerts.propTypes = {
userAcknowledgedGasMissing: PropTypes.bool,
setUserAcknowledgedGasMissing: PropTypes.func,
txData: PropTypes.object,
tokenSymbol: PropTypes.string,
txData: PropTypes.object,
};

export default TransactionAlerts;
1 change: 1 addition & 0 deletions ui/helpers/constants/zendesk-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const ZENDESK_URLS = {
'https://metamask.zendesk.com/hc/en-us/articles/360059952212-MetaMask-is-a-non-custodial-wallet',
SPEEDUP_CANCEL:
'https://metamask.zendesk.com/hc/en-us/articles/360015489251-How-to-speed-up-or-cancel-a-pending-transaction',
SUPPORT_URL: 'https://support.metamask.io/hc/en-us',
TOKEN_ALLOWANCE_WITH_SPENDING_CAP:
'https://support.metamask.io/hc/en-us/articles/6055177143579-How-to-customize-token-approvals-with-a-spending-cap',
TOKEN_SAFETY_PRACTICES:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ export default class ConfirmTransactionBase extends Component {
useCurrencyRateCheck,
tokenSymbol,
} = this.props;

const { t } = this.context;
const { userAcknowledgedGasMissing } = this.state;

Expand Down
Loading