import React from "react";
import { Currency } from "@uniswap/sdk-core";
import styled from "styled-components";
import { getExplorerLink, ExplorerDataType } from "../../utils/getExplorerLink";
import Modal from "../Modal";
import { ExternalLink } from "../../theme";
import { Text } from "rebass";
import { CloseIcon } from "../../theme/components";
import { RowBetween } from "../Row";
import { AlertTriangle, ArrowUpCircle } from "react-feather";
import { ButtonPrimary } from "../Button";
import { AutoColumn, ColumnCenter } from "../Column";
import { useWeb3 } from "../../web3";
import useTheme from "../../hooks/useTheme";
import Loader from "../Loader";
const Wrapper = styled.div`
width: 100%;
padding: 1rem;
`;
const Section = styled(AutoColumn)<{ inline?: boolean }>`
padding: ${({ inline }) => (inline ? "0" : "0")};
`;
const BottomSection = styled(Section)`
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
`;
const ConfirmedIcon = styled(ColumnCenter)<{ inline?: boolean }>`
padding: ${({ inline }) => (inline ? "20px 0" : "60px 0;")};
`;
export function ConfirmationPendingContent({
onDismiss,
pendingText,
inline,
}: {
onDismiss: () => void;
pendingText: string;
inline?: boolean; // not in modal
}) {
return (
{!inline && (
)}
{/* */}
Waiting For Confirmation
{pendingText}
Confirm this transaction in your wallet
);
}
export function TransactionSubmittedContent({
onDismiss,
chainId,
hash,
inline,
}: {
onDismiss: () => void;
hash: string | undefined;
chainId: number;
currencyToAdd?: Currency | undefined;
inline?: boolean; // not in modal
}) {
const theme = useTheme();
return (
{!inline && (
)}
Transaction Submitted
{chainId && hash && (
View on Block Explorer
)}
{inline ? "Return" : "Close"}
);
}
export function ConfirmationModalContent({
title,
bottomContent,
onDismiss,
topContent,
}: {
title: string;
onDismiss: () => void;
topContent: () => React.ReactNode;
bottomContent?: () => React.ReactNode | undefined;
}) {
return (
{bottomContent && (
{bottomContent()}
)}
);
}
export function TransactionErrorContent({
message,
onDismiss,
}: {
message: string;
onDismiss: () => void;
}) {
const theme = useTheme();
return (
Dismiss
);
}
interface ConfirmationModalProps {
isOpen: boolean;
onDismiss: () => void;
hash: string | undefined;
content: () => React.ReactNode;
attemptingTxn: boolean;
pendingText: string;
currencyToAdd?: Currency | undefined;
}
export default function TransactionConfirmationModal({
isOpen,
onDismiss,
attemptingTxn,
hash,
pendingText,
content,
currencyToAdd,
}: ConfirmationModalProps) {
const { chainId } = useWeb3();
if (!chainId) return null;
// confirmation screen
return (
{attemptingTxn ? (
) : hash ? (
) : (
content()
)}
);
}