@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,577 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module registries/x402
|
|
4
|
+
* @description x402 payment flow registry — high-level helpers for
|
|
5
|
+
* the complete x402 HTTP micropayment lifecycle.
|
|
6
|
+
*
|
|
7
|
+
* Implements the x402 payment standard on SAP:
|
|
8
|
+
*
|
|
9
|
+
* ┌──────────┐ HTTP 402 ┌──────────┐
|
|
10
|
+
* │ Client │ ──────────────→│ Agent │
|
|
11
|
+
* └────┬─────┘ └────┬─────┘
|
|
12
|
+
* │ 1. Discover pricing │
|
|
13
|
+
* │ 2. Create/fund escrow │
|
|
14
|
+
* │ 3. Call via x402 header │
|
|
15
|
+
* │ │
|
|
16
|
+
* │ 4. Agent serves request │
|
|
17
|
+
* │ 5. Agent settles onchain │
|
|
18
|
+
* │ ← PaymentSettledEvent ← │
|
|
19
|
+
* │ 6. Client verifies │
|
|
20
|
+
* └───────────────────────────┘
|
|
21
|
+
*
|
|
22
|
+
* This registry provides:
|
|
23
|
+
* - Pricing estimation with volume curve support
|
|
24
|
+
* - x402 HTTP header generation
|
|
25
|
+
* - Escrow lifecycle management
|
|
26
|
+
* - Settlement verification
|
|
27
|
+
* - Balance/expiry monitoring
|
|
28
|
+
*
|
|
29
|
+
* @category Registries
|
|
30
|
+
* @since v0.1.0
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const x402 = client.x402;
|
|
35
|
+
*
|
|
36
|
+
* // === CLIENT SIDE ===
|
|
37
|
+
*
|
|
38
|
+
* // 1. Estimate cost before committing
|
|
39
|
+
* const estimate = x402.estimateCost(agentWallet, 100);
|
|
40
|
+
*
|
|
41
|
+
* // 2. Prepare payment (creates escrow + deposits)
|
|
42
|
+
* const ctx = await x402.preparePayment(agentWallet, {
|
|
43
|
+
* pricePerCall: 1000,
|
|
44
|
+
* maxCalls: 100,
|
|
45
|
+
* deposit: 100_000,
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // 3. Build x402 HTTP headers for API calls
|
|
49
|
+
* const headers = x402.buildPaymentHeaders(ctx);
|
|
50
|
+
*
|
|
51
|
+
* // 4. Check balance
|
|
52
|
+
* const balance = await x402.getBalance(agentWallet);
|
|
53
|
+
*
|
|
54
|
+
* // === AGENT SIDE ===
|
|
55
|
+
*
|
|
56
|
+
* // 5. Settle after serving calls
|
|
57
|
+
* const receipt = await x402.settle(depositorWallet, 5, serviceData);
|
|
58
|
+
*
|
|
59
|
+
* // 6. Batch settle for efficiency
|
|
60
|
+
* const batchReceipt = await x402.settleBatch(depositorWallet, settlements);
|
|
61
|
+
*
|
|
62
|
+
* // 7. Verify a settlement TX
|
|
63
|
+
* const verified = await x402.verifySettlement(txSignature);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
+
exports.X402Registry = void 0;
|
|
68
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
69
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
70
|
+
const pda_1 = require("../pda");
|
|
71
|
+
const utils_1 = require("../utils");
|
|
72
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
73
|
+
// x402 Registry
|
|
74
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
75
|
+
/**
|
|
76
|
+
* @name X402Registry
|
|
77
|
+
* @description x402 payment flow registry for the SAP network.
|
|
78
|
+
*
|
|
79
|
+
* Provides the complete x402 HTTP micropayment lifecycle: pricing
|
|
80
|
+
* estimation, escrow management, HTTP header generation, settlement,
|
|
81
|
+
* and balance monitoring. Used by both clients (payers) and agents (payees).
|
|
82
|
+
*
|
|
83
|
+
* @category Registries
|
|
84
|
+
* @since v0.1.0
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const x402 = client.x402;
|
|
89
|
+
*
|
|
90
|
+
* // Client: prepare payment and build headers
|
|
91
|
+
* const ctx = await x402.preparePayment(agentWallet, {
|
|
92
|
+
* pricePerCall: 1000, maxCalls: 100, deposit: 100_000,
|
|
93
|
+
* });
|
|
94
|
+
* const headers = x402.buildPaymentHeaders(ctx);
|
|
95
|
+
*
|
|
96
|
+
* // Agent: settle calls after serving
|
|
97
|
+
* const receipt = await x402.settle(depositorWallet, 5, "service-data");
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
class X402Registry {
|
|
101
|
+
program;
|
|
102
|
+
wallet;
|
|
103
|
+
constructor(program) {
|
|
104
|
+
this.program = program;
|
|
105
|
+
this.wallet = program.provider.wallet.publicKey;
|
|
106
|
+
}
|
|
107
|
+
// ── Pricing & Estimation ─────────────────────────────
|
|
108
|
+
/**
|
|
109
|
+
* @name estimateCost
|
|
110
|
+
* @description Estimate the cost of N calls to an agent.
|
|
111
|
+
* Reads the escrow data if it exists, falls back to the agent’s pricing.
|
|
112
|
+
* Supports volume curve pricing for tiered cost calculation.
|
|
113
|
+
*
|
|
114
|
+
* @param agentWallet - Agent wallet address.
|
|
115
|
+
* @param calls - Number of calls to estimate.
|
|
116
|
+
* @param opts - Optional: provide pricing directly to avoid on-chain fetch.
|
|
117
|
+
* @param opts.pricePerCall - Base price per call.
|
|
118
|
+
* @param opts.volumeCurve - Volume curve breakpoints.
|
|
119
|
+
* @param opts.totalCallsBefore - Total calls already settled (for curve offset).
|
|
120
|
+
* @returns A {@link CostEstimate} with total cost and per-tier breakdown.
|
|
121
|
+
* @since v0.1.0
|
|
122
|
+
*/
|
|
123
|
+
async estimateCost(agentWallet, calls, opts) {
|
|
124
|
+
let pricePerCall;
|
|
125
|
+
let volumeCurve;
|
|
126
|
+
let totalBefore;
|
|
127
|
+
if (opts?.pricePerCall) {
|
|
128
|
+
pricePerCall = opts.pricePerCall;
|
|
129
|
+
volumeCurve = opts.volumeCurve ?? [];
|
|
130
|
+
totalBefore = opts.totalCallsBefore ?? 0;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// Try to read from existing escrow
|
|
134
|
+
const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
|
|
135
|
+
const [escrowPda] = (0, pda_1.deriveEscrow)(agentPda, this.wallet);
|
|
136
|
+
const escrow = await this.fetchNullable("escrowAccount", escrowPda);
|
|
137
|
+
if (escrow) {
|
|
138
|
+
pricePerCall = escrow.pricePerCall;
|
|
139
|
+
volumeCurve = escrow.volumeCurve ?? [];
|
|
140
|
+
totalBefore = escrow.totalCallsSettled.toNumber();
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// Fall back to agent's first pricing tier
|
|
144
|
+
const agent = await this.fetchNullable("agentAccount", agentPda);
|
|
145
|
+
if (!agent || agent.pricing.length === 0) {
|
|
146
|
+
return {
|
|
147
|
+
totalCost: new anchor_1.BN(0),
|
|
148
|
+
calls,
|
|
149
|
+
effectivePricePerCall: new anchor_1.BN(0),
|
|
150
|
+
hasVolumeCurve: false,
|
|
151
|
+
tiers: [],
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
pricePerCall = agent.pricing[0].pricePerCall;
|
|
155
|
+
volumeCurve = agent.pricing[0].volumeCurve ?? [];
|
|
156
|
+
totalBefore = 0;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return this.calculateCost(pricePerCall, volumeCurve, totalBefore, calls);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @name calculateCost
|
|
163
|
+
* @description Pure cost calculation (no network calls).
|
|
164
|
+
* Implements the same tiered pricing logic as the on-chain program.
|
|
165
|
+
*
|
|
166
|
+
* @param basePrice - Base price per call in smallest token unit.
|
|
167
|
+
* @param volumeCurve - Volume curve breakpoints.
|
|
168
|
+
* @param totalCallsBefore - Total calls already settled (cursor offset).
|
|
169
|
+
* @param calls - Number of calls to calculate cost for.
|
|
170
|
+
* @returns A {@link CostEstimate} with total cost and per-tier breakdown.
|
|
171
|
+
* @since v0.1.0
|
|
172
|
+
*/
|
|
173
|
+
calculateCost(basePrice, volumeCurve, totalCallsBefore, calls) {
|
|
174
|
+
const tiers = [];
|
|
175
|
+
if (volumeCurve.length === 0) {
|
|
176
|
+
const totalCost = basePrice.mul(new anchor_1.BN(calls));
|
|
177
|
+
return {
|
|
178
|
+
totalCost,
|
|
179
|
+
calls,
|
|
180
|
+
effectivePricePerCall: basePrice,
|
|
181
|
+
hasVolumeCurve: false,
|
|
182
|
+
tiers: [{ calls, pricePerCall: basePrice, subtotal: totalCost }],
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
let remaining = calls;
|
|
186
|
+
let cursor = totalCallsBefore;
|
|
187
|
+
let totalCost = new anchor_1.BN(0);
|
|
188
|
+
while (remaining > 0) {
|
|
189
|
+
let currentPrice = basePrice;
|
|
190
|
+
let nextThreshold = null;
|
|
191
|
+
for (const bp of volumeCurve) {
|
|
192
|
+
const threshold = bp.afterCalls;
|
|
193
|
+
if (cursor >= threshold) {
|
|
194
|
+
currentPrice = bp.pricePerCall;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
nextThreshold = threshold;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const callsAtPrice = nextThreshold !== null
|
|
202
|
+
? Math.min(remaining, nextThreshold - cursor)
|
|
203
|
+
: remaining;
|
|
204
|
+
const subtotal = currentPrice.mul(new anchor_1.BN(callsAtPrice));
|
|
205
|
+
totalCost = totalCost.add(subtotal);
|
|
206
|
+
tiers.push({ calls: callsAtPrice, pricePerCall: currentPrice, subtotal });
|
|
207
|
+
remaining -= callsAtPrice;
|
|
208
|
+
cursor += callsAtPrice;
|
|
209
|
+
}
|
|
210
|
+
const effectivePricePerCall = calls > 0
|
|
211
|
+
? totalCost.div(new anchor_1.BN(calls))
|
|
212
|
+
: new anchor_1.BN(0);
|
|
213
|
+
return {
|
|
214
|
+
totalCost,
|
|
215
|
+
calls,
|
|
216
|
+
effectivePricePerCall,
|
|
217
|
+
hasVolumeCurve: true,
|
|
218
|
+
tiers,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
// ── Escrow Lifecycle (Client Side) ───────────────────
|
|
222
|
+
/**
|
|
223
|
+
* @name preparePayment
|
|
224
|
+
* @description Prepare an x402 payment flow — creates and funds an escrow.
|
|
225
|
+
* Derives the escrow PDA, sends the `createEscrow` instruction, and returns
|
|
226
|
+
* a {@link PaymentContext} for building x402 headers.
|
|
227
|
+
*
|
|
228
|
+
* @param agentWallet - The agent’s wallet public key.
|
|
229
|
+
* @param opts - Payment options (price, max calls, deposit, etc.).
|
|
230
|
+
* @returns A {@link PaymentContext} with escrow details and transaction signature.
|
|
231
|
+
* @since v0.1.0
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* const ctx = await x402.preparePayment(agentWallet, {
|
|
236
|
+
* pricePerCall: 1000,
|
|
237
|
+
* maxCalls: 100,
|
|
238
|
+
* deposit: 100_000,
|
|
239
|
+
* });
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
async preparePayment(agentWallet, opts) {
|
|
243
|
+
const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
|
|
244
|
+
const [escrowPda] = (0, pda_1.deriveEscrow)(agentPda, this.wallet);
|
|
245
|
+
const [statsPda] = (0, pda_1.deriveAgentStats)(agentPda);
|
|
246
|
+
const pricePerCall = new anchor_1.BN(opts.pricePerCall.toString());
|
|
247
|
+
const maxCalls = new anchor_1.BN((opts.maxCalls ?? 0).toString());
|
|
248
|
+
const initialDeposit = new anchor_1.BN(opts.deposit.toString());
|
|
249
|
+
const expiresAt = new anchor_1.BN((opts.expiresAt ?? 0).toString());
|
|
250
|
+
const volumeCurve = (opts.volumeCurve ?? []).map((v) => ({
|
|
251
|
+
afterCalls: v.afterCalls,
|
|
252
|
+
pricePerCall: new anchor_1.BN(v.pricePerCall.toString()),
|
|
253
|
+
}));
|
|
254
|
+
const txSignature = await this.methods
|
|
255
|
+
.createEscrow(pricePerCall, maxCalls, initialDeposit, expiresAt, volumeCurve, opts.tokenMint ?? null, opts.tokenDecimals ?? 9)
|
|
256
|
+
.accounts({
|
|
257
|
+
depositor: this.wallet,
|
|
258
|
+
agent: agentPda,
|
|
259
|
+
agentStats: statsPda,
|
|
260
|
+
escrow: escrowPda,
|
|
261
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
262
|
+
})
|
|
263
|
+
.rpc();
|
|
264
|
+
return {
|
|
265
|
+
escrowPda,
|
|
266
|
+
agentPda,
|
|
267
|
+
agentWallet,
|
|
268
|
+
depositorWallet: this.wallet,
|
|
269
|
+
pricePerCall,
|
|
270
|
+
maxCalls,
|
|
271
|
+
txSignature,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* @name addFunds
|
|
276
|
+
* @description Add more funds to an existing escrow.
|
|
277
|
+
*
|
|
278
|
+
* @param agentWallet - Agent wallet of the escrow.
|
|
279
|
+
* @param amount - Amount to deposit in smallest token unit.
|
|
280
|
+
* @returns The transaction signature.
|
|
281
|
+
* @since v0.1.0
|
|
282
|
+
*/
|
|
283
|
+
async addFunds(agentWallet, amount) {
|
|
284
|
+
const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
|
|
285
|
+
const [escrowPda] = (0, pda_1.deriveEscrow)(agentPda, this.wallet);
|
|
286
|
+
return this.methods
|
|
287
|
+
.depositEscrow(new anchor_1.BN(amount.toString()))
|
|
288
|
+
.accounts({
|
|
289
|
+
depositor: this.wallet,
|
|
290
|
+
escrow: escrowPda,
|
|
291
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
292
|
+
})
|
|
293
|
+
.rpc();
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* @name withdrawFunds
|
|
297
|
+
* @description Withdraw remaining funds from an escrow.
|
|
298
|
+
*
|
|
299
|
+
* @param agentWallet - Agent wallet of the escrow.
|
|
300
|
+
* @param amount - Amount to withdraw in smallest token unit.
|
|
301
|
+
* @returns The transaction signature.
|
|
302
|
+
* @since v0.1.0
|
|
303
|
+
*/
|
|
304
|
+
async withdrawFunds(agentWallet, amount) {
|
|
305
|
+
const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
|
|
306
|
+
const [escrowPda] = (0, pda_1.deriveEscrow)(agentPda, this.wallet);
|
|
307
|
+
return this.methods
|
|
308
|
+
.withdrawEscrow(new anchor_1.BN(amount.toString()))
|
|
309
|
+
.accounts({
|
|
310
|
+
depositor: this.wallet,
|
|
311
|
+
escrow: escrowPda,
|
|
312
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
313
|
+
})
|
|
314
|
+
.rpc();
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* @name closeEscrow
|
|
318
|
+
* @description Close an empty escrow (balance must be 0).
|
|
319
|
+
* Reclaims the rent-exempt lamports.
|
|
320
|
+
*
|
|
321
|
+
* @param agentWallet - Agent wallet of the escrow.
|
|
322
|
+
* @returns The transaction signature.
|
|
323
|
+
* @since v0.1.0
|
|
324
|
+
*/
|
|
325
|
+
async closeEscrow(agentWallet) {
|
|
326
|
+
const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
|
|
327
|
+
const [escrowPda] = (0, pda_1.deriveEscrow)(agentPda, this.wallet);
|
|
328
|
+
return this.methods
|
|
329
|
+
.closeEscrow()
|
|
330
|
+
.accounts({
|
|
331
|
+
depositor: this.wallet,
|
|
332
|
+
escrow: escrowPda,
|
|
333
|
+
})
|
|
334
|
+
.rpc();
|
|
335
|
+
}
|
|
336
|
+
// ── x402 HTTP Headers ────────────────────────────────
|
|
337
|
+
/**
|
|
338
|
+
* @name buildPaymentHeaders
|
|
339
|
+
* @description Build x402 HTTP headers for API requests.
|
|
340
|
+
* Include these headers when calling an agent’s x402 endpoint.
|
|
341
|
+
*
|
|
342
|
+
* @param ctx - Payment context from {@link X402Registry.preparePayment}.
|
|
343
|
+
* @param opts - Optional settings.
|
|
344
|
+
* @param opts.network - Solana cluster name (defaults to `"mainnet-beta"`).
|
|
345
|
+
* @returns An {@link X402Headers} object ready to merge into HTTP requests.
|
|
346
|
+
* @since v0.1.0
|
|
347
|
+
*/
|
|
348
|
+
buildPaymentHeaders(ctx, opts) {
|
|
349
|
+
return {
|
|
350
|
+
"X-Payment-Protocol": "SAP-x402",
|
|
351
|
+
"X-Payment-Escrow": ctx.escrowPda.toBase58(),
|
|
352
|
+
"X-Payment-Agent": ctx.agentPda.toBase58(),
|
|
353
|
+
"X-Payment-Depositor": ctx.depositorWallet.toBase58(),
|
|
354
|
+
"X-Payment-MaxCalls": ctx.maxCalls.toString(),
|
|
355
|
+
"X-Payment-PricePerCall": ctx.pricePerCall.toString(),
|
|
356
|
+
"X-Payment-Program": this.program.programId.toBase58(),
|
|
357
|
+
"X-Payment-Network": opts?.network ?? "mainnet-beta",
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* @name buildPaymentHeadersFromEscrow
|
|
362
|
+
* @description Build x402 headers directly from an agent wallet (fetches escrow data).
|
|
363
|
+
* Convenience method that fetches the escrow account on-chain.
|
|
364
|
+
*
|
|
365
|
+
* @param agentWallet - Agent wallet to look up the escrow for.
|
|
366
|
+
* @param opts - Optional settings.
|
|
367
|
+
* @param opts.network - Solana cluster name (defaults to `"mainnet-beta"`).
|
|
368
|
+
* @returns An {@link X402Headers} object, or `null` if no escrow exists.
|
|
369
|
+
* @since v0.1.0
|
|
370
|
+
*/
|
|
371
|
+
async buildPaymentHeadersFromEscrow(agentWallet, opts) {
|
|
372
|
+
const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
|
|
373
|
+
const [escrowPda] = (0, pda_1.deriveEscrow)(agentPda, this.wallet);
|
|
374
|
+
const escrow = await this.fetchNullable("escrowAccount", escrowPda);
|
|
375
|
+
if (!escrow)
|
|
376
|
+
return null;
|
|
377
|
+
return {
|
|
378
|
+
"X-Payment-Protocol": "SAP-x402",
|
|
379
|
+
"X-Payment-Escrow": escrowPda.toBase58(),
|
|
380
|
+
"X-Payment-Agent": agentPda.toBase58(),
|
|
381
|
+
"X-Payment-Depositor": this.wallet.toBase58(),
|
|
382
|
+
"X-Payment-MaxCalls": escrow.maxCalls.toString(),
|
|
383
|
+
"X-Payment-PricePerCall": escrow.pricePerCall.toString(),
|
|
384
|
+
"X-Payment-Program": this.program.programId.toBase58(),
|
|
385
|
+
"X-Payment-Network": opts?.network ?? "mainnet-beta",
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
// ── Settlement (Agent Side) ──────────────────────────
|
|
389
|
+
/**
|
|
390
|
+
* @name settle
|
|
391
|
+
* @description Settle calls — agent claims payment for calls served.
|
|
392
|
+
* Must be called by the agent owner wallet. Calculates the settlement
|
|
393
|
+
* amount using the escrow’s pricing and volume curve.
|
|
394
|
+
*
|
|
395
|
+
* @param depositorWallet - The client wallet that funded the escrow.
|
|
396
|
+
* @param callsToSettle - Number of calls to settle.
|
|
397
|
+
* @param serviceData - Raw service data (auto-hashed to `service_hash`).
|
|
398
|
+
* @returns A {@link SettlementResult} with transaction details and amount.
|
|
399
|
+
* @since v0.1.0
|
|
400
|
+
*/
|
|
401
|
+
async settle(depositorWallet, callsToSettle, serviceData) {
|
|
402
|
+
const serviceHash = (0, utils_1.hashToArray)((0, utils_1.sha256)(typeof serviceData === "string" ? serviceData : Buffer.from(serviceData)));
|
|
403
|
+
const [agentPda] = (0, pda_1.deriveAgent)(this.wallet);
|
|
404
|
+
const [escrowPda] = (0, pda_1.deriveEscrow)(agentPda, depositorWallet);
|
|
405
|
+
const [statsPda] = (0, pda_1.deriveAgentStats)(agentPda);
|
|
406
|
+
// Prefetch to calculate amount
|
|
407
|
+
const escrow = await this.fetch("escrowAccount", escrowPda);
|
|
408
|
+
const estimate = this.calculateCost(escrow.pricePerCall, escrow.volumeCurve, escrow.totalCallsSettled.toNumber(), callsToSettle);
|
|
409
|
+
const txSignature = await this.methods
|
|
410
|
+
.settleCalls(new anchor_1.BN(callsToSettle), serviceHash)
|
|
411
|
+
.accounts({
|
|
412
|
+
wallet: this.wallet,
|
|
413
|
+
agent: agentPda,
|
|
414
|
+
agentStats: statsPda,
|
|
415
|
+
escrow: escrowPda,
|
|
416
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
417
|
+
})
|
|
418
|
+
.rpc();
|
|
419
|
+
return {
|
|
420
|
+
txSignature,
|
|
421
|
+
callsSettled: callsToSettle,
|
|
422
|
+
amount: estimate.totalCost,
|
|
423
|
+
serviceHash,
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* @name settleBatch
|
|
428
|
+
* @description Batch settle — process up to 10 settlements in one TX.
|
|
429
|
+
* Must be called by the agent owner wallet. More gas-efficient than
|
|
430
|
+
* individual settlements.
|
|
431
|
+
*
|
|
432
|
+
* @param depositorWallet - The client wallet that funded the escrow.
|
|
433
|
+
* @param entries - Array of `{ calls, serviceData }` settlement entries.
|
|
434
|
+
* @returns A {@link BatchSettlementResult} with aggregated totals.
|
|
435
|
+
* @since v0.1.0
|
|
436
|
+
*/
|
|
437
|
+
async settleBatch(depositorWallet, entries) {
|
|
438
|
+
const settlements = entries.map((e) => ({
|
|
439
|
+
callsToSettle: new anchor_1.BN(e.calls),
|
|
440
|
+
serviceHash: (0, utils_1.hashToArray)((0, utils_1.sha256)(typeof e.serviceData === "string" ? e.serviceData : Buffer.from(e.serviceData))),
|
|
441
|
+
}));
|
|
442
|
+
const totalCalls = entries.reduce((sum, e) => sum + e.calls, 0);
|
|
443
|
+
const [agentPda] = (0, pda_1.deriveAgent)(this.wallet);
|
|
444
|
+
const [escrowPda] = (0, pda_1.deriveEscrow)(agentPda, depositorWallet);
|
|
445
|
+
const [statsPda] = (0, pda_1.deriveAgentStats)(agentPda);
|
|
446
|
+
// Prefetch for amount estimation
|
|
447
|
+
const escrow = await this.fetch("escrowAccount", escrowPda);
|
|
448
|
+
const estimate = this.calculateCost(escrow.pricePerCall, escrow.volumeCurve, escrow.totalCallsSettled.toNumber(), totalCalls);
|
|
449
|
+
const txSignature = await this.methods
|
|
450
|
+
.settleBatch(settlements)
|
|
451
|
+
.accounts({
|
|
452
|
+
wallet: this.wallet,
|
|
453
|
+
agent: agentPda,
|
|
454
|
+
agentStats: statsPda,
|
|
455
|
+
escrow: escrowPda,
|
|
456
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
457
|
+
})
|
|
458
|
+
.rpc();
|
|
459
|
+
return {
|
|
460
|
+
txSignature,
|
|
461
|
+
totalCalls,
|
|
462
|
+
totalAmount: estimate.totalCost,
|
|
463
|
+
settlementCount: entries.length,
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
// ── Balance & Status ─────────────────────────────────
|
|
467
|
+
/**
|
|
468
|
+
* @name getBalance
|
|
469
|
+
* @description Get the current escrow balance and status.
|
|
470
|
+
* Returns balance, deposit/settlement totals, remaining calls,
|
|
471
|
+
* expiry status, and affordable call estimate.
|
|
472
|
+
*
|
|
473
|
+
* @param agentWallet - Agent wallet of the escrow.
|
|
474
|
+
* @param depositor - Depositor wallet (defaults to caller).
|
|
475
|
+
* @returns An {@link EscrowBalance}, or `null` if no escrow exists.
|
|
476
|
+
* @since v0.1.0
|
|
477
|
+
*/
|
|
478
|
+
async getBalance(agentWallet, depositor) {
|
|
479
|
+
const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
|
|
480
|
+
const dep = depositor ?? this.wallet;
|
|
481
|
+
const [escrowPda] = (0, pda_1.deriveEscrow)(agentPda, dep);
|
|
482
|
+
const escrow = await this.fetchNullable("escrowAccount", escrowPda);
|
|
483
|
+
if (!escrow)
|
|
484
|
+
return null;
|
|
485
|
+
const now = Math.floor(Date.now() / 1000);
|
|
486
|
+
const isExpired = escrow.expiresAt.toNumber() > 0 && now >= escrow.expiresAt.toNumber();
|
|
487
|
+
const maxCalls = escrow.maxCalls.toNumber();
|
|
488
|
+
const settled = escrow.totalCallsSettled.toNumber();
|
|
489
|
+
const callsRemaining = maxCalls > 0 ? maxCalls - settled : Infinity;
|
|
490
|
+
// Estimate affordable calls with current balance
|
|
491
|
+
const pricePerCall = escrow.pricePerCall.toNumber();
|
|
492
|
+
const balance = escrow.balance.toNumber();
|
|
493
|
+
const affordableCalls = pricePerCall > 0
|
|
494
|
+
? Math.floor(balance / pricePerCall)
|
|
495
|
+
: Infinity;
|
|
496
|
+
return {
|
|
497
|
+
balance: escrow.balance,
|
|
498
|
+
totalDeposited: escrow.totalDeposited,
|
|
499
|
+
totalSettled: escrow.totalSettled,
|
|
500
|
+
totalCallsSettled: escrow.totalCallsSettled,
|
|
501
|
+
callsRemaining: Math.min(callsRemaining, affordableCalls),
|
|
502
|
+
isExpired,
|
|
503
|
+
affordableCalls,
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* @name hasEscrow
|
|
508
|
+
* @description Check if an escrow exists for a given agent + depositor pair.
|
|
509
|
+
*
|
|
510
|
+
* @param agentWallet - Agent wallet to check.
|
|
511
|
+
* @param depositor - Depositor wallet (defaults to caller).
|
|
512
|
+
* @returns `true` if the escrow account exists on-chain.
|
|
513
|
+
* @since v0.1.0
|
|
514
|
+
*/
|
|
515
|
+
async hasEscrow(agentWallet, depositor) {
|
|
516
|
+
const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
|
|
517
|
+
const [escrowPda] = (0, pda_1.deriveEscrow)(agentPda, depositor ?? this.wallet);
|
|
518
|
+
const info = await this.program.provider.connection.getAccountInfo(escrowPda);
|
|
519
|
+
return info !== null;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* @name fetchEscrow
|
|
523
|
+
* @description Fetch the raw escrow account data.
|
|
524
|
+
*
|
|
525
|
+
* @param agentWallet - Agent wallet of the escrow.
|
|
526
|
+
* @param depositor - Depositor wallet (defaults to caller).
|
|
527
|
+
* @returns The raw {@link EscrowAccountData}, or `null` if not found.
|
|
528
|
+
* @since v0.1.0
|
|
529
|
+
*/
|
|
530
|
+
async fetchEscrow(agentWallet, depositor) {
|
|
531
|
+
const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
|
|
532
|
+
const dep = depositor ?? this.wallet;
|
|
533
|
+
const [escrowPda] = (0, pda_1.deriveEscrow)(agentPda, dep);
|
|
534
|
+
return this.fetchNullable("escrowAccount", escrowPda);
|
|
535
|
+
}
|
|
536
|
+
// ── Internals ────────────────────────────────────────
|
|
537
|
+
/**
|
|
538
|
+
* @name methods
|
|
539
|
+
* @description Accessor for the Anchor program methods namespace.
|
|
540
|
+
* @returns The program methods object for building RPC calls.
|
|
541
|
+
* @private
|
|
542
|
+
*/
|
|
543
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
544
|
+
get methods() {
|
|
545
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
546
|
+
return this.program.methods;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* @name fetch
|
|
550
|
+
* @description Fetch an on-chain account by name and PDA. Throws if not found.
|
|
551
|
+
* @param name - Anchor account discriminator name.
|
|
552
|
+
* @param pda - Account public key to fetch.
|
|
553
|
+
* @returns The deserialized account data.
|
|
554
|
+
* @throws If the account does not exist.
|
|
555
|
+
* @private
|
|
556
|
+
*/
|
|
557
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
558
|
+
async fetch(name, pda) {
|
|
559
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
560
|
+
return this.program.account[name].fetch(pda);
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* @name fetchNullable
|
|
564
|
+
* @description Fetch an on-chain account by name and PDA. Returns `null` if not found.
|
|
565
|
+
* @param name - Anchor account discriminator name.
|
|
566
|
+
* @param pda - Account public key to fetch.
|
|
567
|
+
* @returns The deserialized account data, or `null` if the account does not exist.
|
|
568
|
+
* @private
|
|
569
|
+
*/
|
|
570
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
571
|
+
async fetchNullable(name, pda) {
|
|
572
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
573
|
+
return this.program.account[name].fetchNullable(pda);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
exports.X402Registry = X402Registry;
|
|
577
|
+
//# sourceMappingURL=x402.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402.js","sourceRoot":"","sources":["../../../src/registries/x402.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;;;AAEH,6CAIyB;AACzB,8CAA4D;AAE5D,gCAIgB;AAChB,oCAA+C;AAyL/C,sEAAsE;AACtE,iBAAiB;AACjB,sEAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,YAAY;IAGM;IAFZ,MAAM,CAAY;IAEnC,YAA6B,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;QAC9C,IAAI,CAAC,MAAM,GAAI,OAAO,CAAC,QAA2B,CAAC,MAAM,CAAC,SAAS,CAAC;IACtE,CAAC;IAED,wDAAwD;IAExD;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,YAAY,CAChB,WAAsB,EACtB,KAAa,EACb,IAIC;QAED,IAAI,YAAgB,CAAC;QACrB,IAAI,WAAoC,CAAC;QACzC,IAAI,WAAmB,CAAC;QAExB,IAAI,IAAI,EAAE,YAAY,EAAE,CAAC;YACvB,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;YACjC,WAAW,GAAG,IAAI,CAAC,WA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IAAA,kBAAY,EAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,aAAa,CAAoB,eAAe,EAAE,SAAS,CAAC,CAAC;IAC3E,CAAC;IAED,wDAAwD;IAExD;;;;;OAKG;IACH,8DAA8D;IAC9D,IAAY,OAAO;QACjB,+DAA+D;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED;;;;;;;;OAQG;IACH,8DAA8D;IACtD,KAAK,CAAC,KAAK,CAAI,IAAY,EAAE,GAAc;QACjD,0GAA0G;QAC1G,OAAQ,IAAI,CAAC,OAAO,CAAC,OAAe,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAe,CAAC;IACtE,CAAC;IAED;;;;;;;OAOG;IACH,8DAA8D;IACtD,KAAK,CAAC,aAAa,CAAI,IAAY,EAAE,GAAc;QACzD,0GAA0G;QAC1G,OAAQ,IAAI,CAAC,OAAO,CAAC,OAAe,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,GAAG,CAAsB,CAAC;IACrF,CAAC;CACF;AAtmBD,oCAsmBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module types/accounts
|
|
4
|
+
* @description Deserialized on-chain account data interfaces.
|
|
5
|
+
*
|
|
6
|
+
* Every interface mirrors the corresponding Rust struct exactly.
|
|
7
|
+
* Anchor deserializes PDA accounts into these shapes.
|
|
8
|
+
*
|
|
9
|
+
* @category Types
|
|
10
|
+
* @since v0.1.0
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/types/accounts.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module types/common
|
|
4
|
+
* @description Shared helper structs used across accounts and instructions.
|
|
5
|
+
*
|
|
6
|
+
* These types appear as nested fields in both on-chain account data
|
|
7
|
+
* and instruction argument DTOs.
|
|
8
|
+
*
|
|
9
|
+
* @category Types
|
|
10
|
+
* @since v0.1.0
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/types/common.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}
|