Add 4bytes decoding support to trace view

This commit is contained in:
Willian Mitsuda 2021-10-27 01:08:26 -03:00
parent 5229cb8c95
commit 48986de7f3
2 changed files with 7 additions and 4 deletions

View File

@ -2,7 +2,7 @@ import React from "react";
import AddressHighlighter from "../components/AddressHighlighter"; import AddressHighlighter from "../components/AddressHighlighter";
import DecoratedAddressLink from "../components/DecoratedAddressLink"; import DecoratedAddressLink from "../components/DecoratedAddressLink";
import { TransactionData } from "../types"; import { TransactionData } from "../types";
import { rawInputTo4Bytes } from "../use4Bytes"; import { rawInputTo4Bytes, use4Bytes } from "../use4Bytes";
import { TraceGroup } from "../useErigonHooks"; import { TraceGroup } from "../useErigonHooks";
type TraceItemProps = { type TraceItemProps = {
@ -13,6 +13,8 @@ type TraceItemProps = {
const TraceItem: React.FC<TraceItemProps> = ({ t, txData, last }) => { const TraceItem: React.FC<TraceItemProps> = ({ t, txData, last }) => {
const raw4Bytes = rawInputTo4Bytes(t.input); const raw4Bytes = rawInputTo4Bytes(t.input);
const fourBytesEntry = use4Bytes(raw4Bytes);
return ( return (
<> <>
<div className="flex"> <div className="flex">
@ -36,7 +38,9 @@ const TraceItem: React.FC<TraceItemProps> = ({ t, txData, last }) => {
</AddressHighlighter> </AddressHighlighter>
</span> </span>
<span>.</span> <span>.</span>
<span>{raw4Bytes}</span> <span className="font-bold text-blue-900">
{fourBytesEntry ? fourBytesEntry.name : raw4Bytes}
</span>
<span>(</span> <span>(</span>
{t.input.length > 10 && ( {t.input.length > 10 && (
<span className="whitespace-nowrap"> <span className="whitespace-nowrap">

View File

@ -61,8 +61,7 @@ export const use4Bytes = (
const sigs = await res.text(); const sigs = await res.text();
const sig = sigs.split(";")[0]; const sig = sigs.split(";")[0];
const cut = sig.indexOf("("); const cut = sig.indexOf("(");
let method = sig.slice(0, cut); const method = sig.slice(0, cut);
method = method.charAt(0).toUpperCase() + method.slice(1);
const entry: FourBytesEntry = { const entry: FourBytesEntry = {
name: method, name: method,