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

View File

@ -30,7 +30,11 @@ const TransactionAddress: React.FC<TransactionAddressProps> = ({
const toHasCode = useHasCode( const toHasCode = useHasCode(
provider, provider,
address, address,
blockNumber !== undefined ? blockNumber - 1 : undefined blockNumber !== undefined
? blockNumber === "latest"
? "latest"
: blockNumber - 1
: undefined
); );
return ( 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), * at the time (block) the transaction happened it was still an EOA (create2),
* so it should be displayed as an EOA. * 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); export const useBlockNumberContext = () => useContext(BlockNumberContext);