@saberhq/sail
Version:
Account caching and batched loading for React-based Solana applications.
45 lines • 1.24 kB
TypeScript
/// <reference types="node" />
import type { AccountParsers } from "@saberhq/anchor-contrib";
import type { PublicKey } from "@solana/web3.js";
import type { ParsedAccountDatum } from "../types";
/**
* A parser for program-owned accounts.
*/
export declare type ProgramAccountParser<T> = {
/**
* ID of the program.
*/
programID: PublicKey;
/**
* Name of the account.
*/
name: string;
/**
* Function which parses the account.
*/
parse: (data: Buffer) => T;
};
export interface ProgramAccountParsers<M> {
/**
* Program address.
*/
address: PublicKey;
/**
* Parsers.
*/
accountParsers: AccountParsers<M>;
}
/**
* Makes program account parsers.
* @param parsers
* @returns
*/
export declare const makeProgramAccountParsers: <M, A extends keyof M>({ address, accountParsers, }: ProgramAccountParsers<M>) => { [K in A]: ProgramAccountParser<M[K]>; };
export declare type ParserHooks<T> = {
useSingleData: (key: PublicKey | null | undefined) => {
loading: boolean;
data: ParsedAccountDatum<T>;
};
useData: (keys: (PublicKey | null | undefined)[]) => ParsedAccountDatum<T>[];
};
//# sourceMappingURL=programAccounts.d.ts.map