import React from "react"; import { BlockTag } from "@ethersproject/abstract-provider"; import { BigNumber } from "@ethersproject/bignumber"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faExclamationCircle } from "@fortawesome/free-solid-svg-icons/faExclamationCircle"; import MethodName from "../components/MethodName"; import BlockLink from "../components/BlockLink"; import TransactionLink from "../components/TransactionLink"; import DecoratedAddressLink from "../components/DecoratedAddressLink"; import TimestampAge from "../components/TimestampAge"; import AddressHighlighter from "../components/AddressHighlighter"; import TransactionDirection, { Direction, Flags, } from "../components/TransactionDirection"; import TransactionValue from "../components/TransactionValue"; import { ProcessedTransaction } from "../types"; import { FeeDisplay } from "./useFeeToggler"; import { formatValue } from "../components/formatter"; import ETH2USDValue from "../components/ETH2USDValue"; import { ResolvedAddresses } from "../api/address-resolver"; type TransactionItemProps = { tx: ProcessedTransaction; ensCache?: ResolvedAddresses; selectedAddress?: string; feeDisplay: FeeDisplay; priceMap: Record; }; const TransactionItem: React.FC = ({ tx, ensCache, selectedAddress, feeDisplay, priceMap, }) => { 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 || tx.createdContractAddress === 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 ensCreated = ensCache && tx.createdContractAddress && ensCache[tx.createdContractAddress]; const flash = tx.gasPrice.isZero() && tx.internalMinerInteraction; return (
{tx.status === 0 && ( )}
{tx.to !== null ? : } {tx.from && ( )} {tx.to ? ( ) : ( )} {feeDisplay === FeeDisplay.TX_FEE && formatValue(tx.fee, 18)} {feeDisplay === FeeDisplay.TX_FEE_USD && (priceMap[tx.blockNumber] ? ( ) : ( "N/A" ))} {feeDisplay === FeeDisplay.GAS_PRICE && formatValue(tx.gasPrice, 9)}
); }; export default React.memo(TransactionItem);