import type { FiatStepResponse, JsonValue, Quote } from '@fun-xyz/fiat-contract/types'; import { type GetIdentityAssertion, type IdentityAssertionProvider } from '../../domains/fiat/identityAssertion'; import type { SubmitTransition, SurfaceTransition, TransitionDispatch } from '../../domains/fiat/selectTransitions'; import type { CollectedInputs, SurfaceResult } from '../../domains/fiat/submitBody'; import type { FunLogger } from '../../utils/funLogger'; import type { FiatFlowState, FiatPhase } from './fiatFlowReducer'; /** * How `/fiat/*` requests authenticate. One object rather than two optional * props, because a minter without a subject is the identity-crossing bug: the * cache has to be scoped to *who* the assertion speaks for, and the callback's own * identity cannot say. A host that inlines the callback passes a new function * every render, so rebuilding on that would defeat the cache, while never * rebuilding would let a user switch keep spending the previous user's assertion * until it expired. Pairing them makes the subject impossible to forget. */ export interface FiatIdentityAssertion { /** Mints the host-signed identity assertion sent as the bearer credential. */ getAssertion: GetIdentityAssertion; /** Who the assertion speaks for — the signed-in user's id. */ subject: string; } export interface UseFiatTransitionsParams { apiKey: string; logger: FunLogger; /** Omitted only while a flow has no signed-in user to speak for. */ identityAssertion?: FiatIdentityAssertion; /** Address that receives the purchased crypto. */ depositAddress?: string; /** * Whether a confirmed delivery ends the order — true only where the * provider pays the recipient itself. See {@link ComputePageOptions}. */ settlesOnDelivery?: boolean; } export interface FiatFlow { phase: FiatPhase; page: FiatFlowState['page']; stepResponse?: FiatStepResponse; quote?: Quote; identityAssertionProvider?: IdentityAssertionProvider; ctas: TransitionDispatch['ctas']; surface: TransitionDispatch['surface']; collected: CollectedInputs; isPolling: boolean; isInFlight: boolean; error: unknown; submitError: unknown; receive: (stepResponse: FiatStepResponse) => void; setField: (name: string, value: JsonValue) => void; /** Submits a collected transition, optionally adding values produced atomically by a provider surface. */ submit: (cta: SubmitTransition, additionalInputs?: CollectedInputs) => Promise; reportSurface: (result: SurfaceResult, transition?: SurfaceTransition) => Promise; retry: () => Promise; exit: () => void; } /** Drives transitions, submissions, and polling for one fiat flow. */ export declare function useFiatTransitions({ apiKey, logger, identityAssertion, depositAddress, settlesOnDelivery, }: UseFiatTransitionsParams): FiatFlow; //# sourceMappingURL=useFiatTransitions.d.ts.map