@oobe-protocol-labs/synapse-sap-sdk 0.6.2 → 0.7.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 +7 -0
- package/dist/cjs/constants/seeds.js.map +1 -1
- package/dist/cjs/core/client.js +42 -0
- package/dist/cjs/core/client.js.map +1 -1
- package/dist/cjs/events/geyser.js +295 -0
- package/dist/cjs/events/geyser.js.map +1 -0
- package/dist/cjs/idl/synapse_agent_sap.json +7545 -3501
- package/dist/cjs/index.js +28 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/escrow-v2.js +241 -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 +7 -1
- package/dist/cjs/modules/index.js.map +1 -1
- 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 +143 -1
- package/dist/cjs/pda/index.js.map +1 -1
- package/dist/cjs/postgres/sync.js +72 -4
- package/dist/cjs/postgres/sync.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 +51 -1
- package/dist/cjs/types/enums.js.map +1 -1
- package/dist/cjs/types/index.js +4 -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 +7 -0
- package/dist/esm/constants/seeds.js.map +1 -1
- package/dist/esm/core/client.js +42 -0
- package/dist/esm/core/client.js.map +1 -1
- package/dist/esm/events/geyser.js +258 -0
- package/dist/esm/events/geyser.js.map +1 -0
- package/dist/esm/idl/synapse_agent_sap.json +7545 -3501
- package/dist/esm/index.js +7 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/escrow-v2.js +237 -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 +3 -0
- package/dist/esm/modules/index.js.map +1 -1
- 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 +135 -0
- package/dist/esm/pda/index.js.map +1 -1
- package/dist/esm/postgres/sync.js +72 -4
- package/dist/esm/postgres/sync.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 +50 -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 +7 -0
- package/dist/types/constants/seeds.d.ts.map +1 -1
- package/dist/types/core/client.d.ts +33 -0
- package/dist/types/core/client.d.ts.map +1 -1
- package/dist/types/events/geyser.d.ts +150 -0
- package/dist/types/events/geyser.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/escrow-v2.d.ts +51 -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 +3 -0
- package/dist/types/modules/index.d.ts.map +1 -1
- 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 +99 -0
- package/dist/types/pda/index.d.ts.map +1 -1
- package/dist/types/plugin/schemas.d.ts +2 -2
- package/dist/types/postgres/sync.d.ts +26 -2
- package/dist/types/postgres/sync.d.ts.map +1 -1
- 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 +157 -1
- package/dist/types/types/accounts.d.ts.map +1 -1
- package/dist/types/types/enums.d.ts +64 -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 +5 -1
- package/src/constants/seeds.ts +7 -0
- package/src/core/client.ts +45 -0
- package/src/events/geyser.ts +384 -0
- package/src/events/yellowstone.d.ts +7 -0
- package/src/idl/synapse_agent_sap.json +7545 -3501
- package/src/index.ts +51 -0
- package/src/modules/escrow-v2.ts +396 -0
- package/src/modules/escrow.ts +4 -0
- package/src/modules/index.ts +3 -0
- package/src/modules/staking.ts +122 -0
- package/src/modules/subscription.ts +147 -0
- package/src/pda/index.ts +196 -0
- package/src/postgres/sync.ts +90 -4
- package/src/registries/x402.ts +108 -69
- package/src/types/accounts.ts +192 -1
- package/src/types/enums.ts +65 -0
- package/src/types/index.ts +15 -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
|
@@ -235,4 +235,68 @@ export declare const ToolCategory: {
|
|
|
235
235
|
* @description Union of all {@link ToolCategory} variant shapes.
|
|
236
236
|
*/
|
|
237
237
|
export type ToolCategoryKind = (typeof ToolCategory)[keyof typeof ToolCategory];
|
|
238
|
+
/**
|
|
239
|
+
* @name SettlementSecurity
|
|
240
|
+
* @description Anchor-compatible enum variants for V2 escrow settlement security levels.
|
|
241
|
+
*
|
|
242
|
+
* - `SelfReport` — Agent settles unilaterally (v1 compatible).
|
|
243
|
+
* - `CoSigned` — Agent + client must co-sign every settlement.
|
|
244
|
+
* - `DisputeWindow` — Settlement enters pending state, depositor can dispute.
|
|
245
|
+
*
|
|
246
|
+
* @category Types
|
|
247
|
+
* @since v0.5.0
|
|
248
|
+
*/
|
|
249
|
+
export declare const SettlementSecurity: {
|
|
250
|
+
readonly SelfReport: {
|
|
251
|
+
readonly selfReport: {};
|
|
252
|
+
};
|
|
253
|
+
readonly CoSigned: {
|
|
254
|
+
readonly coSigned: {};
|
|
255
|
+
};
|
|
256
|
+
readonly DisputeWindow: {
|
|
257
|
+
readonly disputeWindow: {};
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
export type SettlementSecurityKind = (typeof SettlementSecurity)[keyof typeof SettlementSecurity];
|
|
261
|
+
/**
|
|
262
|
+
* @name DisputeOutcome
|
|
263
|
+
* @description Anchor-compatible enum variants for dispute resolution outcomes.
|
|
264
|
+
*
|
|
265
|
+
* @category Types
|
|
266
|
+
* @since v0.5.0
|
|
267
|
+
*/
|
|
268
|
+
export declare const DisputeOutcome: {
|
|
269
|
+
readonly Pending: {
|
|
270
|
+
readonly pending: {};
|
|
271
|
+
};
|
|
272
|
+
readonly AutoReleased: {
|
|
273
|
+
readonly autoReleased: {};
|
|
274
|
+
};
|
|
275
|
+
readonly DepositorWins: {
|
|
276
|
+
readonly depositorWins: {};
|
|
277
|
+
};
|
|
278
|
+
readonly AgentWins: {
|
|
279
|
+
readonly agentWins: {};
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
export type DisputeOutcomeKind = (typeof DisputeOutcome)[keyof typeof DisputeOutcome];
|
|
283
|
+
/**
|
|
284
|
+
* @name BillingInterval
|
|
285
|
+
* @description Anchor-compatible enum variants for subscription billing intervals.
|
|
286
|
+
*
|
|
287
|
+
* @category Types
|
|
288
|
+
* @since v0.5.0
|
|
289
|
+
*/
|
|
290
|
+
export declare const BillingInterval: {
|
|
291
|
+
readonly Daily: {
|
|
292
|
+
readonly daily: {};
|
|
293
|
+
};
|
|
294
|
+
readonly Weekly: {
|
|
295
|
+
readonly weekly: {};
|
|
296
|
+
};
|
|
297
|
+
readonly Monthly: {
|
|
298
|
+
readonly monthly: {};
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
export type BillingIntervalKind = (typeof BillingInterval)[keyof typeof BillingInterval];
|
|
238
302
|
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/types/enums.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;CAIZ,CAAC;AAEX;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAA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"}
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
* import { TokenType, SettlementMode } from "@synapse-sap/sdk/types";
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
export { TokenType, PluginType, SettlementMode, ToolHttpMethod, ToolCategory, } from "./enums";
|
|
23
|
-
export type { TokenTypeKind, PluginTypeKind, SettlementModeKind, ToolHttpMethodKind, ToolCategoryKind, } from "./enums";
|
|
22
|
+
export { TokenType, PluginType, SettlementMode, ToolHttpMethod, ToolCategory, SettlementSecurity, DisputeOutcome, BillingInterval, } from "./enums";
|
|
23
|
+
export type { TokenTypeKind, PluginTypeKind, SettlementModeKind, ToolHttpMethodKind, ToolCategoryKind, SettlementSecurityKind, DisputeOutcomeKind, BillingIntervalKind, } from "./enums";
|
|
24
24
|
export type { Capability, VolumeCurveBreakpoint, PricingTier, PluginRef, Settlement, } from "./common";
|
|
25
|
-
export type { AgentAccountData, AgentStatsData, FeedbackAccountData, CapabilityIndexData, ProtocolIndexData, ToolCategoryIndexData, GlobalRegistryData, MemoryVaultData, SessionLedgerData, EpochPageData, VaultDelegateData, SessionCheckpointData, ToolDescriptorData, EscrowAccountData, AgentAttestationData, MemoryLedgerData, LedgerPageData, } from "./accounts";
|
|
26
|
-
export type { RegisterAgentArgs, UpdateAgentArgs, GiveFeedbackArgs, UpdateFeedbackArgs, PublishToolArgs, UpdateToolArgs, InscribeToolSchemaArgs, InscribeMemoryArgs, CompactInscribeArgs, CreateEscrowArgs, CreateAttestationArgs, DelegatePermissionBit, SchemaTypeValue, CompressionTypeValue, } from "./instructions";
|
|
25
|
+
export type { AgentAccountData, AgentStatsData, FeedbackAccountData, CapabilityIndexData, ProtocolIndexData, ToolCategoryIndexData, GlobalRegistryData, MemoryVaultData, SessionLedgerData, EpochPageData, VaultDelegateData, SessionCheckpointData, ToolDescriptorData, EscrowAccountData, AgentAttestationData, MemoryLedgerData, LedgerPageData, EscrowAccountV2Data, PendingSettlementData, DisputeRecordData, AgentStakeData, SubscriptionData, CounterShardData, IndexPageData, } from "./accounts";
|
|
26
|
+
export type { RegisterAgentArgs, UpdateAgentArgs, GiveFeedbackArgs, UpdateFeedbackArgs, PublishToolArgs, UpdateToolArgs, InscribeToolSchemaArgs, InscribeMemoryArgs, CompactInscribeArgs, CreateEscrowArgs, CreateAttestationArgs, DelegatePermissionBit, SchemaTypeValue, CompressionTypeValue, CreateEscrowV2Args, CreateSubscriptionArgs, } from "./instructions";
|
|
27
27
|
export { DelegatePermission, SchemaType, CompressionType, } from "./instructions";
|
|
28
28
|
export type { EndpointDescriptor, HealthCheckDescriptor, ToolManifestEntry, AgentManifest, EndpointValidationResult, } from "./endpoint";
|
|
29
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,UAAU,EACV,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,UAAU,GACX,MAAM,UAAU,CAAC;AAGlB,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
|
|
@@ -238,6 +238,7 @@ export interface CompactInscribeArgs {
|
|
|
238
238
|
*
|
|
239
239
|
* @category Types
|
|
240
240
|
* @since v0.1.0
|
|
241
|
+
* @deprecated Since v0.7.0 — Use {@link CreateEscrowV2Args} for V2 escrows.
|
|
241
242
|
* @see {@link VolumeCurveBreakpoint} for discount curve details.
|
|
242
243
|
*/
|
|
243
244
|
export interface CreateEscrowArgs {
|
|
@@ -363,4 +364,37 @@ export declare const CompressionType: {
|
|
|
363
364
|
* @description Union of valid {@link CompressionType} discriminant values.
|
|
364
365
|
*/
|
|
365
366
|
export type CompressionTypeValue = (typeof CompressionType)[keyof typeof CompressionType];
|
|
367
|
+
/**
|
|
368
|
+
* @interface CreateEscrowV2Args
|
|
369
|
+
* @description Arguments for the `createEscrowV2` instruction.
|
|
370
|
+
* @category Types
|
|
371
|
+
* @since v0.5.0
|
|
372
|
+
*/
|
|
373
|
+
export interface CreateEscrowV2Args {
|
|
374
|
+
readonly escrowNonce: BN;
|
|
375
|
+
readonly pricePerCall: BN;
|
|
376
|
+
readonly maxCalls: BN;
|
|
377
|
+
readonly initialDeposit: BN;
|
|
378
|
+
readonly expiresAt: BN;
|
|
379
|
+
readonly volumeCurve: VolumeCurveBreakpoint[];
|
|
380
|
+
readonly tokenMint: PublicKey | null;
|
|
381
|
+
readonly tokenDecimals: number;
|
|
382
|
+
/** 0=SelfReport, 1=CoSigned, 2=DisputeWindow */
|
|
383
|
+
readonly settlementSecurity: number;
|
|
384
|
+
readonly disputeWindowSlots: BN;
|
|
385
|
+
readonly coSigner: PublicKey | null;
|
|
386
|
+
readonly arbiter: PublicKey | null;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* @interface CreateSubscriptionArgs
|
|
390
|
+
* @description Arguments for the `createSubscription` instruction.
|
|
391
|
+
* @category Types
|
|
392
|
+
* @since v0.5.0
|
|
393
|
+
*/
|
|
394
|
+
export interface CreateSubscriptionArgs {
|
|
395
|
+
readonly subId: BN;
|
|
396
|
+
readonly pricePerInterval: BN;
|
|
397
|
+
readonly billingInterval: number;
|
|
398
|
+
readonly initialFund: BN;
|
|
399
|
+
}
|
|
366
400
|
//# sourceMappingURL=instructions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../../src/types/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAM/E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,iBAAiB;IAChC,0BAA0B;IAC1B,QAAQ,CAAC,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,EAAE,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,qBAAqB,EAAE,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,gDAAgD;IAChD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,kBAAkB,EAAE,EAAE,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;CACpC;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;IACnB,QAAQ,CAAC,gBAAgB,EAAE,EAAE,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;CAC1B"}
|
|
@@ -0,0 +1,145 @@
|
|
|
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, type Connection, type AccountMeta } from "@solana/web3.js";
|
|
12
|
+
import { SapError } from "../errors";
|
|
13
|
+
import type { EscrowAccountData } from "../types";
|
|
14
|
+
/**
|
|
15
|
+
* @interface SplAccountMeta
|
|
16
|
+
* @description Typed SPL account metadata for escrow operations.
|
|
17
|
+
* @category Utils
|
|
18
|
+
* @since v0.6.4
|
|
19
|
+
*/
|
|
20
|
+
export interface SplAccountMeta {
|
|
21
|
+
/** Account role in the escrow pipeline. */
|
|
22
|
+
readonly kind: "escrowAta" | "depositorAta" | "tokenMint" | "tokenProgram";
|
|
23
|
+
/** Account public key. */
|
|
24
|
+
readonly pubkey: PublicKey;
|
|
25
|
+
/** Whether this account is writable. */
|
|
26
|
+
readonly writable: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @interface EscrowValidationResult
|
|
30
|
+
* @description Result of server-side escrow state validation.
|
|
31
|
+
* @category Utils
|
|
32
|
+
* @since v0.6.4
|
|
33
|
+
*/
|
|
34
|
+
export interface EscrowValidationResult {
|
|
35
|
+
/** Whether the escrow is valid for settlement. */
|
|
36
|
+
readonly valid: boolean;
|
|
37
|
+
/** Escrow account data (if found). */
|
|
38
|
+
readonly escrow: EscrowAccountData | null;
|
|
39
|
+
/** Escrow PDA address. */
|
|
40
|
+
readonly escrowPda: PublicKey;
|
|
41
|
+
/** Agent PDA address. */
|
|
42
|
+
readonly agentPda: PublicKey;
|
|
43
|
+
/** Whether this is an SPL token escrow (vs SOL). */
|
|
44
|
+
readonly isSplEscrow: boolean;
|
|
45
|
+
/** Generated SPL account metas (empty for SOL escrows). */
|
|
46
|
+
readonly splAccounts: SplAccountMeta[];
|
|
47
|
+
/** Validation errors (empty when valid). */
|
|
48
|
+
readonly errors: string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @name MissingEscrowAtaError
|
|
52
|
+
* @description Thrown when an SPL escrow operation is missing required
|
|
53
|
+
* Associated Token Accounts.
|
|
54
|
+
* @category Errors
|
|
55
|
+
* @since v0.6.4
|
|
56
|
+
*/
|
|
57
|
+
export declare class MissingEscrowAtaError extends SapError {
|
|
58
|
+
/** The ATA address that is missing. */
|
|
59
|
+
readonly ataAddress: string;
|
|
60
|
+
/** Which side is missing: depositor or escrow. */
|
|
61
|
+
readonly side: "depositor" | "escrow";
|
|
62
|
+
constructor(ataAddress: string, side: "depositor" | "escrow");
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @name validateEscrowState
|
|
66
|
+
* @description Validates that an escrow is in a correct state for settlement.
|
|
67
|
+
*
|
|
68
|
+
* Checks:
|
|
69
|
+
* - Escrow PDA exists on-chain
|
|
70
|
+
* - If SPL: depositor ATA exists, escrow ATA exists, token mint matches
|
|
71
|
+
* - Balance >= requested settlement amount
|
|
72
|
+
* - Escrow is not expired
|
|
73
|
+
* - Max calls not exceeded
|
|
74
|
+
*
|
|
75
|
+
* @param connection - Solana RPC connection.
|
|
76
|
+
* @param agentWallet - The agent's wallet public key.
|
|
77
|
+
* @param depositorWallet - The depositor's wallet public key.
|
|
78
|
+
* @param fetchEscrow - Callback to fetch escrow data (avoids coupling to SapProgram).
|
|
79
|
+
* @param opts
|
|
80
|
+
* @param opts.callsToSettle - Number of calls to validate affordability for.
|
|
81
|
+
*
|
|
82
|
+
* @returns A detailed {@link EscrowValidationResult}.
|
|
83
|
+
*
|
|
84
|
+
* @category Utils
|
|
85
|
+
* @since v0.6.4
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const result = await validateEscrowState(
|
|
90
|
+
* connection,
|
|
91
|
+
* agentWallet,
|
|
92
|
+
* depositorWallet,
|
|
93
|
+
* (pda) => client.escrow.fetchByPda(pda),
|
|
94
|
+
* { callsToSettle: 5 },
|
|
95
|
+
* );
|
|
96
|
+
*
|
|
97
|
+
* if (!result.valid) {
|
|
98
|
+
* console.error("Escrow validation failed:", result.errors);
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function validateEscrowState(connection: Connection, agentWallet: PublicKey, depositorWallet: PublicKey, fetchEscrow: (escrowPda: PublicKey) => Promise<EscrowAccountData | null>, opts?: {
|
|
103
|
+
callsToSettle?: number;
|
|
104
|
+
}): Promise<EscrowValidationResult>;
|
|
105
|
+
/**
|
|
106
|
+
* @name attachSplAccounts
|
|
107
|
+
* @description Build the typed `SplAccountMeta[]` for an SPL token escrow operation.
|
|
108
|
+
* Does NOT validate existence — use {@link validateEscrowState} for full validation.
|
|
109
|
+
*
|
|
110
|
+
* @param escrowPda - The escrow PDA address.
|
|
111
|
+
* @param depositorWallet - The depositor's wallet public key.
|
|
112
|
+
* @param tokenMint - The SPL token mint.
|
|
113
|
+
* @returns An array of typed {@link SplAccountMeta} for SPL escrow operations.
|
|
114
|
+
*
|
|
115
|
+
* @category Utils
|
|
116
|
+
* @since v0.6.4
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const splMetas = attachSplAccounts(escrowPda, depositorWallet, usdcMint);
|
|
121
|
+
*
|
|
122
|
+
* // Convert to Anchor-compatible AccountMeta[]
|
|
123
|
+
* const accountMetas = splMetas.map(m => ({
|
|
124
|
+
* pubkey: m.pubkey,
|
|
125
|
+
* isWritable: m.writable,
|
|
126
|
+
* isSigner: false,
|
|
127
|
+
* }));
|
|
128
|
+
*
|
|
129
|
+
* await client.escrow.settle(depositor, calls, hash, accountMetas);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare function attachSplAccounts(escrowPda: PublicKey, depositorWallet: PublicKey, tokenMint: PublicKey): SplAccountMeta[];
|
|
133
|
+
/**
|
|
134
|
+
* @name toAccountMetas
|
|
135
|
+
* @description Convert typed {@link SplAccountMeta} to Anchor-compatible
|
|
136
|
+
* `AccountMeta[]` for use with `.remainingAccounts()`.
|
|
137
|
+
*
|
|
138
|
+
* @param splMetas - Array of typed SPL account metas.
|
|
139
|
+
* @returns `AccountMeta[]` compatible with Anchor's `remainingAccounts`.
|
|
140
|
+
*
|
|
141
|
+
* @category Utils
|
|
142
|
+
* @since v0.6.4
|
|
143
|
+
*/
|
|
144
|
+
export declare function toAccountMetas(splMetas: SplAccountMeta[]): AccountMeta[];
|
|
145
|
+
//# sourceMappingURL=escrow-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escrow-validation.d.ts","sourceRoot":"","sources":["../../../src/utils/escrow-validation.ts"],"names":[],"mappings":"AAA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;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,SAAS,EACtB,eAAe,EAAE,SAAS,EAC1B,WAAW,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,EACxE,IAAI,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC,sBAAsB,CAAC,CAgGjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,SAAS,EAC1B,SAAS,EAAE,SAAS,GACnB,cAAc,EAAE,CAOlB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,WAAW,EAAE,CAMxE"}
|
|
@@ -24,4 +24,10 @@ export type { RpcConfig, DualConnection, AtaResult } from "./rpc-strategy";
|
|
|
24
24
|
export { createEnvSchema, createEndpointDescriptorSchema, createHealthCheckSchema, createToolManifestEntrySchema, createAgentManifestSchema, createPreparePaymentSchema, createRegisterAgentSchema, createCallArgsSchema, validateOrThrow, } from "./schemas";
|
|
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
26
|
export type { PriorityFeeConfig, SettleOptions, } from "./priority-fee";
|
|
27
|
+
export { validateEscrowState, attachSplAccounts, toAccountMetas, MissingEscrowAtaError, } from "./escrow-validation";
|
|
28
|
+
export type { SplAccountMeta, EscrowValidationResult, } from "./escrow-validation";
|
|
29
|
+
export { SapMerchantValidator, parseX402Headers, } from "./merchant-validator";
|
|
30
|
+
export type { ParsedX402Headers, MerchantValidationResult, } from "./merchant-validator";
|
|
31
|
+
export { getX402DirectPayments } from "./x402-direct";
|
|
32
|
+
export type { X402DirectPayment, SettlementPayload, GetX402DirectOptions, } from "./x402-direct";
|
|
27
33
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","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;AAGnE,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;AAC9B,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,uBAAuB,EACvB,6BAA6B,EAC7B,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,GAChB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,kCAAkC,GACnC,MAAM,gBAAg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AqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,cAAc,EACd,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
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 { type PublicKey, type Connection, type AccountMeta } from "@solana/web3.js";
|
|
16
|
+
import { BN } from "@coral-xyz/anchor";
|
|
17
|
+
import type { EscrowValidationResult } from "./escrow-validation";
|
|
18
|
+
import type { EscrowAccountData } from "../types";
|
|
19
|
+
/**
|
|
20
|
+
* @interface ParsedX402Headers
|
|
21
|
+
* @description Parsed and typed x402 payment headers from incoming HTTP request.
|
|
22
|
+
* @category Utils
|
|
23
|
+
* @since v0.6.4
|
|
24
|
+
*/
|
|
25
|
+
export interface ParsedX402Headers {
|
|
26
|
+
/** x402 protocol identifier — must be "SAP-x402". */
|
|
27
|
+
readonly protocol: string;
|
|
28
|
+
/** Escrow PDA address. */
|
|
29
|
+
readonly escrowPda: PublicKey;
|
|
30
|
+
/** Agent PDA address. */
|
|
31
|
+
readonly agentPda: PublicKey;
|
|
32
|
+
/** Depositor wallet address. */
|
|
33
|
+
readonly depositorWallet: PublicKey;
|
|
34
|
+
/** Max calls allowed. */
|
|
35
|
+
readonly maxCalls: BN;
|
|
36
|
+
/** Price per call. */
|
|
37
|
+
readonly pricePerCall: BN;
|
|
38
|
+
/** SAP program ID. */
|
|
39
|
+
readonly programId: PublicKey;
|
|
40
|
+
/** Network identifier. */
|
|
41
|
+
readonly network: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @interface MerchantValidationResult
|
|
45
|
+
* @description Complete validation result for merchant-side x402 processing.
|
|
46
|
+
* @category Utils
|
|
47
|
+
* @since v0.6.4
|
|
48
|
+
*/
|
|
49
|
+
export interface MerchantValidationResult {
|
|
50
|
+
/** Whether the escrow is valid and ready for settlement. */
|
|
51
|
+
readonly valid: boolean;
|
|
52
|
+
/** Parsed x402 headers. */
|
|
53
|
+
readonly headers: ParsedX402Headers;
|
|
54
|
+
/** Full escrow validation result. */
|
|
55
|
+
readonly escrowValidation: EscrowValidationResult;
|
|
56
|
+
/** Pre-built AccountMeta[] for settlement TX (empty for SOL escrows). */
|
|
57
|
+
readonly accountMetas: AccountMeta[];
|
|
58
|
+
/** All validation errors. */
|
|
59
|
+
readonly errors: string[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @name parseX402Headers
|
|
63
|
+
* @description Parse and validate x402 headers from an HTTP request.
|
|
64
|
+
*
|
|
65
|
+
* @param headers - HTTP headers object (case-insensitive key lookup).
|
|
66
|
+
* @returns Parsed x402 headers.
|
|
67
|
+
* @throws {SapValidationError} If required headers are missing or malformed.
|
|
68
|
+
*
|
|
69
|
+
* @category Utils
|
|
70
|
+
* @since v0.6.4
|
|
71
|
+
*/
|
|
72
|
+
export declare function parseX402Headers(headers: Record<string, string | string[] | undefined>): ParsedX402Headers;
|
|
73
|
+
/**
|
|
74
|
+
* @name SapMerchantValidator
|
|
75
|
+
* @description Standard Synapse merchant middleware for x402 payment validation.
|
|
76
|
+
*
|
|
77
|
+
* Reads `X-Payment-*` headers, validates escrow state on-chain, generates
|
|
78
|
+
* correct `AccountMeta[]` for SPL token escrows, and throws explicit errors
|
|
79
|
+
* (e.g. {@link MissingEscrowAtaError}) when ATA accounts are missing.
|
|
80
|
+
*
|
|
81
|
+
* @category Utils
|
|
82
|
+
* @since v0.6.4
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const validator = new SapMerchantValidator(connection, fetchEscrow);
|
|
87
|
+
*
|
|
88
|
+
* // Express.js integration
|
|
89
|
+
* app.post("/api/v1/chat", async (req, res) => {
|
|
90
|
+
* try {
|
|
91
|
+
* const validation = await validator.validateRequest(req.headers, {
|
|
92
|
+
* callsToSettle: 1,
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* if (!validation.valid) {
|
|
96
|
+
* return res.status(402).json({ errors: validation.errors });
|
|
97
|
+
* }
|
|
98
|
+
*
|
|
99
|
+
* // Process request...
|
|
100
|
+
*
|
|
101
|
+
* // Settle payment using pre-built account metas
|
|
102
|
+
* await client.escrow.settle(
|
|
103
|
+
* validation.headers.depositorWallet,
|
|
104
|
+
* 1,
|
|
105
|
+
* serviceHash,
|
|
106
|
+
* validation.accountMetas,
|
|
107
|
+
* );
|
|
108
|
+
*
|
|
109
|
+
* res.json({ result: "..." });
|
|
110
|
+
* } catch (err) {
|
|
111
|
+
* if (err instanceof MissingEscrowAtaError) {
|
|
112
|
+
* return res.status(402).json({
|
|
113
|
+
* error: err.message,
|
|
114
|
+
* side: err.side,
|
|
115
|
+
* ata: err.ataAddress,
|
|
116
|
+
* });
|
|
117
|
+
* }
|
|
118
|
+
* throw err;
|
|
119
|
+
* }
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare class SapMerchantValidator {
|
|
124
|
+
private readonly connection;
|
|
125
|
+
private readonly fetchEscrow;
|
|
126
|
+
/**
|
|
127
|
+
* @param connection - Solana RPC connection.
|
|
128
|
+
* @param fetchEscrow - Callback to fetch escrow account data by PDA.
|
|
129
|
+
* Typically `(pda) => client.escrow.fetchByPda(pda).catch(() => null)`.
|
|
130
|
+
*/
|
|
131
|
+
constructor(connection: Connection, fetchEscrow: (escrowPda: PublicKey) => Promise<EscrowAccountData | null>);
|
|
132
|
+
/**
|
|
133
|
+
* @name validateRequest
|
|
134
|
+
* @description Full validation pipeline for an incoming x402 request.
|
|
135
|
+
*
|
|
136
|
+
* Steps:
|
|
137
|
+
* 1. Parse `X-Payment-*` headers
|
|
138
|
+
* 2. Fetch escrow on-chain
|
|
139
|
+
* 3. Validate escrow state (balance, expiry, max calls)
|
|
140
|
+
* 4. If SPL escrow: validate ATAs exist and mint matches
|
|
141
|
+
* 5. Build `AccountMeta[]` for settlement TX
|
|
142
|
+
*
|
|
143
|
+
* @param headers - HTTP headers from the incoming request.
|
|
144
|
+
* @param opts
|
|
145
|
+
* @param opts.callsToSettle - Number of calls to validate affordability for (default: 1).
|
|
146
|
+
* @param opts.throwOnMissingAta - Throw {@link MissingEscrowAtaError} instead of returning errors (default: true).
|
|
147
|
+
*
|
|
148
|
+
* @returns A complete {@link MerchantValidationResult}.
|
|
149
|
+
*
|
|
150
|
+
* @throws {SapValidationError} If headers are missing or malformed.
|
|
151
|
+
* @throws {MissingEscrowAtaError} If SPL ATAs are missing and `throwOnMissingAta` is true.
|
|
152
|
+
*
|
|
153
|
+
* @category Utils
|
|
154
|
+
* @since v0.6.4
|
|
155
|
+
*/
|
|
156
|
+
validateRequest(headers: Record<string, string | string[] | undefined>, opts?: {
|
|
157
|
+
callsToSettle?: number;
|
|
158
|
+
throwOnMissingAta?: boolean;
|
|
159
|
+
}): Promise<MerchantValidationResult>;
|
|
160
|
+
/**
|
|
161
|
+
* @name validateEscrow
|
|
162
|
+
* @description Validate escrow from pre-parsed headers (convenience method).
|
|
163
|
+
* Call this when you've already parsed the headers yourself.
|
|
164
|
+
*
|
|
165
|
+
* @param headers - Pre-parsed x402 headers.
|
|
166
|
+
* @param opts
|
|
167
|
+
* @returns The escrow validation result with pre-built account metas.
|
|
168
|
+
*
|
|
169
|
+
* @category Utils
|
|
170
|
+
* @since v0.6.4
|
|
171
|
+
*/
|
|
172
|
+
validateEscrow(headers: ParsedX402Headers, opts?: {
|
|
173
|
+
callsToSettle?: number;
|
|
174
|
+
}): Promise<EscrowValidationResult>;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=merchant-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merchant-validator.d.ts","sourceRoot":"","sources":["../../../src/utils/merchant-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAMvC,OAAO,KAAK,EACV,sBAAsB,EACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAMlD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,0BAA0B;IAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,yBAAyB;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,gCAAgC;IAChC,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC;IACpC,yBAAyB;IACzB,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;IACtB,sBAAsB;IACtB,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC;IAC1B,sBAAsB;IACtB,QAAQ,CAAC,SAAS,EAAE,SA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EAC1B,IAAI,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAChC,OAAO,CAAC,sBAAsB,CAAC;CASnC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module utils/x402-direct
|
|
3
|
+
* @description Recognize x402 direct SPL token payments on an agent's ATA
|
|
4
|
+
* by scanning transaction history and filtering for x402 patterns.
|
|
5
|
+
*
|
|
6
|
+
* @category Utils
|
|
7
|
+
* @since v0.6.4
|
|
8
|
+
*/
|
|
9
|
+
import { type Connection, PublicKey } from "@solana/web3.js";
|
|
10
|
+
/**
|
|
11
|
+
* @interface SettlementPayload
|
|
12
|
+
* @description Settlement metadata from the merchant's PAYMENT-RESPONSE.
|
|
13
|
+
* @category Utils
|
|
14
|
+
* @since v0.6.4
|
|
15
|
+
*/
|
|
16
|
+
export interface SettlementPayload {
|
|
17
|
+
/** SHA-256 service hash. */
|
|
18
|
+
readonly serviceHash: string;
|
|
19
|
+
/** Resource identifier. */
|
|
20
|
+
readonly resource: string;
|
|
21
|
+
/** Agent wallet (base58). */
|
|
22
|
+
readonly agentWallet: string;
|
|
23
|
+
/** Depositor wallet (base58). */
|
|
24
|
+
readonly depositorWallet: string;
|
|
25
|
+
/** Amount in smallest unit. */
|
|
26
|
+
readonly amount: string;
|
|
27
|
+
/** Service timestamp. */
|
|
28
|
+
readonly timestamp: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @interface X402DirectPayment
|
|
32
|
+
* @description A recognized x402 direct SPL transfer on an agent's ATA.
|
|
33
|
+
* @category Utils
|
|
34
|
+
* @since v0.6.4
|
|
35
|
+
*/
|
|
36
|
+
export interface X402DirectPayment {
|
|
37
|
+
/** Transaction signature. */
|
|
38
|
+
readonly signature: string;
|
|
39
|
+
/** Transfer amount (in smallest token unit). */
|
|
40
|
+
readonly amount: bigint;
|
|
41
|
+
/** Source ATA (payer). */
|
|
42
|
+
readonly payerAta: PublicKey;
|
|
43
|
+
/** Destination ATA (payTo / agent). */
|
|
44
|
+
readonly payeeAta: PublicKey;
|
|
45
|
+
/** Token mint used for transfer. */
|
|
46
|
+
readonly mint: PublicKey;
|
|
47
|
+
/** Memo data (if a Memo instruction was included). */
|
|
48
|
+
readonly memo: string | null;
|
|
49
|
+
/** Matched settlement payload (if server-side verification is available). */
|
|
50
|
+
readonly settlement: SettlementPayload | null;
|
|
51
|
+
/** Block time (unix seconds). */
|
|
52
|
+
readonly blockTime: number | null;
|
|
53
|
+
/** Slot number. */
|
|
54
|
+
readonly slot: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @interface GetX402DirectOptions
|
|
58
|
+
* @description Options for {@link getX402DirectPayments}.
|
|
59
|
+
* @category Utils
|
|
60
|
+
* @since v0.6.4
|
|
61
|
+
*/
|
|
62
|
+
export interface GetX402DirectOptions {
|
|
63
|
+
/** Max signatures to scan (default: 100). */
|
|
64
|
+
readonly limit?: number;
|
|
65
|
+
/** Only return transfers from this specific payer. */
|
|
66
|
+
readonly filterPayer?: PublicKey;
|
|
67
|
+
/** Known settlements from server-side PAYMENT-RESPONSE logs.
|
|
68
|
+
* Used for deterministic hash matching. */
|
|
69
|
+
readonly knownSettlements?: SettlementPayload[];
|
|
70
|
+
/** Only include payments that match x402 memo prefix. Default: false. */
|
|
71
|
+
readonly requireMemo?: boolean;
|
|
72
|
+
/** Scan before this TX signature (pagination). */
|
|
73
|
+
readonly before?: string;
|
|
74
|
+
/** Scan after this TX signature (pagination). */
|
|
75
|
+
readonly until?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @name getX402DirectPayments
|
|
79
|
+
* @description Scan an agent's ATA for x402 direct payments.
|
|
80
|
+
*
|
|
81
|
+
* Fetches recent transaction signatures for the given `payTo` ATA,
|
|
82
|
+
* inspects each transaction for SPL token transfers, and filters
|
|
83
|
+
* for x402 payment patterns (memo prefix, settlement hash match, etc.).
|
|
84
|
+
*
|
|
85
|
+
* @param connection - Solana RPC connection.
|
|
86
|
+
* @param payToAta - The agent's receiving ATA (e.g. USDC ATA of Syra).
|
|
87
|
+
* @param opts - Filter and pagination options.
|
|
88
|
+
* @returns Array of recognized x402 direct payments, newest first.
|
|
89
|
+
*
|
|
90
|
+
* @category Utils
|
|
91
|
+
* @since v0.6.4
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { getX402DirectPayments, findATA } from "@oobe-protocol-labs/synapse-sap-sdk";
|
|
96
|
+
*
|
|
97
|
+
* const USDC_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
98
|
+
* const payToAta = findATA(agentWallet, USDC_MINT);
|
|
99
|
+
*
|
|
100
|
+
* const payments = await getX402DirectPayments(connection, payToAta, {
|
|
101
|
+
* limit: 50,
|
|
102
|
+
* knownSettlements: savedSettlements, // from your API PAYMENT-RESPONSE logs
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* for (const p of payments) {
|
|
106
|
+
* console.log(`${p.signature}: ${p.amount} from ${p.payerAta.toBase58()}`);
|
|
107
|
+
* if (p.settlement) {
|
|
108
|
+
* console.log(` Matched settlement: ${p.settlement.serviceHash}`);
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare function getX402DirectPayments(connection: Connection, payToAta: PublicKey, opts?: GetX402DirectOptions): Promise<X402DirectPayment[]>;
|
|
114
|
+
//# sourceMappingURL=x402-direct.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402-direct.d.ts","sourceRoot":"","sources":["../../../src/utils/x402-direct.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,UAAU,EACf,SAAS,EAGV,MAAM,iBAAiB,CAAC;AAOzB;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC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