import { MismatchButton } from "./MismatchButton"; import { Center, Flex, Icon, Popover, PopoverArrow, PopoverBody, PopoverContent, PopoverTrigger, Tooltip, } from "@chakra-ui/react"; import { useAccount, useAddress, useChainId } from "@thirdweb-dev/react"; import { CHAIN_ID_TO_GNOSIS } from "constants/mappings"; import React, { useEffect, useMemo, useRef, useState } from "react"; import useDimensions from "react-cool-dimensions"; import { BiTransferAlt } from "react-icons/bi"; import { FiInfo } from "react-icons/fi"; import { ButtonProps, Card, Heading, LinkButton, Text } from "tw-components"; export interface TransactionButtonProps extends Omit { transactionCount: number; isLoading: boolean; } export const TransactionButton: React.FC = ({ children, transactionCount, isLoading, size, colorScheme, variant, ...restButtonProps }) => { const { observe, width } = useDimensions(); const [{ data }] = useAccount(); const connectorRequiresExternalConfirmation = useMemo(() => { return ( data?.connector?.id === "gnosis" || data?.connector?.id === "walletConnect" ); }, [data?.connector?.id]); const initialFocusRef = useRef(null); return ( {children} This action will trigger {transactionCount}{" "} {transactionCount > 1 ? "transactions" : "transaction"}. } >
{transactionCount}
); }; interface ExternalApprovalNoticeProps { connectorId?: string; initialFocusRef: React.RefObject; } const ExternalApprovalNotice: React.FC = ({ connectorId, initialFocusRef, }) => { const address = useAddress(); const chainId = useChainId() || -1; const [showHint, setShowHint] = useState(false); useEffect(() => { const t = setTimeout(() => { setShowHint(true); }, 15_000); return () => clearTimeout(t); }, []); if (connectorId === "gnosis") { const isChainIdSupported = chainId in CHAIN_ID_TO_GNOSIS; return ( Execute Transaction You will need to execute this transaction in your Gnosis Safe to continue. {showHint && ( Once you have approved and executed the transaction in your Gnosis Safe this action will continue automatically. )} Go To Gnosis Safe ); } else if (connectorId === "walletConnect") { return ( Approve Transaction You will need to approve this transaction in your connected wallet. {showHint && ( Once you have approved the transaction in your connected wallet this action will continue automatically. )} ); } return null; };