diff --git a/src/address/AddressTransactionResults.tsx b/src/address/AddressTransactionResults.tsx index f19a43a..4fd7b25 100644 --- a/src/address/AddressTransactionResults.tsx +++ b/src/address/AddressTransactionResults.tsx @@ -1,6 +1,10 @@ import React, { useContext, useEffect, useMemo, useState } from "react"; import { BlockTag } from "@ethersproject/providers"; import ContentFrame from "../ContentFrame"; +import InfoRow from "../components/InfoRow"; +import TransactionAddress from "../components/TransactionAddress"; +import Copy from "../components/Copy"; +import TransactionLink from "../components/TransactionLink"; import PendingResults from "../search/PendingResults"; import ResultHeader from "../search/ResultHeader"; import { SearchController } from "../search/search"; @@ -13,6 +17,7 @@ import { RuntimeContext } from "../useRuntime"; import { useParams, useSearchParams } from "react-router-dom"; import { ChecksummedAddress, ProcessedTransaction } from "../types"; import { useContractsMetadata } from "../hooks"; +import { useContractCreator } from "../useErigonHooks"; type AddressTransactionResultsProps = { address: ChecksummedAddress; @@ -117,31 +122,46 @@ const AddressTransactionResults: React.FC = ({ return _addresses; }, [address, page]); const metadatas = useContractsMetadata(addresses, provider); + const creator = useContractCreator(provider, address); return ( - - - {page ? ( - - {page.map((tx) => ( - - ))} - - - ) : ( - - )} + + + {creator && ( + +
+ + + at + tx: + +
+
+ )} + + + {page ? ( + <> + {page.map((tx) => ( + + ))} + + + ) : ( + + )} +
); }; diff --git a/src/params.ts b/src/params.ts index f26ef7a..26f7291 100644 --- a/src/params.ts +++ b/src/params.ts @@ -1,3 +1,3 @@ -export const MIN_API_LEVEL = 7; +export const MIN_API_LEVEL = 8; export const PAGE_SIZE = 25; diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index ad9b0b8..0039963 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -605,3 +605,56 @@ export const useTransactionBySenderAndNonce = ( } return data; }; + +type ContractCreatorKey = { + type: "cc"; + network: number; + address: ChecksummedAddress; +}; + +type ContractCreator = { + hash: string; + creator: ChecksummedAddress; +}; + +export const useContractCreator = ( + provider: JsonRpcProvider | undefined, + address: ChecksummedAddress | undefined +): ContractCreator | null | undefined => { + const { data, error } = useSWR< + ContractCreator | null | undefined, + any, + ContractCreatorKey | null + >( + provider && address + ? { + type: "cc", + network: provider.network.chainId, + address, + } + : null, + getContractCreatorFetcher(provider!) + ); + + if (error) { + return undefined; + } + return data as ContractCreator; +}; + +const getContractCreatorFetcher = + (provider: JsonRpcProvider) => + async ({ + network, + address, + }: ContractCreatorKey): Promise => { + const result = (await provider.send("ots_experimentalGetContractCreator", [ + address, + ])) as ContractCreator; + + // Empty or success + if (result) { + result.creator = provider.formatter.address(result.creator); + } + return result; + };