import { ChainId } from 'moonbeamswap' import React, { useContext } from 'react' import styled, { ThemeContext } from 'styled-components' import Modal from '../Modal' import { ExternalLink } from '../../theme' import { Text } from 'rebass' import { CloseIcon, Spinner } from '../../theme/components' import { RowBetween } from '../Row' import { AlertTriangle, ArrowUpCircle } from 'react-feather' import { ButtonPrimary } from '../Button' import { AutoColumn, ColumnCenter } from '../Column' import Circle from '../../assets/images/blue-loader.svg' import { getEtherscanLink } from '../../utils' import { useActiveWeb3React } from '../../hooks' const Wrapper = styled.div` width: 100%; ` const Section = styled(AutoColumn)` padding: 24px; ` const BottomSection = styled(Section)` background-color: ${({ theme }) => theme.bg2}; border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; ` const ConfirmedIcon = styled(ColumnCenter)` padding: 60px 0; ` const CustomLightSpinner = styled(Spinner)<{ size: string }>` height: ${({ size }) => size}; width: ${({ size }) => size}; ` function ConfirmationPendingContent({ onDismiss, pendingText }: { onDismiss: () => void; pendingText: string }) { return (
Waiting For Confirmation {pendingText} Confirm this transaction in your wallet
) } function TransactionSubmittedContent({ onDismiss, chainId, hash }: { onDismiss: () => void hash: string | undefined chainId: ChainId }) { const theme = useContext(ThemeContext) return (
Transaction Submitted {chainId && hash && ( View on Moonbeam explorer )} Close
) } export function ConfirmationModalContent({ title, bottomContent, onDismiss, topContent }: { title: string onDismiss: () => void topContent: () => React.ReactNode bottomContent: () => React.ReactNode }) { return (
{title} {topContent()}
{bottomContent()}
) } export function TransactionErrorContent({ message, onDismiss }: { message: string; onDismiss: () => void }) { const theme = useContext(ThemeContext) return (
Error {message}
Dismiss
) } interface ConfirmationModalProps { isOpen: boolean onDismiss: () => void hash: string | undefined content: () => React.ReactNode attemptingTxn: boolean pendingText: string } export default function TransactionConfirmationModal({ isOpen, onDismiss, attemptingTxn, hash, pendingText, content }: ConfirmationModalProps) { const { chainId } = useActiveWeb3React() if (!chainId) return null // confirmation screen return ( {attemptingTxn ? ( ) : hash ? ( ) : ( content() )} ) }