Eliminate redundant function
This commit is contained in:
parent
e9f32e3530
commit
28a216ff5f
|
@ -37,7 +37,7 @@ import PercentagePosition from "../components/PercentagePosition";
|
||||||
import DecodedParamsTable from "./decoder/DecodedParamsTable";
|
import DecodedParamsTable from "./decoder/DecodedParamsTable";
|
||||||
import InputDecoder from "./decoder/InputDecoder";
|
import InputDecoder from "./decoder/InputDecoder";
|
||||||
import {
|
import {
|
||||||
rawInputTo4Bytes,
|
extract4Bytes,
|
||||||
use4Bytes,
|
use4Bytes,
|
||||||
useTransactionDescription,
|
useTransactionDescription,
|
||||||
} from "../use4Bytes";
|
} from "../use4Bytes";
|
||||||
|
@ -74,7 +74,8 @@ const Details: React.FC<DetailsProps> = ({
|
||||||
txData.confirmedData?.blockBaseFeePerGas !== undefined &&
|
txData.confirmedData?.blockBaseFeePerGas !== undefined &&
|
||||||
txData.confirmedData?.blockBaseFeePerGas !== null;
|
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 fourBytesEntry = use4Bytes(fourBytes);
|
||||||
const fourBytesTxDesc = useTransactionDescription(
|
const fourBytesTxDesc = useTransactionDescription(
|
||||||
fourBytesEntry,
|
fourBytesEntry,
|
||||||
|
|
|
@ -21,7 +21,8 @@ export type FourBytesMap = Record<string, FourBytesEntry | null | undefined>;
|
||||||
*
|
*
|
||||||
* @param rawInput Raw tx input including the "0x"
|
* @param rawInput Raw tx input including the "0x"
|
||||||
* @returns the first 4 bytes, including the "0x" or null if the input
|
* @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 => {
|
export const extract4Bytes = (rawInput: string): string | null => {
|
||||||
if (rawInput.length < 10) {
|
if (rawInput.length < 10) {
|
||||||
|
@ -30,8 +31,6 @@ export const extract4Bytes = (rawInput: string): string | null => {
|
||||||
return rawInput.slice(0, 10);
|
return rawInput.slice(0, 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const rawInputTo4Bytes = (rawInput: string) => rawInput.slice(0, 10);
|
|
||||||
|
|
||||||
const fetch4Bytes = async (
|
const fetch4Bytes = async (
|
||||||
assetsURLPrefix: string,
|
assetsURLPrefix: string,
|
||||||
fourBytes: string
|
fourBytes: string
|
||||||
|
|
Loading…
Reference in New Issue