import { queryClient } from '../commands/_app.js';
import { queryChains } from './chains.js';
import { chainById } from '../util/chains/chains.js';
const getQueryParams = () => {
    return {
        queryKey: ['chainById'],
        queryFn: async () => {
            const chains = await queryChains();
            return chains.reduce((acc, chain) => {
                acc[chain.id] = chain;
                // Also set the source chain (L1)
                acc[chain.sourceId] = chainById[chain.sourceId];
                return acc;
            }, {});
        },
        staleTime: Infinity, // For the duration of the CLI session, this is cached
    };
};
export const queryMappingChainById = async () => {
    return queryClient.fetchQuery(getQueryParams());
};
// TODO: remove this entirely
export const useMappingChainById = () => {
    return {
        data: chainById,
        isLoading: false,
    };
};
