import { t } from '@vegaprotocol/react-helpers'; import { Dialog, Icon, Intent, Loader } from '@vegaprotocol/ui-toolkit'; import { isEthereumError } from '../ethereum-error'; import type { EthTxState, TxError } from '../use-ethereum-transaction'; import { EthTxStatus } from '../use-ethereum-transaction'; import { ConfirmRow, TxRow, ConfirmationEventRow } from './dialog-rows'; export interface EthereumTransactionDialogProps { title: string; onChange: (isOpen: boolean) => void; transaction: EthTxState; // Undefined means this dialog isn't expecting an additional event for a complete state, a boolean // value means it is but hasn't been received yet requiredConfirmations?: number; } export const EthereumTransactionDialog = ({ onChange, title, transaction, requiredConfirmations = 1, }: EthereumTransactionDialogProps) => { const { status, error, confirmations, txHash } = transaction; return ( ); }; export const TransactionContent = ({ status, error, txHash, confirmations, requiredConfirmations = 1, }: { status: EthTxStatus; error: TxError | null; txHash: string | null; confirmations: number; requiredConfirmations?: number; }) => { if (status === EthTxStatus.Error) { let errorMessage = ''; if (isEthereumError(error)) { errorMessage = error.reason; } else if (error instanceof Error) { errorMessage = error.message; } return (
{t('Error')}: {errorMessage}
); } return (