/** * @module vault * @description Encrypted memory vault — init, session management, inscribe, * delegate access, nonce rotation, and close operations. * * Vaults provide encrypted, session-scoped memory storage for agents, * with support for epoch-based pagination and hot-wallet delegation. * * @category Modules * @since v0.1.0 * @packageDocumentation */ import { type PublicKey, type TransactionSignature } from "@solana/web3.js"; import { BaseModule } from "./base"; import type { MemoryVaultData, SessionLedgerData, EpochPageData, VaultDelegateData, InscribeMemoryArgs, CompactInscribeArgs } from "../types"; /** * @name VaultModule * @description Manages encrypted memory vaults for the Synapse Agent Protocol. * Provides methods to initialise vaults, open/close sessions, inscribe * encrypted data, manage delegates (hot wallets), rotate nonces, and * fetch all related account types. * * @category Modules * @since v0.1.0 * @extends BaseModule * * @example * ```ts * const sap = new SapClient(provider); * // Initialize a vault * await sap.vault.initVault([...nonce]); * // Open a session and inscribe data * await sap.vault.openSession([...sessionHash]); * ``` */ export declare class VaultModule extends BaseModule { /** * @name deriveVault * @description Derive the `MemoryVault` PDA for a given agent. * @param agentPda - The agent account PDA. * @returns A tuple of `[PublicKey, bump]` for the vault PDA. * @see {@link deriveVault} from `pda/` module for the underlying derivation. * @since v0.1.0 */ deriveVault(agentPda: PublicKey): readonly [PublicKey, number]; /** * @name deriveSession * @description Derive the `SessionLedger` PDA for a given vault and session hash. * @param vaultPda - The memory vault PDA. * @param sessionHash - A unique session identifier (32 bytes). * @returns A tuple of `[PublicKey, bump]` for the session PDA. * @see {@link deriveSession} from `pda/` module for the underlying derivation. * @since v0.1.0 */ deriveSession(vaultPda: PublicKey, sessionHash: Uint8Array): readonly [PublicKey, number]; /** * @name initVault * @description Initialize an encrypted memory vault for the caller's agent. * Creates the `MemoryVault` PDA and sets the initial encryption nonce. * @param vaultNonce - The initial encryption nonce (byte array). * @returns {Promise} The transaction signature. * @since v0.1.0 */ initVault(vaultNonce: number[]): Promise; /** * @name openSession * @description Open a new session within a vault. Creates a `SessionLedger` * PDA identified by the session hash. * @param sessionHash - A unique session identifier (byte array). * @returns {Promise} The transaction signature. * @since v0.1.0 */ openSession(sessionHash: number[]): Promise; /** * @name inscribe * @description Inscribe encrypted data into the transaction log. * Account resolution is handled by Anchor via remaining accounts. * @param args - Inscription parameters (sequence, encrypted data, nonce, content hash, fragments, compression, epoch). * @returns {Promise} The transaction signature. * @since v0.1.0 */ inscribe(args: InscribeMemoryArgs): Promise; /** * @name inscribeWithAccounts * @description Full inscribe with explicit session and epoch page PDAs. * Use this when you need manual control over account resolution. * @param sessionPda - The session ledger PDA. * @param epochPagePda - The epoch page PDA for the target epoch. * @param vaultPda - The memory vault PDA. * @param args - Inscription parameters. * @returns {Promise} The transaction signature. * @since v0.1.0 */ inscribeWithAccounts(sessionPda: PublicKey, epochPagePda: PublicKey, vaultPda: PublicKey, args: InscribeMemoryArgs): Promise; /** * @name compactInscribe * @description Simplified inscription (4 args vs 8) for single-fragment writes. * @param sessionPda - The session ledger PDA. * @param vaultPda - The memory vault PDA. * @param args - Compact inscription parameters (sequence, encrypted data, nonce, content hash). * @returns {Promise} The transaction signature. * @since v0.1.0 */ compactInscribe(sessionPda: PublicKey, vaultPda: PublicKey, args: CompactInscribeArgs): Promise; /** * @name closeSession * @description Close a session — no more inscriptions will be allowed. * @param vaultPda - The memory vault PDA. * @param sessionPda - The session ledger PDA to close. * @returns {Promise} The transaction signature. * @since v0.1.0 */ closeSession(vaultPda: PublicKey, sessionPda: PublicKey): Promise; /** * @name closeVault * @description Close the `MemoryVault` PDA and reclaim rent to the owner wallet. * @returns {Promise} The transaction signature. * @since v0.1.0 */ closeVault(): Promise; /** * @name closeSessionPda * @description Close a `SessionLedger` PDA (session must be closed first). * Reclaims rent to the owner wallet. * @param vaultPda - The memory vault PDA. * @param sessionPda - The session ledger PDA to close. * @returns {Promise} The transaction signature. * @since v0.1.0 */ closeSessionPda(vaultPda: PublicKey, sessionPda: PublicKey): Promise; /** * @name closeEpochPage * @description Close an `EpochPage` PDA and reclaim rent. * @param sessionPda - The session ledger PDA that owns this epoch page. * @param epochIndex - The zero-based epoch index. * @returns {Promise} The transaction signature. * @since v0.1.0 */ closeEpochPage(sessionPda: PublicKey, epochIndex: number): Promise; /** * @name rotateNonce * @description Rotate the vault encryption nonce. All future inscriptions * will use the new nonce. * @param newNonce - The replacement nonce (byte array). * @returns {Promise} The transaction signature. * @since v0.1.0 */ rotateNonce(newNonce: number[]): Promise; /** * @name addDelegate * @description Authorize a delegate (hot wallet) for vault operations. * Creates a `VaultDelegate` PDA with the specified permissions and expiry. * @param delegatePubkey - The public key of the delegate wallet to authorize. * @param permissions - Bitmask of permitted operations. * @param expiresAt - Unix timestamp when delegation expires. * @returns {Promise} The transaction signature. * @since v0.1.0 */ addDelegate(delegatePubkey: PublicKey, permissions: number, expiresAt: number | bigint): Promise; /** * @name revokeDelegate * @description Revoke a delegate’s authorization, closing their `VaultDelegate` PDA. * @param delegatePubkey - The public key of the delegate wallet to revoke. * @returns {Promise} The transaction signature. * @since v0.1.0 */ revokeDelegate(delegatePubkey: PublicKey): Promise; /** * @name inscribeDelegated * @description Inscribe data via an authorized delegate (hot wallet). * The transaction is signed by the delegate instead of the vault owner. * @param delegateWallet - The delegate wallet public key. * @param vaultPda - The memory vault PDA. * @param sessionPda - The session ledger PDA. * @param epochPagePda - The epoch page PDA. * @param args - Inscription parameters. * @returns {Promise} The transaction signature. * @since v0.1.0 */ inscribeDelegated(delegateWallet: PublicKey, vaultPda: PublicKey, sessionPda: PublicKey, epochPagePda: PublicKey, args: InscribeMemoryArgs): Promise; /** * @name fetchVault * @description Fetch a deserialized `MemoryVault` account. * @param agentPda - The agent account PDA. * @returns {Promise} The vault account data. * @throws Will throw if the vault account does not exist. * @since v0.1.0 */ fetchVault(agentPda: PublicKey): Promise; /** * @name fetchVaultNullable * @description Fetch a deserialized `MemoryVault` account, or `null` * if it does not exist on-chain. * @param agentPda - The agent account PDA. * @returns {Promise} The vault data or `null`. * @since v0.1.0 */ fetchVaultNullable(agentPda: PublicKey): Promise; /** * @name fetchSession * @description Fetch a deserialized `SessionLedger` account by vault and session hash. * @param vaultPda - The memory vault PDA. * @param sessionHash - The session identifier used during creation. * @returns {Promise} The session ledger data. * @throws Will throw if the session does not exist. * @since v0.1.0 */ fetchSession(vaultPda: PublicKey, sessionHash: Uint8Array): Promise; /** * @name fetchSessionByPda * @description Fetch a deserialized `SessionLedger` account by its PDA directly, * bypassing PDA derivation. * @param sessionPda - The session ledger PDA. * @returns {Promise} The session ledger data. * @throws Will throw if the session does not exist. * @since v0.1.0 */ fetchSessionByPda(sessionPda: PublicKey): Promise; /** * @name fetchEpochPage * @description Fetch a deserialized `EpochPage` account. * @param sessionPda - The session ledger PDA. * @param epochIndex - The zero-based epoch index. * @returns {Promise} The epoch page data. * @throws Will throw if the epoch page does not exist. * @since v0.1.0 */ fetchEpochPage(sessionPda: PublicKey, epochIndex: number): Promise; /** * @name fetchDelegate * @description Fetch a deserialized `VaultDelegate` account. * @param vaultPda - The memory vault PDA. * @param delegatePubkey - The delegate wallet public key. * @returns {Promise} The delegate account data. * @throws Will throw if the delegate does not exist. * @since v0.1.0 */ fetchDelegate(vaultPda: PublicKey, delegatePubkey: PublicKey): Promise; } //# sourceMappingURL=vault.d.ts.map