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} hasParamNames={resolvedTxDesc === txDesc}
userMethod={userMethod} userMethod={userMethod}
devMethod={devMethod} devMethod={devMethod}
resolvedAddresses={resolvedAddresses}
/> />
)} )}
</Tab.Panel> </Tab.Panel>

View File

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

View File

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

View File

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

View File

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