UNPKG

@cyberk/hyperion-sdk

Version:

Hyperion SDK from Cyberk

33 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.usePoolInfo = void 0; const react_query_1 = require("@tanstack/react-query"); const RPCs_1 = require("../constants/RPCs"); const useCosmWasmClient_1 = require("./useCosmWasmClient"); const getPoolInfo_1 = require("../query/getPoolInfo"); const usePoolInfo = ({ contractAddress, chainId, options: observerOptions, }) => { 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, getPoolInfo_1.getPoolInfoQueryOptions)({ client: cosmwasmClient, contractAddress, }); return (0, react_query_1.useQuery)({ ...observerOptions, ...options, // @ts-expect-error queryKey, enabled: Boolean(enabled && (observerOptions?.enabled ?? true)), }); }; exports.usePoolInfo = usePoolInfo; //# sourceMappingURL=usePoolInfo.js.map