import { queryClient } from '../commands/_app.js';
import { CHAIN_LIST_URL, fetchChainList, } from '../superchain-registry/fetchChainList.js';
import { useQuery } from '@tanstack/react-query';
const getQueryParams = (chainListURL) => {
    return {
        queryKey: ['chainConfig', chainListURL],
        queryFn: () => fetchChainList(chainListURL),
    };
};
export const queryChainConfig = async (chainListURL = CHAIN_LIST_URL) => {
    return queryClient.fetchQuery(getQueryParams(chainListURL));
};
export const useChainConfig = (chainListURL = CHAIN_LIST_URL) => {
    return useQuery({
        ...getQueryParams(chainListURL),
        staleTime: Infinity, // For the duration of the CLI session, this is cached
    });
};
