@cyberk/hyperion-sdk
Version:
Hyperion SDK from Cyberk
30 lines • 984 B
JavaScript
import { useQuery } from "@tanstack/react-query";
import { RPCs } from "../constants/RPCs";
import { useCosmWasmClient } from "./useCosmWasmClient";
import { getAllPairsQueryOptions, } from "../query/getAllPairs";
export const useAllPairs = ({ factoryAddress, chainId, options: observerOptions, limit, }) => {
const rpc = RPCs[chainId];
if (!rpc) {
throw new Error(`RPC not found for chainId: ${chainId}`);
}
const { data: cosmwasmClient } = useCosmWasmClient({
rpc,
options: {
enabled: !!rpc,
},
});
const enabled = !!cosmwasmClient;
const { queryKey, ...options } = getAllPairsQueryOptions({
client: cosmwasmClient,
factoryAddress,
limit,
});
return useQuery({
...observerOptions,
...options,
// @ts-expect-error
queryKey,
enabled: Boolean(enabled && (observerOptions?.enabled ?? true)),
});
};
//# sourceMappingURL=useAllPairs.js.map