Fix tabs when search by ens name; fix contract creation on block txs results

This commit is contained in:
Willian Mitsuda 2021-12-04 16:54:27 -03:00
parent 7a9dd3c519
commit 658e530ed1
7 changed files with 18 additions and 10 deletions

View File

@ -108,11 +108,9 @@ const AddressTransactions: React.FC = () => {
</StandardSubtitle> </StandardSubtitle>
<Tab.Group> <Tab.Group>
<Tab.List className="flex space-x-2 border-l border-r border-t rounded-t-lg bg-white"> <Tab.List className="flex space-x-2 border-l border-r border-t rounded-t-lg bg-white">
<NavTab href={`/address/${checksummedAddress}`}> <NavTab href={`/address/${addressOrName}`}>Overview</NavTab>
Overview
</NavTab>
{(contractAddresses?.length ?? 0) > 0 && ( {(contractAddresses?.length ?? 0) > 0 && (
<NavTab href={`/address/${checksummedAddress}/contract`}> <NavTab href={`/address/${addressOrName}/contract`}>
<span <span
className={`flex items-baseline space-x-2 ${ className={`flex items-baseline space-x-2 ${
addressMetadata === undefined ? "italic opacity-50" : "" addressMetadata === undefined ? "italic opacity-50" : ""

View File

@ -40,7 +40,7 @@ const BlockTransactionResults: React.FC<BlockTransactionResultsProps> = ({
return []; return [];
} }
return page.map((t) => t.to).filter((to): to is string => to !== undefined); return page.map((t) => t.to).filter((to): to is string => to !== null);
}, [page]); }, [page]);
const metadatas = useContractsMetadata(addresses, provider); const metadatas = useContractsMetadata(addresses, provider);

View File

@ -99,7 +99,10 @@ const TransactionItem: React.FC<TransactionItemProps> = ({
/> />
</span> </span>
</span> </span>
<span className="col-span-2 flex items-baseline" title={tx.to}> <span
className="col-span-2 flex items-baseline"
title={tx.to ?? tx.createdContractAddress}
>
<span className="truncate"> <span className="truncate">
{tx.to ? ( {tx.to ? (
<AddressHighlighter address={tx.to}> <AddressHighlighter address={tx.to}>

View File

@ -52,7 +52,7 @@ export class SearchController {
idx: _receipt.transactionIndex, idx: _receipt.transactionIndex,
hash: t.hash, hash: t.hash,
from: t.from, from: t.from,
to: t.to, to: t.to ?? null,
createdContractAddress: _receipt.contractAddress, createdContractAddress: _receipt.contractAddress,
value: t.value, value: t.value,
fee: _receipt.gasUsed.mul(t.gasPrice!), fee: _receipt.gasUsed.mul(t.gasPrice!),

View File

@ -16,7 +16,7 @@ export type ProcessedTransaction = {
idx: number; idx: number;
hash: string; hash: string;
from?: string; from?: string;
to?: string; to: string | null;
createdContractAddress?: string; createdContractAddress?: string;
internalMinerInteraction?: boolean; internalMinerInteraction?: boolean;
value: BigNumber; value: BigNumber;

View File

@ -103,7 +103,7 @@ export const useBlockTransactions = (
idx: i, idx: i,
hash: t.hash, hash: t.hash,
from: t.from, from: t.from,
to: t.to, to: t.to ?? null,
createdContractAddress: _receipts[i].contractAddress, createdContractAddress: _receipts[i].contractAddress,
value: t.value, value: t.value,
fee: fee:
@ -457,8 +457,10 @@ export const useAddressesWithCode = (
const [results, setResults] = useState<ChecksummedAddress[] | undefined>(); const [results, setResults] = useState<ChecksummedAddress[] | undefined>();
useEffect(() => { useEffect(() => {
if (provider === undefined) { // Reset
setResults(undefined); setResults(undefined);
if (provider === undefined) {
return; return;
} }

View File

@ -27,6 +27,11 @@ export const useAddressOrENSFromURL = (
// If it looks like it is an ENS name, try to resolve it // If it looks like it is an ENS name, try to resolve it
useEffect(() => { useEffect(() => {
// Reset
setENS(false);
setError(false);
setChecksummedAddress(undefined);
// TODO: handle and offer fallback to bad checksummed addresses // TODO: handle and offer fallback to bad checksummed addresses
if (isAddress(addressOrName)) { if (isAddress(addressOrName)) {
// Normalize to checksummed address // Normalize to checksummed address