@usesigil/kit 0.15.0 → 0.17.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 (627) hide show
  1. package/README.md +56 -0
  2. package/dist/advanced-analytics.d.ts +3 -2
  3. package/dist/advanced-analytics.d.ts.map +1 -1
  4. package/dist/advanced-analytics.js +9 -42
  5. package/dist/advanced-analytics.js.map +1 -1
  6. package/dist/agent-bootstrap.d.ts +117 -0
  7. package/dist/agent-bootstrap.d.ts.map +1 -0
  8. package/dist/agent-bootstrap.js +211 -0
  9. package/dist/agent-bootstrap.js.map +1 -0
  10. package/dist/agent-errors.d.ts +20 -4
  11. package/dist/agent-errors.d.ts.map +1 -1
  12. package/dist/agent-errors.js +947 -377
  13. package/dist/agent-errors.js.map +1 -1
  14. package/dist/audit-log.d.ts +101 -0
  15. package/dist/audit-log.d.ts.map +1 -0
  16. package/dist/audit-log.js +145 -0
  17. package/dist/audit-log.js.map +1 -0
  18. package/dist/build-unsigned.d.ts +152 -0
  19. package/dist/build-unsigned.d.ts.map +1 -0
  20. package/dist/build-unsigned.js +152 -0
  21. package/dist/build-unsigned.js.map +1 -0
  22. package/dist/caip2-network.d.ts +171 -0
  23. package/dist/caip2-network.d.ts.map +1 -0
  24. package/dist/caip2-network.js +202 -0
  25. package/dist/caip2-network.js.map +1 -0
  26. package/dist/canonical-encode.d.ts +59 -0
  27. package/dist/canonical-encode.d.ts.map +1 -0
  28. package/dist/canonical-encode.js +141 -0
  29. package/dist/canonical-encode.js.map +1 -0
  30. package/dist/cosign-helper.d.ts +264 -0
  31. package/dist/cosign-helper.d.ts.map +1 -0
  32. package/dist/cosign-helper.js +147 -0
  33. package/dist/cosign-helper.js.map +1 -0
  34. package/dist/create-vault.d.ts +102 -1
  35. package/dist/create-vault.d.ts.map +1 -1
  36. package/dist/create-vault.js +108 -9
  37. package/dist/create-vault.js.map +1 -1
  38. package/dist/dashboard/close-vault.d.ts +110 -0
  39. package/dist/dashboard/close-vault.d.ts.map +1 -0
  40. package/dist/dashboard/close-vault.js +165 -0
  41. package/dist/dashboard/close-vault.js.map +1 -0
  42. package/dist/dashboard/errors.d.ts +37 -0
  43. package/dist/dashboard/errors.d.ts.map +1 -1
  44. package/dist/dashboard/errors.js +81 -1
  45. package/dist/dashboard/errors.js.map +1 -1
  46. package/dist/dashboard/from-json.d.ts.map +1 -1
  47. package/dist/dashboard/from-json.js +1 -2
  48. package/dist/dashboard/from-json.js.map +1 -1
  49. package/dist/dashboard/index.d.ts +204 -31
  50. package/dist/dashboard/index.d.ts.map +1 -1
  51. package/dist/dashboard/index.js +290 -49
  52. package/dist/dashboard/index.js.map +1 -1
  53. package/dist/dashboard/mutations.d.ts +160 -10
  54. package/dist/dashboard/mutations.d.ts.map +1 -1
  55. package/dist/dashboard/mutations.js +584 -66
  56. package/dist/dashboard/mutations.js.map +1 -1
  57. package/dist/dashboard/post-assertion-validation.d.ts +88 -0
  58. package/dist/dashboard/post-assertion-validation.d.ts.map +1 -0
  59. package/dist/dashboard/post-assertion-validation.js +312 -0
  60. package/dist/dashboard/post-assertion-validation.js.map +1 -0
  61. package/dist/dashboard/reads.d.ts +92 -1
  62. package/dist/dashboard/reads.d.ts.map +1 -1
  63. package/dist/dashboard/reads.js +244 -26
  64. package/dist/dashboard/reads.js.map +1 -1
  65. package/dist/dashboard/types.d.ts +172 -21
  66. package/dist/dashboard/types.d.ts.map +1 -1
  67. package/dist/errors/agent-errors.generated.d.ts +21 -0
  68. package/dist/errors/agent-errors.generated.d.ts.map +1 -0
  69. package/dist/errors/agent-errors.generated.js +133 -0
  70. package/dist/errors/agent-errors.generated.js.map +1 -0
  71. package/dist/errors/codes.d.ts +21 -2
  72. package/dist/errors/codes.d.ts.map +1 -1
  73. package/dist/errors/codes.js +20 -1
  74. package/dist/errors/codes.js.map +1 -1
  75. package/dist/errors/context.d.ts +9 -1
  76. package/dist/errors/context.d.ts.map +1 -1
  77. package/dist/event-analytics.d.ts +1 -3
  78. package/dist/event-analytics.d.ts.map +1 -1
  79. package/dist/event-analytics.js +28 -81
  80. package/dist/event-analytics.js.map +1 -1
  81. package/dist/events.d.ts.map +1 -1
  82. package/dist/events.js +23 -13
  83. package/dist/events.js.map +1 -1
  84. package/dist/generated/accounts/agentSpendOverlay.d.ts +60 -0
  85. package/dist/generated/accounts/agentSpendOverlay.d.ts.map +1 -1
  86. package/dist/generated/accounts/agentSpendOverlay.js +6 -2
  87. package/dist/generated/accounts/agentSpendOverlay.js.map +1 -1
  88. package/dist/generated/accounts/agentVault.d.ts +168 -4
  89. package/dist/generated/accounts/agentVault.d.ts.map +1 -1
  90. package/dist/generated/accounts/agentVault.js +11 -3
  91. package/dist/generated/accounts/agentVault.js.map +1 -1
  92. package/dist/generated/accounts/auditLogRejected.d.ts +66 -0
  93. package/dist/generated/accounts/auditLogRejected.d.ts.map +1 -0
  94. package/dist/generated/accounts/auditLogRejected.js +68 -0
  95. package/dist/generated/accounts/auditLogRejected.js.map +1 -0
  96. package/dist/generated/accounts/auditLogSuccess.d.ts +78 -0
  97. package/dist/generated/accounts/auditLogSuccess.d.ts.map +1 -0
  98. package/dist/generated/accounts/auditLogSuccess.js +68 -0
  99. package/dist/generated/accounts/auditLogSuccess.js.map +1 -0
  100. package/dist/generated/accounts/index.d.ts +4 -4
  101. package/dist/generated/accounts/index.d.ts.map +1 -1
  102. package/dist/generated/accounts/index.js +4 -4
  103. package/dist/generated/accounts/index.js.map +1 -1
  104. package/dist/generated/accounts/pendingAgentGrant.d.ts +199 -0
  105. package/dist/generated/accounts/pendingAgentGrant.d.ts.map +1 -0
  106. package/dist/generated/accounts/pendingAgentGrant.js +75 -0
  107. package/dist/generated/accounts/pendingAgentGrant.js.map +1 -0
  108. package/dist/generated/accounts/pendingAgentPermissionsUpdate.d.ts +76 -0
  109. package/dist/generated/accounts/pendingAgentPermissionsUpdate.d.ts.map +1 -1
  110. package/dist/generated/accounts/pendingAgentPermissionsUpdate.js +9 -1
  111. package/dist/generated/accounts/pendingAgentPermissionsUpdate.js.map +1 -1
  112. package/dist/generated/accounts/pendingOwnershipTransfer.d.ts +131 -0
  113. package/dist/generated/accounts/pendingOwnershipTransfer.d.ts.map +1 -0
  114. package/dist/generated/accounts/pendingOwnershipTransfer.js +76 -0
  115. package/dist/generated/accounts/pendingOwnershipTransfer.js.map +1 -0
  116. package/dist/generated/accounts/pendingPolicyUpdate.d.ts +220 -4
  117. package/dist/generated/accounts/pendingPolicyUpdate.d.ts.map +1 -1
  118. package/dist/generated/accounts/pendingPolicyUpdate.js +25 -5
  119. package/dist/generated/accounts/pendingPolicyUpdate.js.map +1 -1
  120. package/dist/generated/accounts/policyConfig.d.ts +495 -34
  121. package/dist/generated/accounts/policyConfig.d.ts.map +1 -1
  122. package/dist/generated/accounts/policyConfig.js +34 -7
  123. package/dist/generated/accounts/policyConfig.js.map +1 -1
  124. package/dist/generated/accounts/postExecutionAssertions.d.ts +2 -2
  125. package/dist/generated/accounts/postExecutionAssertions.d.ts.map +1 -1
  126. package/dist/generated/accounts/postExecutionAssertions.js +3 -3
  127. package/dist/generated/accounts/sessionAuthority.d.ts +154 -12
  128. package/dist/generated/accounts/sessionAuthority.d.ts.map +1 -1
  129. package/dist/generated/accounts/sessionAuthority.js +12 -10
  130. package/dist/generated/accounts/sessionAuthority.js.map +1 -1
  131. package/dist/generated/accounts/spendTracker.d.ts +83 -3
  132. package/dist/generated/accounts/spendTracker.d.ts.map +1 -1
  133. package/dist/generated/accounts/spendTracker.js +14 -2
  134. package/dist/generated/accounts/spendTracker.js.map +1 -1
  135. package/dist/generated/errors/sigil.d.ts +160 -100
  136. package/dist/generated/errors/sigil.d.ts.map +1 -1
  137. package/dist/generated/errors/sigil.js +214 -124
  138. package/dist/generated/errors/sigil.js.map +1 -1
  139. package/dist/generated/event-discriminators.d.ts.map +1 -1
  140. package/dist/generated/event-discriminators.js +11 -13
  141. package/dist/generated/event-discriminators.js.map +1 -1
  142. package/dist/generated/instructions/acceptOwnershipTransfer.d.ts +142 -0
  143. package/dist/generated/instructions/acceptOwnershipTransfer.d.ts.map +1 -0
  144. package/dist/generated/instructions/acceptOwnershipTransfer.js +171 -0
  145. package/dist/generated/instructions/acceptOwnershipTransfer.js.map +1 -0
  146. package/dist/generated/instructions/acceptOwnershipTransferMultisig.d.ts +142 -0
  147. package/dist/generated/instructions/acceptOwnershipTransferMultisig.d.ts.map +1 -0
  148. package/dist/generated/instructions/acceptOwnershipTransferMultisig.js +171 -0
  149. package/dist/generated/instructions/acceptOwnershipTransferMultisig.js.map +1 -0
  150. package/dist/generated/instructions/applyAgentGrant.d.ts +100 -0
  151. package/dist/generated/instructions/applyAgentGrant.d.ts.map +1 -0
  152. package/dist/generated/instructions/{applyConstraintsUpdate.js → applyAgentGrant.js} +66 -42
  153. package/dist/generated/instructions/applyAgentGrant.js.map +1 -0
  154. package/dist/generated/instructions/applyAgentPermissionsUpdate.d.ts +31 -8
  155. package/dist/generated/instructions/applyAgentPermissionsUpdate.d.ts.map +1 -1
  156. package/dist/generated/instructions/applyAgentPermissionsUpdate.js +38 -2
  157. package/dist/generated/instructions/applyAgentPermissionsUpdate.js.map +1 -1
  158. package/dist/generated/instructions/applyPendingPolicy.d.ts +18 -7
  159. package/dist/generated/instructions/applyPendingPolicy.d.ts.map +1 -1
  160. package/dist/generated/instructions/applyPendingPolicy.js +38 -2
  161. package/dist/generated/instructions/applyPendingPolicy.js.map +1 -1
  162. package/dist/generated/instructions/cancelAgentGrant.d.ts +106 -0
  163. package/dist/generated/instructions/cancelAgentGrant.d.ts.map +1 -0
  164. package/dist/generated/instructions/{allocatePendingConstraintsPda.js → cancelAgentGrant.js} +54 -42
  165. package/dist/generated/instructions/cancelAgentGrant.js.map +1 -0
  166. package/dist/generated/instructions/cancelOwnershipTransfer.d.ts +121 -0
  167. package/dist/generated/instructions/cancelOwnershipTransfer.d.ts.map +1 -0
  168. package/dist/generated/instructions/{queueCloseConstraints.js → cancelOwnershipTransfer.js} +58 -44
  169. package/dist/generated/instructions/cancelOwnershipTransfer.js.map +1 -0
  170. package/dist/generated/instructions/closePostAssertions.d.ts +6 -1
  171. package/dist/generated/instructions/closePostAssertions.d.ts.map +1 -1
  172. package/dist/generated/instructions/closePostAssertions.js +11 -3
  173. package/dist/generated/instructions/closePostAssertions.js.map +1 -1
  174. package/dist/generated/instructions/closeVault.d.ts +40 -8
  175. package/dist/generated/instructions/closeVault.d.ts.map +1 -1
  176. package/dist/generated/instructions/closeVault.js +40 -2
  177. package/dist/generated/instructions/closeVault.js.map +1 -1
  178. package/dist/generated/instructions/createPostAssertions.d.ts +4 -0
  179. package/dist/generated/instructions/createPostAssertions.d.ts.map +1 -1
  180. package/dist/generated/instructions/createPostAssertions.js +2 -0
  181. package/dist/generated/instructions/createPostAssertions.js.map +1 -1
  182. package/dist/generated/instructions/depositFunds.d.ts +21 -10
  183. package/dist/generated/instructions/depositFunds.d.ts.map +1 -1
  184. package/dist/generated/instructions/depositFunds.js +37 -2
  185. package/dist/generated/instructions/depositFunds.js.map +1 -1
  186. package/dist/generated/instructions/finalizeSession.d.ts +49 -7
  187. package/dist/generated/instructions/finalizeSession.d.ts.map +1 -1
  188. package/dist/generated/instructions/finalizeSession.js +59 -2
  189. package/dist/generated/instructions/finalizeSession.js.map +1 -1
  190. package/dist/generated/instructions/freezeVault.d.ts +39 -5
  191. package/dist/generated/instructions/freezeVault.d.ts.map +1 -1
  192. package/dist/generated/instructions/freezeVault.js +77 -5
  193. package/dist/generated/instructions/freezeVault.js.map +1 -1
  194. package/dist/generated/instructions/index.d.ts +10 -14
  195. package/dist/generated/instructions/index.d.ts.map +1 -1
  196. package/dist/generated/instructions/index.js +10 -14
  197. package/dist/generated/instructions/index.js.map +1 -1
  198. package/dist/generated/instructions/initializeVault.d.ts +79 -13
  199. package/dist/generated/instructions/initializeVault.d.ts.map +1 -1
  200. package/dist/generated/instructions/initializeVault.js +57 -5
  201. package/dist/generated/instructions/initializeVault.js.map +1 -1
  202. package/dist/generated/instructions/initiateOwnershipTransfer.d.ts +106 -0
  203. package/dist/generated/instructions/initiateOwnershipTransfer.d.ts.map +1 -0
  204. package/dist/generated/instructions/initiateOwnershipTransfer.js +181 -0
  205. package/dist/generated/instructions/initiateOwnershipTransfer.js.map +1 -0
  206. package/dist/generated/instructions/pauseAgent.d.ts +49 -5
  207. package/dist/generated/instructions/pauseAgent.d.ts.map +1 -1
  208. package/dist/generated/instructions/pauseAgent.js +80 -5
  209. package/dist/generated/instructions/pauseAgent.js.map +1 -1
  210. package/dist/generated/instructions/promoteGraylistDestination.d.ts +56 -0
  211. package/dist/generated/instructions/promoteGraylistDestination.d.ts.map +1 -0
  212. package/dist/generated/instructions/{createInstructionConstraints.js → promoteGraylistDestination.js} +23 -40
  213. package/dist/generated/instructions/promoteGraylistDestination.js.map +1 -0
  214. package/dist/generated/instructions/queueAgentGrant.d.ts +113 -0
  215. package/dist/generated/instructions/queueAgentGrant.d.ts.map +1 -0
  216. package/dist/generated/instructions/queueAgentGrant.js +181 -0
  217. package/dist/generated/instructions/queueAgentGrant.js.map +1 -0
  218. package/dist/generated/instructions/queueAgentPermissionsUpdate.d.ts +8 -0
  219. package/dist/generated/instructions/queueAgentPermissionsUpdate.d.ts.map +1 -1
  220. package/dist/generated/instructions/queueAgentPermissionsUpdate.js +4 -0
  221. package/dist/generated/instructions/queueAgentPermissionsUpdate.js.map +1 -1
  222. package/dist/generated/instructions/queuePolicyUpdate.d.ts +40 -8
  223. package/dist/generated/instructions/queuePolicyUpdate.d.ts.map +1 -1
  224. package/dist/generated/instructions/queuePolicyUpdate.js +21 -5
  225. package/dist/generated/instructions/queuePolicyUpdate.js.map +1 -1
  226. package/dist/generated/instructions/reactivateVault.d.ts +71 -5
  227. package/dist/generated/instructions/reactivateVault.d.ts.map +1 -1
  228. package/dist/generated/instructions/reactivateVault.js +80 -5
  229. package/dist/generated/instructions/reactivateVault.js.map +1 -1
  230. package/dist/generated/instructions/recordAgentViolation.d.ts +89 -0
  231. package/dist/generated/instructions/recordAgentViolation.d.ts.map +1 -0
  232. package/dist/generated/instructions/recordAgentViolation.js +152 -0
  233. package/dist/generated/instructions/recordAgentViolation.js.map +1 -0
  234. package/dist/generated/instructions/registerAgent.d.ts +84 -6
  235. package/dist/generated/instructions/registerAgent.d.ts.map +1 -1
  236. package/dist/generated/instructions/registerAgent.js +81 -4
  237. package/dist/generated/instructions/registerAgent.js.map +1 -1
  238. package/dist/generated/instructions/revokeAgent.d.ts +49 -6
  239. package/dist/generated/instructions/revokeAgent.d.ts.map +1 -1
  240. package/dist/generated/instructions/revokeAgent.js +81 -4
  241. package/dist/generated/instructions/revokeAgent.js.map +1 -1
  242. package/dist/generated/instructions/setObserveOnly.d.ts +56 -0
  243. package/dist/generated/instructions/setObserveOnly.d.ts.map +1 -0
  244. package/dist/generated/instructions/setObserveOnly.js +111 -0
  245. package/dist/generated/instructions/setObserveOnly.js.map +1 -0
  246. package/dist/generated/instructions/unpauseAgent.d.ts +46 -5
  247. package/dist/generated/instructions/unpauseAgent.d.ts.map +1 -1
  248. package/dist/generated/instructions/unpauseAgent.js +80 -5
  249. package/dist/generated/instructions/unpauseAgent.js.map +1 -1
  250. package/dist/generated/instructions/validateAndAuthorize.d.ts +29 -0
  251. package/dist/generated/instructions/validateAndAuthorize.d.ts.map +1 -1
  252. package/dist/generated/instructions/validateAndAuthorize.js +4 -0
  253. package/dist/generated/instructions/validateAndAuthorize.js.map +1 -1
  254. package/dist/generated/instructions/withdrawFunds.d.ts +53 -11
  255. package/dist/generated/instructions/withdrawFunds.d.ts.map +1 -1
  256. package/dist/generated/instructions/withdrawFunds.js +51 -2
  257. package/dist/generated/instructions/withdrawFunds.js.map +1 -1
  258. package/dist/generated/programs/sigil.d.ts +79 -95
  259. package/dist/generated/programs/sigil.d.ts.map +1 -1
  260. package/dist/generated/programs/sigil.js +139 -187
  261. package/dist/generated/programs/sigil.js.map +1 -1
  262. package/dist/generated/types/actionAuthorized.d.ts +0 -2
  263. package/dist/generated/types/actionAuthorized.d.ts.map +1 -1
  264. package/dist/generated/types/actionAuthorized.js +0 -2
  265. package/dist/generated/types/actionAuthorized.js.map +1 -1
  266. package/dist/generated/types/agentAutoRevoked.d.ts +31 -0
  267. package/dist/generated/types/agentAutoRevoked.d.ts.map +1 -0
  268. package/dist/generated/types/{pdaAllocated.js → agentAutoRevoked.js} +12 -10
  269. package/dist/generated/types/agentAutoRevoked.js.map +1 -0
  270. package/dist/generated/types/agentEntry.d.ts +48 -0
  271. package/dist/generated/types/agentEntry.d.ts.map +1 -1
  272. package/dist/generated/types/agentEntry.js +4 -2
  273. package/dist/generated/types/agentEntry.js.map +1 -1
  274. package/dist/generated/types/agentGrantApplied.d.ts +38 -0
  275. package/dist/generated/types/agentGrantApplied.d.ts.map +1 -0
  276. package/dist/generated/types/agentGrantApplied.js +34 -0
  277. package/dist/generated/types/agentGrantApplied.js.map +1 -0
  278. package/dist/generated/types/agentGrantCancelled.d.ts +33 -0
  279. package/dist/generated/types/agentGrantCancelled.d.ts.map +1 -0
  280. package/dist/generated/types/agentGrantCancelled.js +28 -0
  281. package/dist/generated/types/agentGrantCancelled.js.map +1 -0
  282. package/dist/generated/types/agentGrantQueued.d.ts +38 -0
  283. package/dist/generated/types/agentGrantQueued.d.ts.map +1 -0
  284. package/dist/generated/types/agentGrantQueued.js +32 -0
  285. package/dist/generated/types/agentGrantQueued.js.map +1 -0
  286. package/dist/generated/types/auditEntry.d.ts +120 -0
  287. package/dist/generated/types/auditEntry.d.ts.map +1 -0
  288. package/dist/generated/types/auditEntry.js +34 -0
  289. package/dist/generated/types/auditEntry.js.map +1 -0
  290. package/dist/generated/types/destinationGraylistEntry.d.ts +32 -0
  291. package/dist/generated/types/destinationGraylistEntry.d.ts.map +1 -0
  292. package/dist/generated/types/destinationGraylistEntry.js +24 -0
  293. package/dist/generated/types/destinationGraylistEntry.js.map +1 -0
  294. package/dist/generated/types/graylistEntered.d.ts +31 -0
  295. package/dist/generated/types/graylistEntered.d.ts.map +1 -0
  296. package/dist/generated/types/graylistEntered.js +30 -0
  297. package/dist/generated/types/graylistEntered.js.map +1 -0
  298. package/dist/generated/types/graylistPromoted.d.ts +29 -0
  299. package/dist/generated/types/graylistPromoted.d.ts.map +1 -0
  300. package/dist/generated/types/graylistPromoted.js +28 -0
  301. package/dist/generated/types/graylistPromoted.js.map +1 -0
  302. package/dist/generated/types/index.d.ts +13 -21
  303. package/dist/generated/types/index.d.ts.map +1 -1
  304. package/dist/generated/types/index.js +13 -21
  305. package/dist/generated/types/index.js.map +1 -1
  306. package/dist/generated/types/observeOnlyChanged.d.ts +33 -0
  307. package/dist/generated/types/observeOnlyChanged.d.ts.map +1 -0
  308. package/dist/generated/types/observeOnlyChanged.js +32 -0
  309. package/dist/generated/types/observeOnlyChanged.js.map +1 -0
  310. package/dist/generated/types/ownershipTransferAccepted.d.ts +32 -0
  311. package/dist/generated/types/ownershipTransferAccepted.d.ts.map +1 -0
  312. package/dist/generated/types/ownershipTransferAccepted.js +30 -0
  313. package/dist/generated/types/ownershipTransferAccepted.js.map +1 -0
  314. package/dist/generated/types/ownershipTransferCancelled.d.ts +29 -0
  315. package/dist/generated/types/ownershipTransferCancelled.d.ts.map +1 -0
  316. package/dist/generated/types/ownershipTransferCancelled.js +28 -0
  317. package/dist/generated/types/ownershipTransferCancelled.js.map +1 -0
  318. package/dist/generated/types/ownershipTransferInitiated.d.ts +33 -0
  319. package/dist/generated/types/ownershipTransferInitiated.d.ts.map +1 -0
  320. package/dist/generated/types/ownershipTransferInitiated.js +30 -0
  321. package/dist/generated/types/ownershipTransferInitiated.js.map +1 -0
  322. package/dist/generated/types/perRecipientCounter.d.ts +61 -0
  323. package/dist/generated/types/perRecipientCounter.d.ts.map +1 -0
  324. package/dist/generated/types/perRecipientCounter.js +26 -0
  325. package/dist/generated/types/perRecipientCounter.js.map +1 -0
  326. package/dist/generated/types/postAssertionEntry.d.ts +14 -7
  327. package/dist/generated/types/postAssertionEntry.d.ts.map +1 -1
  328. package/dist/generated/types/postAssertionEntry.js +5 -7
  329. package/dist/generated/types/postAssertionEntry.js.map +1 -1
  330. package/dist/generated/types/postAssertionEntryZC.d.ts +53 -22
  331. package/dist/generated/types/postAssertionEntryZC.d.ts.map +1 -1
  332. package/dist/generated/types/postAssertionEntryZC.js +4 -6
  333. package/dist/generated/types/postAssertionEntryZC.js.map +1 -1
  334. package/dist/generated/types/sessionFinalized.d.ts +0 -4
  335. package/dist/generated/types/sessionFinalized.d.ts.map +1 -1
  336. package/dist/generated/types/sessionFinalized.js +0 -2
  337. package/dist/generated/types/sessionFinalized.js.map +1 -1
  338. package/dist/generated/types/vaultFrozen.d.ts +26 -0
  339. package/dist/generated/types/vaultFrozen.d.ts.map +1 -1
  340. package/dist/generated/types/vaultFrozen.js +5 -1
  341. package/dist/generated/types/vaultFrozen.js.map +1 -1
  342. package/dist/index.d.ts +35 -6
  343. package/dist/index.d.ts.map +1 -1
  344. package/dist/index.js +81 -7
  345. package/dist/index.js.map +1 -1
  346. package/dist/inscribe.d.ts +0 -4
  347. package/dist/inscribe.d.ts.map +1 -1
  348. package/dist/inscribe.js +0 -1
  349. package/dist/inscribe.js.map +1 -1
  350. package/dist/inspector.d.ts +0 -23
  351. package/dist/inspector.d.ts.map +1 -1
  352. package/dist/inspector.js +0 -52
  353. package/dist/inspector.js.map +1 -1
  354. package/dist/kit-adapter.d.ts +1 -1
  355. package/dist/kit-adapter.d.ts.map +1 -1
  356. package/dist/kit-adapter.js +1 -1
  357. package/dist/kit-adapter.js.map +1 -1
  358. package/dist/logger.d.ts +48 -0
  359. package/dist/logger.d.ts.map +1 -1
  360. package/dist/logger.js +36 -0
  361. package/dist/logger.js.map +1 -1
  362. package/dist/multisig-detection.d.ts +83 -0
  363. package/dist/multisig-detection.d.ts.map +1 -0
  364. package/dist/multisig-detection.js +128 -0
  365. package/dist/multisig-detection.js.map +1 -0
  366. package/dist/owner-transaction.d.ts +8 -0
  367. package/dist/owner-transaction.d.ts.map +1 -1
  368. package/dist/owner-transaction.js +1 -0
  369. package/dist/owner-transaction.js.map +1 -1
  370. package/dist/ownership-transfer.d.ts +79 -0
  371. package/dist/ownership-transfer.d.ts.map +1 -0
  372. package/dist/ownership-transfer.js +66 -0
  373. package/dist/ownership-transfer.js.map +1 -0
  374. package/dist/policy/compute-cosign-digest.d.ts +193 -0
  375. package/dist/policy/compute-cosign-digest.d.ts.map +1 -0
  376. package/dist/policy/compute-cosign-digest.js +318 -0
  377. package/dist/policy/compute-cosign-digest.js.map +1 -0
  378. package/dist/policy/compute-policy-preview-digest.d.ts +258 -0
  379. package/dist/policy/compute-policy-preview-digest.d.ts.map +1 -0
  380. package/dist/policy/compute-policy-preview-digest.js +351 -0
  381. package/dist/policy/compute-policy-preview-digest.js.map +1 -0
  382. package/dist/policy-attestation.d.ts +51 -0
  383. package/dist/policy-attestation.d.ts.map +1 -0
  384. package/dist/policy-attestation.js +43 -0
  385. package/dist/policy-attestation.js.map +1 -0
  386. package/dist/presets.d.ts +1 -7
  387. package/dist/presets.d.ts.map +1 -1
  388. package/dist/presets.js +0 -5
  389. package/dist/presets.js.map +1 -1
  390. package/dist/preview-create-vault.d.ts +280 -0
  391. package/dist/preview-create-vault.d.ts.map +1 -0
  392. package/dist/preview-create-vault.js +498 -0
  393. package/dist/preview-create-vault.js.map +1 -0
  394. package/dist/resolve-accounts.d.ts +75 -10
  395. package/dist/resolve-accounts.d.ts.map +1 -1
  396. package/dist/resolve-accounts.js +68 -32
  397. package/dist/resolve-accounts.js.map +1 -1
  398. package/dist/rpc-helpers.d.ts +29 -3
  399. package/dist/rpc-helpers.d.ts.map +1 -1
  400. package/dist/rpc-helpers.js +51 -12
  401. package/dist/rpc-helpers.js.map +1 -1
  402. package/dist/seal/intent-digest.d.ts +195 -0
  403. package/dist/seal/intent-digest.d.ts.map +1 -0
  404. package/dist/seal/intent-digest.js +372 -0
  405. package/dist/seal/intent-digest.js.map +1 -0
  406. package/dist/seal.d.ts +166 -3
  407. package/dist/seal.d.ts.map +1 -1
  408. package/dist/seal.js +428 -8
  409. package/dist/seal.js.map +1 -1
  410. package/dist/security-analytics.d.ts +3 -3
  411. package/dist/security-analytics.d.ts.map +1 -1
  412. package/dist/security-analytics.js +13 -128
  413. package/dist/security-analytics.js.map +1 -1
  414. package/dist/session-mint.d.ts +72 -0
  415. package/dist/session-mint.d.ts.map +1 -0
  416. package/dist/session-mint.js +59 -0
  417. package/dist/session-mint.js.map +1 -0
  418. package/dist/sigil.d.ts +0 -4
  419. package/dist/sigil.d.ts.map +1 -1
  420. package/dist/simulation.d.ts +19 -0
  421. package/dist/simulation.d.ts.map +1 -1
  422. package/dist/simulation.js +211 -138
  423. package/dist/simulation.js.map +1 -1
  424. package/dist/squads-detection.d.ts +135 -0
  425. package/dist/squads-detection.d.ts.map +1 -0
  426. package/dist/squads-detection.js +124 -0
  427. package/dist/squads-detection.js.map +1 -0
  428. package/dist/state-resolver.d.ts +0 -16
  429. package/dist/state-resolver.d.ts.map +1 -1
  430. package/dist/state-resolver.js +162 -97
  431. package/dist/state-resolver.js.map +1 -1
  432. package/dist/testing/devnet.d.ts +40 -1
  433. package/dist/testing/devnet.d.ts.map +1 -1
  434. package/dist/testing/devnet.js +333 -45
  435. package/dist/testing/devnet.js.map +1 -1
  436. package/dist/testing/errors/expect.d.ts +137 -0
  437. package/dist/testing/errors/expect.d.ts.map +1 -0
  438. package/dist/testing/errors/expect.js +372 -0
  439. package/dist/testing/errors/expect.js.map +1 -0
  440. package/dist/testing/errors/index.d.ts +3 -0
  441. package/dist/testing/errors/index.d.ts.map +1 -0
  442. package/dist/testing/errors/index.js +8 -0
  443. package/dist/testing/errors/index.js.map +1 -0
  444. package/dist/testing/errors/names.generated.d.ts +211 -0
  445. package/dist/testing/errors/names.generated.d.ts.map +1 -0
  446. package/dist/testing/errors/names.generated.js +206 -0
  447. package/dist/testing/errors/names.generated.js.map +1 -0
  448. package/dist/testing/index.d.ts +1 -0
  449. package/dist/testing/index.d.ts.map +1 -1
  450. package/dist/testing/index.js +8 -0
  451. package/dist/testing/index.js.map +1 -1
  452. package/dist/testing/mock-rpc.d.ts +16 -0
  453. package/dist/testing/mock-rpc.d.ts.map +1 -1
  454. package/dist/testing/mock-rpc.js +27 -0
  455. package/dist/testing/mock-rpc.js.map +1 -1
  456. package/dist/testing/mock-state.d.ts +2 -0
  457. package/dist/testing/mock-state.d.ts.map +1 -1
  458. package/dist/testing/mock-state.js +45 -6
  459. package/dist/testing/mock-state.js.map +1 -1
  460. package/dist/types.d.ts +5 -15
  461. package/dist/types.d.ts.map +1 -1
  462. package/dist/types.js +11 -69
  463. package/dist/types.js.map +1 -1
  464. package/dist/vault-analytics.d.ts +0 -2
  465. package/dist/vault-analytics.d.ts.map +1 -1
  466. package/dist/vault-analytics.js +1 -9
  467. package/dist/vault-analytics.js.map +1 -1
  468. package/package.json +12 -5
  469. package/dist/dashboard/constraint-reads.d.ts +0 -50
  470. package/dist/dashboard/constraint-reads.d.ts.map +0 -1
  471. package/dist/dashboard/constraint-reads.js +0 -119
  472. package/dist/dashboard/constraint-reads.js.map +0 -1
  473. package/dist/generated/accounts/escrowDeposit.d.ts +0 -50
  474. package/dist/generated/accounts/escrowDeposit.d.ts.map +0 -1
  475. package/dist/generated/accounts/escrowDeposit.js +0 -76
  476. package/dist/generated/accounts/escrowDeposit.js.map +0 -1
  477. package/dist/generated/accounts/instructionConstraints.d.ts +0 -46
  478. package/dist/generated/accounts/instructionConstraints.d.ts.map +0 -1
  479. package/dist/generated/accounts/instructionConstraints.js +0 -73
  480. package/dist/generated/accounts/instructionConstraints.js.map +0 -1
  481. package/dist/generated/accounts/pendingCloseConstraints.d.ts +0 -37
  482. package/dist/generated/accounts/pendingCloseConstraints.d.ts.map +0 -1
  483. package/dist/generated/accounts/pendingCloseConstraints.js +0 -66
  484. package/dist/generated/accounts/pendingCloseConstraints.js.map +0 -1
  485. package/dist/generated/accounts/pendingConstraintsUpdate.d.ts +0 -62
  486. package/dist/generated/accounts/pendingConstraintsUpdate.d.ts.map +0 -1
  487. package/dist/generated/accounts/pendingConstraintsUpdate.js +0 -75
  488. package/dist/generated/accounts/pendingConstraintsUpdate.js.map +0 -1
  489. package/dist/generated/instructions/allocateConstraintsPda.d.ts +0 -62
  490. package/dist/generated/instructions/allocateConstraintsPda.d.ts.map +0 -1
  491. package/dist/generated/instructions/allocateConstraintsPda.js +0 -134
  492. package/dist/generated/instructions/allocateConstraintsPda.js.map +0 -1
  493. package/dist/generated/instructions/allocatePendingConstraintsPda.d.ts +0 -66
  494. package/dist/generated/instructions/allocatePendingConstraintsPda.d.ts.map +0 -1
  495. package/dist/generated/instructions/allocatePendingConstraintsPda.js.map +0 -1
  496. package/dist/generated/instructions/applyCloseConstraints.d.ts +0 -59
  497. package/dist/generated/instructions/applyCloseConstraints.d.ts.map +0 -1
  498. package/dist/generated/instructions/applyCloseConstraints.js +0 -143
  499. package/dist/generated/instructions/applyCloseConstraints.js.map +0 -1
  500. package/dist/generated/instructions/applyConstraintsUpdate.d.ts +0 -62
  501. package/dist/generated/instructions/applyConstraintsUpdate.d.ts.map +0 -1
  502. package/dist/generated/instructions/applyConstraintsUpdate.js.map +0 -1
  503. package/dist/generated/instructions/cancelCloseConstraints.d.ts +0 -51
  504. package/dist/generated/instructions/cancelCloseConstraints.d.ts.map +0 -1
  505. package/dist/generated/instructions/cancelCloseConstraints.js +0 -115
  506. package/dist/generated/instructions/cancelCloseConstraints.js.map +0 -1
  507. package/dist/generated/instructions/cancelConstraintsUpdate.d.ts +0 -51
  508. package/dist/generated/instructions/cancelConstraintsUpdate.d.ts.map +0 -1
  509. package/dist/generated/instructions/cancelConstraintsUpdate.js +0 -115
  510. package/dist/generated/instructions/cancelConstraintsUpdate.js.map +0 -1
  511. package/dist/generated/instructions/closeSettledEscrow.d.ts +0 -72
  512. package/dist/generated/instructions/closeSettledEscrow.d.ts.map +0 -1
  513. package/dist/generated/instructions/closeSettledEscrow.js +0 -127
  514. package/dist/generated/instructions/closeSettledEscrow.js.map +0 -1
  515. package/dist/generated/instructions/createEscrow.d.ts +0 -131
  516. package/dist/generated/instructions/createEscrow.d.ts.map +0 -1
  517. package/dist/generated/instructions/createEscrow.js +0 -272
  518. package/dist/generated/instructions/createEscrow.js.map +0 -1
  519. package/dist/generated/instructions/createInstructionConstraints.d.ts +0 -68
  520. package/dist/generated/instructions/createInstructionConstraints.d.ts.map +0 -1
  521. package/dist/generated/instructions/createInstructionConstraints.js.map +0 -1
  522. package/dist/generated/instructions/extendPda.d.ts +0 -52
  523. package/dist/generated/instructions/extendPda.d.ts.map +0 -1
  524. package/dist/generated/instructions/extendPda.js +0 -86
  525. package/dist/generated/instructions/extendPda.js.map +0 -1
  526. package/dist/generated/instructions/queueCloseConstraints.d.ts +0 -66
  527. package/dist/generated/instructions/queueCloseConstraints.d.ts.map +0 -1
  528. package/dist/generated/instructions/queueCloseConstraints.js.map +0 -1
  529. package/dist/generated/instructions/queueConstraintsUpdate.d.ts +0 -75
  530. package/dist/generated/instructions/queueConstraintsUpdate.d.ts.map +0 -1
  531. package/dist/generated/instructions/queueConstraintsUpdate.js +0 -154
  532. package/dist/generated/instructions/queueConstraintsUpdate.js.map +0 -1
  533. package/dist/generated/instructions/refundEscrow.d.ts +0 -74
  534. package/dist/generated/instructions/refundEscrow.d.ts.map +0 -1
  535. package/dist/generated/instructions/refundEscrow.js +0 -142
  536. package/dist/generated/instructions/refundEscrow.js.map +0 -1
  537. package/dist/generated/instructions/settleEscrow.d.ts +0 -80
  538. package/dist/generated/instructions/settleEscrow.d.ts.map +0 -1
  539. package/dist/generated/instructions/settleEscrow.js +0 -173
  540. package/dist/generated/instructions/settleEscrow.js.map +0 -1
  541. package/dist/generated/types/accountConstraint.d.ts +0 -18
  542. package/dist/generated/types/accountConstraint.d.ts.map +0 -1
  543. package/dist/generated/types/accountConstraint.js +0 -24
  544. package/dist/generated/types/accountConstraint.js.map +0 -1
  545. package/dist/generated/types/accountConstraintZC.d.ts +0 -18
  546. package/dist/generated/types/accountConstraintZC.d.ts.map +0 -1
  547. package/dist/generated/types/accountConstraintZC.js +0 -26
  548. package/dist/generated/types/accountConstraintZC.js.map +0 -1
  549. package/dist/generated/types/closeConstraintsApplied.d.ts +0 -20
  550. package/dist/generated/types/closeConstraintsApplied.d.ts.map +0 -1
  551. package/dist/generated/types/closeConstraintsApplied.js +0 -24
  552. package/dist/generated/types/closeConstraintsApplied.js.map +0 -1
  553. package/dist/generated/types/closeConstraintsCancelled.d.ts +0 -16
  554. package/dist/generated/types/closeConstraintsCancelled.d.ts.map +0 -1
  555. package/dist/generated/types/closeConstraintsCancelled.js +0 -18
  556. package/dist/generated/types/closeConstraintsCancelled.js.map +0 -1
  557. package/dist/generated/types/closeConstraintsQueued.d.ts +0 -20
  558. package/dist/generated/types/closeConstraintsQueued.d.ts.map +0 -1
  559. package/dist/generated/types/closeConstraintsQueued.js +0 -24
  560. package/dist/generated/types/closeConstraintsQueued.js.map +0 -1
  561. package/dist/generated/types/constraintEntry.d.ts +0 -39
  562. package/dist/generated/types/constraintEntry.d.ts.map +0 -1
  563. package/dist/generated/types/constraintEntry.js +0 -31
  564. package/dist/generated/types/constraintEntry.js.map +0 -1
  565. package/dist/generated/types/constraintEntryZC.d.ts +0 -68
  566. package/dist/generated/types/constraintEntryZC.d.ts.map +0 -1
  567. package/dist/generated/types/constraintEntryZC.js +0 -49
  568. package/dist/generated/types/constraintEntryZC.js.map +0 -1
  569. package/dist/generated/types/constraintOperator.d.ts +0 -22
  570. package/dist/generated/types/constraintOperator.d.ts.map +0 -1
  571. package/dist/generated/types/constraintOperator.js +0 -28
  572. package/dist/generated/types/constraintOperator.js.map +0 -1
  573. package/dist/generated/types/constraintsChangeApplied.d.ts +0 -30
  574. package/dist/generated/types/constraintsChangeApplied.d.ts.map +0 -1
  575. package/dist/generated/types/constraintsChangeApplied.js +0 -32
  576. package/dist/generated/types/constraintsChangeApplied.js.map +0 -1
  577. package/dist/generated/types/constraintsChangeCancelled.d.ts +0 -16
  578. package/dist/generated/types/constraintsChangeCancelled.d.ts.map +0 -1
  579. package/dist/generated/types/constraintsChangeCancelled.js +0 -18
  580. package/dist/generated/types/constraintsChangeCancelled.js.map +0 -1
  581. package/dist/generated/types/constraintsChangeQueued.d.ts +0 -30
  582. package/dist/generated/types/constraintsChangeQueued.d.ts.map +0 -1
  583. package/dist/generated/types/constraintsChangeQueued.js +0 -32
  584. package/dist/generated/types/constraintsChangeQueued.js.map +0 -1
  585. package/dist/generated/types/dataConstraint.d.ts +0 -23
  586. package/dist/generated/types/dataConstraint.d.ts.map +0 -1
  587. package/dist/generated/types/dataConstraint.js +0 -27
  588. package/dist/generated/types/dataConstraint.js.map +0 -1
  589. package/dist/generated/types/dataConstraintZC.d.ts +0 -20
  590. package/dist/generated/types/dataConstraintZC.d.ts.map +0 -1
  591. package/dist/generated/types/dataConstraintZC.js +0 -30
  592. package/dist/generated/types/dataConstraintZC.js.map +0 -1
  593. package/dist/generated/types/discriminatorFormat.d.ts +0 -25
  594. package/dist/generated/types/discriminatorFormat.d.ts.map +0 -1
  595. package/dist/generated/types/discriminatorFormat.js +0 -31
  596. package/dist/generated/types/discriminatorFormat.js.map +0 -1
  597. package/dist/generated/types/escrowCreated.d.ts +0 -30
  598. package/dist/generated/types/escrowCreated.d.ts.map +0 -1
  599. package/dist/generated/types/escrowCreated.js +0 -34
  600. package/dist/generated/types/escrowCreated.js.map +0 -1
  601. package/dist/generated/types/escrowRefunded.d.ts +0 -26
  602. package/dist/generated/types/escrowRefunded.d.ts.map +0 -1
  603. package/dist/generated/types/escrowRefunded.js +0 -30
  604. package/dist/generated/types/escrowRefunded.js.map +0 -1
  605. package/dist/generated/types/escrowSettled.d.ts +0 -26
  606. package/dist/generated/types/escrowSettled.d.ts.map +0 -1
  607. package/dist/generated/types/escrowSettled.js +0 -30
  608. package/dist/generated/types/escrowSettled.js.map +0 -1
  609. package/dist/generated/types/escrowStatus.d.ts +0 -18
  610. package/dist/generated/types/escrowStatus.d.ts.map +0 -1
  611. package/dist/generated/types/escrowStatus.js +0 -24
  612. package/dist/generated/types/escrowStatus.js.map +0 -1
  613. package/dist/generated/types/instructionConstraintsCreated.d.ts +0 -34
  614. package/dist/generated/types/instructionConstraintsCreated.d.ts.map +0 -1
  615. package/dist/generated/types/instructionConstraintsCreated.js +0 -36
  616. package/dist/generated/types/instructionConstraintsCreated.js.map +0 -1
  617. package/dist/generated/types/pdaAllocated.d.ts +0 -24
  618. package/dist/generated/types/pdaAllocated.d.ts.map +0 -1
  619. package/dist/generated/types/pdaAllocated.js.map +0 -1
  620. package/dist/generated/types/pdaExtended.d.ts +0 -24
  621. package/dist/generated/types/pdaExtended.d.ts.map +0 -1
  622. package/dist/generated/types/pdaExtended.js +0 -28
  623. package/dist/generated/types/pdaExtended.js.map +0 -1
  624. package/dist/integrations/protocol-handler.d.ts +0 -59
  625. package/dist/integrations/protocol-handler.d.ts.map +0 -1
  626. package/dist/integrations/protocol-handler.js +0 -9
  627. package/dist/integrations/protocol-handler.js.map +0 -1
@@ -10,18 +10,26 @@ import { pipe, createTransactionMessage, setTransactionMessageFeePayer, setTrans
10
10
  import { getSetComputeUnitLimitInstruction, getSetComputeUnitPriceInstruction, } from "@solana-program/compute-budget";
11
11
  import { sendAndConfirmTransaction, getBlockhashCache, } from "../rpc-helpers.js";
12
12
  import { AccountRole } from "../kit-adapter.js";
13
- import { getAgentOverlayPDA, getPendingPolicyPDA, getPendingCloseConstraintsPDA, } from "../resolve-accounts.js";
13
+ import { getAgentOverlayPDA, getPendingPolicyPDA, getPolicyPDA, } from "../resolve-accounts.js";
14
14
  import { resolveVaultStateForOwner } from "../state-resolver.js";
15
15
  import { redactCause } from "../network-errors.js";
16
16
  import { SIGIL_PROGRAM_ADDRESS, MAX_ALLOWED_PROTOCOLS } from "../types.js";
17
+ import { fetchAgentVault } from "../generated/accounts/agentVault.js";
18
+ import { fetchPolicyConfig } from "../generated/accounts/policyConfig.js";
19
+ import { computePolicyPreviewDigest } from "../policy/compute-policy-preview-digest.js";
17
20
  // Phase 3: Simple mutations
18
- import { getFreezeVaultInstruction } from "../generated/instructions/freezeVault.js";
19
- import { getReactivateVaultInstruction } from "../generated/instructions/reactivateVault.js";
21
+ import { getFreezeVaultInstructionAsync } from "../generated/instructions/freezeVault.js";
22
+ import { getReactivateVaultInstructionAsync } from "../generated/instructions/reactivateVault.js";
23
+ import { getSetObserveOnlyInstructionAsync } from "../generated/instructions/setObserveOnly.js";
24
+ import { getQueueAgentGrantInstructionAsync } from "../generated/instructions/queueAgentGrant.js";
25
+ import { getApplyAgentGrantInstructionAsync } from "../generated/instructions/applyAgentGrant.js";
26
+ import { getCancelAgentGrantInstructionAsync } from "../generated/instructions/cancelAgentGrant.js";
20
27
  import { getCloseVaultInstructionAsync } from "../generated/instructions/closeVault.js";
21
- import { getPauseAgentInstruction } from "../generated/instructions/pauseAgent.js";
22
- import { getUnpauseAgentInstruction } from "../generated/instructions/unpauseAgent.js";
23
- import { getRevokeAgentInstruction } from "../generated/instructions/revokeAgent.js";
24
- import { getRegisterAgentInstruction } from "../generated/instructions/registerAgent.js";
28
+ import { enumerateExistingPendingPdasForClose } from "./close-vault.js";
29
+ import { getPauseAgentInstructionAsync } from "../generated/instructions/pauseAgent.js";
30
+ import { getUnpauseAgentInstructionAsync } from "../generated/instructions/unpauseAgent.js";
31
+ import { getRevokeAgentInstructionAsync } from "../generated/instructions/revokeAgent.js";
32
+ import { getRegisterAgentInstructionAsync } from "../generated/instructions/registerAgent.js";
25
33
  // Phase 4: Complex mutations
26
34
  import { getDepositFundsInstructionAsync } from "../generated/instructions/depositFunds.js";
27
35
  import { getWithdrawFundsInstructionAsync } from "../generated/instructions/withdrawFunds.js";
@@ -31,16 +39,119 @@ import { getCancelPendingPolicyInstructionAsync } from "../generated/instruction
31
39
  import { getQueueAgentPermissionsUpdateInstructionAsync } from "../generated/instructions/queueAgentPermissionsUpdate.js";
32
40
  import { getApplyAgentPermissionsUpdateInstructionAsync } from "../generated/instructions/applyAgentPermissionsUpdate.js";
33
41
  import { getCancelAgentPermissionsUpdateInstruction } from "../generated/instructions/cancelAgentPermissionsUpdate.js";
34
- import { getCreateInstructionConstraintsInstructionAsync } from "../generated/instructions/createInstructionConstraints.js";
35
- import { getQueueConstraintsUpdateInstructionAsync } from "../generated/instructions/queueConstraintsUpdate.js";
36
- import { getApplyConstraintsUpdateInstructionAsync } from "../generated/instructions/applyConstraintsUpdate.js";
37
- import { getCancelConstraintsUpdateInstructionAsync } from "../generated/instructions/cancelConstraintsUpdate.js";
38
- import { getQueueCloseConstraintsInstructionAsync } from "../generated/instructions/queueCloseConstraints.js";
39
- import { getApplyCloseConstraintsInstructionAsync } from "../generated/instructions/applyCloseConstraints.js";
40
- import { getCancelCloseConstraintsInstructionAsync } from "../generated/instructions/cancelCloseConstraints.js";
42
+ import { getCreatePostAssertionsInstructionAsync } from "../generated/instructions/createPostAssertions.js";
43
+ import { getClosePostAssertionsInstructionAsync } from "../generated/instructions/closePostAssertions.js";
44
+ // M-2 (pre-redeploy audit 2026-05-21): Phase 8 ownership-transfer ix builders.
45
+ // The on-chain handlers live at programs/sigil/src/instructions/
46
+ // {initiate,accept,cancel}_ownership_transfer.rs plus the Squads V4
47
+ // accept-multisig variant.
48
+ import { getInitiateOwnershipTransferInstructionAsync } from "../generated/instructions/initiateOwnershipTransfer.js";
49
+ import { getAcceptOwnershipTransferInstructionAsync } from "../generated/instructions/acceptOwnershipTransfer.js";
50
+ import { getAcceptOwnershipTransferMultisigInstructionAsync } from "../generated/instructions/acceptOwnershipTransferMultisig.js";
51
+ import { getCancelOwnershipTransferInstructionAsync } from "../generated/instructions/cancelOwnershipTransfer.js";
52
+ import { validatePostAssertionEntries } from "./post-assertion-validation.js";
41
53
  import { toDxError } from "./errors.js";
54
+ import { SigilSdkDomainError } from "../errors/sdk.js";
55
+ import { SIGIL_ERROR__SDK__MAINNET_CONFIRMATION_REQUIRED } from "../errors/codes.js";
42
56
  // ─── Shared Helper ───────────────────────────────────────────────────────────
43
57
  const CU_OWNER_ACTION = 200_000;
58
+ /**
59
+ * CH-3 (Security audit 2026-05-23 / Jordan): AL2 mainnet confirmation gate
60
+ * embedded inside the mutation builder so direct `mutations.*` imports
61
+ * cannot bypass it. The OwnerClient wrapper layer has its own gate
62
+ * (`OwnerClient.assertMainnetConfirmed`) which catches consumers using the
63
+ * class API — this in-mutation gate is the safety net for consumers who
64
+ * import the mutation function directly.
65
+ *
66
+ * Behavior is intentionally STRICTER than the OwnerClient gate. The
67
+ * OwnerClient gate honours a `requireMainnetConfirmation: false` opt-out
68
+ * via the class config; this mutation-level gate has no such config (a
69
+ * standalone function takes no client config), so on mainnet the caller
70
+ * MUST pass `mainnetConfirmed: true` or the call throws. Devnet ignores
71
+ * the gate entirely.
72
+ *
73
+ * Currently only `createPostAssertions` + `closePostAssertions` invoke
74
+ * this — they are the only standalone mutations whose OwnerClient
75
+ * wrapper is missing (the rest of the mutations are gated at the
76
+ * wrapper). Future standalone mutations should also call this helper.
77
+ *
78
+ * Single source of truth: per the audit finding, the mutation-level gate
79
+ * is the canonical enforcement point. The OwnerClient wrapper gate (when
80
+ * a wrapper exists) double-asserts the same contract; passing
81
+ * `mainnetConfirmed: true` satisfies both layers idempotently.
82
+ */
83
+ function assertMutationMainnetConfirmed(methodName, network, vault, opts) {
84
+ if (network !== "mainnet")
85
+ return;
86
+ if (opts?.mainnetConfirmed === true)
87
+ return;
88
+ throw new SigilSdkDomainError(SIGIL_ERROR__SDK__MAINNET_CONFIRMATION_REQUIRED, `mutations.${methodName} on mainnet requires \`mainnetConfirmed: true\` ` +
89
+ `in the per-call options. Direct imports of mutation builders do not ` +
90
+ `inherit OwnerClient's \`requireMainnetConfirmation\` opt-out — pass ` +
91
+ `\`mainnetConfirmed: true\` to acknowledge the destructive mainnet action. ` +
92
+ `Docs: https://github.com/Sigil-Trade/sigil/blob/main/sdk/kit/MIGRATION.md`, {
93
+ context: {
94
+ method: methodName,
95
+ network: "mainnet",
96
+ vault: vault.toString(),
97
+ },
98
+ });
99
+ }
100
+ /**
101
+ * PEN-CROSS-3 (Phase 2 close-up): compute the post-mutation
102
+ * policy_preview_digest for one of the 4 sibling handlers
103
+ * (create_instruction_constraints, apply_close_constraints,
104
+ * create_post_assertions, close_post_assertions).
105
+ *
106
+ * Reads the live PolicyConfig + AgentVault, applies the caller-specified
107
+ * flag override, then returns the canonical digest the on-chain handler
108
+ * will recompute and assert against. The owner signs this exact digest
109
+ * when calling the ix — defends against blind-sign by forcing explicit
110
+ * attestation of the flag flip.
111
+ */
112
+ async function siblingHandlerExpectedDigest(rpc, vault, override) {
113
+ const [policyAddress] = await getPolicyPDA(vault);
114
+ const [livePolicy, liveVault] = await Promise.all([
115
+ fetchPolicyConfig(rpc, policyAddress),
116
+ fetchAgentVault(rpc, vault),
117
+ ]);
118
+ return computePolicyPreviewDigest({
119
+ dailySpendingCapUsd: livePolicy.data.dailySpendingCapUsd,
120
+ maxTransactionSizeUsd: livePolicy.data.maxTransactionSizeUsd,
121
+ maxSlippageBps: livePolicy.data.maxSlippageBps,
122
+ developerFeeRate: livePolicy.data.developerFeeRate,
123
+ protocolMode: livePolicy.data.protocolMode,
124
+ protocols: livePolicy.data.protocols,
125
+ destinationMode: livePolicy.data.destinationMode,
126
+ allowedDestinations: livePolicy.data.allowedDestinations,
127
+ timelockDuration: livePolicy.data.timelockDuration,
128
+ sessionExpirySeconds: livePolicy.data.sessionExpirySeconds,
129
+ observeOnly: liveVault.data.observeOnly,
130
+ hasPostAssertions: override.hasPostAssertions !== undefined
131
+ ? override.hasPostAssertions
132
+ : livePolicy.data.hasPostAssertions,
133
+ createdAtSlot: livePolicy.data.createdAtSlot,
134
+ // TA-05 (Phase 3): operating_hours is policy-owned. Sibling handlers
135
+ // (constraints/post-assertions) never mutate it — pass through.
136
+ operatingHours: livePolicy.data.operatingHours,
137
+ // TA-07/17 (Phase 3): also pass-through from live policy.
138
+ autoPromoteGrays: livePolicy.data.autoPromoteGrays,
139
+ autoRevokeThreshold: livePolicy.data.autoRevokeThreshold,
140
+ // TA-12/14 (Phase 5): pass-through from live policy — sibling
141
+ // handlers (constraints / post-assertions flips) never mutate the
142
+ // post-execution invariant fields.
143
+ stableBalanceFloor: livePolicy.data.stableBalanceFloor,
144
+ perRecipientDailyCapUsd: livePolicy.data.perRecipientDailyCapUsd,
145
+ // G6 (audit 2026-05-18 cosign opt-in): pass-through from live policy.
146
+ // Sibling handlers never mutate cosign_required — the user changes
147
+ // this via `queue_policy_update` only.
148
+ cosignRequired: livePolicy.data.cosignRequired,
149
+ // D-5 (Bucket 2 audit 2026-05-21, F-RP3-1): pass-through from live
150
+ // policy. Position 22 of the canonical TA-19 digest. Sibling handlers
151
+ // never mutate this — owner sets via queue_policy_update only.
152
+ cosignSessionPubkey: livePolicy.data.cosignSessionPubkey,
153
+ });
154
+ }
44
155
  async function run(rpc, owner, network, instructions, opts = {}) {
45
156
  try {
46
157
  const cu = opts.computeUnits ?? CU_OWNER_ACTION;
@@ -125,11 +236,11 @@ async function derivePendingAgentPermsPDA(vault, agent) {
125
236
  // PHASE 3: Simple mutations
126
237
  // ═══════════════════════════════════════════════════════════════════════════════
127
238
  export async function freezeVault(rpc, vault, owner, network, opts) {
128
- const ix = getFreezeVaultInstruction({ owner, vault });
239
+ const ix = await getFreezeVaultInstructionAsync({ owner, vault });
129
240
  return run(rpc, owner, network, [ix], opts);
130
241
  }
131
242
  export async function resumeVault(rpc, vault, owner, network, newAgent, opts) {
132
- const ix = getReactivateVaultInstruction({
243
+ const ix = await getReactivateVaultInstructionAsync({
133
244
  owner,
134
245
  vault,
135
246
  newAgent: newAgent?.address ?? null,
@@ -137,6 +248,77 @@ export async function resumeVault(rpc, vault, owner, network, newAgent, opts) {
137
248
  });
138
249
  return run(rpc, owner, network, [ix], opts);
139
250
  }
251
+ /**
252
+ * Phase 8 alias for {@link resumeVault} matching the on-chain
253
+ * `reactivate_vault` instruction name. Prefer `reactivateVault` in new
254
+ * code; `resumeVault` is retained for backwards compatibility.
255
+ */
256
+ export async function reactivateVault(rpc, vault, owner, network, newAgent, opts) {
257
+ return resumeVault(rpc, vault, owner, network, newAgent, opts);
258
+ }
259
+ /**
260
+ * Phase 8 owner-side observe-only toggle. Setting `newValue: true` puts
261
+ * the vault into read-only mode (all `validate_and_authorize` calls reject
262
+ * with `ErrObserveOnlyEnabled`). Setting `newValue: false` resumes
263
+ * spending. Bumps `policy_version` so concurrent validate_and_authorize
264
+ * calls fail fast with `PolicyVersionMismatch`.
265
+ */
266
+ export async function setObserveOnly(rpc, vault, owner, network, newValue, opts) {
267
+ const ix = await getSetObserveOnlyInstructionAsync({
268
+ vault,
269
+ owner,
270
+ newValue,
271
+ });
272
+ return run(rpc, owner, network, [ix], opts);
273
+ }
274
+ /**
275
+ * Phase 8 owner-side queue of a new agent capability grant. The grant
276
+ * becomes effective after `apply_agent_grant` is called (subject to the
277
+ * cosign_required gate if enabled on the policy).
278
+ *
279
+ * `capability` is the on-chain `AgentCapability` discriminant:
280
+ * - 0 = READ_ONLY
281
+ * - 1 = OPERATOR
282
+ * - 2 = FULL
283
+ * `spendingLimitUsd` is in 6-decimal USDC units (e.g. `$500 = 500_000_000n`).
284
+ */
285
+ export async function queueAgentGrant(rpc, vault, owner, network, agent, capability, spendingLimitUsd, opts) {
286
+ const ix = await getQueueAgentGrantInstructionAsync({
287
+ owner,
288
+ vault,
289
+ agent,
290
+ capability,
291
+ spendingLimitUsd,
292
+ });
293
+ return run(rpc, owner, network, [ix], opts);
294
+ }
295
+ /**
296
+ * Phase 8 owner-side apply of a previously-queued agent capability grant.
297
+ * The grant must have been queued via {@link queueAgentGrant}; the apply
298
+ * handler verifies the PendingAgentGrant PDA exists and that any cosign
299
+ * requirement on the policy has been satisfied (or that the grant lowers
300
+ * — not raises — privilege so cosign is bypassable per F-AT-1).
301
+ */
302
+ export async function applyAgentGrant(rpc, vault, owner, network, opts) {
303
+ const [agentSpendOverlay] = await getAgentOverlayPDA(vault);
304
+ const ix = await getApplyAgentGrantInstructionAsync({
305
+ owner,
306
+ vault,
307
+ agentSpendOverlay,
308
+ });
309
+ return run(rpc, owner, network, [ix], opts);
310
+ }
311
+ /**
312
+ * Phase 8 owner-side cancel of a previously-queued agent capability
313
+ * grant. Closes the PendingAgentGrant PDA and returns rent to the owner.
314
+ */
315
+ export async function cancelAgentGrant(rpc, vault, owner, network, opts) {
316
+ const ix = await getCancelAgentGrantInstructionAsync({
317
+ owner,
318
+ vault,
319
+ });
320
+ return run(rpc, owner, network, [ix], opts);
321
+ }
140
322
  /**
141
323
  * Permanently closes vault and reclaims rent.
142
324
  *
@@ -163,13 +345,8 @@ export async function closeVault(rpc, vault, owner, network, opts) {
163
345
  const [pendingPolicyPda] = await getPendingPolicyPDA(vault);
164
346
  const agents = vaultData.agents || [];
165
347
  const agentPdaDerivations = await Promise.all(agents.map((agent) => derivePendingAgentPermsPDA(vault, agent.pubkey)));
166
- const [pendingCloseConstraintsPda] = await getPendingCloseConstraintsPDA(vault);
167
348
  // Check all PDAs in parallel (E4 fix — batch instead of sequential)
168
- const allPdas = [
169
- pendingPolicyPda,
170
- ...agentPdaDerivations,
171
- pendingCloseConstraintsPda,
172
- ];
349
+ const allPdas = [pendingPolicyPda, ...agentPdaDerivations];
173
350
  const existenceChecks = await Promise.all(allPdas.map(async (pda) => {
174
351
  try {
175
352
  const info = await rpc
@@ -204,13 +381,31 @@ export async function closeVault(rpc, vault, owner, network, opts) {
204
381
  });
205
382
  }
206
383
  }
207
- // 3. pending_close_constraints (if exists) E1 fix: correct seed "pending_close_constraints"
208
- const constraintsIdx = 1 + agents.length;
209
- if (existenceChecks[constraintsIdx]) {
210
- remainingAccounts.push({
211
- address: existenceChecks[constraintsIdx],
212
- role: AccountRole.WRITABLE,
213
- });
384
+ // 3-4. SFH-01 close: enumerate pending_owner + pending_agent_grant via the
385
+ // dedicated helper. Without these, the on-chain drain blocks for
386
+ // pending_owner + pending_agent_grant silently no-op via the
387
+ // `lamports() > 0` guard, orphaning their rent. Helper performs parallel
388
+ // getAccountInfo and only includes accounts that exist.
389
+ // (M1-04b: pending_close_constraints + pending_constraints drains removed.)
390
+ //
391
+ // HH-1 close (audit 2026-05-23 §RP): the helper's silent-failure on RPC
392
+ // errors is now escalated to ERROR-level log with vault context. If a
393
+ // transient RPC failure during enumeration kept a PDA out of
394
+ // remainingAccounts, the on-chain drain falls through silently and rent
395
+ // is permanently orphaned. The ERROR-level log surfaces this to off-chain
396
+ // monitors / alerting; the close TX still proceeds (best-effort drain
397
+ // semantic preserved).
398
+ let ch2EnumerationHadRpcError = false;
399
+ const ch2PendingAccounts = await enumerateExistingPendingPdasForClose(rpc, vault, undefined, (kind, address, cause) => {
400
+ ch2EnumerationHadRpcError = true;
401
+ const c = redactCause(cause);
402
+ getSigilModuleLogger().error(`[closeVault] HH-1: RPC enumeration failed for ${kind} ${address} on vault ${vault} — close TX will proceed without it; rent for that PDA WILL stay orphaned if the PDA exists on-chain. Cause: ${c.message ?? c.name ?? c.code ?? "unknown"}`);
403
+ });
404
+ if (ch2EnumerationHadRpcError) {
405
+ getSigilModuleLogger().error(`[closeVault] HH-1: at least one pending-PDA enumeration RPC failed for vault ${vault} — verify rent reclamation via on-chain audit before considering close complete.`);
406
+ }
407
+ for (const pa of ch2PendingAccounts) {
408
+ remainingAccounts.push({ address: pa.address, role: pa.role });
214
409
  }
215
410
  // Append remaining accounts to instruction if any exist
216
411
  const finalIx = remainingAccounts.length > 0
@@ -234,14 +429,24 @@ export async function closeVault(rpc, vault, owner, network, opts) {
234
429
  // decision (9-1 vote, 2026-04-19). See Plans/we-need-to-plan-serialized-summit.md.
235
430
  export async function pauseAgent(rpc, vault, owner, network, agent, opts) {
236
431
  requireValidAddress(agent, "Agent address");
237
- const ix = getPauseAgentInstruction({ owner, vault, agentToPause: agent });
432
+ // PEN-CROSS-5 (Phase 4 absorption): policy now required for policy_version bump.
433
+ const [policyPda] = await getPolicyPDA(vault);
434
+ const ix = await getPauseAgentInstructionAsync({
435
+ owner,
436
+ vault,
437
+ policy: policyPda,
438
+ agentToPause: agent,
439
+ });
238
440
  return run(rpc, owner, network, [ix], opts);
239
441
  }
240
442
  export async function unpauseAgent(rpc, vault, owner, network, agent, opts) {
241
443
  requireValidAddress(agent, "Agent address");
242
- const ix = getUnpauseAgentInstruction({
444
+ // PEN-CROSS-5 (Phase 4 absorption): policy now required for policy_version bump.
445
+ const [policyPda] = await getPolicyPDA(vault);
446
+ const ix = await getUnpauseAgentInstructionAsync({
243
447
  owner,
244
448
  vault,
449
+ policy: policyPda,
245
450
  agentToUnpause: agent,
246
451
  });
247
452
  return run(rpc, owner, network, [ix], opts);
@@ -249,9 +454,12 @@ export async function unpauseAgent(rpc, vault, owner, network, agent, opts) {
249
454
  export async function revokeAgent(rpc, vault, owner, network, agent, opts) {
250
455
  requireValidAddress(agent, "Agent address");
251
456
  const [overlayPda] = await getAgentOverlayPDA(vault, 0);
252
- const ix = getRevokeAgentInstruction({
457
+ // PEN-CROSS-5 (Phase 4 absorption): policy now required for policy_version bump.
458
+ const [policyPda] = await getPolicyPDA(vault);
459
+ const ix = await getRevokeAgentInstructionAsync({
253
460
  owner,
254
461
  vault,
462
+ policy: policyPda,
255
463
  agentSpendOverlay: overlayPda,
256
464
  agentToRemove: agent,
257
465
  });
@@ -261,9 +469,12 @@ export async function addAgent(rpc, vault, owner, network, agent, permissions, s
261
469
  requireValidAddress(agent, "Agent address");
262
470
  requireValidPermissions(permissions);
263
471
  const [overlayPda] = await getAgentOverlayPDA(vault, 0);
264
- const ix = getRegisterAgentInstruction({
472
+ // PEN-CROSS-5 (Phase 4 absorption): policy now required for policy_version bump.
473
+ const [policyPda] = await getPolicyPDA(vault);
474
+ const ix = await getRegisterAgentInstructionAsync({
265
475
  owner,
266
476
  vault,
477
+ policy: policyPda,
267
478
  agentSpendOverlay: overlayPda,
268
479
  agent,
269
480
  capability: Number(permissions),
@@ -311,7 +522,7 @@ export async function withdraw(rpc, vault, owner, network, mint, amount, opts) {
311
522
  * - `allowedDestinations.length` (MAX_ALLOWED_DESTINATIONS on-chain)
312
523
  * - `protocolCaps.length` must equal `approvedApps.length` when has_protocol_caps
313
524
  * - `maxSlippageBps` <= MAX_SLIPPAGE_BPS on-chain
314
- * - `sessionExpirySlots` range (10..=450 when > 0)
525
+ * - `sessionExpirySeconds` range (5..=90 when > 0; audit F5-H1)
315
526
  */
316
527
  export async function queuePolicyUpdate(rpc, vault, owner, network, changes, opts) {
317
528
  if (Object.keys(changes).length === 0) {
@@ -331,23 +542,131 @@ export async function queuePolicyUpdate(rpc, vault, owner, network, changes, opt
331
542
  changes.approvedApps.length > MAX_ALLOWED_PROTOCOLS) {
332
543
  throw toDxError(new Error(`approvedApps length exceeds on-chain MAX_ALLOWED_PROTOCOLS (${MAX_ALLOWED_PROTOCOLS}). Got ${changes.approvedApps.length}. On-chain rejects TooManyAllowedProtocols.`));
333
544
  }
545
+ // Phase 2 TA-19: fetch live policy + vault state to compute the digest of
546
+ // the merged-effective policy that WILL result if this update is applied.
547
+ // The on-chain handler re-asserts the same digest at queue time, so any
548
+ // owner blind-sign that diverges from the SDK-projected update is rejected.
549
+ const [policyPda] = await getPolicyPDA(vault);
550
+ const livePolicy = await fetchPolicyConfig(rpc, policyPda);
551
+ const liveVault = await fetchAgentVault(rpc, vault);
552
+ const newProtocolMode = changes.protocolMode
553
+ ? mapProtocolMode(changes.protocolMode)
554
+ : null;
555
+ const effProtocolMode = newProtocolMode ?? livePolicy.data.protocolMode;
556
+ const effProtocols = changes.approvedApps ?? livePolicy.data.protocols;
557
+ const effDestinationMode = changes.destinationMode ?? livePolicy.data.destinationMode;
558
+ const effDestinations = changes.allowedDestinations ?? livePolicy.data.allowedDestinations;
559
+ const effDaily = changes.dailyCap ?? livePolicy.data.dailySpendingCapUsd;
560
+ const effMaxTx = changes.maxPerTrade ?? livePolicy.data.maxTransactionSizeUsd;
561
+ const effMaxSlip = changes.maxSlippageBps ?? livePolicy.data.maxSlippageBps;
562
+ // PEN-CROSS-6: developer_fee_rate is now part of the digest. Project the
563
+ // merged-effective value the same way as other Option<…> fields.
564
+ const effDeveloperFeeRate = changes.developerFeeRate ?? livePolicy.data.developerFeeRate;
565
+ const effTimelock = changes.timelock != null
566
+ ? BigInt(changes.timelock)
567
+ : livePolicy.data.timelockDuration;
568
+ const effSessionExpiry = changes.sessionExpirySeconds ?? livePolicy.data.sessionExpirySeconds;
569
+ const newPolicyPreviewDigest = computePolicyPreviewDigest({
570
+ dailySpendingCapUsd: effDaily,
571
+ maxTransactionSizeUsd: effMaxTx,
572
+ maxSlippageBps: effMaxSlip,
573
+ developerFeeRate: effDeveloperFeeRate,
574
+ protocolMode: effProtocolMode,
575
+ protocols: effProtocols,
576
+ destinationMode: effDestinationMode,
577
+ allowedDestinations: effDestinations,
578
+ timelockDuration: effTimelock,
579
+ sessionExpirySeconds: effSessionExpiry,
580
+ observeOnly: liveVault.data.observeOnly,
581
+ hasPostAssertions: livePolicy.data.hasPostAssertions,
582
+ // PEN-CROSS-2: created_at_slot is immutable post-init — read from live.
583
+ createdAtSlot: livePolicy.data.createdAtSlot,
584
+ // TA-05 (Phase 3): operating_hours is policy-owned and bound by TA-19.
585
+ // queueAgentPermissions does not currently mutate it through the
586
+ // dashboard mutation surface — read from live policy.
587
+ operatingHours: livePolicy.data.operatingHours,
588
+ // TA-07/17 (Phase 3): same — not mutated by this dashboard surface.
589
+ autoPromoteGrays: livePolicy.data.autoPromoteGrays,
590
+ autoRevokeThreshold: livePolicy.data.autoRevokeThreshold,
591
+ // TA-12/14 (Phase 5): post-exec invariants. Not mutated by this surface;
592
+ // pass-through from live policy. Mutating them is elevated per TA-09.
593
+ stableBalanceFloor: livePolicy.data.stableBalanceFloor,
594
+ perRecipientDailyCapUsd: livePolicy.data.perRecipientDailyCapUsd,
595
+ // G6 (audit 2026-05-18 cosign opt-in): pass-through from live policy.
596
+ // The non-elevated dashboard surface does NOT mutate cosign_required;
597
+ // owners change cosign opt-in via a separate elevated workflow that
598
+ // includes the cosign signer (or, for false→true direction, can also
599
+ // be done non-elevated by passing the override directly through the
600
+ // ix arg below — but this dashboard helper keeps the policy stable
601
+ // for the default path).
602
+ cosignRequired: livePolicy.data.cosignRequired,
603
+ // F-Q6 (2026-06-02): operator_grant_delay not mutated by this dashboard
604
+ // surface — pass-through from live policy so the digest matches the
605
+ // on-chain merged (eff) value at canonical position 22.
606
+ operatorGrantDelaySeconds: livePolicy.data.operatorGrantDelaySeconds,
607
+ });
334
608
  const ix = await getQueuePolicyUpdateInstructionAsync({
335
609
  owner,
336
610
  vault,
337
611
  dailySpendingCapUsd: changes.dailyCap ?? null,
338
612
  maxTransactionAmountUsd: changes.maxPerTrade ?? null,
339
- protocolMode: changes.protocolMode
340
- ? mapProtocolMode(changes.protocolMode)
341
- : null,
613
+ protocolMode: newProtocolMode,
342
614
  protocols: changes.approvedApps ?? null,
343
- maxLeverageBps: changes.leverageLimit ?? null,
344
615
  developerFeeRate: changes.developerFeeRate ?? null,
345
616
  maxSlippageBps: changes.maxSlippageBps ?? null,
346
617
  timelockDuration: changes.timelock != null ? BigInt(changes.timelock) : null,
347
618
  allowedDestinations: changes.allowedDestinations ?? null,
348
- sessionExpirySlots: changes.sessionExpirySlots ?? null,
619
+ sessionExpirySeconds: changes.sessionExpirySeconds ?? null,
349
620
  hasProtocolCaps: changes.hasProtocolCaps ?? null,
350
621
  protocolCaps: changes.protocolCaps ?? null,
622
+ destinationMode: changes.destinationMode ?? null,
623
+ // TA-05 (Phase 3): operating_hours is not mutated by this mutation
624
+ // surface — pass null to fall through to live policy at on-chain merge.
625
+ operatingHours: null,
626
+ // TA-12/14 (Phase 5): not mutated by this non-elevated surface — pass
627
+ // null to fall through to live policy. Elevated mutations (lowering
628
+ // floor, raising per-recipient cap) require cosign and the
629
+ // `queuePolicyElevated()` helper.
630
+ stableBalanceFloor: null,
631
+ perRecipientDailyCapUsd: null,
632
+ // G6 (audit 2026-05-18 cosign opt-in): not mutated by this non-
633
+ // elevated surface — pass null to fall through to live policy.
634
+ // Toggling cosign on/off goes through a dedicated path that is
635
+ // aware of the one-way-ratchet semantics (true→false requires
636
+ // cosign; false→true does not).
637
+ cosignRequired: null,
638
+ // D-5 (Bucket 2 audit 2026-05-21, F-RP3-1): not mutated by this
639
+ // non-elevated surface — pass null to keep live policy value. Owner
640
+ // sets cosign_session_pubkey via a dedicated elevated helper that
641
+ // verifies the new pubkey isn't a Sigil-protected PDA at queue time.
642
+ cosignSessionPubkey: null,
643
+ // F-Q6 (2026-06-02): not mutated by this dashboard surface — pass null
644
+ // (falls through to live policy at on-chain merge). Configurability is
645
+ // available via the raw codama builder + owner paths.
646
+ operatorGrantDelaySeconds: null,
647
+ // TA-09 (Phase 3): non-elevated path by default — pass the
648
+ // System Program / zero-pubkey ("11111111111111111111111111111111").
649
+ // Elevated mutations through this dashboard surface require a
650
+ // follow-on `queuePolicyElevated()` helper (cosign-helper.ts, G4).
651
+ //
652
+ // CANONICAL `cosign_session` ARG CONTRACT (Round 2 §RP-2 B4 F-3,
653
+ // 2026-05-19) — for non-Codama callers reading this file as a
654
+ // reference impl:
655
+ // - Non-elevated queue (this branch): pass `Pubkey::default()`
656
+ // and OMIT any cosigner from `remaining_accounts`.
657
+ // - Elevated queue (raising daily_cap, expanding destinations /
658
+ // protocols, lowering stable_balance_floor, raising
659
+ // per_recipient_daily_cap_usd, disabling protocol_caps, mutating
660
+ // protocol_caps entries, or disabling cosign): pass a REAL session
661
+ // pubkey + include it in `remaining_accounts` with
662
+ // `is_signer == true`. Build the bundle via
663
+ // `buildCosignBundle()` in `sdk/kit/src/cosign-helper.ts`.
664
+ // - Reject path: a non-default `cosign_session` on a non-elevated
665
+ // queue surfaces `InvalidPermissions` (6088). INTENTIONAL — the
666
+ // on-chain handler refuses to silently downgrade a caller's
667
+ // declared intent (Option A behaviour).
668
+ cosignSession: "11111111111111111111111111111111",
669
+ newPolicyPreviewDigest,
351
670
  });
352
671
  return run(rpc, owner, network, [ix], opts);
353
672
  }
@@ -359,7 +678,11 @@ export async function cancelPendingPolicy(rpc, vault, owner, network, opts) {
359
678
  const ix = await getCancelPendingPolicyInstructionAsync({ owner, vault });
360
679
  return run(rpc, owner, network, [ix], opts);
361
680
  }
362
- export async function queueAgentPermissions(rpc, vault, owner, network, agent, permissions, spendingLimit, opts) {
681
+ export async function queueAgentPermissions(rpc, vault, owner, network, agent, permissions, spendingLimit, opts,
682
+ // TA-06 (Phase 3): per-agent cooldown_seconds. 0 = disabled. Optional so
683
+ // existing dashboard callers continue compiling; pass non-zero when
684
+ // configuring agents that need pacing.
685
+ cooldownSeconds = 0n) {
363
686
  requireValidAddress(agent, "Agent address");
364
687
  requireValidPermissions(permissions);
365
688
  const ix = await getQueueAgentPermissionsUpdateInstructionAsync({
@@ -368,6 +691,29 @@ export async function queueAgentPermissions(rpc, vault, owner, network, agent, p
368
691
  agent,
369
692
  newCapability: Number(permissions),
370
693
  spendingLimitUsd: spendingLimit,
694
+ cooldownSeconds,
695
+ // Round 2 F-RP3-2 fix (audit 2026-05-19): non-elevated path default —
696
+ // System Program / zero-pubkey. The on-chain handler's elevated gate
697
+ // requires a non-default `cosign_session` only when the mutation
698
+ // raises capability, raises spending_limit, OR sets a non-zero
699
+ // cooldown AND `policy.cosign_required == true`. Callers who need
700
+ // the elevated path should use a dedicated wrapper that injects a
701
+ // real cosign-session pubkey + remaining_accounts signer (analogous
702
+ // to `queuePolicyElevated()` for queue_policy_update).
703
+ //
704
+ // CANONICAL `cosign_session` ARG CONTRACT (Round 2 §RP-2 B4 F-3,
705
+ // 2026-05-19) — same shape as the `queuePolicyUpdate` path above:
706
+ // - Non-elevated (this branch): pass `Pubkey::default()` and
707
+ // OMIT the cosigner from `remaining_accounts`.
708
+ // - Elevated (raising capability, raising spending_limit, or
709
+ // setting non-zero cooldown on a `cosign_required: true` vault):
710
+ // pass a REAL session pubkey + include it as a signer in
711
+ // `remaining_accounts`.
712
+ // - Reject path: passing a non-default `cosign_session` on a
713
+ // non-elevated queue surfaces `InvalidPermissions` (6088).
714
+ // INTENTIONAL — the on-chain handler refuses to silently
715
+ // downgrade a caller's declared intent (Option A behaviour).
716
+ cosignSession: "11111111111111111111111111111111",
371
717
  });
372
718
  return run(rpc, owner, network, [ix], opts);
373
719
  }
@@ -393,46 +739,218 @@ export async function cancelAgentPermissions(rpc, vault, owner, network, agent,
393
739
  });
394
740
  return run(rpc, owner, network, [ix], opts);
395
741
  }
396
- export async function createConstraints(rpc, vault, owner, network, entries, opts) {
397
- if (!entries || entries.length === 0)
398
- throw toDxError(new Error("Constraint entries must be a non-empty array"));
399
- const ix = await getCreateInstructionConstraintsInstructionAsync({
742
+ // ─── Post-execution assertions (Phase 2) ─────────────────────────────────────
743
+ // Composes with pre-execution InstructionConstraints — NOT a replacement.
744
+ //
745
+ // Pre-execution (createConstraints above): validates instruction args BEFORE
746
+ // the DeFi call runs. Fails closed on disallowed instructions.
747
+ //
748
+ // Post-execution (createPostAssertions below): snapshots account bytes before
749
+ // finalize_session, compares against the on-chain PostExecutionAssertions PDA
750
+ // after the DeFi call completes, reverts the whole tx on mismatch. Used for
751
+ // leverage caps (CrossFieldLte) and similar "state-after-is-bounded" checks.
752
+ //
753
+ // Both wrappers auto-derive their respective PDAs — callers pass only the
754
+ // vault. Validation runs client-side so the caller never burns a round-trip
755
+ // on an entry the on-chain validate_entries would reject. See
756
+ // `post-assertion-validation.ts` and Phase 2 PRD ISC-6..9.
757
+ /**
758
+ * Create the PostExecutionAssertions PDA for a vault and write the entries.
759
+ *
760
+ * Every entry is validated client-side first (see `validatePostAssertionEntries`).
761
+ * A mid-batch rejection throws a DxError with a message pointing at the
762
+ * offending index; the transaction is never built.
763
+ *
764
+ * Idempotency: calling this twice on the same vault without an intervening
765
+ * close returns an Anchor `AccountAlreadyExists` (3010) — Anchor's `init`
766
+ * constraint enforces this at the program boundary. Phase 2 ISC-45.
767
+ *
768
+ * Rent: destination on close is the vault's owner (Anchor `close = owner`
769
+ * on the account), so `closePostAssertions` refunds to the owner signer.
770
+ *
771
+ * @param rpc RPC client for blockhash resolution + tx submission.
772
+ * @param vault Vault PDA this assertions set belongs to.
773
+ * @param owner Owner signer — must match the vault's `owner` field.
774
+ * @param network Cluster selector (devnet / mainnet).
775
+ * @param entries 1..=4 PostAssertionEntry values. Validated before send.
776
+ * @param opts Optional TxOpts (compute budget, priority fee).
777
+ * @returns TxResult with the confirmed signature.
778
+ */
779
+ export async function createPostAssertions(rpc, vault, owner, network, entries, opts) {
780
+ // Client-side check mirrors on-chain validate_entries. Throws
781
+ // PostAssertionValidationError, which is structurally a DxError (numeric
782
+ // `code`, `message`, `recovery: string[]`) AND carries the typed
783
+ // `validationCode` + `entryIndex` for FE branching. We intentionally do
784
+ // NOT wrap via toDxError — that would collapse the typed fields into
785
+ // DX_ERROR_CODE_UNMAPPED (7999) and break ISC-19's "pinpoint the bad
786
+ // entry" promise. See post-assertion-validation.ts docblock.
787
+ validatePostAssertionEntries(entries);
788
+ // CH-3 (audit 2026-05-23): AL2 gate AFTER client-side validation so the
789
+ // caller learns about entry-shape mistakes (the cheap, fixable error)
790
+ // before they're forced to think about mainnet acknowledgement (the
791
+ // ceremonial gate). Order matches the OwnerClient pattern of running
792
+ // local validation before destructive-action confirmation.
793
+ assertMutationMainnetConfirmed("createPostAssertions", network, vault, opts);
794
+ // PEN-CROSS-3: bind the post-mutation digest (`has_post_assertions=1`).
795
+ const expectedDigest = await siblingHandlerExpectedDigest(rpc, vault, {
796
+ hasPostAssertions: 1,
797
+ });
798
+ const ix = await getCreatePostAssertionsInstructionAsync({
400
799
  owner,
401
800
  vault,
402
801
  entries,
403
- strictMode: opts?.strictMode ?? true,
802
+ expectedDigest,
404
803
  });
405
804
  return run(rpc, owner, network, [ix], opts);
406
805
  }
407
- export async function queueConstraintsUpdate(rpc, vault, owner, network, entries, opts) {
408
- if (!entries || entries.length === 0)
409
- throw toDxError(new Error("Constraint entries must be a non-empty array"));
410
- const ix = await getQueueConstraintsUpdateInstructionAsync({
806
+ /**
807
+ * Close the PostExecutionAssertions PDA for a vault. Rent refunds to owner.
808
+ *
809
+ * No-op if the PDA does not exist — Anchor's `close` attribute will reject
810
+ * the instruction with `AccountNotInitialized` if there's nothing to close;
811
+ * the DxError surface communicates this cleanly.
812
+ *
813
+ * After close, `has_post_assertions` on PolicyConfig flips 0 and
814
+ * finalize_session skips the post-assertion scan on future agent txs.
815
+ *
816
+ * @param rpc RPC client for blockhash resolution + tx submission.
817
+ * @param vault Vault PDA whose assertions set should be closed.
818
+ * @param owner Owner signer — receives the rent refund.
819
+ * @param network Cluster selector.
820
+ * @param opts Optional TxOpts.
821
+ * @returns TxResult with the confirmed signature.
822
+ */
823
+ export async function closePostAssertions(rpc, vault, owner, network, opts) {
824
+ // CH-3 (audit 2026-05-23): AL2 gate. `closePostAssertions` has no
825
+ // client-side validation step (no entries arg), so the gate runs first.
826
+ assertMutationMainnetConfirmed("closePostAssertions", network, vault, opts);
827
+ // PEN-CROSS-3: bind the post-mutation digest (`has_post_assertions=0`).
828
+ const expectedDigest = await siblingHandlerExpectedDigest(rpc, vault, {
829
+ hasPostAssertions: 0,
830
+ });
831
+ const ix = await getClosePostAssertionsInstructionAsync({
411
832
  owner,
412
833
  vault,
413
- entries,
414
- strictMode: opts?.strictMode ?? true,
834
+ expectedDigest,
415
835
  });
416
836
  return run(rpc, owner, network, [ix], opts);
417
837
  }
418
- export async function applyConstraintsUpdate(rpc, vault, owner, network, opts) {
419
- const ix = await getApplyConstraintsUpdateInstructionAsync({ owner, vault });
420
- return run(rpc, owner, network, [ix], opts);
421
- }
422
- export async function cancelConstraintsUpdate(rpc, vault, owner, network, opts) {
423
- const ix = await getCancelConstraintsUpdateInstructionAsync({ owner, vault });
838
+ // ═══════════════════════════════════════════════════════════════════════════════
839
+ // M-2 (pre-redeploy audit 2026-05-21): Phase 8 ownership-transfer mutations.
840
+ //
841
+ // On-chain reference: programs/sigil/src/instructions/
842
+ // - initiate_ownership_transfer.rs (owner queues transfer + 48h timelock)
843
+ // - accept_ownership_transfer.rs (new wallet-owner finalises after timelock)
844
+ // - accept_ownership_transfer_multisig.rs (Squads V4 PDA accepts via CPI)
845
+ // - cancel_ownership_transfer.rs (current owner aborts during timelock)
846
+ //
847
+ // Cosign gate: when `policy.cosign_required = true`, `queue_policy_update`
848
+ // AND `initiate_ownership_transfer` BOTH require a non-owner co-signer in
849
+ // `remaining_accounts` (D4 symmetric cosign gate). The mutations below
850
+ // expose the `cosignSession` parameter; pass `undefined` when the policy
851
+ // does not require cosign.
852
+ //
853
+ // LBL-01: all four ix derive vault state by reading
854
+ // `vault.vault_authority` (immutable) — the on-chain accept handler
855
+ // overwrites `vault.owner` but the PDA address stays put.
856
+ // ═══════════════════════════════════════════════════════════════════════════════
857
+ /**
858
+ * Queue an ownership transfer for `vault`. The pending PDA carries the
859
+ * target `newOwner` plus the configured timelock (default 48h). The
860
+ * transfer is finalised only by a follow-up `acceptOwnershipTransfer`
861
+ * (wallet) or `acceptOwnershipTransferMultisig` (Squads V4).
862
+ *
863
+ * @param newOwner The pubkey that will become `vault.owner` after
864
+ * accept. MUST NOT be a system program / sysvar
865
+ * (rejected on-chain by `ErrInvalidOwnershipTarget`).
866
+ * @param isMultisigTarget Set to `true` when `newOwner` is a Squads V4
867
+ * multisig PDA — the on-chain handler enforces
868
+ * that the matching accept variant is used.
869
+ *
870
+ * Cosign behaviour: when `policy.cosign_required = true`, the on-chain
871
+ * handler enforces a non-owner co-signer; pass the cosign session pubkey
872
+ * via the SDK's transaction-signing layer when building the tx. Pre-G6
873
+ * (audit 2026-05-18) policies without cosign opt-in succeed without one.
874
+ *
875
+ * Replays the H-3 "no double-initiate" rule: a second initiate without
876
+ * an intervening `cancelOwnershipTransfer` fails with
877
+ * `ErrPendingOwnershipExists` (6103).
878
+ */
879
+ export async function initiateOwnershipTransfer(rpc, vault, owner, network, newOwner, isMultisigTarget, opts) {
880
+ const ix = await getInitiateOwnershipTransferInstructionAsync({
881
+ owner,
882
+ vault,
883
+ newOwner,
884
+ isMultisigTarget,
885
+ });
424
886
  return run(rpc, owner, network, [ix], opts);
425
887
  }
426
- export async function queueCloseConstraints(rpc, vault, owner, network, opts) {
427
- const ix = await getQueueCloseConstraintsInstructionAsync({ owner, vault });
428
- return run(rpc, owner, network, [ix], opts);
888
+ /**
889
+ * Finalise a previously-initiated ownership transfer when the incoming
890
+ * owner is a wallet (keypair) signer. The new owner MUST be the signer
891
+ * of the enclosing transaction; the on-chain handler verifies their key
892
+ * matches `pending.new_owner`.
893
+ *
894
+ * Timelock: the transfer is only accepted after the configured timelock
895
+ * has elapsed (default 48h). Calls before the window expires fail with
896
+ * `ErrPendingOwnershipNotReady` (6104).
897
+ *
898
+ * Note: the `owner` argument on this function is the NEW owner who
899
+ * accepts — kept as `owner` for parity with the rest of the mutations
900
+ * surface, but semantically `newOwner.address` is what lands on-chain
901
+ * as `vault.owner`. `vault.vault_authority` (the immutable PDA seed)
902
+ * is unchanged by this ix.
903
+ */
904
+ export async function acceptOwnershipTransfer(rpc, vault, newOwner, network, opts) {
905
+ const ix = await getAcceptOwnershipTransferInstructionAsync({
906
+ newOwner,
907
+ vault,
908
+ });
909
+ return run(rpc, newOwner, network, [ix], opts);
429
910
  }
430
- export async function applyCloseConstraints(rpc, vault, owner, network, opts) {
431
- const ix = await getApplyCloseConstraintsInstructionAsync({ owner, vault });
432
- return run(rpc, owner, network, [ix], opts);
911
+ /**
912
+ * Finalise a previously-initiated ownership transfer when the incoming
913
+ * owner is a Squads V4 multisig PDA (NOT a wallet signer). The Squads
914
+ * program is the CPI caller; the multisig PDA itself has no private key.
915
+ *
916
+ * The on-chain handler verifies:
917
+ * 1. `multisig_pda.owner == SQUADS_V4_PROGRAM_ID`
918
+ * 2. `multisig_pda.key() == pending.new_owner`
919
+ * 3. `pending.is_multisig_target == true`
920
+ *
921
+ * Caller is responsible for routing this ix through the Squads V4
922
+ * proposal flow so it reaches the on-chain handler under the Squads
923
+ * program signer seeds. The `feePayer` MUST be a wallet signer that
924
+ * funds the tx; this SDK call accepts that signer separately so the
925
+ * Squads PDA is NOT a signer at the kit transaction-signing layer.
926
+ *
927
+ * Timelock + cosign rules identical to {@link acceptOwnershipTransfer}.
928
+ */
929
+ export async function acceptOwnershipTransferMultisig(rpc, vault, multisigPda, feePayer, network, opts) {
930
+ const ix = await getAcceptOwnershipTransferMultisigInstructionAsync({
931
+ multisigPda,
932
+ vault,
933
+ });
934
+ return run(rpc, feePayer, network, [ix], opts);
433
935
  }
434
- export async function cancelCloseConstraints(rpc, vault, owner, network, opts) {
435
- const ix = await getCancelCloseConstraintsInstructionAsync({ owner, vault });
436
- return run(rpc, owner, network, [ix], opts);
936
+ /**
937
+ * Cancel a queued ownership transfer during the timelock window. The
938
+ * `currentOwner` (signer) MUST match `pending.current_owner` (the
939
+ * pubkey that called `initiateOwnershipTransfer`); the on-chain handler
940
+ * rejects with a require-keys-eq violation otherwise.
941
+ *
942
+ * Closes the pending PDA and returns rent to the current owner. After
943
+ * this ix lands, `initiateOwnershipTransfer` is callable again to queue
944
+ * a different target.
945
+ *
946
+ * Cosign behaviour (D4 symmetric gate): if `policy.cosign_required`,
947
+ * cancellation also requires a non-owner co-signer.
948
+ */
949
+ export async function cancelOwnershipTransfer(rpc, vault, currentOwner, network, opts) {
950
+ const ix = await getCancelOwnershipTransferInstructionAsync({
951
+ currentOwner,
952
+ vault,
953
+ });
954
+ return run(rpc, currentOwner, network, [ix], opts);
437
955
  }
438
956
  //# sourceMappingURL=mutations.js.map