From b7ee948cd5417db785eb8f03e2b37a0d8ed0a458 Mon Sep 17 00:00:00 2001 From: Diana Savatina Date: Thu, 19 Dec 2024 16:13:12 +0000 Subject: [PATCH] feat: WalletConnect integration, part 8, verify --- .../src/components/SendFlow/common/Header.tsx | 5 ++ apps/web/src/components/SendFlow/utils.tsx | 2 + .../WalletConnect/ProjectInfoCard.tsx | 8 +-- .../WalletConnect/SessionProposalModal.tsx | 10 ++- .../WalletConnect/VerifyInfobox.tsx | 67 ++++++++++++++++--- .../WalletConnect/useHandleWcRequest.tsx | 6 +- 6 files changed, 72 insertions(+), 26 deletions(-) diff --git a/apps/web/src/components/SendFlow/common/Header.tsx b/apps/web/src/components/SendFlow/common/Header.tsx index c032a227d6..e6a6d115a9 100644 --- a/apps/web/src/components/SendFlow/common/Header.tsx +++ b/apps/web/src/components/SendFlow/common/Header.tsx @@ -3,6 +3,7 @@ import { capitalize } from "lodash"; import { CodeSandboxIcon } from "../../../assets/icons"; import { useColor } from "../../../styles/useColor"; +import { VerifyInfobox } from "../../WalletConnect/VerifyInfobox"; import { SignPageHeader } from "../SignPageHeader"; import { type SignHeaderProps } from "../utils"; @@ -37,6 +38,10 @@ export const Header = ({ headerProps }: { headerProps: SignHeaderProps }) => { {headerProps.appName} + ); }; diff --git a/apps/web/src/components/SendFlow/utils.tsx b/apps/web/src/components/SendFlow/utils.tsx index dfc8ff88f3..e705d5711a 100644 --- a/apps/web/src/components/SendFlow/utils.tsx +++ b/apps/web/src/components/SendFlow/utils.tsx @@ -76,6 +76,8 @@ export type SignHeaderProps = { network: Network; appName: string; appIcon?: string; + isScam?: boolean; + validationStatus?: "VALID" | "INVALID" | "UNKNOWN"; }; export type SdkSignPageProps = { diff --git a/apps/web/src/components/WalletConnect/ProjectInfoCard.tsx b/apps/web/src/components/WalletConnect/ProjectInfoCard.tsx index 78cc0ce66e..04b850952d 100644 --- a/apps/web/src/components/WalletConnect/ProjectInfoCard.tsx +++ b/apps/web/src/components/WalletConnect/ProjectInfoCard.tsx @@ -1,8 +1,6 @@ -import { Avatar, Box, Card, Flex, Icon, Link, Text } from "@chakra-ui/react"; +import { Avatar, Box, Card, Link, Text } from "@chakra-ui/react"; import { type SignClientTypes } from "@walletconnect/types"; -import { PencilIcon } from "../../assets/icons"; - type Props = { metadata: SignClientTypes.Metadata; intention?: string; @@ -38,10 +36,6 @@ export const ProjectInfoCard = ({ metadata, intention }: Props) => { {url} - - - Cannot Verify: to be implemented - ); }; diff --git a/apps/web/src/components/WalletConnect/SessionProposalModal.tsx b/apps/web/src/components/WalletConnect/SessionProposalModal.tsx index 0122248b56..91b7c4c188 100644 --- a/apps/web/src/components/WalletConnect/SessionProposalModal.tsx +++ b/apps/web/src/components/WalletConnect/SessionProposalModal.tsx @@ -22,7 +22,7 @@ import { useToggleWcPeerListUpdated, walletKit, } from "@umami/state"; -import { type SessionTypes } from "@walletconnect/types"; +import { type SessionTypes, type Verify } from "@walletconnect/types"; import { buildApprovedNamespaces, getSdkError } from "@walletconnect/utils"; import { FormProvider, useForm } from "react-hook-form"; @@ -46,6 +46,10 @@ export const SessionProposalModal = ({ const { onClose } = useDynamicModalContext(); const { isLoading, handleAsyncAction } = useAsyncActionHandler(); + const verifyContext: Verify.Context = proposal.verifyContext; + const isScam = verifyContext.verified.isScam ?? false; + const validationStatus = verifyContext.verified.validation; + const form = useForm<{ address: string }>({ mode: "onBlur", }); @@ -97,6 +101,7 @@ export const SessionProposalModal = ({ + Requested permissions @@ -132,7 +137,6 @@ export const SessionProposalModal = ({ {network} - @@ -141,7 +145,7 @@ export const SessionProposalModal = ({