Custom formatting for bytes param type (no fixed size)

This commit is contained in:
Willian Mitsuda 2021-09-18 17:53:02 -03:00
parent 698e2a365c
commit 101aa5a21f
1 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,5 @@
import React from "react";
import { LogDescription, ParamType, Result } from "@ethersproject/abi";
import { ParamType, Result } from "@ethersproject/abi";
import AddressHighlighter from "../components/AddressHighlighter";
import DecoratedAddressLink from "../components/DecoratedAddressLink";
import Copy from "../components/Copy";
@ -51,6 +51,14 @@ const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
<span className={`${r ? "text-green-700" : "text-red-700"}`}>
{r.toString()}
</span>
) : paramTypes[i].type === "bytes" ? (
<span>
{r.toString()}{" "}
<span className="font-sans text-xs text-gray-400">
{r.toString().length / 2 - 1}{" "}
{r.toString().length / 2 - 1 === 1 ? "byte" : "bytes"}
</span>
</span>
) : (
r.toString()
)}