/** * 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 type { UseMutationResult } from '@tanstack/react-query'; import { signCellMutationOptions } from '@ton/appkit/queries'; import type { SignCellData, SignCellErrorType, SignCellOptions, SignCellVariables } from '@ton/appkit/queries'; import { useAppKit } from '../../settings'; import { useMutation } from '../../../libs/query'; export type UseSignCellParameters = SignCellOptions; export type UseSignCellReturnType = UseMutationResult< SignCellData, SignCellErrorType, SignCellVariables, context >; /** * Hook to sign TON Cell data with the connected wallet. * Used for on-chain signature verification. * * @example * ```tsx * const { mutate: signCell, isPending } = useSignCell(); * * const handleSign = () => { * signCell({ cell: bocBase64, schema: "transfer#abc amount:uint64 = Transfer" }); * }; * ``` */ export const useSignCell = ( parameters?: UseSignCellParameters, ): UseSignCellReturnType => { const appKit = useAppKit(); return useMutation(signCellMutationOptions(appKit, parameters)); };