Add warning for input decoded from 4bytes signatures wuthout param names

This commit is contained in:
Willian Mitsuda 2021-09-25 14:45:12 -03:00
parent b57518ba96
commit e4fa639e69
3 changed files with 12 additions and 3 deletions

View File

@ -25,7 +25,7 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
<tr className="grid grid-cols-12 gap-x-2 py-2 hover:bg-gray-100"> <tr className="grid grid-cols-12 gap-x-2 py-2 hover:bg-gray-100">
<td className="col-span-3 pl-1"> <td className="col-span-3 pl-1">
{prefix && <span className="text-gray-300">{prefix}</span>} {prefix && <span className="text-gray-300">{prefix}</span>}
{paramType.name}{" "} {paramType.name ?? <span className="italic">param_{i}</span>}{" "}
{i !== undefined && ( {i !== undefined && (
<span className="text-gray-400 text-xs">({i})</span> <span className="text-gray-400 text-xs">({i})</span>
)} )}
@ -65,7 +65,8 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
</tr> </tr>
{paramType.baseType === "tuple" && {paramType.baseType === "tuple" &&
r.map((e: any, idx: number) => ( r.map((e: any, idx: number) => (
<DecodedParamRow key={idx} <DecodedParamRow
key={idx}
prefix={paramType.name + "."} prefix={paramType.name + "."}
r={e} r={e}
paramType={paramType.components[idx]} paramType={paramType.components[idx]}

View File

@ -7,14 +7,16 @@ type DecodedParamsTableProps = {
args: Result; args: Result;
paramTypes: ParamType[]; paramTypes: ParamType[];
txData: TransactionData; txData: TransactionData;
hasParamNames?: boolean;
}; };
const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({ const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
args, args,
paramTypes, paramTypes,
txData, txData,
hasParamNames = true,
}) => ( }) => (
<table className="border rounded w-full"> <table className="border w-full">
<thead> <thead>
<tr className="grid grid-cols-12 text-left gap-x-2 py-2 bg-gray-100"> <tr className="grid grid-cols-12 text-left gap-x-2 py-2 bg-gray-100">
<th className="col-span-3 pl-1"> <th className="col-span-3 pl-1">
@ -23,6 +25,11 @@ const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
<th className="col-span-1">type</th> <th className="col-span-1">type</th>
<th className="col-span-8 pr-1">value</th> <th className="col-span-8 pr-1">value</th>
</tr> </tr>
{!hasParamNames && (
<tr className="grid grid-cols-12 text-left gap-x-2 py-2 bg-yellow-100 text-red-700">
<th className="col-span-12 px-1">Parameter names are not available.</th>
</tr>
)}
</thead> </thead>
<tbody className="divide-y"> <tbody className="divide-y">
{args.map((r, i) => ( {args.map((r, i) => (

View File

@ -352,6 +352,7 @@ const Details: React.FC<DetailsProps> = ({
args={resolvedTxDesc.args} args={resolvedTxDesc.args}
paramTypes={resolvedTxDesc.functionFragment.inputs} paramTypes={resolvedTxDesc.functionFragment.inputs}
txData={txData} txData={txData}
hasParamNames={resolvedTxDesc === txDesc}
/> />
)} )}
</Tab.Panel> </Tab.Panel>