UNPKG

@pod-protocol/sdk

Version:

TypeScript SDK for PoD Protocol - AI agent communication on Solana

185 lines 5.74 kB
/** * Account size constants for PoD Protocol program accounts * Used for efficient filtering in getProgramAccounts calls */ /** * Standard Solana account overhead */ export declare const ACCOUNT_OVERHEAD = 8; /** * Standard field sizes in bytes */ export declare const FIELD_SIZES: { readonly PUBKEY: 32; readonly U64: 8; readonly U32: 4; readonly U16: 2; readonly U8: 1; readonly BOOL: 1; readonly BUMP: 1; readonly STRING_PREFIX: 4; readonly VEC_PREFIX: 4; readonly OPTION: 1; }; /** * Variable field size limits (for capacity planning) */ export declare const VARIABLE_LIMITS: { readonly AGENT_METADATA_URI: 200; readonly AGENT_NAME: 64; readonly CHANNEL_NAME: 64; readonly CHANNEL_DESCRIPTION: 256; readonly MESSAGE_PAYLOAD: 1024; readonly MESSAGE_PAYLOAD_HASH: 32; readonly INVITE_MESSAGE: 256; }; /** * Calculate agent account size * Fields: capabilities (u64), metadata_uri (String), reputation (u64), * last_updated (u64), invites_sent (u64), last_invite_at (u64), bump (u8) */ export declare const AGENT_ACCOUNT_SIZE: number; /** * Calculate message account size * Fields: sender (Pubkey), recipient (Pubkey), payload (String), payload_hash (bytes), * message_type (enum), status (enum), timestamp (u64), created_at (u64), expires_at (u64), bump (u8) */ export declare const MESSAGE_ACCOUNT_SIZE: number; /** * Calculate channel account size * Fields: creator (Pubkey), name (String), description (String), visibility (enum), * current_participants (u32), max_participants (u32), fee_per_message (u64), * escrow_balance (u64), created_at (u64), last_updated (u64), bump (u8) */ export declare const CHANNEL_ACCOUNT_SIZE: number; /** * Calculate participant account size * Fields: channel (Pubkey), agent (Pubkey), role (enum), joined_at (u64), * permissions (u64), bump (u8) */ export declare const PARTICIPANT_ACCOUNT_SIZE: number; /** * Calculate invitation account size * Fields: channel (Pubkey), inviter (Pubkey), invitee (Pubkey), * message (String), created_at (u64), expires_at (u64), bump (u8) */ export declare const INVITATION_ACCOUNT_SIZE: number; /** * Calculate escrow account size * Fields: channel (Pubkey), creator (Pubkey), balance (u64), * created_at (u64), bump (u8) */ export declare const ESCROW_ACCOUNT_SIZE: number; /** * Channel message account size (messages within channels) * Fields: channel (Pubkey), sender (Pubkey), content (String), * message_type (enum), timestamp (u64), nonce (u64), bump (u8) */ export declare const CHANNEL_MESSAGE_ACCOUNT_SIZE: number; /** * Account size lookup table */ export declare const ACCOUNT_SIZES: { readonly agentAccount: number; readonly messageAccount: number; readonly channelAccount: number; readonly participantAccount: number; readonly invitationAccount: number; readonly escrowAccount: number; readonly channelMessage: number; }; /** * Account discriminators (8-byte prefixes for different account types) * These are calculated from the account type name using sha256 */ export declare const ACCOUNT_DISCRIMINATORS: { readonly agentAccount: "e7c48c7b8b8e7e7e"; readonly messageAccount: "a1b2c3d4e5f6a7b8"; readonly channelAccount: "c7d8e9f0a1b2c3d4"; readonly participantAccount: "f1e2d3c4b5a69788"; readonly invitationAccount: "9b8a7f6e5d4c3b2a"; readonly escrowAccount: "5f4e3d2c1b0a9f8e"; readonly channelMessage: "8e7d6c5b4a392817"; }; /** * Utility functions for account filtering */ export declare class AccountFilters { /** * Create dataSize filter for specific account type */ static createDataSizeFilter(accountType: keyof typeof ACCOUNT_SIZES): { dataSize: number; }; /** * Create memcmp filter for account discriminator */ static createDiscriminatorFilter(accountType: keyof typeof ACCOUNT_DISCRIMINATORS): { memcmp: { offset: number; bytes: string; }; }; /** * Create memcmp filter for pubkey field at specific offset */ static createPubkeyFilter(offset: number, pubkey: string): { memcmp: { offset: number; bytes: string; }; }; /** * Create combined filters for efficient account fetching */ static createAccountFilters(accountType: keyof typeof ACCOUNT_SIZES, additionalFilters?: Array<{ memcmp: { offset: number; bytes: string; }; }>): Array<{ dataSize?: number; memcmp?: { offset: number; bytes: string; }; }>; /** * Calculate maximum accounts that can be fetched in one call * Based on typical RPC response size limits (10MB) */ static getMaxAccountsPerCall(accountType: keyof typeof ACCOUNT_SIZES): number; /** * Get field offsets for common filtering patterns */ static getFieldOffsets(): { agent: { capabilities: number; reputation: number; }; message: { sender: number; recipient: number; messageType: number; status: number; }; channel: { creator: number; visibility: number; }; participant: { channel: number; agent: number; }; }; } /** * Estimate total data transfer for account fetching operations */ export declare function estimateDataTransfer(accountType: keyof typeof ACCOUNT_SIZES, estimatedCount: number): { accountSize: number; totalSize: number; recommendedBatchSize: number; estimatedCalls: number; }; //# sourceMappingURL=account-sizes.d.ts.map