import { type SignTypedDataPayload } from '../../components/Openfort/types.js'; import type { OpenfortError } from '../../errors/base.js'; import type { OpenfortHookOptions } from '../../types.js'; /** * The resolved result of a modal signing request. * * @example * ```ts * import type { SignMessageResult } from '@openfort/react' * * function readSignature(result: SignMessageResult) { * return 'error' in result ? result.error.shortMessage : result.signature * } * ``` */ export type SignMessageResult = { signature: string; } | { error: OpenfortError; }; type SignMessageSuccess = Extract; /** * Lifecycle callbacks for modal signing requests. * * @example * ```ts * import type { UseSignMessageOptions } from '@openfort/react' * * const options: UseSignMessageOptions = { * onError: (error) => console.error(error.shortMessage), * } * ``` */ export type UseSignMessageOptions = OpenfortHookOptions; /** * Hook for signing messages with a confirmation modal. EIP-712 typed data is * available for EVM wallets; Solana wallets accept plain messages. * * Opens the Openfort "Sign message" screen, shows the message (or EIP-712 typed * data) to the user. Every request resolves to `{ signature }` or `{ error }`; * cancellation, supersession, and signing failures never reject the promise. * * @example * ```tsx * import { useSignMessage } from '@openfort/react' * * function SignButton() { * const { signMessage, isPending } = useSignMessage() * const sign = async () => { * const result = await signMessage('I hereby vote for foobar') * if ('error' in result) return * console.log(result.signature) * } * return * } * ``` */ export declare function useSignMessage(hookOptions?: UseSignMessageOptions): { signMessage: (message: string) => Promise; signTypedData: (typedData: SignTypedDataPayload) => Promise; isPending: boolean; error: OpenfortError | null; }; export {};