@cyberk/hyperion-sdk
Version:
Hyperion SDK from Cyberk
34 lines • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useRegisteredNativeTokenDecimals = void 0;
const react_query_1 = require("@tanstack/react-query");
const RPCs_1 = require("../constants/RPCs");
const useCosmWasmClient_1 = require("./useCosmWasmClient");
const getRegisteredNativeTokenDecimals_1 = require("../query/getRegisteredNativeTokenDecimals");
const useRegisteredNativeTokenDecimals = ({ factoryAddress, chainId, denom, 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 && !!factoryAddress && !!denom;
const { queryKey, ...options } = (0, getRegisteredNativeTokenDecimals_1.getRegisteredNativeTokenDecimals)({
client: cosmwasmClient,
factoryAddress,
denom,
});
return (0, react_query_1.useQuery)({
...observerOptions,
...options,
// @ts-expect-error
queryKey,
enabled: Boolean(enabled && (observerOptions?.enabled ?? true)),
});
};
exports.useRegisteredNativeTokenDecimals = useRegisteredNativeTokenDecimals;
//# sourceMappingURL=useRegisteredNativeTokenDecimals.js.map