Color topic hashes/method selectors

This commit is contained in:
Willian Mitsuda 2021-10-25 14:43:41 -03:00
parent 4acc8be926
commit 01818584b7
1 changed files with 17 additions and 1 deletions

View File

@ -18,19 +18,26 @@ const DecodedFragment: React.FC<DecodedFragmentProps> = ({
intf, intf,
fragment, fragment,
}) => { }) => {
let fragmentType: "constructor" | "event" | "function" | undefined;
let sig: string | undefined; let sig: string | undefined;
let letter: string | undefined; let letter: string | undefined;
let letterBg: string | undefined; let letterBg: string | undefined;
let hashBg: string | undefined;
if (FunctionFragment.isFunctionFragment(fragment)) { if (FunctionFragment.isFunctionFragment(fragment)) {
fragmentType = "function";
sig = intf.getSighash(fragment); sig = intf.getSighash(fragment);
letter = "F"; letter = "F";
letterBg = "bg-purple-500"; letterBg = "bg-purple-500";
hashBg = "bg-purple-50";
} else if (EventFragment.isEventFragment(fragment)) { } else if (EventFragment.isEventFragment(fragment)) {
fragmentType = "event";
sig = intf.getEventTopic(fragment); sig = intf.getEventTopic(fragment);
letter = "E"; letter = "E";
letterBg = "bg-green-300"; letterBg = "bg-green-300";
hashBg = "bg-green-50";
} else if (ConstructorFragment.isConstructorFragment(fragment)) { } else if (ConstructorFragment.isConstructorFragment(fragment)) {
fragmentType = "constructor";
letter = "C"; letter = "C";
letterBg = "bg-blue-500"; letterBg = "bg-blue-500";
} }
@ -51,7 +58,16 @@ const DecodedFragment: React.FC<DecodedFragmentProps> = ({
{fragment.format("full")} {fragment.format("full")}
</span> </span>
{sig && ( {sig && (
<span className="text-xs border rounded-xl px-2 pt-1 font-code"> <span
className={`text-xs border rounded-xl px-2 pt-1 font-code text-gray-600 ${hashBg}`}
title={
fragmentType === "function"
? "Method Selector"
: fragmentType === "event"
? "Topic Hash"
: ""
}
>
{sig} {sig}
</span> </span>
)} )}