From 30225789806d2d9289c28b0248b9ba220bc49753 Mon Sep 17 00:00:00 2001 From: KillariDev Date: Fri, 29 Dec 2023 11:43:21 +0200 Subject: [PATCH 1/2] There should be no account risks or blocked accounts --- .../ConnectedAccountBlocked/index.tsx | 56 ------------------- src/components/TopLevelModals/index.tsx | 8 --- src/hooks/useAccountRiskCheck.test.ts | 56 ------------------- src/hooks/useAccountRiskCheck.ts | 40 ------------- 4 files changed, 160 deletions(-) delete mode 100644 src/components/ConnectedAccountBlocked/index.tsx delete mode 100644 src/hooks/useAccountRiskCheck.test.ts delete mode 100644 src/hooks/useAccountRiskCheck.ts diff --git a/src/components/ConnectedAccountBlocked/index.tsx b/src/components/ConnectedAccountBlocked/index.tsx deleted file mode 100644 index a73be912016..00000000000 --- a/src/components/ConnectedAccountBlocked/index.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { Trans } from '@lingui/macro' -import Column from 'components/Column' -import { BlockedIcon } from 'components/TokenSafety/TokenSafetyIcon' -import styled, { useTheme } from 'styled-components' -import { ExternalLink, ThemedText } from 'theme/components' -import { CopyHelper } from 'theme/components' - -import Modal from '../Modal' - -const ContentWrapper = styled(Column)` - align-items: center; - margin: 32px; - text-align: center; - font-size: 12px; -` -interface ConnectedAccountBlockedProps { - account?: string | null - isOpen: boolean -} - -export default function ConnectedAccountBlocked(props: ConnectedAccountBlockedProps) { - const theme = useTheme() - return ( - - - - - Blocked address - - - {props.account} - - - This address is blocked on the Uniswap Labs interface because it is associated with one or more{' '} - - blocked activities - - . - - - If you believe this is an error, please send an email including your address to {' '} - - - - compliance@uniswap.org - - - - ) -} diff --git a/src/components/TopLevelModals/index.tsx b/src/components/TopLevelModals/index.tsx index b5474782ead..056fcff9846 100644 --- a/src/components/TopLevelModals/index.tsx +++ b/src/components/TopLevelModals/index.tsx @@ -1,12 +1,9 @@ -import { useWeb3React } from '@web3-react/core' import { OffchainActivityModal } from 'components/AccountDrawer/MiniPortfolio/Activity/OffchainActivityModal' import AirdropModal from 'components/AirdropModal' import AddressClaimModal from 'components/claim/AddressClaimModal' -import ConnectedAccountBlocked from 'components/ConnectedAccountBlocked' import FiatOnrampModal from 'components/FiatOnrampModal' import { UkDisclaimerModal } from 'components/NavBar/UkDisclaimerModal' import DevFlagsBox from 'dev/DevFlagsBox' -import useAccountRiskCheck from 'hooks/useAccountRiskCheck' import Bag from 'nft/components/bag/Bag' import TransactionCompleteModal from 'nft/components/collection/TransactionCompleteModal' import { useModalIsOpen, useToggleModal } from 'state/application/hooks' @@ -16,16 +13,11 @@ import { isDevelopmentEnv, isStagingEnv } from 'utils/env' export default function TopLevelModals() { const addressClaimOpen = useModalIsOpen(ApplicationModal.ADDRESS_CLAIM) const addressClaimToggle = useToggleModal(ApplicationModal.ADDRESS_CLAIM) - const blockedAccountModalOpen = useModalIsOpen(ApplicationModal.BLOCKED_ACCOUNT) - const { account } = useWeb3React() - useAccountRiskCheck(account) - const accountBlocked = Boolean(blockedAccountModalOpen && account) const shouldShowDevFlags = isDevelopmentEnv() || isStagingEnv() return ( <> - diff --git a/src/hooks/useAccountRiskCheck.test.ts b/src/hooks/useAccountRiskCheck.test.ts deleted file mode 100644 index ecd8246e197..00000000000 --- a/src/hooks/useAccountRiskCheck.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { ApplicationModal, setOpenModal } from 'state/application/reducer' -import { renderHook, waitFor } from 'test-utils/render' - -import useAccountRiskCheck from './useAccountRiskCheck' - -// Mock the useAppDispatch hook -const dispatchMock = jest.fn() -jest.mock('state/hooks', () => ({ - useAppDispatch: () => dispatchMock, -})) - -describe('useAccountRiskCheck', () => { - it('should handle blocked account', async () => { - const account = 'blocked-account' - const mockResponse = { block: true } - const fetchMock = jest.spyOn(window, 'fetch').mockResolvedValueOnce({ - json: jest.fn().mockResolvedValueOnce(mockResponse), - } as any) - - renderHook(() => useAccountRiskCheck(account)) - - await waitFor(() => { - expect(fetchMock).toHaveBeenCalledWith('https://api.uniswap.org/v1/screen', { - method: 'POST', - headers: new Headers({ - 'Content-Type': 'application/json', - }), - body: JSON.stringify({ address: account }), - }) - - expect(dispatchMock).toHaveBeenCalledWith(setOpenModal(ApplicationModal.BLOCKED_ACCOUNT)) - }) - }) - - it('should handle non-blocked account', async () => { - const account = 'non-blocked-account' - const mockResponse = { block: false } - const fetchMock = jest.spyOn(window, 'fetch').mockResolvedValueOnce({ - json: jest.fn().mockResolvedValueOnce(mockResponse), - } as any) - - renderHook(() => useAccountRiskCheck(account)) - - await waitFor(() => { - expect(fetchMock).toHaveBeenCalledWith('https://api.uniswap.org/v1/screen', { - method: 'POST', - headers: new Headers({ - 'Content-Type': 'application/json', - }), - body: JSON.stringify({ address: account }), - }) - - expect(dispatchMock).not.toHaveBeenCalledWith(setOpenModal(ApplicationModal.BLOCKED_ACCOUNT)) - }) - }) -}) diff --git a/src/hooks/useAccountRiskCheck.ts b/src/hooks/useAccountRiskCheck.ts deleted file mode 100644 index a01b51b6440..00000000000 --- a/src/hooks/useAccountRiskCheck.ts +++ /dev/null @@ -1,40 +0,0 @@ -import ms from 'ms' -import { useEffect } from 'react' -import { ApplicationModal, setOpenModal } from 'state/application/reducer' -import { useAppDispatch } from 'state/hooks' - -export default function useAccountRiskCheck(account: string | null | undefined) { - const dispatch = useAppDispatch() - - useEffect(() => { - if (account) { - const riskCheckLocalStorageKey = `risk-check-${account}` - const now = Date.now() - try { - // Check local browser cache - const storedTime = localStorage.getItem(riskCheckLocalStorageKey) - const checkExpirationTime = storedTime ? parseInt(storedTime) : now - 1 - if (checkExpirationTime < Date.now()) { - const headers = new Headers({ 'Content-Type': 'application/json' }) - fetch('https://api.uniswap.org/v1/screen', { - method: 'POST', - headers, - body: JSON.stringify({ address: account }), - }) - .then((res) => res.json()) - .then((data) => { - if (data.block) { - dispatch(setOpenModal(ApplicationModal.BLOCKED_ACCOUNT)) - } - }) - .catch(() => { - dispatch(setOpenModal(null)) - }) - } - } finally { - // Set item to have 1 day local cache storage - localStorage.setItem(riskCheckLocalStorageKey, (now + ms(`1d`)).toString()) - } - } - }, [account, dispatch]) -} From 3737d0ff99f90897a56ec7e4cbac36c8527f45f9 Mon Sep 17 00:00:00 2001 From: KillariDev Date: Tue, 2 Jan 2024 10:42:06 +0200 Subject: [PATCH 2/2] don't export BlockedIcon --- src/components/TokenSafety/TokenSafetyIcon.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TokenSafety/TokenSafetyIcon.tsx b/src/components/TokenSafety/TokenSafetyIcon.tsx index a63b242e604..2c50139ac73 100644 --- a/src/components/TokenSafety/TokenSafetyIcon.tsx +++ b/src/components/TokenSafety/TokenSafetyIcon.tsx @@ -18,7 +18,7 @@ const WarningIcon = styled(AlertTriangle)` color: ${({ theme }) => theme.neutral3}; ` -export const BlockedIcon = styled(Slash)` +const BlockedIcon = styled(Slash)` ${WarningIconStyle} color: ${({ theme }) => theme.neutral2}; `