/** * 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. * */ 'use client'; import { getGaslessConfigQueryOptions } from '@ton/appkit/queries'; import type { GetGaslessConfigData, GetGaslessConfigErrorType, GetGaslessConfigQueryConfig } 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 UseGaslessConfigParameters = GetGaslessConfigQueryConfig; export type UseGaslessConfigReturnType = UseQueryReturnType< selectData, GetGaslessConfigErrorType >; /** * Hook to fetch the gasless relayer's configuration — relay address and * accepted fee assets. */ export const useGaslessConfig = ( parameters: UseGaslessConfigParameters = {}, ): UseGaslessConfigReturnType => { const appKit = useAppKit(); const walletNetwork = useNetwork(); return useQuery( getGaslessConfigQueryOptions(appKit, { ...parameters, network: parameters.network ?? walletNetwork }), ); };