Add tuple support
This commit is contained in:
parent
f2d6bc54a9
commit
d007f10e7a
@ -6,6 +6,7 @@ import { ParamType } from "@ethersproject/abi";
|
|||||||
import { TransactionData } from "../types";
|
import { TransactionData } from "../types";
|
||||||
|
|
||||||
type DecodedParamRowProps = {
|
type DecodedParamRowProps = {
|
||||||
|
prefix?: string;
|
||||||
i?: number | undefined;
|
i?: number | undefined;
|
||||||
r: any;
|
r: any;
|
||||||
paramType: ParamType;
|
paramType: ParamType;
|
||||||
@ -13,22 +14,25 @@ type DecodedParamRowProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
||||||
|
prefix,
|
||||||
i,
|
i,
|
||||||
r,
|
r,
|
||||||
paramType,
|
paramType,
|
||||||
txData,
|
txData,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<tr className="grid grid-cols-12 gap-x-2 py-2">
|
<tr className="grid grid-cols-12 gap-x-2 py-2">
|
||||||
<td className="col-span-3 pl-1">
|
<td className="col-span-3 pl-1">
|
||||||
|
{prefix && <span className="text-gray-300">{prefix}</span>}
|
||||||
{paramType.name}{" "}
|
{paramType.name}{" "}
|
||||||
{i !== undefined && (
|
{i !== undefined && (
|
||||||
<span className="text-gray-400 text-xs">({i})</span>
|
<span className="text-gray-400 text-xs">({i})</span>
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td className="col-span-1">{paramType.type}</td>
|
<td className="col-span-1 text-gray-500">{paramType.type}</td>
|
||||||
<td className="col-span-8 pr-1 font-code break-all">
|
<td className="col-span-8 pr-1 font-code break-all">
|
||||||
{paramType.type === "address" ? (
|
{paramType.baseType === "address" ? (
|
||||||
<div className="flex items-baseline space-x-2 -ml-1 mr-3">
|
<div className="flex items-baseline space-x-2 -ml-1 mr-3">
|
||||||
<AddressHighlighter address={r.toString()}>
|
<AddressHighlighter address={r.toString()}>
|
||||||
<DecoratedAddressLink
|
<DecoratedAddressLink
|
||||||
@ -40,11 +44,11 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
|||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
<Copy value={r.toString()} />
|
<Copy value={r.toString()} />
|
||||||
</div>
|
</div>
|
||||||
) : paramType.type === "bool" ? (
|
) : paramType.baseType === "bool" ? (
|
||||||
<span className={`${r ? "text-green-700" : "text-red-700"}`}>
|
<span className={`${r ? "text-green-700" : "text-red-700"}`}>
|
||||||
{r.toString()}
|
{r.toString()}
|
||||||
</span>
|
</span>
|
||||||
) : paramType.type === "bytes" ? (
|
) : paramType.baseType === "bytes" ? (
|
||||||
<span>
|
<span>
|
||||||
{r.toString()}{" "}
|
{r.toString()}{" "}
|
||||||
<span className="font-sans text-xs text-gray-400">
|
<span className="font-sans text-xs text-gray-400">
|
||||||
@ -52,11 +56,23 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
|||||||
{r.toString().length / 2 - 1 === 1 ? "byte" : "bytes"}
|
{r.toString().length / 2 - 1 === 1 ? "byte" : "bytes"}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
) : paramType.baseType === "tuple" ? (
|
||||||
|
<></>
|
||||||
) : (
|
) : (
|
||||||
r.toString()
|
r.toString()
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{paramType.baseType === "tuple" &&
|
||||||
|
r.map((e: any, idx: number) => (
|
||||||
|
<DecodedParamRow
|
||||||
|
prefix={paramType.name + "."}
|
||||||
|
r={e}
|
||||||
|
paramType={paramType.components[idx]}
|
||||||
|
txData={txData}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user