diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 66c34e9..d414d1e 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -37,7 +37,7 @@ import PercentagePosition from "../components/PercentagePosition"; import DecodedParamsTable from "./decoder/DecodedParamsTable"; import InputDecoder from "./decoder/InputDecoder"; import { - rawInputTo4Bytes, + extract4Bytes, use4Bytes, useTransactionDescription, } from "../use4Bytes"; @@ -74,7 +74,8 @@ const Details: React.FC = ({ txData.confirmedData?.blockBaseFeePerGas !== undefined && txData.confirmedData?.blockBaseFeePerGas !== null; - const fourBytes = txData.to !== null ? rawInputTo4Bytes(txData.data) : "0x"; + const fourBytes = + txData.to !== null ? extract4Bytes(txData.data) ?? "0x" : "0x"; const fourBytesEntry = use4Bytes(fourBytes); const fourBytesTxDesc = useTransactionDescription( fourBytesEntry, diff --git a/src/use4Bytes.ts b/src/use4Bytes.ts index 233fa3f..ea4f28c 100644 --- a/src/use4Bytes.ts +++ b/src/use4Bytes.ts @@ -21,7 +21,8 @@ export type FourBytesMap = Record; * * @param rawInput Raw tx input including the "0x" * @returns the first 4 bytes, including the "0x" or null if the input - * contains an invalid selector, e.g., txs with 0x00 data + * contains an invalid selector, e.g., txs with 0x00 data; simple transfers (0x) + * return null as well as it is not a method selector */ export const extract4Bytes = (rawInput: string): string | null => { if (rawInput.length < 10) { @@ -30,8 +31,6 @@ export const extract4Bytes = (rawInput: string): string | null => { return rawInput.slice(0, 10); }; -export const rawInputTo4Bytes = (rawInput: string) => rawInput.slice(0, 10); - const fetch4Bytes = async ( assetsURLPrefix: string, fourBytes: string