Replace batch calls of address resolution caches and deep props down with in-place useSWR calls
This commit is contained in:
parent
f1d06b5025
commit
ff0fd63ab9
@ -10,13 +10,11 @@ import {
|
|||||||
TokenMeta,
|
TokenMeta,
|
||||||
TokenTransfer,
|
TokenTransfer,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import { ResolvedAddresses } from "./api/address-resolver";
|
|
||||||
import { Metadata } from "./sourcify/useSourcify";
|
import { Metadata } from "./sourcify/useSourcify";
|
||||||
|
|
||||||
type TokenTransferItemProps = {
|
type TokenTransferItemProps = {
|
||||||
t: TokenTransfer;
|
t: TokenTransfer;
|
||||||
tokenMeta?: TokenMeta | null | undefined;
|
tokenMeta?: TokenMeta | null | undefined;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
metadatas: Record<ChecksummedAddress, Metadata | null | undefined>;
|
metadatas: Record<ChecksummedAddress, Metadata | null | undefined>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -24,7 +22,6 @@ type TokenTransferItemProps = {
|
|||||||
const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
|
const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
|
||||||
t,
|
t,
|
||||||
tokenMeta,
|
tokenMeta,
|
||||||
resolvedAddresses,
|
|
||||||
metadatas,
|
metadatas,
|
||||||
}) => (
|
}) => (
|
||||||
<div className="flex items-baseline space-x-2 px-2 py-1 truncate hover:bg-gray-100">
|
<div className="flex items-baseline space-x-2 px-2 py-1 truncate hover:bg-gray-100">
|
||||||
@ -37,7 +34,6 @@ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
|
|||||||
<TransactionAddress
|
<TransactionAddress
|
||||||
address={t.from}
|
address={t.from}
|
||||||
addressCtx={AddressContext.FROM}
|
addressCtx={AddressContext.FROM}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
metadata={metadatas[t.from]}
|
metadata={metadatas[t.from]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -46,7 +42,6 @@ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
|
|||||||
<TransactionAddress
|
<TransactionAddress
|
||||||
address={t.to}
|
address={t.to}
|
||||||
addressCtx={AddressContext.TO}
|
addressCtx={AddressContext.TO}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
metadata={metadatas[t.to]}
|
metadata={metadatas[t.to]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -60,11 +55,7 @@ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
|
|||||||
/>
|
/>
|
||||||
</ValueHighlighter>
|
</ValueHighlighter>
|
||||||
</span>
|
</span>
|
||||||
<TransactionAddress
|
<TransactionAddress address={t.token} metadata={metadatas[t.token]} />
|
||||||
address={t.token}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
metadata={metadatas[t.token]}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,10 +11,7 @@ import { useInternalOperations, useTxData } from "./useErigonHooks";
|
|||||||
import { useETHUSDOracle } from "./usePriceOracle";
|
import { useETHUSDOracle } from "./usePriceOracle";
|
||||||
import { useAppConfigContext } from "./useAppConfig";
|
import { useAppConfigContext } from "./useAppConfig";
|
||||||
import { useSourcify, useTransactionDescription } from "./sourcify/useSourcify";
|
import { useSourcify, useTransactionDescription } from "./sourcify/useSourcify";
|
||||||
import {
|
import { transactionDataCollector } from "./useResolvedAddresses";
|
||||||
transactionDataCollector,
|
|
||||||
useResolvedAddresses,
|
|
||||||
} from "./useResolvedAddresses";
|
|
||||||
import { SelectedTransactionContext } from "./useSelectedTransaction";
|
import { SelectedTransactionContext } from "./useSelectedTransaction";
|
||||||
|
|
||||||
const Details = React.lazy(
|
const Details = React.lazy(
|
||||||
@ -49,7 +46,6 @@ const Transaction: React.FC = () => {
|
|||||||
() => transactionDataCollector(txData),
|
() => transactionDataCollector(txData),
|
||||||
[txData]
|
[txData]
|
||||||
);
|
);
|
||||||
const resolvedAddresses = useResolvedAddresses(provider, addrCollector);
|
|
||||||
|
|
||||||
const internalOps = useInternalOperations(provider, txData);
|
const internalOps = useInternalOperations(provider, txData);
|
||||||
const sendsEthToMiner = useMemo(() => {
|
const sendsEthToMiner = useMemo(() => {
|
||||||
@ -119,29 +115,14 @@ const Transaction: React.FC = () => {
|
|||||||
internalOps={internalOps}
|
internalOps={internalOps}
|
||||||
sendsEthToMiner={sendsEthToMiner}
|
sendsEthToMiner={sendsEthToMiner}
|
||||||
ethUSDPrice={blockETHUSDPrice}
|
ethUSDPrice={blockETHUSDPrice}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="logs"
|
path="logs"
|
||||||
element={
|
element={<Logs txData={txData} metadata={metadata} />}
|
||||||
<Logs
|
|
||||||
txData={txData}
|
|
||||||
metadata={metadata}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="trace"
|
|
||||||
element={
|
|
||||||
<Trace
|
|
||||||
txData={txData}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
|
<Route path="trace" element={<Trace txData={txData} />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
</SelectionContext.Provider>
|
</SelectionContext.Provider>
|
||||||
|
@ -104,7 +104,6 @@ const AddressTransactionResults: React.FC<AddressTransactionResultsProps> = ({
|
|||||||
|
|
||||||
// Resolve all addresses that appear on this page results
|
// Resolve all addresses that appear on this page results
|
||||||
const addrCollector = useMemo(() => pageCollector(page), [page]);
|
const addrCollector = useMemo(() => pageCollector(page), [page]);
|
||||||
const resolvedAddresses = useResolvedAddresses(provider, addrCollector);
|
|
||||||
|
|
||||||
// Calculate Sourcify metadata for all addresses that appear on this page results
|
// Calculate Sourcify metadata for all addresses that appear on this page results
|
||||||
const addresses = useMemo(() => {
|
const addresses = useMemo(() => {
|
||||||
@ -152,7 +151,6 @@ const AddressTransactionResults: React.FC<AddressTransactionResultsProps> = ({
|
|||||||
<TransactionItem
|
<TransactionItem
|
||||||
key={tx.hash}
|
key={tx.hash}
|
||||||
tx={tx}
|
tx={tx}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
selectedAddress={address}
|
selectedAddress={address}
|
||||||
feeDisplay={feeDisplay}
|
feeDisplay={feeDisplay}
|
||||||
priceMap={priceMap}
|
priceMap={priceMap}
|
||||||
|
@ -8,7 +8,7 @@ import TransactionItem from "../search/TransactionItem";
|
|||||||
import { useFeeToggler } from "../search/useFeeToggler";
|
import { useFeeToggler } from "../search/useFeeToggler";
|
||||||
import { RuntimeContext } from "../useRuntime";
|
import { RuntimeContext } from "../useRuntime";
|
||||||
import { SelectionContext, useSelection } from "../useSelection";
|
import { SelectionContext, useSelection } from "../useSelection";
|
||||||
import { pageCollector, useResolvedAddresses } from "../useResolvedAddresses";
|
import { pageCollector } from "../useResolvedAddresses";
|
||||||
import { ChecksummedAddress, ProcessedTransaction } from "../types";
|
import { ChecksummedAddress, ProcessedTransaction } from "../types";
|
||||||
import { PAGE_SIZE } from "../params";
|
import { PAGE_SIZE } from "../params";
|
||||||
import { useMultipleETHUSDOracle } from "../usePriceOracle";
|
import { useMultipleETHUSDOracle } from "../usePriceOracle";
|
||||||
@ -31,7 +31,6 @@ const BlockTransactionResults: React.FC<BlockTransactionResultsProps> = ({
|
|||||||
const selectionCtx = useSelection();
|
const selectionCtx = useSelection();
|
||||||
const [feeDisplay, feeDisplayToggler] = useFeeToggler();
|
const [feeDisplay, feeDisplayToggler] = useFeeToggler();
|
||||||
const addrCollector = useMemo(() => pageCollector(page), [page]);
|
const addrCollector = useMemo(() => pageCollector(page), [page]);
|
||||||
const resolvedAddresses = useResolvedAddresses(provider, addrCollector);
|
|
||||||
const blockTags = useMemo(() => [blockTag], [blockTag]);
|
const blockTags = useMemo(() => [blockTag], [blockTag]);
|
||||||
const priceMap = useMultipleETHUSDOracle(provider, blockTags);
|
const priceMap = useMultipleETHUSDOracle(provider, blockTags);
|
||||||
|
|
||||||
@ -79,7 +78,6 @@ const BlockTransactionResults: React.FC<BlockTransactionResultsProps> = ({
|
|||||||
<TransactionItem
|
<TransactionItem
|
||||||
key={tx.hash}
|
key={tx.hash}
|
||||||
tx={tx}
|
tx={tx}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
feeDisplay={feeDisplay}
|
feeDisplay={feeDisplay}
|
||||||
priceMap={priceMap}
|
priceMap={priceMap}
|
||||||
metadatas={metadatas}
|
metadatas={metadatas}
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
import React from "react";
|
import React, { useContext } from "react";
|
||||||
import {
|
import { resolverRendererRegistry } from "../api/address-resolver";
|
||||||
ResolvedAddresses,
|
import { useResolvedAddress } from "../useResolvedAddresses";
|
||||||
resolverRendererRegistry,
|
import { RuntimeContext } from "../useRuntime";
|
||||||
} from "../api/address-resolver";
|
|
||||||
import PlainAddress from "./PlainAddress";
|
import PlainAddress from "./PlainAddress";
|
||||||
|
|
||||||
type AddressOrENSNameProps = {
|
type AddressOrENSNameProps = {
|
||||||
address: string;
|
address: string;
|
||||||
selectedAddress?: string;
|
selectedAddress?: string;
|
||||||
dontOverrideColors?: boolean;
|
dontOverrideColors?: boolean;
|
||||||
resolvedAddresses?: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const AddressOrENSName: React.FC<AddressOrENSNameProps> = ({
|
const AddressOrENSName: React.FC<AddressOrENSNameProps> = ({
|
||||||
address,
|
address,
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
dontOverrideColors,
|
dontOverrideColors,
|
||||||
resolvedAddresses,
|
|
||||||
}) => {
|
}) => {
|
||||||
const resolvedAddress = resolvedAddresses?.[address];
|
const { provider } = useContext(RuntimeContext);
|
||||||
|
const resolvedAddress = useResolvedAddress(provider, address);
|
||||||
const linkable = address !== selectedAddress;
|
const linkable = address !== selectedAddress;
|
||||||
|
|
||||||
if (!resolvedAddress) {
|
if (!resolvedAddress) {
|
||||||
|
@ -9,7 +9,6 @@ import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins";
|
|||||||
import AddressOrENSName from "./AddressOrENSName";
|
import AddressOrENSName from "./AddressOrENSName";
|
||||||
import SourcifyLogo from "../sourcify/SourcifyLogo";
|
import SourcifyLogo from "../sourcify/SourcifyLogo";
|
||||||
import { AddressContext, ZERO_ADDRESS } from "../types";
|
import { AddressContext, ZERO_ADDRESS } from "../types";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
import { Metadata } from "../sourcify/useSourcify";
|
import { Metadata } from "../sourcify/useSourcify";
|
||||||
|
|
||||||
type DecoratedAddressLinkProps = {
|
type DecoratedAddressLinkProps = {
|
||||||
@ -21,7 +20,6 @@ type DecoratedAddressLinkProps = {
|
|||||||
selfDestruct?: boolean;
|
selfDestruct?: boolean;
|
||||||
txFrom?: boolean;
|
txFrom?: boolean;
|
||||||
txTo?: boolean;
|
txTo?: boolean;
|
||||||
resolvedAddresses?: ResolvedAddresses | undefined;
|
|
||||||
metadata?: Metadata | null | undefined;
|
metadata?: Metadata | null | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -34,7 +32,6 @@ const DecoratedAddressLink: React.FC<DecoratedAddressLinkProps> = ({
|
|||||||
selfDestruct,
|
selfDestruct,
|
||||||
txFrom,
|
txFrom,
|
||||||
txTo,
|
txTo,
|
||||||
resolvedAddresses,
|
|
||||||
metadata,
|
metadata,
|
||||||
}) => {
|
}) => {
|
||||||
const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS;
|
const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS;
|
||||||
@ -87,7 +84,6 @@ const DecoratedAddressLink: React.FC<DecoratedAddressLinkProps> = ({
|
|||||||
address={address}
|
address={address}
|
||||||
selectedAddress={selectedAddress}
|
selectedAddress={selectedAddress}
|
||||||
dontOverrideColors={mint || burn}
|
dontOverrideColors={mint || burn}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -5,17 +5,12 @@ import TransactionAddress from "./TransactionAddress";
|
|||||||
import AddressHighlighter from "./AddressHighlighter";
|
import AddressHighlighter from "./AddressHighlighter";
|
||||||
import DecoratedAddressLink from "./DecoratedAddressLink";
|
import DecoratedAddressLink from "./DecoratedAddressLink";
|
||||||
import { InternalOperation } from "../types";
|
import { InternalOperation } from "../types";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
|
|
||||||
type InternalCreateProps = {
|
type InternalCreateProps = {
|
||||||
internalOp: InternalOperation;
|
internalOp: InternalOperation;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const InternalCreate: React.FC<InternalCreateProps> = ({
|
const InternalCreate: React.FC<InternalCreateProps> = ({ internalOp }) => (
|
||||||
internalOp,
|
|
||||||
resolvedAddresses,
|
|
||||||
}) => (
|
|
||||||
<div className="flex items-baseline space-x-1 whitespace-nowrap">
|
<div className="flex items-baseline space-x-1 whitespace-nowrap">
|
||||||
<span className="text-gray-500">
|
<span className="text-gray-500">
|
||||||
<FontAwesomeIcon icon={faAngleRight} size="1x" /> CREATE
|
<FontAwesomeIcon icon={faAngleRight} size="1x" /> CREATE
|
||||||
@ -23,20 +18,11 @@ const InternalCreate: React.FC<InternalCreateProps> = ({
|
|||||||
<span>Contract</span>
|
<span>Contract</span>
|
||||||
<div className="flex items-baseline">
|
<div className="flex items-baseline">
|
||||||
<AddressHighlighter address={internalOp.to}>
|
<AddressHighlighter address={internalOp.to}>
|
||||||
<DecoratedAddressLink
|
<DecoratedAddressLink address={internalOp.to} creation />
|
||||||
address={internalOp.to}
|
|
||||||
creation
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
</div>
|
</div>
|
||||||
<span className="flex items-baseline text-gray-400">
|
<span className="flex items-baseline text-gray-400">
|
||||||
(Creator:{" "}
|
(Creator: <TransactionAddress address={internalOp.from} />)
|
||||||
<TransactionAddress
|
|
||||||
address={internalOp.from}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -5,19 +5,16 @@ import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight";
|
|||||||
import AddressHighlighter from "./AddressHighlighter";
|
import AddressHighlighter from "./AddressHighlighter";
|
||||||
import DecoratedAddressLink from "./DecoratedAddressLink";
|
import DecoratedAddressLink from "./DecoratedAddressLink";
|
||||||
import { TransactionData, InternalOperation } from "../types";
|
import { TransactionData, InternalOperation } from "../types";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
import TransactionAddress from "./TransactionAddress";
|
import TransactionAddress from "./TransactionAddress";
|
||||||
|
|
||||||
type InternalSelfDestructProps = {
|
type InternalSelfDestructProps = {
|
||||||
txData: TransactionData;
|
txData: TransactionData;
|
||||||
internalOp: InternalOperation;
|
internalOp: InternalOperation;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const InternalSelfDestruct: React.FC<InternalSelfDestructProps> = ({
|
const InternalSelfDestruct: React.FC<InternalSelfDestructProps> = ({
|
||||||
txData,
|
txData,
|
||||||
internalOp,
|
internalOp,
|
||||||
resolvedAddresses,
|
|
||||||
}) => {
|
}) => {
|
||||||
const toMiner =
|
const toMiner =
|
||||||
txData.confirmedData?.miner !== undefined &&
|
txData.confirmedData?.miner !== undefined &&
|
||||||
@ -32,21 +29,12 @@ const InternalSelfDestruct: React.FC<InternalSelfDestructProps> = ({
|
|||||||
<span>Contract</span>
|
<span>Contract</span>
|
||||||
<div className="flex items-baseline">
|
<div className="flex items-baseline">
|
||||||
<AddressHighlighter address={internalOp.from}>
|
<AddressHighlighter address={internalOp.from}>
|
||||||
<DecoratedAddressLink
|
<DecoratedAddressLink address={internalOp.from} selfDestruct />
|
||||||
address={internalOp.from}
|
|
||||||
selfDestruct
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
</div>
|
</div>
|
||||||
{internalOp.value.isZero() && (
|
{internalOp.value.isZero() && (
|
||||||
<div className="flex items-baseline text-gray-400">
|
<div className="flex items-baseline text-gray-400">
|
||||||
(To:{" "}
|
(To: <TransactionAddress address={internalOp.to} />)
|
||||||
<TransactionAddress
|
|
||||||
address={internalOp.to}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@ -64,11 +52,7 @@ const InternalSelfDestruct: React.FC<InternalSelfDestructProps> = ({
|
|||||||
toMiner ? "rounded px-2 py-1 bg-yellow-100" : ""
|
toMiner ? "rounded px-2 py-1 bg-yellow-100" : ""
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<DecoratedAddressLink
|
<DecoratedAddressLink address={internalOp.to} miner={toMiner} />
|
||||||
address={internalOp.to}
|
|
||||||
miner={toMiner}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,37 +3,24 @@ import InternalTransfer from "./InternalTransfer";
|
|||||||
import InternalSelfDestruct from "./InternalSelfDestruct";
|
import InternalSelfDestruct from "./InternalSelfDestruct";
|
||||||
import InternalCreate from "./InternalCreate";
|
import InternalCreate from "./InternalCreate";
|
||||||
import { TransactionData, InternalOperation, OperationType } from "../types";
|
import { TransactionData, InternalOperation, OperationType } from "../types";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
|
|
||||||
type InternalTransactionOperationProps = {
|
type InternalTransactionOperationProps = {
|
||||||
txData: TransactionData;
|
txData: TransactionData;
|
||||||
internalOp: InternalOperation;
|
internalOp: InternalOperation;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const InternalTransactionOperation: React.FC<InternalTransactionOperationProps> =
|
const InternalTransactionOperation: React.FC<InternalTransactionOperationProps> =
|
||||||
({ txData, internalOp, resolvedAddresses }) => (
|
({ txData, internalOp }) => (
|
||||||
<>
|
<>
|
||||||
{internalOp.type === OperationType.TRANSFER && (
|
{internalOp.type === OperationType.TRANSFER && (
|
||||||
<InternalTransfer
|
<InternalTransfer txData={txData} internalOp={internalOp} />
|
||||||
txData={txData}
|
|
||||||
internalOp={internalOp}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
{internalOp.type === OperationType.SELF_DESTRUCT && (
|
{internalOp.type === OperationType.SELF_DESTRUCT && (
|
||||||
<InternalSelfDestruct
|
<InternalSelfDestruct txData={txData} internalOp={internalOp} />
|
||||||
txData={txData}
|
|
||||||
internalOp={internalOp}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
{(internalOp.type === OperationType.CREATE ||
|
{(internalOp.type === OperationType.CREATE ||
|
||||||
internalOp.type === OperationType.CREATE2) && (
|
internalOp.type === OperationType.CREATE2) && (
|
||||||
<InternalCreate
|
<InternalCreate internalOp={internalOp} />
|
||||||
internalOp={internalOp}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -5,18 +5,15 @@ import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight";
|
|||||||
import AddressHighlighter from "./AddressHighlighter";
|
import AddressHighlighter from "./AddressHighlighter";
|
||||||
import DecoratedAddressLink from "./DecoratedAddressLink";
|
import DecoratedAddressLink from "./DecoratedAddressLink";
|
||||||
import { TransactionData, InternalOperation } from "../types";
|
import { TransactionData, InternalOperation } from "../types";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
|
|
||||||
type InternalTransferProps = {
|
type InternalTransferProps = {
|
||||||
txData: TransactionData;
|
txData: TransactionData;
|
||||||
internalOp: InternalOperation;
|
internalOp: InternalOperation;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const InternalTransfer: React.FC<InternalTransferProps> = ({
|
const InternalTransfer: React.FC<InternalTransferProps> = ({
|
||||||
txData,
|
txData,
|
||||||
internalOp,
|
internalOp,
|
||||||
resolvedAddresses,
|
|
||||||
}) => {
|
}) => {
|
||||||
const fromMiner =
|
const fromMiner =
|
||||||
txData.confirmedData?.miner !== undefined &&
|
txData.confirmedData?.miner !== undefined &&
|
||||||
@ -44,7 +41,6 @@ const InternalTransfer: React.FC<InternalTransferProps> = ({
|
|||||||
miner={fromMiner}
|
miner={fromMiner}
|
||||||
txFrom={internalOp.from === txData.from}
|
txFrom={internalOp.from === txData.from}
|
||||||
txTo={internalOp.from === txData.to}
|
txTo={internalOp.from === txData.to}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
@ -62,7 +58,6 @@ const InternalTransfer: React.FC<InternalTransferProps> = ({
|
|||||||
miner={toMiner}
|
miner={toMiner}
|
||||||
txFrom={internalOp.to === txData.from}
|
txFrom={internalOp.to === txData.from}
|
||||||
txTo={internalOp.to === txData.to}
|
txTo={internalOp.to === txData.to}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import AddressHighlighter from "./AddressHighlighter";
|
import AddressHighlighter from "./AddressHighlighter";
|
||||||
import DecoratedAddressLink from "./DecoratedAddressLink";
|
import DecoratedAddressLink from "./DecoratedAddressLink";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
import { useSelectedTransaction } from "../useSelectedTransaction";
|
import { useSelectedTransaction } from "../useSelectedTransaction";
|
||||||
import { AddressContext } from "../types";
|
import { AddressContext } from "../types";
|
||||||
import { Metadata } from "../sourcify/useSourcify";
|
import { Metadata } from "../sourcify/useSourcify";
|
||||||
@ -9,14 +8,12 @@ import { Metadata } from "../sourcify/useSourcify";
|
|||||||
type TransactionAddressProps = {
|
type TransactionAddressProps = {
|
||||||
address: string;
|
address: string;
|
||||||
addressCtx?: AddressContext | undefined;
|
addressCtx?: AddressContext | undefined;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
metadata?: Metadata | null | undefined;
|
metadata?: Metadata | null | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TransactionAddress: React.FC<TransactionAddressProps> = ({
|
const TransactionAddress: React.FC<TransactionAddressProps> = ({
|
||||||
address,
|
address,
|
||||||
addressCtx,
|
addressCtx,
|
||||||
resolvedAddresses,
|
|
||||||
metadata,
|
metadata,
|
||||||
}) => {
|
}) => {
|
||||||
const txData = useSelectedTransaction();
|
const txData = useSelectedTransaction();
|
||||||
@ -32,7 +29,6 @@ const TransactionAddress: React.FC<TransactionAddressProps> = ({
|
|||||||
txFrom={address === txData?.from}
|
txFrom={address === txData?.from}
|
||||||
txTo={address === txData?.to || creation}
|
txTo={address === txData?.to || creation}
|
||||||
creation={creation}
|
creation={creation}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
metadata={metadata}
|
metadata={metadata}
|
||||||
/>
|
/>
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
|
@ -18,12 +18,10 @@ import { ChecksummedAddress, ProcessedTransaction } from "../types";
|
|||||||
import { FeeDisplay } from "./useFeeToggler";
|
import { FeeDisplay } from "./useFeeToggler";
|
||||||
import { formatValue } from "../components/formatter";
|
import { formatValue } from "../components/formatter";
|
||||||
import ETH2USDValue from "../components/ETH2USDValue";
|
import ETH2USDValue from "../components/ETH2USDValue";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
import { Metadata } from "../sourcify/useSourcify";
|
import { Metadata } from "../sourcify/useSourcify";
|
||||||
|
|
||||||
type TransactionItemProps = {
|
type TransactionItemProps = {
|
||||||
tx: ProcessedTransaction;
|
tx: ProcessedTransaction;
|
||||||
resolvedAddresses?: ResolvedAddresses;
|
|
||||||
selectedAddress?: string;
|
selectedAddress?: string;
|
||||||
feeDisplay: FeeDisplay;
|
feeDisplay: FeeDisplay;
|
||||||
priceMap: Record<BlockTag, BigNumber>;
|
priceMap: Record<BlockTag, BigNumber>;
|
||||||
@ -32,7 +30,6 @@ type TransactionItemProps = {
|
|||||||
|
|
||||||
const TransactionItem: React.FC<TransactionItemProps> = ({
|
const TransactionItem: React.FC<TransactionItemProps> = ({
|
||||||
tx,
|
tx,
|
||||||
resolvedAddresses,
|
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
feeDisplay,
|
feeDisplay,
|
||||||
priceMap,
|
priceMap,
|
||||||
@ -87,7 +84,6 @@ const TransactionItem: React.FC<TransactionItemProps> = ({
|
|||||||
address={tx.from}
|
address={tx.from}
|
||||||
selectedAddress={selectedAddress}
|
selectedAddress={selectedAddress}
|
||||||
miner={tx.miner === tx.from}
|
miner={tx.miner === tx.from}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
)}
|
)}
|
||||||
@ -110,7 +106,6 @@ const TransactionItem: React.FC<TransactionItemProps> = ({
|
|||||||
address={tx.to}
|
address={tx.to}
|
||||||
selectedAddress={selectedAddress}
|
selectedAddress={selectedAddress}
|
||||||
miner={tx.miner === tx.to}
|
miner={tx.miner === tx.to}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
metadata={metadatas[tx.to]}
|
metadata={metadatas[tx.to]}
|
||||||
/>
|
/>
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
@ -120,7 +115,6 @@ const TransactionItem: React.FC<TransactionItemProps> = ({
|
|||||||
address={tx.createdContractAddress!}
|
address={tx.createdContractAddress!}
|
||||||
selectedAddress={selectedAddress}
|
selectedAddress={selectedAddress}
|
||||||
creation
|
creation
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
metadata={metadatas[tx.createdContractAddress!]}
|
metadata={metadatas[tx.createdContractAddress!]}
|
||||||
/>
|
/>
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
|
@ -42,7 +42,6 @@ import {
|
|||||||
useTransactionDescription,
|
useTransactionDescription,
|
||||||
} from "../use4Bytes";
|
} from "../use4Bytes";
|
||||||
import { DevDoc, Metadata, useError, UserDoc } from "../sourcify/useSourcify";
|
import { DevDoc, Metadata, useError, UserDoc } from "../sourcify/useSourcify";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
import { RuntimeContext } from "../useRuntime";
|
import { RuntimeContext } from "../useRuntime";
|
||||||
import { useContractsMetadata } from "../hooks";
|
import { useContractsMetadata } from "../hooks";
|
||||||
import { useTransactionError } from "../useErigonHooks";
|
import { useTransactionError } from "../useErigonHooks";
|
||||||
@ -56,7 +55,6 @@ type DetailsProps = {
|
|||||||
internalOps?: InternalOperation[];
|
internalOps?: InternalOperation[];
|
||||||
sendsEthToMiner: boolean;
|
sendsEthToMiner: boolean;
|
||||||
ethUSDPrice: BigNumber | undefined;
|
ethUSDPrice: BigNumber | undefined;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const Details: React.FC<DetailsProps> = ({
|
const Details: React.FC<DetailsProps> = ({
|
||||||
@ -68,7 +66,6 @@ const Details: React.FC<DetailsProps> = ({
|
|||||||
internalOps,
|
internalOps,
|
||||||
sendsEthToMiner,
|
sendsEthToMiner,
|
||||||
ethUSDPrice,
|
ethUSDPrice,
|
||||||
resolvedAddresses,
|
|
||||||
}) => {
|
}) => {
|
||||||
const hasEIP1559 =
|
const hasEIP1559 =
|
||||||
txData.confirmedData?.blockBaseFeePerGas !== undefined &&
|
txData.confirmedData?.blockBaseFeePerGas !== undefined &&
|
||||||
@ -200,7 +197,6 @@ const Details: React.FC<DetailsProps> = ({
|
|||||||
hasParamNames
|
hasParamNames
|
||||||
userMethod={userError}
|
userMethod={userError}
|
||||||
devMethod={devError}
|
devMethod={devError}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Tab.Panel>
|
</Tab.Panel>
|
||||||
@ -252,10 +248,7 @@ const Details: React.FC<DetailsProps> = ({
|
|||||||
<InfoRow title="From / Nonce">
|
<InfoRow title="From / Nonce">
|
||||||
<div className="flex divide-x-2 divide-dotted divide-gray-300">
|
<div className="flex divide-x-2 divide-dotted divide-gray-300">
|
||||||
<div className="flex items-baseline space-x-2 -ml-1 mr-3">
|
<div className="flex items-baseline space-x-2 -ml-1 mr-3">
|
||||||
<TransactionAddress
|
<TransactionAddress address={txData.from} />
|
||||||
address={txData.from}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
<Copy value={txData.from} />
|
<Copy value={txData.from} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-baseline pl-3">
|
<div className="flex items-baseline pl-3">
|
||||||
@ -268,7 +261,6 @@ const Details: React.FC<DetailsProps> = ({
|
|||||||
<div className="flex items-baseline space-x-2 -ml-1">
|
<div className="flex items-baseline space-x-2 -ml-1">
|
||||||
<TransactionAddress
|
<TransactionAddress
|
||||||
address={txData.to}
|
address={txData.to}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
metadata={metadatas?.[txData.to]}
|
metadata={metadatas?.[txData.to]}
|
||||||
/>
|
/>
|
||||||
<Copy value={txData.to} />
|
<Copy value={txData.to} />
|
||||||
@ -281,7 +273,6 @@ const Details: React.FC<DetailsProps> = ({
|
|||||||
<div className="flex items-baseline space-x-2 -ml-1">
|
<div className="flex items-baseline space-x-2 -ml-1">
|
||||||
<TransactionAddress
|
<TransactionAddress
|
||||||
address={txData.confirmedData?.createdContractAddress!}
|
address={txData.confirmedData?.createdContractAddress!}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
metadata={
|
metadata={
|
||||||
metadatas?.[txData.confirmedData?.createdContractAddress!]
|
metadatas?.[txData.confirmedData?.createdContractAddress!]
|
||||||
}
|
}
|
||||||
@ -296,7 +287,6 @@ const Details: React.FC<DetailsProps> = ({
|
|||||||
key={i}
|
key={i}
|
||||||
txData={txData}
|
txData={txData}
|
||||||
internalOp={op}
|
internalOp={op}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@ -314,7 +304,6 @@ const Details: React.FC<DetailsProps> = ({
|
|||||||
key={i}
|
key={i}
|
||||||
t={t}
|
t={t}
|
||||||
tokenMeta={txData.tokenMetas[t.token]}
|
tokenMeta={txData.tokenMetas[t.token]}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
metadatas={metadatas}
|
metadatas={metadatas}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@ -438,7 +427,6 @@ const Details: React.FC<DetailsProps> = ({
|
|||||||
data={txData.data}
|
data={txData.data}
|
||||||
userMethod={userMethod}
|
userMethod={userMethod}
|
||||||
devMethod={devMethod}
|
devMethod={devMethod}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
</ContentFrame>
|
</ContentFrame>
|
||||||
|
@ -8,23 +8,16 @@ import ModeTab from "../components/ModeTab";
|
|||||||
import DecodedParamsTable from "./decoder/DecodedParamsTable";
|
import DecodedParamsTable from "./decoder/DecodedParamsTable";
|
||||||
import DecodedLogSignature from "./decoder/DecodedLogSignature";
|
import DecodedLogSignature from "./decoder/DecodedLogSignature";
|
||||||
import { useTopic0 } from "../useTopic0";
|
import { useTopic0 } from "../useTopic0";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
import { ChecksummedAddress } from "../types";
|
import { ChecksummedAddress } from "../types";
|
||||||
import { Metadata } from "../sourcify/useSourcify";
|
import { Metadata } from "../sourcify/useSourcify";
|
||||||
|
|
||||||
type LogEntryProps = {
|
type LogEntryProps = {
|
||||||
log: Log;
|
log: Log;
|
||||||
logDesc: LogDescription | null | undefined;
|
logDesc: LogDescription | null | undefined;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
metadatas: Record<ChecksummedAddress, Metadata | null | undefined>;
|
metadatas: Record<ChecksummedAddress, Metadata | null | undefined>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const LogEntry: React.FC<LogEntryProps> = ({
|
const LogEntry: React.FC<LogEntryProps> = ({ log, logDesc, metadatas }) => {
|
||||||
log,
|
|
||||||
logDesc,
|
|
||||||
resolvedAddresses,
|
|
||||||
metadatas,
|
|
||||||
}) => {
|
|
||||||
const rawTopic0 = log.topics[0];
|
const rawTopic0 = log.topics[0];
|
||||||
const topic0 = useTopic0(rawTopic0);
|
const topic0 = useTopic0(rawTopic0);
|
||||||
|
|
||||||
@ -65,7 +58,6 @@ const LogEntry: React.FC<LogEntryProps> = ({
|
|||||||
<div className="flex items-baseline space-x-2 -ml-1 mr-3">
|
<div className="flex items-baseline space-x-2 -ml-1 mr-3">
|
||||||
<TransactionAddress
|
<TransactionAddress
|
||||||
address={log.address}
|
address={log.address}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
metadata={metadatas[log.address]}
|
metadata={metadatas[log.address]}
|
||||||
/>
|
/>
|
||||||
<Copy value={log.address} />
|
<Copy value={log.address} />
|
||||||
@ -109,7 +101,6 @@ const LogEntry: React.FC<LogEntryProps> = ({
|
|||||||
args={resolvedLogDesc.args}
|
args={resolvedLogDesc.args}
|
||||||
paramTypes={resolvedLogDesc.eventFragment.inputs}
|
paramTypes={resolvedLogDesc.eventFragment.inputs}
|
||||||
hasParamNames={resolvedLogDesc === logDesc}
|
hasParamNames={resolvedLogDesc === logDesc}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,17 +4,15 @@ import ContentFrame from "../ContentFrame";
|
|||||||
import LogEntry from "./LogEntry";
|
import LogEntry from "./LogEntry";
|
||||||
import { TransactionData } from "../types";
|
import { TransactionData } from "../types";
|
||||||
import { Metadata } from "../sourcify/useSourcify";
|
import { Metadata } from "../sourcify/useSourcify";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
import { RuntimeContext } from "../useRuntime";
|
import { RuntimeContext } from "../useRuntime";
|
||||||
import { useContractsMetadata } from "../hooks";
|
import { useContractsMetadata } from "../hooks";
|
||||||
|
|
||||||
type LogsProps = {
|
type LogsProps = {
|
||||||
txData: TransactionData;
|
txData: TransactionData;
|
||||||
metadata: Metadata | null | undefined;
|
metadata: Metadata | null | undefined;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const Logs: React.FC<LogsProps> = ({ txData, metadata, resolvedAddresses }) => {
|
const Logs: React.FC<LogsProps> = ({ txData, metadata }) => {
|
||||||
const baseMetadatas = useMemo((): Record<string, Metadata | null> => {
|
const baseMetadatas = useMemo((): Record<string, Metadata | null> => {
|
||||||
if (!txData.to || metadata === undefined) {
|
if (!txData.to || metadata === undefined) {
|
||||||
return {};
|
return {};
|
||||||
@ -68,7 +66,6 @@ const Logs: React.FC<LogsProps> = ({ txData, metadata, resolvedAddresses }) => {
|
|||||||
key={i}
|
key={i}
|
||||||
log={l}
|
log={l}
|
||||||
logDesc={logDescs?.[i]}
|
logDesc={logDescs?.[i]}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
metadatas={metadatas}
|
metadatas={metadatas}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
@ -6,32 +6,19 @@ import { TransactionData } from "../types";
|
|||||||
import { useBatch4Bytes } from "../use4Bytes";
|
import { useBatch4Bytes } from "../use4Bytes";
|
||||||
import { useTraceTransaction, useUniqueSignatures } from "../useErigonHooks";
|
import { useTraceTransaction, useUniqueSignatures } from "../useErigonHooks";
|
||||||
import { RuntimeContext } from "../useRuntime";
|
import { RuntimeContext } from "../useRuntime";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
import { tracesCollector } from "../useResolvedAddresses";
|
||||||
import { tracesCollector, useResolvedAddresses } from "../useResolvedAddresses";
|
|
||||||
|
|
||||||
type TraceProps = {
|
type TraceProps = {
|
||||||
txData: TransactionData;
|
txData: TransactionData;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const Trace: React.FC<TraceProps> = ({ txData, resolvedAddresses }) => {
|
const Trace: React.FC<TraceProps> = ({ txData }) => {
|
||||||
const { provider } = useContext(RuntimeContext);
|
const { provider } = useContext(RuntimeContext);
|
||||||
const traces = useTraceTransaction(provider, txData.transactionHash);
|
const traces = useTraceTransaction(provider, txData.transactionHash);
|
||||||
const uniqueSignatures = useUniqueSignatures(traces);
|
const uniqueSignatures = useUniqueSignatures(traces);
|
||||||
const sigMap = useBatch4Bytes(uniqueSignatures);
|
const sigMap = useBatch4Bytes(uniqueSignatures);
|
||||||
|
|
||||||
const addrCollector = useMemo(() => tracesCollector(traces), [traces]);
|
const addrCollector = useMemo(() => tracesCollector(traces), [traces]);
|
||||||
const traceResolvedAddresses = useResolvedAddresses(provider, addrCollector);
|
|
||||||
const mergedResolvedAddresses = useMemo(() => {
|
|
||||||
const merge = {};
|
|
||||||
if (resolvedAddresses) {
|
|
||||||
Object.assign(merge, resolvedAddresses);
|
|
||||||
}
|
|
||||||
if (traceResolvedAddresses) {
|
|
||||||
Object.assign(merge, traceResolvedAddresses);
|
|
||||||
}
|
|
||||||
return merge;
|
|
||||||
}, [resolvedAddresses, traceResolvedAddresses]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContentFrame tabs>
|
<ContentFrame tabs>
|
||||||
@ -39,10 +26,7 @@ const Trace: React.FC<TraceProps> = ({ txData, resolvedAddresses }) => {
|
|||||||
{traces ? (
|
{traces ? (
|
||||||
<>
|
<>
|
||||||
<div className="border hover:border-gray-500 rounded px-1 py-0.5">
|
<div className="border hover:border-gray-500 rounded px-1 py-0.5">
|
||||||
<TransactionAddress
|
<TransactionAddress address={txData.from} />
|
||||||
address={txData.from}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="ml-5 space-y-3 self-stretch">
|
<div className="ml-5 space-y-3 self-stretch">
|
||||||
{traces.map((t, i, a) => (
|
{traces.map((t, i, a) => (
|
||||||
@ -51,7 +35,6 @@ const Trace: React.FC<TraceProps> = ({ txData, resolvedAddresses }) => {
|
|||||||
t={t}
|
t={t}
|
||||||
last={i === a.length - 1}
|
last={i === a.length - 1}
|
||||||
fourBytesMap={sigMap}
|
fourBytesMap={sigMap}
|
||||||
resolvedAddresses={mergedResolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
@ -7,7 +7,6 @@ import FunctionSignature from "./FunctionSignature";
|
|||||||
import InputDecoder from "./decoder/InputDecoder";
|
import InputDecoder from "./decoder/InputDecoder";
|
||||||
import ExpanderSwitch from "../components/ExpanderSwitch";
|
import ExpanderSwitch from "../components/ExpanderSwitch";
|
||||||
import { TraceEntry } from "../useErigonHooks";
|
import { TraceEntry } from "../useErigonHooks";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
import {
|
import {
|
||||||
extract4Bytes,
|
extract4Bytes,
|
||||||
FourBytesEntry,
|
FourBytesEntry,
|
||||||
@ -17,14 +16,9 @@ import {
|
|||||||
type TraceInputProps = {
|
type TraceInputProps = {
|
||||||
t: TraceEntry;
|
t: TraceEntry;
|
||||||
fourBytesMap: Record<string, FourBytesEntry | null | undefined>;
|
fourBytesMap: Record<string, FourBytesEntry | null | undefined>;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const TraceInput: React.FC<TraceInputProps> = ({
|
const TraceInput: React.FC<TraceInputProps> = ({ t, fourBytesMap }) => {
|
||||||
t,
|
|
||||||
fourBytesMap,
|
|
||||||
resolvedAddresses,
|
|
||||||
}) => {
|
|
||||||
const raw4Bytes = extract4Bytes(t.input);
|
const raw4Bytes = extract4Bytes(t.input);
|
||||||
const fourBytes = raw4Bytes !== null ? fourBytesMap[raw4Bytes] : null;
|
const fourBytes = raw4Bytes !== null ? fourBytesMap[raw4Bytes] : null;
|
||||||
const sigText =
|
const sigText =
|
||||||
@ -54,10 +48,7 @@ const TraceInput: React.FC<TraceInputProps> = ({
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<span>
|
<span>
|
||||||
<TransactionAddress
|
<TransactionAddress address={t.to} />
|
||||||
address={t.to}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
</span>
|
</span>
|
||||||
{t.type !== "CREATE" && t.type !== "CREATE2" && (
|
{t.type !== "CREATE" && t.type !== "CREATE2" && (
|
||||||
<>
|
<>
|
||||||
@ -93,7 +84,6 @@ const TraceInput: React.FC<TraceInputProps> = ({
|
|||||||
data={t.input}
|
data={t.input}
|
||||||
userMethod={undefined}
|
userMethod={undefined}
|
||||||
devMethod={undefined}
|
devMethod={undefined}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>)</div>
|
<div>)</div>
|
||||||
|
@ -5,22 +5,15 @@ import { faMinusSquare } from "@fortawesome/free-regular-svg-icons/faMinusSquare
|
|||||||
import { Switch } from "@headlessui/react";
|
import { Switch } from "@headlessui/react";
|
||||||
import { FourBytesEntry } from "../use4Bytes";
|
import { FourBytesEntry } from "../use4Bytes";
|
||||||
import { TraceGroup } from "../useErigonHooks";
|
import { TraceGroup } from "../useErigonHooks";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
|
||||||
import TraceInput from "./TraceInput";
|
import TraceInput from "./TraceInput";
|
||||||
|
|
||||||
type TraceItemProps = {
|
type TraceItemProps = {
|
||||||
t: TraceGroup;
|
t: TraceGroup;
|
||||||
last: boolean;
|
last: boolean;
|
||||||
fourBytesMap: Record<string, FourBytesEntry | null | undefined>;
|
fourBytesMap: Record<string, FourBytesEntry | null | undefined>;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const TraceItem: React.FC<TraceItemProps> = ({
|
const TraceItem: React.FC<TraceItemProps> = ({ t, last, fourBytesMap }) => {
|
||||||
t,
|
|
||||||
last,
|
|
||||||
fourBytesMap,
|
|
||||||
resolvedAddresses,
|
|
||||||
}) => {
|
|
||||||
const [expanded, setExpanded] = useState<boolean>(true);
|
const [expanded, setExpanded] = useState<boolean>(true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -42,11 +35,7 @@ const TraceItem: React.FC<TraceItemProps> = ({
|
|||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
)}
|
)}
|
||||||
<TraceInput
|
<TraceInput t={t} fourBytesMap={fourBytesMap} />
|
||||||
t={t}
|
|
||||||
fourBytesMap={fourBytesMap}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
{t.children && (
|
{t.children && (
|
||||||
<div
|
<div
|
||||||
@ -54,11 +43,7 @@ const TraceItem: React.FC<TraceItemProps> = ({
|
|||||||
expanded ? "" : "hidden"
|
expanded ? "" : "hidden"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<TraceChildren
|
<TraceChildren c={t.children} fourBytesMap={fourBytesMap} />
|
||||||
c={t.children}
|
|
||||||
fourBytesMap={fourBytesMap}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
@ -68,11 +53,10 @@ const TraceItem: React.FC<TraceItemProps> = ({
|
|||||||
type TraceChildrenProps = {
|
type TraceChildrenProps = {
|
||||||
c: TraceGroup[];
|
c: TraceGroup[];
|
||||||
fourBytesMap: Record<string, FourBytesEntry | null | undefined>;
|
fourBytesMap: Record<string, FourBytesEntry | null | undefined>;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const TraceChildren: React.FC<TraceChildrenProps> = React.memo(
|
const TraceChildren: React.FC<TraceChildrenProps> = React.memo(
|
||||||
({ c, fourBytesMap, resolvedAddresses }) => {
|
({ c, fourBytesMap }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{c.map((tc, i, a) => (
|
{c.map((tc, i, a) => (
|
||||||
@ -81,7 +65,6 @@ const TraceChildren: React.FC<TraceChildrenProps> = React.memo(
|
|||||||
t={tc}
|
t={tc}
|
||||||
last={i === a.length - 1}
|
last={i === a.length - 1}
|
||||||
fourBytesMap={fourBytesMap}
|
fourBytesMap={fourBytesMap}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import TransactionAddress from "../../components/TransactionAddress";
|
import TransactionAddress from "../../components/TransactionAddress";
|
||||||
import Copy from "../../components/Copy";
|
import Copy from "../../components/Copy";
|
||||||
import { ResolvedAddresses } from "../../api/address-resolver";
|
|
||||||
|
|
||||||
type AddressDecoderProps = {
|
type AddressDecoderProps = {
|
||||||
r: string;
|
r: string;
|
||||||
resolvedAddresses?: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const AddressDecoder: React.FC<AddressDecoderProps> = ({
|
const AddressDecoder: React.FC<AddressDecoderProps> = ({ r }) => (
|
||||||
r,
|
|
||||||
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">
|
||||||
<TransactionAddress address={r} resolvedAddresses={resolvedAddresses} />
|
<TransactionAddress address={r} />
|
||||||
<Copy value={r} />
|
<Copy value={r} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -8,7 +8,6 @@ import Uint256Decoder from "./Uint256Decoder";
|
|||||||
import AddressDecoder from "./AddressDecoder";
|
import AddressDecoder from "./AddressDecoder";
|
||||||
import BooleanDecoder from "./BooleanDecoder";
|
import BooleanDecoder from "./BooleanDecoder";
|
||||||
import BytesDecoder from "./BytesDecoder";
|
import BytesDecoder from "./BytesDecoder";
|
||||||
import { ResolvedAddresses } from "../../api/address-resolver";
|
|
||||||
import SelectionHighlighter, {
|
import SelectionHighlighter, {
|
||||||
valueSelector,
|
valueSelector,
|
||||||
} from "../../components/SelectionHighlighter";
|
} from "../../components/SelectionHighlighter";
|
||||||
@ -20,7 +19,6 @@ type DecodedParamRowProps = {
|
|||||||
paramType: ParamType;
|
paramType: ParamType;
|
||||||
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> = ({
|
||||||
@ -30,7 +28,6 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
|||||||
paramType,
|
paramType,
|
||||||
arrayElem,
|
arrayElem,
|
||||||
help,
|
help,
|
||||||
resolvedAddresses,
|
|
||||||
}) => {
|
}) => {
|
||||||
const [showHelp, setShowHelp] = useState<boolean>(false);
|
const [showHelp, setShowHelp] = useState<boolean>(false);
|
||||||
|
|
||||||
@ -80,10 +77,7 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
|||||||
{paramType.baseType === "uint256" ? (
|
{paramType.baseType === "uint256" ? (
|
||||||
<Uint256Decoder r={r} />
|
<Uint256Decoder r={r} />
|
||||||
) : paramType.baseType === "address" ? (
|
) : paramType.baseType === "address" ? (
|
||||||
<AddressDecoder
|
<AddressDecoder r={r.toString()} />
|
||||||
r={r.toString()}
|
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
|
||||||
) : paramType.baseType === "bool" ? (
|
) : paramType.baseType === "bool" ? (
|
||||||
<BooleanDecoder r={r} />
|
<BooleanDecoder r={r} />
|
||||||
) : paramType.baseType === "bytes" ? (
|
) : paramType.baseType === "bytes" ? (
|
||||||
@ -111,7 +105,6 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
|||||||
i={idx}
|
i={idx}
|
||||||
r={e}
|
r={e}
|
||||||
paramType={paramType.components[idx]}
|
paramType={paramType.components[idx]}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{paramType.baseType === "array" &&
|
{paramType.baseType === "array" &&
|
||||||
@ -122,7 +115,6 @@ const DecodedParamRow: React.FC<DecodedParamRowProps> = ({
|
|||||||
r={e}
|
r={e}
|
||||||
paramType={paramType.arrayChildren}
|
paramType={paramType.arrayChildren}
|
||||||
arrayElem={idx}
|
arrayElem={idx}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
@ -2,7 +2,6 @@ import React from "react";
|
|||||||
import { ParamType, Result } from "@ethersproject/abi";
|
import { ParamType, Result } from "@ethersproject/abi";
|
||||||
import DecodedParamRow from "./DecodedParamRow";
|
import DecodedParamRow from "./DecodedParamRow";
|
||||||
import { DevMethod, UserMethod } from "../../sourcify/useSourcify";
|
import { DevMethod, UserMethod } from "../../sourcify/useSourcify";
|
||||||
import { ResolvedAddresses } from "../../api/address-resolver";
|
|
||||||
|
|
||||||
type DecodedParamsTableProps = {
|
type DecodedParamsTableProps = {
|
||||||
args: Result;
|
args: Result;
|
||||||
@ -10,7 +9,6 @@ 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> = ({
|
||||||
@ -18,7 +16,6 @@ const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
|
|||||||
paramTypes,
|
paramTypes,
|
||||||
hasParamNames = true,
|
hasParamNames = true,
|
||||||
devMethod,
|
devMethod,
|
||||||
resolvedAddresses,
|
|
||||||
}) => (
|
}) => (
|
||||||
<table className="border w-full">
|
<table className="border w-full">
|
||||||
<thead>
|
<thead>
|
||||||
@ -47,7 +44,6 @@ const DecodedParamsTable: React.FC<DecodedParamsTableProps> = ({
|
|||||||
r={r}
|
r={r}
|
||||||
paramType={paramTypes[i]}
|
paramType={paramTypes[i]}
|
||||||
help={devMethod?.params?.[paramTypes[i].name]}
|
help={devMethod?.params?.[paramTypes[i].name]}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -5,7 +5,6 @@ import { Tab } from "@headlessui/react";
|
|||||||
import ModeTab from "../../components/ModeTab";
|
import ModeTab from "../../components/ModeTab";
|
||||||
import DecodedParamsTable from "./DecodedParamsTable";
|
import DecodedParamsTable from "./DecodedParamsTable";
|
||||||
import { DevMethod, UserMethod } from "../../sourcify/useSourcify";
|
import { DevMethod, UserMethod } from "../../sourcify/useSourcify";
|
||||||
import { ResolvedAddresses } from "../../api/address-resolver";
|
|
||||||
|
|
||||||
type InputDecoderProps = {
|
type InputDecoderProps = {
|
||||||
fourBytes: string;
|
fourBytes: string;
|
||||||
@ -14,7 +13,6 @@ type InputDecoderProps = {
|
|||||||
data: string;
|
data: string;
|
||||||
userMethod: UserMethod | undefined;
|
userMethod: UserMethod | undefined;
|
||||||
devMethod: DevMethod | undefined;
|
devMethod: DevMethod | undefined;
|
||||||
resolvedAddresses: ResolvedAddresses | undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const InputDecoder: React.FC<InputDecoderProps> = ({
|
const InputDecoder: React.FC<InputDecoderProps> = ({
|
||||||
@ -24,7 +22,6 @@ const InputDecoder: React.FC<InputDecoderProps> = ({
|
|||||||
data,
|
data,
|
||||||
userMethod,
|
userMethod,
|
||||||
devMethod,
|
devMethod,
|
||||||
resolvedAddresses,
|
|
||||||
}) => {
|
}) => {
|
||||||
const utfInput = useMemo(() => {
|
const utfInput = useMemo(() => {
|
||||||
try {
|
try {
|
||||||
@ -57,7 +54,6 @@ const InputDecoder: React.FC<InputDecoderProps> = ({
|
|||||||
hasParamNames={hasParamNames}
|
hasParamNames={hasParamNames}
|
||||||
userMethod={userMethod}
|
userMethod={userMethod}
|
||||||
devMethod={devMethod}
|
devMethod={devMethod}
|
||||||
resolvedAddresses={resolvedAddresses}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Tab.Panel>
|
</Tab.Panel>
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
import { useState, useEffect, useRef, useContext } from "react";
|
import { useState, useEffect, useRef, useContext } from "react";
|
||||||
import { JsonRpcProvider } from "@ethersproject/providers";
|
import { BaseProvider, JsonRpcProvider } from "@ethersproject/providers";
|
||||||
import { getAddress, isAddress } from "@ethersproject/address";
|
import { getAddress, isAddress } from "@ethersproject/address";
|
||||||
import { batchPopulate, ResolvedAddresses } from "./api/address-resolver";
|
import useSWR from "swr";
|
||||||
|
import {
|
||||||
|
batchPopulate,
|
||||||
|
mainResolver,
|
||||||
|
ResolvedAddresses,
|
||||||
|
} from "./api/address-resolver";
|
||||||
|
import { SelectedResolvedName } from "./api/address-resolver/CompositeAddressResolver";
|
||||||
import { TraceGroup } from "./useErigonHooks";
|
import { TraceGroup } from "./useErigonHooks";
|
||||||
import { RuntimeContext } from "./useRuntime";
|
import { RuntimeContext } from "./useRuntime";
|
||||||
import {
|
import {
|
||||||
@ -184,3 +190,23 @@ export const useResolvedAddresses = (
|
|||||||
|
|
||||||
return names;
|
return names;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useResolvedAddress = (
|
||||||
|
provider: BaseProvider | undefined,
|
||||||
|
address: ChecksummedAddress
|
||||||
|
): SelectedResolvedName<any> | undefined => {
|
||||||
|
const fetcher = async (
|
||||||
|
key: string
|
||||||
|
): Promise<SelectedResolvedName<any> | undefined> => {
|
||||||
|
if (!provider) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return mainResolver.resolveAddress(provider, address);
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data, error } = useSWR(address, fetcher);
|
||||||
|
if (error) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user