UNPKG

@macalinao/grill

Version:

Modern Solana development kit for React applications with automatic account batching, caching, and transaction notifications

46 lines 1.78 kB
import type { Account, Address, Decoder, FetchAccountConfig, Simplify } from "gill"; import type { GillUseRpcHook } from "./types.js"; type RpcConfig = Simplify<Omit<FetchAccountConfig, "abortSignal">>; export type UseAccountsInput<TConfig extends RpcConfig = RpcConfig, TDecodedData extends object = Uint8Array> = GillUseRpcHook<TConfig> & { /** * Addresses of the accounts to get the info of. */ addresses: (Address | null | undefined)[]; /** * Account decoder that can decode the account's `data` byte array value. * * Note: if not provided, the account will be returned as a `Uint8Array`. */ decoder?: Decoder<TDecodedData>; }; export type UseAccountsResult<TDecodedData extends object> = { isLoading: true; data: (Account<TDecodedData> | null | undefined)[]; addresses: (Address | null | undefined)[]; } | { isLoading: false; data: (Account<TDecodedData> | null)[]; addresses: (Address | null | undefined)[]; }; /** * Get account info for multiple addresses with automatic batching via DataLoader. * Concurrent queries are automatically batched into a single RPC call. * * @example * ```tsx * const tokenAccounts = useAccounts({ * addresses: [tokenAccount1, tokenAccount2, tokenAccount3], * decoder: tokenAccountDecoder, * }); * * // Access individual results * tokenAccounts.forEach((result, index) => { * if (result.data) { * console.log(`Account ${index}:`, result.data); * } * }); * ``` */ export declare function useAccounts<TConfig extends RpcConfig = RpcConfig, TDecodedData extends object = Uint8Array>({ options, addresses, decoder, }: UseAccountsInput<TConfig, TDecodedData>): UseAccountsResult<TDecodedData>; export {}; //# sourceMappingURL=use-accounts.d.ts.map