Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
blackdevelopa committed Sep 19, 2023
1 parent 97d99a4 commit b31f46d
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 54 deletions.
3 changes: 0 additions & 3 deletions shared/constants/security-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ type SecurityProviderConfig = Record<
readonly tKeyName: string;
/** URL to securty provider website */
readonly url: string;
/** URL to security provider support page */
readonly supportUrl: string;
}
>;

export const SECURITY_PROVIDER_CONFIG: Readonly<SecurityProviderConfig> = {
[SecurityProvider.Blockaid]: {
tKeyName: 'blockaid',
url: 'https://blockaid.io/',
supportUrl: 'https://support.metamask.io/hc/en-us',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ 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,
onClickBlockaidSupport,
...props
}) {
const t = useContext(I18nContext);
Expand Down Expand Up @@ -61,9 +62,9 @@ function SecurityProviderBannerAlert({
<ButtonLink
key={`security-provider-button-supporturl-${provider}`}
size={Size.inherit}
href={SECURITY_PROVIDER_CONFIG[provider].supportUrl}
href={ZENDESK_URLS.SUPPORT_URL}
externalLink
onClick={onClickBlockaidSupport}
onClick={onClickSupportLink}
>
{t('contactUs')}
</ButtonLink>,
Expand Down Expand Up @@ -123,7 +124,7 @@ SecurityProviderBannerAlert.propTypes = {
provider: PropTypes.oneOf(Object.values(SecurityProvider)),

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

export default SecurityProviderBannerAlert;
14 changes: 5 additions & 9 deletions ui/components/app/signature-request/signature-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ import {
MetaMetricsEventName,
///: END:ONLY_INCLUDE_IN
} from '../../../../shared/constants/metametrics';
import {
SECURITY_PROVIDER_MESSAGE_SEVERITY,
SecurityProvider,
SECURITY_PROVIDER_CONFIG,
} from '../../../../shared/constants/security-provider';
import { SECURITY_PROVIDER_MESSAGE_SEVERITY } from '../../../../shared/constants/security-provider';
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';

import {
TextAlign,
Expand Down Expand Up @@ -159,7 +156,7 @@ const SignatureRequest = ({ txData }) => {
return { sanitizedMessage, domain, primaryType };
});

const onClickBlockaidSupport = useCallback(() => {
const onClickSupportLink = useCallback(() => {
trackEvent({
category: MetaMetricsEventCategory.Transactions,
event: MetaMetricsEventName.ExternalLinkClicked,
Expand All @@ -168,8 +165,7 @@ const SignatureRequest = ({ txData }) => {
type,
version,
external_link_clicked: true,
security_alert_support_link:
SECURITY_PROVIDER_CONFIG[SecurityProvider.Blockaid].supportUrl,
security_alert_support_link: ZENDESK_URLS.SUPPORT_URL,
},
});
}, []);
Expand Down Expand Up @@ -269,7 +265,7 @@ const SignatureRequest = ({ txData }) => {
marginLeft={4}
marginRight={4}
marginBottom={4}
onClickBlockaidSupport={onClickBlockaidSupport}
onClickSupportLink={onClickSupportLink}
/>
///: END:ONLY_INCLUDE_IN
}
Expand Down
44 changes: 39 additions & 5 deletions ui/components/app/transaction-alerts/transaction-alerts.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,75 @@
import React from 'react';
import React, { useCallback, useContext } from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';

import { PriorityLevels } from '../../../../shared/constants/gas';
import { submittedPendingTransactionsSelector } from '../../../selectors';
import {
submittedPendingTransactionsSelector,
getKnownMethodData,
} from '../../../selectors';
import { useGasFeeContext } from '../../../contexts/gasFee';
import { useI18nContext } from '../../../hooks/useI18nContext';
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';
import { getMethodName } from '../../../helpers/utils/metrics';
import { TransactionType } from '../../../../shared/constants/transaction';

import { isSuspiciousResponse } from '../../../../shared/modules/security-provider.utils';
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
import BlockaidBannerAlert from '../security-provider-banner-alert/blockaid-banner-alert/blockaid-banner-alert';
///: END:ONLY_INCLUDE_IN
import SecurityProviderBannerMessage from '../security-provider-banner-message/security-provider-banner-message';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import {
MetaMetricsEventCategory,
MetaMetricsEventName,
} from '../../../../shared/constants/metametrics';

const TransactionAlerts = ({
userAcknowledgedGasMissing,
setUserAcknowledgedGasMissing,
txData,
onClickBlockaidSupport,
}) => {
const { estimateUsed, hasSimulationError, supportsEIP1559, isNetworkBusy } =
useGasFeeContext();
const pendingTransactions = useSelector(submittedPendingTransactionsSelector);
const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext);
const { txParams = {} } = txData;
const methodData = useSelector(
(state) => getKnownMethodData(state, txParams.data) || {},
);

console.log(methodData, 'methodDatamethodData');

const onClickSupportLink = useCallback(() => {
trackEvent({
category: MetaMetricsEventCategory.Transactions,
event: MetaMetricsEventName.ExternalLinkClicked,
properties: {
action: 'Confirm Screen',
legacy_event: true,
recipientKnown: null,
functionType:
'confirm' ||
getMethodName(methodData.name) ||
TransactionType.contractInteraction,
origin: txData?.origin,
external_link_clicked: true,
security_alert_support_link: ZENDESK_URLS.SUPPORT_URL,
},
});
}, []);

return (
<div className="transaction-alerts">
{
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
<BlockaidBannerAlert
onClickSupportLink={onClickSupportLink}
securityAlertResponse={txData?.securityAlertResponse}
onClickBlockaidSupport={onClickBlockaidSupport}
/>
///: END:ONLY_INCLUDE_IN
}
Expand Down Expand Up @@ -95,7 +130,6 @@ TransactionAlerts.propTypes = {
userAcknowledgedGasMissing: PropTypes.bool,
setUserAcknowledgedGasMissing: PropTypes.func,
txData: PropTypes.object,
onClickBlockaidSupport: PropTypes.func,
};

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 @@ -14,10 +14,7 @@ import UserPreferencedCurrencyDisplay from '../../components/app/user-preference
import { PRIMARY, SECONDARY } from '../../helpers/constants/common';
import TextField from '../../components/ui/text-field';
import SimulationErrorMessage from '../../components/ui/simulation-error-message';
import {
MetaMetricsEventCategory,
MetaMetricsEventName,
} from '../../../shared/constants/metametrics';
import { MetaMetricsEventCategory } from '../../../shared/constants/metametrics';
import {
TransactionType,
TransactionStatus,
Expand Down Expand Up @@ -58,10 +55,6 @@ import { ConfirmTitle } from '../../components/app/confirm-title';
import { ConfirmSubTitle } from '../../components/app/confirm-subtitle';
import { ConfirmGasDisplay } from '../../components/app/confirm-gas-display';
import updateTxData from '../../../shared/modules/updateTxData';
import {
SecurityProvider,
SECURITY_PROVIDER_CONFIG,
} from '../../../shared/constants/security-provider';

export default class ConfirmTransactionBase extends Component {
static contextTypes = {
Expand Down Expand Up @@ -331,9 +324,6 @@ export default class ConfirmTransactionBase extends Component {
nativeCurrency,
isBuyableChain,
useCurrencyRateCheck,
actionKey,
txData: { origin },
methodData = {},
} = this.props;

const { t } = this.context;
Expand Down Expand Up @@ -460,27 +450,6 @@ export default class ConfirmTransactionBase extends Component {
</div>
);

const onClickBlockaidSupport = () => {
const { trackEvent } = this.context;
trackEvent({
category: MetaMetricsEventCategory.Transactions,
event: MetaMetricsEventName.ExternalLinkClicked,
properties: {
action: 'Confirm Screen',
legacy_event: true,
recipientKnown: null,
functionType:
actionKey ||
getMethodName(methodData.name) ||
TransactionType.contractInteraction,
origin,
external_link_clicked: true,
security_alert_support_link:
SECURITY_PROVIDER_CONFIG[SecurityProvider.Blockaid].supportUrl,
},
});
};

return (
<div className="confirm-page-container-content__details">
<TransactionAlerts
Expand All @@ -493,7 +462,6 @@ export default class ConfirmTransactionBase extends Component {
networkName={networkName}
type={txData.type}
isBuyableChain={isBuyableChain}
onClickBlockaidSupport={onClickBlockaidSupport}
/>
<TransactionDetail
disabled={isDisabled()}
Expand Down

0 comments on commit b31f46d

Please sign in to comment.