import React from "react"; import { ConstructorFragment, EventFragment, Fragment, FunctionFragment, Interface, } from "@ethersproject/abi"; type DecodedFragmentProps = { intf: Interface; fragment: Fragment; }; const DecodedFragment: React.FC = ({ intf, fragment, }) => { let sig: string | undefined; let letter: string | undefined; let letterBg: string | undefined; if (FunctionFragment.isFunctionFragment(fragment)) { sig = intf.getSighash(fragment); letter = "F"; letterBg = "bg-purple-500"; } else if (EventFragment.isEventFragment(fragment)) { sig = intf.getEventTopic(fragment); letter = "E"; letterBg = "bg-green-300"; } else if (ConstructorFragment.isConstructorFragment(fragment)) { letter = "C"; letterBg = "bg-blue-500"; } return (
{letter && ( {letter} )} {fragment.format("full")} {sig && ( {sig} )}
); }; export default React.memo(DecodedFragment);