From 658e530ed14260c3f4be820d52a716c44e8e86cc Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sat, 4 Dec 2021 16:54:27 -0300 Subject: [PATCH] Fix tabs when search by ens name; fix contract creation on block txs results --- src/AddressTransactions.tsx | 6 ++---- src/block/BlockTransactionResults.tsx | 2 +- src/search/TransactionItem.tsx | 5 ++++- src/search/search.ts | 2 +- src/types.ts | 2 +- src/useErigonHooks.ts | 6 ++++-- src/useResolvedAddresses.ts | 5 +++++ 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/AddressTransactions.tsx b/src/AddressTransactions.tsx index 9adcd86..d7222c0 100644 --- a/src/AddressTransactions.tsx +++ b/src/AddressTransactions.tsx @@ -108,11 +108,9 @@ const AddressTransactions: React.FC = () => { - - Overview - + Overview {(contractAddresses?.length ?? 0) > 0 && ( - + = ({ 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]); const metadatas = useContractsMetadata(addresses, provider); diff --git a/src/search/TransactionItem.tsx b/src/search/TransactionItem.tsx index 929d2cd..b6cfe1e 100644 --- a/src/search/TransactionItem.tsx +++ b/src/search/TransactionItem.tsx @@ -99,7 +99,10 @@ const TransactionItem: React.FC = ({ /> - + {tx.to ? ( diff --git a/src/search/search.ts b/src/search/search.ts index 25bda65..57a5958 100644 --- a/src/search/search.ts +++ b/src/search/search.ts @@ -52,7 +52,7 @@ export class SearchController { idx: _receipt.transactionIndex, hash: t.hash, from: t.from, - to: t.to, + to: t.to ?? null, createdContractAddress: _receipt.contractAddress, value: t.value, fee: _receipt.gasUsed.mul(t.gasPrice!), diff --git a/src/types.ts b/src/types.ts index fde36bb..adedc86 100644 --- a/src/types.ts +++ b/src/types.ts @@ -16,7 +16,7 @@ export type ProcessedTransaction = { idx: number; hash: string; from?: string; - to?: string; + to: string | null; createdContractAddress?: string; internalMinerInteraction?: boolean; value: BigNumber; diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index f722f03..a1e45f1 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -103,7 +103,7 @@ export const useBlockTransactions = ( idx: i, hash: t.hash, from: t.from, - to: t.to, + to: t.to ?? null, createdContractAddress: _receipts[i].contractAddress, value: t.value, fee: @@ -457,8 +457,10 @@ export const useAddressesWithCode = ( const [results, setResults] = useState(); useEffect(() => { + // Reset + setResults(undefined); + if (provider === undefined) { - setResults(undefined); return; } diff --git a/src/useResolvedAddresses.ts b/src/useResolvedAddresses.ts index dc0df3a..9c92310 100644 --- a/src/useResolvedAddresses.ts +++ b/src/useResolvedAddresses.ts @@ -27,6 +27,11 @@ export const useAddressOrENSFromURL = ( // If it looks like it is an ENS name, try to resolve it useEffect(() => { + // Reset + setENS(false); + setError(false); + setChecksummedAddress(undefined); + // TODO: handle and offer fallback to bad checksummed addresses if (isAddress(addressOrName)) { // Normalize to checksummed address