import React, { useContext } from "react"; import { BigNumber } from "@ethersproject/bignumber"; import { formatEther } from "@ethersproject/units"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight"; import { faCaretRight } from "@fortawesome/free-solid-svg-icons/faCaretRight"; import { faSackDollar } from "@fortawesome/free-solid-svg-icons/faSackDollar"; import AddressHighlighter from "./AddressHighlighter"; import DecoratedAddressLink from "./DecoratedAddressLink"; import USDAmount from "./USDAmount"; import { RuntimeContext } from "../useRuntime"; import { useHasCode } from "../useErigonHooks"; import { useChainInfo } from "../useChainInfo"; import { TransactionData, InternalOperation } from "../types"; type InternalTransferProps = { txData: TransactionData; internalOp: InternalOperation; // TODO: migrate all this logic to SWR ethUSDPrice: BigNumber | undefined; }; const InternalTransfer: React.FC = ({ txData, internalOp, ethUSDPrice, }) => { const { nativeCurrency: { symbol, decimals }, } = useChainInfo(); const fromMiner = txData.confirmedData?.miner !== undefined && internalOp.from === txData.confirmedData.miner; const toMiner = txData.confirmedData?.miner !== undefined && internalOp.to === txData.confirmedData.miner; const { provider } = useContext(RuntimeContext); const fromHasCode = useHasCode( provider, internalOp.from, txData.confirmedData ? txData.confirmedData.blockNumber - 1 : undefined ); const toHasCode = useHasCode( provider, internalOp.to, txData.confirmedData ? txData.confirmedData.blockNumber - 1 : undefined ); return (
TRANSFER
{formatEther(internalOp.value)} {symbol} {ethUSDPrice && ( )}
); }; export default InternalTransfer;