From d007f10e7a5f0cedd986d99c6a3c2ba8b4c75607 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sat, 18 Sep 2021 18:35:37 -0300 Subject: [PATCH] Add tuple support --- src/transaction/DecodedParamRow.tsx | 90 +++++++++++++++++------------ 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/src/transaction/DecodedParamRow.tsx b/src/transaction/DecodedParamRow.tsx index 3e5e2cd..68027b3 100644 --- a/src/transaction/DecodedParamRow.tsx +++ b/src/transaction/DecodedParamRow.tsx @@ -6,6 +6,7 @@ import { ParamType } from "@ethersproject/abi"; import { TransactionData } from "../types"; type DecodedParamRowProps = { + prefix?: string; i?: number | undefined; r: any; paramType: ParamType; @@ -13,50 +14,65 @@ type DecodedParamRowProps = { }; const DecodedParamRow: React.FC = ({ + prefix, i, r, paramType, txData, }) => { return ( - - - {paramType.name}{" "} - {i !== undefined && ( - ({i}) - )} - - {paramType.type} - - {paramType.type === "address" ? ( -
- - - - -
- ) : paramType.type === "bool" ? ( - - {r.toString()} - - ) : paramType.type === "bytes" ? ( - - {r.toString()}{" "} - - {r.toString().length / 2 - 1}{" "} - {r.toString().length / 2 - 1 === 1 ? "byte" : "bytes"} + <> + + + {prefix && {prefix}} + {paramType.name}{" "} + {i !== undefined && ( + ({i}) + )} + + {paramType.type} + + {paramType.baseType === "address" ? ( +
+ + + + +
+ ) : paramType.baseType === "bool" ? ( + + {r.toString()} -
- ) : ( - r.toString() - )} - - + ) : paramType.baseType === "bytes" ? ( + + {r.toString()}{" "} + + {r.toString().length / 2 - 1}{" "} + {r.toString().length / 2 - 1 === 1 ? "byte" : "bytes"} + + + ) : paramType.baseType === "tuple" ? ( + <> + ) : ( + r.toString() + )} + + + {paramType.baseType === "tuple" && + r.map((e: any, idx: number) => ( + + ))} + ); };