2021-09-17 22:42:19 +00:00
|
|
|
import React from "react";
|
2021-09-18 20:41:00 +00:00
|
|
|
import { LogDescription, ParamType, Result } from "@ethersproject/abi";
|
2021-09-18 19:10:47 +00:00
|
|
|
import AddressHighlighter from "../components/AddressHighlighter";
|
|
|
|
import DecoratedAddressLink from "../components/DecoratedAddressLink";
|
|
|
|
import Copy from "../components/Copy";
|
|
|
|
import { TransactionData } from "../types";
|
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-17 22:42:19 +00:00
|
|
|
};
|
|
|
|
|
2021-09-18 20:41:00 +00:00
|
|
|
const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
|
|
|
|
args,
|
|
|
|
paramTypes,
|
|
|
|
txData,
|
|
|
|
}) => (
|
2021-09-18 19:10:47 +00:00
|
|
|
<table className="border rounded 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">
|
|
|
|
param <span className="text-gray-400 text-xs">(index)</span>
|
|
|
|
</th>
|
|
|
|
<th className="col-span-1">type</th>
|
|
|
|
<th className="col-span-8 pr-1">value</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody className="divide-y">
|
2021-09-18 20:41:00 +00:00
|
|
|
{args.map((r, i) => (
|
2021-09-18 18:52:33 +00:00
|
|
|
<tr key={i} className="grid grid-cols-12 gap-x-2 py-2">
|
2021-09-17 22:42:19 +00:00
|
|
|
<td className="col-span-3 pl-1">
|
2021-09-18 20:41:00 +00:00
|
|
|
{paramTypes[i].name}{" "}
|
2021-09-17 22:42:19 +00:00
|
|
|
<span className="text-gray-400 text-xs">({i})</span>
|
|
|
|
</td>
|
2021-09-18 20:41:00 +00:00
|
|
|
<td className="col-span-1">{paramTypes[i].type}</td>
|
2021-09-18 18:52:33 +00:00
|
|
|
<td className="col-span-8 pr-1 font-code break-all">
|
2021-09-18 20:41:00 +00:00
|
|
|
{paramTypes[i].type === "address" ? (
|
2021-09-18 19:10:47 +00:00
|
|
|
<div className="flex items-baseline space-x-2 -ml-1 mr-3">
|
|
|
|
<AddressHighlighter address={r.toString()}>
|
|
|
|
<DecoratedAddressLink
|
|
|
|
address={r.toString()}
|
|
|
|
miner={r.toString() === txData.confirmedData?.miner}
|
|
|
|
txFrom={r.toString() === txData.from}
|
|
|
|
txTo={r.toString() === txData.to}
|
|
|
|
/>
|
|
|
|
</AddressHighlighter>
|
|
|
|
<Copy value={r.toString()} />
|
|
|
|
</div>
|
2021-09-18 20:43:47 +00:00
|
|
|
) : paramTypes[i].type === "bool" ? (
|
|
|
|
<span className={`${r ? "text-green-700" : "text-red-700"}`}>
|
|
|
|
{r.toString()}
|
|
|
|
</span>
|
2021-09-18 19:10:47 +00:00
|
|
|
) : (
|
|
|
|
r.toString()
|
|
|
|
)}
|
2021-09-18 18:52:33 +00:00
|
|
|
</td>
|
2021-09-17 22:42:19 +00:00
|
|
|
</tr>
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
);
|
|
|
|
|
2021-09-18 20:41:00 +00:00
|
|
|
export default React.memo(DecodedParamsTable);
|