@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.
Files changed (315) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +882 -0
  3. package/dist/cjs/constants/index.js +43 -0
  4. package/dist/cjs/constants/index.js.map +1 -0
  5. package/dist/cjs/constants/limits.js +161 -0
  6. package/dist/cjs/constants/limits.js.map +1 -0
  7. package/dist/cjs/constants/programs.js +78 -0
  8. package/dist/cjs/constants/programs.js.map +1 -0
  9. package/dist/cjs/constants/seeds.js +57 -0
  10. package/dist/cjs/constants/seeds.js.map +1 -0
  11. package/dist/cjs/core/client.js +391 -0
  12. package/dist/cjs/core/client.js.map +1 -0
  13. package/dist/cjs/core/connection.js +319 -0
  14. package/dist/cjs/core/connection.js.map +1 -0
  15. package/dist/cjs/core/index.js +24 -0
  16. package/dist/cjs/core/index.js.map +1 -0
  17. package/dist/cjs/errors/index.js +334 -0
  18. package/dist/cjs/errors/index.js.map +1 -0
  19. package/dist/cjs/events/index.js +136 -0
  20. package/dist/cjs/events/index.js.map +1 -0
  21. package/dist/cjs/idl/index.js +63 -0
  22. package/dist/cjs/idl/index.js.map +1 -0
  23. package/dist/cjs/idl/synapse_agent_sap.json +9710 -0
  24. package/dist/cjs/index.js +147 -0
  25. package/dist/cjs/index.js.map +1 -0
  26. package/dist/cjs/modules/agent.js +272 -0
  27. package/dist/cjs/modules/agent.js.map +1 -0
  28. package/dist/cjs/modules/attestation.js +147 -0
  29. package/dist/cjs/modules/attestation.js.map +1 -0
  30. package/dist/cjs/modules/base.js +128 -0
  31. package/dist/cjs/modules/base.js.map +1 -0
  32. package/dist/cjs/modules/escrow.js +246 -0
  33. package/dist/cjs/modules/escrow.js.map +1 -0
  34. package/dist/cjs/modules/feedback.js +166 -0
  35. package/dist/cjs/modules/feedback.js.map +1 -0
  36. package/dist/cjs/modules/index.js +35 -0
  37. package/dist/cjs/modules/index.js.map +1 -0
  38. package/dist/cjs/modules/indexing.js +375 -0
  39. package/dist/cjs/modules/indexing.js.map +1 -0
  40. package/dist/cjs/modules/ledger.js +234 -0
  41. package/dist/cjs/modules/ledger.js.map +1 -0
  42. package/dist/cjs/modules/tools.js +319 -0
  43. package/dist/cjs/modules/tools.js.map +1 -0
  44. package/dist/cjs/modules/vault.js +410 -0
  45. package/dist/cjs/modules/vault.js.map +1 -0
  46. package/dist/cjs/pda/index.js +377 -0
  47. package/dist/cjs/pda/index.js.map +1 -0
  48. package/dist/cjs/plugin/index.js +934 -0
  49. package/dist/cjs/plugin/index.js.map +1 -0
  50. package/dist/cjs/plugin/protocols.js +282 -0
  51. package/dist/cjs/plugin/protocols.js.map +1 -0
  52. package/dist/cjs/plugin/schemas.js +831 -0
  53. package/dist/cjs/plugin/schemas.js.map +1 -0
  54. package/dist/cjs/postgres/adapter.js +715 -0
  55. package/dist/cjs/postgres/adapter.js.map +1 -0
  56. package/dist/cjs/postgres/index.js +50 -0
  57. package/dist/cjs/postgres/index.js.map +1 -0
  58. package/dist/cjs/postgres/serializers.js +381 -0
  59. package/dist/cjs/postgres/serializers.js.map +1 -0
  60. package/dist/cjs/postgres/sync.js +221 -0
  61. package/dist/cjs/postgres/sync.js.map +1 -0
  62. package/dist/cjs/postgres/types.js +44 -0
  63. package/dist/cjs/postgres/types.js.map +1 -0
  64. package/dist/cjs/registries/builder.js +414 -0
  65. package/dist/cjs/registries/builder.js.map +1 -0
  66. package/dist/cjs/registries/discovery.js +362 -0
  67. package/dist/cjs/registries/discovery.js.map +1 -0
  68. package/dist/cjs/registries/index.js +51 -0
  69. package/dist/cjs/registries/index.js.map +1 -0
  70. package/dist/cjs/registries/session.js +433 -0
  71. package/dist/cjs/registries/session.js.map +1 -0
  72. package/dist/cjs/registries/x402.js +577 -0
  73. package/dist/cjs/registries/x402.js.map +1 -0
  74. package/dist/cjs/types/accounts.js +13 -0
  75. package/dist/cjs/types/accounts.js.map +1 -0
  76. package/dist/cjs/types/common.js +13 -0
  77. package/dist/cjs/types/common.js.map +1 -0
  78. package/dist/cjs/types/enums.js +174 -0
  79. package/dist/cjs/types/enums.js.map +1 -0
  80. package/dist/cjs/types/index.js +36 -0
  81. package/dist/cjs/types/index.js.map +1 -0
  82. package/dist/cjs/types/instructions.js +92 -0
  83. package/dist/cjs/types/instructions.js.map +1 -0
  84. package/dist/cjs/utils/hash.js +58 -0
  85. package/dist/cjs/utils/hash.js.map +1 -0
  86. package/dist/cjs/utils/index.js +27 -0
  87. package/dist/cjs/utils/index.js.map +1 -0
  88. package/dist/cjs/utils/serialization.js +105 -0
  89. package/dist/cjs/utils/serialization.js.map +1 -0
  90. package/dist/cjs/utils/validation.js +36 -0
  91. package/dist/cjs/utils/validation.js.map +1 -0
  92. package/dist/esm/constants/index.js +29 -0
  93. package/dist/esm/constants/index.js.map +1 -0
  94. package/dist/esm/constants/limits.js +158 -0
  95. package/dist/esm/constants/limits.js.map +1 -0
  96. package/dist/esm/constants/programs.js +75 -0
  97. package/dist/esm/constants/programs.js.map +1 -0
  98. package/dist/esm/constants/seeds.js +54 -0
  99. package/dist/esm/constants/seeds.js.map +1 -0
  100. package/dist/esm/core/client.js +384 -0
  101. package/dist/esm/core/client.js.map +1 -0
  102. package/dist/esm/core/connection.js +315 -0
  103. package/dist/esm/core/connection.js.map +1 -0
  104. package/dist/esm/core/index.js +19 -0
  105. package/dist/esm/core/index.js.map +1 -0
  106. package/dist/esm/errors/index.js +325 -0
  107. package/dist/esm/errors/index.js.map +1 -0
  108. package/dist/esm/events/index.js +132 -0
  109. package/dist/esm/events/index.js.map +1 -0
  110. package/dist/esm/idl/index.js +57 -0
  111. package/dist/esm/idl/index.js.map +1 -0
  112. package/dist/esm/idl/synapse_agent_sap.json +9710 -0
  113. package/dist/esm/index.js +70 -0
  114. package/dist/esm/index.js.map +1 -0
  115. package/dist/esm/modules/agent.js +268 -0
  116. package/dist/esm/modules/agent.js.map +1 -0
  117. package/dist/esm/modules/attestation.js +143 -0
  118. package/dist/esm/modules/attestation.js.map +1 -0
  119. package/dist/esm/modules/base.js +124 -0
  120. package/dist/esm/modules/base.js.map +1 -0
  121. package/dist/esm/modules/escrow.js +242 -0
  122. package/dist/esm/modules/escrow.js.map +1 -0
  123. package/dist/esm/modules/feedback.js +162 -0
  124. package/dist/esm/modules/feedback.js.map +1 -0
  125. package/dist/esm/modules/index.js +23 -0
  126. package/dist/esm/modules/index.js.map +1 -0
  127. package/dist/esm/modules/indexing.js +371 -0
  128. package/dist/esm/modules/indexing.js.map +1 -0
  129. package/dist/esm/modules/ledger.js +230 -0
  130. package/dist/esm/modules/ledger.js.map +1 -0
  131. package/dist/esm/modules/tools.js +315 -0
  132. package/dist/esm/modules/tools.js.map +1 -0
  133. package/dist/esm/modules/vault.js +406 -0
  134. package/dist/esm/modules/vault.js.map +1 -0
  135. package/dist/esm/pda/index.js +357 -0
  136. package/dist/esm/pda/index.js.map +1 -0
  137. package/dist/esm/plugin/index.js +927 -0
  138. package/dist/esm/plugin/index.js.map +1 -0
  139. package/dist/esm/plugin/protocols.js +279 -0
  140. package/dist/esm/plugin/protocols.js.map +1 -0
  141. package/dist/esm/plugin/schemas.js +828 -0
  142. package/dist/esm/plugin/schemas.js.map +1 -0
  143. package/dist/esm/postgres/adapter.js +678 -0
  144. package/dist/esm/postgres/adapter.js.map +1 -0
  145. package/dist/esm/postgres/index.js +27 -0
  146. package/dist/esm/postgres/index.js.map +1 -0
  147. package/dist/esm/postgres/serializers.js +362 -0
  148. package/dist/esm/postgres/serializers.js.map +1 -0
  149. package/dist/esm/postgres/sync.js +217 -0
  150. package/dist/esm/postgres/sync.js.map +1 -0
  151. package/dist/esm/postgres/types.js +41 -0
  152. package/dist/esm/postgres/types.js.map +1 -0
  153. package/dist/esm/registries/builder.js +410 -0
  154. package/dist/esm/registries/builder.js.map +1 -0
  155. package/dist/esm/registries/discovery.js +358 -0
  156. package/dist/esm/registries/discovery.js.map +1 -0
  157. package/dist/esm/registries/index.js +44 -0
  158. package/dist/esm/registries/index.js.map +1 -0
  159. package/dist/esm/registries/session.js +429 -0
  160. package/dist/esm/registries/session.js.map +1 -0
  161. package/dist/esm/registries/x402.js +573 -0
  162. package/dist/esm/registries/x402.js.map +1 -0
  163. package/dist/esm/types/accounts.js +12 -0
  164. package/dist/esm/types/accounts.js.map +1 -0
  165. package/dist/esm/types/common.js +12 -0
  166. package/dist/esm/types/common.js.map +1 -0
  167. package/dist/esm/types/enums.js +171 -0
  168. package/dist/esm/types/enums.js.map +1 -0
  169. package/dist/esm/types/index.js +25 -0
  170. package/dist/esm/types/index.js.map +1 -0
  171. package/dist/esm/types/instructions.js +89 -0
  172. package/dist/esm/types/instructions.js.map +1 -0
  173. package/dist/esm/utils/hash.js +53 -0
  174. package/dist/esm/utils/hash.js.map +1 -0
  175. package/dist/esm/utils/index.js +19 -0
  176. package/dist/esm/utils/index.js.map +1 -0
  177. package/dist/esm/utils/serialization.js +98 -0
  178. package/dist/esm/utils/serialization.js.map +1 -0
  179. package/dist/esm/utils/validation.js +33 -0
  180. package/dist/esm/utils/validation.js.map +1 -0
  181. package/dist/types/constants/index.d.ts +27 -0
  182. package/dist/types/constants/index.d.ts.map +1 -0
  183. package/dist/types/constants/limits.d.ts +149 -0
  184. package/dist/types/constants/limits.d.ts.map +1 -0
  185. package/dist/types/constants/programs.d.ts +69 -0
  186. package/dist/types/constants/programs.d.ts.map +1 -0
  187. package/dist/types/constants/seeds.d.ts +61 -0
  188. package/dist/types/constants/seeds.d.ts.map +1 -0
  189. package/dist/types/core/client.d.ts +323 -0
  190. package/dist/types/core/client.d.ts.map +1 -0
  191. package/dist/types/core/connection.d.ts +279 -0
  192. package/dist/types/core/connection.d.ts.map +1 -0
  193. package/dist/types/core/index.d.ts +20 -0
  194. package/dist/types/core/index.d.ts.map +1 -0
  195. package/dist/types/errors/index.d.ts +276 -0
  196. package/dist/types/errors/index.d.ts.map +1 -0
  197. package/dist/types/events/index.d.ts +248 -0
  198. package/dist/types/events/index.d.ts.map +1 -0
  199. package/dist/types/idl/index.d.ts +70 -0
  200. package/dist/types/idl/index.d.ts.map +1 -0
  201. package/dist/types/index.d.ts +68 -0
  202. package/dist/types/index.d.ts.map +1 -0
  203. package/dist/types/modules/agent.d.ts +166 -0
  204. package/dist/types/modules/agent.d.ts.map +1 -0
  205. package/dist/types/modules/attestation.d.ts +96 -0
  206. package/dist/types/modules/attestation.d.ts.map +1 -0
  207. package/dist/types/modules/base.d.ts +126 -0
  208. package/dist/types/modules/base.d.ts.map +1 -0
  209. package/dist/types/modules/escrow.d.ts +151 -0
  210. package/dist/types/modules/escrow.d.ts.map +1 -0
  211. package/dist/types/modules/feedback.d.ts +105 -0
  212. package/dist/types/modules/feedback.d.ts.map +1 -0
  213. package/dist/types/modules/index.d.ts +24 -0
  214. package/dist/types/modules/index.d.ts.map +1 -0
  215. package/dist/types/modules/indexing.d.ts +200 -0
  216. package/dist/types/modules/indexing.d.ts.map +1 -0
  217. package/dist/types/modules/ledger.d.ts +150 -0
  218. package/dist/types/modules/ledger.d.ts.map +1 -0
  219. package/dist/types/modules/tools.d.ts +182 -0
  220. package/dist/types/modules/tools.d.ts.map +1 -0
  221. package/dist/types/modules/vault.d.ts +240 -0
  222. package/dist/types/modules/vault.d.ts.map +1 -0
  223. package/dist/types/pda/index.d.ts +296 -0
  224. package/dist/types/pda/index.d.ts.map +1 -0
  225. package/dist/types/plugin/index.d.ts +171 -0
  226. package/dist/types/plugin/index.d.ts.map +1 -0
  227. package/dist/types/plugin/protocols.d.ts +152 -0
  228. package/dist/types/plugin/protocols.d.ts.map +1 -0
  229. package/dist/types/plugin/schemas.d.ts +823 -0
  230. package/dist/types/plugin/schemas.d.ts.map +1 -0
  231. package/dist/types/postgres/adapter.d.ts +355 -0
  232. package/dist/types/postgres/adapter.d.ts.map +1 -0
  233. package/dist/types/postgres/index.d.ts +24 -0
  234. package/dist/types/postgres/index.d.ts.map +1 -0
  235. package/dist/types/postgres/serializers.d.ts +30 -0
  236. package/dist/types/postgres/serializers.d.ts.map +1 -0
  237. package/dist/types/postgres/sync.d.ts +132 -0
  238. package/dist/types/postgres/sync.d.ts.map +1 -0
  239. package/dist/types/postgres/types.d.ts +167 -0
  240. package/dist/types/postgres/types.d.ts.map +1 -0
  241. package/dist/types/registries/builder.d.ts +340 -0
  242. package/dist/types/registries/builder.d.ts.map +1 -0
  243. package/dist/types/registries/discovery.d.ts +333 -0
  244. package/dist/types/registries/discovery.d.ts.map +1 -0
  245. package/dist/types/registries/index.d.ts +48 -0
  246. package/dist/types/registries/index.d.ts.map +1 -0
  247. package/dist/types/registries/session.d.ts +323 -0
  248. package/dist/types/registries/session.d.ts.map +1 -0
  249. package/dist/types/registries/x402.d.ts +463 -0
  250. package/dist/types/registries/x402.d.ts.map +1 -0
  251. package/dist/types/types/accounts.d.ts +565 -0
  252. package/dist/types/types/accounts.d.ts.map +1 -0
  253. package/dist/types/types/common.d.ts +166 -0
  254. package/dist/types/types/common.d.ts.map +1 -0
  255. package/dist/types/types/enums.d.ts +238 -0
  256. package/dist/types/types/enums.d.ts.map +1 -0
  257. package/dist/types/types/index.d.ts +28 -0
  258. package/dist/types/types/index.d.ts.map +1 -0
  259. package/dist/types/types/instructions.d.ts +366 -0
  260. package/dist/types/types/instructions.d.ts.map +1 -0
  261. package/dist/types/utils/hash.d.ts +48 -0
  262. package/dist/types/utils/hash.d.ts.map +1 -0
  263. package/dist/types/utils/index.d.ts +19 -0
  264. package/dist/types/utils/index.d.ts.map +1 -0
  265. package/dist/types/utils/serialization.d.ts +69 -0
  266. package/dist/types/utils/serialization.d.ts.map +1 -0
  267. package/dist/types/utils/validation.d.ts +29 -0
  268. package/dist/types/utils/validation.d.ts.map +1 -0
  269. package/package.json +178 -0
  270. package/src/constants/index.ts +44 -0
  271. package/src/constants/limits.ts +165 -0
  272. package/src/constants/programs.ts +83 -0
  273. package/src/constants/seeds.ts +66 -0
  274. package/src/core/client.ts +416 -0
  275. package/src/core/connection.ts +409 -0
  276. package/src/core/index.ts +20 -0
  277. package/src/errors/index.ts +346 -0
  278. package/src/events/index.ts +335 -0
  279. package/src/idl/index.ts +76 -0
  280. package/src/idl/synapse_agent_sap.json +9710 -0
  281. package/src/index.ts +253 -0
  282. package/src/modules/agent.ts +319 -0
  283. package/src/modules/attestation.ts +168 -0
  284. package/src/modules/base.ts +158 -0
  285. package/src/modules/escrow.ts +308 -0
  286. package/src/modules/feedback.ts +186 -0
  287. package/src/modules/index.ts +24 -0
  288. package/src/modules/indexing.ts +444 -0
  289. package/src/modules/ledger.ts +262 -0
  290. package/src/modules/tools.ts +411 -0
  291. package/src/modules/vault.ts +533 -0
  292. package/src/pda/index.ts +512 -0
  293. package/src/plugin/index.ts +1202 -0
  294. package/src/plugin/protocols.ts +404 -0
  295. package/src/plugin/schemas.ts +909 -0
  296. package/src/postgres/adapter.ts +904 -0
  297. package/src/postgres/index.ts +59 -0
  298. package/src/postgres/schema.sql +683 -0
  299. package/src/postgres/serializers.ts +485 -0
  300. package/src/postgres/sync.ts +254 -0
  301. package/src/postgres/types.ts +245 -0
  302. package/src/registries/builder.ts +607 -0
  303. package/src/registries/discovery.ts +572 -0
  304. package/src/registries/index.ts +77 -0
  305. package/src/registries/session.ts +613 -0
  306. package/src/registries/x402.ts +906 -0
  307. package/src/types/accounts.ts +618 -0
  308. package/src/types/common.ts +187 -0
  309. package/src/types/enums.ts +214 -0
  310. package/src/types/index.ts +92 -0
  311. package/src/types/instructions.ts +413 -0
  312. package/src/utils/hash.ts +57 -0
  313. package/src/utils/index.ts +19 -0
  314. package/src/utils/serialization.ts +98 -0
  315. 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"],"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AAO,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;;;;;;;;;;;GAW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AC,oBAAoB,CAAC;IAcjE;;;;;;OAMG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgB5D;;;;;;;;OAQG;IACG,iBAAiB,CACrB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAgBhC;;;;;;;;OAQG;IACG,gBAAgB,CACpB,UAAU,EAAE,SAAS,EACrB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,oBAAoB,CAAC;IAchC;;;;;;;OAOG;IACG,eAAe,CACnB,UAAU,EAAE,SAAS,EACrB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;;;OAQG;IACG,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAK/E;;;;;;;;OAQG;IACG,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAK9F;;;;;;;;OAQG;IACG,eAAe,CACnB,UAAU,EAAE,SAAS,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,m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