Small refactorings

This commit is contained in:
Willian Mitsuda 2021-12-02 15:42:59 -03:00
parent 2e04c726d7
commit c40e653bef
5 changed files with 14 additions and 16 deletions

View File

@ -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
);

View File

@ -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
);

View File

@ -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]);
};

View File

@ -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
);

View File

@ -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
);