/** * Copyright (c) TonTech. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { getJettonBalanceByAddressQueryOptions } from '@ton/appkit/queries'; import type { GetJettonBalanceByAddressData, GetJettonBalanceErrorType, GetJettonBalanceByAddressQueryConfig, } from '@ton/appkit/queries'; import { useAppKit } from '../../settings'; import { useQuery } from '../../../libs/query'; import type { UseQueryReturnType } from '../../../libs/query'; import { useNetwork } from '../../network'; export type UseJettonBalanceByAddressParameters = GetJettonBalanceByAddressQueryConfig; export type UseJettonBalanceByAddressReturnType = UseQueryReturnType< selectData, GetJettonBalanceErrorType >; /** * Hook to get jetton balance */ export const useJettonBalanceByAddress = ( parameters: UseJettonBalanceByAddressParameters = {}, ): UseJettonBalanceByAddressReturnType => { const appKit = useAppKit(); const walletNetwork = useNetwork(); return useQuery( getJettonBalanceByAddressQueryOptions(appKit, { ...parameters, network: parameters.network ?? walletNetwork }), ); };