UNPKG

@j0nnyboi/amman

Version:

A modern mandatory toolbelt to help test solana SDK libraries and apps on a locally running validator.

73 lines (72 loc) 2.9 kB
/// <reference types="node" /> /// <reference types="node" /> import { AccountDiff } from '@j0nnyboi/amman-client'; import { AccountInfo, Connection, Keypair } from '@safecoin/web3.js'; import * as Diff from 'diff'; import EventEmitter from 'events'; import { AmmanAccount } from '../types'; import { AccountProvider } from './providers'; export type { Change } from 'diff'; export declare type AccountState = { account: AmmanAccount | undefined; slot: number; data: Buffer; accountDiff?: AccountDiff; rendered?: string; renderedDiff?: Diff.Change[]; }; declare class AccountStateTracker { readonly states: (AccountState & { timestamp: number; })[]; add(state: AccountState): void; get relayStates(): { slot: number; accountDiff?: AccountDiff | undefined; rendered?: string | undefined; renderedDiff?: Diff.Change[] | undefined; timestamp: number; account: Record<string, any>; }[]; renderDiff(lastState: AccountState | null, state: AccountState): Diff.Change[] | undefined; accountStateForSlot(slot: number): (AccountState & { timestamp: number; }) | undefined; accountDataForSlot(slot: number): Buffer | undefined; } export declare class AccountStates extends EventEmitter { readonly connection: Connection; readonly accountProvider: AccountProvider; readonly loadedAccountInfos: Map<string, AccountInfo<Buffer>>; readonly loadedKeypairs: Map<string, Keypair>; readonly states: Map<string, AccountStateTracker>; readonly keypairs: Map<string, { keypair: Keypair; id: string; }>; private _paused; get paused(): boolean; set paused(val: boolean); private constructor(); update(address: string, slot: number, accountInfo?: AccountInfo<Buffer>): Promise<void>; add(address: string, state: AccountState): void; get(address: string): AccountStateTracker | undefined; accountStateForSlot(address: string, slot: number): (AccountState & { timestamp: number; }) | undefined; accountDataForSlot(address: string, slot: number): Buffer | undefined; allAccountAddresses(): string[]; storeKeypair(id: string, keypair: Keypair): void; labelKeypairs(labels: Record<string, string>): void; get allKeypairs(): Map<string, { keypair: Keypair; id: string; }>; getKeypairById(keypairId: string): Keypair | undefined; getKeypairByAddress(address: string): Keypair | undefined; private _onLog; private static _instance; static get instance(): AccountStates; static createInstance(connection: Connection, accountProvider: AccountProvider, loadedAccountInfos: Map<string, AccountInfo<Buffer>>, loadedKeypairs: Map<string, Keypair>): AccountStates; } export declare function printableAccount(account: Record<string, any>): Record<string, any>;