UNPKG

@wuwei-labs/srsly

Version:
53 lines 1.78 kB
/** * @purpose Contract account utilities for SRSLY * * Fetches contract state data from the SRSLY program. */ import { type Address } from '@solana/kit'; import { type ContractState } from '../generated/codama/accounts'; /** * Fetch contract state from the SRSLY program * * @param contractAddress - Contract account address * @param rpcUrl - Optional RPC endpoint URL. If not provided, uses RPC from global config * @returns Contract state with fleet, gameId, ownerProfile, etc. * @throws Error if contract account not found or fetch fails * * @example * ```typescript * // Uses RPC URL from global config * const contract = await fetchContract('ContractAddress...'); * console.log(contract.data.fleet, contract.data.gameId); * * // Uses specific RPC URL * const contract2 = await fetchContract( * 'ContractAddress...', * 'https://api.devnet.solana.com' * ); * console.log('Rate:', contract2.data.rate); * ``` */ export declare function fetchContract(contractAddress: Address | string, rpcUrl?: string): Promise<{ data: ContractState; address: Address; }>; /** * Fetch all contract state accounts from the SRSLY program * * Uses getProgramAccounts with a discriminator filter to find all ContractState accounts. * * @param rpcUrl - Optional RPC endpoint URL. If not provided, uses RPC from global config * @returns Array of contract states with their addresses * * @example * ```typescript * const contracts = await fetchAllContracts(); * console.log(`Found ${contracts.length} contracts`); * contracts.forEach(c => console.log(c.address, c.data.fleet)); * ``` */ export declare function fetchAllContracts(rpcUrl?: string): Promise<Array<{ data: ContractState; address: Address; }>>; //# sourceMappingURL=contract.d.ts.map