diff --git a/src/transaction/DecodedParamRow.tsx b/src/transaction/DecodedParamRow.tsx index 5678ac8..aec65ce 100644 --- a/src/transaction/DecodedParamRow.tsx +++ b/src/transaction/DecodedParamRow.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { ReactNode } from "react"; import AddressHighlighter from "../components/AddressHighlighter"; import DecoratedAddressLink from "../components/DecoratedAddressLink"; import Copy from "../components/Copy"; @@ -6,11 +6,12 @@ import { ParamType } from "@ethersproject/abi"; import { TransactionData } from "../types"; type DecodedParamRowProps = { - prefix?: string; + prefix?: ReactNode; i?: number | undefined; r: any; paramType: ParamType; txData: TransactionData; + arrayElem?: number | undefined; }; const DecodedParamRow: React.FC = ({ @@ -19,15 +20,24 @@ const DecodedParamRow: React.FC = ({ r, paramType, txData, + arrayElem, }) => { return ( <> {prefix && {prefix}} - {paramType.name ?? param_{i}}{" "} - {i !== undefined && ( - ({i}) + {arrayElem !== undefined ? ( + {" "} + [{arrayElem}] + + ) : ( + <> + {paramType.name ?? param_{i}}{" "} + {i !== undefined && ( + ({i}) + )} + )} {paramType.type} @@ -56,7 +66,8 @@ const DecodedParamRow: React.FC = ({ {r.toString().length / 2 - 1 === 1 ? "byte" : "bytes"} - ) : paramType.baseType === "tuple" ? ( + ) : paramType.baseType === "tuple" || + paramType.baseType === "array" ? ( <> ) : ( r.toString() @@ -73,6 +84,17 @@ const DecodedParamRow: React.FC = ({ txData={txData} /> ))} + {paramType.baseType === "array" && + r.map((e: any, idx: number) => ( + param_{i}} + r={e} + paramType={paramType.arrayChildren} + txData={txData} + arrayElem={idx} + /> + ))} ); };