@usesigil/kit 0.16.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 (629) 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 +1 -2
  7. package/dist/agent-bootstrap.d.ts.map +1 -1
  8. package/dist/agent-bootstrap.js.map +1 -1
  9. package/dist/agent-errors.d.ts +20 -4
  10. package/dist/agent-errors.d.ts.map +1 -1
  11. package/dist/agent-errors.js +854 -369
  12. package/dist/agent-errors.js.map +1 -1
  13. package/dist/audit-log.d.ts +101 -0
  14. package/dist/audit-log.d.ts.map +1 -0
  15. package/dist/audit-log.js +145 -0
  16. package/dist/audit-log.js.map +1 -0
  17. package/dist/caip2-network.d.ts +171 -0
  18. package/dist/caip2-network.d.ts.map +1 -0
  19. package/dist/caip2-network.js +202 -0
  20. package/dist/caip2-network.js.map +1 -0
  21. package/dist/canonical-encode.d.ts +59 -0
  22. package/dist/canonical-encode.d.ts.map +1 -0
  23. package/dist/canonical-encode.js +141 -0
  24. package/dist/canonical-encode.js.map +1 -0
  25. package/dist/cosign-helper.d.ts +264 -0
  26. package/dist/cosign-helper.d.ts.map +1 -0
  27. package/dist/cosign-helper.js +147 -0
  28. package/dist/cosign-helper.js.map +1 -0
  29. package/dist/create-vault.d.ts +92 -0
  30. package/dist/create-vault.d.ts.map +1 -1
  31. package/dist/create-vault.js +98 -7
  32. package/dist/create-vault.js.map +1 -1
  33. package/dist/dashboard/close-vault.d.ts +110 -0
  34. package/dist/dashboard/close-vault.d.ts.map +1 -0
  35. package/dist/dashboard/close-vault.js +165 -0
  36. package/dist/dashboard/close-vault.js.map +1 -0
  37. package/dist/dashboard/errors.d.ts +2 -2
  38. package/dist/dashboard/errors.d.ts.map +1 -1
  39. package/dist/dashboard/errors.js +11 -7
  40. package/dist/dashboard/errors.js.map +1 -1
  41. package/dist/dashboard/index.d.ts +181 -34
  42. package/dist/dashboard/index.d.ts.map +1 -1
  43. package/dist/dashboard/index.js +258 -52
  44. package/dist/dashboard/index.js.map +1 -1
  45. package/dist/dashboard/mutations.d.ts +117 -26
  46. package/dist/dashboard/mutations.d.ts.map +1 -1
  47. package/dist/dashboard/mutations.js +521 -110
  48. package/dist/dashboard/mutations.js.map +1 -1
  49. package/dist/dashboard/post-assertion-validation.d.ts +1 -1
  50. package/dist/dashboard/post-assertion-validation.d.ts.map +1 -1
  51. package/dist/dashboard/post-assertion-validation.js +169 -48
  52. package/dist/dashboard/post-assertion-validation.js.map +1 -1
  53. package/dist/dashboard/reads.d.ts +3 -4
  54. package/dist/dashboard/reads.d.ts.map +1 -1
  55. package/dist/dashboard/reads.js +11 -22
  56. package/dist/dashboard/reads.js.map +1 -1
  57. package/dist/dashboard/types.d.ts +32 -17
  58. package/dist/dashboard/types.d.ts.map +1 -1
  59. package/dist/errors/agent-errors.generated.d.ts +21 -0
  60. package/dist/errors/agent-errors.generated.d.ts.map +1 -0
  61. package/dist/errors/agent-errors.generated.js +133 -0
  62. package/dist/errors/agent-errors.generated.js.map +1 -0
  63. package/dist/errors/codes.d.ts +21 -2
  64. package/dist/errors/codes.d.ts.map +1 -1
  65. package/dist/errors/codes.js +19 -0
  66. package/dist/errors/codes.js.map +1 -1
  67. package/dist/errors/context.d.ts +9 -1
  68. package/dist/errors/context.d.ts.map +1 -1
  69. package/dist/event-analytics.d.ts +1 -3
  70. package/dist/event-analytics.d.ts.map +1 -1
  71. package/dist/event-analytics.js +28 -81
  72. package/dist/event-analytics.js.map +1 -1
  73. package/dist/events.d.ts.map +1 -1
  74. package/dist/events.js +23 -14
  75. package/dist/events.js.map +1 -1
  76. package/dist/generated/accounts/agentSpendOverlay.d.ts +60 -0
  77. package/dist/generated/accounts/agentSpendOverlay.d.ts.map +1 -1
  78. package/dist/generated/accounts/agentSpendOverlay.js +6 -2
  79. package/dist/generated/accounts/agentSpendOverlay.js.map +1 -1
  80. package/dist/generated/accounts/agentVault.d.ts +168 -4
  81. package/dist/generated/accounts/agentVault.d.ts.map +1 -1
  82. package/dist/generated/accounts/agentVault.js +11 -3
  83. package/dist/generated/accounts/agentVault.js.map +1 -1
  84. package/dist/generated/accounts/auditLogRejected.d.ts +66 -0
  85. package/dist/generated/accounts/auditLogRejected.d.ts.map +1 -0
  86. package/dist/generated/accounts/auditLogRejected.js +68 -0
  87. package/dist/generated/accounts/auditLogRejected.js.map +1 -0
  88. package/dist/generated/accounts/auditLogSuccess.d.ts +78 -0
  89. package/dist/generated/accounts/auditLogSuccess.d.ts.map +1 -0
  90. package/dist/generated/accounts/auditLogSuccess.js +68 -0
  91. package/dist/generated/accounts/auditLogSuccess.js.map +1 -0
  92. package/dist/generated/accounts/index.d.ts +4 -4
  93. package/dist/generated/accounts/index.d.ts.map +1 -1
  94. package/dist/generated/accounts/index.js +4 -4
  95. package/dist/generated/accounts/index.js.map +1 -1
  96. package/dist/generated/accounts/pendingAgentGrant.d.ts +199 -0
  97. package/dist/generated/accounts/pendingAgentGrant.d.ts.map +1 -0
  98. package/dist/generated/accounts/pendingAgentGrant.js +75 -0
  99. package/dist/generated/accounts/pendingAgentGrant.js.map +1 -0
  100. package/dist/generated/accounts/pendingAgentPermissionsUpdate.d.ts +64 -0
  101. package/dist/generated/accounts/pendingAgentPermissionsUpdate.d.ts.map +1 -1
  102. package/dist/generated/accounts/pendingAgentPermissionsUpdate.js +7 -1
  103. package/dist/generated/accounts/pendingAgentPermissionsUpdate.js.map +1 -1
  104. package/dist/generated/accounts/pendingOwnershipTransfer.d.ts +131 -0
  105. package/dist/generated/accounts/pendingOwnershipTransfer.d.ts.map +1 -0
  106. package/dist/generated/accounts/pendingOwnershipTransfer.js +76 -0
  107. package/dist/generated/accounts/pendingOwnershipTransfer.js.map +1 -0
  108. package/dist/generated/accounts/pendingPolicyUpdate.d.ts +200 -4
  109. package/dist/generated/accounts/pendingPolicyUpdate.d.ts.map +1 -1
  110. package/dist/generated/accounts/pendingPolicyUpdate.js +19 -1
  111. package/dist/generated/accounts/pendingPolicyUpdate.js.map +1 -1
  112. package/dist/generated/accounts/policyConfig.d.ts +479 -36
  113. package/dist/generated/accounts/policyConfig.d.ts.map +1 -1
  114. package/dist/generated/accounts/policyConfig.js +30 -3
  115. package/dist/generated/accounts/policyConfig.js.map +1 -1
  116. package/dist/generated/accounts/postExecutionAssertions.d.ts +2 -2
  117. package/dist/generated/accounts/postExecutionAssertions.d.ts.map +1 -1
  118. package/dist/generated/accounts/postExecutionAssertions.js +3 -3
  119. package/dist/generated/accounts/sessionAuthority.d.ts +140 -12
  120. package/dist/generated/accounts/sessionAuthority.d.ts.map +1 -1
  121. package/dist/generated/accounts/sessionAuthority.js +9 -7
  122. package/dist/generated/accounts/sessionAuthority.js.map +1 -1
  123. package/dist/generated/accounts/spendTracker.d.ts +83 -3
  124. package/dist/generated/accounts/spendTracker.d.ts.map +1 -1
  125. package/dist/generated/accounts/spendTracker.js +14 -2
  126. package/dist/generated/accounts/spendTracker.js.map +1 -1
  127. package/dist/generated/errors/sigil.d.ts +129 -83
  128. package/dist/generated/errors/sigil.d.ts.map +1 -1
  129. package/dist/generated/errors/sigil.js +175 -106
  130. package/dist/generated/errors/sigil.js.map +1 -1
  131. package/dist/generated/event-discriminators.d.ts.map +1 -1
  132. package/dist/generated/event-discriminators.js +11 -14
  133. package/dist/generated/event-discriminators.js.map +1 -1
  134. package/dist/generated/instructions/acceptOwnershipTransfer.d.ts +142 -0
  135. package/dist/generated/instructions/acceptOwnershipTransfer.d.ts.map +1 -0
  136. package/dist/generated/instructions/acceptOwnershipTransfer.js +171 -0
  137. package/dist/generated/instructions/acceptOwnershipTransfer.js.map +1 -0
  138. package/dist/generated/instructions/acceptOwnershipTransferMultisig.d.ts +142 -0
  139. package/dist/generated/instructions/acceptOwnershipTransferMultisig.d.ts.map +1 -0
  140. package/dist/generated/instructions/acceptOwnershipTransferMultisig.js +171 -0
  141. package/dist/generated/instructions/acceptOwnershipTransferMultisig.js.map +1 -0
  142. package/dist/generated/instructions/applyAgentGrant.d.ts +100 -0
  143. package/dist/generated/instructions/applyAgentGrant.d.ts.map +1 -0
  144. package/dist/generated/instructions/{applyConstraintsUpdate.js → applyAgentGrant.js} +66 -42
  145. package/dist/generated/instructions/applyAgentGrant.js.map +1 -0
  146. package/dist/generated/instructions/applyAgentPermissionsUpdate.d.ts +31 -8
  147. package/dist/generated/instructions/applyAgentPermissionsUpdate.d.ts.map +1 -1
  148. package/dist/generated/instructions/applyAgentPermissionsUpdate.js +38 -2
  149. package/dist/generated/instructions/applyAgentPermissionsUpdate.js.map +1 -1
  150. package/dist/generated/instructions/applyPendingPolicy.d.ts +18 -7
  151. package/dist/generated/instructions/applyPendingPolicy.d.ts.map +1 -1
  152. package/dist/generated/instructions/applyPendingPolicy.js +38 -2
  153. package/dist/generated/instructions/applyPendingPolicy.js.map +1 -1
  154. package/dist/generated/instructions/cancelAgentGrant.d.ts +106 -0
  155. package/dist/generated/instructions/cancelAgentGrant.d.ts.map +1 -0
  156. package/dist/generated/instructions/{allocatePendingConstraintsPda.js → cancelAgentGrant.js} +54 -42
  157. package/dist/generated/instructions/cancelAgentGrant.js.map +1 -0
  158. package/dist/generated/instructions/cancelOwnershipTransfer.d.ts +121 -0
  159. package/dist/generated/instructions/cancelOwnershipTransfer.d.ts.map +1 -0
  160. package/dist/generated/instructions/{queueCloseConstraints.js → cancelOwnershipTransfer.js} +58 -44
  161. package/dist/generated/instructions/cancelOwnershipTransfer.js.map +1 -0
  162. package/dist/generated/instructions/closePostAssertions.d.ts +6 -1
  163. package/dist/generated/instructions/closePostAssertions.d.ts.map +1 -1
  164. package/dist/generated/instructions/closePostAssertions.js +11 -3
  165. package/dist/generated/instructions/closePostAssertions.js.map +1 -1
  166. package/dist/generated/instructions/closeVault.d.ts +40 -8
  167. package/dist/generated/instructions/closeVault.d.ts.map +1 -1
  168. package/dist/generated/instructions/closeVault.js +40 -2
  169. package/dist/generated/instructions/closeVault.js.map +1 -1
  170. package/dist/generated/instructions/createPostAssertions.d.ts +4 -0
  171. package/dist/generated/instructions/createPostAssertions.d.ts.map +1 -1
  172. package/dist/generated/instructions/createPostAssertions.js +2 -0
  173. package/dist/generated/instructions/createPostAssertions.js.map +1 -1
  174. package/dist/generated/instructions/depositFunds.d.ts +21 -10
  175. package/dist/generated/instructions/depositFunds.d.ts.map +1 -1
  176. package/dist/generated/instructions/depositFunds.js +37 -2
  177. package/dist/generated/instructions/depositFunds.js.map +1 -1
  178. package/dist/generated/instructions/finalizeSession.d.ts +49 -7
  179. package/dist/generated/instructions/finalizeSession.d.ts.map +1 -1
  180. package/dist/generated/instructions/finalizeSession.js +59 -2
  181. package/dist/generated/instructions/finalizeSession.js.map +1 -1
  182. package/dist/generated/instructions/freezeVault.d.ts +36 -5
  183. package/dist/generated/instructions/freezeVault.d.ts.map +1 -1
  184. package/dist/generated/instructions/freezeVault.js +65 -4
  185. package/dist/generated/instructions/freezeVault.js.map +1 -1
  186. package/dist/generated/instructions/index.d.ts +10 -15
  187. package/dist/generated/instructions/index.d.ts.map +1 -1
  188. package/dist/generated/instructions/index.js +10 -15
  189. package/dist/generated/instructions/index.js.map +1 -1
  190. package/dist/generated/instructions/initializeVault.d.ts +79 -9
  191. package/dist/generated/instructions/initializeVault.d.ts.map +1 -1
  192. package/dist/generated/instructions/initializeVault.js +57 -3
  193. package/dist/generated/instructions/initializeVault.js.map +1 -1
  194. package/dist/generated/instructions/initiateOwnershipTransfer.d.ts +106 -0
  195. package/dist/generated/instructions/initiateOwnershipTransfer.d.ts.map +1 -0
  196. package/dist/generated/instructions/initiateOwnershipTransfer.js +181 -0
  197. package/dist/generated/instructions/initiateOwnershipTransfer.js.map +1 -0
  198. package/dist/generated/instructions/pauseAgent.d.ts +49 -5
  199. package/dist/generated/instructions/pauseAgent.d.ts.map +1 -1
  200. package/dist/generated/instructions/pauseAgent.js +80 -5
  201. package/dist/generated/instructions/pauseAgent.js.map +1 -1
  202. package/dist/generated/instructions/promoteGraylistDestination.d.ts +56 -0
  203. package/dist/generated/instructions/promoteGraylistDestination.d.ts.map +1 -0
  204. package/dist/generated/instructions/{createInstructionConstraints.js → promoteGraylistDestination.js} +23 -40
  205. package/dist/generated/instructions/promoteGraylistDestination.js.map +1 -0
  206. package/dist/generated/instructions/queueAgentGrant.d.ts +113 -0
  207. package/dist/generated/instructions/queueAgentGrant.d.ts.map +1 -0
  208. package/dist/generated/instructions/queueAgentGrant.js +181 -0
  209. package/dist/generated/instructions/queueAgentGrant.js.map +1 -0
  210. package/dist/generated/instructions/queueAgentPermissionsUpdate.d.ts +8 -0
  211. package/dist/generated/instructions/queueAgentPermissionsUpdate.d.ts.map +1 -1
  212. package/dist/generated/instructions/queueAgentPermissionsUpdate.js +4 -0
  213. package/dist/generated/instructions/queueAgentPermissionsUpdate.js.map +1 -1
  214. package/dist/generated/instructions/queuePolicyUpdate.d.ts +32 -0
  215. package/dist/generated/instructions/queuePolicyUpdate.d.ts.map +1 -1
  216. package/dist/generated/instructions/queuePolicyUpdate.js +17 -1
  217. package/dist/generated/instructions/queuePolicyUpdate.js.map +1 -1
  218. package/dist/generated/instructions/reactivateVault.d.ts +71 -5
  219. package/dist/generated/instructions/reactivateVault.d.ts.map +1 -1
  220. package/dist/generated/instructions/reactivateVault.js +80 -5
  221. package/dist/generated/instructions/reactivateVault.js.map +1 -1
  222. package/dist/generated/instructions/recordAgentViolation.d.ts +89 -0
  223. package/dist/generated/instructions/recordAgentViolation.d.ts.map +1 -0
  224. package/dist/generated/instructions/recordAgentViolation.js +152 -0
  225. package/dist/generated/instructions/recordAgentViolation.js.map +1 -0
  226. package/dist/generated/instructions/registerAgent.d.ts +84 -6
  227. package/dist/generated/instructions/registerAgent.d.ts.map +1 -1
  228. package/dist/generated/instructions/registerAgent.js +81 -4
  229. package/dist/generated/instructions/registerAgent.js.map +1 -1
  230. package/dist/generated/instructions/revokeAgent.d.ts +49 -6
  231. package/dist/generated/instructions/revokeAgent.d.ts.map +1 -1
  232. package/dist/generated/instructions/revokeAgent.js +81 -4
  233. package/dist/generated/instructions/revokeAgent.js.map +1 -1
  234. package/dist/generated/instructions/setObserveOnly.d.ts +56 -0
  235. package/dist/generated/instructions/setObserveOnly.d.ts.map +1 -0
  236. package/dist/generated/instructions/setObserveOnly.js +111 -0
  237. package/dist/generated/instructions/setObserveOnly.js.map +1 -0
  238. package/dist/generated/instructions/unpauseAgent.d.ts +46 -5
  239. package/dist/generated/instructions/unpauseAgent.d.ts.map +1 -1
  240. package/dist/generated/instructions/unpauseAgent.js +80 -5
  241. package/dist/generated/instructions/unpauseAgent.js.map +1 -1
  242. package/dist/generated/instructions/validateAndAuthorize.d.ts +29 -0
  243. package/dist/generated/instructions/validateAndAuthorize.d.ts.map +1 -1
  244. package/dist/generated/instructions/validateAndAuthorize.js +4 -0
  245. package/dist/generated/instructions/validateAndAuthorize.js.map +1 -1
  246. package/dist/generated/instructions/withdrawFunds.d.ts +53 -11
  247. package/dist/generated/instructions/withdrawFunds.d.ts.map +1 -1
  248. package/dist/generated/instructions/withdrawFunds.js +51 -2
  249. package/dist/generated/instructions/withdrawFunds.js.map +1 -1
  250. package/dist/generated/programs/sigil.d.ts +79 -99
  251. package/dist/generated/programs/sigil.d.ts.map +1 -1
  252. package/dist/generated/programs/sigil.js +139 -199
  253. package/dist/generated/programs/sigil.js.map +1 -1
  254. package/dist/generated/types/actionAuthorized.d.ts +0 -2
  255. package/dist/generated/types/actionAuthorized.d.ts.map +1 -1
  256. package/dist/generated/types/actionAuthorized.js +0 -2
  257. package/dist/generated/types/actionAuthorized.js.map +1 -1
  258. package/dist/generated/types/agentAutoRevoked.d.ts +31 -0
  259. package/dist/generated/types/agentAutoRevoked.d.ts.map +1 -0
  260. package/dist/generated/types/{orphanConstraintsPdaCleaned.js → agentAutoRevoked.js} +12 -8
  261. package/dist/generated/types/agentAutoRevoked.js.map +1 -0
  262. package/dist/generated/types/agentEntry.d.ts +48 -0
  263. package/dist/generated/types/agentEntry.d.ts.map +1 -1
  264. package/dist/generated/types/agentEntry.js +4 -2
  265. package/dist/generated/types/agentEntry.js.map +1 -1
  266. package/dist/generated/types/agentGrantApplied.d.ts +38 -0
  267. package/dist/generated/types/agentGrantApplied.d.ts.map +1 -0
  268. package/dist/generated/types/agentGrantApplied.js +34 -0
  269. package/dist/generated/types/agentGrantApplied.js.map +1 -0
  270. package/dist/generated/types/agentGrantCancelled.d.ts +33 -0
  271. package/dist/generated/types/agentGrantCancelled.d.ts.map +1 -0
  272. package/dist/generated/types/agentGrantCancelled.js +28 -0
  273. package/dist/generated/types/agentGrantCancelled.js.map +1 -0
  274. package/dist/generated/types/agentGrantQueued.d.ts +38 -0
  275. package/dist/generated/types/agentGrantQueued.d.ts.map +1 -0
  276. package/dist/generated/types/agentGrantQueued.js +32 -0
  277. package/dist/generated/types/agentGrantQueued.js.map +1 -0
  278. package/dist/generated/types/auditEntry.d.ts +120 -0
  279. package/dist/generated/types/auditEntry.d.ts.map +1 -0
  280. package/dist/generated/types/auditEntry.js +34 -0
  281. package/dist/generated/types/auditEntry.js.map +1 -0
  282. package/dist/generated/types/destinationGraylistEntry.d.ts +32 -0
  283. package/dist/generated/types/destinationGraylistEntry.d.ts.map +1 -0
  284. package/dist/generated/types/destinationGraylistEntry.js +24 -0
  285. package/dist/generated/types/destinationGraylistEntry.js.map +1 -0
  286. package/dist/generated/types/graylistEntered.d.ts +31 -0
  287. package/dist/generated/types/graylistEntered.d.ts.map +1 -0
  288. package/dist/generated/types/graylistEntered.js +30 -0
  289. package/dist/generated/types/graylistEntered.js.map +1 -0
  290. package/dist/generated/types/graylistPromoted.d.ts +29 -0
  291. package/dist/generated/types/graylistPromoted.d.ts.map +1 -0
  292. package/dist/generated/types/graylistPromoted.js +28 -0
  293. package/dist/generated/types/graylistPromoted.js.map +1 -0
  294. package/dist/generated/types/index.d.ts +13 -22
  295. package/dist/generated/types/index.d.ts.map +1 -1
  296. package/dist/generated/types/index.js +13 -22
  297. package/dist/generated/types/index.js.map +1 -1
  298. package/dist/generated/types/observeOnlyChanged.d.ts +33 -0
  299. package/dist/generated/types/observeOnlyChanged.d.ts.map +1 -0
  300. package/dist/generated/types/observeOnlyChanged.js +32 -0
  301. package/dist/generated/types/observeOnlyChanged.js.map +1 -0
  302. package/dist/generated/types/ownershipTransferAccepted.d.ts +32 -0
  303. package/dist/generated/types/ownershipTransferAccepted.d.ts.map +1 -0
  304. package/dist/generated/types/ownershipTransferAccepted.js +30 -0
  305. package/dist/generated/types/ownershipTransferAccepted.js.map +1 -0
  306. package/dist/generated/types/ownershipTransferCancelled.d.ts +29 -0
  307. package/dist/generated/types/ownershipTransferCancelled.d.ts.map +1 -0
  308. package/dist/generated/types/ownershipTransferCancelled.js +28 -0
  309. package/dist/generated/types/ownershipTransferCancelled.js.map +1 -0
  310. package/dist/generated/types/ownershipTransferInitiated.d.ts +33 -0
  311. package/dist/generated/types/ownershipTransferInitiated.d.ts.map +1 -0
  312. package/dist/generated/types/ownershipTransferInitiated.js +30 -0
  313. package/dist/generated/types/ownershipTransferInitiated.js.map +1 -0
  314. package/dist/generated/types/perRecipientCounter.d.ts +61 -0
  315. package/dist/generated/types/perRecipientCounter.d.ts.map +1 -0
  316. package/dist/generated/types/perRecipientCounter.js +26 -0
  317. package/dist/generated/types/perRecipientCounter.js.map +1 -0
  318. package/dist/generated/types/postAssertionEntry.d.ts +14 -7
  319. package/dist/generated/types/postAssertionEntry.d.ts.map +1 -1
  320. package/dist/generated/types/postAssertionEntry.js +5 -7
  321. package/dist/generated/types/postAssertionEntry.js.map +1 -1
  322. package/dist/generated/types/postAssertionEntryZC.d.ts +53 -22
  323. package/dist/generated/types/postAssertionEntryZC.d.ts.map +1 -1
  324. package/dist/generated/types/postAssertionEntryZC.js +4 -6
  325. package/dist/generated/types/postAssertionEntryZC.js.map +1 -1
  326. package/dist/generated/types/sessionFinalized.d.ts +0 -4
  327. package/dist/generated/types/sessionFinalized.d.ts.map +1 -1
  328. package/dist/generated/types/sessionFinalized.js +0 -2
  329. package/dist/generated/types/sessionFinalized.js.map +1 -1
  330. package/dist/generated/types/vaultFrozen.d.ts +14 -0
  331. package/dist/generated/types/vaultFrozen.d.ts.map +1 -1
  332. package/dist/generated/types/vaultFrozen.js +2 -0
  333. package/dist/generated/types/vaultFrozen.js.map +1 -1
  334. package/dist/index.d.ts +28 -9
  335. package/dist/index.d.ts.map +1 -1
  336. package/dist/index.js +64 -11
  337. package/dist/index.js.map +1 -1
  338. package/dist/inspector.d.ts +0 -23
  339. package/dist/inspector.d.ts.map +1 -1
  340. package/dist/inspector.js +0 -52
  341. package/dist/inspector.js.map +1 -1
  342. package/dist/kit-adapter.d.ts +1 -1
  343. package/dist/kit-adapter.d.ts.map +1 -1
  344. package/dist/kit-adapter.js +1 -1
  345. package/dist/kit-adapter.js.map +1 -1
  346. package/dist/multisig-detection.d.ts +83 -0
  347. package/dist/multisig-detection.d.ts.map +1 -0
  348. package/dist/multisig-detection.js +128 -0
  349. package/dist/multisig-detection.js.map +1 -0
  350. package/dist/ownership-transfer.d.ts +79 -0
  351. package/dist/ownership-transfer.d.ts.map +1 -0
  352. package/dist/ownership-transfer.js +66 -0
  353. package/dist/ownership-transfer.js.map +1 -0
  354. package/dist/policy/compute-cosign-digest.d.ts +193 -0
  355. package/dist/policy/compute-cosign-digest.d.ts.map +1 -0
  356. package/dist/policy/compute-cosign-digest.js +318 -0
  357. package/dist/policy/compute-cosign-digest.js.map +1 -0
  358. package/dist/policy/compute-policy-preview-digest.d.ts +258 -0
  359. package/dist/policy/compute-policy-preview-digest.d.ts.map +1 -0
  360. package/dist/policy/compute-policy-preview-digest.js +351 -0
  361. package/dist/policy/compute-policy-preview-digest.js.map +1 -0
  362. package/dist/policy-attestation.d.ts +51 -0
  363. package/dist/policy-attestation.d.ts.map +1 -0
  364. package/dist/policy-attestation.js +43 -0
  365. package/dist/policy-attestation.js.map +1 -0
  366. package/dist/preview-create-vault.d.ts.map +1 -1
  367. package/dist/preview-create-vault.js +37 -16
  368. package/dist/preview-create-vault.js.map +1 -1
  369. package/dist/resolve-accounts.d.ts +75 -10
  370. package/dist/resolve-accounts.d.ts.map +1 -1
  371. package/dist/resolve-accounts.js +68 -32
  372. package/dist/resolve-accounts.js.map +1 -1
  373. package/dist/rpc-helpers.d.ts +29 -3
  374. package/dist/rpc-helpers.d.ts.map +1 -1
  375. package/dist/rpc-helpers.js +51 -12
  376. package/dist/rpc-helpers.js.map +1 -1
  377. package/dist/seal/intent-digest.d.ts +195 -0
  378. package/dist/seal/intent-digest.d.ts.map +1 -0
  379. package/dist/seal/intent-digest.js +372 -0
  380. package/dist/seal/intent-digest.js.map +1 -0
  381. package/dist/seal.d.ts +166 -3
  382. package/dist/seal.d.ts.map +1 -1
  383. package/dist/seal.js +428 -32
  384. package/dist/seal.js.map +1 -1
  385. package/dist/security-analytics.d.ts +3 -3
  386. package/dist/security-analytics.d.ts.map +1 -1
  387. package/dist/security-analytics.js +13 -128
  388. package/dist/security-analytics.js.map +1 -1
  389. package/dist/session-mint.d.ts +72 -0
  390. package/dist/session-mint.d.ts.map +1 -0
  391. package/dist/session-mint.js +59 -0
  392. package/dist/session-mint.js.map +1 -0
  393. package/dist/simulation.d.ts +19 -0
  394. package/dist/simulation.d.ts.map +1 -1
  395. package/dist/simulation.js +187 -95
  396. package/dist/simulation.js.map +1 -1
  397. package/dist/squads-detection.d.ts +135 -0
  398. package/dist/squads-detection.d.ts.map +1 -0
  399. package/dist/squads-detection.js +124 -0
  400. package/dist/squads-detection.js.map +1 -0
  401. package/dist/state-resolver.d.ts +0 -16
  402. package/dist/state-resolver.d.ts.map +1 -1
  403. package/dist/state-resolver.js +162 -97
  404. package/dist/state-resolver.js.map +1 -1
  405. package/dist/testing/devnet.d.ts +40 -1
  406. package/dist/testing/devnet.d.ts.map +1 -1
  407. package/dist/testing/devnet.js +333 -44
  408. package/dist/testing/devnet.js.map +1 -1
  409. package/dist/testing/errors/expect.d.ts +1 -1
  410. package/dist/testing/errors/expect.js +1 -1
  411. package/dist/testing/errors/names.generated.d.ts +81 -58
  412. package/dist/testing/errors/names.generated.d.ts.map +1 -1
  413. package/dist/testing/errors/names.generated.js +82 -59
  414. package/dist/testing/errors/names.generated.js.map +1 -1
  415. package/dist/testing/mock-rpc.d.ts +8 -0
  416. package/dist/testing/mock-rpc.d.ts.map +1 -1
  417. package/dist/testing/mock-rpc.js +13 -0
  418. package/dist/testing/mock-rpc.js.map +1 -1
  419. package/dist/testing/mock-state.d.ts +2 -0
  420. package/dist/testing/mock-state.d.ts.map +1 -1
  421. package/dist/testing/mock-state.js +43 -4
  422. package/dist/testing/mock-state.js.map +1 -1
  423. package/dist/types.d.ts +5 -15
  424. package/dist/types.d.ts.map +1 -1
  425. package/dist/types.js +11 -69
  426. package/dist/types.js.map +1 -1
  427. package/dist/vault-analytics.d.ts +0 -2
  428. package/dist/vault-analytics.d.ts.map +1 -1
  429. package/dist/vault-analytics.js +1 -9
  430. package/dist/vault-analytics.js.map +1 -1
  431. package/package.json +7 -12
  432. package/dist/constraints/index.d.ts +0 -23
  433. package/dist/constraints/index.d.ts.map +0 -1
  434. package/dist/constraints/index.js +0 -24
  435. package/dist/constraints/index.js.map +0 -1
  436. package/dist/dashboard/constraint-builders.d.ts +0 -82
  437. package/dist/dashboard/constraint-builders.d.ts.map +0 -1
  438. package/dist/dashboard/constraint-builders.js +0 -204
  439. package/dist/dashboard/constraint-builders.js.map +0 -1
  440. package/dist/dashboard/constraint-reads.d.ts +0 -50
  441. package/dist/dashboard/constraint-reads.d.ts.map +0 -1
  442. package/dist/dashboard/constraint-reads.js +0 -119
  443. package/dist/dashboard/constraint-reads.js.map +0 -1
  444. package/dist/generated/accounts/escrowDeposit.d.ts +0 -50
  445. package/dist/generated/accounts/escrowDeposit.d.ts.map +0 -1
  446. package/dist/generated/accounts/escrowDeposit.js +0 -76
  447. package/dist/generated/accounts/escrowDeposit.js.map +0 -1
  448. package/dist/generated/accounts/instructionConstraints.d.ts +0 -46
  449. package/dist/generated/accounts/instructionConstraints.d.ts.map +0 -1
  450. package/dist/generated/accounts/instructionConstraints.js +0 -73
  451. package/dist/generated/accounts/instructionConstraints.js.map +0 -1
  452. package/dist/generated/accounts/pendingCloseConstraints.d.ts +0 -49
  453. package/dist/generated/accounts/pendingCloseConstraints.d.ts.map +0 -1
  454. package/dist/generated/accounts/pendingCloseConstraints.js +0 -68
  455. package/dist/generated/accounts/pendingCloseConstraints.js.map +0 -1
  456. package/dist/generated/accounts/pendingConstraintsUpdate.d.ts +0 -76
  457. package/dist/generated/accounts/pendingConstraintsUpdate.d.ts.map +0 -1
  458. package/dist/generated/accounts/pendingConstraintsUpdate.js +0 -77
  459. package/dist/generated/accounts/pendingConstraintsUpdate.js.map +0 -1
  460. package/dist/generated/instructions/allocateConstraintsPda.d.ts +0 -62
  461. package/dist/generated/instructions/allocateConstraintsPda.d.ts.map +0 -1
  462. package/dist/generated/instructions/allocateConstraintsPda.js +0 -134
  463. package/dist/generated/instructions/allocateConstraintsPda.js.map +0 -1
  464. package/dist/generated/instructions/allocatePendingConstraintsPda.d.ts +0 -66
  465. package/dist/generated/instructions/allocatePendingConstraintsPda.d.ts.map +0 -1
  466. package/dist/generated/instructions/allocatePendingConstraintsPda.js.map +0 -1
  467. package/dist/generated/instructions/applyCloseConstraints.d.ts +0 -59
  468. package/dist/generated/instructions/applyCloseConstraints.d.ts.map +0 -1
  469. package/dist/generated/instructions/applyCloseConstraints.js +0 -143
  470. package/dist/generated/instructions/applyCloseConstraints.js.map +0 -1
  471. package/dist/generated/instructions/applyConstraintsUpdate.d.ts +0 -62
  472. package/dist/generated/instructions/applyConstraintsUpdate.d.ts.map +0 -1
  473. package/dist/generated/instructions/applyConstraintsUpdate.js.map +0 -1
  474. package/dist/generated/instructions/cancelCloseConstraints.d.ts +0 -51
  475. package/dist/generated/instructions/cancelCloseConstraints.d.ts.map +0 -1
  476. package/dist/generated/instructions/cancelCloseConstraints.js +0 -115
  477. package/dist/generated/instructions/cancelCloseConstraints.js.map +0 -1
  478. package/dist/generated/instructions/cancelConstraintsUpdate.d.ts +0 -51
  479. package/dist/generated/instructions/cancelConstraintsUpdate.d.ts.map +0 -1
  480. package/dist/generated/instructions/cancelConstraintsUpdate.js +0 -115
  481. package/dist/generated/instructions/cancelConstraintsUpdate.js.map +0 -1
  482. package/dist/generated/instructions/cleanupOrphanConstraintsPda.d.ts +0 -67
  483. package/dist/generated/instructions/cleanupOrphanConstraintsPda.d.ts.map +0 -1
  484. package/dist/generated/instructions/cleanupOrphanConstraintsPda.js +0 -120
  485. package/dist/generated/instructions/cleanupOrphanConstraintsPda.js.map +0 -1
  486. package/dist/generated/instructions/closeSettledEscrow.d.ts +0 -72
  487. package/dist/generated/instructions/closeSettledEscrow.d.ts.map +0 -1
  488. package/dist/generated/instructions/closeSettledEscrow.js +0 -127
  489. package/dist/generated/instructions/closeSettledEscrow.js.map +0 -1
  490. package/dist/generated/instructions/createEscrow.d.ts +0 -131
  491. package/dist/generated/instructions/createEscrow.d.ts.map +0 -1
  492. package/dist/generated/instructions/createEscrow.js +0 -272
  493. package/dist/generated/instructions/createEscrow.js.map +0 -1
  494. package/dist/generated/instructions/createInstructionConstraints.d.ts +0 -68
  495. package/dist/generated/instructions/createInstructionConstraints.d.ts.map +0 -1
  496. package/dist/generated/instructions/createInstructionConstraints.js.map +0 -1
  497. package/dist/generated/instructions/extendPda.d.ts +0 -52
  498. package/dist/generated/instructions/extendPda.d.ts.map +0 -1
  499. package/dist/generated/instructions/extendPda.js +0 -86
  500. package/dist/generated/instructions/extendPda.js.map +0 -1
  501. package/dist/generated/instructions/queueCloseConstraints.d.ts +0 -66
  502. package/dist/generated/instructions/queueCloseConstraints.d.ts.map +0 -1
  503. package/dist/generated/instructions/queueCloseConstraints.js.map +0 -1
  504. package/dist/generated/instructions/queueConstraintsUpdate.d.ts +0 -75
  505. package/dist/generated/instructions/queueConstraintsUpdate.d.ts.map +0 -1
  506. package/dist/generated/instructions/queueConstraintsUpdate.js +0 -154
  507. package/dist/generated/instructions/queueConstraintsUpdate.js.map +0 -1
  508. package/dist/generated/instructions/refundEscrow.d.ts +0 -74
  509. package/dist/generated/instructions/refundEscrow.d.ts.map +0 -1
  510. package/dist/generated/instructions/refundEscrow.js +0 -142
  511. package/dist/generated/instructions/refundEscrow.js.map +0 -1
  512. package/dist/generated/instructions/settleEscrow.d.ts +0 -80
  513. package/dist/generated/instructions/settleEscrow.d.ts.map +0 -1
  514. package/dist/generated/instructions/settleEscrow.js +0 -173
  515. package/dist/generated/instructions/settleEscrow.js.map +0 -1
  516. package/dist/generated/types/accountConstraint.d.ts +0 -33
  517. package/dist/generated/types/accountConstraint.d.ts.map +0 -1
  518. package/dist/generated/types/accountConstraint.js +0 -26
  519. package/dist/generated/types/accountConstraint.js.map +0 -1
  520. package/dist/generated/types/accountConstraintZC.d.ts +0 -25
  521. package/dist/generated/types/accountConstraintZC.d.ts.map +0 -1
  522. package/dist/generated/types/accountConstraintZC.js +0 -28
  523. package/dist/generated/types/accountConstraintZC.js.map +0 -1
  524. package/dist/generated/types/closeConstraintsApplied.d.ts +0 -20
  525. package/dist/generated/types/closeConstraintsApplied.d.ts.map +0 -1
  526. package/dist/generated/types/closeConstraintsApplied.js +0 -24
  527. package/dist/generated/types/closeConstraintsApplied.js.map +0 -1
  528. package/dist/generated/types/closeConstraintsCancelled.d.ts +0 -16
  529. package/dist/generated/types/closeConstraintsCancelled.d.ts.map +0 -1
  530. package/dist/generated/types/closeConstraintsCancelled.js +0 -18
  531. package/dist/generated/types/closeConstraintsCancelled.js.map +0 -1
  532. package/dist/generated/types/closeConstraintsQueued.d.ts +0 -20
  533. package/dist/generated/types/closeConstraintsQueued.d.ts.map +0 -1
  534. package/dist/generated/types/closeConstraintsQueued.js +0 -24
  535. package/dist/generated/types/closeConstraintsQueued.js.map +0 -1
  536. package/dist/generated/types/constraintEntry.d.ts +0 -35
  537. package/dist/generated/types/constraintEntry.d.ts.map +0 -1
  538. package/dist/generated/types/constraintEntry.js +0 -29
  539. package/dist/generated/types/constraintEntry.js.map +0 -1
  540. package/dist/generated/types/constraintEntryZC.d.ts +0 -73
  541. package/dist/generated/types/constraintEntryZC.d.ts.map +0 -1
  542. package/dist/generated/types/constraintEntryZC.js +0 -49
  543. package/dist/generated/types/constraintEntryZC.js.map +0 -1
  544. package/dist/generated/types/constraintOperator.d.ts +0 -22
  545. package/dist/generated/types/constraintOperator.d.ts.map +0 -1
  546. package/dist/generated/types/constraintOperator.js +0 -28
  547. package/dist/generated/types/constraintOperator.js.map +0 -1
  548. package/dist/generated/types/constraintsChangeApplied.d.ts +0 -30
  549. package/dist/generated/types/constraintsChangeApplied.d.ts.map +0 -1
  550. package/dist/generated/types/constraintsChangeApplied.js +0 -32
  551. package/dist/generated/types/constraintsChangeApplied.js.map +0 -1
  552. package/dist/generated/types/constraintsChangeCancelled.d.ts +0 -16
  553. package/dist/generated/types/constraintsChangeCancelled.d.ts.map +0 -1
  554. package/dist/generated/types/constraintsChangeCancelled.js +0 -18
  555. package/dist/generated/types/constraintsChangeCancelled.js.map +0 -1
  556. package/dist/generated/types/constraintsChangeQueued.d.ts +0 -30
  557. package/dist/generated/types/constraintsChangeQueued.d.ts.map +0 -1
  558. package/dist/generated/types/constraintsChangeQueued.js +0 -32
  559. package/dist/generated/types/constraintsChangeQueued.js.map +0 -1
  560. package/dist/generated/types/dataConstraint.d.ts +0 -23
  561. package/dist/generated/types/dataConstraint.d.ts.map +0 -1
  562. package/dist/generated/types/dataConstraint.js +0 -27
  563. package/dist/generated/types/dataConstraint.js.map +0 -1
  564. package/dist/generated/types/dataConstraintZC.d.ts +0 -20
  565. package/dist/generated/types/dataConstraintZC.d.ts.map +0 -1
  566. package/dist/generated/types/dataConstraintZC.js +0 -30
  567. package/dist/generated/types/dataConstraintZC.js.map +0 -1
  568. package/dist/generated/types/discriminatorFormat.d.ts +0 -25
  569. package/dist/generated/types/discriminatorFormat.d.ts.map +0 -1
  570. package/dist/generated/types/discriminatorFormat.js +0 -31
  571. package/dist/generated/types/discriminatorFormat.js.map +0 -1
  572. package/dist/generated/types/escrowCreated.d.ts +0 -30
  573. package/dist/generated/types/escrowCreated.d.ts.map +0 -1
  574. package/dist/generated/types/escrowCreated.js +0 -34
  575. package/dist/generated/types/escrowCreated.js.map +0 -1
  576. package/dist/generated/types/escrowRefunded.d.ts +0 -26
  577. package/dist/generated/types/escrowRefunded.d.ts.map +0 -1
  578. package/dist/generated/types/escrowRefunded.js +0 -30
  579. package/dist/generated/types/escrowRefunded.js.map +0 -1
  580. package/dist/generated/types/escrowSettled.d.ts +0 -26
  581. package/dist/generated/types/escrowSettled.d.ts.map +0 -1
  582. package/dist/generated/types/escrowSettled.js +0 -30
  583. package/dist/generated/types/escrowSettled.js.map +0 -1
  584. package/dist/generated/types/escrowStatus.d.ts +0 -18
  585. package/dist/generated/types/escrowStatus.d.ts.map +0 -1
  586. package/dist/generated/types/escrowStatus.js +0 -24
  587. package/dist/generated/types/escrowStatus.js.map +0 -1
  588. package/dist/generated/types/instructionConstraintsCreated.d.ts +0 -34
  589. package/dist/generated/types/instructionConstraintsCreated.d.ts.map +0 -1
  590. package/dist/generated/types/instructionConstraintsCreated.js +0 -36
  591. package/dist/generated/types/instructionConstraintsCreated.js.map +0 -1
  592. package/dist/generated/types/orphanConstraintsPdaCleaned.d.ts +0 -22
  593. package/dist/generated/types/orphanConstraintsPdaCleaned.d.ts.map +0 -1
  594. package/dist/generated/types/orphanConstraintsPdaCleaned.js.map +0 -1
  595. package/dist/generated/types/pdaAllocated.d.ts +0 -24
  596. package/dist/generated/types/pdaAllocated.d.ts.map +0 -1
  597. package/dist/generated/types/pdaAllocated.js +0 -28
  598. package/dist/generated/types/pdaAllocated.js.map +0 -1
  599. package/dist/generated/types/pdaExtended.d.ts +0 -24
  600. package/dist/generated/types/pdaExtended.d.ts.map +0 -1
  601. package/dist/generated/types/pdaExtended.js +0 -28
  602. package/dist/generated/types/pdaExtended.js.map +0 -1
  603. package/dist/post-assertions/cross-field-lte.d.ts +0 -134
  604. package/dist/post-assertions/cross-field-lte.d.ts.map +0 -1
  605. package/dist/post-assertions/cross-field-lte.js +0 -129
  606. package/dist/post-assertions/cross-field-lte.js.map +0 -1
  607. package/dist/post-assertions/index.d.ts +0 -28
  608. package/dist/post-assertions/index.d.ts.map +0 -1
  609. package/dist/post-assertions/index.js +0 -28
  610. package/dist/post-assertions/index.js.map +0 -1
  611. package/dist/post-assertions/presets/flash-trade.d.ts +0 -139
  612. package/dist/post-assertions/presets/flash-trade.d.ts.map +0 -1
  613. package/dist/post-assertions/presets/flash-trade.js +0 -154
  614. package/dist/post-assertions/presets/flash-trade.js.map +0 -1
  615. package/dist/protocol-registry/annotations/drift.json +0 -7
  616. package/dist/protocol-registry/annotations/flash-trade.json +0 -7
  617. package/dist/protocol-registry/annotations/jupiter-borrow.json +0 -7
  618. package/dist/protocol-registry/annotations/jupiter-earn.json +0 -7
  619. package/dist/protocol-registry/annotations/jupiter-lend.json +0 -7
  620. package/dist/protocol-registry/annotations/jupiter.json +0 -7
  621. package/dist/protocol-registry/annotations/kamino.json +0 -7
  622. package/dist/protocol-registry/index.d.ts +0 -45
  623. package/dist/protocol-registry/index.d.ts.map +0 -1
  624. package/dist/protocol-registry/index.js +0 -76
  625. package/dist/protocol-registry/index.js.map +0 -1
  626. package/dist/protocol-tier.d.ts +0 -157
  627. package/dist/protocol-tier.d.ts.map +0 -1
  628. package/dist/protocol-tier.js +0 -104
  629. package/dist/protocol-tier.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, getPolicyPDA, } 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,18 +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 { getApplyConstraintsUpdateInstructionAsync } from "../generated/instructions/applyConstraintsUpdate.js";
35
- import { getCancelConstraintsUpdateInstructionAsync } from "../generated/instructions/cancelConstraintsUpdate.js";
36
- import { getQueueCloseConstraintsInstructionAsync } from "../generated/instructions/queueCloseConstraints.js";
37
- import { getApplyCloseConstraintsInstructionAsync } from "../generated/instructions/applyCloseConstraints.js";
38
- import { getCancelCloseConstraintsInstructionAsync } from "../generated/instructions/cancelCloseConstraints.js";
39
42
  import { getCreatePostAssertionsInstructionAsync } from "../generated/instructions/createPostAssertions.js";
40
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";
41
52
  import { validatePostAssertionEntries } from "./post-assertion-validation.js";
42
- import { buildCreateConstraintsIxs, buildQueueConstraintsUpdateIxs, } from "./constraint-builders.js";
43
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";
44
56
  // ─── Shared Helper ───────────────────────────────────────────────────────────
45
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
+ }
46
155
  async function run(rpc, owner, network, instructions, opts = {}) {
47
156
  try {
48
157
  const cu = opts.computeUnits ?? CU_OWNER_ACTION;
@@ -127,11 +236,11 @@ async function derivePendingAgentPermsPDA(vault, agent) {
127
236
  // PHASE 3: Simple mutations
128
237
  // ═══════════════════════════════════════════════════════════════════════════════
129
238
  export async function freezeVault(rpc, vault, owner, network, opts) {
130
- const ix = getFreezeVaultInstruction({ owner, vault });
239
+ const ix = await getFreezeVaultInstructionAsync({ owner, vault });
131
240
  return run(rpc, owner, network, [ix], opts);
132
241
  }
133
242
  export async function resumeVault(rpc, vault, owner, network, newAgent, opts) {
134
- const ix = getReactivateVaultInstruction({
243
+ const ix = await getReactivateVaultInstructionAsync({
135
244
  owner,
136
245
  vault,
137
246
  newAgent: newAgent?.address ?? null,
@@ -139,6 +248,77 @@ export async function resumeVault(rpc, vault, owner, network, newAgent, opts) {
139
248
  });
140
249
  return run(rpc, owner, network, [ix], opts);
141
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
+ }
142
322
  /**
143
323
  * Permanently closes vault and reclaims rent.
144
324
  *
@@ -165,13 +345,8 @@ export async function closeVault(rpc, vault, owner, network, opts) {
165
345
  const [pendingPolicyPda] = await getPendingPolicyPDA(vault);
166
346
  const agents = vaultData.agents || [];
167
347
  const agentPdaDerivations = await Promise.all(agents.map((agent) => derivePendingAgentPermsPDA(vault, agent.pubkey)));
168
- const [pendingCloseConstraintsPda] = await getPendingCloseConstraintsPDA(vault);
169
348
  // Check all PDAs in parallel (E4 fix — batch instead of sequential)
170
- const allPdas = [
171
- pendingPolicyPda,
172
- ...agentPdaDerivations,
173
- pendingCloseConstraintsPda,
174
- ];
349
+ const allPdas = [pendingPolicyPda, ...agentPdaDerivations];
175
350
  const existenceChecks = await Promise.all(allPdas.map(async (pda) => {
176
351
  try {
177
352
  const info = await rpc
@@ -206,13 +381,31 @@ export async function closeVault(rpc, vault, owner, network, opts) {
206
381
  });
207
382
  }
208
383
  }
209
- // 3. pending_close_constraints (if exists) E1 fix: correct seed "pending_close_constraints"
210
- const constraintsIdx = 1 + agents.length;
211
- if (existenceChecks[constraintsIdx]) {
212
- remainingAccounts.push({
213
- address: existenceChecks[constraintsIdx],
214
- role: AccountRole.WRITABLE,
215
- });
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 });
216
409
  }
217
410
  // Append remaining accounts to instruction if any exist
218
411
  const finalIx = remainingAccounts.length > 0
@@ -236,14 +429,24 @@ export async function closeVault(rpc, vault, owner, network, opts) {
236
429
  // decision (9-1 vote, 2026-04-19). See Plans/we-need-to-plan-serialized-summit.md.
237
430
  export async function pauseAgent(rpc, vault, owner, network, agent, opts) {
238
431
  requireValidAddress(agent, "Agent address");
239
- 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
+ });
240
440
  return run(rpc, owner, network, [ix], opts);
241
441
  }
242
442
  export async function unpauseAgent(rpc, vault, owner, network, agent, opts) {
243
443
  requireValidAddress(agent, "Agent address");
244
- 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({
245
447
  owner,
246
448
  vault,
449
+ policy: policyPda,
247
450
  agentToUnpause: agent,
248
451
  });
249
452
  return run(rpc, owner, network, [ix], opts);
@@ -251,9 +454,12 @@ export async function unpauseAgent(rpc, vault, owner, network, agent, opts) {
251
454
  export async function revokeAgent(rpc, vault, owner, network, agent, opts) {
252
455
  requireValidAddress(agent, "Agent address");
253
456
  const [overlayPda] = await getAgentOverlayPDA(vault, 0);
254
- 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({
255
460
  owner,
256
461
  vault,
462
+ policy: policyPda,
257
463
  agentSpendOverlay: overlayPda,
258
464
  agentToRemove: agent,
259
465
  });
@@ -263,9 +469,12 @@ export async function addAgent(rpc, vault, owner, network, agent, permissions, s
263
469
  requireValidAddress(agent, "Agent address");
264
470
  requireValidPermissions(permissions);
265
471
  const [overlayPda] = await getAgentOverlayPDA(vault, 0);
266
- 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({
267
475
  owner,
268
476
  vault,
477
+ policy: policyPda,
269
478
  agentSpendOverlay: overlayPda,
270
479
  agent,
271
480
  capability: Number(permissions),
@@ -333,14 +542,75 @@ export async function queuePolicyUpdate(rpc, vault, owner, network, changes, opt
333
542
  changes.approvedApps.length > MAX_ALLOWED_PROTOCOLS) {
334
543
  throw toDxError(new Error(`approvedApps length exceeds on-chain MAX_ALLOWED_PROTOCOLS (${MAX_ALLOWED_PROTOCOLS}). Got ${changes.approvedApps.length}. On-chain rejects TooManyAllowedProtocols.`));
335
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
+ });
336
608
  const ix = await getQueuePolicyUpdateInstructionAsync({
337
609
  owner,
338
610
  vault,
339
611
  dailySpendingCapUsd: changes.dailyCap ?? null,
340
612
  maxTransactionAmountUsd: changes.maxPerTrade ?? null,
341
- protocolMode: changes.protocolMode
342
- ? mapProtocolMode(changes.protocolMode)
343
- : null,
613
+ protocolMode: newProtocolMode,
344
614
  protocols: changes.approvedApps ?? null,
345
615
  developerFeeRate: changes.developerFeeRate ?? null,
346
616
  maxSlippageBps: changes.maxSlippageBps ?? null,
@@ -350,6 +620,53 @@ export async function queuePolicyUpdate(rpc, vault, owner, network, changes, opt
350
620
  hasProtocolCaps: changes.hasProtocolCaps ?? null,
351
621
  protocolCaps: changes.protocolCaps ?? null,
352
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,
353
670
  });
354
671
  return run(rpc, owner, network, [ix], opts);
355
672
  }
@@ -361,7 +678,11 @@ export async function cancelPendingPolicy(rpc, vault, owner, network, opts) {
361
678
  const ix = await getCancelPendingPolicyInstructionAsync({ owner, vault });
362
679
  return run(rpc, owner, network, [ix], opts);
363
680
  }
364
- 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) {
365
686
  requireValidAddress(agent, "Agent address");
366
687
  requireValidPermissions(permissions);
367
688
  const ix = await getQueueAgentPermissionsUpdateInstructionAsync({
@@ -370,6 +691,29 @@ export async function queueAgentPermissions(rpc, vault, owner, network, agent, p
370
691
  agent,
371
692
  newCapability: Number(permissions),
372
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",
373
717
  });
374
718
  return run(rpc, owner, network, [ix], opts);
375
719
  }
@@ -395,79 +739,6 @@ export async function cancelAgentPermissions(rpc, vault, owner, network, agent,
395
739
  });
396
740
  return run(rpc, owner, network, [ix], opts);
397
741
  }
398
- /**
399
- * Allocate the constraints PDA and write the entries.
400
- *
401
- * Day-0 fix: this used to send only the `create_instruction_constraints`
402
- * instruction, which always failed because the PDA needs to be pre-allocated
403
- * to `InstructionConstraints::SIZE` (35,888 bytes) before the populate handler
404
- * runs. We now send the full 5-instruction chain (allocate + 3 extends +
405
- * populate) in one atomic transaction. See `constraint-builders.ts` for the
406
- * tx-size guardrail (~3 fully-populated entries per call).
407
- */
408
- export async function createConstraints(rpc, vault, owner, network, entries, opts) {
409
- if (!entries || entries.length === 0)
410
- throw toDxError(new Error("Constraint entries must be a non-empty array"));
411
- try {
412
- const [policy] = await getPolicyPDA(vault);
413
- const ixs = await buildCreateConstraintsIxs({
414
- owner,
415
- vault,
416
- policy,
417
- entries,
418
- strictMode: opts?.strictMode ?? true,
419
- });
420
- return run(rpc, owner, network, ixs, opts);
421
- }
422
- catch (err) {
423
- throw toDxError(err);
424
- }
425
- }
426
- /**
427
- * Allocate the pending constraints PDA and queue an update.
428
- *
429
- * Same Day-0 fix as `createConstraints` but targets the `pending_constraints`
430
- * PDA at 35,904 bytes (16 more than `InstructionConstraints` for the extra
431
- * timestamp fields in `PendingConstraintsUpdate`).
432
- */
433
- export async function queueConstraintsUpdate(rpc, vault, owner, network, entries, opts) {
434
- if (!entries || entries.length === 0)
435
- throw toDxError(new Error("Constraint entries must be a non-empty array"));
436
- try {
437
- const [policy] = await getPolicyPDA(vault);
438
- const ixs = await buildQueueConstraintsUpdateIxs({
439
- owner,
440
- vault,
441
- policy,
442
- entries,
443
- strictMode: opts?.strictMode ?? true,
444
- });
445
- return run(rpc, owner, network, ixs, opts);
446
- }
447
- catch (err) {
448
- throw toDxError(err);
449
- }
450
- }
451
- export async function applyConstraintsUpdate(rpc, vault, owner, network, opts) {
452
- const ix = await getApplyConstraintsUpdateInstructionAsync({ owner, vault });
453
- return run(rpc, owner, network, [ix], opts);
454
- }
455
- export async function cancelConstraintsUpdate(rpc, vault, owner, network, opts) {
456
- const ix = await getCancelConstraintsUpdateInstructionAsync({ owner, vault });
457
- return run(rpc, owner, network, [ix], opts);
458
- }
459
- export async function queueCloseConstraints(rpc, vault, owner, network, opts) {
460
- const ix = await getQueueCloseConstraintsInstructionAsync({ owner, vault });
461
- return run(rpc, owner, network, [ix], opts);
462
- }
463
- export async function applyCloseConstraints(rpc, vault, owner, network, opts) {
464
- const ix = await getApplyCloseConstraintsInstructionAsync({ owner, vault });
465
- return run(rpc, owner, network, [ix], opts);
466
- }
467
- export async function cancelCloseConstraints(rpc, vault, owner, network, opts) {
468
- const ix = await getCancelCloseConstraintsInstructionAsync({ owner, vault });
469
- return run(rpc, owner, network, [ix], opts);
470
- }
471
742
  // ─── Post-execution assertions (Phase 2) ─────────────────────────────────────
472
743
  // Composes with pre-execution InstructionConstraints — NOT a replacement.
473
744
  //
@@ -514,10 +785,21 @@ export async function createPostAssertions(rpc, vault, owner, network, entries,
514
785
  // DX_ERROR_CODE_UNMAPPED (7999) and break ISC-19's "pinpoint the bad
515
786
  // entry" promise. See post-assertion-validation.ts docblock.
516
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
+ });
517
798
  const ix = await getCreatePostAssertionsInstructionAsync({
518
799
  owner,
519
800
  vault,
520
801
  entries,
802
+ expectedDigest,
521
803
  });
522
804
  return run(rpc, owner, network, [ix], opts);
523
805
  }
@@ -539,7 +821,136 @@ export async function createPostAssertions(rpc, vault, owner, network, entries,
539
821
  * @returns TxResult with the confirmed signature.
540
822
  */
541
823
  export async function closePostAssertions(rpc, vault, owner, network, opts) {
542
- const ix = await getClosePostAssertionsInstructionAsync({ owner, vault });
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({
832
+ owner,
833
+ vault,
834
+ expectedDigest,
835
+ });
543
836
  return run(rpc, owner, network, [ix], opts);
544
837
  }
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
+ });
886
+ return run(rpc, owner, network, [ix], opts);
887
+ }
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);
910
+ }
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);
935
+ }
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);
955
+ }
545
956
  //# sourceMappingURL=mutations.js.map