UNPKG

@wuwei-labs/srsly

Version:
78 lines 2.7 kB
/** * @purpose Thread account utilities for SRSLY * * Fetches Antegen thread state data. The thread type moved from a Codama * account to a plain type after the Anchor upgrade, so we manually fetch * and decode using the generated codec. */ import { type Address } from '@solana/kit'; import { type Thread } from '../generated/codama/types/thread'; /** * Fetch and decode a raw Antegen thread account by its direct address. * * Used internally by instruction wrappers that already know the thread address. * * @param threadAddress - Direct address of the thread account * @param rpcUrl - Optional RPC URL override * @returns Decoded thread data */ export declare function fetchThreadByAddress(threadAddress: Address | string, rpcUrl?: string): Promise<{ address: Address; data: Thread; }>; /** * Fetch and decode an Antegen thread account by contract address. * * Looks up the contract's `thread` field, then fetches and decodes the * thread account. Returns null if no thread is configured on the contract. * * @param contractAddress - Address of the rental contract * @param rpcUrl - Optional RPC URL override * @returns Decoded thread data, or null if no thread configured */ export declare function fetchThread(contractAddress: Address | string, rpcUrl?: string): Promise<{ address: Address; data: Thread; } | null>; /** Decoded account from a decompiled instruction */ export interface DecompiledAccount { address: string; isSigner: boolean; isWritable: boolean; } /** Decompiled instruction from a fiber */ export interface DecompiledInstruction { programId: string; accounts: DecompiledAccount[]; data: string; } /** Decoded FiberState */ export interface FiberState { thread: string; compiledInstruction: DecompiledInstruction[]; numUniqueAccounts: number; lastExecuted: number; execCount: number; priorityFee: number; } /** * Fetch and decode a FiberState account by its direct address. */ export declare function fetchFiberByAddress(fiberAddress: Address | string, rpcUrl?: string): Promise<{ address: Address; data: FiberState; }>; /** * Fetch and decode a FiberState by contract address and fiber index. * * Looks up the contract's thread, derives the fiber PDA, then fetches + decodes. * * @param contractAddress - Address of the rental contract * @param fiberIndex - Fiber index (0=controller, 1=close_rental, 2=activate_rental) * @param rpcUrl - Optional RPC URL override */ export declare function fetchFiber(contractAddress: Address | string, fiberIndex: number, rpcUrl?: string): Promise<{ address: Address; data: FiberState; }>; //# sourceMappingURL=thread.d.ts.map