import React, { ReactNode, useState } from "react"; import { ParamType } from "@ethersproject/abi"; import { Switch } from "@headlessui/react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faQuestionCircle } from "@fortawesome/free-regular-svg-icons/faQuestionCircle"; import { faQuestionCircle as faQuestionCircleSolid } from "@fortawesome/free-solid-svg-icons/faQuestionCircle"; import Uint256Decoder from "./Uint256Decoder"; import AddressDecoder from "./AddressDecoder"; import BooleanDecoder from "./BooleanDecoder"; import BytesDecoder from "./BytesDecoder"; import { TransactionData } from "../../types"; type DecodedParamRowProps = { prefix?: ReactNode; i?: number | undefined; r: any; paramType: ParamType; txData: TransactionData; arrayElem?: number | undefined; help?: string | undefined; }; const DecodedParamRow: React.FC = ({ prefix, i, r, paramType, txData, arrayElem, help, }) => { const [showHelp, setShowHelp] = useState(false); return ( <>
{prefix && {prefix}} {arrayElem !== undefined ? ( {" "} [{arrayElem}] ) : ( <> {paramType.name ?? param_{i}}{" "} {i !== undefined && ( ({i}) )} )} {help && ( )}
{help && showHelp &&
{help}
} {paramType.type} {paramType.baseType === "uint256" ? ( ) : paramType.baseType === "address" ? ( ) : paramType.baseType === "bool" ? ( ) : paramType.baseType === "bytes" ? ( ) : paramType.baseType === "tuple" || paramType.baseType === "array" ? ( <> ) : ( r.toString() )} {paramType.baseType === "tuple" && r.map((e: any, idx: number) => ( param_{i}. ) } i={idx} r={e} paramType={paramType.components[idx]} txData={txData} /> ))} {paramType.baseType === "array" && r.map((e: any, idx: number) => ( param_{i}} r={e} paramType={paramType.arrayChildren} txData={txData} arrayElem={idx} /> ))} ); }; export default React.memo(DecodedParamRow);