Move hook
This commit is contained in:
parent
6f6dd1877a
commit
7a9dd3c519
16
src/hooks.ts
16
src/hooks.ts
|
@ -1,13 +1,19 @@
|
||||||
|
import { useMemo } from "react";
|
||||||
import { JsonRpcProvider } from "@ethersproject/providers";
|
import { JsonRpcProvider } from "@ethersproject/providers";
|
||||||
import { ChecksummedAddress } from "./types";
|
import { ChecksummedAddress } from "./types";
|
||||||
import {
|
import { Metadata, useMultipleMetadata } from "./sourcify/useSourcify";
|
||||||
Metadata,
|
|
||||||
useDedupedAddresses,
|
|
||||||
useMultipleMetadata,
|
|
||||||
} from "./sourcify/useSourcify";
|
|
||||||
import { useAppConfigContext } from "./useAppConfig";
|
import { useAppConfigContext } from "./useAppConfig";
|
||||||
import { useAddressesWithCode } from "./useErigonHooks";
|
import { useAddressesWithCode } from "./useErigonHooks";
|
||||||
|
|
||||||
|
export const useDedupedAddresses = (
|
||||||
|
addresses: ChecksummedAddress[]
|
||||||
|
): ChecksummedAddress[] => {
|
||||||
|
return useMemo(() => {
|
||||||
|
const deduped = new Set(addresses);
|
||||||
|
return [...deduped];
|
||||||
|
}, [addresses]);
|
||||||
|
};
|
||||||
|
|
||||||
export const useContractsMetadata = (
|
export const useContractsMetadata = (
|
||||||
addresses: ChecksummedAddress[],
|
addresses: ChecksummedAddress[],
|
||||||
provider: JsonRpcProvider | undefined,
|
provider: JsonRpcProvider | undefined,
|
||||||
|
|
|
@ -121,15 +121,6 @@ export const useSourcify = (
|
||||||
return rawMetadata;
|
return rawMetadata;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useDedupedAddresses = (
|
|
||||||
addresses: ChecksummedAddress[]
|
|
||||||
): ChecksummedAddress[] => {
|
|
||||||
return useMemo(() => {
|
|
||||||
const deduped = new Set(addresses);
|
|
||||||
return [...deduped];
|
|
||||||
}, [addresses]);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useMultipleMetadata = (
|
export const useMultipleMetadata = (
|
||||||
baseMetadatas: Record<string, Metadata | null> | undefined,
|
baseMetadatas: Record<string, Metadata | null> | undefined,
|
||||||
addresses: ChecksummedAddress[] | undefined,
|
addresses: ChecksummedAddress[] | undefined,
|
||||||
|
|
Loading…
Reference in New Issue