2021-09-17 22:42:19 +00:00
|
|
|
import React from "react";
|
2021-09-18 20:53:02 +00:00
|
|
|
import { ParamType, Result } from "@ethersproject/abi";
|
2021-09-18 21:18:38 +00:00
|
|
|
import DecodedParamRow from "./DecodedParamRow";
|
2021-09-25 20:19:49 +00:00
|
|
|
import { TransactionData } from "../../types";
|
2021-09-29 19:22:35 +00:00
|
|
|
import { DevMethod, UserMethod } from "../../useSourcify";
|
2021-09-17 22:42:19 +00:00
|
|
|
|
2021-09-18 20:41:00 +00:00
|
|
|
type DecodedParamsTableProps = {
|
|
|
|
args: Result;
|
|
|
|
paramTypes: ParamType[];
|
2021-09-18 19:10:47 +00:00
|
|
|
txData: TransactionData;
|
2021-09-25 17:45:12 +00:00
|
|
|
hasParamNames?: boolean;
|
2021-09-29 19:22:35 +00:00
|
|
|
userMethod?: UserMethod | undefined;
|
|
|
|
devMethod?: DevMethod | undefined;
|
2021-09-17 22:42:19 +00:00
|
|
|
};
|
|
|
|
|
2021-09-18 20:41:00 +00:00
|
|
|
const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
|
|
|
|
args,
|
|
|
|
paramTypes,
|
|
|
|
txData,
|
2021-09-25 17:45:12 +00:00
|
|
|
hasParamNames = true,
|
2021-09-29 19:22:35 +00:00
|
|
|
devMethod,
|
2021-09-18 20:41:00 +00:00
|
|
|
}) => (
|
2021-09-25 17:45:12 +00:00
|
|
|
<table className="border w-full">
|
2021-09-17 22:42:19 +00:00
|
|
|
<thead>
|
2021-09-18 18:52:33 +00:00
|
|
|
<tr className="grid grid-cols-12 text-left gap-x-2 py-2 bg-gray-100">
|
2021-09-17 22:42:19 +00:00
|
|
|
<th className="col-span-3 pl-1">
|
2021-09-18 21:03:54 +00:00
|
|
|
name <span className="text-gray-400 text-xs">(index)</span>
|
2021-09-17 22:42:19 +00:00
|
|
|
</th>
|
|
|
|
<th className="col-span-1">type</th>
|
|
|
|
<th className="col-span-8 pr-1">value</th>
|
|
|
|
</tr>
|
2021-09-25 17:45:12 +00:00
|
|
|
{!hasParamNames && (
|
|
|
|
<tr className="grid grid-cols-12 text-left gap-x-2 py-2 bg-yellow-100 text-red-700">
|
2021-09-25 20:19:49 +00:00
|
|
|
<th className="col-span-12 px-1">
|
2021-09-27 18:47:55 +00:00
|
|
|
{paramTypes.length > 0 && paramTypes[0].name !== null
|
|
|
|
? "Parameter names are estimated."
|
|
|
|
: "Parameter names are not available."}
|
2021-09-25 20:19:49 +00:00
|
|
|
</th>
|
2021-09-25 17:45:12 +00:00
|
|
|
</tr>
|
|
|
|
)}
|
2021-09-17 22:42:19 +00:00
|
|
|
</thead>
|
|
|
|
<tbody className="divide-y">
|
2021-09-18 20:41:00 +00:00
|
|
|
{args.map((r, i) => (
|
2021-09-18 21:18:38 +00:00
|
|
|
<DecodedParamRow
|
|
|
|
key={i}
|
|
|
|
i={i}
|
|
|
|
r={r}
|
|
|
|
paramType={paramTypes[i]}
|
|
|
|
txData={txData}
|
2021-09-29 19:22:35 +00:00
|
|
|
help={devMethod?.params?.[paramTypes[i].name]}
|
2021-09-18 21:18:38 +00:00
|
|
|
/>
|
2021-09-17 22:42:19 +00:00
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
);
|
|
|
|
|
2021-09-18 20:41:00 +00:00
|
|
|
export default React.memo(DecodedParamsTable);
|