@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,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module base
|
|
3
|
+
* @description Abstract base class for all SDK modules.
|
|
4
|
+
*
|
|
5
|
+
* Provides shared access to the Anchor program, provider,
|
|
6
|
+
* and typed `fetch` / `fetchNullable` helpers.
|
|
7
|
+
*
|
|
8
|
+
* @category Modules
|
|
9
|
+
* @since v0.1.0
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import { type AnchorProvider, type Program, BN } from "@coral-xyz/anchor";
|
|
13
|
+
import type { PublicKey, TransactionSignature } from "@solana/web3.js";
|
|
14
|
+
/**
|
|
15
|
+
* Anchor `Program` instance typed for the Synapse Agent SAP IDL.
|
|
16
|
+
*
|
|
17
|
+
* @name SapProgram
|
|
18
|
+
* @description Alias for `Program<any>` — the Anchor program reference
|
|
19
|
+
* used as the backbone of every module in the SDK.
|
|
20
|
+
* @category Modules
|
|
21
|
+
* @since v0.1.0
|
|
22
|
+
*/
|
|
23
|
+
export type SapProgram = Program<any>;
|
|
24
|
+
/**
|
|
25
|
+
* @name SapTransactionResult
|
|
26
|
+
* @description Instruction builder return type — a ready-to-send transaction.
|
|
27
|
+
* Contains the finalized transaction signature after RPC submission.
|
|
28
|
+
* @category Modules
|
|
29
|
+
* @since v0.1.0
|
|
30
|
+
*/
|
|
31
|
+
export interface SapTransactionResult {
|
|
32
|
+
/** The base-58 encoded transaction signature returned by the RPC node. */
|
|
33
|
+
readonly signature: TransactionSignature;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @name BaseModule
|
|
37
|
+
* @description Abstract base module inherited by every domain module in the SDK.
|
|
38
|
+
* Encapsulates the Anchor program reference, provider access, and common
|
|
39
|
+
* helpers for account fetching and BN construction.
|
|
40
|
+
*
|
|
41
|
+
* @abstract
|
|
42
|
+
* @category Modules
|
|
43
|
+
* @since v0.1.0
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* class MyModule extends BaseModule {
|
|
48
|
+
* async doSomething() {
|
|
49
|
+
* const data = await this.fetchAccount<MyData>("myAccount", pda);
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare abstract class BaseModule {
|
|
55
|
+
protected readonly program: SapProgram;
|
|
56
|
+
/**
|
|
57
|
+
* Create a new module instance.
|
|
58
|
+
*
|
|
59
|
+
* @param program - The Anchor `Program` instance for the SAP IDL.
|
|
60
|
+
* @protected
|
|
61
|
+
*/
|
|
62
|
+
constructor(program: SapProgram);
|
|
63
|
+
/**
|
|
64
|
+
* @name methods
|
|
65
|
+
* @description Instruction method namespace — bypasses `noUncheckedIndexedAccess`
|
|
66
|
+
* on `Program<any>` where every property is `T | undefined`.
|
|
67
|
+
* Used internally by subclasses to build and send instructions.
|
|
68
|
+
* @returns The Anchor program `methods` object for chaining instruction builders.
|
|
69
|
+
* @protected
|
|
70
|
+
* @since v0.1.0
|
|
71
|
+
*/
|
|
72
|
+
protected get methods(): any;
|
|
73
|
+
/**
|
|
74
|
+
* @name provider
|
|
75
|
+
* @description The AnchorProvider from the program, giving access to
|
|
76
|
+
* the connection and wallet for signing transactions.
|
|
77
|
+
* @returns {AnchorProvider} The Anchor provider instance.
|
|
78
|
+
* @protected
|
|
79
|
+
* @since v0.1.0
|
|
80
|
+
*/
|
|
81
|
+
protected get provider(): AnchorProvider;
|
|
82
|
+
/**
|
|
83
|
+
* @name walletPubkey
|
|
84
|
+
* @description Convenience accessor for the signer wallet's public key.
|
|
85
|
+
* @returns {PublicKey} The public key of the connected wallet.
|
|
86
|
+
* @protected
|
|
87
|
+
* @since v0.1.0
|
|
88
|
+
*/
|
|
89
|
+
protected get walletPubkey(): PublicKey;
|
|
90
|
+
/**
|
|
91
|
+
* @name fetchAccount
|
|
92
|
+
* @description Generic account fetch — deserializes the on-chain account
|
|
93
|
+
* data into the given type `T`, or throws if the account does not exist.
|
|
94
|
+
* @typeParam T - The expected deserialized account data type.
|
|
95
|
+
* @param accountName - The Anchor account discriminator name (e.g. `"agentAccount"`).
|
|
96
|
+
* @param address - The public key of the account to fetch.
|
|
97
|
+
* @returns {Promise<T>} The deserialized account data.
|
|
98
|
+
* @throws Will throw if the account does not exist on-chain.
|
|
99
|
+
* @protected
|
|
100
|
+
* @since v0.1.0
|
|
101
|
+
*/
|
|
102
|
+
protected fetchAccount<T>(accountName: string, address: PublicKey): Promise<T>;
|
|
103
|
+
/**
|
|
104
|
+
* @name fetchAccountNullable
|
|
105
|
+
* @description Generic nullable account fetch — deserializes the on-chain
|
|
106
|
+
* account data into type `T`, or returns `null` if the account does not exist.
|
|
107
|
+
* @typeParam T - The expected deserialized account data type.
|
|
108
|
+
* @param accountName - The Anchor account discriminator name (e.g. `"agentAccount"`).
|
|
109
|
+
* @param address - The public key of the account to fetch.
|
|
110
|
+
* @returns {Promise<T | null>} The deserialized account data, or `null`.
|
|
111
|
+
* @protected
|
|
112
|
+
* @since v0.1.0
|
|
113
|
+
*/
|
|
114
|
+
protected fetchAccountNullable<T>(accountName: string, address: PublicKey): Promise<T | null>;
|
|
115
|
+
/**
|
|
116
|
+
* @name bn
|
|
117
|
+
* @description Create an Anchor `BN` from a number, bigint, or existing BN.
|
|
118
|
+
* Passes through values that are already `BN` instances.
|
|
119
|
+
* @param value - The numeric value to convert.
|
|
120
|
+
* @returns {BN} An Anchor-compatible big number.
|
|
121
|
+
* @protected
|
|
122
|
+
* @since v0.1.0
|
|
123
|
+
*/
|
|
124
|
+
protected bn(value: number | bigint | BN): BN;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/modules/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvE;;;;;;;;GAQG;AAEH,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,oBAAoB,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,8BAAsB,UAAU;IAOlB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU;IANlD;;;;;OAKG;gBAC4B,OAAO,EAAE,UAAU;IAElD;;;;;;;;OAQG;IAEH,SAAS,KAAK,OAAO,IAAI,GAAG,CAG3B;IAED;;;;;;;OAOG;IACH,SAAS,KAAK,QAAQ,IAAI,cAAc,CAEvC;IAED;;;;;;OAMG;IACH,SAAS,KAAK,YAAY,IAAI,SAAS,CAEtC;IAED;;;;;;;;;;;OAWG;cACa,YAAY,CAAC,CAAC,EAC5B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,CAAC,CAAC;IAKb;;;;;;;;;;OAUG;cACa,oBAAoB,CAAC,CAAC,EACpC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAKpB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,EAAE,GAAG,EAAE;CAI9C"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module escrow
|
|
3
|
+
* @description x402 escrow settlement layer — create, deposit,
|
|
4
|
+
* settle, withdraw, batch settle, and close escrow accounts.
|
|
5
|
+
*
|
|
6
|
+
* Supports both SOL and SPL token escrows. SPL operations require
|
|
7
|
+
* passing additional `AccountMeta[]` via the `splAccounts` parameter.
|
|
8
|
+
*
|
|
9
|
+
* @category Modules
|
|
10
|
+
* @since v0.1.0
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { type PublicKey, type TransactionSignature, type AccountMeta } from "@solana/web3.js";
|
|
14
|
+
import { BN } from "@coral-xyz/anchor";
|
|
15
|
+
import { BaseModule } from "./base";
|
|
16
|
+
import type { EscrowAccountData, CreateEscrowArgs, Settlement } from "../types";
|
|
17
|
+
/**
|
|
18
|
+
* @name EscrowModule
|
|
19
|
+
* @description Manages x402-compatible escrow accounts for agent micropayments.
|
|
20
|
+
* Provides methods to create, fund, settle, withdraw, batch-settle, close,
|
|
21
|
+
* and fetch escrow PDAs on the Solana Agent Protocol.
|
|
22
|
+
*
|
|
23
|
+
* @category Modules
|
|
24
|
+
* @since v0.1.0
|
|
25
|
+
* @extends BaseModule
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const sap = new SapClient(provider);
|
|
30
|
+
* // Create a SOL escrow for an agent
|
|
31
|
+
* const sig = await sap.escrow.create(agentWallet, {
|
|
32
|
+
* pricePerCall: new BN(1_000_000),
|
|
33
|
+
* maxCalls: new BN(100),
|
|
34
|
+
* initialDeposit: new BN(100_000_000),
|
|
35
|
+
* expiresAt: null,
|
|
36
|
+
* volumeCurve: null,
|
|
37
|
+
* tokenMint: null,
|
|
38
|
+
* tokenDecimals: null,
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare class EscrowModule extends BaseModule {
|
|
43
|
+
/**
|
|
44
|
+
* @name deriveEscrow
|
|
45
|
+
* @description Derive the `EscrowAccount` PDA for a given agent and depositor.
|
|
46
|
+
* @param agentPda - The agent account PDA.
|
|
47
|
+
* @param depositor - The depositor wallet. Defaults to the connected wallet.
|
|
48
|
+
* @returns A tuple of `[PublicKey, bump]` for the escrow PDA.
|
|
49
|
+
* @see {@link deriveEscrow} from `pda/` module for the underlying derivation.
|
|
50
|
+
* @since v0.1.0
|
|
51
|
+
*/
|
|
52
|
+
deriveEscrow(agentPda: PublicKey, depositor?: PublicKey): readonly [PublicKey, number];
|
|
53
|
+
/**
|
|
54
|
+
* @name create
|
|
55
|
+
* @description Create a new escrow for agent micropayments.
|
|
56
|
+
*
|
|
57
|
+
* For **SOL escrow**: pass `tokenMint: null` and leave `splAccounts` empty.
|
|
58
|
+
* For **SPL escrow**: pass `tokenMint`, `tokenDecimals`, and provide
|
|
59
|
+
* `splAccounts` with `[depositorAta, escrowAta, tokenMint, tokenProgram]`.
|
|
60
|
+
*
|
|
61
|
+
* @param agentWallet - The wallet of the agent to pay.
|
|
62
|
+
* @param args - Escrow creation parameters (price, max calls, deposit, expiry, volume curve, token info).
|
|
63
|
+
* @param splAccounts - Remaining accounts for SPL token transfers:
|
|
64
|
+
* `[depositorAta, escrowAta, tokenMint, tokenProgram]`. Defaults to `[]`.
|
|
65
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
66
|
+
* @since v0.1.0
|
|
67
|
+
*/
|
|
68
|
+
create(agentWallet: PublicKey, args: CreateEscrowArgs, splAccounts?: AccountMeta[]): Promise<TransactionSignature>;
|
|
69
|
+
/**
|
|
70
|
+
* @name deposit
|
|
71
|
+
* @description Deposit additional funds into an existing escrow.
|
|
72
|
+
* @param agentWallet - The wallet of the agent associated with the escrow.
|
|
73
|
+
* @param amount - The amount to deposit (lamports for SOL, smallest unit for SPL).
|
|
74
|
+
* @param splAccounts - Remaining accounts for SPL token transfers. Defaults to `[]`.
|
|
75
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
76
|
+
* @since v0.1.0
|
|
77
|
+
*/
|
|
78
|
+
deposit(agentWallet: PublicKey, amount: BN | number | bigint, splAccounts?: AccountMeta[]): Promise<TransactionSignature>;
|
|
79
|
+
/**
|
|
80
|
+
* @name settle
|
|
81
|
+
* @description Agent settles calls — claims earned funds from the escrow.
|
|
82
|
+
* Must be called by the agent owner wallet.
|
|
83
|
+
* @param depositorWallet - The wallet of the client who funded the escrow.
|
|
84
|
+
* @param callsToSettle - Number of calls to settle payment for.
|
|
85
|
+
* @param serviceHash - A 32-byte SHA-256 hash identifying the service rendered.
|
|
86
|
+
* @param splAccounts - Remaining accounts for SPL token transfers. Defaults to `[]`.
|
|
87
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
88
|
+
* @since v0.1.0
|
|
89
|
+
*/
|
|
90
|
+
settle(depositorWallet: PublicKey, callsToSettle: BN | number | bigint, serviceHash: number[], splAccounts?: AccountMeta[]): Promise<TransactionSignature>;
|
|
91
|
+
/**
|
|
92
|
+
* @name withdraw
|
|
93
|
+
* @description Client withdraws un-settled funds from their escrow.
|
|
94
|
+
* @param agentWallet - The wallet of the agent associated with the escrow.
|
|
95
|
+
* @param amount - The amount to withdraw (lamports for SOL, smallest unit for SPL).
|
|
96
|
+
* @param splAccounts - Remaining accounts for SPL token transfers. Defaults to `[]`.
|
|
97
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
98
|
+
* @since v0.1.0
|
|
99
|
+
*/
|
|
100
|
+
withdraw(agentWallet: PublicKey, amount: BN | number | bigint, splAccounts?: AccountMeta[]): Promise<TransactionSignature>;
|
|
101
|
+
/**
|
|
102
|
+
* @name close
|
|
103
|
+
* @description Close an empty escrow PDA (balance must be 0) and reclaim rent.
|
|
104
|
+
* @param agentWallet - The wallet of the agent associated with the escrow.
|
|
105
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
106
|
+
* @since v0.1.0
|
|
107
|
+
*/
|
|
108
|
+
close(agentWallet: PublicKey): Promise<TransactionSignature>;
|
|
109
|
+
/**
|
|
110
|
+
* @name settleBatch
|
|
111
|
+
* @description Batch settlement — process up to 10 settlements in a single
|
|
112
|
+
* transaction. Must be called by the agent owner wallet.
|
|
113
|
+
* @param depositorWallet - The wallet of the client who funded the escrow.
|
|
114
|
+
* @param settlements - Array of settlement entries (up to 10).
|
|
115
|
+
* @param splAccounts - Remaining accounts for SPL token transfers. Defaults to `[]`.
|
|
116
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
117
|
+
* @since v0.1.0
|
|
118
|
+
*/
|
|
119
|
+
settleBatch(depositorWallet: PublicKey, settlements: Settlement[], splAccounts?: AccountMeta[]): Promise<TransactionSignature>;
|
|
120
|
+
/**
|
|
121
|
+
* @name fetch
|
|
122
|
+
* @description Fetch a deserialized `EscrowAccount`.
|
|
123
|
+
* @param agentPda - The agent account PDA.
|
|
124
|
+
* @param depositor - The depositor wallet. Defaults to the connected wallet.
|
|
125
|
+
* @returns {Promise<EscrowAccountData>} The escrow account data.
|
|
126
|
+
* @throws Will throw if the escrow account does not exist.
|
|
127
|
+
* @since v0.1.0
|
|
128
|
+
*/
|
|
129
|
+
fetch(agentPda: PublicKey, depositor?: PublicKey): Promise<EscrowAccountData>;
|
|
130
|
+
/**
|
|
131
|
+
* @name fetchNullable
|
|
132
|
+
* @description Fetch a deserialized `EscrowAccount`, or `null` if it
|
|
133
|
+
* does not exist on-chain.
|
|
134
|
+
* @param agentPda - The agent account PDA.
|
|
135
|
+
* @param depositor - The depositor wallet. Defaults to the connected wallet.
|
|
136
|
+
* @returns {Promise<EscrowAccountData | null>} The escrow data or `null`.
|
|
137
|
+
* @since v0.1.0
|
|
138
|
+
*/
|
|
139
|
+
fetchNullable(agentPda: PublicKey, depositor?: PublicKey): Promise<EscrowAccountData | null>;
|
|
140
|
+
/**
|
|
141
|
+
* @name fetchByPda
|
|
142
|
+
* @description Fetch an escrow account by its PDA address directly,
|
|
143
|
+
* bypassing PDA derivation.
|
|
144
|
+
* @param escrowPda - The escrow PDA public key.
|
|
145
|
+
* @returns {Promise<EscrowAccountData>} The escrow account data.
|
|
146
|
+
* @throws Will throw if the escrow account does not exist.
|
|
147
|
+
* @since v0.1.0
|
|
148
|
+
*/
|
|
149
|
+
fetchByPda(escrowPda: PublicKey): Promise<EscrowAccountData>;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=escrow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../../../src/modules/escrow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAMpC,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACX,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAG1C;;;;;;;;OAQG;IACH,YAAY,CACV,QAAQ,EAAE,SAAS,EACnB,SAAS,CAAC,EAAE,SAAS,GACpB,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAM/B;;;;;;;;;;;;;;OAcG;IACG,MAAM,CACV,WAAW,EAAE,SAAS,EACtB,IAAI,EAAE,gBAAgB,EACtB,WAAW,GAAE,WAAW,EAAO,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IA0BhC;;;;;;;;OAQG;IACG,OAAO,CACX,WAAW,EAAE,SAAS,EACtB,MAAM,EAAE,EAAE,GAAG,MAAM,GAAG,MAAM,EAC5B,WAAW,GAAE,WAAW,EAAO,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;;;;;OAUG;IACG,MAAM,CACV,eAAe,EAAE,SAAS,EAC1B,aAAa,EAAE,EAAE,GAAG,MAAM,GAAG,MAAM,EACnC,WAAW,EAAE,MAAM,EAAE,EACrB,WAAW,GAAE,WAAW,EAAO,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IAkBhC;;;;;;;;OAQG;IACG,QAAQ,CACZ,WAAW,EAAE,SAAS,EACtB,MAAM,EAAE,EAAE,GAAG,MAAM,GAAG,MAAM,EAC5B,WAAW,GAAE,WAAW,EAAO,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;OAMG;IACG,KAAK,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAalE;;;;;;;;;OASG;IACG,WAAW,CACf,eAAe,EAAE,SAAS,EAC1B,WAAW,EAAE,UAAU,EAAE,EACzB,WAAW,GAAE,WAAW,EAAO,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IAoBhC;;;;;;;;OAQG;IACG,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKnF;;;;;;;;OAQG;IACG,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAKlG;;;;;;;;OAQG;IACG,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAGnE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module feedback
|
|
3
|
+
* @description Trustless reputation system — give, update, revoke, and close
|
|
4
|
+
* on-chain feedback entries for agents.
|
|
5
|
+
*
|
|
6
|
+
* Feedback entries are PDA-based reviews tied to an agent and a reviewer wallet,
|
|
7
|
+
* enabling permissionless, verifiable reputation on Solana.
|
|
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 { FeedbackAccountData, GiveFeedbackArgs, UpdateFeedbackArgs } from "../types";
|
|
16
|
+
/**
|
|
17
|
+
* @name FeedbackModule
|
|
18
|
+
* @description Manages on-chain feedback entries for the Solana Agent Protocol.
|
|
19
|
+
* Provides methods to give, update, revoke, close, and fetch feedback PDAs
|
|
20
|
+
* that form the trustless reputation layer.
|
|
21
|
+
*
|
|
22
|
+
* @category Modules
|
|
23
|
+
* @since v0.1.0
|
|
24
|
+
* @extends BaseModule
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const sap = new SapClient(provider);
|
|
29
|
+
* const sig = await sap.feedback.give(agentWallet, {
|
|
30
|
+
* score: 5,
|
|
31
|
+
* tag: { quality: {} },
|
|
32
|
+
* commentHash: null,
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class FeedbackModule extends BaseModule {
|
|
37
|
+
/**
|
|
38
|
+
* @name deriveFeedback
|
|
39
|
+
* @description Derive the `FeedbackAccount` PDA for a given agent and reviewer.
|
|
40
|
+
* @param agentPda - The agent account PDA to review.
|
|
41
|
+
* @param reviewer - The reviewer wallet. Defaults to the connected wallet.
|
|
42
|
+
* @returns A tuple of `[PublicKey, bump]` for the feedback PDA.
|
|
43
|
+
* @see {@link deriveFeedback} from `pda/` module for the underlying derivation.
|
|
44
|
+
* @since v0.1.0
|
|
45
|
+
*/
|
|
46
|
+
deriveFeedback(agentPda: PublicKey, reviewer?: PublicKey): readonly [PublicKey, number];
|
|
47
|
+
/**
|
|
48
|
+
* @name give
|
|
49
|
+
* @description Leave on-chain feedback for an agent. Creates a new
|
|
50
|
+
* `FeedbackAccount` PDA owned by the reviewer.
|
|
51
|
+
* @param agentWallet - The wallet that owns the target agent.
|
|
52
|
+
* @param args - Feedback parameters (score, tag, optional comment hash).
|
|
53
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
54
|
+
* @since v0.1.0
|
|
55
|
+
*/
|
|
56
|
+
give(agentWallet: PublicKey, args: GiveFeedbackArgs): Promise<TransactionSignature>;
|
|
57
|
+
/**
|
|
58
|
+
* @name update
|
|
59
|
+
* @description Update an existing feedback entry. Only the original reviewer
|
|
60
|
+
* may update their feedback.
|
|
61
|
+
* @param agentWallet - The wallet that owns the target agent.
|
|
62
|
+
* @param args - Updated feedback parameters (new score, optional new tag, optional comment hash).
|
|
63
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
64
|
+
* @since v0.1.0
|
|
65
|
+
*/
|
|
66
|
+
update(agentWallet: PublicKey, args: UpdateFeedbackArgs): Promise<TransactionSignature>;
|
|
67
|
+
/**
|
|
68
|
+
* @name revoke
|
|
69
|
+
* @description Revoke a feedback entry, marking it as revoked and excluding
|
|
70
|
+
* it from reputation calculations.
|
|
71
|
+
* @param agentWallet - The wallet that owns the target agent.
|
|
72
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
73
|
+
* @since v0.1.0
|
|
74
|
+
*/
|
|
75
|
+
revoke(agentWallet: PublicKey): Promise<TransactionSignature>;
|
|
76
|
+
/**
|
|
77
|
+
* @name close
|
|
78
|
+
* @description Close a revoked feedback PDA and reclaim rent to the reviewer.
|
|
79
|
+
* @param agentWallet - The wallet that owns the target agent.
|
|
80
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
81
|
+
* @since v0.1.0
|
|
82
|
+
*/
|
|
83
|
+
close(agentWallet: PublicKey): Promise<TransactionSignature>;
|
|
84
|
+
/**
|
|
85
|
+
* @name fetch
|
|
86
|
+
* @description Fetch a deserialized `FeedbackAccount`.
|
|
87
|
+
* @param agentPda - The agent account PDA.
|
|
88
|
+
* @param reviewer - The reviewer wallet. Defaults to the connected wallet.
|
|
89
|
+
* @returns {Promise<FeedbackAccountData>} The feedback account data.
|
|
90
|
+
* @throws Will throw if the feedback account does not exist.
|
|
91
|
+
* @since v0.1.0
|
|
92
|
+
*/
|
|
93
|
+
fetch(agentPda: PublicKey, reviewer?: PublicKey): Promise<FeedbackAccountData>;
|
|
94
|
+
/**
|
|
95
|
+
* @name fetchNullable
|
|
96
|
+
* @description Fetch a deserialized `FeedbackAccount`, or `null` if it
|
|
97
|
+
* does not exist on-chain.
|
|
98
|
+
* @param agentPda - The agent account PDA.
|
|
99
|
+
* @param reviewer - The reviewer wallet. Defaults to the connected wallet.
|
|
100
|
+
* @returns {Promise<FeedbackAccountData | null>} The feedback data or `null`.
|
|
101
|
+
* @since v0.1.0
|
|
102
|
+
*/
|
|
103
|
+
fetchNullable(agentPda: PublicKey, reviewer?: PublicKey): Promise<FeedbackAccountData | null>;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=feedback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../../../src/modules/feedback.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,mBAAmB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE1F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAG5C;;;;;;;;OAQG;IACH,cAAc,CACZ,QAAQ,EAAE,SAAS,EACnB,QAAQ,CAAC,EAAE,SAAS,GACnB,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAM/B;;;;;;;;OAQG;IACG,IAAI,CACR,WAAW,EAAE,SAAS,EACtB,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,oBAAoB,CAAC;IAiBhC;;;;;;;;OAQG;IACG,MAAM,CACV,WAAW,EAAE,SAAS,EACtB,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,oBAAoB,CAAC;IAchC;;;;;;;OAOG;IACG,MAAM,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAcnE;;;;;;OAMG;IACG,KAAK,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAelE;;;;;;;;OAQG;IACG,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAKpF;;;;;;;;OAQG;IACG,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;CAIpG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module modules
|
|
3
|
+
* @description Barrel export for all domain modules of the `@synapse-sap/sdk`.
|
|
4
|
+
*
|
|
5
|
+
* Re-exports every module class so consumers can import from a single entry point:
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { AgentModule, VaultModule } from "@synapse-sap/sdk/modules";
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @category Modules
|
|
11
|
+
* @since v0.1.0
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
export { AgentModule } from "./agent";
|
|
15
|
+
export { FeedbackModule } from "./feedback";
|
|
16
|
+
export { IndexingModule } from "./indexing";
|
|
17
|
+
export { ToolsModule } from "./tools";
|
|
18
|
+
export { VaultModule } from "./vault";
|
|
19
|
+
export { EscrowModule } from "./escrow";
|
|
20
|
+
export { AttestationModule } from "./attestation";
|
|
21
|
+
export { LedgerModule } from "./ledger";
|
|
22
|
+
export { BaseModule } from "./base";
|
|
23
|
+
export type { SapProgram, SapTransactionResult } from "./base";
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module indexing
|
|
3
|
+
* @description Scalable discovery layer — capability indexes, protocol indexes,
|
|
4
|
+
* and tool category indexes for the Solana Agent Protocol.
|
|
5
|
+
*
|
|
6
|
+
* Indexes are shared PDA-based registries that map agents and tools to
|
|
7
|
+
* discovery dimensions, enabling efficient on-chain lookups.
|
|
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 { CapabilityIndexData, ProtocolIndexData, ToolCategoryIndexData } from "../types";
|
|
16
|
+
/**
|
|
17
|
+
* @name IndexingModule
|
|
18
|
+
* @description Manages on-chain discovery indexes for the Solana Agent Protocol.
|
|
19
|
+
* Provides methods to create, populate, prune, close, and fetch capability
|
|
20
|
+
* indexes, protocol indexes, and tool category indexes.
|
|
21
|
+
*
|
|
22
|
+
* @category Modules
|
|
23
|
+
* @since v0.1.0
|
|
24
|
+
* @extends BaseModule
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const sap = new SapClient(provider);
|
|
29
|
+
* // Create a capability index and add your agent
|
|
30
|
+
* await sap.indexing.initCapabilityIndex("text-generation");
|
|
31
|
+
* // Query agents by capability
|
|
32
|
+
* const idx = await sap.indexing.fetchCapabilityIndex("text-generation");
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class IndexingModule extends BaseModule {
|
|
36
|
+
/**
|
|
37
|
+
* @name hash
|
|
38
|
+
* @description Hash a capability or protocol ID string for use as a PDA seed.
|
|
39
|
+
* Uses SHA-256 internally.
|
|
40
|
+
* @param id - The capability or protocol identifier string.
|
|
41
|
+
* @returns {Uint8Array} The 32-byte SHA-256 hash.
|
|
42
|
+
* @since v0.1.0
|
|
43
|
+
*/
|
|
44
|
+
hash(id: string): Uint8Array;
|
|
45
|
+
/**
|
|
46
|
+
* @name initCapabilityIndex
|
|
47
|
+
* @description Create a new capability index and register the caller’s agent.
|
|
48
|
+
* The capability ID is hashed to derive the PDA.
|
|
49
|
+
* @param capabilityId - Human-readable capability identifier (e.g. `"text-generation"`).
|
|
50
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
51
|
+
* @since v0.1.0
|
|
52
|
+
*/
|
|
53
|
+
initCapabilityIndex(capabilityId: string): Promise<TransactionSignature>;
|
|
54
|
+
/**
|
|
55
|
+
* @name addToCapabilityIndex
|
|
56
|
+
* @description Add the caller’s agent to an existing capability index.
|
|
57
|
+
* @param capabilityId - The capability identifier string.
|
|
58
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
59
|
+
* @since v0.1.0
|
|
60
|
+
*/
|
|
61
|
+
addToCapabilityIndex(capabilityId: string): Promise<TransactionSignature>;
|
|
62
|
+
/**
|
|
63
|
+
* @name removeFromCapabilityIndex
|
|
64
|
+
* @description Remove the caller’s agent from a capability index.
|
|
65
|
+
* @param capabilityId - The capability identifier string.
|
|
66
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
67
|
+
* @since v0.1.0
|
|
68
|
+
*/
|
|
69
|
+
removeFromCapabilityIndex(capabilityId: string): Promise<TransactionSignature>;
|
|
70
|
+
/**
|
|
71
|
+
* @name closeCapabilityIndex
|
|
72
|
+
* @description Close an empty capability index PDA and reclaim rent.
|
|
73
|
+
* @param capabilityId - The capability identifier string.
|
|
74
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
75
|
+
* @since v0.1.0
|
|
76
|
+
*/
|
|
77
|
+
closeCapabilityIndex(capabilityId: string): Promise<TransactionSignature>;
|
|
78
|
+
/**
|
|
79
|
+
* @name initProtocolIndex
|
|
80
|
+
* @description Create a new protocol index and register the caller’s agent.
|
|
81
|
+
* The protocol ID is hashed to derive the PDA.
|
|
82
|
+
* @param protocolId - Human-readable protocol identifier (e.g. `"mcp-v1"`).
|
|
83
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
84
|
+
* @since v0.1.0
|
|
85
|
+
*/
|
|
86
|
+
initProtocolIndex(protocolId: string): Promise<TransactionSignature>;
|
|
87
|
+
/**
|
|
88
|
+
* @name addToProtocolIndex
|
|
89
|
+
* @description Add the caller’s agent to an existing protocol index.
|
|
90
|
+
* @param protocolId - The protocol identifier string.
|
|
91
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
92
|
+
* @since v0.1.0
|
|
93
|
+
*/
|
|
94
|
+
addToProtocolIndex(protocolId: string): Promise<TransactionSignature>;
|
|
95
|
+
/**
|
|
96
|
+
* @name removeFromProtocolIndex
|
|
97
|
+
* @description Remove the caller’s agent from a protocol index.
|
|
98
|
+
* @param protocolId - The protocol identifier string.
|
|
99
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
100
|
+
* @since v0.1.0
|
|
101
|
+
*/
|
|
102
|
+
removeFromProtocolIndex(protocolId: string): Promise<TransactionSignature>;
|
|
103
|
+
/**
|
|
104
|
+
* @name closeProtocolIndex
|
|
105
|
+
* @description Close an empty protocol index PDA and reclaim rent.
|
|
106
|
+
* @param protocolId - The protocol identifier string.
|
|
107
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
108
|
+
* @since v0.1.0
|
|
109
|
+
*/
|
|
110
|
+
closeProtocolIndex(protocolId: string): Promise<TransactionSignature>;
|
|
111
|
+
/**
|
|
112
|
+
* @name initToolCategoryIndex
|
|
113
|
+
* @description Create a new tool category index PDA.
|
|
114
|
+
* @param category - Numeric tool category enum value.
|
|
115
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
116
|
+
* @since v0.1.0
|
|
117
|
+
*/
|
|
118
|
+
initToolCategoryIndex(category: number): Promise<TransactionSignature>;
|
|
119
|
+
/**
|
|
120
|
+
* @name addToToolCategory
|
|
121
|
+
* @description Add a tool to its matching category index.
|
|
122
|
+
* @param category - Numeric tool category enum value.
|
|
123
|
+
* @param toolPda - The tool descriptor PDA to add.
|
|
124
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
125
|
+
* @since v0.1.0
|
|
126
|
+
*/
|
|
127
|
+
addToToolCategory(category: number, toolPda: PublicKey): Promise<TransactionSignature>;
|
|
128
|
+
/**
|
|
129
|
+
* @name removeFromToolCategory
|
|
130
|
+
* @description Remove a tool from a category index.
|
|
131
|
+
* @param category - Numeric tool category enum value.
|
|
132
|
+
* @param toolPda - The tool descriptor PDA to remove.
|
|
133
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
134
|
+
* @since v0.1.0
|
|
135
|
+
*/
|
|
136
|
+
removeFromToolCategory(category: number, toolPda: PublicKey): Promise<TransactionSignature>;
|
|
137
|
+
/**
|
|
138
|
+
* @name closeToolCategoryIndex
|
|
139
|
+
* @description Close an empty tool category index PDA and reclaim rent.
|
|
140
|
+
* @param category - Numeric tool category enum value.
|
|
141
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
142
|
+
* @since v0.1.0
|
|
143
|
+
*/
|
|
144
|
+
closeToolCategoryIndex(category: number): Promise<TransactionSignature>;
|
|
145
|
+
/**
|
|
146
|
+
* @name fetchCapabilityIndex
|
|
147
|
+
* @description Fetch a deserialized `CapabilityIndex` account by capability ID.
|
|
148
|
+
* @param capabilityId - The capability identifier string.
|
|
149
|
+
* @returns {Promise<CapabilityIndexData>} The capability index data.
|
|
150
|
+
* @throws Will throw if the capability index does not exist.
|
|
151
|
+
* @since v0.1.0
|
|
152
|
+
*/
|
|
153
|
+
fetchCapabilityIndex(capabilityId: string): Promise<CapabilityIndexData>;
|
|
154
|
+
/**
|
|
155
|
+
* @name fetchCapabilityIndexNullable
|
|
156
|
+
* @description Fetch a deserialized `CapabilityIndex` account, or `null`
|
|
157
|
+
* if it does not exist on-chain.
|
|
158
|
+
* @param capabilityId - The capability identifier string.
|
|
159
|
+
* @returns {Promise<CapabilityIndexData | null>} The capability index data or `null`.
|
|
160
|
+
* @since v0.1.0
|
|
161
|
+
*/
|
|
162
|
+
fetchCapabilityIndexNullable(capabilityId: string): Promise<CapabilityIndexData | null>;
|
|
163
|
+
/**
|
|
164
|
+
* @name fetchProtocolIndex
|
|
165
|
+
* @description Fetch a deserialized `ProtocolIndex` account by protocol ID.
|
|
166
|
+
* @param protocolId - The protocol identifier string.
|
|
167
|
+
* @returns {Promise<ProtocolIndexData>} The protocol index data.
|
|
168
|
+
* @throws Will throw if the protocol index does not exist.
|
|
169
|
+
* @since v0.1.0
|
|
170
|
+
*/
|
|
171
|
+
fetchProtocolIndex(protocolId: string): Promise<ProtocolIndexData>;
|
|
172
|
+
/**
|
|
173
|
+
* @name fetchProtocolIndexNullable
|
|
174
|
+
* @description Fetch a deserialized `ProtocolIndex` account, or `null`
|
|
175
|
+
* if it does not exist on-chain.
|
|
176
|
+
* @param protocolId - The protocol identifier string.
|
|
177
|
+
* @returns {Promise<ProtocolIndexData | null>} The protocol index data or `null`.
|
|
178
|
+
* @since v0.1.0
|
|
179
|
+
*/
|
|
180
|
+
fetchProtocolIndexNullable(protocolId: string): Promise<ProtocolIndexData | null>;
|
|
181
|
+
/**
|
|
182
|
+
* @name fetchToolCategoryIndex
|
|
183
|
+
* @description Fetch a deserialized `ToolCategoryIndex` account by category number.
|
|
184
|
+
* @param category - Numeric tool category enum value.
|
|
185
|
+
* @returns {Promise<ToolCategoryIndexData>} The tool category index data.
|
|
186
|
+
* @throws Will throw if the tool category index does not exist.
|
|
187
|
+
* @since v0.1.0
|
|
188
|
+
*/
|
|
189
|
+
fetchToolCategoryIndex(category: number): Promise<ToolCategoryIndexData>;
|
|
190
|
+
/**
|
|
191
|
+
* @name fetchToolCategoryIndexNullable
|
|
192
|
+
* @description Fetch a deserialized `ToolCategoryIndex` account, or `null`
|
|
193
|
+
* if it does not exist on-chain.
|
|
194
|
+
* @param category - Numeric tool category enum value.
|
|
195
|
+
* @returns {Promise<ToolCategoryIndexData | null>} The tool category index data or `null`.
|
|
196
|
+
* @since v0.1.0
|
|
197
|
+
*/
|
|
198
|
+
fetchToolCategoryIndexNullable(category: number): Promise<ToolCategoryIndexData | null>;
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=indexing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexing.d.ts","sourceRoot":"","sources":["../../../src/modules/indexing.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;AAQpC,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAG5C;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAM5B;;;;;;;OAOG;IACG,mBAAmB,CACvB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,oBAAoB,CAAC;IAkBhC;;;;;;OAMG;IACG,oBAAoB,CACxB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;OAMG;IACG,yBAAyB,CAC7B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;OAMG;IACG,oBAAoB,CACxB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,oBAAoB,CAAC;IAiBhC;;;;;;;OAOG;IACG,iBAAiB,CACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,oBAAoB,CAAC;IAkBhC;;;;;;OAMG;IACG,kBAAkB,CACtB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;OAMG;IACG,uBAAuB,CAC3B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;OAMG;IACG,kBAAkB,CACtB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,oBAAoB,CAAC;IAiBhC;;;;;;OAMG;IACG,qBAAqB,CACzB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,oBAAoB,CAAC;IAahC;;;;;;;OAOG;IACG,iBAAiB,CACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;;OAOG;IACG,sBAAsB,CAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;OAMG;IACG,sBAAsB,CAC1B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,oBAAoB,CAAC;IAchC;;;;;;;OAOG;IACG,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAK9E;;;;;;;OAOG;IACG,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAK7F;;;;;;;OAOG;IACG,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKxE;;;;;;;OAOG;IACG,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAKvF;;;;;;;OAOG;IACG,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAK9E;;;;;;;OAOG;IACG,8BAA8B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;CAI9F"}
|