import type { Token } from "../../../../../bridge/index.js"; import { defineChain } from "../../../../../chains/utils.js"; import type { ThirdwebClient } from "../../../../../client/client.js"; import type { SupportedFiatCurrency } from "../../../../../pay/convert/type.js"; import type { PreparedTransaction } from "../../../../../transaction/prepare-transaction.js"; import { useCustomTheme } from "../../../../core/design-system/CustomThemeProvider.js"; import { radius, spacing } from "../../../../core/design-system/index.js"; import { useTransactionDetails } from "../../../../core/hooks/useTransactionDetails.js"; import { getFiatCurrencyIcon } from "../../ConnectWallet/screens/Buy/fiat/currencies.js"; import { FiatValue } from "../../ConnectWallet/screens/Buy/swap/FiatValue.js"; import { StepConnectorArrow } from "../../ConnectWallet/screens/Buy/swap/StepConnector.js"; import { WalletRow } from "../../ConnectWallet/screens/Buy/swap/WalletRow.js"; import { Container } from "../../components/basic.js"; import { Text } from "../../components/text.js"; import { TokenBalanceRow } from "../common/TokenBalanceRow.js"; import type { ModeInfo, PaymentMethod } from "../types.js"; export function PaymentOverview(props: { currency: SupportedFiatCurrency; receiver: string; sender?: string; client: ThirdwebClient; paymentMethod: PaymentMethod; toToken: Token; fromAmount: string; toAmount: string; metadata: { title: string | undefined; description: string | undefined; }; modeInfo: ModeInfo; }) { const theme = useCustomTheme(); const sender = props.sender || (props.paymentMethod.type === "wallet" ? props.paymentMethod.payerWallet.getAccount()?.address : undefined); const isDifferentRecipient = props.receiver.toLowerCase() !== sender?.toLowerCase(); return ( {/* Sell */} {sender && ( )} {props.paymentMethod.type === "wallet" && ( {}} style={{ background: "transparent", border: "none", borderRadius: 0, }} token={props.paymentMethod.originToken} /> )} {props.paymentMethod.type === "fiat" && ( {/* left */} {getFiatCurrencyIcon({ currency: props.paymentMethod.currency, size: "lg", })} {props.paymentMethod.currency} {props.paymentMethod.onramp.charAt(0).toUpperCase() + props.paymentMethod.onramp.slice(1)} {/* right */} {props.fromAmount} )} {/* Connector Icon */} {/* Buy */} {isDifferentRecipient && ( )} {props.modeInfo.mode === "direct_payment" && ( {props.metadata.title || "Payment"} {props.metadata.description && ( {props.metadata.description} )} {props.modeInfo.paymentInfo.amount} {props.toToken.symbol} )} {props.modeInfo.mode === "fund_wallet" && ( {}} style={{ background: "transparent", border: "none", borderRadius: 0, }} token={props.toToken} /> )} {props.modeInfo.mode === "transaction" && ( )} ); } const TransactionOverViewCompact = (props: { transaction: PreparedTransaction; paymentMethod: PaymentMethod; client: ThirdwebClient; metadata: { title: string | undefined; description: string | undefined; }; }) => { const theme = useCustomTheme(); const txInfo = useTransactionDetails({ client: props.client, transaction: props.transaction, wallet: props.paymentMethod.payerWallet, }); if (!txInfo.data) { // Skeleton loading state return ( {/* Title skeleton */}
{/* Description skeleton - only if metadata exists */} {props.metadata.description && (
)} {/* Function name skeleton */}
); } return ( {props.metadata.title || "Transaction"} {props.metadata.description && ( {props.metadata.description} )} {txInfo.data.functionInfo.functionName} ); };