UNPKG

@cyberk/hyperion-sdk

Version:

Hyperion SDK from Cyberk

34 lines 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useAllPairs = void 0; const react_query_1 = require("@tanstack/react-query"); const RPCs_1 = require("../constants/RPCs"); const useCosmWasmClient_1 = require("./useCosmWasmClient"); const getAllPairs_1 = require("../query/getAllPairs"); const useAllPairs = ({ factoryAddress, chainId, options: observerOptions, limit, }) => { const rpc = RPCs_1.RPCs[chainId]; if (!rpc) { throw new Error(`RPC not found for chainId: ${chainId}`); } const { data: cosmwasmClient } = (0, useCosmWasmClient_1.useCosmWasmClient)({ rpc, options: { enabled: !!rpc, }, }); const enabled = !!cosmwasmClient; const { queryKey, ...options } = (0, getAllPairs_1.getAllPairsQueryOptions)({ client: cosmwasmClient, factoryAddress, limit, }); return (0, react_query_1.useQuery)({ ...observerOptions, ...options, // @ts-expect-error queryKey, enabled: Boolean(enabled && (observerOptions?.enabled ?? true)), }); }; exports.useAllPairs = useAllPairs; //# sourceMappingURL=useAllPairs.js.map