UNPKG

@saberhq/sail

Version:

Account caching and batched loading for React-based Solana applications.

38 lines 2.06 kB
import type { ProgramAccount } from "@project-serum/anchor"; import type { Network } from "@saberhq/solana-contrib"; import type { PublicKey } from "@solana/web3.js"; import type { UseQueryOptions, UseQueryResult } from "react-query"; import type { FetchKeysFn } from ".."; import type { ProgramAccountParser } from "./programAccounts"; /** * Result of a parsed account query. */ export declare type ParsedAccountQueryResult<T> = UseQueryResult<ProgramAccount<T> | null | undefined>; /** * Parses accounts with the given parser. * * *NOTE: the reference to the accounts array is not memoized.* * * @param keys * @param parser * @returns */ export declare const useParsedAccounts: <T>(keys: (PublicKey | null | undefined)[], parser: ProgramAccountParser<T>, options?: Omit<UseQueryOptions<ProgramAccount<T> | null | undefined, unknown, ProgramAccount<T> | null | undefined, import("react-query").QueryKey>, "queryKey" | "queryFn">) => ParsedAccountQueryResult<T>[]; /** * Makes the query to fetch a parsed account. * @param key * @param fetchKeys * @param parser * @param options * @returns */ export declare const makeParsedAccountQuery: <T>(key: PublicKey | null | undefined, network: Network, fetchKeys: FetchKeysFn, parser: ProgramAccountParser<T>, options?: Omit<UseQueryOptions<ProgramAccount<T> | null | undefined, unknown, ProgramAccount<T> | null | undefined, import("react-query").QueryKey>, "queryKey" | "queryFn">) => UseQueryOptions<ProgramAccount<T> | null | undefined, unknown, ProgramAccount<T> | null | undefined, import("react-query").QueryKey>; /** * Fetches and parses a single account with the given parser. * * @param keys * @param parser * @returns */ export declare const useParsedAccount: <T>(key: PublicKey | null | undefined, parser: ProgramAccountParser<T>, options?: Omit<UseQueryOptions<ProgramAccount<T> | null | undefined, unknown, ProgramAccount<T> | null | undefined, import("react-query").QueryKey>, "queryKey" | "queryFn">) => ParsedAccountQueryResult<T>; //# sourceMappingURL=useParsedAccount.d.ts.map