Generalize attribute type
This commit is contained in:
parent
9954c8ac02
commit
8c46eaabb1
@ -29,7 +29,11 @@ import USDValue from "../components/USDValue";
|
||||
import FormattedBalance from "../components/FormattedBalance";
|
||||
import ETH2USDValue from "../components/ETH2USDValue";
|
||||
import TokenTransferItem from "../TokenTransferItem";
|
||||
import { TransactionData, InternalOperation } from "../types";
|
||||
import {
|
||||
TransactionData,
|
||||
InternalOperation,
|
||||
toTransactionContext,
|
||||
} from "../types";
|
||||
import PercentageBar from "../components/PercentageBar";
|
||||
import ExternalLink from "../components/ExternalLink";
|
||||
import RelativePosition from "../components/RelativePosition";
|
||||
@ -371,7 +375,7 @@ const Details: React.FC<DetailsProps> = ({
|
||||
<DecodedParamsTable
|
||||
args={resolvedTxDesc.args}
|
||||
paramTypes={resolvedTxDesc.functionFragment.inputs}
|
||||
txData={txData}
|
||||
txContext={toTransactionContext(txData)}
|
||||
hasParamNames={resolvedTxDesc === txDesc}
|
||||
userMethod={userMethod}
|
||||
devMethod={devMethod}
|
||||
|
@ -8,7 +8,7 @@ import Copy from "../components/Copy";
|
||||
import ModeTab from "../components/ModeTab";
|
||||
import DecodedParamsTable from "./decoder/DecodedParamsTable";
|
||||
import DecodedLogSignature from "./decoder/DecodedLogSignature";
|
||||
import { TransactionData } from "../types";
|
||||
import { toTransactionContext, TransactionData } from "../types";
|
||||
import { useTopic0 } from "../useTopic0";
|
||||
import { ResolvedAddresses } from "../api/address-resolver";
|
||||
|
||||
@ -112,7 +112,7 @@ const LogEntry: React.FC<LogEntryProps> = ({
|
||||
<DecodedParamsTable
|
||||
args={resolvedLogDesc.args}
|
||||
paramTypes={resolvedLogDesc.eventFragment.inputs}
|
||||
txData={txData}
|
||||
txContext={toTransactionContext(txData)}
|
||||
hasParamNames={resolvedLogDesc === logDesc}
|
||||
resolvedAddresses={resolvedAddresses}
|
||||
/>
|
||||
|
@ -2,27 +2,27 @@ import React from "react";
|
||||
import AddressHighlighter from "../../components/AddressHighlighter";
|
||||
import DecoratedAddressLink from "../../components/DecoratedAddressLink";
|
||||
import Copy from "../../components/Copy";
|
||||
import { TransactionData } from "../../types";
|
||||
import { SelectedTransactionContext } from "../../types";
|
||||
import { ResolvedAddresses } from "../../api/address-resolver";
|
||||
|
||||
type AddressDecoderProps = {
|
||||
r: string;
|
||||
txData: TransactionData;
|
||||
txContext: SelectedTransactionContext;
|
||||
resolvedAddresses?: ResolvedAddresses | undefined;
|
||||
};
|
||||
|
||||
const AddressDecoder: React.FC<AddressDecoderProps> = ({
|
||||
r,
|
||||
txData,
|
||||
txContext,
|
||||
resolvedAddresses,
|
||||
}) => (
|
||||
<div className="flex items-baseline space-x-2 -ml-1 mr-3">
|
||||
<AddressHighlighter address={r}>
|
||||
<DecoratedAddressLink
|
||||
address={r}
|
||||
miner={r === txData.confirmedData?.miner}
|
||||
txFrom={r === txData.from}
|
||||
txTo={r === txData.to}
|
||||
miner={r === txContext.miner}
|
||||
txFrom={r === txContext.from}
|
||||
txTo={r === txContext.to}
|
||||
resolvedAddresses={resolvedAddresses}
|
||||
/>
|
||||
</AddressHighlighter>
|
||||
|
@ -8,7 +8,7 @@ import Uint256Decoder from "./Uint256Decoder";
|
||||
import AddressDecoder from "./AddressDecoder";
|
||||
import BooleanDecoder from "./BooleanDecoder";
|
||||
import BytesDecoder from "./BytesDecoder";
|
||||
import { TransactionData } from "../../types";
|
||||
import { SelectedTransactionContext } from "../../types";
|
||||
import { ResolvedAddresses } from "../../api/address-resolver";
|
||||
|
||||
type DecodedParamRowProps = {
|
||||
@ -16,7 +16,7 @@ type DecodedParamRowProps = {
|
||||
i?: number | undefined;
|
||||
r: any;
|
||||
paramType: ParamType;
|
||||
txData: TransactionData;
|
||||
txContext: SelectedTransactionContext;
|
||||
arrayElem?: number | undefined;
|
||||
help?: string | undefined;
|
||||
resolvedAddresses?: ResolvedAddresses | undefined;
|
||||
@ -27,7 +27,7 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
||||
i,
|
||||
r,
|
||||
paramType,
|
||||
txData,
|
||||
txContext,
|
||||
arrayElem,
|
||||
help,
|
||||
resolvedAddresses,
|
||||
@ -77,7 +77,7 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
||||
) : paramType.baseType === "address" ? (
|
||||
<AddressDecoder
|
||||
r={r.toString()}
|
||||
txData={txData}
|
||||
txContext={txContext}
|
||||
resolvedAddresses={resolvedAddresses}
|
||||
/>
|
||||
) : paramType.baseType === "bool" ? (
|
||||
@ -106,7 +106,7 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
||||
i={idx}
|
||||
r={e}
|
||||
paramType={paramType.components[idx]}
|
||||
txData={txData}
|
||||
txContext={txContext}
|
||||
/>
|
||||
))}
|
||||
{paramType.baseType === "array" &&
|
||||
@ -116,7 +116,7 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
||||
prefix={paramType.name ?? <span className="italic">param_{i}</span>}
|
||||
r={e}
|
||||
paramType={paramType.arrayChildren}
|
||||
txData={txData}
|
||||
txContext={txContext}
|
||||
arrayElem={idx}
|
||||
/>
|
||||
))}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import React from "react";
|
||||
import { ParamType, Result } from "@ethersproject/abi";
|
||||
import DecodedParamRow from "./DecodedParamRow";
|
||||
import { TransactionData } from "../../types";
|
||||
import { SelectedTransactionContext } from "../../types";
|
||||
import { DevMethod, UserMethod } from "../../useSourcify";
|
||||
import { ResolvedAddresses } from "../../api/address-resolver";
|
||||
|
||||
type DecodedParamsTableProps = {
|
||||
args: Result;
|
||||
paramTypes: ParamType[];
|
||||
txData: TransactionData;
|
||||
txContext: SelectedTransactionContext;
|
||||
hasParamNames?: boolean;
|
||||
userMethod?: UserMethod | undefined;
|
||||
devMethod?: DevMethod | undefined;
|
||||
@ -18,7 +18,7 @@ type DecodedParamsTableProps = {
|
||||
const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
|
||||
args,
|
||||
paramTypes,
|
||||
txData,
|
||||
txContext,
|
||||
hasParamNames = true,
|
||||
devMethod,
|
||||
resolvedAddresses,
|
||||
@ -49,7 +49,7 @@ const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
|
||||
i={i}
|
||||
r={r}
|
||||
paramType={paramTypes[i]}
|
||||
txData={txData}
|
||||
txContext={txContext}
|
||||
help={devMethod?.params?.[paramTypes[i].name]}
|
||||
resolvedAddresses={resolvedAddresses}
|
||||
/>
|
||||
|
16
src/types.ts
16
src/types.ts
@ -64,6 +64,22 @@ export type ConfirmedTransactionData = {
|
||||
logs: Log[];
|
||||
};
|
||||
|
||||
export type SelectedTransactionContext = {
|
||||
from: string;
|
||||
to: string | undefined;
|
||||
miner: string | undefined;
|
||||
};
|
||||
|
||||
export const toTransactionContext = (
|
||||
txData: TransactionData
|
||||
): SelectedTransactionContext => {
|
||||
return {
|
||||
from: txData.from,
|
||||
to: txData.to,
|
||||
miner: txData.confirmedData?.miner,
|
||||
};
|
||||
};
|
||||
|
||||
// The VOID...
|
||||
export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user