@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,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module types/enums
|
|
3
|
+
* @description Anchor-compatible enum variant objects for SAP v2.
|
|
4
|
+
*
|
|
5
|
+
* Each enum mirrors the Rust discriminant format used by Anchor:
|
|
6
|
+
* `{ variant: {} }` — e.g. `{ sol: {} }` for `TokenType::Sol`.
|
|
7
|
+
*
|
|
8
|
+
* Use the `*Kind` types for function signatures.
|
|
9
|
+
*
|
|
10
|
+
* @category Types
|
|
11
|
+
* @since v0.1.0
|
|
12
|
+
* @see {@link https://solana.com/docs | Solana Docs}
|
|
13
|
+
*/
|
|
14
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
15
|
+
// Token Type
|
|
16
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
17
|
+
/**
|
|
18
|
+
* @name TokenType
|
|
19
|
+
* @description Anchor-compatible enum variants for token types accepted by agent pricing and escrow.
|
|
20
|
+
*
|
|
21
|
+
* - `Sol` — Native SOL.
|
|
22
|
+
* - `Usdc` — USDC stablecoin.
|
|
23
|
+
* - `Spl` — Arbitrary SPL token (requires `tokenMint`).
|
|
24
|
+
*
|
|
25
|
+
* @category Types
|
|
26
|
+
* @since v0.1.0
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { TokenType } from "@synapse-sap/sdk";
|
|
31
|
+
*
|
|
32
|
+
* const tier = { tokenType: TokenType.Sol };
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const TokenType = {
|
|
36
|
+
Sol: { sol: {} },
|
|
37
|
+
Usdc: { usdc: {} },
|
|
38
|
+
Spl: { spl: {} },
|
|
39
|
+
};
|
|
40
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
41
|
+
// Plugin Type
|
|
42
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
43
|
+
/**
|
|
44
|
+
* @name PluginType
|
|
45
|
+
* @description Anchor-compatible enum variants for plugin extension types.
|
|
46
|
+
*
|
|
47
|
+
* Plugins extend agent functionality and are feature-gated on-chain.
|
|
48
|
+
*
|
|
49
|
+
* - `Memory` — Encrypted memory / vault storage.
|
|
50
|
+
* - `Validation` — Custom validation logic.
|
|
51
|
+
* - `Delegation` — Hot-wallet delegation.
|
|
52
|
+
* - `Analytics` — Metrics & analytics.
|
|
53
|
+
* - `Governance` — DAO / governance participation.
|
|
54
|
+
* - `Custom` — User-defined plugin type.
|
|
55
|
+
*
|
|
56
|
+
* @category Types
|
|
57
|
+
* @since v0.1.0
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { PluginType } from "@synapse-sap/sdk";
|
|
62
|
+
*
|
|
63
|
+
* const ref = { pluginType: PluginType.Memory, pda: vaultPda };
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export const PluginType = {
|
|
67
|
+
Memory: { memory: {} },
|
|
68
|
+
Validation: { validation: {} },
|
|
69
|
+
Delegation: { delegation: {} },
|
|
70
|
+
Analytics: { analytics: {} },
|
|
71
|
+
Governance: { governance: {} },
|
|
72
|
+
Custom: { custom: {} },
|
|
73
|
+
};
|
|
74
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
75
|
+
// Settlement Mode
|
|
76
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
77
|
+
/**
|
|
78
|
+
* @name SettlementMode
|
|
79
|
+
* @description Anchor-compatible enum variants for payment settlement strategies.
|
|
80
|
+
*
|
|
81
|
+
* - `Instant` — Pay-per-call, settled immediately on invocation.
|
|
82
|
+
* - `Escrow` — Pre-funded escrow account with per-call drawdown.
|
|
83
|
+
* - `Batched` — Aggregated settlement at fixed intervals.
|
|
84
|
+
* - `X402` — HTTP 402-based micropayment protocol settlement.
|
|
85
|
+
*
|
|
86
|
+
* @category Types
|
|
87
|
+
* @since v0.1.0
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* import { SettlementMode } from "@synapse-sap/sdk";
|
|
92
|
+
*
|
|
93
|
+
* const tier = { settlementMode: SettlementMode.Escrow };
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export const SettlementMode = {
|
|
97
|
+
Instant: { instant: {} },
|
|
98
|
+
Escrow: { escrow: {} },
|
|
99
|
+
Batched: { batched: {} },
|
|
100
|
+
X402: { x402: {} },
|
|
101
|
+
};
|
|
102
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
103
|
+
// Tool HTTP Method
|
|
104
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
105
|
+
/**
|
|
106
|
+
* @name ToolHttpMethod
|
|
107
|
+
* @description Anchor-compatible enum variants for the HTTP method exposed by a tool.
|
|
108
|
+
*
|
|
109
|
+
* - `Get` / `Post` / `Put` / `Delete` — Standard REST verbs.
|
|
110
|
+
* - `Compound` — Multi-step tool (calls several sub-operations).
|
|
111
|
+
*
|
|
112
|
+
* @category Types
|
|
113
|
+
* @since v0.1.0
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* import { ToolHttpMethod } from "@synapse-sap/sdk";
|
|
118
|
+
*
|
|
119
|
+
* const args = { httpMethod: ToolHttpMethod.Post };
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export const ToolHttpMethod = {
|
|
123
|
+
Get: { get: {} },
|
|
124
|
+
Post: { post: {} },
|
|
125
|
+
Put: { put: {} },
|
|
126
|
+
Delete: { delete: {} },
|
|
127
|
+
Compound: { compound: {} },
|
|
128
|
+
};
|
|
129
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
130
|
+
// Tool Category
|
|
131
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
132
|
+
/**
|
|
133
|
+
* @name ToolCategory
|
|
134
|
+
* @description Anchor-compatible enum variants for classifying tools in the on-chain registry.
|
|
135
|
+
*
|
|
136
|
+
* Categories power cross-agent tool discovery via the `ToolCategoryIndex` PDA.
|
|
137
|
+
*
|
|
138
|
+
* - `Swap` — Token swap / DEX tools.
|
|
139
|
+
* - `Lend` — Lending protocol tools.
|
|
140
|
+
* - `Stake` — Staking / validator tools.
|
|
141
|
+
* - `Nft` — NFT minting / marketplace tools.
|
|
142
|
+
* - `Payment` — Payment & invoicing tools.
|
|
143
|
+
* - `Data` — Data feeds / oracles.
|
|
144
|
+
* - `Governance` — DAO & governance tools.
|
|
145
|
+
* - `Bridge` — Cross-chain bridge tools.
|
|
146
|
+
* - `Analytics` — On-chain analytics.
|
|
147
|
+
* - `Custom` — User-defined category.
|
|
148
|
+
*
|
|
149
|
+
* @category Types
|
|
150
|
+
* @since v0.1.0
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* import { ToolCategory } from "@synapse-sap/sdk";
|
|
155
|
+
*
|
|
156
|
+
* const args = { category: ToolCategory.Swap };
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
export const ToolCategory = {
|
|
160
|
+
Swap: { swap: {} },
|
|
161
|
+
Lend: { lend: {} },
|
|
162
|
+
Stake: { stake: {} },
|
|
163
|
+
Nft: { nft: {} },
|
|
164
|
+
Payment: { payment: {} },
|
|
165
|
+
Data: { data: {} },
|
|
166
|
+
Governance: { governance: {} },
|
|
167
|
+
Bridge: { bridge: {} },
|
|
168
|
+
Analytics: { analytics: {} },
|
|
169
|
+
Custom: { custom: {} },
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=enums.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/types/enums.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,sEAAsE;AACtE,cAAc;AACd,sEAAsE;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;IAChB,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IAClB,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;CACR,CAAC;AASX,sEAAsE;AACtE,eAAe;AACf,sEAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACtB,UAAU,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IAC9B,UAAU,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IAC9B,SAAS,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IAC5B,UAAU,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IAC9B,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;CACd,CAAC;AAQX,sEAAsE;AACtE,mBAAmB;AACnB,sEAAsE;AAEtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IACxB,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACtB,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IACxB,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;CACV,CAAC;AASX,sEAAsE;AACtE,oBAAoB;AACpB,sEAAsE;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;IAChB,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IAClB,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;IAChB,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACtB,QAAQ,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;CAClB,CAAC;AASX,sEAAsE;AACtE,iBAAiB;AACjB,sEAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IAClB,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IAClB,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;IACpB,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;IAChB,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IACxB,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IAClB,UAAU,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IAC9B,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACtB,SAAS,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IAC5B,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;CACd,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module types
|
|
3
|
+
* @description Strongly-typed domain models for SAP v2.
|
|
4
|
+
*
|
|
5
|
+
* Every type mirrors the onchain Rust struct / enum exactly.
|
|
6
|
+
* Types are organized into four layers:
|
|
7
|
+
*
|
|
8
|
+
* - **enums** — Anchor-style enum variant objects (`TokenType`, `ToolCategory`, …)
|
|
9
|
+
* - **common** — Shared helper structs (`Capability`, `PricingTier`, `Settlement`, …)
|
|
10
|
+
* - **accounts** — Deserialized on-chain PDA account data (`AgentAccountData`, …)
|
|
11
|
+
* - **instructions** — Instruction argument DTOs + permission/schema helpers
|
|
12
|
+
*
|
|
13
|
+
* @category Types
|
|
14
|
+
* @since v0.1.0
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import type { AgentAccountData, RegisterAgentArgs } from "@synapse-sap/sdk/types";
|
|
19
|
+
* import { TokenType, SettlementMode } from "@synapse-sap/sdk/types";
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
// ── Enums ────────────────────────────────────────────
|
|
23
|
+
export { TokenType, PluginType, SettlementMode, ToolHttpMethod, ToolCategory, } from "./enums";
|
|
24
|
+
export { DelegatePermission, SchemaType, CompressionType, } from "./instructions";
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,wDAAwD;AACxD,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,YAAY,GACb,MAAM,SAAS,CAAC;AA0DjB,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,eAAe,GAChB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module types/instructions
|
|
3
|
+
* @description Instruction argument DTOs and helper enumerations.
|
|
4
|
+
*
|
|
5
|
+
* These interfaces map 1:1 to the Anchor instruction argument structs.
|
|
6
|
+
* Use them when calling SDK module methods.
|
|
7
|
+
*
|
|
8
|
+
* @category Types
|
|
9
|
+
* @since v0.1.0
|
|
10
|
+
*/
|
|
11
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
12
|
+
// Permission & Schema Helpers
|
|
13
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
14
|
+
/**
|
|
15
|
+
* @name DelegatePermission
|
|
16
|
+
* @description Bitmask constants for vault delegate permissions.
|
|
17
|
+
*
|
|
18
|
+
* Combine with bitwise OR to grant multiple permissions.
|
|
19
|
+
*
|
|
20
|
+
* | Bit | Value | Permission |
|
|
21
|
+
* | --- | ----- | ------------------- |
|
|
22
|
+
* | 0 | 1 | Inscribe memories |
|
|
23
|
+
* | 1 | 2 | Close sessions |
|
|
24
|
+
* | 2 | 4 | Open sessions |
|
|
25
|
+
* | — | 7 | All permissions |
|
|
26
|
+
*
|
|
27
|
+
* @category Types
|
|
28
|
+
* @since v0.1.0
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { DelegatePermission } from "@synapse-sap/sdk";
|
|
33
|
+
*
|
|
34
|
+
* // Grant inscribe + open session
|
|
35
|
+
* const perms = DelegatePermission.Inscribe | DelegatePermission.OpenSession;
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export const DelegatePermission = {
|
|
39
|
+
Inscribe: 1,
|
|
40
|
+
CloseSession: 2,
|
|
41
|
+
OpenSession: 4,
|
|
42
|
+
All: 7,
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @name SchemaType
|
|
46
|
+
* @description Numeric discriminants for tool schema types.
|
|
47
|
+
*
|
|
48
|
+
* Used in the `inscribeToolSchema` instruction to specify which schema
|
|
49
|
+
* is being written on-chain.
|
|
50
|
+
*
|
|
51
|
+
* @category Types
|
|
52
|
+
* @since v0.1.0
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { SchemaType } from "@synapse-sap/sdk";
|
|
57
|
+
*
|
|
58
|
+
* const args = { schemaType: SchemaType.Input, ... };
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export const SchemaType = {
|
|
62
|
+
Input: 0,
|
|
63
|
+
Output: 1,
|
|
64
|
+
Description: 2,
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* @name CompressionType
|
|
68
|
+
* @description Numeric discriminants for compression algorithms.
|
|
69
|
+
*
|
|
70
|
+
* Used in inscription instructions to declare the compression format
|
|
71
|
+
* of the payload so consumers can decompress correctly.
|
|
72
|
+
*
|
|
73
|
+
* @category Types
|
|
74
|
+
* @since v0.1.0
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { CompressionType } from "@synapse-sap/sdk";
|
|
79
|
+
*
|
|
80
|
+
* const args = { compression: CompressionType.Gzip, ... };
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export const CompressionType = {
|
|
84
|
+
None: 0,
|
|
85
|
+
Deflate: 1,
|
|
86
|
+
Gzip: 2,
|
|
87
|
+
Brotli: 3,
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=instructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../../src/types/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA+SH,sEAAsE;AACtE,+BAA+B;AAC/B,sEAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE,CAAC;IACX,YAAY,EAAE,CAAC;IACf,WAAW,EAAE,CAAC;IACd,GAAG,EAAE,CAAC;CACE,CAAC;AASX;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,WAAW,EAAE,CAAC;CACN,CAAC;AAQX;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module utils/hash
|
|
3
|
+
* @description Cryptographic hashing utilities.
|
|
4
|
+
*
|
|
5
|
+
* @category Utils
|
|
6
|
+
* @since v0.1.0
|
|
7
|
+
*/
|
|
8
|
+
import { createHash } from "crypto";
|
|
9
|
+
/**
|
|
10
|
+
* Compute the SHA-256 hash of a UTF-8 string or byte buffer.
|
|
11
|
+
*
|
|
12
|
+
* Returns a 32-byte `Uint8Array` suitable for PDA seeds
|
|
13
|
+
* and Anchor instruction arguments.
|
|
14
|
+
*
|
|
15
|
+
* @name sha256
|
|
16
|
+
* @description Hashes the input using Node’s `crypto.createHash("sha256")`.
|
|
17
|
+
* @param input - A UTF-8 string, `Buffer`, or `Uint8Array` to hash.
|
|
18
|
+
* @returns {Uint8Array} 32-byte SHA-256 digest.
|
|
19
|
+
* @category Utils
|
|
20
|
+
* @since v0.1.0
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { sha256 } from "@synapse-sap/sdk/utils";
|
|
24
|
+
*
|
|
25
|
+
* const hash = sha256("jupiter:swap"); // Uint8Array (32 bytes)
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export const sha256 = (input) => {
|
|
29
|
+
const hash = createHash("sha256");
|
|
30
|
+
hash.update(typeof input === "string" ? Buffer.from(input, "utf-8") : input);
|
|
31
|
+
return new Uint8Array(hash.digest());
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Convert a `Uint8Array` hash to a plain `number[]`.
|
|
35
|
+
*
|
|
36
|
+
* Anchor instruction argument types expect `number[]` for hash fields
|
|
37
|
+
* rather than typed arrays.
|
|
38
|
+
*
|
|
39
|
+
* @name hashToArray
|
|
40
|
+
* @description Converts a byte array (typically 32 bytes) to a plain JavaScript `number[]`.
|
|
41
|
+
* @param hash - The byte array to convert.
|
|
42
|
+
* @returns {number[]} Shallow copy as a plain array of numbers.
|
|
43
|
+
* @category Utils
|
|
44
|
+
* @since v0.1.0
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { sha256, hashToArray } from "@synapse-sap/sdk/utils";
|
|
48
|
+
*
|
|
49
|
+
* const arr = hashToArray(sha256("jupiter:swap")); // number[]
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export const hashToArray = (hash) => Array.from(hash);
|
|
53
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../../src/utils/hash.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAmC,EAAc,EAAE;IACxE,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM,CACT,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAChE,CAAC;IACF,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAgB,EAAY,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module utils
|
|
3
|
+
* @description Shared utilities used across SDK modules.
|
|
4
|
+
*
|
|
5
|
+
* @category Utils
|
|
6
|
+
* @since v0.1.0
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { sha256, hashToArray, assert } from "@synapse-sap/sdk/utils";
|
|
11
|
+
*
|
|
12
|
+
* const hash = sha256("jupiter:swap");
|
|
13
|
+
* const arr = hashToArray(hash); // number[] for Anchor args
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export { sha256, hashToArray } from "./hash";
|
|
17
|
+
export { assert } from "./validation";
|
|
18
|
+
export { serializeAccount, serializeValue } from "./serialization";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module utils/serialization
|
|
3
|
+
* @description JSON-safe serialization helpers for on-chain account data.
|
|
4
|
+
*
|
|
5
|
+
* On-chain Anchor account objects contain `PublicKey` and `BN` instances
|
|
6
|
+
* that are not JSON-serializable. These helpers convert them to plain
|
|
7
|
+
* strings (`base58` and decimal `string`) recursively.
|
|
8
|
+
*
|
|
9
|
+
* @category Utils
|
|
10
|
+
* @since v0.1.0
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { serializeAccount } from "@synapse-sap/sdk/utils";
|
|
15
|
+
*
|
|
16
|
+
* const raw = await program.account.agent.fetch(pda);
|
|
17
|
+
* const json = serializeAccount(raw);
|
|
18
|
+
* // { authority: "GBL...", totalCalls: "42", ... }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { PublicKey } from "@solana/web3.js";
|
|
22
|
+
import BN from "bn.js";
|
|
23
|
+
/**
|
|
24
|
+
* Recursively convert a single value for JSON serialization.
|
|
25
|
+
*
|
|
26
|
+
* - `PublicKey` → base58 string
|
|
27
|
+
* - `BN` → decimal string
|
|
28
|
+
* - `Uint8Array` / `Buffer` → hex string
|
|
29
|
+
* - `Array` → recursed
|
|
30
|
+
* - plain `object` → recursed via {@link serializeAccount}
|
|
31
|
+
* - primitives → identity
|
|
32
|
+
*
|
|
33
|
+
* @name serializeValue
|
|
34
|
+
* @description Transforms a single Anchor-typed value into its JSON-safe equivalent.
|
|
35
|
+
* @param value - The value to serialize.
|
|
36
|
+
* @returns The JSON-safe representation of `value`.
|
|
37
|
+
* @category Utils
|
|
38
|
+
* @since v0.1.0
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { serializeValue } from "@synapse-sap/sdk/utils";
|
|
42
|
+
*
|
|
43
|
+
* serializeValue(new PublicKey("11111111111111111111111111111111")); // "1111..."
|
|
44
|
+
* serializeValue(new BN(42)); // "42"
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
export function serializeValue(value) {
|
|
49
|
+
if (value === null || value === undefined)
|
|
50
|
+
return null;
|
|
51
|
+
if (value instanceof PublicKey)
|
|
52
|
+
return value.toBase58();
|
|
53
|
+
if (BN.isBN(value))
|
|
54
|
+
return value.toString();
|
|
55
|
+
if (value instanceof Uint8Array || Buffer.isBuffer(value))
|
|
56
|
+
return Buffer.from(value).toString("hex");
|
|
57
|
+
if (Array.isArray(value))
|
|
58
|
+
return value.map(serializeValue);
|
|
59
|
+
if (typeof value === "object") {
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
return serializeAccount(value);
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Serialize an entire on-chain account object to a JSON-safe shape.
|
|
67
|
+
*
|
|
68
|
+
* Iterates over each key and delegates to {@link serializeValue}.
|
|
69
|
+
* Handles `PublicKey` → base58, `BN` → string, and nested
|
|
70
|
+
* objects / arrays recursively.
|
|
71
|
+
*
|
|
72
|
+
* @name serializeAccount
|
|
73
|
+
* @description Converts all non-primitive fields in an Anchor account record to JSON-safe strings.
|
|
74
|
+
* @param obj - The raw account object returned by `program.account.<name>.fetch()`.
|
|
75
|
+
* @returns A new plain object with all values converted.
|
|
76
|
+
* @category Utils
|
|
77
|
+
* @since v0.1.0
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* import { serializeAccount } from "@synapse-sap/sdk/utils";
|
|
81
|
+
*
|
|
82
|
+
* const raw = await program.account.agent.fetch(pda);
|
|
83
|
+
* const safe = serializeAccount(raw);
|
|
84
|
+
* console.log(JSON.stringify(safe));
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
|
+
export function serializeAccount(
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
+
obj) {
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
+
const result = {};
|
|
93
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
94
|
+
result[key] = serializeValue(value);
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=serialization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../../src/utils/serialization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,8DAA8D;AAC9D,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACvD,IAAI,KAAK,YAAY,SAAS;QAAE,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IACxD,IAAI,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC5C,IAAI,KAAK,YAAY,UAAU,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QACvD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,8DAA8D;QAC9D,OAAO,gBAAgB,CAAC,KAA4B,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,8DAA8D;AAC9D,MAAM,UAAU,gBAAgB;AAC9B,8DAA8D;AAC9D,GAAwB;IAGxB,8DAA8D;IAC9D,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module utils/validation
|
|
3
|
+
* @description Runtime assertion helpers.
|
|
4
|
+
*
|
|
5
|
+
* @category Utils
|
|
6
|
+
* @since v0.1.0
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Assert that a condition holds, throwing a descriptive error otherwise.
|
|
10
|
+
*
|
|
11
|
+
* Uses TypeScript’s `asserts condition` return type so the compiler
|
|
12
|
+
* narrows the guarded value after the call.
|
|
13
|
+
*
|
|
14
|
+
* @name assert
|
|
15
|
+
* @description Runtime guard — throws `RangeError` with a `[SAP SDK]` prefix when the condition is falsy.
|
|
16
|
+
* @param condition - The boolean expression to verify.
|
|
17
|
+
* @param message - Human-readable message included in the thrown error.
|
|
18
|
+
* @throws {RangeError} When `condition` is `false`.
|
|
19
|
+
* @category Utils
|
|
20
|
+
* @since v0.1.0
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { assert } from "@synapse-sap/sdk/utils";
|
|
24
|
+
*
|
|
25
|
+
* assert(name.length <= 64, "Agent name exceeds MAX_NAME_LEN");
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function assert(condition, message) {
|
|
29
|
+
if (!condition) {
|
|
30
|
+
throw new RangeError(`[SAP SDK] ${message}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,MAAM,CACpB,SAAkB,EAClB,OAAe;IAEf,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,UAAU,CAAC,aAAa,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module constants
|
|
3
|
+
* @description Protocol constants mirroring the on-chain Rust program.
|
|
4
|
+
*
|
|
5
|
+
* Organized into:
|
|
6
|
+
* - **programs** — Network-specific program IDs
|
|
7
|
+
* - **seeds** — PDA seed prefix strings
|
|
8
|
+
* - **limits** — Size constraints, versions, enum numeric values
|
|
9
|
+
*
|
|
10
|
+
* @category Constants
|
|
11
|
+
* @since v0.1.0
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import {
|
|
16
|
+
* MAINNET_SAP_PROGRAM_ID,
|
|
17
|
+
* DEVNET_SAP_PROGRAM_ID,
|
|
18
|
+
* SEEDS,
|
|
19
|
+
* LIMITS,
|
|
20
|
+
* } from "@synapse-sap/sdk/constants";
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export { SAP_PROGRAM_ADDRESS, MAINNET_SAP_PROGRAM_ID, DEVNET_SAP_PROGRAM_ID, LOCALNET_SAP_PROGRAM_ID, SAP_PROGRAM_ID, } from "./programs";
|
|
24
|
+
export { SEEDS } from "./seeds";
|
|
25
|
+
export type { SeedKey } from "./seeds";
|
|
26
|
+
export { LIMITS, AGENT_VERSION, VAULT_PROTOCOL_VERSION, TOOL_CATEGORY_VALUES, HTTP_METHOD_VALUES, } from "./limits";
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EACL,MAAM,EACN,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,UAAU,CAAC"}
|