From 1e276a4aae5870ae0dec19a77cbcc24a24117898 Mon Sep 17 00:00:00 2001 From: He1DAr Date: Fri, 10 Jan 2025 14:28:40 -0500 Subject: [PATCH] feat: risky tokens banner --- src/app/token/[tokenId]/PageClient.tsx | 69 ++++++++++++++++++-------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/src/app/token/[tokenId]/PageClient.tsx b/src/app/token/[tokenId]/PageClient.tsx index 3cd4f8338..5c1eea400 100644 --- a/src/app/token/[tokenId]/PageClient.tsx +++ b/src/app/token/[tokenId]/PageClient.tsx @@ -3,6 +3,7 @@ import { getHasSBTCInName, getIsSBTC } from '@/app/tokens/utils'; import { Box, Icon, Image, Link, Stack, Text } from '@chakra-ui/react'; import { SealCheck, Warning } from '@phosphor-icons/react'; +import { useMemo } from 'react'; import { Sip10Disclaimer } from '../../../common/components/Sip10Disclaimer'; import { Flex } from '../../../ui/Flex'; @@ -13,6 +14,8 @@ import { Tabs } from './Tabs'; import { TokenInfo } from './TokenInfo'; import { TokenInfoProps } from './types'; +const RISKY_TOKENS = ['SP1J45NVEGQ7ZA4M57TGF0RAB00TMYCYG00X8EF5B.granite-btc']; + export default function PageClient({ tokenId, tokenInfo, @@ -25,6 +28,49 @@ export default function PageClient({ const categories = tokenInfo.extended?.categories || []; const hasSBTCInName = getHasSBTCInName(name ?? '', symbol ?? ''); const isSBTC = getIsSBTC(tokenId); + const isRisky = RISKY_TOKENS.includes(tokenId); + const showWarning = isRisky || (hasSBTCInName && !isSBTC); + const warningMessage = useMemo(() => { + if (isRisky) { + return ( + + + + + + Warning:  + + This token may be a scam. Engaging with unverified tokens could result in loss of + funds. + + + + ); + } + if (hasSBTCInName && !isSBTC) { + return ( + + + + + + Warning:  + + This is not{' '} + + the official sBTC token + {' '} + and may be a scam. Engaging with unverified tokens could result in loss of funds. + + + + ); + } + return null; + }, [hasSBTCInName, isRisky, isSBTC]); return ( <> @@ -56,7 +102,7 @@ export default function PageClient({ )} - {hasSBTCInName && !isSBTC && ( + {!!warningMessage && ( - {hasSBTCInName && !isSBTC && ( - - - - - - Warning:  - - This is not{' '} - - the official sBTC token - {' '} - and may be a scam. Engaging with unverified tokens could result in loss of funds. - - - - )} + {warningMessage}