@oobe-protocol-labs/synapse-sap-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +882 -0
- package/dist/cjs/constants/index.js +43 -0
- package/dist/cjs/constants/index.js.map +1 -0
- package/dist/cjs/constants/limits.js +161 -0
- package/dist/cjs/constants/limits.js.map +1 -0
- package/dist/cjs/constants/programs.js +78 -0
- package/dist/cjs/constants/programs.js.map +1 -0
- package/dist/cjs/constants/seeds.js +57 -0
- package/dist/cjs/constants/seeds.js.map +1 -0
- package/dist/cjs/core/client.js +391 -0
- package/dist/cjs/core/client.js.map +1 -0
- package/dist/cjs/core/connection.js +319 -0
- package/dist/cjs/core/connection.js.map +1 -0
- package/dist/cjs/core/index.js +24 -0
- package/dist/cjs/core/index.js.map +1 -0
- package/dist/cjs/errors/index.js +334 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/events/index.js +136 -0
- package/dist/cjs/events/index.js.map +1 -0
- package/dist/cjs/idl/index.js +63 -0
- package/dist/cjs/idl/index.js.map +1 -0
- package/dist/cjs/idl/synapse_agent_sap.json +9710 -0
- package/dist/cjs/index.js +147 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/modules/agent.js +272 -0
- package/dist/cjs/modules/agent.js.map +1 -0
- package/dist/cjs/modules/attestation.js +147 -0
- package/dist/cjs/modules/attestation.js.map +1 -0
- package/dist/cjs/modules/base.js +128 -0
- package/dist/cjs/modules/base.js.map +1 -0
- package/dist/cjs/modules/escrow.js +246 -0
- package/dist/cjs/modules/escrow.js.map +1 -0
- package/dist/cjs/modules/feedback.js +166 -0
- package/dist/cjs/modules/feedback.js.map +1 -0
- package/dist/cjs/modules/index.js +35 -0
- package/dist/cjs/modules/index.js.map +1 -0
- package/dist/cjs/modules/indexing.js +375 -0
- package/dist/cjs/modules/indexing.js.map +1 -0
- package/dist/cjs/modules/ledger.js +234 -0
- package/dist/cjs/modules/ledger.js.map +1 -0
- package/dist/cjs/modules/tools.js +319 -0
- package/dist/cjs/modules/tools.js.map +1 -0
- package/dist/cjs/modules/vault.js +410 -0
- package/dist/cjs/modules/vault.js.map +1 -0
- package/dist/cjs/pda/index.js +377 -0
- package/dist/cjs/pda/index.js.map +1 -0
- package/dist/cjs/plugin/index.js +934 -0
- package/dist/cjs/plugin/index.js.map +1 -0
- package/dist/cjs/plugin/protocols.js +282 -0
- package/dist/cjs/plugin/protocols.js.map +1 -0
- package/dist/cjs/plugin/schemas.js +831 -0
- package/dist/cjs/plugin/schemas.js.map +1 -0
- package/dist/cjs/postgres/adapter.js +715 -0
- package/dist/cjs/postgres/adapter.js.map +1 -0
- package/dist/cjs/postgres/index.js +50 -0
- package/dist/cjs/postgres/index.js.map +1 -0
- package/dist/cjs/postgres/serializers.js +381 -0
- package/dist/cjs/postgres/serializers.js.map +1 -0
- package/dist/cjs/postgres/sync.js +221 -0
- package/dist/cjs/postgres/sync.js.map +1 -0
- package/dist/cjs/postgres/types.js +44 -0
- package/dist/cjs/postgres/types.js.map +1 -0
- package/dist/cjs/registries/builder.js +414 -0
- package/dist/cjs/registries/builder.js.map +1 -0
- package/dist/cjs/registries/discovery.js +362 -0
- package/dist/cjs/registries/discovery.js.map +1 -0
- package/dist/cjs/registries/index.js +51 -0
- package/dist/cjs/registries/index.js.map +1 -0
- package/dist/cjs/registries/session.js +433 -0
- package/dist/cjs/registries/session.js.map +1 -0
- package/dist/cjs/registries/x402.js +577 -0
- package/dist/cjs/registries/x402.js.map +1 -0
- package/dist/cjs/types/accounts.js +13 -0
- package/dist/cjs/types/accounts.js.map +1 -0
- package/dist/cjs/types/common.js +13 -0
- package/dist/cjs/types/common.js.map +1 -0
- package/dist/cjs/types/enums.js +174 -0
- package/dist/cjs/types/enums.js.map +1 -0
- package/dist/cjs/types/index.js +36 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/instructions.js +92 -0
- package/dist/cjs/types/instructions.js.map +1 -0
- package/dist/cjs/utils/hash.js +58 -0
- package/dist/cjs/utils/hash.js.map +1 -0
- package/dist/cjs/utils/index.js +27 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/serialization.js +105 -0
- package/dist/cjs/utils/serialization.js.map +1 -0
- package/dist/cjs/utils/validation.js +36 -0
- package/dist/cjs/utils/validation.js.map +1 -0
- package/dist/esm/constants/index.js +29 -0
- package/dist/esm/constants/index.js.map +1 -0
- package/dist/esm/constants/limits.js +158 -0
- package/dist/esm/constants/limits.js.map +1 -0
- package/dist/esm/constants/programs.js +75 -0
- package/dist/esm/constants/programs.js.map +1 -0
- package/dist/esm/constants/seeds.js +54 -0
- package/dist/esm/constants/seeds.js.map +1 -0
- package/dist/esm/core/client.js +384 -0
- package/dist/esm/core/client.js.map +1 -0
- package/dist/esm/core/connection.js +315 -0
- package/dist/esm/core/connection.js.map +1 -0
- package/dist/esm/core/index.js +19 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/errors/index.js +325 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/events/index.js +132 -0
- package/dist/esm/events/index.js.map +1 -0
- package/dist/esm/idl/index.js +57 -0
- package/dist/esm/idl/index.js.map +1 -0
- package/dist/esm/idl/synapse_agent_sap.json +9710 -0
- package/dist/esm/index.js +70 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/modules/agent.js +268 -0
- package/dist/esm/modules/agent.js.map +1 -0
- package/dist/esm/modules/attestation.js +143 -0
- package/dist/esm/modules/attestation.js.map +1 -0
- package/dist/esm/modules/base.js +124 -0
- package/dist/esm/modules/base.js.map +1 -0
- package/dist/esm/modules/escrow.js +242 -0
- package/dist/esm/modules/escrow.js.map +1 -0
- package/dist/esm/modules/feedback.js +162 -0
- package/dist/esm/modules/feedback.js.map +1 -0
- package/dist/esm/modules/index.js +23 -0
- package/dist/esm/modules/index.js.map +1 -0
- package/dist/esm/modules/indexing.js +371 -0
- package/dist/esm/modules/indexing.js.map +1 -0
- package/dist/esm/modules/ledger.js +230 -0
- package/dist/esm/modules/ledger.js.map +1 -0
- package/dist/esm/modules/tools.js +315 -0
- package/dist/esm/modules/tools.js.map +1 -0
- package/dist/esm/modules/vault.js +406 -0
- package/dist/esm/modules/vault.js.map +1 -0
- package/dist/esm/pda/index.js +357 -0
- package/dist/esm/pda/index.js.map +1 -0
- package/dist/esm/plugin/index.js +927 -0
- package/dist/esm/plugin/index.js.map +1 -0
- package/dist/esm/plugin/protocols.js +279 -0
- package/dist/esm/plugin/protocols.js.map +1 -0
- package/dist/esm/plugin/schemas.js +828 -0
- package/dist/esm/plugin/schemas.js.map +1 -0
- package/dist/esm/postgres/adapter.js +678 -0
- package/dist/esm/postgres/adapter.js.map +1 -0
- package/dist/esm/postgres/index.js +27 -0
- package/dist/esm/postgres/index.js.map +1 -0
- package/dist/esm/postgres/serializers.js +362 -0
- package/dist/esm/postgres/serializers.js.map +1 -0
- package/dist/esm/postgres/sync.js +217 -0
- package/dist/esm/postgres/sync.js.map +1 -0
- package/dist/esm/postgres/types.js +41 -0
- package/dist/esm/postgres/types.js.map +1 -0
- package/dist/esm/registries/builder.js +410 -0
- package/dist/esm/registries/builder.js.map +1 -0
- package/dist/esm/registries/discovery.js +358 -0
- package/dist/esm/registries/discovery.js.map +1 -0
- package/dist/esm/registries/index.js +44 -0
- package/dist/esm/registries/index.js.map +1 -0
- package/dist/esm/registries/session.js +429 -0
- package/dist/esm/registries/session.js.map +1 -0
- package/dist/esm/registries/x402.js +573 -0
- package/dist/esm/registries/x402.js.map +1 -0
- package/dist/esm/types/accounts.js +12 -0
- package/dist/esm/types/accounts.js.map +1 -0
- package/dist/esm/types/common.js +12 -0
- package/dist/esm/types/common.js.map +1 -0
- package/dist/esm/types/enums.js +171 -0
- package/dist/esm/types/enums.js.map +1 -0
- package/dist/esm/types/index.js +25 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/instructions.js +89 -0
- package/dist/esm/types/instructions.js.map +1 -0
- package/dist/esm/utils/hash.js +53 -0
- package/dist/esm/utils/hash.js.map +1 -0
- package/dist/esm/utils/index.js +19 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/serialization.js +98 -0
- package/dist/esm/utils/serialization.js.map +1 -0
- package/dist/esm/utils/validation.js +33 -0
- package/dist/esm/utils/validation.js.map +1 -0
- package/dist/types/constants/index.d.ts +27 -0
- package/dist/types/constants/index.d.ts.map +1 -0
- package/dist/types/constants/limits.d.ts +149 -0
- package/dist/types/constants/limits.d.ts.map +1 -0
- package/dist/types/constants/programs.d.ts +69 -0
- package/dist/types/constants/programs.d.ts.map +1 -0
- package/dist/types/constants/seeds.d.ts +61 -0
- package/dist/types/constants/seeds.d.ts.map +1 -0
- package/dist/types/core/client.d.ts +323 -0
- package/dist/types/core/client.d.ts.map +1 -0
- package/dist/types/core/connection.d.ts +279 -0
- package/dist/types/core/connection.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +20 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +276 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/events/index.d.ts +248 -0
- package/dist/types/events/index.d.ts.map +1 -0
- package/dist/types/idl/index.d.ts +70 -0
- package/dist/types/idl/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +68 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/modules/agent.d.ts +166 -0
- package/dist/types/modules/agent.d.ts.map +1 -0
- package/dist/types/modules/attestation.d.ts +96 -0
- package/dist/types/modules/attestation.d.ts.map +1 -0
- package/dist/types/modules/base.d.ts +126 -0
- package/dist/types/modules/base.d.ts.map +1 -0
- package/dist/types/modules/escrow.d.ts +151 -0
- package/dist/types/modules/escrow.d.ts.map +1 -0
- package/dist/types/modules/feedback.d.ts +105 -0
- package/dist/types/modules/feedback.d.ts.map +1 -0
- package/dist/types/modules/index.d.ts +24 -0
- package/dist/types/modules/index.d.ts.map +1 -0
- package/dist/types/modules/indexing.d.ts +200 -0
- package/dist/types/modules/indexing.d.ts.map +1 -0
- package/dist/types/modules/ledger.d.ts +150 -0
- package/dist/types/modules/ledger.d.ts.map +1 -0
- package/dist/types/modules/tools.d.ts +182 -0
- package/dist/types/modules/tools.d.ts.map +1 -0
- package/dist/types/modules/vault.d.ts +240 -0
- package/dist/types/modules/vault.d.ts.map +1 -0
- package/dist/types/pda/index.d.ts +296 -0
- package/dist/types/pda/index.d.ts.map +1 -0
- package/dist/types/plugin/index.d.ts +171 -0
- package/dist/types/plugin/index.d.ts.map +1 -0
- package/dist/types/plugin/protocols.d.ts +152 -0
- package/dist/types/plugin/protocols.d.ts.map +1 -0
- package/dist/types/plugin/schemas.d.ts +823 -0
- package/dist/types/plugin/schemas.d.ts.map +1 -0
- package/dist/types/postgres/adapter.d.ts +355 -0
- package/dist/types/postgres/adapter.d.ts.map +1 -0
- package/dist/types/postgres/index.d.ts +24 -0
- package/dist/types/postgres/index.d.ts.map +1 -0
- package/dist/types/postgres/serializers.d.ts +30 -0
- package/dist/types/postgres/serializers.d.ts.map +1 -0
- package/dist/types/postgres/sync.d.ts +132 -0
- package/dist/types/postgres/sync.d.ts.map +1 -0
- package/dist/types/postgres/types.d.ts +167 -0
- package/dist/types/postgres/types.d.ts.map +1 -0
- package/dist/types/registries/builder.d.ts +340 -0
- package/dist/types/registries/builder.d.ts.map +1 -0
- package/dist/types/registries/discovery.d.ts +333 -0
- package/dist/types/registries/discovery.d.ts.map +1 -0
- package/dist/types/registries/index.d.ts +48 -0
- package/dist/types/registries/index.d.ts.map +1 -0
- package/dist/types/registries/session.d.ts +323 -0
- package/dist/types/registries/session.d.ts.map +1 -0
- package/dist/types/registries/x402.d.ts +463 -0
- package/dist/types/registries/x402.d.ts.map +1 -0
- package/dist/types/types/accounts.d.ts +565 -0
- package/dist/types/types/accounts.d.ts.map +1 -0
- package/dist/types/types/common.d.ts +166 -0
- package/dist/types/types/common.d.ts.map +1 -0
- package/dist/types/types/enums.d.ts +238 -0
- package/dist/types/types/enums.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +28 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/instructions.d.ts +366 -0
- package/dist/types/types/instructions.d.ts.map +1 -0
- package/dist/types/utils/hash.d.ts +48 -0
- package/dist/types/utils/hash.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +19 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/serialization.d.ts +69 -0
- package/dist/types/utils/serialization.d.ts.map +1 -0
- package/dist/types/utils/validation.d.ts +29 -0
- package/dist/types/utils/validation.d.ts.map +1 -0
- package/package.json +178 -0
- package/src/constants/index.ts +44 -0
- package/src/constants/limits.ts +165 -0
- package/src/constants/programs.ts +83 -0
- package/src/constants/seeds.ts +66 -0
- package/src/core/client.ts +416 -0
- package/src/core/connection.ts +409 -0
- package/src/core/index.ts +20 -0
- package/src/errors/index.ts +346 -0
- package/src/events/index.ts +335 -0
- package/src/idl/index.ts +76 -0
- package/src/idl/synapse_agent_sap.json +9710 -0
- package/src/index.ts +253 -0
- package/src/modules/agent.ts +319 -0
- package/src/modules/attestation.ts +168 -0
- package/src/modules/base.ts +158 -0
- package/src/modules/escrow.ts +308 -0
- package/src/modules/feedback.ts +186 -0
- package/src/modules/index.ts +24 -0
- package/src/modules/indexing.ts +444 -0
- package/src/modules/ledger.ts +262 -0
- package/src/modules/tools.ts +411 -0
- package/src/modules/vault.ts +533 -0
- package/src/pda/index.ts +512 -0
- package/src/plugin/index.ts +1202 -0
- package/src/plugin/protocols.ts +404 -0
- package/src/plugin/schemas.ts +909 -0
- package/src/postgres/adapter.ts +904 -0
- package/src/postgres/index.ts +59 -0
- package/src/postgres/schema.sql +683 -0
- package/src/postgres/serializers.ts +485 -0
- package/src/postgres/sync.ts +254 -0
- package/src/postgres/types.ts +245 -0
- package/src/registries/builder.ts +607 -0
- package/src/registries/discovery.ts +572 -0
- package/src/registries/index.ts +77 -0
- package/src/registries/session.ts +613 -0
- package/src/registries/x402.ts +906 -0
- package/src/types/accounts.ts +618 -0
- package/src/types/common.ts +187 -0
- package/src/types/enums.ts +214 -0
- package/src/types/index.ts +92 -0
- package/src/types/instructions.ts +413 -0
- package/src/utils/hash.ts +57 -0
- package/src/utils/index.ts +19 -0
- package/src/utils/serialization.ts +98 -0
- package/src/utils/validation.ts +36 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ledger
|
|
3
|
+
* @description Unified on-chain memory — init, write, seal, and close ledger.
|
|
4
|
+
*
|
|
5
|
+
* The recommended memory system: fixed-cost PDA with 4 KB ring buffer,
|
|
6
|
+
* automatic TX log persistence, and rolling merkle proof.
|
|
7
|
+
* Write cost is TX fee only (~0.000005 SOL). ZERO additional rent.
|
|
8
|
+
*
|
|
9
|
+
* @category Modules
|
|
10
|
+
* @since v0.1.0
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { type PublicKey, type TransactionSignature } from "@solana/web3.js";
|
|
14
|
+
import { BaseModule } from "./base";
|
|
15
|
+
import type { MemoryLedgerData, LedgerPageData } from "../types";
|
|
16
|
+
/**
|
|
17
|
+
* @name LedgerModule
|
|
18
|
+
* @description Manage on-chain memory ledgers for sessions.
|
|
19
|
+
* Each session can have one MemoryLedger PDA with a 4KB ring buffer for recent entries.
|
|
20
|
+
* When the ring buffer fills, it can be sealed into a permanent LedgerPage.
|
|
21
|
+
* Ledgers are designed for high-frequency writes with minimal cost (~0.000005 SOL per write).
|
|
22
|
+
* Sealed pages are immutable and stored on-chain (~0.031 SOL per page).
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @name LedgerModule
|
|
26
|
+
* @description Manages the unified on-chain memory ledger for the Solana Agent
|
|
27
|
+
* Protocol. Provides methods to initialise a ledger with a 4 KB ring buffer,
|
|
28
|
+
* write data (TX fee only), seal pages permanently, close ledgers, and
|
|
29
|
+
* decode ring buffer contents.
|
|
30
|
+
*
|
|
31
|
+
* @category Modules
|
|
32
|
+
* @since v0.1.0
|
|
33
|
+
* @extends BaseModule
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const sap = new SapClient(provider);
|
|
38
|
+
* // Init ledger, write data, seal
|
|
39
|
+
* await sap.ledger.init(sessionPda);
|
|
40
|
+
* await sap.ledger.write(sessionPda, data, contentHash);
|
|
41
|
+
* await sap.ledger.seal(sessionPda);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare class LedgerModule extends BaseModule {
|
|
45
|
+
/**
|
|
46
|
+
* @name deriveLedger
|
|
47
|
+
* @description Derive the `MemoryLedger` PDA for a given session.
|
|
48
|
+
* @param sessionPda - The session ledger PDA.
|
|
49
|
+
* @returns A tuple of `[PublicKey, bump]` for the ledger PDA.
|
|
50
|
+
* @see {@link deriveLedger} from `pda/` module for the underlying derivation.
|
|
51
|
+
* @since v0.1.0
|
|
52
|
+
*/
|
|
53
|
+
deriveLedger(sessionPda: PublicKey): readonly [PublicKey, number];
|
|
54
|
+
/**
|
|
55
|
+
* @name deriveLedgerPage
|
|
56
|
+
* @description Derive a `LedgerPage` PDA for a given ledger and page index.
|
|
57
|
+
* @param ledgerPda - The memory ledger PDA.
|
|
58
|
+
* @param pageIndex - The zero-based page index.
|
|
59
|
+
* @returns A tuple of `[PublicKey, bump]` for the page PDA.
|
|
60
|
+
* @see {@link deriveLedgerPage} from `pda/` module for the underlying derivation.
|
|
61
|
+
* @since v0.1.0
|
|
62
|
+
*/
|
|
63
|
+
deriveLedgerPage(ledgerPda: PublicKey, pageIndex: number): readonly [PublicKey, number];
|
|
64
|
+
/**
|
|
65
|
+
* @name init
|
|
66
|
+
* @description Create a `MemoryLedger` with a 4 KB ring buffer (~0.032 SOL rent).
|
|
67
|
+
* @param sessionPda - The session ledger PDA to attach the ledger to.
|
|
68
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
69
|
+
* @since v0.1.0
|
|
70
|
+
*/
|
|
71
|
+
init(sessionPda: PublicKey): Promise<TransactionSignature>;
|
|
72
|
+
/**
|
|
73
|
+
* @name write
|
|
74
|
+
* @description Write data to the ledger (ring buffer + TX log simultaneously).
|
|
75
|
+
* Cost: TX fee only (~0.000005 SOL). ZERO additional rent.
|
|
76
|
+
* @param sessionPda - The session ledger PDA.
|
|
77
|
+
* @param data - The data payload to write (Buffer or Uint8Array).
|
|
78
|
+
* @param contentHash - A 32-byte SHA-256 content hash for verification.
|
|
79
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
80
|
+
* @since v0.1.0
|
|
81
|
+
*/
|
|
82
|
+
write(sessionPda: PublicKey, data: Buffer | Uint8Array, contentHash: number[]): Promise<TransactionSignature>;
|
|
83
|
+
/**
|
|
84
|
+
* @name seal
|
|
85
|
+
* @description Seal the ring buffer into a permanent `LedgerPage`.
|
|
86
|
+
* Pages are WRITE-ONCE, NEVER-DELETE: ~0.031 SOL per page.
|
|
87
|
+
* Automatically fetches the current page index from the ledger.
|
|
88
|
+
* @param sessionPda - The session ledger PDA.
|
|
89
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
90
|
+
* @since v0.1.0
|
|
91
|
+
*/
|
|
92
|
+
seal(sessionPda: PublicKey): Promise<TransactionSignature>;
|
|
93
|
+
/**
|
|
94
|
+
* @name close
|
|
95
|
+
* @description Close a ledger PDA and reclaim ~0.032 SOL rent.
|
|
96
|
+
* @param sessionPda - The session ledger PDA.
|
|
97
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
98
|
+
* @since v0.1.0
|
|
99
|
+
*/
|
|
100
|
+
close(sessionPda: PublicKey): Promise<TransactionSignature>;
|
|
101
|
+
/**
|
|
102
|
+
* @name fetchLedger
|
|
103
|
+
* @description Fetch a deserialized `MemoryLedger` account.
|
|
104
|
+
* @param sessionPda - The session ledger PDA.
|
|
105
|
+
* @returns {Promise<MemoryLedgerData>} The memory ledger data.
|
|
106
|
+
* @throws Will throw if the ledger does not exist.
|
|
107
|
+
* @since v0.1.0
|
|
108
|
+
*/
|
|
109
|
+
fetchLedger(sessionPda: PublicKey): Promise<MemoryLedgerData>;
|
|
110
|
+
/**
|
|
111
|
+
* @name fetchLedgerNullable
|
|
112
|
+
* @description Fetch a deserialized `MemoryLedger` account, or `null`
|
|
113
|
+
* if it does not exist on-chain.
|
|
114
|
+
* @param sessionPda - The session ledger PDA.
|
|
115
|
+
* @returns {Promise<MemoryLedgerData | null>} The ledger data or `null`.
|
|
116
|
+
* @since v0.1.0
|
|
117
|
+
*/
|
|
118
|
+
fetchLedgerNullable(sessionPda: PublicKey): Promise<MemoryLedgerData | null>;
|
|
119
|
+
/**
|
|
120
|
+
* @name fetchPage
|
|
121
|
+
* @description Fetch a deserialized sealed `LedgerPage` account.
|
|
122
|
+
* @param ledgerPda - The memory ledger PDA.
|
|
123
|
+
* @param pageIndex - The zero-based page index.
|
|
124
|
+
* @returns {Promise<LedgerPageData>} The ledger page data.
|
|
125
|
+
* @throws Will throw if the page does not exist.
|
|
126
|
+
* @since v0.1.0
|
|
127
|
+
*/
|
|
128
|
+
fetchPage(ledgerPda: PublicKey, pageIndex: number): Promise<LedgerPageData>;
|
|
129
|
+
/**
|
|
130
|
+
* @name fetchPageNullable
|
|
131
|
+
* @description Fetch a deserialized sealed `LedgerPage` account, or `null`
|
|
132
|
+
* if it does not exist on-chain.
|
|
133
|
+
* @param ledgerPda - The memory ledger PDA.
|
|
134
|
+
* @param pageIndex - The zero-based page index.
|
|
135
|
+
* @returns {Promise<LedgerPageData | null>} The page data or `null`.
|
|
136
|
+
* @since v0.1.0
|
|
137
|
+
*/
|
|
138
|
+
fetchPageNullable(ledgerPda: PublicKey, pageIndex: number): Promise<LedgerPageData | null>;
|
|
139
|
+
/**
|
|
140
|
+
* @name decodeRingBuffer
|
|
141
|
+
* @description Decode the ring buffer into individual entries.
|
|
142
|
+
* Each entry is stored as `[u16 LE data_len][data bytes]`.
|
|
143
|
+
* An entry with `data_len === 0` acts as the empty sentinel.
|
|
144
|
+
* @param ring - Raw ring buffer data (byte array or Uint8Array).
|
|
145
|
+
* @returns {Uint8Array[]} Array of decoded data entries.
|
|
146
|
+
* @since v0.1.0
|
|
147
|
+
*/
|
|
148
|
+
decodeRingBuffer(ring: number[] | Uint8Array): Uint8Array[];
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=ledger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../src/modules/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAiB,KAAK,SAAS,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEjE;;;;;;;GAOG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAG1C;;;;;;;OAOG;IACH,YAAY,CAAC,UAAU,EAAE,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAIjE;;;;;;;;OAQG;IACH,gBAAgB,CACd,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,GAChB,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAM/B;;;;;;OAMG;IACG,IAAI,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAchE;;;;;;;;;OASG;IACG,KAAK,CACT,UAAU,EAAE,SAAS,EACrB,IAAI,EAAE,MAAM,GAAG,UAAU,EACzB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,oBAAoB,CAAC;IAahC;;;;;;;;OAQG;IACG,IAAI,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkBhE;;;;;;OAMG;IACG,KAAK,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAejE;;;;;;;OAOG;IACG,WAAW,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAKnE;;;;;;;OAOG;IACG,mBAAmB,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAKlF;;;;;;;;OAQG;IACG,SAAS,CACb,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC;IAK1B;;;;;;;;OAQG;IACG,iBAAiB,CACrB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAKjC;;;;;;;;OAQG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,GAAG,UAAU,EAAE;CAgB5D"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module tools
|
|
3
|
+
* @description Tool schema registry and session checkpoints for the
|
|
4
|
+
* Solana Agent Protocol.
|
|
5
|
+
*
|
|
6
|
+
* Covers: publish, inscribe schema, update, deactivate/reactivate,
|
|
7
|
+
* close, report invocations, and session checkpoint management.
|
|
8
|
+
*
|
|
9
|
+
* @category Modules
|
|
10
|
+
* @since v0.1.0
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { type PublicKey, type TransactionSignature } from "@solana/web3.js";
|
|
14
|
+
import { BaseModule } from "./base";
|
|
15
|
+
import type { ToolDescriptorData, SessionCheckpointData, PublishToolArgs, UpdateToolArgs, InscribeToolSchemaArgs } from "../types";
|
|
16
|
+
/**
|
|
17
|
+
* @name ToolsModule
|
|
18
|
+
* @description Manages tool descriptors and session checkpoints for the
|
|
19
|
+
* Solana Agent Protocol. Provides methods to publish, update, deactivate,
|
|
20
|
+
* reactivate, close, and fetch tool descriptors, as well as inscribe
|
|
21
|
+
* JSON schemas into TX logs and manage session checkpoints.
|
|
22
|
+
*
|
|
23
|
+
* @category Modules
|
|
24
|
+
* @since v0.1.0
|
|
25
|
+
* @extends BaseModule
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const sap = new SapClient(provider);
|
|
30
|
+
* // Publish a tool by name (auto-hashes)
|
|
31
|
+
* const sig = await sap.tools.publishByName(
|
|
32
|
+
* "getWeather", "mcp-v1", "Fetch weather",
|
|
33
|
+
* '{"type":"object"}', '{"type":"object"}',
|
|
34
|
+
* 0, 1, 2, 1, false,
|
|
35
|
+
* );
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class ToolsModule extends BaseModule {
|
|
39
|
+
/**
|
|
40
|
+
* @name deriveTool
|
|
41
|
+
* @description Derive the `ToolDescriptor` PDA for a given agent and tool name.
|
|
42
|
+
* The tool name is SHA-256 hashed internally.
|
|
43
|
+
* @param agentPda - The agent account PDA.
|
|
44
|
+
* @param toolName - The human-readable tool name.
|
|
45
|
+
* @returns A tuple of `[PublicKey, bump]` for the tool PDA.
|
|
46
|
+
* @see {@link deriveTool} from `pda/` module for the underlying derivation.
|
|
47
|
+
* @since v0.1.0
|
|
48
|
+
*/
|
|
49
|
+
deriveTool(agentPda: PublicKey, toolName: string): readonly [PublicKey, number];
|
|
50
|
+
/**
|
|
51
|
+
* @name publish
|
|
52
|
+
* @description Publish a new tool descriptor for an agent using pre-computed
|
|
53
|
+
* hashes. For auto-hashing, prefer {@link publishByName}.
|
|
54
|
+
* @param args - Tool publication parameters (name, hashes, HTTP method, category, params, etc.).
|
|
55
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
56
|
+
* @since v0.1.0
|
|
57
|
+
*/
|
|
58
|
+
publish(args: PublishToolArgs): Promise<TransactionSignature>;
|
|
59
|
+
/**
|
|
60
|
+
* @name publishByName
|
|
61
|
+
* @description Convenience method to publish a tool using string names.
|
|
62
|
+
* All string arguments are automatically SHA-256 hashed.
|
|
63
|
+
* @param toolName - Human-readable tool name.
|
|
64
|
+
* @param protocolId - Protocol identifier (e.g. `"mcp-v1"`).
|
|
65
|
+
* @param description - Tool description text.
|
|
66
|
+
* @param inputSchema - JSON schema string for input validation.
|
|
67
|
+
* @param outputSchema - JSON schema string for output validation.
|
|
68
|
+
* @param httpMethod - Numeric HTTP method enum value.
|
|
69
|
+
* @param category - Numeric tool category enum value.
|
|
70
|
+
* @param paramsCount - Total number of parameters.
|
|
71
|
+
* @param requiredParams - Number of required parameters.
|
|
72
|
+
* @param isCompound - Whether the tool is a compound (multi-step) tool.
|
|
73
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
74
|
+
* @since v0.1.0
|
|
75
|
+
*/
|
|
76
|
+
publishByName(toolName: string, protocolId: string, description: string, inputSchema: string, outputSchema: string, httpMethod: number, category: number, paramsCount: number, requiredParams: number, isCompound: boolean): Promise<TransactionSignature>;
|
|
77
|
+
/**
|
|
78
|
+
* @name inscribeSchema
|
|
79
|
+
* @description Inscribe a full JSON schema into the transaction log (zero rent).
|
|
80
|
+
* The schema is stored as TX log data, not as PDA account data.
|
|
81
|
+
* @param toolName - The human-readable tool name.
|
|
82
|
+
* @param args - Schema inscription parameters (type, data, hash, compression).
|
|
83
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
84
|
+
* @since v0.1.0
|
|
85
|
+
*/
|
|
86
|
+
inscribeSchema(toolName: string, args: InscribeToolSchemaArgs): Promise<TransactionSignature>;
|
|
87
|
+
/**
|
|
88
|
+
* @name update
|
|
89
|
+
* @description Update a tool’s schema hashes and bump its version.
|
|
90
|
+
* All fields are optional — only non-null values are written.
|
|
91
|
+
* @param toolName - The human-readable tool name.
|
|
92
|
+
* @param args - Partial update parameters (hashes, method, category, params).
|
|
93
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
94
|
+
* @since v0.1.0
|
|
95
|
+
*/
|
|
96
|
+
update(toolName: string, args: UpdateToolArgs): Promise<TransactionSignature>;
|
|
97
|
+
/**
|
|
98
|
+
* @name deactivate
|
|
99
|
+
* @description Deactivate a tool. The tool remains discoverable but is
|
|
100
|
+
* marked as unavailable.
|
|
101
|
+
* @param toolName - The human-readable tool name.
|
|
102
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
103
|
+
* @since v0.1.0
|
|
104
|
+
*/
|
|
105
|
+
deactivate(toolName: string): Promise<TransactionSignature>;
|
|
106
|
+
/**
|
|
107
|
+
* @name reactivate
|
|
108
|
+
* @description Reactivate a previously deactivated tool.
|
|
109
|
+
* @param toolName - The human-readable tool name.
|
|
110
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
111
|
+
* @since v0.1.0
|
|
112
|
+
*/
|
|
113
|
+
reactivate(toolName: string): Promise<TransactionSignature>;
|
|
114
|
+
/**
|
|
115
|
+
* @name close
|
|
116
|
+
* @description Close a tool PDA and reclaim rent to the owner wallet.
|
|
117
|
+
* @param toolName - The human-readable tool name.
|
|
118
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
119
|
+
* @since v0.1.0
|
|
120
|
+
*/
|
|
121
|
+
close(toolName: string): Promise<TransactionSignature>;
|
|
122
|
+
/**
|
|
123
|
+
* @name reportInvocations
|
|
124
|
+
* @description Report tool invocation count. Updates the on-chain counter
|
|
125
|
+
* for analytics and discovery ranking.
|
|
126
|
+
* @param toolName - The human-readable tool name.
|
|
127
|
+
* @param invocations - The number of invocations to report.
|
|
128
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
129
|
+
* @since v0.1.0
|
|
130
|
+
*/
|
|
131
|
+
reportInvocations(toolName: string, invocations: number | bigint): Promise<TransactionSignature>;
|
|
132
|
+
/**
|
|
133
|
+
* @name createCheckpoint
|
|
134
|
+
* @description Create a checkpoint snapshot of the current session state.
|
|
135
|
+
* Checkpoints are indexed by session PDA and checkpoint index.
|
|
136
|
+
* @param sessionPda - The session ledger PDA.
|
|
137
|
+
* @param checkpointIndex - The zero-based checkpoint index.
|
|
138
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
139
|
+
* @since v0.1.0
|
|
140
|
+
*/
|
|
141
|
+
createCheckpoint(sessionPda: PublicKey, checkpointIndex: number): Promise<TransactionSignature>;
|
|
142
|
+
/**
|
|
143
|
+
* @name closeCheckpoint
|
|
144
|
+
* @description Close a checkpoint PDA and reclaim rent.
|
|
145
|
+
* @param sessionPda - The session ledger PDA.
|
|
146
|
+
* @param checkpointIndex - The zero-based checkpoint index.
|
|
147
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
148
|
+
* @since v0.1.0
|
|
149
|
+
*/
|
|
150
|
+
closeCheckpoint(sessionPda: PublicKey, checkpointIndex: number): Promise<TransactionSignature>;
|
|
151
|
+
/**
|
|
152
|
+
* @name fetch
|
|
153
|
+
* @description Fetch a deserialized `ToolDescriptor` account.
|
|
154
|
+
* @param agentPda - The agent account PDA.
|
|
155
|
+
* @param toolName - The human-readable tool name.
|
|
156
|
+
* @returns {Promise<ToolDescriptorData>} The tool descriptor data.
|
|
157
|
+
* @throws Will throw if the tool descriptor does not exist.
|
|
158
|
+
* @since v0.1.0
|
|
159
|
+
*/
|
|
160
|
+
fetch(agentPda: PublicKey, toolName: string): Promise<ToolDescriptorData>;
|
|
161
|
+
/**
|
|
162
|
+
* @name fetchNullable
|
|
163
|
+
* @description Fetch a deserialized `ToolDescriptor` account, or `null`
|
|
164
|
+
* if it does not exist on-chain.
|
|
165
|
+
* @param agentPda - The agent account PDA.
|
|
166
|
+
* @param toolName - The human-readable tool name.
|
|
167
|
+
* @returns {Promise<ToolDescriptorData | null>} The tool data or `null`.
|
|
168
|
+
* @since v0.1.0
|
|
169
|
+
*/
|
|
170
|
+
fetchNullable(agentPda: PublicKey, toolName: string): Promise<ToolDescriptorData | null>;
|
|
171
|
+
/**
|
|
172
|
+
* @name fetchCheckpoint
|
|
173
|
+
* @description Fetch a deserialized `SessionCheckpoint` account by session PDA and index.
|
|
174
|
+
* @param sessionPda - The session ledger PDA.
|
|
175
|
+
* @param checkpointIndex - The zero-based checkpoint index.
|
|
176
|
+
* @returns {Promise<SessionCheckpointData>} The checkpoint data.
|
|
177
|
+
* @throws Will throw if the checkpoint does not exist.
|
|
178
|
+
* @since v0.1.0
|
|
179
|
+
*/
|
|
180
|
+
fetchCheckpoint(sessionPda: PublicKey, checkpointIndex: number): Promise<SessionCheckpointData>;
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/modules/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAiB,KAAK,SAAS,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAOpC,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAY,SAAQ,UAAU;IAGzC;;;;;;;;;OASG;IACH,UAAU,CACR,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,MAAM,GACf,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAM/B;;;;;;;OAOG;IACG,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA6BnE;;;;;;;;;;;;;;;;OAgBG;IACG,aAAa,CACjB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACn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,EACrB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,qBAAqB,CAAC;CAIlC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module vault
|
|
3
|
+
* @description Encrypted memory vault — init, session management, inscribe,
|
|
4
|
+
* delegate access, nonce rotation, and close operations.
|
|
5
|
+
*
|
|
6
|
+
* Vaults provide encrypted, session-scoped memory storage for agents,
|
|
7
|
+
* with support for epoch-based pagination and hot-wallet delegation.
|
|
8
|
+
*
|
|
9
|
+
* @category Modules
|
|
10
|
+
* @since v0.1.0
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { type PublicKey, type TransactionSignature } from "@solana/web3.js";
|
|
14
|
+
import { BaseModule } from "./base";
|
|
15
|
+
import type { MemoryVaultData, SessionLedgerData, EpochPageData, VaultDelegateData, InscribeMemoryArgs, CompactInscribeArgs } from "../types";
|
|
16
|
+
/**
|
|
17
|
+
* @name VaultModule
|
|
18
|
+
* @description Manages encrypted memory vaults for the Solana Agent Protocol.
|
|
19
|
+
* Provides methods to initialise vaults, open/close sessions, inscribe
|
|
20
|
+
* encrypted data, manage delegates (hot wallets), rotate nonces, and
|
|
21
|
+
* fetch all related account types.
|
|
22
|
+
*
|
|
23
|
+
* @category Modules
|
|
24
|
+
* @since v0.1.0
|
|
25
|
+
* @extends BaseModule
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const sap = new SapClient(provider);
|
|
30
|
+
* // Initialize a vault
|
|
31
|
+
* await sap.vault.initVault([...nonce]);
|
|
32
|
+
* // Open a session and inscribe data
|
|
33
|
+
* await sap.vault.openSession([...sessionHash]);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class VaultModule extends BaseModule {
|
|
37
|
+
/**
|
|
38
|
+
* @name deriveVault
|
|
39
|
+
* @description Derive the `MemoryVault` PDA for a given agent.
|
|
40
|
+
* @param agentPda - The agent account PDA.
|
|
41
|
+
* @returns A tuple of `[PublicKey, bump]` for the vault PDA.
|
|
42
|
+
* @see {@link deriveVault} from `pda/` module for the underlying derivation.
|
|
43
|
+
* @since v0.1.0
|
|
44
|
+
*/
|
|
45
|
+
deriveVault(agentPda: PublicKey): readonly [PublicKey, number];
|
|
46
|
+
/**
|
|
47
|
+
* @name deriveSession
|
|
48
|
+
* @description Derive the `SessionLedger` PDA for a given vault and session hash.
|
|
49
|
+
* @param vaultPda - The memory vault PDA.
|
|
50
|
+
* @param sessionHash - A unique session identifier (32 bytes).
|
|
51
|
+
* @returns A tuple of `[PublicKey, bump]` for the session PDA.
|
|
52
|
+
* @see {@link deriveSession} from `pda/` module for the underlying derivation.
|
|
53
|
+
* @since v0.1.0
|
|
54
|
+
*/
|
|
55
|
+
deriveSession(vaultPda: PublicKey, sessionHash: Uint8Array): readonly [PublicKey, number];
|
|
56
|
+
/**
|
|
57
|
+
* @name initVault
|
|
58
|
+
* @description Initialize an encrypted memory vault for the caller's agent.
|
|
59
|
+
* Creates the `MemoryVault` PDA and sets the initial encryption nonce.
|
|
60
|
+
* @param vaultNonce - The initial encryption nonce (byte array).
|
|
61
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
62
|
+
* @since v0.1.0
|
|
63
|
+
*/
|
|
64
|
+
initVault(vaultNonce: number[]): Promise<TransactionSignature>;
|
|
65
|
+
/**
|
|
66
|
+
* @name openSession
|
|
67
|
+
* @description Open a new session within a vault. Creates a `SessionLedger`
|
|
68
|
+
* PDA identified by the session hash.
|
|
69
|
+
* @param sessionHash - A unique session identifier (byte array).
|
|
70
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
71
|
+
* @since v0.1.0
|
|
72
|
+
*/
|
|
73
|
+
openSession(sessionHash: number[]): Promise<TransactionSignature>;
|
|
74
|
+
/**
|
|
75
|
+
* @name inscribe
|
|
76
|
+
* @description Inscribe encrypted data into the transaction log.
|
|
77
|
+
* Account resolution is handled by Anchor via remaining accounts.
|
|
78
|
+
* @param args - Inscription parameters (sequence, encrypted data, nonce, content hash, fragments, compression, epoch).
|
|
79
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
80
|
+
* @since v0.1.0
|
|
81
|
+
*/
|
|
82
|
+
inscribe(args: InscribeMemoryArgs): Promise<TransactionSignature>;
|
|
83
|
+
/**
|
|
84
|
+
* @name inscribeWithAccounts
|
|
85
|
+
* @description Full inscribe with explicit session and epoch page PDAs.
|
|
86
|
+
* Use this when you need manual control over account resolution.
|
|
87
|
+
* @param sessionPda - The session ledger PDA.
|
|
88
|
+
* @param epochPagePda - The epoch page PDA for the target epoch.
|
|
89
|
+
* @param vaultPda - The memory vault PDA.
|
|
90
|
+
* @param args - Inscription parameters.
|
|
91
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
92
|
+
* @since v0.1.0
|
|
93
|
+
*/
|
|
94
|
+
inscribeWithAccounts(sessionPda: PublicKey, epochPagePda: PublicKey, vaultPda: PublicKey, args: InscribeMemoryArgs): Promise<TransactionSignature>;
|
|
95
|
+
/**
|
|
96
|
+
* @name compactInscribe
|
|
97
|
+
* @description Simplified inscription (4 args vs 8) for single-fragment writes.
|
|
98
|
+
* @param sessionPda - The session ledger PDA.
|
|
99
|
+
* @param vaultPda - The memory vault PDA.
|
|
100
|
+
* @param args - Compact inscription parameters (sequence, encrypted data, nonce, content hash).
|
|
101
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
102
|
+
* @since v0.1.0
|
|
103
|
+
*/
|
|
104
|
+
compactInscribe(sessionPda: PublicKey, vaultPda: PublicKey, args: CompactInscribeArgs): Promise<TransactionSignature>;
|
|
105
|
+
/**
|
|
106
|
+
* @name closeSession
|
|
107
|
+
* @description Close a session — no more inscriptions will be allowed.
|
|
108
|
+
* @param vaultPda - The memory vault PDA.
|
|
109
|
+
* @param sessionPda - The session ledger PDA to close.
|
|
110
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
111
|
+
* @since v0.1.0
|
|
112
|
+
*/
|
|
113
|
+
closeSession(vaultPda: PublicKey, sessionPda: PublicKey): Promise<TransactionSignature>;
|
|
114
|
+
/**
|
|
115
|
+
* @name closeVault
|
|
116
|
+
* @description Close the `MemoryVault` PDA and reclaim rent to the owner wallet.
|
|
117
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
118
|
+
* @since v0.1.0
|
|
119
|
+
*/
|
|
120
|
+
closeVault(): Promise<TransactionSignature>;
|
|
121
|
+
/**
|
|
122
|
+
* @name closeSessionPda
|
|
123
|
+
* @description Close a `SessionLedger` PDA (session must be closed first).
|
|
124
|
+
* Reclaims rent to the owner wallet.
|
|
125
|
+
* @param vaultPda - The memory vault PDA.
|
|
126
|
+
* @param sessionPda - The session ledger PDA to close.
|
|
127
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
128
|
+
* @since v0.1.0
|
|
129
|
+
*/
|
|
130
|
+
closeSessionPda(vaultPda: PublicKey, sessionPda: PublicKey): Promise<TransactionSignature>;
|
|
131
|
+
/**
|
|
132
|
+
* @name closeEpochPage
|
|
133
|
+
* @description Close an `EpochPage` PDA and reclaim rent.
|
|
134
|
+
* @param sessionPda - The session ledger PDA that owns this epoch page.
|
|
135
|
+
* @param epochIndex - The zero-based epoch index.
|
|
136
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
137
|
+
* @since v0.1.0
|
|
138
|
+
*/
|
|
139
|
+
closeEpochPage(sessionPda: PublicKey, epochIndex: number): Promise<TransactionSignature>;
|
|
140
|
+
/**
|
|
141
|
+
* @name rotateNonce
|
|
142
|
+
* @description Rotate the vault encryption nonce. All future inscriptions
|
|
143
|
+
* will use the new nonce.
|
|
144
|
+
* @param newNonce - The replacement nonce (byte array).
|
|
145
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
146
|
+
* @since v0.1.0
|
|
147
|
+
*/
|
|
148
|
+
rotateNonce(newNonce: number[]): Promise<TransactionSignature>;
|
|
149
|
+
/**
|
|
150
|
+
* @name addDelegate
|
|
151
|
+
* @description Authorize a delegate (hot wallet) for vault operations.
|
|
152
|
+
* Creates a `VaultDelegate` PDA with the specified permissions and expiry.
|
|
153
|
+
* @param delegatePubkey - The public key of the delegate wallet to authorize.
|
|
154
|
+
* @param permissions - Bitmask of permitted operations.
|
|
155
|
+
* @param expiresAt - Unix timestamp when delegation expires.
|
|
156
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
157
|
+
* @since v0.1.0
|
|
158
|
+
*/
|
|
159
|
+
addDelegate(delegatePubkey: PublicKey, permissions: number, expiresAt: number | bigint): Promise<TransactionSignature>;
|
|
160
|
+
/**
|
|
161
|
+
* @name revokeDelegate
|
|
162
|
+
* @description Revoke a delegate’s authorization, closing their `VaultDelegate` PDA.
|
|
163
|
+
* @param delegatePubkey - The public key of the delegate wallet to revoke.
|
|
164
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
165
|
+
* @since v0.1.0
|
|
166
|
+
*/
|
|
167
|
+
revokeDelegate(delegatePubkey: PublicKey): Promise<TransactionSignature>;
|
|
168
|
+
/**
|
|
169
|
+
* @name inscribeDelegated
|
|
170
|
+
* @description Inscribe data via an authorized delegate (hot wallet).
|
|
171
|
+
* The transaction is signed by the delegate instead of the vault owner.
|
|
172
|
+
* @param delegateWallet - The delegate wallet public key.
|
|
173
|
+
* @param vaultPda - The memory vault PDA.
|
|
174
|
+
* @param sessionPda - The session ledger PDA.
|
|
175
|
+
* @param epochPagePda - The epoch page PDA.
|
|
176
|
+
* @param args - Inscription parameters.
|
|
177
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
178
|
+
* @since v0.1.0
|
|
179
|
+
*/
|
|
180
|
+
inscribeDelegated(delegateWallet: PublicKey, vaultPda: PublicKey, sessionPda: PublicKey, epochPagePda: PublicKey, args: InscribeMemoryArgs): Promise<TransactionSignature>;
|
|
181
|
+
/**
|
|
182
|
+
* @name fetchVault
|
|
183
|
+
* @description Fetch a deserialized `MemoryVault` account.
|
|
184
|
+
* @param agentPda - The agent account PDA.
|
|
185
|
+
* @returns {Promise<MemoryVaultData>} The vault account data.
|
|
186
|
+
* @throws Will throw if the vault account does not exist.
|
|
187
|
+
* @since v0.1.0
|
|
188
|
+
*/
|
|
189
|
+
fetchVault(agentPda: PublicKey): Promise<MemoryVaultData>;
|
|
190
|
+
/**
|
|
191
|
+
* @name fetchVaultNullable
|
|
192
|
+
* @description Fetch a deserialized `MemoryVault` account, or `null`
|
|
193
|
+
* if it does not exist on-chain.
|
|
194
|
+
* @param agentPda - The agent account PDA.
|
|
195
|
+
* @returns {Promise<MemoryVaultData | null>} The vault data or `null`.
|
|
196
|
+
* @since v0.1.0
|
|
197
|
+
*/
|
|
198
|
+
fetchVaultNullable(agentPda: PublicKey): Promise<MemoryVaultData | null>;
|
|
199
|
+
/**
|
|
200
|
+
* @name fetchSession
|
|
201
|
+
* @description Fetch a deserialized `SessionLedger` account by vault and session hash.
|
|
202
|
+
* @param vaultPda - The memory vault PDA.
|
|
203
|
+
* @param sessionHash - The session identifier used during creation.
|
|
204
|
+
* @returns {Promise<SessionLedgerData>} The session ledger data.
|
|
205
|
+
* @throws Will throw if the session does not exist.
|
|
206
|
+
* @since v0.1.0
|
|
207
|
+
*/
|
|
208
|
+
fetchSession(vaultPda: PublicKey, sessionHash: Uint8Array): Promise<SessionLedgerData>;
|
|
209
|
+
/**
|
|
210
|
+
* @name fetchSessionByPda
|
|
211
|
+
* @description Fetch a deserialized `SessionLedger` account by its PDA directly,
|
|
212
|
+
* bypassing PDA derivation.
|
|
213
|
+
* @param sessionPda - The session ledger PDA.
|
|
214
|
+
* @returns {Promise<SessionLedgerData>} The session ledger data.
|
|
215
|
+
* @throws Will throw if the session does not exist.
|
|
216
|
+
* @since v0.1.0
|
|
217
|
+
*/
|
|
218
|
+
fetchSessionByPda(sessionPda: PublicKey): Promise<SessionLedgerData>;
|
|
219
|
+
/**
|
|
220
|
+
* @name fetchEpochPage
|
|
221
|
+
* @description Fetch a deserialized `EpochPage` account.
|
|
222
|
+
* @param sessionPda - The session ledger PDA.
|
|
223
|
+
* @param epochIndex - The zero-based epoch index.
|
|
224
|
+
* @returns {Promise<EpochPageData>} The epoch page data.
|
|
225
|
+
* @throws Will throw if the epoch page does not exist.
|
|
226
|
+
* @since v0.1.0
|
|
227
|
+
*/
|
|
228
|
+
fetchEpochPage(sessionPda: PublicKey, epochIndex: number): Promise<EpochPageData>;
|
|
229
|
+
/**
|
|
230
|
+
* @name fetchDelegate
|
|
231
|
+
* @description Fetch a deserialized `VaultDelegate` account.
|
|
232
|
+
* @param vaultPda - The memory vault PDA.
|
|
233
|
+
* @param delegatePubkey - The delegate wallet public key.
|
|
234
|
+
* @returns {Promise<VaultDelegateData>} The delegate account data.
|
|
235
|
+
* @throws Will throw if the delegate does not exist.
|
|
236
|
+
* @since v0.1.0
|
|
237
|
+
*/
|
|
238
|
+
fetchDelegate(vaultPda: PublicKey, delegatePubkey: PublicKey): Promise<VaultDelegateData>;
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../../../src/modules/vault.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAiB,KAAK,SAAS,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AASpC,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,WAAY,SAAQ,UAAU;IAGzC;;;;;;;OAOG;IACH,WAAW,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAI9D;;;;;;;;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