import { useEffect, useRef } from "react"; import { trackPayEvent } from "../../../../analytics/track/pay.js"; import type { Chain } from "../../../../chains/types.js"; import type { ThirdwebClient } from "../../../../client/client.js"; import { iconSize } from "../../../core/design-system/index.js"; import { useChainMetadata } from "../../../core/hooks/others/useChainQuery.js"; import { AccentFailIcon } from "../ConnectWallet/icons/AccentFailIcon.js"; import { Container } from "../components/basic.js"; import { Spacer } from "../components/Spacer.js"; import { Text } from "../components/text.js"; type UnsupportedTokenScreenProps = { /** * The chain the token is on */ chain: Chain; client: ThirdwebClient; tokenAddress: string; }; /** * Screen displayed when a specified token is not supported by the Bridge API * @internal */ export function UnsupportedTokenScreen(props: UnsupportedTokenScreenProps) { const { chain, tokenAddress, client } = props; const { data: chainMetadata } = useChainMetadata(chain); const hasFiredUnsupportedEvent = useRef(false); useEffect(() => { if (hasFiredUnsupportedEvent.current) return; hasFiredUnsupportedEvent.current = true; trackPayEvent({ chainId: chain.id, client, event: "ub:ui:unsupported_token", fromToken: tokenAddress, }); }, [chain.id, client, tokenAddress]); if (chainMetadata?.testnet) { return ( {/* Error Icon */} {/* Title */} Testnet Not Supported {/* Description */} Bridge does not support testnets at this time. ); } return ( {/* Error Icon */} {/* Title */} Token Not Supported {/* Description */} This token or chain is not supported by the Bridge ); }