import { type EmbeddedAccount, type Openfort, type User } from '@openfort/openfort-js'; import { type DataTag, type DefaultError, type UnusedSkipTokenOptions } from '@tanstack/react-query'; import { openfortKeys, type WalletAssetsKeyParams } from './queryKeys.js'; /** * The cache key the user query reads and writes. * * The real key carries a per-client scope, so `openfortKeys.user()` alone never * matches a cached entry. Target the family by prefix instead: * * @example * ```ts * import { openfortKeys } from '@openfort/react' * * queryClient.invalidateQueries({ queryKey: openfortKeys.user() }) * ``` */ export type UserQueryKey = ReturnType; /** * The cache key the embedded-accounts query reads and writes. * * As with {@link UserQueryKey}, the real key carries a per-client scope, so use * the unscoped form only as an `invalidateQueries` prefix. * * @example * ```ts * import { openfortKeys } from '@openfort/react' * * queryClient.invalidateQueries({ queryKey: openfortKeys.embeddedAccounts() }) * ``` */ export type EmbeddedAccountsQueryKey = ReturnType; /** * What {@link getUserQueryOptions} returns. * * The key is tagged with its payload, so `queryClient.getQueryData(key)` and * `setQueryData` are typed as `User` without a manual type argument. * * @example * ```ts * import { getUserQueryOptions, type UserQueryOptions } from '@openfort/react' * import type { Openfort } from '@openfort/openfort-js' * * const optionsFor = (client: Openfort): UserQueryOptions => getUserQueryOptions(client) * ``` */ export type UserQueryOptions = UnusedSkipTokenOptions & { queryKey: DataTag; }; /** * What {@link getEmbeddedAccountsQueryOptions} returns. * * The key is tagged with its payload, so `queryClient.getQueryData(key)` and * `setQueryData` are typed as `EmbeddedAccount[]` without a manual type argument. * * @example * ```ts * import { * getEmbeddedAccountsQueryOptions, * type EmbeddedAccountsQueryOptions, * } from '@openfort/react' * import type { Openfort } from '@openfort/openfort-js' * * const optionsFor = (client: Openfort): EmbeddedAccountsQueryOptions => * getEmbeddedAccountsQueryOptions(client) * ``` */ export type EmbeddedAccountsQueryOptions = UnusedSkipTokenOptions & { queryKey: DataTag; }; /** Reads the authenticated user. The provider fetches through this too. */ export declare function fetchUser(client: Openfort): Promise; /** Reads the user's embedded wallet accounts. The provider fetches through this too. */ export declare function fetchEmbeddedAccounts(client: Openfort): Promise; /** * Query options for the current user. * * Shares its key and fetcher with the provider, which publishes every user it * loads to this cache entry — so `useQuery(getUserQueryOptions(client))` reads * the same user the SDK is working with rather than a second copy. * * @example * ```tsx * import { getUserQueryOptions } from '@openfort/react' * import { useQuery } from '@tanstack/react-query' * import type { Openfort } from '@openfort/openfort-js' * * export function useCurrentUser(client: Openfort) { * return useQuery(getUserQueryOptions(client)) * } * ``` */ export declare function getUserQueryOptions(client: Openfort): UserQueryOptions; /** * Query options for the user's embedded wallet accounts. * * Shares its key and fetcher with the provider, which publishes every account * list it loads to this cache entry. * * @example * ```tsx * import { getEmbeddedAccountsQueryOptions } from '@openfort/react' * import { useQuery } from '@tanstack/react-query' * import type { Openfort } from '@openfort/openfort-js' * * export function useEmbeddedAccounts(client: Openfort) { * return useQuery(getEmbeddedAccountsQueryOptions(client)) * } * ``` */ export declare function getEmbeddedAccountsQueryOptions(client: Openfort): EmbeddedAccountsQueryOptions; type WalletAssetsChainConfig = { chainId: number; assets: readonly string[]; rpcUrl?: string; }; /** * Key and enablement for an Ethereum wallet-assets query. * * Assets can only be read once an address is known, and — outside multi-chain * mode — once the chain is known too, so both are required rather than asserted. */ export declare function getWalletAssetsQueryScope(params: { client: object; address: string | undefined; chainId: number | undefined; multiChain: boolean; assets: readonly string[]; hasChain: boolean; backendUrl: string; rpcUrl?: string; assetFilter?: readonly WalletAssetsChainConfig[]; fallbackChains?: readonly WalletAssetsChainConfig[]; }): { queryKey: readonly ["openfort", "walletAssets", ...Omit[]]; enabled: boolean; }; export {};