import { CastActionMessageResponse, CastActionFrameResponse } from 'frames.js/types'; import { ParseFramesWithReportsResult } from 'frames.js/frame-parsers'; import { OnErrorFunction } from './unstable-types.cjs'; import { FarcasterSignerState } from './farcaster/signers.cjs'; import 'frames.js'; import 'react'; import './types-CH60H6Gq.cjs'; import './farcaster/types.cjs'; type CastID = { fid: number; hash: `0x${string}`; }; type UseCastActionOptions = { /** * The id of the cast from which the user initiated the action * * If value changes it will refetch the cast action */ castId: CastID; /** * Post URL of the action handler * * If value changes it will refetch the cast action. */ postUrl: string; /** * URL to the action proxy server. If value changes cast action will be refetched. * * Proxy must handle POST requests. */ proxyUrl: string; /** * Signer used to sign the cast action. * * If value changes it will refetch the cast action. */ signer: FarcasterSignerState; /** * If enabled it will fetch the cast action on mount. * * @defaultValue true */ enabled?: boolean; /** * Custom fetch function to fetch cast action. */ fetch?: (url: string, init: RequestInit) => Promise; onError?: OnErrorFunction; /** * Called when the response is a CastActionMessageResponse. */ onMessageResponse?: (response: CastActionMessageResponse) => void; /** * Called when the response is a CastActionFrameResponse. */ onFrameResponse?: (response: CastActionFrameResponse) => void; /** * Called when the response is successful but it's not a valid cast action response. */ onInvalidResponse?: (response: unknown) => void; }; type UseCastActionResult = { refetch: () => Promise; } & ({ status: "idle"; data: undefined; error: undefined; } | { status: "loading"; data: undefined; error: undefined; } | { status: "error"; data: undefined; error: Error; } | { status: "success"; type: "frame"; data: CastActionFrameResponse; frame: ParseFramesWithReportsResult; error: undefined; } | { status: "success"; type: "message"; data: CastActionMessageResponse; error: undefined; }); declare function useCastAction({ castId, enabled, fetch: fetchFunction, onError, proxyUrl, signer, postUrl, onFrameResponse, onMessageResponse, onInvalidResponse, }: UseCastActionOptions): UseCastActionResult; export { type UseCastActionOptions, useCastAction };