@oobe-protocol-labs/synapse-sap-sdk 0.6.3 → 0.8.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/dist/cjs/constants/seeds.js +9 -0
- package/dist/cjs/constants/seeds.js.map +1 -1
- package/dist/cjs/core/client.js +55 -0
- package/dist/cjs/core/client.js.map +1 -1
- package/dist/cjs/idl/synapse_agent_sap.json +8571 -4106
- package/dist/cjs/index.js +29 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/escrow-v2.js +220 -0
- package/dist/cjs/modules/escrow-v2.js.map +1 -0
- package/dist/cjs/modules/escrow.js +4 -0
- package/dist/cjs/modules/escrow.js.map +1 -1
- package/dist/cjs/modules/index.js +9 -1
- package/dist/cjs/modules/index.js.map +1 -1
- package/dist/cjs/modules/receipt.js +144 -0
- package/dist/cjs/modules/receipt.js.map +1 -0
- package/dist/cjs/modules/staking.js +94 -0
- package/dist/cjs/modules/staking.js.map +1 -0
- package/dist/cjs/modules/subscription.js +96 -0
- package/dist/cjs/modules/subscription.js.map +1 -0
- package/dist/cjs/pda/index.js +166 -1
- package/dist/cjs/pda/index.js.map +1 -1
- package/dist/cjs/registries/x402.js +88 -51
- package/dist/cjs/registries/x402.js.map +1 -1
- package/dist/cjs/types/enums.js +96 -1
- package/dist/cjs/types/enums.js.map +1 -1
- package/dist/cjs/types/index.js +6 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/instructions.js.map +1 -1
- package/dist/cjs/utils/escrow-validation.js +219 -0
- package/dist/cjs/utils/escrow-validation.js.map +1 -0
- package/dist/cjs/utils/index.js +12 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/merchant-validator.js +246 -0
- package/dist/cjs/utils/merchant-validator.js.map +1 -0
- package/dist/cjs/utils/x402-direct.js +231 -0
- package/dist/cjs/utils/x402-direct.js.map +1 -0
- package/dist/esm/constants/seeds.js +9 -0
- package/dist/esm/constants/seeds.js.map +1 -1
- package/dist/esm/core/client.js +55 -0
- package/dist/esm/core/client.js.map +1 -1
- package/dist/esm/idl/synapse_agent_sap.json +8571 -4106
- package/dist/esm/index.js +5 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/escrow-v2.js +216 -0
- package/dist/esm/modules/escrow-v2.js.map +1 -0
- package/dist/esm/modules/escrow.js +4 -0
- package/dist/esm/modules/escrow.js.map +1 -1
- package/dist/esm/modules/index.js +4 -0
- package/dist/esm/modules/index.js.map +1 -1
- package/dist/esm/modules/receipt.js +140 -0
- package/dist/esm/modules/receipt.js.map +1 -0
- package/dist/esm/modules/staking.js +90 -0
- package/dist/esm/modules/staking.js.map +1 -0
- package/dist/esm/modules/subscription.js +92 -0
- package/dist/esm/modules/subscription.js.map +1 -0
- package/dist/esm/pda/index.js +157 -0
- package/dist/esm/pda/index.js.map +1 -1
- package/dist/esm/registries/x402.js +89 -52
- package/dist/esm/registries/x402.js.map +1 -1
- package/dist/esm/types/enums.js +95 -0
- package/dist/esm/types/enums.js.map +1 -1
- package/dist/esm/types/index.js +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/instructions.js.map +1 -1
- package/dist/esm/utils/escrow-validation.js +212 -0
- package/dist/esm/utils/escrow-validation.js.map +1 -0
- package/dist/esm/utils/index.js +4 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/merchant-validator.js +241 -0
- package/dist/esm/utils/merchant-validator.js.map +1 -0
- package/dist/esm/utils/x402-direct.js +228 -0
- package/dist/esm/utils/x402-direct.js.map +1 -0
- package/dist/types/constants/seeds.d.ts +9 -0
- package/dist/types/constants/seeds.d.ts.map +1 -1
- package/dist/types/core/client.d.ts +43 -0
- package/dist/types/core/client.d.ts.map +1 -1
- package/dist/types/index.d.ts +6 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/escrow-v2.d.ts +58 -0
- package/dist/types/modules/escrow-v2.d.ts.map +1 -0
- package/dist/types/modules/escrow.d.ts +4 -0
- package/dist/types/modules/escrow.d.ts.map +1 -1
- package/dist/types/modules/index.d.ts +4 -0
- package/dist/types/modules/index.d.ts.map +1 -1
- package/dist/types/modules/receipt.d.ts +77 -0
- package/dist/types/modules/receipt.d.ts.map +1 -0
- package/dist/types/modules/staking.d.ts +32 -0
- package/dist/types/modules/staking.d.ts.map +1 -0
- package/dist/types/modules/subscription.d.ts +33 -0
- package/dist/types/modules/subscription.d.ts.map +1 -0
- package/dist/types/pda/index.d.ts +114 -0
- package/dist/types/pda/index.d.ts.map +1 -1
- package/dist/types/plugin/schemas.d.ts +2 -2
- package/dist/types/registries/x402.d.ts +14 -12
- package/dist/types/registries/x402.d.ts.map +1 -1
- package/dist/types/types/accounts.d.ts +201 -1
- package/dist/types/types/accounts.d.ts.map +1 -1
- package/dist/types/types/enums.d.ts +115 -0
- package/dist/types/types/enums.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +4 -4
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/instructions.d.ts +34 -0
- package/dist/types/types/instructions.d.ts.map +1 -1
- package/dist/types/utils/escrow-validation.d.ts +145 -0
- package/dist/types/utils/escrow-validation.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +6 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/merchant-validator.d.ts +176 -0
- package/dist/types/utils/merchant-validator.d.ts.map +1 -0
- package/dist/types/utils/x402-direct.d.ts +114 -0
- package/dist/types/utils/x402-direct.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/constants/seeds.ts +9 -0
- package/src/core/client.ts +59 -0
- package/src/idl/synapse_agent_sap.json +8571 -4106
- package/src/index.ts +54 -0
- package/src/modules/escrow-v2.ts +375 -0
- package/src/modules/escrow.ts +4 -0
- package/src/modules/index.ts +4 -0
- package/src/modules/receipt.ts +207 -0
- package/src/modules/staking.ts +122 -0
- package/src/modules/subscription.ts +147 -0
- package/src/pda/index.ts +228 -0
- package/src/registries/x402.ts +108 -69
- package/src/types/accounts.ts +241 -1
- package/src/types/enums.ts +119 -0
- package/src/types/index.ts +20 -0
- package/src/types/instructions.ts +40 -0
- package/src/utils/escrow-validation.ts +301 -0
- package/src/utils/index.ts +28 -0
- package/src/utils/merchant-validator.ts +359 -0
- package/src/utils/x402-direct.ts +370 -0
package/dist/esm/types/enums.js
CHANGED
|
@@ -168,4 +168,99 @@ export const ToolCategory = {
|
|
|
168
168
|
Analytics: { analytics: {} },
|
|
169
169
|
Custom: { custom: {} },
|
|
170
170
|
};
|
|
171
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
172
|
+
// Settlement Security (V2.1)
|
|
173
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
174
|
+
/**
|
|
175
|
+
* @name SettlementSecurity
|
|
176
|
+
* @description Anchor-compatible enum variants for V2 escrow settlement security levels.
|
|
177
|
+
*
|
|
178
|
+
* - `SelfReport` — **DEPRECATED in v0.7** — Agent settles unilaterally (abuse vector).
|
|
179
|
+
* - `CoSigned` — Agent + client must co-sign every settlement.
|
|
180
|
+
* - `DisputeWindow` — Settlement enters pending state, depositor can dispute.
|
|
181
|
+
*
|
|
182
|
+
* @category Types
|
|
183
|
+
* @since v0.5.0
|
|
184
|
+
*/
|
|
185
|
+
export const SettlementSecurity = {
|
|
186
|
+
/** @deprecated Removed in v0.7 — returns SelfReportDeprecated error */
|
|
187
|
+
SelfReport: { selfReport: {} },
|
|
188
|
+
CoSigned: { coSigned: {} },
|
|
189
|
+
DisputeWindow: { disputeWindow: {} },
|
|
190
|
+
};
|
|
191
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
192
|
+
// Dispute Outcome (V2.1)
|
|
193
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
194
|
+
/**
|
|
195
|
+
* @name DisputeOutcome
|
|
196
|
+
* @description Anchor-compatible enum variants for dispute resolution outcomes.
|
|
197
|
+
*
|
|
198
|
+
* @category Types
|
|
199
|
+
* @since v0.5.0
|
|
200
|
+
*/
|
|
201
|
+
export const DisputeOutcome = {
|
|
202
|
+
Pending: { pending: {} },
|
|
203
|
+
AutoReleased: { autoReleased: {} },
|
|
204
|
+
DepositorWins: { depositorWins: {} },
|
|
205
|
+
AgentWins: { agentWins: {} },
|
|
206
|
+
/** @since v0.7.0 — Proportional refund based on proven vs claimed calls */
|
|
207
|
+
PartialRefund: { partialRefund: {} },
|
|
208
|
+
/** @since v0.7.0 — 50/50 split for irresolvable quality disputes */
|
|
209
|
+
Split: { split: {} },
|
|
210
|
+
};
|
|
211
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
212
|
+
// Dispute Type (v0.7)
|
|
213
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
214
|
+
/**
|
|
215
|
+
* @name DisputeType
|
|
216
|
+
* @description Categories of disputes that can be filed against a pending settlement.
|
|
217
|
+
*
|
|
218
|
+
* - `NonDelivery` — Agent took payment but delivered nothing.
|
|
219
|
+
* - `PartialDelivery` — Agent delivered fewer calls than claimed.
|
|
220
|
+
* - `Overcharge` — Agent charged more than the agreed price.
|
|
221
|
+
* - `Quality` — Agent delivered but output quality is disputed.
|
|
222
|
+
*
|
|
223
|
+
* @category Types
|
|
224
|
+
* @since v0.7.0
|
|
225
|
+
*/
|
|
226
|
+
export const DisputeType = {
|
|
227
|
+
NonDelivery: 0,
|
|
228
|
+
PartialDelivery: 1,
|
|
229
|
+
Overcharge: 2,
|
|
230
|
+
Quality: 3,
|
|
231
|
+
};
|
|
232
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
233
|
+
// Resolution Layer (v0.7)
|
|
234
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
235
|
+
/**
|
|
236
|
+
* @name ResolutionLayer
|
|
237
|
+
* @description How a dispute was resolved.
|
|
238
|
+
*
|
|
239
|
+
* - `Pending` — Not yet resolved.
|
|
240
|
+
* - `Auto` — Resolved automatically via receipt merkle proofs.
|
|
241
|
+
* - `Governance` — Resolved via protocol governance (quality disputes).
|
|
242
|
+
*
|
|
243
|
+
* @category Types
|
|
244
|
+
* @since v0.7.0
|
|
245
|
+
*/
|
|
246
|
+
export const ResolutionLayer = {
|
|
247
|
+
Pending: { pending: {} },
|
|
248
|
+
Auto: { auto: {} },
|
|
249
|
+
Governance: { governance: {} },
|
|
250
|
+
};
|
|
251
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
252
|
+
// Billing Interval (V2.1)
|
|
253
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
254
|
+
/**
|
|
255
|
+
* @name BillingInterval
|
|
256
|
+
* @description Anchor-compatible enum variants for subscription billing intervals.
|
|
257
|
+
*
|
|
258
|
+
* @category Types
|
|
259
|
+
* @since v0.5.0
|
|
260
|
+
*/
|
|
261
|
+
export const BillingInterval = {
|
|
262
|
+
Daily: { daily: {} },
|
|
263
|
+
Weekly: { weekly: {} },
|
|
264
|
+
Monthly: { monthly: {} },
|
|
265
|
+
};
|
|
171
266
|
//# sourceMappingURL=enums.js.map
|
|
@@ -1 +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,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;IACtB,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;CAChB,CAAC"}
|
package/dist/esm/types/index.js
CHANGED
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
// ── Enums ────────────────────────────────────────────
|
|
23
|
-
export { TokenType, PluginType, SettlementMode, ToolHttpMethod, ToolCategory, } from "./enums";
|
|
23
|
+
export { TokenType, PluginType, SettlementMode, ToolHttpMethod, ToolCategory, SettlementSecurity, DisputeOutcome, BillingInterval, DisputeType, ResolutionLayer, } from "./enums";
|
|
24
24
|
export { DelegatePermission, SchemaType, CompressionType, } from "./instructions";
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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,
|
|
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,EACZ,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,WAAW,EACX,eAAe,GAChB,MAAM,SAAS,CAAC;AAyEjB,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,eAAe,GAChB,MAAM,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../../src/types/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../../src/types/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAgTH,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,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module utils/escrow-validation
|
|
3
|
+
* @description Server-side escrow validation pipeline.
|
|
4
|
+
*
|
|
5
|
+
* Provides typed helpers to validate escrow state before settlement
|
|
6
|
+
* and to build the correct SPL `AccountMeta[]` for token escrows.
|
|
7
|
+
*
|
|
8
|
+
* @category Utils
|
|
9
|
+
* @since v0.6.4
|
|
10
|
+
*/
|
|
11
|
+
import { PublicKey, } from "@solana/web3.js";
|
|
12
|
+
import { BN } from "@coral-xyz/anchor";
|
|
13
|
+
import { findATA } from "./rpc-strategy";
|
|
14
|
+
import { deriveAgent, deriveEscrow } from "../pda";
|
|
15
|
+
import { SapError } from "../errors";
|
|
16
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
17
|
+
// Error
|
|
18
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
19
|
+
/**
|
|
20
|
+
* @name MissingEscrowAtaError
|
|
21
|
+
* @description Thrown when an SPL escrow operation is missing required
|
|
22
|
+
* Associated Token Accounts.
|
|
23
|
+
* @category Errors
|
|
24
|
+
* @since v0.6.4
|
|
25
|
+
*/
|
|
26
|
+
export class MissingEscrowAtaError extends SapError {
|
|
27
|
+
/** The ATA address that is missing. */
|
|
28
|
+
ataAddress;
|
|
29
|
+
/** Which side is missing: depositor or escrow. */
|
|
30
|
+
side;
|
|
31
|
+
constructor(ataAddress, side) {
|
|
32
|
+
super(`Missing ${side} ATA: ${ataAddress}. ` +
|
|
33
|
+
`Settlement mode is Escrow/SPL but the Associated Token Account does not exist. ` +
|
|
34
|
+
`The ${side} must create the ATA before escrow operations.`, "SAP_MISSING_ESCROW_ATA");
|
|
35
|
+
this.name = "MissingEscrowAtaError";
|
|
36
|
+
this.ataAddress = ataAddress;
|
|
37
|
+
this.side = side;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
41
|
+
// Validation
|
|
42
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
43
|
+
/** Standard SPL Token program ID. */
|
|
44
|
+
const TOKEN_PROGRAM_ID_STR = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
45
|
+
/**
|
|
46
|
+
* @name validateEscrowState
|
|
47
|
+
* @description Validates that an escrow is in a correct state for settlement.
|
|
48
|
+
*
|
|
49
|
+
* Checks:
|
|
50
|
+
* - Escrow PDA exists on-chain
|
|
51
|
+
* - If SPL: depositor ATA exists, escrow ATA exists, token mint matches
|
|
52
|
+
* - Balance >= requested settlement amount
|
|
53
|
+
* - Escrow is not expired
|
|
54
|
+
* - Max calls not exceeded
|
|
55
|
+
*
|
|
56
|
+
* @param connection - Solana RPC connection.
|
|
57
|
+
* @param agentWallet - The agent's wallet public key.
|
|
58
|
+
* @param depositorWallet - The depositor's wallet public key.
|
|
59
|
+
* @param fetchEscrow - Callback to fetch escrow data (avoids coupling to SapProgram).
|
|
60
|
+
* @param opts
|
|
61
|
+
* @param opts.callsToSettle - Number of calls to validate affordability for.
|
|
62
|
+
*
|
|
63
|
+
* @returns A detailed {@link EscrowValidationResult}.
|
|
64
|
+
*
|
|
65
|
+
* @category Utils
|
|
66
|
+
* @since v0.6.4
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const result = await validateEscrowState(
|
|
71
|
+
* connection,
|
|
72
|
+
* agentWallet,
|
|
73
|
+
* depositorWallet,
|
|
74
|
+
* (pda) => client.escrow.fetchByPda(pda),
|
|
75
|
+
* { callsToSettle: 5 },
|
|
76
|
+
* );
|
|
77
|
+
*
|
|
78
|
+
* if (!result.valid) {
|
|
79
|
+
* console.error("Escrow validation failed:", result.errors);
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export async function validateEscrowState(connection, agentWallet, depositorWallet, fetchEscrow, opts) {
|
|
84
|
+
const [agentPda] = deriveAgent(agentWallet);
|
|
85
|
+
const [escrowPda] = deriveEscrow(agentPda, depositorWallet);
|
|
86
|
+
const errors = [];
|
|
87
|
+
// 1. Fetch escrow
|
|
88
|
+
const escrow = await fetchEscrow(escrowPda);
|
|
89
|
+
if (!escrow) {
|
|
90
|
+
return {
|
|
91
|
+
valid: false,
|
|
92
|
+
escrow: null,
|
|
93
|
+
escrowPda,
|
|
94
|
+
agentPda,
|
|
95
|
+
isSplEscrow: false,
|
|
96
|
+
splAccounts: [],
|
|
97
|
+
errors: [`Escrow not found at ${escrowPda.toBase58()}`],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// 2. Check expiry
|
|
101
|
+
if (escrow.expiresAt.gt(new BN(0))) {
|
|
102
|
+
const now = Math.floor(Date.now() / 1000);
|
|
103
|
+
if (escrow.expiresAt.lt(new BN(now))) {
|
|
104
|
+
errors.push(`Escrow expired at ${escrow.expiresAt.toString()}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// 3. Check balance / calls
|
|
108
|
+
const callsToSettle = opts?.callsToSettle ?? 1;
|
|
109
|
+
const costForCalls = escrow.pricePerCall.mul(new BN(callsToSettle));
|
|
110
|
+
if (escrow.balance.lt(costForCalls)) {
|
|
111
|
+
errors.push(`Insufficient balance: ${escrow.balance.toString()} < ${costForCalls.toString()} (${callsToSettle} calls × ${escrow.pricePerCall.toString()})`);
|
|
112
|
+
}
|
|
113
|
+
// 4. Check max calls
|
|
114
|
+
if (escrow.maxCalls.gt(new BN(0))) {
|
|
115
|
+
const remaining = escrow.maxCalls.sub(escrow.totalCallsSettled);
|
|
116
|
+
if (remaining.lt(new BN(callsToSettle))) {
|
|
117
|
+
errors.push(`Max calls exceeded: ${remaining.toString()} remaining but needs ${callsToSettle}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// 5. Determine if SPL
|
|
121
|
+
const isSplEscrow = escrow.tokenMint !== null &&
|
|
122
|
+
escrow.tokenMint.toBase58() !== "11111111111111111111111111111111";
|
|
123
|
+
// 6. Build SPL accounts (if SPL escrow)
|
|
124
|
+
const splAccounts = [];
|
|
125
|
+
if (isSplEscrow) {
|
|
126
|
+
const mint = escrow.tokenMint;
|
|
127
|
+
const depositorAta = findATA(depositorWallet, mint);
|
|
128
|
+
const escrowAta = findATA(escrowPda, mint);
|
|
129
|
+
// Verify depositor ATA exists
|
|
130
|
+
const depositorAtaInfo = await connection.getAccountInfo(depositorAta);
|
|
131
|
+
if (!depositorAtaInfo) {
|
|
132
|
+
errors.push(`Depositor ATA does not exist: ${depositorAta.toBase58()}`);
|
|
133
|
+
}
|
|
134
|
+
// Verify escrow ATA exists
|
|
135
|
+
const escrowAtaInfo = await connection.getAccountInfo(escrowAta);
|
|
136
|
+
if (!escrowAtaInfo) {
|
|
137
|
+
errors.push(`Escrow ATA does not exist: ${escrowAta.toBase58()}`);
|
|
138
|
+
}
|
|
139
|
+
// Verify mint matches
|
|
140
|
+
if (depositorAtaInfo) {
|
|
141
|
+
// SPL token account data: bytes 0-32 = mint
|
|
142
|
+
const ataMint = depositorAtaInfo.data.subarray(0, 32);
|
|
143
|
+
if (Buffer.from(ataMint).toString("hex") !== mint.toBuffer().toString("hex")) {
|
|
144
|
+
errors.push(`Depositor ATA mint mismatch: expected ${mint.toBase58()}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
splAccounts.push({ kind: "depositorAta", pubkey: depositorAta, writable: true }, { kind: "escrowAta", pubkey: escrowAta, writable: true }, { kind: "tokenMint", pubkey: mint, writable: false }, { kind: "tokenProgram", pubkey: new PublicKey(TOKEN_PROGRAM_ID_STR), writable: false });
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
valid: errors.length === 0,
|
|
151
|
+
escrow,
|
|
152
|
+
escrowPda,
|
|
153
|
+
agentPda,
|
|
154
|
+
isSplEscrow,
|
|
155
|
+
splAccounts,
|
|
156
|
+
errors,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* @name attachSplAccounts
|
|
161
|
+
* @description Build the typed `SplAccountMeta[]` for an SPL token escrow operation.
|
|
162
|
+
* Does NOT validate existence — use {@link validateEscrowState} for full validation.
|
|
163
|
+
*
|
|
164
|
+
* @param escrowPda - The escrow PDA address.
|
|
165
|
+
* @param depositorWallet - The depositor's wallet public key.
|
|
166
|
+
* @param tokenMint - The SPL token mint.
|
|
167
|
+
* @returns An array of typed {@link SplAccountMeta} for SPL escrow operations.
|
|
168
|
+
*
|
|
169
|
+
* @category Utils
|
|
170
|
+
* @since v0.6.4
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* const splMetas = attachSplAccounts(escrowPda, depositorWallet, usdcMint);
|
|
175
|
+
*
|
|
176
|
+
* // Convert to Anchor-compatible AccountMeta[]
|
|
177
|
+
* const accountMetas = splMetas.map(m => ({
|
|
178
|
+
* pubkey: m.pubkey,
|
|
179
|
+
* isWritable: m.writable,
|
|
180
|
+
* isSigner: false,
|
|
181
|
+
* }));
|
|
182
|
+
*
|
|
183
|
+
* await client.escrow.settle(depositor, calls, hash, accountMetas);
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export function attachSplAccounts(escrowPda, depositorWallet, tokenMint) {
|
|
187
|
+
return [
|
|
188
|
+
{ kind: "depositorAta", pubkey: findATA(depositorWallet, tokenMint), writable: true },
|
|
189
|
+
{ kind: "escrowAta", pubkey: findATA(escrowPda, tokenMint), writable: true },
|
|
190
|
+
{ kind: "tokenMint", pubkey: tokenMint, writable: false },
|
|
191
|
+
{ kind: "tokenProgram", pubkey: new PublicKey(TOKEN_PROGRAM_ID_STR), writable: false },
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @name toAccountMetas
|
|
196
|
+
* @description Convert typed {@link SplAccountMeta} to Anchor-compatible
|
|
197
|
+
* `AccountMeta[]` for use with `.remainingAccounts()`.
|
|
198
|
+
*
|
|
199
|
+
* @param splMetas - Array of typed SPL account metas.
|
|
200
|
+
* @returns `AccountMeta[]` compatible with Anchor's `remainingAccounts`.
|
|
201
|
+
*
|
|
202
|
+
* @category Utils
|
|
203
|
+
* @since v0.6.4
|
|
204
|
+
*/
|
|
205
|
+
export function toAccountMetas(splMetas) {
|
|
206
|
+
return splMetas.map((m) => ({
|
|
207
|
+
pubkey: m.pubkey,
|
|
208
|
+
isWritable: m.writable,
|
|
209
|
+
isSigner: false,
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=escrow-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escrow-validation.js","sourceRoot":"","sources":["../../../src/utils/escrow-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,SAAS,GAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,QAAQ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AC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,QAA0B;IACvD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1B,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,UAAU,EAAE,CAAC,CAAC,QAAQ;QACtB,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC,CAAC;AACN,CAAC"}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -23,4 +23,8 @@ export { getRpcUrl, getFallbackRpcUrl, createDualConnection, findATA, classifyAn
|
|
|
23
23
|
export { createEnvSchema, createEndpointDescriptorSchema, createHealthCheckSchema, createToolManifestEntrySchema, createAgentManifestSchema, createPreparePaymentSchema, createRegisterAgentSchema, createCallArgsSchema, validateOrThrow, } from "./schemas";
|
|
24
24
|
// ── v0.6.2 Priority Fee & Settle Options ───────────
|
|
25
25
|
export { buildPriorityFeeIxs, buildRpcOptions, FAST_SETTLE_OPTIONS, FAST_BATCH_SETTLE_OPTIONS, DEFAULT_SETTLE_PRIORITY_FEE, DEFAULT_SETTLE_COMPUTE_UNITS, DEFAULT_BATCH_SETTLE_COMPUTE_UNITS, } from "./priority-fee";
|
|
26
|
+
// ── v0.6.4 Escrow Validation & Merchant Middleware ──
|
|
27
|
+
export { validateEscrowState, attachSplAccounts, toAccountMetas, MissingEscrowAtaError, } from "./escrow-validation";
|
|
28
|
+
export { SapMerchantValidator, parseX402Headers, } from "./merchant-validator";
|
|
29
|
+
export { getX402DirectPayments } from "./x402-direct";
|
|
26
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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;AAEnE,uDAAuD;AACvD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,uBAAuB,EACvB,6BAA6B,EAC7B,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,uDAAuD;AACvD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,kCAAkC,GACnC,MAAM,gBAAgB,CAAC"}
|
|
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;AAEnE,uDAAuD;AACvD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,uBAAuB,EACvB,6BAA6B,EAC7B,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,uDAAuD;AACvD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,kCAAkC,GACnC,MAAM,gBAAgB,CAAC;AAMxB,wDAAwD;AACxD,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EACL,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module utils/merchant-validator
|
|
3
|
+
* @description Standard Synapse merchant middleware for x402 settlement.
|
|
4
|
+
*
|
|
5
|
+
* Reads `X-Payment-*` headers from incoming HTTP requests, validates
|
|
6
|
+
* the escrow on-chain, auto-generates the correct `AccountMeta[]`,
|
|
7
|
+
* and throws explicit errors (e.g. {@link MissingEscrowAtaError})
|
|
8
|
+
* instead of letting the program return a generic crash.
|
|
9
|
+
*
|
|
10
|
+
* Designed for agents like Syra/Invoica that receive x402 payments.
|
|
11
|
+
*
|
|
12
|
+
* @category Utils
|
|
13
|
+
* @since v0.6.4
|
|
14
|
+
*/
|
|
15
|
+
import { PublicKey as PK } from "@solana/web3.js";
|
|
16
|
+
import { BN } from "@coral-xyz/anchor";
|
|
17
|
+
import { validateEscrowState, toAccountMetas, MissingEscrowAtaError, } from "./escrow-validation";
|
|
18
|
+
import { SapValidationError } from "../errors";
|
|
19
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
20
|
+
// Header parsing
|
|
21
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
22
|
+
/** Required x402 headers. */
|
|
23
|
+
const REQUIRED_HEADERS = [
|
|
24
|
+
"X-Payment-Protocol",
|
|
25
|
+
"X-Payment-Escrow",
|
|
26
|
+
"X-Payment-Agent",
|
|
27
|
+
"X-Payment-Depositor",
|
|
28
|
+
"X-Payment-MaxCalls",
|
|
29
|
+
"X-Payment-PricePerCall",
|
|
30
|
+
"X-Payment-Program",
|
|
31
|
+
"X-Payment-Network",
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* @name parseX402Headers
|
|
35
|
+
* @description Parse and validate x402 headers from an HTTP request.
|
|
36
|
+
*
|
|
37
|
+
* @param headers - HTTP headers object (case-insensitive key lookup).
|
|
38
|
+
* @returns Parsed x402 headers.
|
|
39
|
+
* @throws {SapValidationError} If required headers are missing or malformed.
|
|
40
|
+
*
|
|
41
|
+
* @category Utils
|
|
42
|
+
* @since v0.6.4
|
|
43
|
+
*/
|
|
44
|
+
export function parseX402Headers(headers) {
|
|
45
|
+
// Normalize to case-insensitive
|
|
46
|
+
const normalized = new Map();
|
|
47
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
48
|
+
const val = Array.isArray(value) ? value[0] : value;
|
|
49
|
+
if (val !== undefined) {
|
|
50
|
+
normalized.set(key.toLowerCase(), val);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Validate required headers present
|
|
54
|
+
const missing = [];
|
|
55
|
+
for (const h of REQUIRED_HEADERS) {
|
|
56
|
+
if (!normalized.has(h.toLowerCase())) {
|
|
57
|
+
missing.push(h);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (missing.length > 0) {
|
|
61
|
+
throw new SapValidationError(`Missing required x402 headers: ${missing.join(", ")}`, "x402-headers");
|
|
62
|
+
}
|
|
63
|
+
const get = (key) => normalized.get(key.toLowerCase());
|
|
64
|
+
// Validate protocol
|
|
65
|
+
const protocol = get("X-Payment-Protocol");
|
|
66
|
+
if (protocol !== "SAP-x402") {
|
|
67
|
+
throw new SapValidationError(`Invalid X-Payment-Protocol: "${protocol}" (expected "SAP-x402")`, "X-Payment-Protocol");
|
|
68
|
+
}
|
|
69
|
+
// Parse PublicKeys
|
|
70
|
+
let escrowPda;
|
|
71
|
+
let agentPda;
|
|
72
|
+
let depositorWallet;
|
|
73
|
+
let programId;
|
|
74
|
+
try {
|
|
75
|
+
escrowPda = new PK(get("X-Payment-Escrow"));
|
|
76
|
+
agentPda = new PK(get("X-Payment-Agent"));
|
|
77
|
+
depositorWallet = new PK(get("X-Payment-Depositor"));
|
|
78
|
+
programId = new PK(get("X-Payment-Program"));
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
throw new SapValidationError("Malformed public key in x402 headers", "x402-headers");
|
|
82
|
+
}
|
|
83
|
+
// Parse numeric values
|
|
84
|
+
const maxCallsStr = get("X-Payment-MaxCalls");
|
|
85
|
+
const pricePerCallStr = get("X-Payment-PricePerCall");
|
|
86
|
+
let maxCalls;
|
|
87
|
+
let pricePerCall;
|
|
88
|
+
try {
|
|
89
|
+
maxCalls = new BN(maxCallsStr);
|
|
90
|
+
pricePerCall = new BN(pricePerCallStr);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
throw new SapValidationError("Invalid numeric value in X-Payment-MaxCalls or X-Payment-PricePerCall", "x402-headers");
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
protocol,
|
|
97
|
+
escrowPda,
|
|
98
|
+
agentPda,
|
|
99
|
+
depositorWallet,
|
|
100
|
+
maxCalls,
|
|
101
|
+
pricePerCall,
|
|
102
|
+
programId,
|
|
103
|
+
network: get("X-Payment-Network"),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
107
|
+
// Merchant Validator
|
|
108
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
109
|
+
/**
|
|
110
|
+
* @name SapMerchantValidator
|
|
111
|
+
* @description Standard Synapse merchant middleware for x402 payment validation.
|
|
112
|
+
*
|
|
113
|
+
* Reads `X-Payment-*` headers, validates escrow state on-chain, generates
|
|
114
|
+
* correct `AccountMeta[]` for SPL token escrows, and throws explicit errors
|
|
115
|
+
* (e.g. {@link MissingEscrowAtaError}) when ATA accounts are missing.
|
|
116
|
+
*
|
|
117
|
+
* @category Utils
|
|
118
|
+
* @since v0.6.4
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* const validator = new SapMerchantValidator(connection, fetchEscrow);
|
|
123
|
+
*
|
|
124
|
+
* // Express.js integration
|
|
125
|
+
* app.post("/api/v1/chat", async (req, res) => {
|
|
126
|
+
* try {
|
|
127
|
+
* const validation = await validator.validateRequest(req.headers, {
|
|
128
|
+
* callsToSettle: 1,
|
|
129
|
+
* });
|
|
130
|
+
*
|
|
131
|
+
* if (!validation.valid) {
|
|
132
|
+
* return res.status(402).json({ errors: validation.errors });
|
|
133
|
+
* }
|
|
134
|
+
*
|
|
135
|
+
* // Process request...
|
|
136
|
+
*
|
|
137
|
+
* // Settle payment using pre-built account metas
|
|
138
|
+
* await client.escrow.settle(
|
|
139
|
+
* validation.headers.depositorWallet,
|
|
140
|
+
* 1,
|
|
141
|
+
* serviceHash,
|
|
142
|
+
* validation.accountMetas,
|
|
143
|
+
* );
|
|
144
|
+
*
|
|
145
|
+
* res.json({ result: "..." });
|
|
146
|
+
* } catch (err) {
|
|
147
|
+
* if (err instanceof MissingEscrowAtaError) {
|
|
148
|
+
* return res.status(402).json({
|
|
149
|
+
* error: err.message,
|
|
150
|
+
* side: err.side,
|
|
151
|
+
* ata: err.ataAddress,
|
|
152
|
+
* });
|
|
153
|
+
* }
|
|
154
|
+
* throw err;
|
|
155
|
+
* }
|
|
156
|
+
* });
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
export class SapMerchantValidator {
|
|
160
|
+
connection;
|
|
161
|
+
fetchEscrow;
|
|
162
|
+
/**
|
|
163
|
+
* @param connection - Solana RPC connection.
|
|
164
|
+
* @param fetchEscrow - Callback to fetch escrow account data by PDA.
|
|
165
|
+
* Typically `(pda) => client.escrow.fetchByPda(pda).catch(() => null)`.
|
|
166
|
+
*/
|
|
167
|
+
constructor(connection, fetchEscrow) {
|
|
168
|
+
this.connection = connection;
|
|
169
|
+
this.fetchEscrow = fetchEscrow;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @name validateRequest
|
|
173
|
+
* @description Full validation pipeline for an incoming x402 request.
|
|
174
|
+
*
|
|
175
|
+
* Steps:
|
|
176
|
+
* 1. Parse `X-Payment-*` headers
|
|
177
|
+
* 2. Fetch escrow on-chain
|
|
178
|
+
* 3. Validate escrow state (balance, expiry, max calls)
|
|
179
|
+
* 4. If SPL escrow: validate ATAs exist and mint matches
|
|
180
|
+
* 5. Build `AccountMeta[]` for settlement TX
|
|
181
|
+
*
|
|
182
|
+
* @param headers - HTTP headers from the incoming request.
|
|
183
|
+
* @param opts
|
|
184
|
+
* @param opts.callsToSettle - Number of calls to validate affordability for (default: 1).
|
|
185
|
+
* @param opts.throwOnMissingAta - Throw {@link MissingEscrowAtaError} instead of returning errors (default: true).
|
|
186
|
+
*
|
|
187
|
+
* @returns A complete {@link MerchantValidationResult}.
|
|
188
|
+
*
|
|
189
|
+
* @throws {SapValidationError} If headers are missing or malformed.
|
|
190
|
+
* @throws {MissingEscrowAtaError} If SPL ATAs are missing and `throwOnMissingAta` is true.
|
|
191
|
+
*
|
|
192
|
+
* @category Utils
|
|
193
|
+
* @since v0.6.4
|
|
194
|
+
*/
|
|
195
|
+
async validateRequest(headers, opts) {
|
|
196
|
+
// 1. Parse headers
|
|
197
|
+
const parsed = parseX402Headers(headers);
|
|
198
|
+
// 2. Validate escrow state
|
|
199
|
+
const escrowValidation = await validateEscrowState(this.connection, parsed.agentPda, // agentWallet derived inside validate
|
|
200
|
+
parsed.depositorWallet, this.fetchEscrow, { callsToSettle: opts?.callsToSettle ?? 1 });
|
|
201
|
+
// 3. Check for ATA errors and optionally throw
|
|
202
|
+
const throwOnMissingAta = opts?.throwOnMissingAta !== false;
|
|
203
|
+
if (throwOnMissingAta && escrowValidation.isSplEscrow) {
|
|
204
|
+
for (const error of escrowValidation.errors) {
|
|
205
|
+
if (error.includes("Depositor ATA does not exist")) {
|
|
206
|
+
const ataAddr = error.split(": ")[1] ?? "unknown";
|
|
207
|
+
throw new MissingEscrowAtaError(ataAddr, "depositor");
|
|
208
|
+
}
|
|
209
|
+
if (error.includes("Escrow ATA does not exist")) {
|
|
210
|
+
const ataAddr = error.split(": ")[1] ?? "unknown";
|
|
211
|
+
throw new MissingEscrowAtaError(ataAddr, "escrow");
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// 4. Build account metas
|
|
216
|
+
const accountMetas = toAccountMetas(escrowValidation.splAccounts);
|
|
217
|
+
return {
|
|
218
|
+
valid: escrowValidation.valid,
|
|
219
|
+
headers: parsed,
|
|
220
|
+
escrowValidation,
|
|
221
|
+
accountMetas,
|
|
222
|
+
errors: escrowValidation.errors,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* @name validateEscrow
|
|
227
|
+
* @description Validate escrow from pre-parsed headers (convenience method).
|
|
228
|
+
* Call this when you've already parsed the headers yourself.
|
|
229
|
+
*
|
|
230
|
+
* @param headers - Pre-parsed x402 headers.
|
|
231
|
+
* @param opts
|
|
232
|
+
* @returns The escrow validation result with pre-built account metas.
|
|
233
|
+
*
|
|
234
|
+
* @category Utils
|
|
235
|
+
* @since v0.6.4
|
|
236
|
+
*/
|
|
237
|
+
async validateEscrow(headers, opts) {
|
|
238
|
+
return validateEscrowState(this.connection, headers.agentPda, headers.depositorWallet, this.fetchEscrow, opts);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=merchant-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merchant-validator.js","sourceRoot":"","sources":["../../../src/utils/merchant-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,OAAO,EAAE,SAAS,IAAI,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAmD/C,sEAAsE;AACtE,kBAAkB;AAClB,sEAAsE;AAEtE,6BAA6B;AAC7B,MAAM,gBAAgB,GAAG;IACvB,oBAAoB;IACpB,kBAAkB;IAClB,iBAAiB;IACjB,qBAAqB;IACrB,oBAAoB;IACpB,wBAAwB;IACxB,mBAAmB;IACnB,mBAAmB;CACX,CAAC;AAEX;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAsD;IAEtD,gCAAgC;IAChC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACpD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,GAAG,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,oCAAoC;IACpC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,CAAC,IAAI,gBAAgB,EAAE,CAAC;Q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