import { ComposerActionFormResponse, ComposerActionState } from 'frames.js/types'; import { ResolveAddressFunction } from './unstable-types.cjs'; import { FarcasterSignerState } from './farcaster/signers.cjs'; import { MiniAppMessage, EthSendTransactionAction, EthSignTypedDataV4Action, MiniAppResponse } from './mini-app-messages.cjs'; export { miniAppMessageSchema } from './mini-app-messages.cjs'; import 'frames.js'; import 'frames.js/frame-parsers'; import 'react'; import './types-CH60H6Gq.cjs'; import './farcaster/types.cjs'; import 'viem'; import 'zod'; type RegisterMessageListener = (formResponse: ComposerActionFormResponse, messageListener: MiniAppMessageListener) => () => void; type MiniAppMessageListener = (message: MiniAppMessage) => Promise; type OnTransactionFunctionResult = { hash: `0x${string}`; address: `0x${string}`; }; type OnTransactionFunction = (arg: { action: EthSendTransactionAction; address: `0x${string}`; }) => Promise; type OnSignatureFunctionResult = { hash: `0x${string}`; address: `0x${string}`; }; type OnSignatureFunction = (arg: { action: EthSignTypedDataV4Action; address: `0x${string}`; }) => Promise; type OnCreateCastFunction = (arg: { cast: ComposerActionState; }) => Promise; type OnMessageRespondFunction = (response: MiniAppResponse, form: ComposerActionFormResponse) => unknown; type UseComposerActionOptions = { /** * Current action state, value should be memoized. It doesn't cause composer action / mini app to refetch. */ actionState: ComposerActionState; /** * URL to composer action / mini app server * * If value changes it will refetch the composer action / mini app */ url: string; /** * Signer used to sign the composer action. * * If value changes it will refetch the composer action / mini app */ signer: FarcasterSignerState; /** * URL to the action proxy server. If value changes composer action / mini app will be refetched. * * Proxy must handle POST requests. */ proxyUrl: string; /** * If enabled if will fetch the composer action / mini app on mount. * * @defaultValue true */ enabled?: boolean; /** * Custom fetch function to fetch the composer action / mini app. */ fetch?: (url: string, init: RequestInit) => Promise; /** * Called before onTransaction/onSignature is invoked to obtain an address to use. * * If the function returns null onTransaction/onSignature will not be called. */ resolveAddress: ResolveAddressFunction; onError?: (error: Error) => void; onCreateCast: OnCreateCastFunction; onTransaction: OnTransactionFunction; onSignature: OnSignatureFunction; /** * Called with message response to be posted to child (e.g. iframe). */ onMessageRespond: OnMessageRespondFunction; /** * Allows to override how the message listener is registered. Function must return a function that removes the listener. * * Changes in the value aren't reflected so it's recommended to use a memoized function. * * By default it uses window.addEventListener("message", ...) */ registerMessageListener?: RegisterMessageListener; }; type UseComposerActionResult = { refetch: () => Promise; } & ({ status: "idle"; data: undefined; error: undefined; } | { status: "loading"; data: undefined; error: undefined; } | { status: "error"; data: undefined; error: Error; } | { status: "success"; data: ComposerActionFormResponse; error: undefined; }); declare function useComposerAction({ actionState, enabled, proxyUrl, signer, url, fetch: fetchFunction, onError, onCreateCast, onSignature, onTransaction, resolveAddress, registerMessageListener, onMessageRespond, }: UseComposerActionOptions): UseComposerActionResult; /** * Default function used to register message listener. Works in browsers only. */ declare const defaultRegisterMessageListener: RegisterMessageListener; export { MiniAppMessage, MiniAppResponse, type OnCreateCastFunction, type OnMessageRespondFunction, type OnSignatureFunction, type OnSignatureFunctionResult, type OnTransactionFunction, type OnTransactionFunctionResult, type RegisterMessageListener, ResolveAddressFunction, type UseComposerActionOptions, defaultRegisterMessageListener, useComposerAction };