Push down Sourcify metadata reading
This commit is contained in:
parent
e86133d6d7
commit
d5ba6ac781
@ -10,11 +10,6 @@ import { useInternalOperations, useTxData } from "./useErigonHooks";
|
|||||||
import { SelectionContext, useSelection } from "./useSelection";
|
import { SelectionContext, useSelection } from "./useSelection";
|
||||||
import { SelectedTransactionContext } from "./useSelectedTransaction";
|
import { SelectedTransactionContext } from "./useSelectedTransaction";
|
||||||
import { BlockNumberContext } from "./useBlockTagContext";
|
import { BlockNumberContext } from "./useBlockTagContext";
|
||||||
import { useAppConfigContext } from "./useAppConfig";
|
|
||||||
import {
|
|
||||||
useSourcifyMetadata,
|
|
||||||
useTransactionDescription,
|
|
||||||
} from "./sourcify/useSourcify";
|
|
||||||
|
|
||||||
const Details = React.lazy(() => import("./transaction/Details"));
|
const Details = React.lazy(() => import("./transaction/Details"));
|
||||||
const Logs = React.lazy(() => import("./transaction/Logs"));
|
const Logs = React.lazy(() => import("./transaction/Logs"));
|
||||||
@ -46,14 +41,6 @@ const TransactionPageContent: React.FC<TransactionPageContentProps> = ({
|
|||||||
|
|
||||||
const selectionCtx = useSelection();
|
const selectionCtx = useSelection();
|
||||||
|
|
||||||
const { sourcifySource } = useAppConfigContext();
|
|
||||||
const metadata = useSourcifyMetadata(
|
|
||||||
txData?.to,
|
|
||||||
provider?.network.chainId,
|
|
||||||
sourcifySource
|
|
||||||
);
|
|
||||||
const txDesc = useTransactionDescription(metadata, txData);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SelectedTransactionContext.Provider value={txData}>
|
<SelectedTransactionContext.Provider value={txData}>
|
||||||
<BlockNumberContext.Provider value={txData?.confirmedData?.blockNumber}>
|
<BlockNumberContext.Provider value={txData?.confirmedData?.blockNumber}>
|
||||||
@ -89,10 +76,6 @@ const TransactionPageContent: React.FC<TransactionPageContentProps> = ({
|
|||||||
element={
|
element={
|
||||||
<Details
|
<Details
|
||||||
txData={txData}
|
txData={txData}
|
||||||
txDesc={txDesc}
|
|
||||||
toMetadata={metadata}
|
|
||||||
userDoc={metadata?.output.userdoc}
|
|
||||||
devDoc={metadata?.output.devdoc}
|
|
||||||
internalOps={internalOps}
|
internalOps={internalOps}
|
||||||
sendsEthToMiner={sendsEthToMiner}
|
sendsEthToMiner={sendsEthToMiner}
|
||||||
/>
|
/>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import React, { useContext, useState } from "react";
|
import React, { useContext, useState } from "react";
|
||||||
import { Tab } from "@headlessui/react";
|
import { Tab } from "@headlessui/react";
|
||||||
import { TransactionDescription } from "@ethersproject/abi";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faCheckCircle } from "@fortawesome/free-solid-svg-icons/faCheckCircle";
|
import { faCheckCircle } from "@fortawesome/free-solid-svg-icons/faCheckCircle";
|
||||||
import { faCube } from "@fortawesome/free-solid-svg-icons/faCube";
|
import { faCube } from "@fortawesome/free-solid-svg-icons/faCube";
|
||||||
@ -37,7 +36,12 @@ import {
|
|||||||
use4Bytes,
|
use4Bytes,
|
||||||
useTransactionDescription,
|
useTransactionDescription,
|
||||||
} from "../use4Bytes";
|
} from "../use4Bytes";
|
||||||
import { DevDoc, Metadata, useError, UserDoc } from "../sourcify/useSourcify";
|
import { useAppConfigContext } from "../useAppConfig";
|
||||||
|
import {
|
||||||
|
useError,
|
||||||
|
useSourcifyMetadata,
|
||||||
|
useTransactionDescription as useSourcifyTransactionDescription,
|
||||||
|
} from "../sourcify/useSourcify";
|
||||||
import { RuntimeContext } from "../useRuntime";
|
import { RuntimeContext } from "../useRuntime";
|
||||||
import { useTransactionError } from "../useErigonHooks";
|
import { useTransactionError } from "../useErigonHooks";
|
||||||
import { useChainInfo } from "../useChainInfo";
|
import { useChainInfo } from "../useChainInfo";
|
||||||
@ -45,20 +49,12 @@ import { useETHUSDOracle } from "../usePriceOracle";
|
|||||||
|
|
||||||
type DetailsProps = {
|
type DetailsProps = {
|
||||||
txData: TransactionData;
|
txData: TransactionData;
|
||||||
txDesc: TransactionDescription | null | undefined;
|
|
||||||
toMetadata: Metadata | null | undefined;
|
|
||||||
userDoc?: UserDoc | undefined;
|
|
||||||
devDoc?: DevDoc | undefined;
|
|
||||||
internalOps?: InternalOperation[];
|
internalOps?: InternalOperation[];
|
||||||
sendsEthToMiner: boolean;
|
sendsEthToMiner: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Details: React.FC<DetailsProps> = ({
|
const Details: React.FC<DetailsProps> = ({
|
||||||
txData,
|
txData,
|
||||||
txDesc,
|
|
||||||
toMetadata,
|
|
||||||
userDoc,
|
|
||||||
devDoc,
|
|
||||||
internalOps,
|
internalOps,
|
||||||
sendsEthToMiner,
|
sendsEthToMiner,
|
||||||
}) => {
|
}) => {
|
||||||
@ -75,11 +71,21 @@ const Details: React.FC<DetailsProps> = ({
|
|||||||
txData.value
|
txData.value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { provider } = useContext(RuntimeContext);
|
||||||
|
const { sourcifySource } = useAppConfigContext();
|
||||||
|
const metadata = useSourcifyMetadata(
|
||||||
|
txData?.to,
|
||||||
|
provider?.network.chainId,
|
||||||
|
sourcifySource
|
||||||
|
);
|
||||||
|
|
||||||
|
const txDesc = useSourcifyTransactionDescription(metadata, txData);
|
||||||
|
const userDoc = metadata?.output.userdoc;
|
||||||
|
const devDoc = metadata?.output.devdoc;
|
||||||
const resolvedTxDesc = txDesc ?? fourBytesTxDesc;
|
const resolvedTxDesc = txDesc ?? fourBytesTxDesc;
|
||||||
const userMethod = txDesc ? userDoc?.methods[txDesc.signature] : undefined;
|
const userMethod = txDesc ? userDoc?.methods[txDesc.signature] : undefined;
|
||||||
const devMethod = txDesc ? devDoc?.methods[txDesc.signature] : undefined;
|
const devMethod = txDesc ? devDoc?.methods[txDesc.signature] : undefined;
|
||||||
|
|
||||||
const { provider } = useContext(RuntimeContext);
|
|
||||||
const {
|
const {
|
||||||
nativeCurrency: { name, symbol },
|
nativeCurrency: { name, symbol },
|
||||||
} = useChainInfo();
|
} = useChainInfo();
|
||||||
@ -94,7 +100,7 @@ const Details: React.FC<DetailsProps> = ({
|
|||||||
txData.transactionHash
|
txData.transactionHash
|
||||||
);
|
);
|
||||||
const errorDescription = useError(
|
const errorDescription = useError(
|
||||||
toMetadata,
|
metadata,
|
||||||
isCustomError ? outputData : undefined
|
isCustomError ? outputData : undefined
|
||||||
);
|
);
|
||||||
const userError = errorDescription
|
const userError = errorDescription
|
||||||
|
Loading…
Reference in New Issue
Block a user