import type { EmbeddedAccount, Openfort, User, UserAccount } from '@openfort/openfort-js'; import { type ChainTypeEnum, EmbeddedState } from '@openfort/openfort-js'; import { type StoreApi } from 'zustand/vanilla'; import type { WalletFlowStatus } from '../hooks/openfort/walletTypes'; export type OpenfortStoreState = { user: User | null; linkedAccounts: UserAccount[]; embeddedState: EmbeddedState; embeddedAccounts: EmbeddedAccount[] | undefined; isLoadingAccounts: boolean; activeEmbeddedAddress: string | undefined; walletStatus: WalletFlowStatus; chainType: ChainTypeEnum; isLoading: boolean; needsRecovery: boolean; /** * Set when auto-recovery fails. Null on success or when cleared by a new auth session. * Consumers can read this from `useOpenfortCore()` to show recovery error UI. */ recoveryError: Error | null; }; export type OpenfortStoreActions = { setUser: (user: User | null) => void; setLinkedAccounts: (accounts: UserAccount[]) => void; setEmbeddedState: (state: EmbeddedState) => void; setEmbeddedAccounts: (accounts: EmbeddedAccount[] | undefined) => void; setIsLoadingAccounts: (loading: boolean) => void; setActiveEmbeddedAddress: (address: string | undefined) => void; setWalletStatus: (status: WalletFlowStatus) => void; setChainType: (chainType: ChainTypeEnum) => void; setRecoveryError: (error: Error | null) => void; /** Force-recompute isLoading from current state + bridge info. */ recomputeIsLoading: () => void; logout: () => Promise; signUpGuest: () => Promise; updateUser: (user?: User) => Promise; updateEmbeddedAccounts: (options?: { silent?: boolean; }) => Promise; client: Openfort; }; export type OpenfortStore = OpenfortStoreState & OpenfortStoreActions; export declare function createOpenfortStore(initialChainType: ChainTypeEnum, client: Openfort, getBridgeInfo?: () => { hasBridge: boolean; address: string | undefined; }, connectOnLogin?: boolean): StoreApi;