Correctly render fallback function signature
This commit is contained in:
parent
852ff5f726
commit
3bfd38641b
@ -4,7 +4,7 @@ import DecoratedAddressLink from "../components/DecoratedAddressLink";
|
|||||||
import FormattedBalance from "../components/FormattedBalance";
|
import FormattedBalance from "../components/FormattedBalance";
|
||||||
import FunctionSignature from "./FunctionSignature";
|
import FunctionSignature from "./FunctionSignature";
|
||||||
import { TransactionData } from "../types";
|
import { TransactionData } from "../types";
|
||||||
import { FourBytesEntry, rawInputTo4Bytes } from "../use4Bytes";
|
import { extract4Bytes, FourBytesEntry } from "../use4Bytes";
|
||||||
import { TraceGroup } from "../useErigonHooks";
|
import { TraceGroup } from "../useErigonHooks";
|
||||||
|
|
||||||
type TraceItemProps = {
|
type TraceItemProps = {
|
||||||
@ -20,8 +20,11 @@ const TraceItem: React.FC<TraceItemProps> = ({
|
|||||||
last,
|
last,
|
||||||
fourBytesMap,
|
fourBytesMap,
|
||||||
}) => {
|
}) => {
|
||||||
const raw4Bytes = rawInputTo4Bytes(t.input);
|
const raw4Bytes = extract4Bytes(t.input);
|
||||||
const fourBytesEntry = fourBytesMap[raw4Bytes];
|
const sigText =
|
||||||
|
raw4Bytes === null
|
||||||
|
? "<fallback>"
|
||||||
|
: fourBytesMap[raw4Bytes]?.name ?? raw4Bytes;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -45,10 +48,7 @@ const TraceItem: React.FC<TraceItemProps> = ({
|
|||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
</span>
|
</span>
|
||||||
<span>.</span>
|
<span>.</span>
|
||||||
<FunctionSignature
|
<FunctionSignature callType={t.type} sig={sigText} />
|
||||||
callType={t.type}
|
|
||||||
sig={fourBytesEntry ? fourBytesEntry.name : raw4Bytes}
|
|
||||||
/>
|
|
||||||
{t.value && !t.value.isZero() && (
|
{t.value && !t.value.isZero() && (
|
||||||
<span className="text-red-700 whitespace-nowrap">
|
<span className="text-red-700 whitespace-nowrap">
|
||||||
{"{"}value: <FormattedBalance value={t.value} /> ETH{"}"}
|
{"{"}value: <FormattedBalance value={t.value} /> ETH{"}"}
|
||||||
|
@ -16,6 +16,13 @@ const simpleTransfer: FourBytesEntry = {
|
|||||||
|
|
||||||
const fullCache = new Map<string, FourBytesEntry | null>();
|
const fullCache = new Map<string, FourBytesEntry | null>();
|
||||||
|
|
||||||
|
export const extract4Bytes = (rawInput: string): string | null => {
|
||||||
|
if (rawInput.length < 10) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return rawInput.slice(0, 10);
|
||||||
|
};
|
||||||
|
|
||||||
export const rawInputTo4Bytes = (rawInput: string) => rawInput.slice(0, 10);
|
export const rawInputTo4Bytes = (rawInput: string) => rawInput.slice(0, 10);
|
||||||
|
|
||||||
const fetch4Bytes = async (
|
const fetch4Bytes = async (
|
||||||
|
Loading…
Reference in New Issue
Block a user