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

View File

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