import { type CheckoutQuoteResponse, type WalletExecutionErrorCode } from '@funkit/connect-core'; import type { Address } from 'viem'; import type { WithdrawalFlowCallbacks, WithdrawalFlowConfig, WithdrawalToken } from '../flow/withdrawalFlowConfig'; /** * What a submitted withdrawal can be followed by: a venue that submits * off-chain leaves an address, not a transaction of ours. A union rather than * two optionals, so the completion screen cannot read the wrong one. */ export type DepositAddressOrHash = { kind: 'transaction'; txHash: string; } | { kind: 'depositAddress'; depositAddress: Address; }; export type CryptoWithdrawalSubmission = { status: 'idle'; } | { status: 'submitting'; stepMessage?: string; } | { status: 'submitted'; depositAddressOrHash: DepositAddressOrHash; submissionId: string; /** The amount that executed, not whatever the field says by now. */ amount: string; } | { status: 'failed'; code: WalletExecutionErrorCode; /** * The error's own text. Read by the form only where the classified cause * says nothing the user can act on — a failure the SDK cannot name is * better reported in the provider's words than as "please try again". */ message: string; }; export interface UseCryptoWithdrawalExecutionParams { config: WithdrawalFlowConfig; sourceToken: WithdrawalToken; destinationToken: WithdrawalToken; callbacks: WithdrawalFlowCallbacks; } /** * Runs the withdrawal the user approved, down whichever rail the config names: * the relay quote, or `config.submitWithdrawal` when the venue moves the funds. * * Both guards are read synchronously inside the async submit — before the first * await — so neither may wait for a re-render: a ref for a double-tap on this * mount, and a module-scoped set of in-flight withdrawals for a second press * after the sheet was closed and reopened mid-execution. The set holds only * while the signature is outstanding; deliberately sending the same amount to * the same address again once it has settled is a legitimate withdrawal. */ export declare function useCryptoWithdrawalExecution({ config, sourceToken, destinationToken, callbacks, }: UseCryptoWithdrawalExecutionParams): { submission: CryptoWithdrawalSubmission; submit: ({ quote, recipientAddress, amount, }: { /** The quote on screen — executed as-is, so fees shown are fees paid. */ quote: CheckoutQuoteResponse; recipientAddress: string; amount: string; }) => Promise; reset: () => void; }; //# sourceMappingURL=useCryptoWithdrawalExecution.d.ts.map