diff --git a/src/components/MethodName.tsx b/src/components/MethodName.tsx index f084fa5..539db12 100644 --- a/src/components/MethodName.tsx +++ b/src/components/MethodName.tsx @@ -1,22 +1,12 @@ import React from "react"; -import { extract4Bytes, use4Bytes } from "../use4Bytes"; +import { useMethodSelector } from "../use4Bytes"; type MethodNameProps = { data: string; }; const MethodName: React.FC = ({ data }) => { - const rawFourBytes = extract4Bytes(data); - const fourBytesEntry = use4Bytes(rawFourBytes); - const isSimpleTransfer = data === "0x"; - const methodName = isSimpleTransfer - ? "transfer" - : fourBytesEntry?.name ?? rawFourBytes ?? "-"; - const methodTitle = isSimpleTransfer - ? "ETH Transfer" - : methodName === rawFourBytes - ? methodName - : `${methodName} [${rawFourBytes}]`; + const [isSimpleTransfer, methodName, methodTitle] = useMethodSelector(data); return (
{ + const rawFourBytes = extract4Bytes(data); + const fourBytesEntry = use4Bytes(rawFourBytes); + const isSimpleTransfer = data === "0x"; + const methodName = isSimpleTransfer + ? "transfer" + : fourBytesEntry?.name ?? rawFourBytes ?? "-"; + const methodTitle = isSimpleTransfer + ? "ETH Transfer" + : methodName === rawFourBytes + ? methodName + : `${methodName} [${rawFourBytes}]`; + + return [isSimpleTransfer, methodName, methodTitle]; +}; + export const useTransactionDescription = ( fourBytesEntry: FourBytesEntry | null | undefined, data: string | undefined,