Small refactorings
This commit is contained in:
parent
2e04c726d7
commit
c40e653bef
|
@ -123,12 +123,12 @@ const AddressTransactionResults: React.FC<AddressTransactionResultsProps> = ({
|
|||
}
|
||||
return _addresses;
|
||||
}, [address, page]);
|
||||
const { sourcifySource } = useAppConfigContext();
|
||||
const deduped = useDedupedAddresses(addresses);
|
||||
const checked = useAddressesWithCode(provider, deduped);
|
||||
const contracts = useAddressesWithCode(provider, deduped);
|
||||
const { sourcifySource } = useAppConfigContext();
|
||||
const metadatas = useMultipleMetadata(
|
||||
undefined,
|
||||
checked,
|
||||
contracts,
|
||||
provider?.network.chainId,
|
||||
sourcifySource
|
||||
);
|
||||
|
|
|
@ -47,12 +47,12 @@ const BlockTransactionResults: React.FC<BlockTransactionResultsProps> = ({
|
|||
|
||||
return page.map((t) => t.to).filter((to): to is string => to !== undefined);
|
||||
}, [page]);
|
||||
const { sourcifySource } = useAppConfigContext();
|
||||
const deduped = useDedupedAddresses(addresses);
|
||||
const checked = useAddressesWithCode(provider, deduped);
|
||||
const contracts = useAddressesWithCode(provider, deduped);
|
||||
const { sourcifySource } = useAppConfigContext();
|
||||
const metadatas = useMultipleMetadata(
|
||||
undefined,
|
||||
checked,
|
||||
contracts,
|
||||
provider?.network.chainId,
|
||||
sourcifySource
|
||||
);
|
||||
|
|
|
@ -132,12 +132,10 @@ export const useSingleMetadata = (
|
|||
};
|
||||
|
||||
export const useDedupedAddresses = (
|
||||
addresses: (ChecksummedAddress | undefined)[]
|
||||
addresses: ChecksummedAddress[]
|
||||
): ChecksummedAddress[] => {
|
||||
return useMemo(() => {
|
||||
const deduped = new Set(
|
||||
addresses.filter((a): a is ChecksummedAddress => a !== undefined)
|
||||
);
|
||||
const deduped = new Set(addresses);
|
||||
return [...deduped];
|
||||
}, [addresses]);
|
||||
};
|
||||
|
|
|
@ -101,12 +101,12 @@ const Details: React.FC<DetailsProps> = ({
|
|||
}
|
||||
return _addresses;
|
||||
}, [txData]);
|
||||
const { sourcifySource } = useAppConfigContext();
|
||||
const deduped = useDedupedAddresses(addresses);
|
||||
const checked = useAddressesWithCode(provider, deduped);
|
||||
const contracts = useAddressesWithCode(provider, deduped);
|
||||
const { sourcifySource } = useAppConfigContext();
|
||||
const metadatas = useMultipleMetadata(
|
||||
undefined,
|
||||
checked,
|
||||
contracts,
|
||||
provider?.network.chainId,
|
||||
sourcifySource
|
||||
);
|
||||
|
|
|
@ -35,12 +35,12 @@ const Logs: React.FC<LogsProps> = ({ txData, metadata, resolvedAddresses }) => {
|
|||
[txData]
|
||||
);
|
||||
const { provider } = useContext(RuntimeContext);
|
||||
const { sourcifySource } = useAppConfigContext();
|
||||
const deduped = useDedupedAddresses(logAddresses);
|
||||
const checked = useAddressesWithCode(provider, deduped);
|
||||
const contracts = useAddressesWithCode(provider, deduped);
|
||||
const { sourcifySource } = useAppConfigContext();
|
||||
const metadatas = useMultipleMetadata(
|
||||
baseMetadatas,
|
||||
checked,
|
||||
contracts,
|
||||
provider?.network.chainId,
|
||||
sourcifySource
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue