@saberhq/sail
Version:
Account caching and batched loading for React-based Solana applications.
35 lines • 1.33 kB
TypeScript
import type { AccountParsers } from "@saberhq/anchor-contrib";
import type { KeyedAccountInfo, PublicKey } from "@solana/web3.js";
import type { ParserHooks } from "..";
import type { ParsedAccountDatum } from "../types";
export declare type AccountParser<T> = (info: KeyedAccountInfo) => T;
/**
* Makes account parsers from a coder.
* @param parsers
* @returns
*/
export declare const makeParsersFromCoder: <M>(parsers: AccountParsers<M>) => AccountParsers<M> extends infer T extends object ? { [P in keyof T]: (info: KeyedAccountInfo) => M[keyof M]; } : never;
/**
* Makes hooks for parsers.
* @param parsers
* @returns
*/
export declare const makeParserHooks: <M>(parsers: AccountParsers<M>) => { [K in keyof M]: ParserHooks<M[K]>; };
/**
* Parses accounts with the given parser.
*
* @deprecated use {@link useBatchedParsedAccounts} instead
* @param keys
* @param parser
* @returns
*/
export declare const useParsedAccountsData: <T>(keys: (PublicKey | null | undefined)[], parser: AccountParser<T>) => ParsedAccountDatum<T>[];
/**
* Loads the parsed data of a single account.
* @returns
*/
export declare const useParsedAccountData: <T>(key: PublicKey | null | undefined, parser: AccountParser<T>) => {
loading: boolean;
data: ParsedAccountDatum<T>;
};
//# sourceMappingURL=useParsedAccountsData.d.ts.map