import React, { useMemo } from "react"; import { TransactionDescription } from "@ethersproject/abi"; import { toUtf8String } from "@ethersproject/strings"; import { Tab } from "@headlessui/react"; import ModeTab from "../../components/ModeTab"; import DecodedParamsTable from "./DecodedParamsTable"; import { DevMethod, UserMethod } from "../../sourcify/useSourcify"; type InputDecoderProps = { fourBytes: string; resolvedTxDesc: TransactionDescription | null | undefined; hasParamNames: boolean; data: string; userMethod: UserMethod | undefined; devMethod: DevMethod | undefined; }; const InputDecoder: React.FC = ({ fourBytes, resolvedTxDesc, hasParamNames, data, userMethod, devMethod, }) => { const utfInput = useMemo(() => { try { return toUtf8String(data); } catch (err) { // Silently ignore on purpose return undefined; } }, [data]); return ( Decoded Raw UTF-8 {fourBytes === "0x" ? ( <>No parameters ) : resolvedTxDesc === undefined ? ( <>Waiting for data... ) : resolvedTxDesc === null ? ( <>Can't decode data ) : ( )}