Add missing resolvers support on decoded inputs and logs table

This commit is contained in:
Willian Mitsuda 2021-11-03 09:14:52 -03:00
parent 03e48f678c
commit 8efe230bc8
5 changed files with 22 additions and 2 deletions

View File

@ -375,6 +375,7 @@ const Details: React.FC<DetailsProps> = ({
hasParamNames={resolvedTxDesc === txDesc}
userMethod={userMethod}
devMethod={devMethod}
resolvedAddresses={resolvedAddresses}
/>
)}
</Tab.Panel>

View File

@ -114,6 +114,7 @@ const LogEntry: React.FC<LogEntryProps> = ({
paramTypes={resolvedLogDesc.eventFragment.inputs}
txData={txData}
hasParamNames={resolvedLogDesc === logDesc}
resolvedAddresses={resolvedAddresses}
/>
</div>
</div>

View File

@ -3,13 +3,19 @@ import AddressHighlighter from "../../components/AddressHighlighter";
import DecoratedAddressLink from "../../components/DecoratedAddressLink";
import Copy from "../../components/Copy";
import { TransactionData } from "../../types";
import { ResolvedAddresses } from "../../api/address-resolver";
type AddressDecoderProps = {
r: any;
txData: TransactionData;
resolvedAddresses?: ResolvedAddresses | undefined;
};
const AddressDecoder: React.FC<AddressDecoderProps> = ({ r, txData }) => (
const AddressDecoder: React.FC<AddressDecoderProps> = ({
r,
txData,
resolvedAddresses,
}) => (
<div className="flex items-baseline space-x-2 -ml-1 mr-3">
<AddressHighlighter address={r.toString()}>
<DecoratedAddressLink
@ -17,6 +23,7 @@ const AddressDecoder: React.FC<AddressDecoderProps> = ({ r, txData }) => (
miner={r.toString() === txData.confirmedData?.miner}
txFrom={r.toString() === txData.from}
txTo={r.toString() === txData.to}
resolvedAddresses={resolvedAddresses}
/>
</AddressHighlighter>
<Copy value={r.toString()} />

View File

@ -9,6 +9,7 @@ import AddressDecoder from "./AddressDecoder";
import BooleanDecoder from "./BooleanDecoder";
import BytesDecoder from "./BytesDecoder";
import { TransactionData } from "../../types";
import { ResolvedAddresses } from "../../api/address-resolver";
type DecodedParamRowProps = {
prefix?: ReactNode;
@ -18,6 +19,7 @@ type DecodedParamRowProps = {
txData: TransactionData;
arrayElem?: number | undefined;
help?: string | undefined;
resolvedAddresses?: ResolvedAddresses | undefined;
};
const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
@ -28,6 +30,7 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
txData,
arrayElem,
help,
resolvedAddresses,
}) => {
const [showHelp, setShowHelp] = useState<boolean>(false);
@ -72,7 +75,11 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
{paramType.baseType === "uint256" ? (
<Uint256Decoder r={r} />
) : paramType.baseType === "address" ? (
<AddressDecoder r={r} txData={txData} />
<AddressDecoder
r={r}
txData={txData}
resolvedAddresses={resolvedAddresses}
/>
) : paramType.baseType === "bool" ? (
<BooleanDecoder r={r} />
) : paramType.baseType === "bytes" ? (

View File

@ -3,6 +3,7 @@ import { ParamType, Result } from "@ethersproject/abi";
import DecodedParamRow from "./DecodedParamRow";
import { TransactionData } from "../../types";
import { DevMethod, UserMethod } from "../../useSourcify";
import { ResolvedAddresses } from "../../api/address-resolver";
type DecodedParamsTableProps = {
args: Result;
@ -11,6 +12,7 @@ type DecodedParamsTableProps = {
hasParamNames?: boolean;
userMethod?: UserMethod | undefined;
devMethod?: DevMethod | undefined;
resolvedAddresses?: ResolvedAddresses | undefined;
};
const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
@ -19,6 +21,7 @@ const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
txData,
hasParamNames = true,
devMethod,
resolvedAddresses,
}) => (
<table className="border w-full">
<thead>
@ -48,6 +51,7 @@ const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
paramType={paramTypes[i]}
txData={txData}
help={devMethod?.params?.[paramTypes[i].name]}
resolvedAddresses={resolvedAddresses}
/>
))}
</tbody>