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/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}; ` 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]) -}