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,34 +134,39 @@ const AddressTransactionResults: React.FC<AddressTransactionResultsProps> = ({
return ( return (
<ContentFrame tabs> <ContentFrame tabs>
<SelectionContext.Provider value={selectionCtx}> <SelectionContext.Provider value={selectionCtx}>
{balance && ( <BlockNumberContext.Provider value="latest">
<InfoRow title="Balance"> {balance && (
<div className="space-x-2"> <InfoRow title="Balance">
<TransactionValue value={balance} /> <div className="space-x-2">
{!balance.isZero() && priceMap["latest"] !== undefined && ( <TransactionValue value={balance} />
<span className="px-2 border-green-200 border rounded-lg bg-green-100 text-green-600"> {!balance.isZero() && priceMap["latest"] !== undefined && (
<ETH2USDValue <span className="px-2 border-green-200 border rounded-lg bg-green-100 text-green-600">
ethAmount={balance} <ETH2USDValue
eth2USDValue={priceMap["latest"]} ethAmount={balance}
eth2USDValue={priceMap["latest"]}
/>
</span>
)}
</div>
</InfoRow>
)}
{creator && (
<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}
showCodeIndicator
/> />
</span> <Copy value={creator.creator} />
)} </div>
</div> <div className="flex items-baseline pl-3">
</InfoRow> <TransactionLink txHash={creator.hash} />
)} </div>
{creator && (
<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} />
<Copy value={creator.creator} />
</div> </div>
<div className="flex items-baseline pl-3"> </InfoRow>
<TransactionLink txHash={creator.hash} /> )}
</div> </BlockNumberContext.Provider>
</div>
</InfoRow>
)}
<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);