From 76ab331cc8c38eb4e19925175e10d66a14699877 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 09:36:51 -0700 Subject: [PATCH 1/4] Bump @stellar/design-system in /extension (#1729) Bumps [@stellar/design-system](https://github.com/stellar/stellar-design-system) from 2.0.0-beta.15 to 2.0.0-beta.17. - [Release notes](https://github.com/stellar/stellar-design-system/releases) - [Commits](https://github.com/stellar/stellar-design-system/commits) --- updated-dependencies: - dependency-name: "@stellar/design-system" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From 841567ae184c8744879e39ddbecbbc437b406824 Mon Sep 17 00:00:00 2001 From: Piyal Basu Date: Tue, 7 Jan 2025 13:51:14 -0500 Subject: [PATCH 2/4] adding blockaid byline and feedback form --- @shared/api/types.ts | 4 +- .../components/WarningMessages/index.tsx | 506 ++++++++++++------ .../components/WarningMessages/styles.scss | 93 +++- .../manageAssets/ManageAssetRows/index.tsx | 28 +- .../sendPayment/SendAmount/index.tsx | 29 +- .../SendConfirm/TransactionDetails/index.tsx | 4 +- extension/src/popup/helpers/blockaid.ts | 78 +++ .../src/popup/views/SignTransaction/index.tsx | 44 +- .../popup/views/SignTransaction/styles.scss | 9 + .../views/__tests__/SendPayment.test.tsx | 2 + 10 files changed, 557 insertions(+), 240 deletions(-) diff --git a/@shared/api/types.ts b/@shared/api/types.ts index f560816d08..03ddbe1dd6 100644 --- a/@shared/api/types.ts +++ b/@shared/api/types.ts @@ -244,7 +244,9 @@ export interface Balance { export type BlockAidScanAssetResult = Blockaid.TokenScanResponse; export type BlockAidScanSiteResult = Blockaid.SiteScanResponse; -export type BlockAidScanTxResult = Blockaid.StellarTransactionScanResponse; +export type BlockAidScanTxResult = Blockaid.StellarTransactionScanResponse & { + request_id: string; +}; export type BlockAidBulkScanAssetResult = Blockaid.TokenBulkScanResponse; export interface AssetBalance extends Balance { diff --git a/extension/src/popup/components/WarningMessages/index.tsx b/extension/src/popup/components/WarningMessages/index.tsx index 418b4e6cdd..9056dc72ed 100644 --- a/extension/src/popup/components/WarningMessages/index.tsx +++ b/extension/src/popup/components/WarningMessages/index.tsx @@ -1,8 +1,21 @@ import React, { useState, useRef, useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { createPortal } from "react-dom"; -import { Button, Icon, Loader, Notification } from "@stellar/design-system"; +import { + Alert, + Button, + Card, + Icon, + Loader, + Notification, + Select, + Textarea, + Text, +} from "@stellar/design-system"; import { useTranslation, Trans } from "react-i18next"; +import { Field, FieldProps, Formik, Form } from "formik"; +import { object as YupObject, string as YupString } from "yup"; + import { POPUP_HEIGHT } from "constants/dimensions"; import { Account, @@ -61,7 +74,12 @@ import IconShieldBlockaid from "popup/assets/icon-shield-blockaid.svg"; import IconWarningBlockaid from "popup/assets/icon-warning-blockaid.svg"; import IconWarningBlockaidYellow from "popup/assets/icon-warning-blockaid-yellow.svg"; import { getVerifiedTokens } from "popup/helpers/searchAsset"; -import { isAssetSuspicious, isBlockaidWarning } from "popup/helpers/blockaid"; +import { + isAssetSuspicious, + isBlockaidWarning, + reportAssetWarning, + reportTransactionWarning, +} from "popup/helpers/blockaid"; import { CopyValue } from "../CopyValue"; import "./styles.scss"; @@ -257,15 +275,204 @@ export const BackupPhraseWarningMessage = () => { ); }; -const BlockaidByLine = () => { +interface BlockaidFeedbackFormValues { + details: string; + transactionIssue?: string; +} + +const BlockaidFeedbackFormSchema = YupObject().shape({ + details: YupString().required(), +}); + +interface BlockaidFeedbackFormProps { + address?: string; + requestId?: string; + setIsFeedbackActive: (isActive: boolean) => void; +} + +const BlockaidFeedbackForm = ({ + address, + requestId, + setIsFeedbackActive, +}: BlockaidFeedbackFormProps) => { + const { t } = useTranslation(); + const feedbackRef = useRef(null); + const networkDetails = useSelector(settingsNetworkDetailsSelector); + + const handleSubmit = async (values: BlockaidFeedbackFormValues) => { + if (requestId && values.transactionIssue) { + await reportTransactionWarning({ + details: values.details, + requestId, + event: values.transactionIssue, + }); + } else if (address) { + await reportAssetWarning({ + address, + details: values.details, + networkDetails, + }); + } + + setIsFeedbackActive(false); + }; + + const initialValues: BlockaidFeedbackFormValues = { + details: "", + transactionIssue: "should_be_benign", + }; + + useEffect(() => { + const handleClickOutside = (event: MouseEvent) => { + if ( + feedbackRef.current && + !feedbackRef.current.contains(event.target as Node) + ) { + setIsFeedbackActive(false); + } + }; + + document.addEventListener("click", handleClickOutside, true); + return () => { + document.removeEventListener("click", handleClickOutside, true); + }; + }, [setIsFeedbackActive]); + + return ( + <> +
+ +
+
+
+ + + {({ dirty, isValid, isSubmitting }) => ( +
+
+ + {t("Leave feedback about Blockaid warnings and messages")} + + {requestId ? ( + + {({ field }: FieldProps) => ( + + )} + + ) : null} + + + {({ field }: FieldProps) => ( +