@cyberk/hyperion-sdk
Version:
Hyperion SDK from Cyberk
32 lines • 1.05 kB
JavaScript
import { queryContractSmart } from "../utils";
export const getCw20TokenBalanceQueryMsg = ({ address, }) => {
return {
balance: {
address,
},
};
};
export const getCw20TokenBalanceQueryKey = (options) => {
return ["cw20TokenBalance", options.tokenAddress, options.address];
};
export const getCw20TokenBalanceFn = async (options) => {
const { client, tokenAddress, address } = options;
if (!client) {
throw new Error("Client is required");
}
if (!tokenAddress) {
throw new Error("Token address is required");
}
if (!address) {
throw new Error("Address is required");
}
const response = await queryContractSmart(client, tokenAddress, getCw20TokenBalanceQueryMsg({ address }));
return response.balance;
};
export const getCw20TokenBalanceQueryOptions = (options) => {
return {
queryFn: async () => getCw20TokenBalanceFn(options),
queryKey: getCw20TokenBalanceQueryKey(options),
};
};
//# sourceMappingURL=getCw20TokenBalance.js.map