Add eoa/contract indicator to contract creator addr on addr page

This commit is contained in:
Willian Mitsuda 2022-03-24 15:39:09 -03:00
parent f1a9a2f65d
commit 3fa2add09f
3 changed files with 40 additions and 28 deletions

View File

@ -20,6 +20,7 @@ import { useParams, useSearchParams } from "react-router-dom";
import { ChecksummedAddress, ProcessedTransaction } from "../types";
import { useContractsMetadata } from "../hooks";
import { useAddressBalance, useContractCreator } from "../useErigonHooks";
import { BlockNumberContext } from "../useBlockTagContext";
type AddressTransactionResultsProps = {
address: ChecksummedAddress;
@ -133,6 +134,7 @@ const AddressTransactionResults: React.FC<AddressTransactionResultsProps> = ({
return (
<ContentFrame tabs>
<SelectionContext.Provider value={selectionCtx}>
<BlockNumberContext.Provider value="latest">
{balance && (
<InfoRow title="Balance">
<div className="space-x-2">
@ -152,7 +154,10 @@ const AddressTransactionResults: React.FC<AddressTransactionResultsProps> = ({
<InfoRow title="Contract creator">
<div className="flex divide-x-2 divide-dotted divide-gray-300">
<div className="flex items-baseline space-x-2 -ml-1 mr-3">
<TransactionAddress address={creator.creator} />
<TransactionAddress
address={creator.creator}
showCodeIndicator
/>
<Copy value={creator.creator} />
</div>
<div className="flex items-baseline pl-3">
@ -161,6 +166,7 @@ const AddressTransactionResults: React.FC<AddressTransactionResultsProps> = ({
</div>
</InfoRow>
)}
</BlockNumberContext.Provider>
<NavBar address={address} page={page} controller={controller} />
<ResultHeader
feeDisplay={feeDisplay}

View File

@ -30,7 +30,11 @@ const TransactionAddress: React.FC<TransactionAddressProps> = ({
const toHasCode = useHasCode(
provider,
address,
blockNumber !== undefined ? blockNumber - 1 : undefined
blockNumber !== undefined
? blockNumber === "latest"
? "latest"
: blockNumber - 1
: undefined
);
return (

View File

@ -10,6 +10,8 @@ import { createContext, useContext } from "react";
* at the time (block) the transaction happened it was still an EOA (create2),
* so it should be displayed as an EOA.
*/
export const BlockNumberContext = createContext<number | undefined>(undefined);
export const BlockNumberContext = createContext<number | "latest" | undefined>(
undefined
);
export const useBlockNumberContext = () => useContext(BlockNumberContext);