UNPKG

@drift-labs/sdk-browser

Version:
67 lines (66 loc) 2.38 kB
import { DriftClient } from '../driftClient'; import { RevenueShareEscrowAccount } from '../types'; export declare class RevenueShareEscrowMap { /** * map from authority pubkey to RevenueShareEscrow account data. */ private authorityEscrowMap; private driftClient; private parallelSync; private fetchPromise?; private fetchPromiseResolver; /** * Creates a new RevenueShareEscrowMap instance. * * @param {DriftClient} driftClient - The DriftClient instance. * @param {boolean} parallelSync - Whether to sync accounts in parallel. */ constructor(driftClient: DriftClient, parallelSync?: boolean); /** * Subscribe to all RevenueShareEscrow accounts. */ subscribe(): Promise<void>; has(authorityPublicKey: string): boolean; get(authorityPublicKey: string): RevenueShareEscrowAccount | undefined; /** * Enforce that a RevenueShareEscrow will exist for the given authorityPublicKey, * reading one from the blockchain if necessary. * @param authorityPublicKey * @returns */ mustGet(authorityPublicKey: string): Promise<RevenueShareEscrowAccount | undefined>; addRevenueShareEscrow(authority: string): Promise<void>; size(): number; sync(): Promise<void>; /** * A slow, bankrun test friendly version of sync(), uses getAccountInfo on every cached account to refresh data * @returns */ slowSync(): Promise<void>; syncAll(): Promise<void>; /** * Get all RevenueShareEscrow accounts */ getAll(): Map<string, RevenueShareEscrowAccount>; /** * Get all authorities that have RevenueShareEscrow accounts */ getAuthorities(): string[]; /** * Get RevenueShareEscrow accounts that have approved referrers */ getEscrowsWithApprovedReferrers(): Map<string, RevenueShareEscrowAccount>; /** * Get RevenueShareEscrow accounts that have active orders */ getEscrowsWithOrders(): Map<string, RevenueShareEscrowAccount>; /** * Get RevenueShareEscrow account by referrer */ getByReferrer(referrerPublicKey: string): RevenueShareEscrowAccount | undefined; /** * Get all RevenueShareEscrow accounts for a specific referrer */ getAllByReferrer(referrerPublicKey: string): RevenueShareEscrowAccount[]; unsubscribe(): Promise<void>; }