@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.
Files changed (132) hide show
  1. package/dist/cjs/constants/seeds.js +9 -0
  2. package/dist/cjs/constants/seeds.js.map +1 -1
  3. package/dist/cjs/core/client.js +55 -0
  4. package/dist/cjs/core/client.js.map +1 -1
  5. package/dist/cjs/idl/synapse_agent_sap.json +8571 -4106
  6. package/dist/cjs/index.js +29 -3
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/modules/escrow-v2.js +220 -0
  9. package/dist/cjs/modules/escrow-v2.js.map +1 -0
  10. package/dist/cjs/modules/escrow.js +4 -0
  11. package/dist/cjs/modules/escrow.js.map +1 -1
  12. package/dist/cjs/modules/index.js +9 -1
  13. package/dist/cjs/modules/index.js.map +1 -1
  14. package/dist/cjs/modules/receipt.js +144 -0
  15. package/dist/cjs/modules/receipt.js.map +1 -0
  16. package/dist/cjs/modules/staking.js +94 -0
  17. package/dist/cjs/modules/staking.js.map +1 -0
  18. package/dist/cjs/modules/subscription.js +96 -0
  19. package/dist/cjs/modules/subscription.js.map +1 -0
  20. package/dist/cjs/pda/index.js +166 -1
  21. package/dist/cjs/pda/index.js.map +1 -1
  22. package/dist/cjs/registries/x402.js +88 -51
  23. package/dist/cjs/registries/x402.js.map +1 -1
  24. package/dist/cjs/types/enums.js +96 -1
  25. package/dist/cjs/types/enums.js.map +1 -1
  26. package/dist/cjs/types/index.js +6 -1
  27. package/dist/cjs/types/index.js.map +1 -1
  28. package/dist/cjs/types/instructions.js.map +1 -1
  29. package/dist/cjs/utils/escrow-validation.js +219 -0
  30. package/dist/cjs/utils/escrow-validation.js.map +1 -0
  31. package/dist/cjs/utils/index.js +12 -1
  32. package/dist/cjs/utils/index.js.map +1 -1
  33. package/dist/cjs/utils/merchant-validator.js +246 -0
  34. package/dist/cjs/utils/merchant-validator.js.map +1 -0
  35. package/dist/cjs/utils/x402-direct.js +231 -0
  36. package/dist/cjs/utils/x402-direct.js.map +1 -0
  37. package/dist/esm/constants/seeds.js +9 -0
  38. package/dist/esm/constants/seeds.js.map +1 -1
  39. package/dist/esm/core/client.js +55 -0
  40. package/dist/esm/core/client.js.map +1 -1
  41. package/dist/esm/idl/synapse_agent_sap.json +8571 -4106
  42. package/dist/esm/index.js +5 -3
  43. package/dist/esm/index.js.map +1 -1
  44. package/dist/esm/modules/escrow-v2.js +216 -0
  45. package/dist/esm/modules/escrow-v2.js.map +1 -0
  46. package/dist/esm/modules/escrow.js +4 -0
  47. package/dist/esm/modules/escrow.js.map +1 -1
  48. package/dist/esm/modules/index.js +4 -0
  49. package/dist/esm/modules/index.js.map +1 -1
  50. package/dist/esm/modules/receipt.js +140 -0
  51. package/dist/esm/modules/receipt.js.map +1 -0
  52. package/dist/esm/modules/staking.js +90 -0
  53. package/dist/esm/modules/staking.js.map +1 -0
  54. package/dist/esm/modules/subscription.js +92 -0
  55. package/dist/esm/modules/subscription.js.map +1 -0
  56. package/dist/esm/pda/index.js +157 -0
  57. package/dist/esm/pda/index.js.map +1 -1
  58. package/dist/esm/registries/x402.js +89 -52
  59. package/dist/esm/registries/x402.js.map +1 -1
  60. package/dist/esm/types/enums.js +95 -0
  61. package/dist/esm/types/enums.js.map +1 -1
  62. package/dist/esm/types/index.js +1 -1
  63. package/dist/esm/types/index.js.map +1 -1
  64. package/dist/esm/types/instructions.js.map +1 -1
  65. package/dist/esm/utils/escrow-validation.js +212 -0
  66. package/dist/esm/utils/escrow-validation.js.map +1 -0
  67. package/dist/esm/utils/index.js +4 -0
  68. package/dist/esm/utils/index.js.map +1 -1
  69. package/dist/esm/utils/merchant-validator.js +241 -0
  70. package/dist/esm/utils/merchant-validator.js.map +1 -0
  71. package/dist/esm/utils/x402-direct.js +228 -0
  72. package/dist/esm/utils/x402-direct.js.map +1 -0
  73. package/dist/types/constants/seeds.d.ts +9 -0
  74. package/dist/types/constants/seeds.d.ts.map +1 -1
  75. package/dist/types/core/client.d.ts +43 -0
  76. package/dist/types/core/client.d.ts.map +1 -1
  77. package/dist/types/index.d.ts +6 -4
  78. package/dist/types/index.d.ts.map +1 -1
  79. package/dist/types/modules/escrow-v2.d.ts +58 -0
  80. package/dist/types/modules/escrow-v2.d.ts.map +1 -0
  81. package/dist/types/modules/escrow.d.ts +4 -0
  82. package/dist/types/modules/escrow.d.ts.map +1 -1
  83. package/dist/types/modules/index.d.ts +4 -0
  84. package/dist/types/modules/index.d.ts.map +1 -1
  85. package/dist/types/modules/receipt.d.ts +77 -0
  86. package/dist/types/modules/receipt.d.ts.map +1 -0
  87. package/dist/types/modules/staking.d.ts +32 -0
  88. package/dist/types/modules/staking.d.ts.map +1 -0
  89. package/dist/types/modules/subscription.d.ts +33 -0
  90. package/dist/types/modules/subscription.d.ts.map +1 -0
  91. package/dist/types/pda/index.d.ts +114 -0
  92. package/dist/types/pda/index.d.ts.map +1 -1
  93. package/dist/types/plugin/schemas.d.ts +2 -2
  94. package/dist/types/registries/x402.d.ts +14 -12
  95. package/dist/types/registries/x402.d.ts.map +1 -1
  96. package/dist/types/types/accounts.d.ts +201 -1
  97. package/dist/types/types/accounts.d.ts.map +1 -1
  98. package/dist/types/types/enums.d.ts +115 -0
  99. package/dist/types/types/enums.d.ts.map +1 -1
  100. package/dist/types/types/index.d.ts +4 -4
  101. package/dist/types/types/index.d.ts.map +1 -1
  102. package/dist/types/types/instructions.d.ts +34 -0
  103. package/dist/types/types/instructions.d.ts.map +1 -1
  104. package/dist/types/utils/escrow-validation.d.ts +145 -0
  105. package/dist/types/utils/escrow-validation.d.ts.map +1 -0
  106. package/dist/types/utils/index.d.ts +6 -0
  107. package/dist/types/utils/index.d.ts.map +1 -1
  108. package/dist/types/utils/merchant-validator.d.ts +176 -0
  109. package/dist/types/utils/merchant-validator.d.ts.map +1 -0
  110. package/dist/types/utils/x402-direct.d.ts +114 -0
  111. package/dist/types/utils/x402-direct.d.ts.map +1 -0
  112. package/package.json +2 -2
  113. package/src/constants/seeds.ts +9 -0
  114. package/src/core/client.ts +59 -0
  115. package/src/idl/synapse_agent_sap.json +8571 -4106
  116. package/src/index.ts +54 -0
  117. package/src/modules/escrow-v2.ts +375 -0
  118. package/src/modules/escrow.ts +4 -0
  119. package/src/modules/index.ts +4 -0
  120. package/src/modules/receipt.ts +207 -0
  121. package/src/modules/staking.ts +122 -0
  122. package/src/modules/subscription.ts +147 -0
  123. package/src/pda/index.ts +228 -0
  124. package/src/registries/x402.ts +108 -69
  125. package/src/types/accounts.ts +241 -1
  126. package/src/types/enums.ts +119 -0
  127. package/src/types/index.ts +20 -0
  128. package/src/types/instructions.ts +40 -0
  129. package/src/utils/escrow-validation.ts +301 -0
  130. package/src/utils/index.ts +28 -0
  131. package/src/utils/merchant-validator.ts +359 -0
  132. package/src/utils/x402-direct.ts +370 -0
package/dist/cjs/index.js CHANGED
@@ -45,9 +45,9 @@
45
45
  * @since v0.1.0
46
46
  */
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.isNetworkEquivalent = exports.normalizeNetworkId = exports.serializeValue = exports.serializeAccount = exports.assert = exports.hashToArray = exports.sha256 = exports.deriveLedgerPage = exports.deriveLedger = exports.deriveAttestation = exports.deriveEscrow = exports.deriveTool = exports.deriveCheckpoint = exports.deriveVaultDelegate = exports.deriveEpochPage = exports.deriveSession = exports.deriveVault = exports.deriveToolCategoryIndex = exports.deriveProtocolIndex = exports.deriveCapabilityIndex = exports.deriveFeedback = exports.deriveAgentStats = exports.deriveAgent = exports.deriveGlobalRegistry = exports.IDL_METADATA = exports.IDL_PROGRAM_ADDRESS = exports.SAP_IDL = exports.SapNetwork = exports.HTTP_METHOD_VALUES = exports.TOOL_CATEGORY_VALUES = exports.VAULT_PROTOCOL_VERSION = exports.AGENT_VERSION = exports.LIMITS = exports.SEEDS = exports.LOCALNET_SAP_PROGRAM_ID = exports.DEVNET_SAP_PROGRAM_ID = exports.MAINNET_SAP_PROGRAM_ID = exports.SAP_PROGRAM_ID = exports.SAP_PROGRAM_ADDRESS = exports.CompressionType = exports.SchemaType = exports.DelegatePermission = exports.ToolCategory = exports.ToolHttpMethod = exports.SettlementMode = exports.PluginType = exports.TokenType = exports.KeypairWallet = exports.SapConnection = exports.SapClient = void 0;
49
- exports.SAP_PROTOCOLS = exports.SAPPlugin = exports.createSAPPlugin = exports.BaseModule = exports.LedgerModule = exports.AttestationModule = exports.EscrowModule = exports.VaultModule = exports.ToolsModule = exports.IndexingModule = exports.FeedbackModule = exports.AgentModule = exports.GeyserEventStream = exports.SAP_EVENT_NAMES = exports.EventParser = exports.SapPermissionError = exports.SapTimeoutError = exports.SapAccountNotFoundError = exports.SapRpcError = exports.SapValidationError = exports.SapError = exports.DEFAULT_BATCH_SETTLE_COMPUTE_UNITS = exports.DEFAULT_SETTLE_COMPUTE_UNITS = exports.DEFAULT_SETTLE_PRIORITY_FEE = exports.FAST_BATCH_SETTLE_OPTIONS = exports.FAST_SETTLE_OPTIONS = exports.buildRpcOptions = exports.buildPriorityFeeIxs = exports.validateOrThrow = exports.createCallArgsSchema = exports.createRegisterAgentSchema = exports.createPreparePaymentSchema = exports.createAgentManifestSchema = exports.createToolManifestEntrySchema = exports.createHealthCheckSchema = exports.createEndpointDescriptorSchema = exports.createEnvSchema = exports.extractAnchorErrorCode = exports.classifyAnchorError = exports.findATA = exports.createDualConnection = exports.getFallbackRpcUrl = exports.getRpcUrl = exports.validateAgentEndpoints = exports.validateHealthCheck = exports.validateEndpointDescriptor = exports.validateEndpoint = exports.isKnownNetwork = exports.getNetworkClusterName = exports.getNetworkGenesisHash = void 0;
50
- exports.AgentBuilder = exports.SessionManager = exports.X402Registry = exports.DiscoveryRegistry = exports.TransactionParser = exports.extractAccountKeys = exports.filterSapInnerInstructions = exports.decodeInnerInstructions = exports.parseSapTransactionBatch = exports.parseSapTransactionComplete = exports.containsSapInstruction = exports.parseSapInstructionNamesFromList = exports.parseSapInstructionsFromList = exports.parseSapInstructionNamesFromTransaction = exports.parseSapInstructionsFromTransaction = exports.SAP_TABLE_MAP = exports.SapSyncEngine = exports.SapPostgres = void 0;
48
+ exports.deriveSubscription = exports.deriveStake = exports.deriveDispute = exports.derivePendingSettlement = exports.deriveEscrowV2 = exports.deriveEscrow = exports.deriveTool = exports.deriveCheckpoint = exports.deriveVaultDelegate = exports.deriveEpochPage = exports.deriveSession = exports.deriveVault = exports.deriveToolCategoryIndex = exports.deriveProtocolIndex = exports.deriveCapabilityIndex = exports.deriveFeedback = exports.deriveAgentStats = exports.deriveAgent = exports.deriveGlobalRegistry = exports.IDL_METADATA = exports.IDL_PROGRAM_ADDRESS = exports.SAP_IDL = exports.SapNetwork = exports.HTTP_METHOD_VALUES = exports.TOOL_CATEGORY_VALUES = exports.VAULT_PROTOCOL_VERSION = exports.AGENT_VERSION = exports.LIMITS = exports.SEEDS = exports.LOCALNET_SAP_PROGRAM_ID = exports.DEVNET_SAP_PROGRAM_ID = exports.MAINNET_SAP_PROGRAM_ID = exports.SAP_PROGRAM_ID = exports.SAP_PROGRAM_ADDRESS = exports.ResolutionLayer = exports.DisputeType = exports.BillingInterval = exports.DisputeOutcome = exports.SettlementSecurity = exports.CompressionType = exports.SchemaType = exports.DelegatePermission = exports.ToolCategory = exports.ToolHttpMethod = exports.SettlementMode = exports.PluginType = exports.TokenType = exports.KeypairWallet = exports.SapConnection = exports.SapClient = void 0;
49
+ exports.SapError = exports.getX402DirectPayments = exports.parseX402Headers = exports.SapMerchantValidator = exports.MissingEscrowAtaError = exports.toAccountMetas = exports.attachSplAccounts = exports.validateEscrowState = exports.DEFAULT_BATCH_SETTLE_COMPUTE_UNITS = exports.DEFAULT_SETTLE_COMPUTE_UNITS = exports.DEFAULT_SETTLE_PRIORITY_FEE = exports.FAST_BATCH_SETTLE_OPTIONS = exports.FAST_SETTLE_OPTIONS = exports.buildRpcOptions = exports.buildPriorityFeeIxs = exports.validateOrThrow = exports.createCallArgsSchema = exports.createRegisterAgentSchema = exports.createPreparePaymentSchema = exports.createAgentManifestSchema = exports.createToolManifestEntrySchema = exports.createHealthCheckSchema = exports.createEndpointDescriptorSchema = exports.createEnvSchema = exports.extractAnchorErrorCode = exports.classifyAnchorError = exports.findATA = exports.createDualConnection = exports.getFallbackRpcUrl = exports.getRpcUrl = exports.validateAgentEndpoints = exports.validateHealthCheck = exports.validateEndpointDescriptor = exports.validateEndpoint = exports.isKnownNetwork = exports.getNetworkClusterName = exports.getNetworkGenesisHash = exports.isNetworkEquivalent = exports.normalizeNetworkId = exports.serializeValue = exports.serializeAccount = exports.assert = exports.hashToArray = exports.sha256 = exports.deriveReceiptBatch = exports.deriveLedgerPage = exports.deriveLedger = exports.deriveAttestation = exports.deriveIndexPage = exports.deriveShard = void 0;
50
+ exports.AgentBuilder = exports.SessionManager = exports.X402Registry = exports.DiscoveryRegistry = exports.TransactionParser = exports.extractAccountKeys = exports.filterSapInnerInstructions = exports.decodeInnerInstructions = exports.parseSapTransactionBatch = exports.parseSapTransactionComplete = exports.containsSapInstruction = exports.parseSapInstructionNamesFromList = exports.parseSapInstructionsFromList = exports.parseSapInstructionNamesFromTransaction = exports.parseSapInstructionsFromTransaction = exports.SAP_TABLE_MAP = exports.SapSyncEngine = exports.SapPostgres = exports.SAP_PROTOCOLS = exports.SAPPlugin = exports.createSAPPlugin = exports.BaseModule = exports.LedgerModule = exports.AttestationModule = exports.SubscriptionModule = exports.StakingModule = exports.ReceiptModule = exports.EscrowV2Module = exports.EscrowModule = exports.VaultModule = exports.ToolsModule = exports.IndexingModule = exports.FeedbackModule = exports.AgentModule = exports.GeyserEventStream = exports.SAP_EVENT_NAMES = exports.EventParser = exports.SapPermissionError = exports.SapTimeoutError = exports.SapAccountNotFoundError = exports.SapRpcError = exports.SapValidationError = void 0;
51
51
  // ── Core ─────────────────────────────────────────────
52
52
  var core_1 = require("./core");
53
53
  Object.defineProperty(exports, "SapClient", { enumerable: true, get: function () { return core_1.SapClient; } });
@@ -62,6 +62,11 @@ Object.defineProperty(exports, "ToolCategory", { enumerable: true, get: function
62
62
  Object.defineProperty(exports, "DelegatePermission", { enumerable: true, get: function () { return types_1.DelegatePermission; } });
63
63
  Object.defineProperty(exports, "SchemaType", { enumerable: true, get: function () { return types_1.SchemaType; } });
64
64
  Object.defineProperty(exports, "CompressionType", { enumerable: true, get: function () { return types_1.CompressionType; } });
65
+ Object.defineProperty(exports, "SettlementSecurity", { enumerable: true, get: function () { return types_1.SettlementSecurity; } });
66
+ Object.defineProperty(exports, "DisputeOutcome", { enumerable: true, get: function () { return types_1.DisputeOutcome; } });
67
+ Object.defineProperty(exports, "BillingInterval", { enumerable: true, get: function () { return types_1.BillingInterval; } });
68
+ Object.defineProperty(exports, "DisputeType", { enumerable: true, get: function () { return types_1.DisputeType; } });
69
+ Object.defineProperty(exports, "ResolutionLayer", { enumerable: true, get: function () { return types_1.ResolutionLayer; } });
65
70
  // ── Constants ────────────────────────────────────────
66
71
  var constants_1 = require("./constants");
67
72
  Object.defineProperty(exports, "SAP_PROGRAM_ADDRESS", { enumerable: true, get: function () { return constants_1.SAP_PROGRAM_ADDRESS; } });
@@ -97,9 +102,17 @@ Object.defineProperty(exports, "deriveVaultDelegate", { enumerable: true, get: f
97
102
  Object.defineProperty(exports, "deriveCheckpoint", { enumerable: true, get: function () { return pda_1.deriveCheckpoint; } });
98
103
  Object.defineProperty(exports, "deriveTool", { enumerable: true, get: function () { return pda_1.deriveTool; } });
99
104
  Object.defineProperty(exports, "deriveEscrow", { enumerable: true, get: function () { return pda_1.deriveEscrow; } });
105
+ Object.defineProperty(exports, "deriveEscrowV2", { enumerable: true, get: function () { return pda_1.deriveEscrowV2; } });
106
+ Object.defineProperty(exports, "derivePendingSettlement", { enumerable: true, get: function () { return pda_1.derivePendingSettlement; } });
107
+ Object.defineProperty(exports, "deriveDispute", { enumerable: true, get: function () { return pda_1.deriveDispute; } });
108
+ Object.defineProperty(exports, "deriveStake", { enumerable: true, get: function () { return pda_1.deriveStake; } });
109
+ Object.defineProperty(exports, "deriveSubscription", { enumerable: true, get: function () { return pda_1.deriveSubscription; } });
110
+ Object.defineProperty(exports, "deriveShard", { enumerable: true, get: function () { return pda_1.deriveShard; } });
111
+ Object.defineProperty(exports, "deriveIndexPage", { enumerable: true, get: function () { return pda_1.deriveIndexPage; } });
100
112
  Object.defineProperty(exports, "deriveAttestation", { enumerable: true, get: function () { return pda_1.deriveAttestation; } });
101
113
  Object.defineProperty(exports, "deriveLedger", { enumerable: true, get: function () { return pda_1.deriveLedger; } });
102
114
  Object.defineProperty(exports, "deriveLedgerPage", { enumerable: true, get: function () { return pda_1.deriveLedgerPage; } });
115
+ Object.defineProperty(exports, "deriveReceiptBatch", { enumerable: true, get: function () { return pda_1.deriveReceiptBatch; } });
103
116
  // ── Utilities ────────────────────────────────────────
104
117
  var utils_1 = require("./utils");
105
118
  Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return utils_1.sha256; } });
@@ -149,6 +162,15 @@ Object.defineProperty(exports, "FAST_BATCH_SETTLE_OPTIONS", { enumerable: true,
149
162
  Object.defineProperty(exports, "DEFAULT_SETTLE_PRIORITY_FEE", { enumerable: true, get: function () { return utils_7.DEFAULT_SETTLE_PRIORITY_FEE; } });
150
163
  Object.defineProperty(exports, "DEFAULT_SETTLE_COMPUTE_UNITS", { enumerable: true, get: function () { return utils_7.DEFAULT_SETTLE_COMPUTE_UNITS; } });
151
164
  Object.defineProperty(exports, "DEFAULT_BATCH_SETTLE_COMPUTE_UNITS", { enumerable: true, get: function () { return utils_7.DEFAULT_BATCH_SETTLE_COMPUTE_UNITS; } });
165
+ // v0.6.4 — Escrow validation, merchant middleware, x402 direct
166
+ var utils_8 = require("./utils");
167
+ Object.defineProperty(exports, "validateEscrowState", { enumerable: true, get: function () { return utils_8.validateEscrowState; } });
168
+ Object.defineProperty(exports, "attachSplAccounts", { enumerable: true, get: function () { return utils_8.attachSplAccounts; } });
169
+ Object.defineProperty(exports, "toAccountMetas", { enumerable: true, get: function () { return utils_8.toAccountMetas; } });
170
+ Object.defineProperty(exports, "MissingEscrowAtaError", { enumerable: true, get: function () { return utils_8.MissingEscrowAtaError; } });
171
+ Object.defineProperty(exports, "SapMerchantValidator", { enumerable: true, get: function () { return utils_8.SapMerchantValidator; } });
172
+ Object.defineProperty(exports, "parseX402Headers", { enumerable: true, get: function () { return utils_8.parseX402Headers; } });
173
+ Object.defineProperty(exports, "getX402DirectPayments", { enumerable: true, get: function () { return utils_8.getX402DirectPayments; } });
152
174
  // ── Errors ───────────────────────────────────────────
153
175
  var errors_1 = require("./errors");
154
176
  Object.defineProperty(exports, "SapError", { enumerable: true, get: function () { return errors_1.SapError; } });
@@ -172,6 +194,10 @@ Object.defineProperty(exports, "IndexingModule", { enumerable: true, get: functi
172
194
  Object.defineProperty(exports, "ToolsModule", { enumerable: true, get: function () { return index_2.ToolsModule; } });
173
195
  Object.defineProperty(exports, "VaultModule", { enumerable: true, get: function () { return index_2.VaultModule; } });
174
196
  Object.defineProperty(exports, "EscrowModule", { enumerable: true, get: function () { return index_2.EscrowModule; } });
197
+ Object.defineProperty(exports, "EscrowV2Module", { enumerable: true, get: function () { return index_2.EscrowV2Module; } });
198
+ Object.defineProperty(exports, "ReceiptModule", { enumerable: true, get: function () { return index_2.ReceiptModule; } });
199
+ Object.defineProperty(exports, "StakingModule", { enumerable: true, get: function () { return index_2.StakingModule; } });
200
+ Object.defineProperty(exports, "SubscriptionModule", { enumerable: true, get: function () { return index_2.SubscriptionModule; } });
175
201
  Object.defineProperty(exports, "AttestationModule", { enumerable: true, get: function () { return index_2.AttestationModule; } });
176
202
  Object.defineProperty(exports, "LedgerModule", { enumerable: true, get: function () { return index_2.LedgerModule; } });
177
203
  Object.defineProperty(exports, "BaseModule", { enumerable: true, get: function () { return index_2.BaseModule; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;;;;;AAEH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,2GAAA,kBAAkB,OAAA;AAClB,0GAAA,iBAAiB,OAAA;AACjB,qGAAA,YAAY,OAAA;AACZ,mGAAA,UAAU,OAAA;AAIZ,wDAAwD;AACxD,wCAA4D;AAAnD,wGAAA,eAAe,OAAA;AAAE,kGAAA,SAAS,OAAA;AAYnC,gDAAmD;AAA1C,0GAAA,aAAa,OAAA;AAEtB,4DAA4D;AAC5D,uCAAuE;AAA9D,uGAAA,WAAW,OAAA;AAAE,yGAAA,aAAa,OAAA;AAAE,yGAAA,aAAa,OAAA;AAelD,0DAA0D;AAC1D,mCAYkB;AAXhB,6HAAA,mCAAmC,OAAA;AACnC,iIAAA,uCAAuC,OAAA;AACvC,sHAAA,4BAA4B,OAAA;AAC5B,0HAAA,gCAAgC,OAAA;AAChC,gHAAA,sBAAsB,OAAA;AACtB,qHAAA,2BAA2B,OAAA;AAC3B,kHAAA,wBAAwB,OAAA;AACxB,iHAAA,uBAAuB,OAAA;AACvB,oHAAA,0BAA0B,OAAA;AAC1B,4GAAA,kBAAkB,OAAA;AAClB,2GAAA,iBAAiB,OAAA;AAYnB,yDAAyD;AACzD,4CAK4B;AAJ1B,0GAAA,iBAAiB,OAAA;AACjB,qGAAA,YAAY,OAAA;AACZ,uGAAA,cAAc,OAAA;AACd,qGAAA,YAAY,OAAA"}
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+ /**
3
+ * @module escrow-v2
4
+ * @description V2 escrow settlement layer — supports settlement security
5
+ * modes (CoSigned, DisputeWindow), receipt-based dispute resolution,
6
+ * pending settlements, and automatic resolution via merkle proofs.
7
+ *
8
+ * @category Modules
9
+ * @since v0.7.0
10
+ * @packageDocumentation
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.EscrowV2Module = void 0;
14
+ const web3_js_1 = require("@solana/web3.js");
15
+ const anchor_1 = require("@coral-xyz/anchor");
16
+ const base_1 = require("./base");
17
+ const pda_1 = require("../pda");
18
+ const priority_fee_1 = require("../utils/priority-fee");
19
+ /**
20
+ * @name EscrowV2Module
21
+ * @description Manages V2 escrow accounts with settlement security modes,
22
+ * dispute windows, and pending settlement flows.
23
+ *
24
+ * @category Modules
25
+ * @since v0.7.0
26
+ * @extends BaseModule
27
+ */
28
+ class EscrowV2Module extends base_1.BaseModule {
29
+ // ── Helpers ──────────────────────────────────────────
30
+ /** Convert BN | number | bigint → number for PDA seed functions. */
31
+ toNum(v) {
32
+ return anchor_1.BN.isBN(v) ? v.toNumber() : Number(v);
33
+ }
34
+ // ── PDA helpers ──────────────────────────────────────
35
+ deriveEscrow(agentPda, depositor, nonce = 0) {
36
+ return (0, pda_1.deriveEscrowV2)(agentPda, depositor ?? this.walletPubkey, this.toNum(nonce));
37
+ }
38
+ derivePendingSettlement(escrowV2Pda, settlementIndex) {
39
+ return (0, pda_1.derivePendingSettlement)(escrowV2Pda, this.toNum(settlementIndex));
40
+ }
41
+ deriveDispute(pendingSettlementPda) {
42
+ return (0, pda_1.deriveDispute)(pendingSettlementPda);
43
+ }
44
+ // ── Instructions ─────────────────────────────────────
45
+ async create(agentWallet, args, splAccounts = []) {
46
+ const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
47
+ const [escrowPda] = this.deriveEscrow(agentPda, undefined, args.escrowNonce);
48
+ return this.methods
49
+ .createEscrowV2(this.bn(args.escrowNonce), this.bn(args.pricePerCall), this.bn(args.maxCalls), this.bn(args.initialDeposit), args.expiresAt, args.volumeCurve, args.tokenMint, args.tokenDecimals, args.settlementSecurity, this.bn(args.disputeWindowSlots), args.coSigner, args.arbiter)
50
+ .accounts({
51
+ depositor: this.walletPubkey,
52
+ agent: agentPda,
53
+ escrow: escrowPda,
54
+ systemProgram: web3_js_1.SystemProgram.programId,
55
+ })
56
+ .remainingAccounts(splAccounts)
57
+ .rpc();
58
+ }
59
+ async deposit(agentWallet, nonce, amount, splAccounts = []) {
60
+ const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
61
+ const [escrowPda] = this.deriveEscrow(agentPda, undefined, nonce);
62
+ return this.methods
63
+ .depositEscrowV2(this.bn(nonce), this.bn(amount))
64
+ .accounts({
65
+ depositor: this.walletPubkey,
66
+ escrow: escrowPda,
67
+ systemProgram: web3_js_1.SystemProgram.programId,
68
+ })
69
+ .remainingAccounts(splAccounts)
70
+ .rpc();
71
+ }
72
+ async settle(depositorWallet, nonce, callsToSettle, serviceHash, splAccounts = [], opts) {
73
+ const [agentPda] = (0, pda_1.deriveAgent)(this.walletPubkey);
74
+ const [escrowPda] = this.deriveEscrow(agentPda, depositorWallet, nonce);
75
+ const [statsPda] = (0, pda_1.deriveAgentStats)(agentPda);
76
+ const preIxs = (0, priority_fee_1.buildPriorityFeeIxs)(opts);
77
+ const rpcOpts = (0, priority_fee_1.buildRpcOptions)(opts);
78
+ let builder = this.methods
79
+ .settleCallsV2(this.bn(nonce), this.bn(callsToSettle), serviceHash)
80
+ .accounts({
81
+ wallet: this.walletPubkey,
82
+ agent: agentPda,
83
+ agentStats: statsPda,
84
+ escrow: escrowPda,
85
+ systemProgram: web3_js_1.SystemProgram.programId,
86
+ })
87
+ .remainingAccounts(splAccounts);
88
+ if (preIxs.length > 0) {
89
+ builder = builder.preInstructions(preIxs);
90
+ }
91
+ return builder.rpc(rpcOpts);
92
+ }
93
+ async createPendingSettlement(agentWallet, depositorWallet, nonce, settlementIndex, callsToSettle, amount, serviceHash, receiptMerkleRoot = new Array(32).fill(0)) {
94
+ const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
95
+ const [escrowPda] = this.deriveEscrow(agentPda, depositorWallet, nonce);
96
+ const [pendingPda] = this.derivePendingSettlement(escrowPda, settlementIndex);
97
+ return this.methods
98
+ .createPendingSettlement(this.bn(settlementIndex), this.bn(callsToSettle), this.bn(amount), serviceHash, receiptMerkleRoot)
99
+ .accounts({
100
+ wallet: this.walletPubkey,
101
+ agent: agentPda,
102
+ escrow: escrowPda,
103
+ pendingSettlement: pendingPda,
104
+ systemProgram: web3_js_1.SystemProgram.programId,
105
+ })
106
+ .rpc();
107
+ }
108
+ async finalizeSettlement(agentWallet, depositorWallet, nonce, settlementIndex) {
109
+ const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
110
+ const [escrowPda] = this.deriveEscrow(agentPda, depositorWallet, nonce);
111
+ const [pendingPda] = this.derivePendingSettlement(escrowPda, settlementIndex);
112
+ const [statsPda] = (0, pda_1.deriveAgentStats)(agentPda);
113
+ return this.methods
114
+ .finalizeSettlement()
115
+ .accounts({
116
+ payer: this.walletPubkey,
117
+ agentWallet,
118
+ escrow: escrowPda,
119
+ pendingSettlement: pendingPda,
120
+ agentStats: statsPda,
121
+ })
122
+ .rpc();
123
+ }
124
+ async fileDispute(agentWallet, nonce, settlementIndex, evidenceHash, disputeType = 0) {
125
+ const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
126
+ const [escrowPda] = this.deriveEscrow(agentPda, undefined, nonce);
127
+ const [pendingPda] = this.derivePendingSettlement(escrowPda, settlementIndex);
128
+ const [disputePda] = this.deriveDispute(pendingPda);
129
+ return this.methods
130
+ .fileDispute(evidenceHash, disputeType)
131
+ .accounts({
132
+ depositor: this.walletPubkey,
133
+ escrow: escrowPda,
134
+ pendingSettlement: pendingPda,
135
+ dispute: disputePda,
136
+ systemProgram: web3_js_1.SystemProgram.programId,
137
+ })
138
+ .rpc();
139
+ }
140
+ /**
141
+ * @deprecated Since v0.7.0 — Arbiter-based resolution removed.
142
+ * Use {@link ReceiptModule.submitReceiptProof} + {@link ReceiptModule.autoResolveDispute} instead.
143
+ */
144
+ async resolveDispute(_depositorWallet, _agentWallet, _nonce, _settlementIndex, _outcome) {
145
+ throw new Error("resolveDispute removed in v0.7.0 — use ReceiptModule.autoResolveDispute");
146
+ }
147
+ async closeDispute(pendingSettlementPda) {
148
+ const [disputePda] = this.deriveDispute(pendingSettlementPda);
149
+ return this.methods
150
+ .closeDispute()
151
+ .accounts({
152
+ depositor: this.walletPubkey,
153
+ dispute: disputePda,
154
+ })
155
+ .rpc();
156
+ }
157
+ async closePendingSettlement(pendingSettlementPda) {
158
+ return this.methods
159
+ .closePendingSettlement()
160
+ .accounts({
161
+ payer: this.walletPubkey,
162
+ pendingSettlement: pendingSettlementPda,
163
+ })
164
+ .rpc();
165
+ }
166
+ async withdraw(agentWallet, nonce, amount) {
167
+ const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
168
+ const [escrowPda] = this.deriveEscrow(agentPda, undefined, nonce);
169
+ return this.methods
170
+ .withdrawEscrowV2(this.bn(amount))
171
+ .accounts({
172
+ depositor: this.walletPubkey,
173
+ escrow: escrowPda,
174
+ })
175
+ .rpc();
176
+ }
177
+ async close(agentWallet, nonce = 0) {
178
+ const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
179
+ const [escrowPda] = this.deriveEscrow(agentPda, undefined, nonce);
180
+ return this.methods
181
+ .closeEscrowV2()
182
+ .accounts({
183
+ depositor: this.walletPubkey,
184
+ escrow: escrowPda,
185
+ })
186
+ .rpc();
187
+ }
188
+ /**
189
+ * @deprecated Since v0.7.0 — Migration instruction removed from program.
190
+ */
191
+ async migrateFromV1(_agentWallet) {
192
+ throw new Error("migrateFromV1 removed in v0.7.0 — migration instruction was deleted");
193
+ }
194
+ // ── Fetchers ─────────────────────────────────────────
195
+ async fetch(agentPda, depositor, nonce = 0) {
196
+ const [pda] = this.deriveEscrow(agentPda, depositor, nonce);
197
+ return this.fetchAccount("escrowAccountV2", pda);
198
+ }
199
+ async fetchNullable(agentPda, depositor, nonce = 0) {
200
+ const [pda] = this.deriveEscrow(agentPda, depositor, nonce);
201
+ return this.fetchAccountNullable("escrowAccountV2", pda);
202
+ }
203
+ async fetchByPda(escrowPda) {
204
+ return this.fetchAccount("escrowAccountV2", escrowPda);
205
+ }
206
+ async fetchPendingSettlement(pendingPda) {
207
+ return this.fetchAccount("pendingSettlement", pendingPda);
208
+ }
209
+ async fetchPendingSettlementNullable(pendingPda) {
210
+ return this.fetchAccountNullable("pendingSettlement", pendingPda);
211
+ }
212
+ async fetchDispute(disputePda) {
213
+ return this.fetchAccount("disputeRecord", disputePda);
214
+ }
215
+ async fetchDisputeNullable(disputePda) {
216
+ return this.fetchAccountNullable("disputeRecord", disputePda);
217
+ }
218
+ }
219
+ exports.EscrowV2Module = EscrowV2Module;
220
+ //# sourceMappingURL=escrow-v2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escrow-v2.js","sourceRoot":"","sources":["../../../src/modules/escrow-v2.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,6CAKyB;AACzB,8CAAuC;AACvC,iCAAoC;AACpC,gCAMgB;AAOhB,wDAG+B;AAG/B;;;;;;;;GAQG;AACH,MAAa,cAAe,SAAQ,iBAAU;IAC5C,wDAAwD;IAExD,oEAAoE;IAC5D,KAAK,CAAC,CAAuB;QACnC,OAAO,WAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,wDAAwD;IAExD,YAAY,CACV,QAAmB,EACnB,SAAqB,EACrB,QAA8B,CAAC;QAE/B,OAAO,IAAA,oBAAc,EAAC,QAAQ,EAAE,SAAS,IAAI,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,uBAAuB,CACrB,WAAsB,EACtB,eAAqC;QAErC,OAAO,IAAA,6BAAgB,EAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,aAAa,CACX,oBAA+B;QAE/B,OAAO,IAAA,mBAAgB,EAAC,oBAAoB,CAAC,CAAC;IAChD,CAAC;IAED,wDAAwD;IAExD,KAAK,CAAC,MAAM,CACV,WAAsB,EACtB,IAAwB,EACxB,cAA6B,EAAE;QAE/B,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAA,iBAAW,EAAC,WAAW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B,OAAO,IAAI,CAAC,YAAY,CAAoB,eAAe,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,UAAqB;QAErB,OAAO,IAAI,CAAC,oBAAoB,CAAoB,eAAe,EAAE,UAAU,CAAC,CAAC;IACnF,CAAC;CACF;AAvUD,wCAuUC"}
@@ -41,6 +41,10 @@ const priority_fee_1 = require("../utils/priority-fee");
41
41
  * tokenDecimals: null,
42
42
  * });
43
43
  * ```
44
+ *
45
+ * @deprecated Since v0.7.0 — Use {@link EscrowV2Module} (`client.escrowV2`) instead.
46
+ * V1 escrows lack settlement security, dispute resolution, and staking integration.
47
+ * Existing V1 escrows can be migrated via `client.escrowV2.migrateFromV1()`.
44
48
  */
45
49
  class EscrowModule extends base_1.BaseModule {
46
50
  // ── PDA helpers ──────────────────────────────────────
@@ -1 +1 @@
1
- {"version":3,"file":"escrow.js","sourceRoot":"","sources":["../../../src/modules/escrow.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,6CAKyB;AAEzB,iCAAoC;AACpC,gCAIgB;AAMhB,wDAG+B;AAG/B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,YAAa,SAAQ,iBAAU;IAC1C,wDAAwD;IAExD;;;;;;;;OAQG;IACH,YAAY,CACV,QAAmB,EACnB,SAAqB;QAErB,OAAO,IAAA,kBAAY,EAAC,QAAQ,EAAE,SAAS,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;IAChE,CAAC;IAED,wDAAwD;IAExD;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,MAAM,CACV,WAAsB,EACtB,IAAsB,EACtB,cAA6B,EAAE;QAE/B,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAA,iBAAW,EAAC,WAAW,CAAC,CAAC;QAC5C,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,QA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AAS,CAAC,CAAC;IAC1E,CAAC;CACF;AAhRD,oCAgRC"}
@@ -13,7 +13,7 @@
13
13
  * @packageDocumentation
14
14
  */
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.BaseModule = exports.LedgerModule = exports.AttestationModule = exports.EscrowModule = exports.VaultModule = exports.ToolsModule = exports.IndexingModule = exports.FeedbackModule = exports.AgentModule = void 0;
16
+ exports.BaseModule = exports.LedgerModule = exports.AttestationModule = exports.SubscriptionModule = exports.StakingModule = exports.ReceiptModule = exports.EscrowV2Module = exports.EscrowModule = exports.VaultModule = exports.ToolsModule = exports.IndexingModule = exports.FeedbackModule = exports.AgentModule = void 0;
17
17
  var agent_1 = require("./agent");
18
18
  Object.defineProperty(exports, "AgentModule", { enumerable: true, get: function () { return agent_1.AgentModule; } });
19
19
  var feedback_1 = require("./feedback");
@@ -26,6 +26,14 @@ var vault_1 = require("./vault");
26
26
  Object.defineProperty(exports, "VaultModule", { enumerable: true, get: function () { return vault_1.VaultModule; } });
27
27
  var escrow_1 = require("./escrow");
28
28
  Object.defineProperty(exports, "EscrowModule", { enumerable: true, get: function () { return escrow_1.EscrowModule; } });
29
+ var escrow_v2_1 = require("./escrow-v2");
30
+ Object.defineProperty(exports, "EscrowV2Module", { enumerable: true, get: function () { return escrow_v2_1.EscrowV2Module; } });
31
+ var receipt_1 = require("./receipt");
32
+ Object.defineProperty(exports, "ReceiptModule", { enumerable: true, get: function () { return receipt_1.ReceiptModule; } });
33
+ var staking_1 = require("./staking");
34
+ Object.defineProperty(exports, "StakingModule", { enumerable: true, get: function () { return staking_1.StakingModule; } });
35
+ var subscription_1 = require("./subscription");
36
+ Object.defineProperty(exports, "SubscriptionModule", { enumerable: true, get: function () { return subscription_1.SubscriptionModule; } });
29
37
  var attestation_1 = require("./attestation");
30
38
  Object.defineProperty(exports, "AttestationModule", { enumerable: true, get: function () { return attestation_1.AttestationModule; } });
31
39
  var ledger_1 = require("./ledger");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AACrB,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAC1B,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AACrB,+BAAoC;AAA3B,kGAAA,UAAU,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AACrB,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AACvB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,+CAAoD;AAA3C,kHAAA,kBAAkB,OAAA;AAC3B,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAC1B,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AACrB,+BAAoC;AAA3B,kGAAA,UAAU,OAAA"}
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ /**
3
+ * @module receipt
4
+ * @description Receipt-based trustless dispute resolution (v0.7).
5
+ *
6
+ * Agents inscribe merkle roots of call receipt batches on-chain.
7
+ * During disputes, agents submit merkle inclusion proofs to prove delivery.
8
+ * After the proof deadline, anyone can trigger automatic proportional resolution.
9
+ *
10
+ * @category Modules
11
+ * @since v0.7.0
12
+ * @packageDocumentation
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ReceiptModule = void 0;
16
+ const web3_js_1 = require("@solana/web3.js");
17
+ const anchor_1 = require("@coral-xyz/anchor");
18
+ const base_1 = require("./base");
19
+ const pda_1 = require("../pda");
20
+ /**
21
+ * @name ReceiptModule
22
+ * @description Manages receipt batch inscriptions, merkle proof submissions,
23
+ * and automatic dispute resolution for the v0.7 trustless settlement layer.
24
+ *
25
+ * @category Modules
26
+ * @since v0.7.0
27
+ * @extends BaseModule
28
+ */
29
+ class ReceiptModule extends base_1.BaseModule {
30
+ // ── Helpers ──────────────────────────────────────────
31
+ toNum(v) {
32
+ return anchor_1.BN.isBN(v) ? v.toNumber() : Number(v);
33
+ }
34
+ // ── PDA helpers ──────────────────────────────────────
35
+ deriveReceiptBatch(escrowV2Pda, batchIndex) {
36
+ return (0, pda_1.deriveReceiptBatch)(escrowV2Pda, batchIndex);
37
+ }
38
+ // ── Instructions ─────────────────────────────────────
39
+ /**
40
+ * Inscribe a receipt batch merkle root on-chain.
41
+ *
42
+ * Called by the **agent** to commit a cryptographic proof of calls delivered.
43
+ * The `merkleRoot` is the root of a merkle tree whose leaves are individual
44
+ * call receipt hashes.
45
+ *
46
+ * @param depositorWallet - The depositor's wallet (needed for escrow PDA derivation).
47
+ * @param nonce - Escrow nonce.
48
+ * @param batchIndex - Zero-based batch index (must equal escrow.receipt_batch_count).
49
+ * @param merkleRoot - 32-byte merkle root of the receipt batch.
50
+ * @param callCount - Number of calls in the batch.
51
+ * @param periodStart - Unix timestamp for the start of the covered period.
52
+ * @param periodEnd - Unix timestamp for the end of the covered period.
53
+ */
54
+ async inscribeReceiptBatch(depositorWallet, nonce, batchIndex, merkleRoot, callCount, periodStart, periodEnd) {
55
+ const [agentPda] = (0, pda_1.deriveAgent)(this.walletPubkey);
56
+ const [escrowPda] = (0, pda_1.deriveEscrowV2)(agentPda, depositorWallet, this.toNum(nonce));
57
+ const [receiptPda] = this.deriveReceiptBatch(escrowPda, batchIndex);
58
+ return this.methods
59
+ .inscribeReceiptBatch(batchIndex, merkleRoot, this.bn(callCount), this.bn(periodStart), this.bn(periodEnd))
60
+ .accounts({
61
+ wallet: this.walletPubkey,
62
+ agent: agentPda,
63
+ escrow: escrowPda,
64
+ receiptBatch: receiptPda,
65
+ systemProgram: web3_js_1.SystemProgram.programId,
66
+ })
67
+ .rpc();
68
+ }
69
+ /**
70
+ * Submit a merkle inclusion proof during a dispute.
71
+ *
72
+ * Called by the **agent** to prove delivery of specific calls.
73
+ * Each proof verifies that a set of receipt hashes are included
74
+ * in the previously inscribed merkle root.
75
+ *
76
+ * @param depositorWallet - The depositor's wallet.
77
+ * @param nonce - Escrow nonce.
78
+ * @param settlementIndex - Index of the disputed pending settlement.
79
+ * @param batchIndex - Receipt batch index containing the proof.
80
+ * @param provenCount - Number of calls proven in this proof submission.
81
+ * @param proof - Array of 32-byte merkle proof hashes.
82
+ * @param leaf - The 32-byte leaf hash being proven.
83
+ */
84
+ async submitReceiptProof(depositorWallet, nonce, settlementIndex, batchIndex, provenCount, proof, leaf) {
85
+ const [agentPda] = (0, pda_1.deriveAgent)(this.walletPubkey);
86
+ const [escrowPda] = (0, pda_1.deriveEscrowV2)(agentPda, depositorWallet, this.toNum(nonce));
87
+ const [pendingPda] = (0, pda_1.derivePendingSettlement)(escrowPda, this.toNum(settlementIndex));
88
+ const [disputePda] = (0, pda_1.deriveDispute)(pendingPda);
89
+ const [receiptPda] = this.deriveReceiptBatch(escrowPda, batchIndex);
90
+ return this.methods
91
+ .submitReceiptProof(batchIndex, this.bn(provenCount), proof, leaf)
92
+ .accounts({
93
+ wallet: this.walletPubkey,
94
+ agent: agentPda,
95
+ escrow: escrowPda,
96
+ pendingSettlement: pendingPda,
97
+ dispute: disputePda,
98
+ receiptBatch: receiptPda,
99
+ })
100
+ .rpc();
101
+ }
102
+ /**
103
+ * Trigger automatic dispute resolution after the proof deadline.
104
+ *
105
+ * Permissionless crank — anyone can call this once the deadline has passed.
106
+ * Resolution is proportional: if the agent proved N of M claimed calls,
107
+ * N/M of the settlement amount goes to the agent, the rest is refunded.
108
+ *
109
+ * @param agentWallet - The agent's wallet.
110
+ * @param depositorWallet - The depositor's wallet.
111
+ * @param nonce - Escrow nonce.
112
+ * @param settlementIndex - Index of the disputed pending settlement.
113
+ */
114
+ async autoResolveDispute(agentWallet, depositorWallet, nonce, settlementIndex) {
115
+ const [agentPda] = (0, pda_1.deriveAgent)(agentWallet);
116
+ const [escrowPda] = (0, pda_1.deriveEscrowV2)(agentPda, depositorWallet, this.toNum(nonce));
117
+ const [pendingPda] = (0, pda_1.derivePendingSettlement)(escrowPda, this.toNum(settlementIndex));
118
+ const [disputePda] = (0, pda_1.deriveDispute)(pendingPda);
119
+ const [statsPda] = (0, pda_1.deriveAgentStats)(agentPda);
120
+ return this.methods
121
+ .autoResolveDispute()
122
+ .accounts({
123
+ payer: this.walletPubkey,
124
+ depositor: depositorWallet,
125
+ agentWallet,
126
+ escrow: escrowPda,
127
+ pendingSettlement: pendingPda,
128
+ dispute: disputePda,
129
+ agentStats: statsPda,
130
+ })
131
+ .rpc();
132
+ }
133
+ // ── Fetchers ─────────────────────────────────────────
134
+ async fetchReceiptBatch(escrowV2Pda, batchIndex) {
135
+ const [pda] = this.deriveReceiptBatch(escrowV2Pda, batchIndex);
136
+ return this.fetchAccount("receiptBatch", pda);
137
+ }
138
+ async fetchReceiptBatchNullable(escrowV2Pda, batchIndex) {
139
+ const [pda] = this.deriveReceiptBatch(escrowV2Pda, batchIndex);
140
+ return this.fetchAccountNullable("receiptBatch", pda);
141
+ }
142
+ }
143
+ exports.ReceiptModule = ReceiptModule;
144
+ //# sourceMappingURL=receipt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receipt.js","sourceRoot":"","sources":["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