import React from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faExclamationCircle, faCoins, } from "@fortawesome/free-solid-svg-icons"; import MethodName from "../components/MethodName"; import BlockLink from "../components/BlockLink"; import TransactionLink from "../components/TransactionLink"; import AddressOrENSName from "../components/AddressOrENSName"; import TimestampAge from "../components/TimestampAge"; import TransactionDirection, { Direction, Flags, } from "../components/TransactionDirection"; import TransactionValue from "../components/TransactionValue"; import { ENSReverseCache, ProcessedTransaction } from "../types"; import { FeeDisplay } from "./useFeeToggler"; import { formatValue } from "../components/formatter"; type TransactionItemProps = { tx: ProcessedTransaction; ensCache?: ENSReverseCache; selectedAddress?: string; feeDisplay: FeeDisplay; }; const TransactionItem: React.FC = ({ tx, ensCache, selectedAddress, feeDisplay, }) => { let direction: Direction | undefined; if (selectedAddress) { if (tx.from === selectedAddress && tx.to === selectedAddress) { direction = Direction.SELF; } else if (tx.from === selectedAddress) { direction = Direction.OUT; } else if (tx.to === selectedAddress) { direction = Direction.IN; } else { direction = Direction.INTERNAL; } } const ensFrom = ensCache && tx.from && ensCache[tx.from]; const ensTo = ensCache && tx.to && ensCache[tx.to]; const flash = tx.gasPrice.isZero() && tx.internalMinerInteraction; return (
{tx.status === 0 && ( )}
{tx.from && (
{tx.miner && tx.miner === tx.from && ( )}
)}
{tx.to && ( )} {feeDisplay === FeeDisplay.TX_FEE ? formatValue(tx.fee, 18) : formatValue(tx.gasPrice, 9)}
); }; export default React.memo(TransactionItem);