@usesigil/kit 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -0
- package/dist/advanced-analytics.d.ts +3 -2
- package/dist/advanced-analytics.d.ts.map +1 -1
- package/dist/advanced-analytics.js +9 -42
- package/dist/advanced-analytics.js.map +1 -1
- package/dist/agent-bootstrap.d.ts +1 -2
- package/dist/agent-bootstrap.d.ts.map +1 -1
- package/dist/agent-bootstrap.js.map +1 -1
- package/dist/agent-errors.d.ts +20 -4
- package/dist/agent-errors.d.ts.map +1 -1
- package/dist/agent-errors.js +864 -367
- package/dist/agent-errors.js.map +1 -1
- package/dist/audit-log.d.ts +101 -0
- package/dist/audit-log.d.ts.map +1 -0
- package/dist/audit-log.js +145 -0
- package/dist/audit-log.js.map +1 -0
- package/dist/caip2-network.d.ts +171 -0
- package/dist/caip2-network.d.ts.map +1 -0
- package/dist/caip2-network.js +202 -0
- package/dist/caip2-network.js.map +1 -0
- package/dist/canonical-encode.d.ts +59 -0
- package/dist/canonical-encode.d.ts.map +1 -0
- package/dist/canonical-encode.js +141 -0
- package/dist/canonical-encode.js.map +1 -0
- package/dist/cosign-helper.d.ts +264 -0
- package/dist/cosign-helper.d.ts.map +1 -0
- package/dist/cosign-helper.js +147 -0
- package/dist/cosign-helper.js.map +1 -0
- package/dist/create-vault.d.ts +92 -0
- package/dist/create-vault.d.ts.map +1 -1
- package/dist/create-vault.js +108 -7
- package/dist/create-vault.js.map +1 -1
- package/dist/dashboard/close-vault.d.ts +110 -0
- package/dist/dashboard/close-vault.d.ts.map +1 -0
- package/dist/dashboard/close-vault.js +165 -0
- package/dist/dashboard/close-vault.js.map +1 -0
- package/dist/dashboard/errors.d.ts +2 -2
- package/dist/dashboard/errors.d.ts.map +1 -1
- package/dist/dashboard/errors.js +11 -7
- package/dist/dashboard/errors.js.map +1 -1
- package/dist/dashboard/index.d.ts +190 -34
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +282 -52
- package/dist/dashboard/index.js.map +1 -1
- package/dist/dashboard/mutations.d.ts +153 -24
- package/dist/dashboard/mutations.d.ts.map +1 -1
- package/dist/dashboard/mutations.js +680 -114
- package/dist/dashboard/mutations.js.map +1 -1
- package/dist/dashboard/post-assertion-validation.d.ts +1 -1
- package/dist/dashboard/post-assertion-validation.d.ts.map +1 -1
- package/dist/dashboard/post-assertion-validation.js +169 -48
- package/dist/dashboard/post-assertion-validation.js.map +1 -1
- package/dist/dashboard/reads.d.ts +3 -4
- package/dist/dashboard/reads.d.ts.map +1 -1
- package/dist/dashboard/reads.js +11 -22
- package/dist/dashboard/reads.js.map +1 -1
- package/dist/dashboard/types.d.ts +56 -19
- package/dist/dashboard/types.d.ts.map +1 -1
- package/dist/errors/agent-errors.generated.d.ts +21 -0
- package/dist/errors/agent-errors.generated.d.ts.map +1 -0
- package/dist/errors/agent-errors.generated.js +134 -0
- package/dist/errors/agent-errors.generated.js.map +1 -0
- package/dist/errors/codes.d.ts +21 -2
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +19 -0
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/context.d.ts +9 -1
- package/dist/errors/context.d.ts.map +1 -1
- package/dist/event-analytics.d.ts +1 -3
- package/dist/event-analytics.d.ts.map +1 -1
- package/dist/event-analytics.js +28 -81
- package/dist/event-analytics.js.map +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +23 -14
- package/dist/events.js.map +1 -1
- package/dist/generated/accounts/agentSpendOverlay.d.ts +60 -0
- package/dist/generated/accounts/agentSpendOverlay.d.ts.map +1 -1
- package/dist/generated/accounts/agentSpendOverlay.js +6 -2
- package/dist/generated/accounts/agentSpendOverlay.js.map +1 -1
- package/dist/generated/accounts/agentVault.d.ts +168 -4
- package/dist/generated/accounts/agentVault.d.ts.map +1 -1
- package/dist/generated/accounts/agentVault.js +11 -3
- package/dist/generated/accounts/agentVault.js.map +1 -1
- package/dist/generated/accounts/auditLogRejected.d.ts +66 -0
- package/dist/generated/accounts/auditLogRejected.d.ts.map +1 -0
- package/dist/generated/accounts/auditLogRejected.js +68 -0
- package/dist/generated/accounts/auditLogRejected.js.map +1 -0
- package/dist/generated/accounts/auditLogSuccess.d.ts +78 -0
- package/dist/generated/accounts/auditLogSuccess.d.ts.map +1 -0
- package/dist/generated/accounts/auditLogSuccess.js +68 -0
- package/dist/generated/accounts/auditLogSuccess.js.map +1 -0
- package/dist/generated/accounts/index.d.ts +4 -4
- package/dist/generated/accounts/index.d.ts.map +1 -1
- package/dist/generated/accounts/index.js +4 -4
- package/dist/generated/accounts/index.js.map +1 -1
- package/dist/generated/accounts/pendingAgentGrant.d.ts +199 -0
- package/dist/generated/accounts/pendingAgentGrant.d.ts.map +1 -0
- package/dist/generated/accounts/pendingAgentGrant.js +75 -0
- package/dist/generated/accounts/pendingAgentGrant.js.map +1 -0
- package/dist/generated/accounts/pendingAgentPermissionsUpdate.d.ts +64 -0
- package/dist/generated/accounts/pendingAgentPermissionsUpdate.d.ts.map +1 -1
- package/dist/generated/accounts/pendingAgentPermissionsUpdate.js +7 -1
- package/dist/generated/accounts/pendingAgentPermissionsUpdate.js.map +1 -1
- package/dist/generated/accounts/pendingOwnershipTransfer.d.ts +131 -0
- package/dist/generated/accounts/pendingOwnershipTransfer.d.ts.map +1 -0
- package/dist/generated/accounts/pendingOwnershipTransfer.js +76 -0
- package/dist/generated/accounts/pendingOwnershipTransfer.js.map +1 -0
- package/dist/generated/accounts/pendingPolicyUpdate.d.ts +200 -4
- package/dist/generated/accounts/pendingPolicyUpdate.d.ts.map +1 -1
- package/dist/generated/accounts/pendingPolicyUpdate.js +19 -1
- package/dist/generated/accounts/pendingPolicyUpdate.js.map +1 -1
- package/dist/generated/accounts/policyConfig.d.ts +479 -36
- package/dist/generated/accounts/policyConfig.d.ts.map +1 -1
- package/dist/generated/accounts/policyConfig.js +30 -3
- package/dist/generated/accounts/policyConfig.js.map +1 -1
- package/dist/generated/accounts/postExecutionAssertions.d.ts +2 -2
- package/dist/generated/accounts/postExecutionAssertions.d.ts.map +1 -1
- package/dist/generated/accounts/postExecutionAssertions.js +3 -3
- package/dist/generated/accounts/sessionAuthority.d.ts +140 -12
- package/dist/generated/accounts/sessionAuthority.d.ts.map +1 -1
- package/dist/generated/accounts/sessionAuthority.js +9 -7
- package/dist/generated/accounts/sessionAuthority.js.map +1 -1
- package/dist/generated/accounts/spendTracker.d.ts +83 -3
- package/dist/generated/accounts/spendTracker.d.ts.map +1 -1
- package/dist/generated/accounts/spendTracker.js +14 -2
- package/dist/generated/accounts/spendTracker.js.map +1 -1
- package/dist/generated/errors/sigil.d.ts +131 -83
- package/dist/generated/errors/sigil.d.ts.map +1 -1
- package/dist/generated/errors/sigil.js +178 -106
- package/dist/generated/errors/sigil.js.map +1 -1
- package/dist/generated/event-discriminators.d.ts.map +1 -1
- package/dist/generated/event-discriminators.js +11 -14
- package/dist/generated/event-discriminators.js.map +1 -1
- package/dist/generated/instructions/acceptOwnershipTransfer.d.ts +142 -0
- package/dist/generated/instructions/acceptOwnershipTransfer.d.ts.map +1 -0
- package/dist/generated/instructions/acceptOwnershipTransfer.js +171 -0
- package/dist/generated/instructions/acceptOwnershipTransfer.js.map +1 -0
- package/dist/generated/instructions/acceptOwnershipTransferMultisig.d.ts +85 -0
- package/dist/generated/instructions/acceptOwnershipTransferMultisig.d.ts.map +1 -0
- package/dist/generated/instructions/acceptOwnershipTransferMultisig.js +171 -0
- package/dist/generated/instructions/acceptOwnershipTransferMultisig.js.map +1 -0
- package/dist/generated/instructions/applyAgentGrant.d.ts +100 -0
- package/dist/generated/instructions/applyAgentGrant.d.ts.map +1 -0
- package/dist/generated/instructions/{applyConstraintsUpdate.js → applyAgentGrant.js} +66 -42
- package/dist/generated/instructions/applyAgentGrant.js.map +1 -0
- package/dist/generated/instructions/applyAgentPermissionsUpdate.d.ts +31 -8
- package/dist/generated/instructions/applyAgentPermissionsUpdate.d.ts.map +1 -1
- package/dist/generated/instructions/applyAgentPermissionsUpdate.js +38 -2
- package/dist/generated/instructions/applyAgentPermissionsUpdate.js.map +1 -1
- package/dist/generated/instructions/applyPendingPolicy.d.ts +18 -7
- package/dist/generated/instructions/applyPendingPolicy.d.ts.map +1 -1
- package/dist/generated/instructions/applyPendingPolicy.js +38 -2
- package/dist/generated/instructions/applyPendingPolicy.js.map +1 -1
- package/dist/generated/instructions/cancelAgentGrant.d.ts +106 -0
- package/dist/generated/instructions/cancelAgentGrant.d.ts.map +1 -0
- package/dist/generated/instructions/{allocatePendingConstraintsPda.js → cancelAgentGrant.js} +54 -42
- package/dist/generated/instructions/cancelAgentGrant.js.map +1 -0
- package/dist/generated/instructions/cancelOwnershipTransfer.d.ts +121 -0
- package/dist/generated/instructions/cancelOwnershipTransfer.d.ts.map +1 -0
- package/dist/generated/instructions/{queueCloseConstraints.js → cancelOwnershipTransfer.js} +58 -44
- package/dist/generated/instructions/cancelOwnershipTransfer.js.map +1 -0
- package/dist/generated/instructions/closePostAssertions.d.ts +6 -1
- package/dist/generated/instructions/closePostAssertions.d.ts.map +1 -1
- package/dist/generated/instructions/closePostAssertions.js +11 -3
- package/dist/generated/instructions/closePostAssertions.js.map +1 -1
- package/dist/generated/instructions/closeVault.d.ts +40 -8
- package/dist/generated/instructions/closeVault.d.ts.map +1 -1
- package/dist/generated/instructions/closeVault.js +40 -2
- package/dist/generated/instructions/closeVault.js.map +1 -1
- package/dist/generated/instructions/createPostAssertions.d.ts +4 -0
- package/dist/generated/instructions/createPostAssertions.d.ts.map +1 -1
- package/dist/generated/instructions/createPostAssertions.js +2 -0
- package/dist/generated/instructions/createPostAssertions.js.map +1 -1
- package/dist/generated/instructions/depositFunds.d.ts +21 -10
- package/dist/generated/instructions/depositFunds.d.ts.map +1 -1
- package/dist/generated/instructions/depositFunds.js +37 -2
- package/dist/generated/instructions/depositFunds.js.map +1 -1
- package/dist/generated/instructions/finalizeSession.d.ts +49 -7
- package/dist/generated/instructions/finalizeSession.d.ts.map +1 -1
- package/dist/generated/instructions/finalizeSession.js +59 -2
- package/dist/generated/instructions/finalizeSession.js.map +1 -1
- package/dist/generated/instructions/freezeVault.d.ts +36 -5
- package/dist/generated/instructions/freezeVault.d.ts.map +1 -1
- package/dist/generated/instructions/freezeVault.js +65 -4
- package/dist/generated/instructions/freezeVault.js.map +1 -1
- package/dist/generated/instructions/index.d.ts +10 -15
- package/dist/generated/instructions/index.d.ts.map +1 -1
- package/dist/generated/instructions/index.js +10 -15
- package/dist/generated/instructions/index.js.map +1 -1
- package/dist/generated/instructions/initializeVault.d.ts +79 -9
- package/dist/generated/instructions/initializeVault.d.ts.map +1 -1
- package/dist/generated/instructions/initializeVault.js +57 -3
- package/dist/generated/instructions/initializeVault.js.map +1 -1
- package/dist/generated/instructions/initiateOwnershipTransfer.d.ts +106 -0
- package/dist/generated/instructions/initiateOwnershipTransfer.d.ts.map +1 -0
- package/dist/generated/instructions/initiateOwnershipTransfer.js +181 -0
- package/dist/generated/instructions/initiateOwnershipTransfer.js.map +1 -0
- package/dist/generated/instructions/pauseAgent.d.ts +49 -5
- package/dist/generated/instructions/pauseAgent.d.ts.map +1 -1
- package/dist/generated/instructions/pauseAgent.js +80 -5
- package/dist/generated/instructions/pauseAgent.js.map +1 -1
- package/dist/generated/instructions/promoteGraylistDestination.d.ts +56 -0
- package/dist/generated/instructions/promoteGraylistDestination.d.ts.map +1 -0
- package/dist/generated/instructions/{createInstructionConstraints.js → promoteGraylistDestination.js} +23 -40
- package/dist/generated/instructions/promoteGraylistDestination.js.map +1 -0
- package/dist/generated/instructions/queueAgentGrant.d.ts +113 -0
- package/dist/generated/instructions/queueAgentGrant.d.ts.map +1 -0
- package/dist/generated/instructions/queueAgentGrant.js +181 -0
- package/dist/generated/instructions/queueAgentGrant.js.map +1 -0
- package/dist/generated/instructions/queueAgentPermissionsUpdate.d.ts +8 -0
- package/dist/generated/instructions/queueAgentPermissionsUpdate.d.ts.map +1 -1
- package/dist/generated/instructions/queueAgentPermissionsUpdate.js +4 -0
- package/dist/generated/instructions/queueAgentPermissionsUpdate.js.map +1 -1
- package/dist/generated/instructions/queuePolicyUpdate.d.ts +32 -0
- package/dist/generated/instructions/queuePolicyUpdate.d.ts.map +1 -1
- package/dist/generated/instructions/queuePolicyUpdate.js +17 -1
- package/dist/generated/instructions/queuePolicyUpdate.js.map +1 -1
- package/dist/generated/instructions/reactivateVault.d.ts +71 -5
- package/dist/generated/instructions/reactivateVault.d.ts.map +1 -1
- package/dist/generated/instructions/reactivateVault.js +80 -5
- package/dist/generated/instructions/reactivateVault.js.map +1 -1
- package/dist/generated/instructions/recordAgentViolation.d.ts +89 -0
- package/dist/generated/instructions/recordAgentViolation.d.ts.map +1 -0
- package/dist/generated/instructions/recordAgentViolation.js +152 -0
- package/dist/generated/instructions/recordAgentViolation.js.map +1 -0
- package/dist/generated/instructions/registerAgent.d.ts +84 -6
- package/dist/generated/instructions/registerAgent.d.ts.map +1 -1
- package/dist/generated/instructions/registerAgent.js +81 -4
- package/dist/generated/instructions/registerAgent.js.map +1 -1
- package/dist/generated/instructions/revokeAgent.d.ts +49 -6
- package/dist/generated/instructions/revokeAgent.d.ts.map +1 -1
- package/dist/generated/instructions/revokeAgent.js +81 -4
- package/dist/generated/instructions/revokeAgent.js.map +1 -1
- package/dist/generated/instructions/setObserveOnly.d.ts +56 -0
- package/dist/generated/instructions/setObserveOnly.d.ts.map +1 -0
- package/dist/generated/instructions/setObserveOnly.js +111 -0
- package/dist/generated/instructions/setObserveOnly.js.map +1 -0
- package/dist/generated/instructions/unpauseAgent.d.ts +46 -5
- package/dist/generated/instructions/unpauseAgent.d.ts.map +1 -1
- package/dist/generated/instructions/unpauseAgent.js +80 -5
- package/dist/generated/instructions/unpauseAgent.js.map +1 -1
- package/dist/generated/instructions/validateAndAuthorize.d.ts +29 -0
- package/dist/generated/instructions/validateAndAuthorize.d.ts.map +1 -1
- package/dist/generated/instructions/validateAndAuthorize.js +4 -0
- package/dist/generated/instructions/validateAndAuthorize.js.map +1 -1
- package/dist/generated/instructions/withdrawFunds.d.ts +53 -11
- package/dist/generated/instructions/withdrawFunds.d.ts.map +1 -1
- package/dist/generated/instructions/withdrawFunds.js +51 -2
- package/dist/generated/instructions/withdrawFunds.js.map +1 -1
- package/dist/generated/programs/sigil.d.ts +79 -99
- package/dist/generated/programs/sigil.d.ts.map +1 -1
- package/dist/generated/programs/sigil.js +139 -199
- package/dist/generated/programs/sigil.js.map +1 -1
- package/dist/generated/types/actionAuthorized.d.ts +0 -2
- package/dist/generated/types/actionAuthorized.d.ts.map +1 -1
- package/dist/generated/types/actionAuthorized.js +0 -2
- package/dist/generated/types/actionAuthorized.js.map +1 -1
- package/dist/generated/types/agentAutoRevoked.d.ts +31 -0
- package/dist/generated/types/agentAutoRevoked.d.ts.map +1 -0
- package/dist/generated/types/{orphanConstraintsPdaCleaned.js → agentAutoRevoked.js} +12 -8
- package/dist/generated/types/agentAutoRevoked.js.map +1 -0
- package/dist/generated/types/agentEntry.d.ts +48 -0
- package/dist/generated/types/agentEntry.d.ts.map +1 -1
- package/dist/generated/types/agentEntry.js +4 -2
- package/dist/generated/types/agentEntry.js.map +1 -1
- package/dist/generated/types/agentGrantApplied.d.ts +38 -0
- package/dist/generated/types/agentGrantApplied.d.ts.map +1 -0
- package/dist/generated/types/agentGrantApplied.js +34 -0
- package/dist/generated/types/agentGrantApplied.js.map +1 -0
- package/dist/generated/types/agentGrantCancelled.d.ts +33 -0
- package/dist/generated/types/agentGrantCancelled.d.ts.map +1 -0
- package/dist/generated/types/agentGrantCancelled.js +28 -0
- package/dist/generated/types/agentGrantCancelled.js.map +1 -0
- package/dist/generated/types/agentGrantQueued.d.ts +38 -0
- package/dist/generated/types/agentGrantQueued.d.ts.map +1 -0
- package/dist/generated/types/agentGrantQueued.js +32 -0
- package/dist/generated/types/agentGrantQueued.js.map +1 -0
- package/dist/generated/types/auditEntry.d.ts +120 -0
- package/dist/generated/types/auditEntry.d.ts.map +1 -0
- package/dist/generated/types/auditEntry.js +34 -0
- package/dist/generated/types/auditEntry.js.map +1 -0
- package/dist/generated/types/destinationGraylistEntry.d.ts +32 -0
- package/dist/generated/types/destinationGraylistEntry.d.ts.map +1 -0
- package/dist/generated/types/destinationGraylistEntry.js +24 -0
- package/dist/generated/types/destinationGraylistEntry.js.map +1 -0
- package/dist/generated/types/graylistEntered.d.ts +31 -0
- package/dist/generated/types/graylistEntered.d.ts.map +1 -0
- package/dist/generated/types/graylistEntered.js +30 -0
- package/dist/generated/types/graylistEntered.js.map +1 -0
- package/dist/generated/types/graylistPromoted.d.ts +29 -0
- package/dist/generated/types/graylistPromoted.d.ts.map +1 -0
- package/dist/generated/types/graylistPromoted.js +28 -0
- package/dist/generated/types/graylistPromoted.js.map +1 -0
- package/dist/generated/types/index.d.ts +13 -22
- package/dist/generated/types/index.d.ts.map +1 -1
- package/dist/generated/types/index.js +13 -22
- package/dist/generated/types/index.js.map +1 -1
- package/dist/generated/types/observeOnlyChanged.d.ts +33 -0
- package/dist/generated/types/observeOnlyChanged.d.ts.map +1 -0
- package/dist/generated/types/observeOnlyChanged.js +32 -0
- package/dist/generated/types/observeOnlyChanged.js.map +1 -0
- package/dist/generated/types/ownershipTransferAccepted.d.ts +32 -0
- package/dist/generated/types/ownershipTransferAccepted.d.ts.map +1 -0
- package/dist/generated/types/ownershipTransferAccepted.js +30 -0
- package/dist/generated/types/ownershipTransferAccepted.js.map +1 -0
- package/dist/generated/types/ownershipTransferCancelled.d.ts +29 -0
- package/dist/generated/types/ownershipTransferCancelled.d.ts.map +1 -0
- package/dist/generated/types/ownershipTransferCancelled.js +28 -0
- package/dist/generated/types/ownershipTransferCancelled.js.map +1 -0
- package/dist/generated/types/ownershipTransferInitiated.d.ts +33 -0
- package/dist/generated/types/ownershipTransferInitiated.d.ts.map +1 -0
- package/dist/generated/types/ownershipTransferInitiated.js +30 -0
- package/dist/generated/types/ownershipTransferInitiated.js.map +1 -0
- package/dist/generated/types/perRecipientCounter.d.ts +61 -0
- package/dist/generated/types/perRecipientCounter.d.ts.map +1 -0
- package/dist/generated/types/perRecipientCounter.js +26 -0
- package/dist/generated/types/perRecipientCounter.js.map +1 -0
- package/dist/generated/types/postAssertionEntry.d.ts +14 -7
- package/dist/generated/types/postAssertionEntry.d.ts.map +1 -1
- package/dist/generated/types/postAssertionEntry.js +5 -7
- package/dist/generated/types/postAssertionEntry.js.map +1 -1
- package/dist/generated/types/postAssertionEntryZC.d.ts +53 -22
- package/dist/generated/types/postAssertionEntryZC.d.ts.map +1 -1
- package/dist/generated/types/postAssertionEntryZC.js +4 -6
- package/dist/generated/types/postAssertionEntryZC.js.map +1 -1
- package/dist/generated/types/sessionFinalized.d.ts +0 -4
- package/dist/generated/types/sessionFinalized.d.ts.map +1 -1
- package/dist/generated/types/sessionFinalized.js +0 -2
- package/dist/generated/types/sessionFinalized.js.map +1 -1
- package/dist/generated/types/vaultFrozen.d.ts +14 -0
- package/dist/generated/types/vaultFrozen.d.ts.map +1 -1
- package/dist/generated/types/vaultFrozen.js +2 -0
- package/dist/generated/types/vaultFrozen.js.map +1 -1
- package/dist/index.d.ts +31 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -11
- package/dist/index.js.map +1 -1
- package/dist/inspector.d.ts +0 -23
- package/dist/inspector.d.ts.map +1 -1
- package/dist/inspector.js +0 -52
- package/dist/inspector.js.map +1 -1
- package/dist/kit-adapter.d.ts +1 -1
- package/dist/kit-adapter.d.ts.map +1 -1
- package/dist/kit-adapter.js +1 -1
- package/dist/kit-adapter.js.map +1 -1
- package/dist/multisig-detection.d.ts +83 -0
- package/dist/multisig-detection.d.ts.map +1 -0
- package/dist/multisig-detection.js +128 -0
- package/dist/multisig-detection.js.map +1 -0
- package/dist/ownership-transfer.d.ts +79 -0
- package/dist/ownership-transfer.d.ts.map +1 -0
- package/dist/ownership-transfer.js +66 -0
- package/dist/ownership-transfer.js.map +1 -0
- package/dist/policy/compute-agent-perms-cosign-digest.d.ts +51 -0
- package/dist/policy/compute-agent-perms-cosign-digest.d.ts.map +1 -0
- package/dist/policy/compute-agent-perms-cosign-digest.js +55 -0
- package/dist/policy/compute-agent-perms-cosign-digest.js.map +1 -0
- package/dist/policy/compute-cosign-digest.d.ts +193 -0
- package/dist/policy/compute-cosign-digest.d.ts.map +1 -0
- package/dist/policy/compute-cosign-digest.js +318 -0
- package/dist/policy/compute-cosign-digest.js.map +1 -0
- package/dist/policy/compute-policy-preview-digest.d.ts +279 -0
- package/dist/policy/compute-policy-preview-digest.d.ts.map +1 -0
- package/dist/policy/compute-policy-preview-digest.js +373 -0
- package/dist/policy/compute-policy-preview-digest.js.map +1 -0
- package/dist/policy-attestation.d.ts +51 -0
- package/dist/policy-attestation.d.ts.map +1 -0
- package/dist/policy-attestation.js +43 -0
- package/dist/policy-attestation.js.map +1 -0
- package/dist/preview-create-vault.d.ts.map +1 -1
- package/dist/preview-create-vault.js +37 -16
- package/dist/preview-create-vault.js.map +1 -1
- package/dist/resolve-accounts.d.ts +75 -10
- package/dist/resolve-accounts.d.ts.map +1 -1
- package/dist/resolve-accounts.js +68 -32
- package/dist/resolve-accounts.js.map +1 -1
- package/dist/rpc-helpers.d.ts +29 -3
- package/dist/rpc-helpers.d.ts.map +1 -1
- package/dist/rpc-helpers.js +51 -12
- package/dist/rpc-helpers.js.map +1 -1
- package/dist/seal/intent-digest.d.ts +195 -0
- package/dist/seal/intent-digest.d.ts.map +1 -0
- package/dist/seal/intent-digest.js +372 -0
- package/dist/seal/intent-digest.js.map +1 -0
- package/dist/seal.d.ts +166 -3
- package/dist/seal.d.ts.map +1 -1
- package/dist/seal.js +428 -32
- package/dist/seal.js.map +1 -1
- package/dist/security-analytics.d.ts +3 -3
- package/dist/security-analytics.d.ts.map +1 -1
- package/dist/security-analytics.js +13 -128
- package/dist/security-analytics.js.map +1 -1
- package/dist/session-mint.d.ts +72 -0
- package/dist/session-mint.d.ts.map +1 -0
- package/dist/session-mint.js +59 -0
- package/dist/session-mint.js.map +1 -0
- package/dist/simulation.d.ts +19 -0
- package/dist/simulation.d.ts.map +1 -1
- package/dist/simulation.js +187 -95
- package/dist/simulation.js.map +1 -1
- package/dist/squads-detection.d.ts +135 -0
- package/dist/squads-detection.d.ts.map +1 -0
- package/dist/squads-detection.js +124 -0
- package/dist/squads-detection.js.map +1 -0
- package/dist/state-resolver.d.ts +0 -16
- package/dist/state-resolver.d.ts.map +1 -1
- package/dist/state-resolver.js +162 -97
- package/dist/state-resolver.js.map +1 -1
- package/dist/testing/devnet.d.ts +40 -1
- package/dist/testing/devnet.d.ts.map +1 -1
- package/dist/testing/devnet.js +333 -44
- package/dist/testing/devnet.js.map +1 -1
- package/dist/testing/errors/expect.d.ts +1 -1
- package/dist/testing/errors/expect.js +1 -1
- package/dist/testing/errors/names.generated.d.ts +82 -58
- package/dist/testing/errors/names.generated.d.ts.map +1 -1
- package/dist/testing/errors/names.generated.js +83 -59
- package/dist/testing/errors/names.generated.js.map +1 -1
- package/dist/testing/mock-rpc.d.ts +8 -0
- package/dist/testing/mock-rpc.d.ts.map +1 -1
- package/dist/testing/mock-rpc.js +13 -0
- package/dist/testing/mock-rpc.js.map +1 -1
- package/dist/testing/mock-state.d.ts +2 -0
- package/dist/testing/mock-state.d.ts.map +1 -1
- package/dist/testing/mock-state.js +43 -4
- package/dist/testing/mock-state.js.map +1 -1
- package/dist/types.d.ts +5 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +11 -69
- package/dist/types.js.map +1 -1
- package/dist/vault-analytics.d.ts +0 -2
- package/dist/vault-analytics.d.ts.map +1 -1
- package/dist/vault-analytics.js +1 -9
- package/dist/vault-analytics.js.map +1 -1
- package/package.json +7 -12
- package/dist/constraints/index.d.ts +0 -23
- package/dist/constraints/index.d.ts.map +0 -1
- package/dist/constraints/index.js +0 -24
- package/dist/constraints/index.js.map +0 -1
- package/dist/dashboard/constraint-builders.d.ts +0 -82
- package/dist/dashboard/constraint-builders.d.ts.map +0 -1
- package/dist/dashboard/constraint-builders.js +0 -204
- package/dist/dashboard/constraint-builders.js.map +0 -1
- package/dist/dashboard/constraint-reads.d.ts +0 -50
- package/dist/dashboard/constraint-reads.d.ts.map +0 -1
- package/dist/dashboard/constraint-reads.js +0 -119
- package/dist/dashboard/constraint-reads.js.map +0 -1
- package/dist/generated/accounts/escrowDeposit.d.ts +0 -50
- package/dist/generated/accounts/escrowDeposit.d.ts.map +0 -1
- package/dist/generated/accounts/escrowDeposit.js +0 -76
- package/dist/generated/accounts/escrowDeposit.js.map +0 -1
- package/dist/generated/accounts/instructionConstraints.d.ts +0 -46
- package/dist/generated/accounts/instructionConstraints.d.ts.map +0 -1
- package/dist/generated/accounts/instructionConstraints.js +0 -73
- package/dist/generated/accounts/instructionConstraints.js.map +0 -1
- package/dist/generated/accounts/pendingCloseConstraints.d.ts +0 -49
- package/dist/generated/accounts/pendingCloseConstraints.d.ts.map +0 -1
- package/dist/generated/accounts/pendingCloseConstraints.js +0 -68
- package/dist/generated/accounts/pendingCloseConstraints.js.map +0 -1
- package/dist/generated/accounts/pendingConstraintsUpdate.d.ts +0 -76
- package/dist/generated/accounts/pendingConstraintsUpdate.d.ts.map +0 -1
- package/dist/generated/accounts/pendingConstraintsUpdate.js +0 -77
- package/dist/generated/accounts/pendingConstraintsUpdate.js.map +0 -1
- package/dist/generated/instructions/allocateConstraintsPda.d.ts +0 -62
- package/dist/generated/instructions/allocateConstraintsPda.d.ts.map +0 -1
- package/dist/generated/instructions/allocateConstraintsPda.js +0 -134
- package/dist/generated/instructions/allocateConstraintsPda.js.map +0 -1
- package/dist/generated/instructions/allocatePendingConstraintsPda.d.ts +0 -66
- package/dist/generated/instructions/allocatePendingConstraintsPda.d.ts.map +0 -1
- package/dist/generated/instructions/allocatePendingConstraintsPda.js.map +0 -1
- package/dist/generated/instructions/applyCloseConstraints.d.ts +0 -59
- package/dist/generated/instructions/applyCloseConstraints.d.ts.map +0 -1
- package/dist/generated/instructions/applyCloseConstraints.js +0 -143
- package/dist/generated/instructions/applyCloseConstraints.js.map +0 -1
- package/dist/generated/instructions/applyConstraintsUpdate.d.ts +0 -62
- package/dist/generated/instructions/applyConstraintsUpdate.d.ts.map +0 -1
- package/dist/generated/instructions/applyConstraintsUpdate.js.map +0 -1
- package/dist/generated/instructions/cancelCloseConstraints.d.ts +0 -51
- package/dist/generated/instructions/cancelCloseConstraints.d.ts.map +0 -1
- package/dist/generated/instructions/cancelCloseConstraints.js +0 -115
- package/dist/generated/instructions/cancelCloseConstraints.js.map +0 -1
- package/dist/generated/instructions/cancelConstraintsUpdate.d.ts +0 -51
- package/dist/generated/instructions/cancelConstraintsUpdate.d.ts.map +0 -1
- package/dist/generated/instructions/cancelConstraintsUpdate.js +0 -115
- package/dist/generated/instructions/cancelConstraintsUpdate.js.map +0 -1
- package/dist/generated/instructions/cleanupOrphanConstraintsPda.d.ts +0 -67
- package/dist/generated/instructions/cleanupOrphanConstraintsPda.d.ts.map +0 -1
- package/dist/generated/instructions/cleanupOrphanConstraintsPda.js +0 -120
- package/dist/generated/instructions/cleanupOrphanConstraintsPda.js.map +0 -1
- package/dist/generated/instructions/closeSettledEscrow.d.ts +0 -72
- package/dist/generated/instructions/closeSettledEscrow.d.ts.map +0 -1
- package/dist/generated/instructions/closeSettledEscrow.js +0 -127
- package/dist/generated/instructions/closeSettledEscrow.js.map +0 -1
- package/dist/generated/instructions/createEscrow.d.ts +0 -131
- package/dist/generated/instructions/createEscrow.d.ts.map +0 -1
- package/dist/generated/instructions/createEscrow.js +0 -272
- package/dist/generated/instructions/createEscrow.js.map +0 -1
- package/dist/generated/instructions/createInstructionConstraints.d.ts +0 -68
- package/dist/generated/instructions/createInstructionConstraints.d.ts.map +0 -1
- package/dist/generated/instructions/createInstructionConstraints.js.map +0 -1
- package/dist/generated/instructions/extendPda.d.ts +0 -52
- package/dist/generated/instructions/extendPda.d.ts.map +0 -1
- package/dist/generated/instructions/extendPda.js +0 -86
- package/dist/generated/instructions/extendPda.js.map +0 -1
- package/dist/generated/instructions/queueCloseConstraints.d.ts +0 -66
- package/dist/generated/instructions/queueCloseConstraints.d.ts.map +0 -1
- package/dist/generated/instructions/queueCloseConstraints.js.map +0 -1
- package/dist/generated/instructions/queueConstraintsUpdate.d.ts +0 -75
- package/dist/generated/instructions/queueConstraintsUpdate.d.ts.map +0 -1
- package/dist/generated/instructions/queueConstraintsUpdate.js +0 -154
- package/dist/generated/instructions/queueConstraintsUpdate.js.map +0 -1
- package/dist/generated/instructions/refundEscrow.d.ts +0 -74
- package/dist/generated/instructions/refundEscrow.d.ts.map +0 -1
- package/dist/generated/instructions/refundEscrow.js +0 -142
- package/dist/generated/instructions/refundEscrow.js.map +0 -1
- package/dist/generated/instructions/settleEscrow.d.ts +0 -80
- package/dist/generated/instructions/settleEscrow.d.ts.map +0 -1
- package/dist/generated/instructions/settleEscrow.js +0 -173
- package/dist/generated/instructions/settleEscrow.js.map +0 -1
- package/dist/generated/types/accountConstraint.d.ts +0 -33
- package/dist/generated/types/accountConstraint.d.ts.map +0 -1
- package/dist/generated/types/accountConstraint.js +0 -26
- package/dist/generated/types/accountConstraint.js.map +0 -1
- package/dist/generated/types/accountConstraintZC.d.ts +0 -25
- package/dist/generated/types/accountConstraintZC.d.ts.map +0 -1
- package/dist/generated/types/accountConstraintZC.js +0 -28
- package/dist/generated/types/accountConstraintZC.js.map +0 -1
- package/dist/generated/types/closeConstraintsApplied.d.ts +0 -20
- package/dist/generated/types/closeConstraintsApplied.d.ts.map +0 -1
- package/dist/generated/types/closeConstraintsApplied.js +0 -24
- package/dist/generated/types/closeConstraintsApplied.js.map +0 -1
- package/dist/generated/types/closeConstraintsCancelled.d.ts +0 -16
- package/dist/generated/types/closeConstraintsCancelled.d.ts.map +0 -1
- package/dist/generated/types/closeConstraintsCancelled.js +0 -18
- package/dist/generated/types/closeConstraintsCancelled.js.map +0 -1
- package/dist/generated/types/closeConstraintsQueued.d.ts +0 -20
- package/dist/generated/types/closeConstraintsQueued.d.ts.map +0 -1
- package/dist/generated/types/closeConstraintsQueued.js +0 -24
- package/dist/generated/types/closeConstraintsQueued.js.map +0 -1
- package/dist/generated/types/constraintEntry.d.ts +0 -35
- package/dist/generated/types/constraintEntry.d.ts.map +0 -1
- package/dist/generated/types/constraintEntry.js +0 -29
- package/dist/generated/types/constraintEntry.js.map +0 -1
- package/dist/generated/types/constraintEntryZC.d.ts +0 -73
- package/dist/generated/types/constraintEntryZC.d.ts.map +0 -1
- package/dist/generated/types/constraintEntryZC.js +0 -49
- package/dist/generated/types/constraintEntryZC.js.map +0 -1
- package/dist/generated/types/constraintOperator.d.ts +0 -22
- package/dist/generated/types/constraintOperator.d.ts.map +0 -1
- package/dist/generated/types/constraintOperator.js +0 -28
- package/dist/generated/types/constraintOperator.js.map +0 -1
- package/dist/generated/types/constraintsChangeApplied.d.ts +0 -30
- package/dist/generated/types/constraintsChangeApplied.d.ts.map +0 -1
- package/dist/generated/types/constraintsChangeApplied.js +0 -32
- package/dist/generated/types/constraintsChangeApplied.js.map +0 -1
- package/dist/generated/types/constraintsChangeCancelled.d.ts +0 -16
- package/dist/generated/types/constraintsChangeCancelled.d.ts.map +0 -1
- package/dist/generated/types/constraintsChangeCancelled.js +0 -18
- package/dist/generated/types/constraintsChangeCancelled.js.map +0 -1
- package/dist/generated/types/constraintsChangeQueued.d.ts +0 -30
- package/dist/generated/types/constraintsChangeQueued.d.ts.map +0 -1
- package/dist/generated/types/constraintsChangeQueued.js +0 -32
- package/dist/generated/types/constraintsChangeQueued.js.map +0 -1
- package/dist/generated/types/dataConstraint.d.ts +0 -23
- package/dist/generated/types/dataConstraint.d.ts.map +0 -1
- package/dist/generated/types/dataConstraint.js +0 -27
- package/dist/generated/types/dataConstraint.js.map +0 -1
- package/dist/generated/types/dataConstraintZC.d.ts +0 -20
- package/dist/generated/types/dataConstraintZC.d.ts.map +0 -1
- package/dist/generated/types/dataConstraintZC.js +0 -30
- package/dist/generated/types/dataConstraintZC.js.map +0 -1
- package/dist/generated/types/discriminatorFormat.d.ts +0 -25
- package/dist/generated/types/discriminatorFormat.d.ts.map +0 -1
- package/dist/generated/types/discriminatorFormat.js +0 -31
- package/dist/generated/types/discriminatorFormat.js.map +0 -1
- package/dist/generated/types/escrowCreated.d.ts +0 -30
- package/dist/generated/types/escrowCreated.d.ts.map +0 -1
- package/dist/generated/types/escrowCreated.js +0 -34
- package/dist/generated/types/escrowCreated.js.map +0 -1
- package/dist/generated/types/escrowRefunded.d.ts +0 -26
- package/dist/generated/types/escrowRefunded.d.ts.map +0 -1
- package/dist/generated/types/escrowRefunded.js +0 -30
- package/dist/generated/types/escrowRefunded.js.map +0 -1
- package/dist/generated/types/escrowSettled.d.ts +0 -26
- package/dist/generated/types/escrowSettled.d.ts.map +0 -1
- package/dist/generated/types/escrowSettled.js +0 -30
- package/dist/generated/types/escrowSettled.js.map +0 -1
- package/dist/generated/types/escrowStatus.d.ts +0 -18
- package/dist/generated/types/escrowStatus.d.ts.map +0 -1
- package/dist/generated/types/escrowStatus.js +0 -24
- package/dist/generated/types/escrowStatus.js.map +0 -1
- package/dist/generated/types/instructionConstraintsCreated.d.ts +0 -34
- package/dist/generated/types/instructionConstraintsCreated.d.ts.map +0 -1
- package/dist/generated/types/instructionConstraintsCreated.js +0 -36
- package/dist/generated/types/instructionConstraintsCreated.js.map +0 -1
- package/dist/generated/types/orphanConstraintsPdaCleaned.d.ts +0 -22
- package/dist/generated/types/orphanConstraintsPdaCleaned.d.ts.map +0 -1
- package/dist/generated/types/orphanConstraintsPdaCleaned.js.map +0 -1
- package/dist/generated/types/pdaAllocated.d.ts +0 -24
- package/dist/generated/types/pdaAllocated.d.ts.map +0 -1
- package/dist/generated/types/pdaAllocated.js +0 -28
- package/dist/generated/types/pdaAllocated.js.map +0 -1
- package/dist/generated/types/pdaExtended.d.ts +0 -24
- package/dist/generated/types/pdaExtended.d.ts.map +0 -1
- package/dist/generated/types/pdaExtended.js +0 -28
- package/dist/generated/types/pdaExtended.js.map +0 -1
- package/dist/post-assertions/cross-field-lte.d.ts +0 -134
- package/dist/post-assertions/cross-field-lte.d.ts.map +0 -1
- package/dist/post-assertions/cross-field-lte.js +0 -129
- package/dist/post-assertions/cross-field-lte.js.map +0 -1
- package/dist/post-assertions/index.d.ts +0 -28
- package/dist/post-assertions/index.d.ts.map +0 -1
- package/dist/post-assertions/index.js +0 -28
- package/dist/post-assertions/index.js.map +0 -1
- package/dist/post-assertions/presets/flash-trade.d.ts +0 -139
- package/dist/post-assertions/presets/flash-trade.d.ts.map +0 -1
- package/dist/post-assertions/presets/flash-trade.js +0 -154
- package/dist/post-assertions/presets/flash-trade.js.map +0 -1
- package/dist/protocol-registry/annotations/drift.json +0 -7
- package/dist/protocol-registry/annotations/flash-trade.json +0 -7
- package/dist/protocol-registry/annotations/jupiter-borrow.json +0 -7
- package/dist/protocol-registry/annotations/jupiter-earn.json +0 -7
- package/dist/protocol-registry/annotations/jupiter-lend.json +0 -7
- package/dist/protocol-registry/annotations/jupiter.json +0 -7
- package/dist/protocol-registry/annotations/kamino.json +0 -7
- package/dist/protocol-registry/index.d.ts +0 -45
- package/dist/protocol-registry/index.d.ts.map +0 -1
- package/dist/protocol-registry/index.js +0 -76
- package/dist/protocol-registry/index.js.map +0 -1
- package/dist/protocol-tier.d.ts +0 -157
- package/dist/protocol-tier.d.ts.map +0 -1
- package/dist/protocol-tier.js +0 -104
- package/dist/protocol-tier.js.map +0 -1
|
@@ -6,22 +6,32 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { getProgramDerivedAddress, getAddressEncoder } from "../kit-adapter.js";
|
|
8
8
|
import { getSigilModuleLogger } from "../logger.js";
|
|
9
|
-
import { pipe, createTransactionMessage, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, addSignersToTransactionMessage, signTransactionMessageWithSigners, getBase64EncodedWireTransaction, } from "../kit-adapter.js";
|
|
9
|
+
import { pipe, createTransactionMessage, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, addSignersToTransactionMessage, signTransactionMessageWithSigners, partiallySignTransactionMessageWithSigners, getBase64EncodedWireTransaction, } from "../kit-adapter.js";
|
|
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,
|
|
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, computeAgentSetHash, } from "../policy/compute-policy-preview-digest.js";
|
|
20
|
+
import { computeAgentPermsCosignDigest } from "../policy/compute-agent-perms-cosign-digest.js";
|
|
21
|
+
import { computeCosignDigest } from "../policy/compute-cosign-digest.js";
|
|
17
22
|
// Phase 3: Simple mutations
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
23
|
+
import { getFreezeVaultInstructionAsync } from "../generated/instructions/freezeVault.js";
|
|
24
|
+
import { getReactivateVaultInstructionAsync } from "../generated/instructions/reactivateVault.js";
|
|
25
|
+
import { getSetObserveOnlyInstructionAsync } from "../generated/instructions/setObserveOnly.js";
|
|
26
|
+
import { getQueueAgentGrantInstructionAsync } from "../generated/instructions/queueAgentGrant.js";
|
|
27
|
+
import { getApplyAgentGrantInstructionAsync } from "../generated/instructions/applyAgentGrant.js";
|
|
28
|
+
import { getCancelAgentGrantInstructionAsync } from "../generated/instructions/cancelAgentGrant.js";
|
|
20
29
|
import { getCloseVaultInstructionAsync } from "../generated/instructions/closeVault.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
30
|
+
import { enumerateExistingPendingPdasForClose } from "./close-vault.js";
|
|
31
|
+
import { getPauseAgentInstructionAsync } from "../generated/instructions/pauseAgent.js";
|
|
32
|
+
import { getUnpauseAgentInstructionAsync } from "../generated/instructions/unpauseAgent.js";
|
|
33
|
+
import { getRevokeAgentInstructionAsync } from "../generated/instructions/revokeAgent.js";
|
|
34
|
+
import { getRegisterAgentInstructionAsync } from "../generated/instructions/registerAgent.js";
|
|
25
35
|
// Phase 4: Complex mutations
|
|
26
36
|
import { getDepositFundsInstructionAsync } from "../generated/instructions/depositFunds.js";
|
|
27
37
|
import { getWithdrawFundsInstructionAsync } from "../generated/instructions/withdrawFunds.js";
|
|
@@ -31,19 +41,146 @@ import { getCancelPendingPolicyInstructionAsync } from "../generated/instruction
|
|
|
31
41
|
import { getQueueAgentPermissionsUpdateInstructionAsync } from "../generated/instructions/queueAgentPermissionsUpdate.js";
|
|
32
42
|
import { getApplyAgentPermissionsUpdateInstructionAsync } from "../generated/instructions/applyAgentPermissionsUpdate.js";
|
|
33
43
|
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
44
|
import { getCreatePostAssertionsInstructionAsync } from "../generated/instructions/createPostAssertions.js";
|
|
40
45
|
import { getClosePostAssertionsInstructionAsync } from "../generated/instructions/closePostAssertions.js";
|
|
46
|
+
// M-2 (pre-redeploy audit 2026-05-21): Phase 8 ownership-transfer ix builders.
|
|
47
|
+
// The on-chain handlers live at programs/sigil/src/instructions/
|
|
48
|
+
// {initiate,accept,cancel}_ownership_transfer.rs plus the Squads V4
|
|
49
|
+
// accept-multisig variant.
|
|
50
|
+
import { getInitiateOwnershipTransferInstructionAsync } from "../generated/instructions/initiateOwnershipTransfer.js";
|
|
51
|
+
import { getAcceptOwnershipTransferInstructionAsync } from "../generated/instructions/acceptOwnershipTransfer.js";
|
|
52
|
+
import { getAcceptOwnershipTransferMultisigInstructionAsync } from "../generated/instructions/acceptOwnershipTransferMultisig.js";
|
|
53
|
+
import { getCancelOwnershipTransferInstructionAsync } from "../generated/instructions/cancelOwnershipTransfer.js";
|
|
41
54
|
import { validatePostAssertionEntries } from "./post-assertion-validation.js";
|
|
42
|
-
import { buildCreateConstraintsIxs, buildQueueConstraintsUpdateIxs, } from "./constraint-builders.js";
|
|
43
55
|
import { toDxError } from "./errors.js";
|
|
56
|
+
import { SigilSdkDomainError } from "../errors/sdk.js";
|
|
57
|
+
import { SIGIL_ERROR__SDK__MAINNET_CONFIRMATION_REQUIRED } from "../errors/codes.js";
|
|
44
58
|
// ─── Shared Helper ───────────────────────────────────────────────────────────
|
|
45
59
|
const CU_OWNER_ACTION = 200_000;
|
|
46
|
-
|
|
60
|
+
/**
|
|
61
|
+
* CH-3 (Security audit 2026-05-23 / Jordan): AL2 mainnet confirmation gate
|
|
62
|
+
* embedded inside the mutation builder so direct `mutations.*` imports
|
|
63
|
+
* cannot bypass it. The OwnerClient wrapper layer has its own gate
|
|
64
|
+
* (`OwnerClient.assertMainnetConfirmed`) which catches consumers using the
|
|
65
|
+
* class API — this in-mutation gate is the safety net for consumers who
|
|
66
|
+
* import the mutation function directly.
|
|
67
|
+
*
|
|
68
|
+
* Behavior is intentionally STRICTER than the OwnerClient gate. The
|
|
69
|
+
* OwnerClient gate honours a `requireMainnetConfirmation: false` opt-out
|
|
70
|
+
* via the class config; this mutation-level gate has no such config (a
|
|
71
|
+
* standalone function takes no client config), so on mainnet the caller
|
|
72
|
+
* MUST pass `mainnetConfirmed: true` or the call throws. Devnet ignores
|
|
73
|
+
* the gate entirely.
|
|
74
|
+
*
|
|
75
|
+
* Currently only `createPostAssertions` + `closePostAssertions` invoke
|
|
76
|
+
* this — they are the only standalone mutations whose OwnerClient
|
|
77
|
+
* wrapper is missing (the rest of the mutations are gated at the
|
|
78
|
+
* wrapper). Future standalone mutations should also call this helper.
|
|
79
|
+
*
|
|
80
|
+
* Single source of truth: per the audit finding, the mutation-level gate
|
|
81
|
+
* is the canonical enforcement point. The OwnerClient wrapper gate (when
|
|
82
|
+
* a wrapper exists) double-asserts the same contract; passing
|
|
83
|
+
* `mainnetConfirmed: true` satisfies both layers idempotently.
|
|
84
|
+
*/
|
|
85
|
+
function assertMutationMainnetConfirmed(methodName, network, vault, opts) {
|
|
86
|
+
if (network !== "mainnet")
|
|
87
|
+
return;
|
|
88
|
+
if (opts?.mainnetConfirmed === true)
|
|
89
|
+
return;
|
|
90
|
+
throw new SigilSdkDomainError(SIGIL_ERROR__SDK__MAINNET_CONFIRMATION_REQUIRED, `mutations.${methodName} on mainnet requires \`mainnetConfirmed: true\` ` +
|
|
91
|
+
`in the per-call options. Direct imports of mutation builders do not ` +
|
|
92
|
+
`inherit OwnerClient's \`requireMainnetConfirmation\` opt-out — pass ` +
|
|
93
|
+
`\`mainnetConfirmed: true\` to acknowledge the destructive mainnet action. ` +
|
|
94
|
+
`Docs: https://github.com/Sigil-Trade/sigil/blob/main/sdk/kit/MIGRATION.md`, {
|
|
95
|
+
context: {
|
|
96
|
+
method: methodName,
|
|
97
|
+
network: "mainnet",
|
|
98
|
+
vault: vault.toString(),
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* PEN-CROSS-3 (Phase 2 close-up): compute the post-mutation
|
|
104
|
+
* policy_preview_digest for one of the 4 sibling handlers
|
|
105
|
+
* (create_instruction_constraints, apply_close_constraints,
|
|
106
|
+
* create_post_assertions, close_post_assertions).
|
|
107
|
+
*
|
|
108
|
+
* Reads the live PolicyConfig + AgentVault, applies the caller-specified
|
|
109
|
+
* flag override, then returns the canonical digest the on-chain handler
|
|
110
|
+
* will recompute and assert against. The owner signs this exact digest
|
|
111
|
+
* when calling the ix — defends against blind-sign by forcing explicit
|
|
112
|
+
* attestation of the flag flip.
|
|
113
|
+
*/
|
|
114
|
+
async function siblingHandlerExpectedDigest(rpc, vault, override) {
|
|
115
|
+
const [policyAddress] = await getPolicyPDA(vault);
|
|
116
|
+
const [livePolicy, liveVault] = await Promise.all([
|
|
117
|
+
fetchPolicyConfig(rpc, policyAddress),
|
|
118
|
+
fetchAgentVault(rpc, vault),
|
|
119
|
+
]);
|
|
120
|
+
return computePolicyPreviewDigest({
|
|
121
|
+
dailySpendingCapUsd: livePolicy.data.dailySpendingCapUsd,
|
|
122
|
+
maxTransactionSizeUsd: livePolicy.data.maxTransactionSizeUsd,
|
|
123
|
+
maxSlippageBps: livePolicy.data.maxSlippageBps,
|
|
124
|
+
developerFeeRate: livePolicy.data.developerFeeRate,
|
|
125
|
+
protocolMode: livePolicy.data.protocolMode,
|
|
126
|
+
protocols: livePolicy.data.protocols,
|
|
127
|
+
destinationMode: livePolicy.data.destinationMode,
|
|
128
|
+
allowedDestinations: livePolicy.data.allowedDestinations,
|
|
129
|
+
timelockDuration: livePolicy.data.timelockDuration,
|
|
130
|
+
sessionExpirySeconds: livePolicy.data.sessionExpirySeconds,
|
|
131
|
+
observeOnly: liveVault.data.observeOnly,
|
|
132
|
+
hasPostAssertions: override.hasPostAssertions !== undefined
|
|
133
|
+
? override.hasPostAssertions
|
|
134
|
+
: livePolicy.data.hasPostAssertions,
|
|
135
|
+
createdAtSlot: livePolicy.data.createdAtSlot,
|
|
136
|
+
// TA-05 (Phase 3): operating_hours is policy-owned. Sibling handlers
|
|
137
|
+
// (constraints/post-assertions) never mutate it — pass through.
|
|
138
|
+
operatingHours: livePolicy.data.operatingHours,
|
|
139
|
+
// TA-07/17 (Phase 3): also pass-through from live policy.
|
|
140
|
+
autoPromoteGrays: livePolicy.data.autoPromoteGrays,
|
|
141
|
+
autoRevokeThreshold: livePolicy.data.autoRevokeThreshold,
|
|
142
|
+
// TA-12/14 (Phase 5): pass-through from live policy — sibling
|
|
143
|
+
// handlers (constraints / post-assertions flips) never mutate the
|
|
144
|
+
// post-execution invariant fields.
|
|
145
|
+
stableBalanceFloor: livePolicy.data.stableBalanceFloor,
|
|
146
|
+
perRecipientDailyCapUsd: livePolicy.data.perRecipientDailyCapUsd,
|
|
147
|
+
// G6 (audit 2026-05-18 cosign opt-in): pass-through from live policy.
|
|
148
|
+
// Sibling handlers never mutate cosign_required — the user changes
|
|
149
|
+
// this via `queue_policy_update` only.
|
|
150
|
+
cosignRequired: livePolicy.data.cosignRequired,
|
|
151
|
+
// D-5 (Bucket 2 audit 2026-05-21, F-RP3-1): pass-through from live
|
|
152
|
+
// policy. Position 21 of the canonical TA-19 digest. Sibling handlers
|
|
153
|
+
// never mutate this — owner sets via queue_policy_update only.
|
|
154
|
+
cosignSessionPubkey: livePolicy.data.cosignSessionPubkey,
|
|
155
|
+
// M-1 (audit 2026-06-11): per-protocol caps (positions 23-24). Sibling
|
|
156
|
+
// handlers never mutate the caps — pass-through from live policy so the
|
|
157
|
+
// re-bind digest matches the on-chain recompute (create_post_assertions
|
|
158
|
+
// .rs:138-139 / close_post_assertions.rs read policy.has_protocol_caps +
|
|
159
|
+
// policy.protocol_caps).
|
|
160
|
+
hasProtocolCaps: livePolicy.data.hasProtocolCaps,
|
|
161
|
+
protocolCaps: livePolicy.data.protocolCaps,
|
|
162
|
+
// HIGH (audit 2026-06-11 follow-up): create_post_assertions.rs:129 and
|
|
163
|
+
// close_post_assertions.rs recompute agent_set_hash from the LIVE vault
|
|
164
|
+
// agents, and :136 reads operator_grant_delay_seconds from live policy.
|
|
165
|
+
// Omitting them here defaulted the digest to EMPTY_AGENT_SET_HASH / 0n,
|
|
166
|
+
// mismatching the on-chain recompute (PolicyPreviewMismatch) for ANY vault
|
|
167
|
+
// with >=1 agent or a non-zero operator-grant delay — i.e. every real vault.
|
|
168
|
+
// vault.agents is the active-agent Vec (register pushes; owner-revoke
|
|
169
|
+
// removes the entry, auto-revoke zeroes its capability in place — either
|
|
170
|
+
// way membership matches the on-chain Vec), mapped 1:1 by
|
|
171
|
+
// computeAgentSetHash (mirrors compute_agent_set_hash).
|
|
172
|
+
agentSetHash: computeAgentSetHash(liveVault.data.agents),
|
|
173
|
+
operatorGrantDelaySeconds: livePolicy.data.operatorGrantDelaySeconds,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
async function run(rpc, owner, network, instructions, opts = {},
|
|
177
|
+
// Elevated-cosign surface (audit 2026-06-12): additional signers beyond the
|
|
178
|
+
// owner (e.g. a cosign-session signer for an elevated queue mutation). The
|
|
179
|
+
// cosigner must ALSO be present in the instruction's account metas as a
|
|
180
|
+
// readonly-signer (the elevated wrappers append it); attaching it here makes
|
|
181
|
+
// its signature land in the wire tx. Default [] preserves the owner-only path
|
|
182
|
+
// for every existing non-elevated caller.
|
|
183
|
+
cosigners = []) {
|
|
47
184
|
try {
|
|
48
185
|
const cu = opts.computeUnits ?? CU_OWNER_ACTION;
|
|
49
186
|
const allIx = [
|
|
@@ -62,7 +199,7 @@ async function run(rpc, owner, network, instructions, opts = {}) {
|
|
|
62
199
|
const cache = getBlockhashCache(rpc);
|
|
63
200
|
const blockhash = await cache.get(rpc);
|
|
64
201
|
const txMessage = pipe(createTransactionMessage({ version: 0 }), (tx) => setTransactionMessageFeePayer(owner.address, tx), (tx) => setTransactionMessageLifetimeUsingBlockhash(blockhash, tx), (tx) => appendTransactionMessageInstructions(allIx, tx));
|
|
65
|
-
const txWithSigners = addSignersToTransactionMessage([owner], txMessage);
|
|
202
|
+
const txWithSigners = addSignersToTransactionMessage([owner, ...cosigners], txMessage);
|
|
66
203
|
const signedTx = await signTransactionMessageWithSigners(txWithSigners);
|
|
67
204
|
const wire = getBase64EncodedWireTransaction(signedTx);
|
|
68
205
|
const signature = await sendAndConfirmTransaction(rpc, wire);
|
|
@@ -127,11 +264,11 @@ async function derivePendingAgentPermsPDA(vault, agent) {
|
|
|
127
264
|
// PHASE 3: Simple mutations
|
|
128
265
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
129
266
|
export async function freezeVault(rpc, vault, owner, network, opts) {
|
|
130
|
-
const ix =
|
|
267
|
+
const ix = await getFreezeVaultInstructionAsync({ owner, vault });
|
|
131
268
|
return run(rpc, owner, network, [ix], opts);
|
|
132
269
|
}
|
|
133
270
|
export async function resumeVault(rpc, vault, owner, network, newAgent, opts) {
|
|
134
|
-
const ix =
|
|
271
|
+
const ix = await getReactivateVaultInstructionAsync({
|
|
135
272
|
owner,
|
|
136
273
|
vault,
|
|
137
274
|
newAgent: newAgent?.address ?? null,
|
|
@@ -139,6 +276,77 @@ export async function resumeVault(rpc, vault, owner, network, newAgent, opts) {
|
|
|
139
276
|
});
|
|
140
277
|
return run(rpc, owner, network, [ix], opts);
|
|
141
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Phase 8 alias for {@link resumeVault} matching the on-chain
|
|
281
|
+
* `reactivate_vault` instruction name. Prefer `reactivateVault` in new
|
|
282
|
+
* code; `resumeVault` is retained for backwards compatibility.
|
|
283
|
+
*/
|
|
284
|
+
export async function reactivateVault(rpc, vault, owner, network, newAgent, opts) {
|
|
285
|
+
return resumeVault(rpc, vault, owner, network, newAgent, opts);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Phase 8 owner-side observe-only toggle. Setting `newValue: true` puts
|
|
289
|
+
* the vault into read-only mode (all `validate_and_authorize` calls reject
|
|
290
|
+
* with `ErrObserveOnlyEnabled`). Setting `newValue: false` resumes
|
|
291
|
+
* spending. Bumps `policy_version` so concurrent validate_and_authorize
|
|
292
|
+
* calls fail fast with `PolicyVersionMismatch`.
|
|
293
|
+
*/
|
|
294
|
+
export async function setObserveOnly(rpc, vault, owner, network, newValue, opts) {
|
|
295
|
+
const ix = await getSetObserveOnlyInstructionAsync({
|
|
296
|
+
vault,
|
|
297
|
+
owner,
|
|
298
|
+
newValue,
|
|
299
|
+
});
|
|
300
|
+
return run(rpc, owner, network, [ix], opts);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Phase 8 owner-side queue of a new agent capability grant. The grant
|
|
304
|
+
* becomes effective after `apply_agent_grant` is called (subject to the
|
|
305
|
+
* cosign_required gate if enabled on the policy).
|
|
306
|
+
*
|
|
307
|
+
* `capability` is the on-chain `AgentCapability` discriminant:
|
|
308
|
+
* - 0 = READ_ONLY
|
|
309
|
+
* - 1 = OPERATOR
|
|
310
|
+
* - 2 = FULL
|
|
311
|
+
* `spendingLimitUsd` is in 6-decimal USDC units (e.g. `$500 = 500_000_000n`).
|
|
312
|
+
*/
|
|
313
|
+
export async function queueAgentGrant(rpc, vault, owner, network, agent, capability, spendingLimitUsd, opts) {
|
|
314
|
+
const ix = await getQueueAgentGrantInstructionAsync({
|
|
315
|
+
owner,
|
|
316
|
+
vault,
|
|
317
|
+
agent,
|
|
318
|
+
capability,
|
|
319
|
+
spendingLimitUsd,
|
|
320
|
+
});
|
|
321
|
+
return run(rpc, owner, network, [ix], opts);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Phase 8 owner-side apply of a previously-queued agent capability grant.
|
|
325
|
+
* The grant must have been queued via {@link queueAgentGrant}; the apply
|
|
326
|
+
* handler verifies the PendingAgentGrant PDA exists and that any cosign
|
|
327
|
+
* requirement on the policy has been satisfied (or that the grant lowers
|
|
328
|
+
* — not raises — privilege so cosign is bypassable per F-AT-1).
|
|
329
|
+
*/
|
|
330
|
+
export async function applyAgentGrant(rpc, vault, owner, network, opts) {
|
|
331
|
+
const [agentSpendOverlay] = await getAgentOverlayPDA(vault);
|
|
332
|
+
const ix = await getApplyAgentGrantInstructionAsync({
|
|
333
|
+
owner,
|
|
334
|
+
vault,
|
|
335
|
+
agentSpendOverlay,
|
|
336
|
+
});
|
|
337
|
+
return run(rpc, owner, network, [ix], opts);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Phase 8 owner-side cancel of a previously-queued agent capability
|
|
341
|
+
* grant. Closes the PendingAgentGrant PDA and returns rent to the owner.
|
|
342
|
+
*/
|
|
343
|
+
export async function cancelAgentGrant(rpc, vault, owner, network, opts) {
|
|
344
|
+
const ix = await getCancelAgentGrantInstructionAsync({
|
|
345
|
+
owner,
|
|
346
|
+
vault,
|
|
347
|
+
});
|
|
348
|
+
return run(rpc, owner, network, [ix], opts);
|
|
349
|
+
}
|
|
142
350
|
/**
|
|
143
351
|
* Permanently closes vault and reclaims rent.
|
|
144
352
|
*
|
|
@@ -165,13 +373,8 @@ export async function closeVault(rpc, vault, owner, network, opts) {
|
|
|
165
373
|
const [pendingPolicyPda] = await getPendingPolicyPDA(vault);
|
|
166
374
|
const agents = vaultData.agents || [];
|
|
167
375
|
const agentPdaDerivations = await Promise.all(agents.map((agent) => derivePendingAgentPermsPDA(vault, agent.pubkey)));
|
|
168
|
-
const [pendingCloseConstraintsPda] = await getPendingCloseConstraintsPDA(vault);
|
|
169
376
|
// Check all PDAs in parallel (E4 fix — batch instead of sequential)
|
|
170
|
-
const allPdas = [
|
|
171
|
-
pendingPolicyPda,
|
|
172
|
-
...agentPdaDerivations,
|
|
173
|
-
pendingCloseConstraintsPda,
|
|
174
|
-
];
|
|
377
|
+
const allPdas = [pendingPolicyPda, ...agentPdaDerivations];
|
|
175
378
|
const existenceChecks = await Promise.all(allPdas.map(async (pda) => {
|
|
176
379
|
try {
|
|
177
380
|
const info = await rpc
|
|
@@ -206,13 +409,31 @@ export async function closeVault(rpc, vault, owner, network, opts) {
|
|
|
206
409
|
});
|
|
207
410
|
}
|
|
208
411
|
}
|
|
209
|
-
// 3.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
412
|
+
// 3-4. SFH-01 close: enumerate pending_owner + pending_agent_grant via the
|
|
413
|
+
// dedicated helper. Without these, the on-chain drain blocks for
|
|
414
|
+
// pending_owner + pending_agent_grant silently no-op via the
|
|
415
|
+
// `lamports() > 0` guard, orphaning their rent. Helper performs parallel
|
|
416
|
+
// getAccountInfo and only includes accounts that exist.
|
|
417
|
+
// (M1-04b: pending_close_constraints + pending_constraints drains removed.)
|
|
418
|
+
//
|
|
419
|
+
// HH-1 close (audit 2026-05-23 §RP): the helper's silent-failure on RPC
|
|
420
|
+
// errors is now escalated to ERROR-level log with vault context. If a
|
|
421
|
+
// transient RPC failure during enumeration kept a PDA out of
|
|
422
|
+
// remainingAccounts, the on-chain drain falls through silently and rent
|
|
423
|
+
// is permanently orphaned. The ERROR-level log surfaces this to off-chain
|
|
424
|
+
// monitors / alerting; the close TX still proceeds (best-effort drain
|
|
425
|
+
// semantic preserved).
|
|
426
|
+
let ch2EnumerationHadRpcError = false;
|
|
427
|
+
const ch2PendingAccounts = await enumerateExistingPendingPdasForClose(rpc, vault, undefined, (kind, address, cause) => {
|
|
428
|
+
ch2EnumerationHadRpcError = true;
|
|
429
|
+
const c = redactCause(cause);
|
|
430
|
+
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"}`);
|
|
431
|
+
});
|
|
432
|
+
if (ch2EnumerationHadRpcError) {
|
|
433
|
+
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.`);
|
|
434
|
+
}
|
|
435
|
+
for (const pa of ch2PendingAccounts) {
|
|
436
|
+
remainingAccounts.push({ address: pa.address, role: pa.role });
|
|
216
437
|
}
|
|
217
438
|
// Append remaining accounts to instruction if any exist
|
|
218
439
|
const finalIx = remainingAccounts.length > 0
|
|
@@ -236,14 +457,24 @@ export async function closeVault(rpc, vault, owner, network, opts) {
|
|
|
236
457
|
// decision (9-1 vote, 2026-04-19). See Plans/we-need-to-plan-serialized-summit.md.
|
|
237
458
|
export async function pauseAgent(rpc, vault, owner, network, agent, opts) {
|
|
238
459
|
requireValidAddress(agent, "Agent address");
|
|
239
|
-
|
|
460
|
+
// PEN-CROSS-5 (Phase 4 absorption): policy now required for policy_version bump.
|
|
461
|
+
const [policyPda] = await getPolicyPDA(vault);
|
|
462
|
+
const ix = await getPauseAgentInstructionAsync({
|
|
463
|
+
owner,
|
|
464
|
+
vault,
|
|
465
|
+
policy: policyPda,
|
|
466
|
+
agentToPause: agent,
|
|
467
|
+
});
|
|
240
468
|
return run(rpc, owner, network, [ix], opts);
|
|
241
469
|
}
|
|
242
470
|
export async function unpauseAgent(rpc, vault, owner, network, agent, opts) {
|
|
243
471
|
requireValidAddress(agent, "Agent address");
|
|
244
|
-
|
|
472
|
+
// PEN-CROSS-5 (Phase 4 absorption): policy now required for policy_version bump.
|
|
473
|
+
const [policyPda] = await getPolicyPDA(vault);
|
|
474
|
+
const ix = await getUnpauseAgentInstructionAsync({
|
|
245
475
|
owner,
|
|
246
476
|
vault,
|
|
477
|
+
policy: policyPda,
|
|
247
478
|
agentToUnpause: agent,
|
|
248
479
|
});
|
|
249
480
|
return run(rpc, owner, network, [ix], opts);
|
|
@@ -251,9 +482,12 @@ export async function unpauseAgent(rpc, vault, owner, network, agent, opts) {
|
|
|
251
482
|
export async function revokeAgent(rpc, vault, owner, network, agent, opts) {
|
|
252
483
|
requireValidAddress(agent, "Agent address");
|
|
253
484
|
const [overlayPda] = await getAgentOverlayPDA(vault, 0);
|
|
254
|
-
|
|
485
|
+
// PEN-CROSS-5 (Phase 4 absorption): policy now required for policy_version bump.
|
|
486
|
+
const [policyPda] = await getPolicyPDA(vault);
|
|
487
|
+
const ix = await getRevokeAgentInstructionAsync({
|
|
255
488
|
owner,
|
|
256
489
|
vault,
|
|
490
|
+
policy: policyPda,
|
|
257
491
|
agentSpendOverlay: overlayPda,
|
|
258
492
|
agentToRemove: agent,
|
|
259
493
|
});
|
|
@@ -263,9 +497,12 @@ export async function addAgent(rpc, vault, owner, network, agent, permissions, s
|
|
|
263
497
|
requireValidAddress(agent, "Agent address");
|
|
264
498
|
requireValidPermissions(permissions);
|
|
265
499
|
const [overlayPda] = await getAgentOverlayPDA(vault, 0);
|
|
266
|
-
|
|
500
|
+
// PEN-CROSS-5 (Phase 4 absorption): policy now required for policy_version bump.
|
|
501
|
+
const [policyPda] = await getPolicyPDA(vault);
|
|
502
|
+
const ix = await getRegisterAgentInstructionAsync({
|
|
267
503
|
owner,
|
|
268
504
|
vault,
|
|
505
|
+
policy: policyPda,
|
|
269
506
|
agentSpendOverlay: overlayPda,
|
|
270
507
|
agent,
|
|
271
508
|
capability: Number(permissions),
|
|
@@ -316,6 +553,37 @@ export async function withdraw(rpc, vault, owner, network, mint, amount, opts) {
|
|
|
316
553
|
* - `sessionExpirySeconds` range (5..=90 when > 0; audit F5-H1)
|
|
317
554
|
*/
|
|
318
555
|
export async function queuePolicyUpdate(rpc, vault, owner, network, changes, opts) {
|
|
556
|
+
// Non-elevated path: cosign_session = Pubkey::default(), no cosigner in
|
|
557
|
+
// remaining_accounts, owner-only signature. Shares buildPolicyUpdateIx (the
|
|
558
|
+
// merged-effective projection + TA-19 digest) with queuePolicyElevated — the
|
|
559
|
+
// single source of truth that prevents digest drift between the two surfaces.
|
|
560
|
+
// An elevated change submitted here (e.g. raising a cap on a cosign_required
|
|
561
|
+
// vault) fails closed on-chain with ErrCosignRequired; use queuePolicyElevated.
|
|
562
|
+
const ix = await buildPolicyUpdateIx(rpc, owner, vault, changes, DEFAULT_COSIGN_SESSION);
|
|
563
|
+
return run(rpc, owner, network, [ix], opts);
|
|
564
|
+
}
|
|
565
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
566
|
+
// Elevated-cosign surface (audit 2026-06-12) — policy path.
|
|
567
|
+
//
|
|
568
|
+
// queuePolicyElevated / buildQueuePolicyElevated mirror the agent-perms pair for
|
|
569
|
+
// policy changes. They share buildPolicyUpdateIx with queuePolicyUpdate (DRY —
|
|
570
|
+
// the single source of truth for the merged-effective projection + TA-19 digest;
|
|
571
|
+
// duplicating it is the exact digest-drift failure mode the 2026-06-11 audit
|
|
572
|
+
// fixed). The only difference between non-elevated and elevated is the
|
|
573
|
+
// cosign_session arg (default vs a real cosigner pubkey) + the elevated-only
|
|
574
|
+
// change fields, all plumbed through `eff = changes.X ?? live`.
|
|
575
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
576
|
+
/** Pubkey::default() (System Program) — the non-elevated cosign_session arg. */
|
|
577
|
+
const DEFAULT_COSIGN_SESSION = "11111111111111111111111111111111";
|
|
578
|
+
/**
|
|
579
|
+
* Shared queue_policy_update instruction builder. Validates `changes`, fetches
|
|
580
|
+
* live policy+vault, projects the merged-effective policy (`eff = changes.X ??
|
|
581
|
+
* live.X` for EVERY field, so omitted fields fall through to live — the
|
|
582
|
+
* non-elevated path is byte-identical to the prior inline impl), computes the
|
|
583
|
+
* TA-19 digest over it, and builds the ix with the supplied `cosignSession`
|
|
584
|
+
* (DEFAULT_COSIGN_SESSION = non-elevated; a real cosigner pubkey = elevated).
|
|
585
|
+
*/
|
|
586
|
+
async function buildPolicyUpdateIx(rpc, owner, vault, changes, cosignSession) {
|
|
319
587
|
if (Object.keys(changes).length === 0) {
|
|
320
588
|
throw toDxError(new Error("At least one policy change is required"));
|
|
321
589
|
}
|
|
@@ -333,14 +601,66 @@ export async function queuePolicyUpdate(rpc, vault, owner, network, changes, opt
|
|
|
333
601
|
changes.approvedApps.length > MAX_ALLOWED_PROTOCOLS) {
|
|
334
602
|
throw toDxError(new Error(`approvedApps length exceeds on-chain MAX_ALLOWED_PROTOCOLS (${MAX_ALLOWED_PROTOCOLS}). Got ${changes.approvedApps.length}. On-chain rejects TooManyAllowedProtocols.`));
|
|
335
603
|
}
|
|
604
|
+
const [policyPda] = await getPolicyPDA(vault);
|
|
605
|
+
const livePolicy = await fetchPolicyConfig(rpc, policyPda);
|
|
606
|
+
const liveVault = await fetchAgentVault(rpc, vault);
|
|
607
|
+
const newProtocolMode = changes.protocolMode
|
|
608
|
+
? mapProtocolMode(changes.protocolMode)
|
|
609
|
+
: null;
|
|
610
|
+
const effProtocolMode = newProtocolMode ?? livePolicy.data.protocolMode;
|
|
611
|
+
const effProtocols = changes.approvedApps ?? livePolicy.data.protocols;
|
|
612
|
+
const effDestinationMode = changes.destinationMode ?? livePolicy.data.destinationMode;
|
|
613
|
+
const effDestinations = changes.allowedDestinations ?? livePolicy.data.allowedDestinations;
|
|
614
|
+
const effDaily = changes.dailyCap ?? livePolicy.data.dailySpendingCapUsd;
|
|
615
|
+
const effMaxTx = changes.maxPerTrade ?? livePolicy.data.maxTransactionSizeUsd;
|
|
616
|
+
const effMaxSlip = changes.maxSlippageBps ?? livePolicy.data.maxSlippageBps;
|
|
617
|
+
const effDeveloperFeeRate = changes.developerFeeRate ?? livePolicy.data.developerFeeRate;
|
|
618
|
+
const effTimelock = changes.timelock != null
|
|
619
|
+
? BigInt(changes.timelock)
|
|
620
|
+
: livePolicy.data.timelockDuration;
|
|
621
|
+
const effSessionExpiry = changes.sessionExpirySeconds ?? livePolicy.data.sessionExpirySeconds;
|
|
622
|
+
const effHasProtocolCaps = changes.hasProtocolCaps ?? livePolicy.data.hasProtocolCaps;
|
|
623
|
+
const effProtocolCaps = changes.protocolCaps ?? livePolicy.data.protocolCaps;
|
|
624
|
+
// Elevated-only fields (audit 2026-06-12): same merged-effective projection.
|
|
625
|
+
// Undefined ⇒ live pass-through, so queuePolicyUpdate's digest is unchanged.
|
|
626
|
+
const effStableFloor = changes.stableBalanceFloor ?? livePolicy.data.stableBalanceFloor;
|
|
627
|
+
const effPerRecip = changes.perRecipientDailyCapUsd ?? livePolicy.data.perRecipientDailyCapUsd;
|
|
628
|
+
const effCosignRequired = changes.cosignRequired ?? livePolicy.data.cosignRequired;
|
|
629
|
+
const effCosignSessionPubkey = changes.cosignSessionPubkey ?? livePolicy.data.cosignSessionPubkey;
|
|
630
|
+
const effOperatorDelay = changes.operatorGrantDelaySeconds ??
|
|
631
|
+
livePolicy.data.operatorGrantDelaySeconds;
|
|
632
|
+
const newPolicyPreviewDigest = computePolicyPreviewDigest({
|
|
633
|
+
dailySpendingCapUsd: effDaily,
|
|
634
|
+
maxTransactionSizeUsd: effMaxTx,
|
|
635
|
+
maxSlippageBps: effMaxSlip,
|
|
636
|
+
developerFeeRate: effDeveloperFeeRate,
|
|
637
|
+
protocolMode: effProtocolMode,
|
|
638
|
+
protocols: effProtocols,
|
|
639
|
+
destinationMode: effDestinationMode,
|
|
640
|
+
allowedDestinations: effDestinations,
|
|
641
|
+
timelockDuration: effTimelock,
|
|
642
|
+
sessionExpirySeconds: effSessionExpiry,
|
|
643
|
+
observeOnly: liveVault.data.observeOnly,
|
|
644
|
+
hasPostAssertions: livePolicy.data.hasPostAssertions,
|
|
645
|
+
createdAtSlot: livePolicy.data.createdAtSlot,
|
|
646
|
+
operatingHours: livePolicy.data.operatingHours,
|
|
647
|
+
autoPromoteGrays: livePolicy.data.autoPromoteGrays,
|
|
648
|
+
autoRevokeThreshold: livePolicy.data.autoRevokeThreshold,
|
|
649
|
+
stableBalanceFloor: effStableFloor,
|
|
650
|
+
perRecipientDailyCapUsd: effPerRecip,
|
|
651
|
+
cosignRequired: effCosignRequired,
|
|
652
|
+
operatorGrantDelaySeconds: effOperatorDelay,
|
|
653
|
+
hasProtocolCaps: effHasProtocolCaps,
|
|
654
|
+
protocolCaps: effProtocolCaps,
|
|
655
|
+
agentSetHash: computeAgentSetHash(liveVault.data.agents),
|
|
656
|
+
cosignSessionPubkey: effCosignSessionPubkey,
|
|
657
|
+
});
|
|
336
658
|
const ix = await getQueuePolicyUpdateInstructionAsync({
|
|
337
659
|
owner,
|
|
338
660
|
vault,
|
|
339
661
|
dailySpendingCapUsd: changes.dailyCap ?? null,
|
|
340
662
|
maxTransactionAmountUsd: changes.maxPerTrade ?? null,
|
|
341
|
-
protocolMode:
|
|
342
|
-
? mapProtocolMode(changes.protocolMode)
|
|
343
|
-
: null,
|
|
663
|
+
protocolMode: newProtocolMode,
|
|
344
664
|
protocols: changes.approvedApps ?? null,
|
|
345
665
|
developerFeeRate: changes.developerFeeRate ?? null,
|
|
346
666
|
maxSlippageBps: changes.maxSlippageBps ?? null,
|
|
@@ -350,8 +670,55 @@ export async function queuePolicyUpdate(rpc, vault, owner, network, changes, opt
|
|
|
350
670
|
hasProtocolCaps: changes.hasProtocolCaps ?? null,
|
|
351
671
|
protocolCaps: changes.protocolCaps ?? null,
|
|
352
672
|
destinationMode: changes.destinationMode ?? null,
|
|
673
|
+
operatingHours: null,
|
|
674
|
+
stableBalanceFloor: changes.stableBalanceFloor ?? null,
|
|
675
|
+
perRecipientDailyCapUsd: changes.perRecipientDailyCapUsd ?? null,
|
|
676
|
+
cosignRequired: changes.cosignRequired ?? null,
|
|
677
|
+
cosignSessionPubkey: changes.cosignSessionPubkey ?? null,
|
|
678
|
+
operatorGrantDelaySeconds: changes.operatorGrantDelaySeconds ?? null,
|
|
679
|
+
cosignSession,
|
|
680
|
+
newPolicyPreviewDigest,
|
|
353
681
|
});
|
|
354
|
-
return
|
|
682
|
+
return ix;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Elevated policy queue — single-builder dual-sign. Caller holds the cosigner
|
|
686
|
+
* key; signs [owner, cosigner] + sends. For true 2-party async use
|
|
687
|
+
* buildQueuePolicyElevated.
|
|
688
|
+
*/
|
|
689
|
+
export async function queuePolicyElevated(rpc, vault, owner, network, changes, cosigner, opts) {
|
|
690
|
+
requireValidAddress(cosigner.address, "Cosigner address");
|
|
691
|
+
if (cosigner.address === owner.address) {
|
|
692
|
+
throw toDxError(new Error("Cosigner must be distinct from the owner (on-chain ErrCosignRequired)"));
|
|
693
|
+
}
|
|
694
|
+
const ix = await buildPolicyUpdateIx(rpc, owner, vault, changes, cosigner.address);
|
|
695
|
+
return run(rpc, owner, network, [withCosignerSigner(ix, cosigner.address)], opts, [cosigner]);
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Elevated policy queue — partial-sign handoff. Owner-signs + returns the
|
|
699
|
+
* partial tx + the policy cosign digest for the cosigner to complete + send.
|
|
700
|
+
* The cosign digest binds the RAW queued args (mirrors compute_cosign_digest).
|
|
701
|
+
*/
|
|
702
|
+
export async function buildQueuePolicyElevated(rpc, vault, owner, changes, cosignSession, opts) {
|
|
703
|
+
requireValidAddress(cosignSession, "Cosigner address");
|
|
704
|
+
if (cosignSession === owner.address) {
|
|
705
|
+
throw toDxError(new Error("Cosigner must be distinct from the owner (on-chain ErrCosignRequired)"));
|
|
706
|
+
}
|
|
707
|
+
const ix = await buildPolicyUpdateIx(rpc, owner, vault, changes, cosignSession);
|
|
708
|
+
const partialTransactionBase64 = await buildOwnerPartialSignedTx(rpc, owner, [withCosignerSigner(ix, cosignSession)], opts);
|
|
709
|
+
const cosignDigest = computeCosignDigest({
|
|
710
|
+
cosignSession,
|
|
711
|
+
dailySpendingCapUsd: changes.dailyCap ?? null,
|
|
712
|
+
maxTransactionAmountUsd: changes.maxPerTrade ?? null,
|
|
713
|
+
allowedDestinations: changes.allowedDestinations ?? null,
|
|
714
|
+
protocols: changes.approvedApps ?? null,
|
|
715
|
+
stableBalanceFloor: changes.stableBalanceFloor ?? null,
|
|
716
|
+
perRecipientDailyCapUsd: changes.perRecipientDailyCapUsd ?? null,
|
|
717
|
+
hasProtocolCaps: changes.hasProtocolCaps ?? null,
|
|
718
|
+
protocolCaps: changes.protocolCaps ?? null,
|
|
719
|
+
cosignRequired: changes.cosignRequired ?? null,
|
|
720
|
+
});
|
|
721
|
+
return { partialTransactionBase64, cosignSession, cosignDigest };
|
|
355
722
|
}
|
|
356
723
|
export async function applyPendingPolicy(rpc, vault, owner, network, opts) {
|
|
357
724
|
const ix = await getApplyPendingPolicyInstructionAsync({ owner, vault });
|
|
@@ -361,7 +728,11 @@ export async function cancelPendingPolicy(rpc, vault, owner, network, opts) {
|
|
|
361
728
|
const ix = await getCancelPendingPolicyInstructionAsync({ owner, vault });
|
|
362
729
|
return run(rpc, owner, network, [ix], opts);
|
|
363
730
|
}
|
|
364
|
-
export async function queueAgentPermissions(rpc, vault, owner, network, agent, permissions, spendingLimit, opts
|
|
731
|
+
export async function queueAgentPermissions(rpc, vault, owner, network, agent, permissions, spendingLimit, opts,
|
|
732
|
+
// TA-06 (Phase 3): per-agent cooldown_seconds. 0 = disabled. Optional so
|
|
733
|
+
// existing dashboard callers continue compiling; pass non-zero when
|
|
734
|
+
// configuring agents that need pacing.
|
|
735
|
+
cooldownSeconds = 0n) {
|
|
365
736
|
requireValidAddress(agent, "Agent address");
|
|
366
737
|
requireValidPermissions(permissions);
|
|
367
738
|
const ix = await getQueueAgentPermissionsUpdateInstructionAsync({
|
|
@@ -370,9 +741,137 @@ export async function queueAgentPermissions(rpc, vault, owner, network, agent, p
|
|
|
370
741
|
agent,
|
|
371
742
|
newCapability: Number(permissions),
|
|
372
743
|
spendingLimitUsd: spendingLimit,
|
|
744
|
+
cooldownSeconds,
|
|
745
|
+
// Round 2 F-RP3-2 fix (audit 2026-05-19): non-elevated path default —
|
|
746
|
+
// System Program / zero-pubkey. The on-chain handler's elevated gate
|
|
747
|
+
// requires a non-default `cosign_session` only when the mutation
|
|
748
|
+
// raises capability, raises spending_limit, OR sets a non-zero
|
|
749
|
+
// cooldown AND `policy.cosign_required == true`. Callers who need
|
|
750
|
+
// the elevated path should use a dedicated wrapper that injects a
|
|
751
|
+
// real cosign-session pubkey + remaining_accounts signer (analogous
|
|
752
|
+
// to `queuePolicyElevated()` for queue_policy_update).
|
|
753
|
+
//
|
|
754
|
+
// CANONICAL `cosign_session` ARG CONTRACT (Round 2 §RP-2 B4 F-3,
|
|
755
|
+
// 2026-05-19) — same shape as the `queuePolicyUpdate` path above:
|
|
756
|
+
// - Non-elevated (this branch): pass `Pubkey::default()` and
|
|
757
|
+
// OMIT the cosigner from `remaining_accounts`.
|
|
758
|
+
// - Elevated (raising capability, raising spending_limit, or
|
|
759
|
+
// setting non-zero cooldown on a `cosign_required: true` vault):
|
|
760
|
+
// pass a REAL session pubkey + include it as a signer in
|
|
761
|
+
// `remaining_accounts`.
|
|
762
|
+
// - Reject path: passing a non-default `cosign_session` on a
|
|
763
|
+
// non-elevated queue surfaces `InvalidPermissions` (6036).
|
|
764
|
+
// INTENTIONAL — the on-chain handler refuses to silently
|
|
765
|
+
// downgrade a caller's declared intent (Option A behaviour).
|
|
766
|
+
cosignSession: "11111111111111111111111111111111",
|
|
373
767
|
});
|
|
374
768
|
return run(rpc, owner, network, [ix], opts);
|
|
375
769
|
}
|
|
770
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
771
|
+
// Elevated-cosign surface (audit 2026-06-12).
|
|
772
|
+
//
|
|
773
|
+
// On a `cosign_required` vault, raising an agent's capability or spending limit,
|
|
774
|
+
// or setting a non-zero cooldown, is an ELEVATED mutation: the on-chain
|
|
775
|
+
// queue_agent_permissions_update handler requires a non-default `cosign_session`
|
|
776
|
+
// that is (a) distinct from the owner and (b) present as a signer in
|
|
777
|
+
// remaining_accounts. Two caller models:
|
|
778
|
+
// - queueAgentPermissionsElevated(...) single-builder dual-sign: caller
|
|
779
|
+
// supplies the cosigner as a TransactionSigner; we sign [owner, cosigner].
|
|
780
|
+
// - buildQueueAgentPermissionsElevated(...) partial-sign handoff: caller
|
|
781
|
+
// supplies only the cosigner PUBKEY; we owner-partial-sign and return the
|
|
782
|
+
// base64 partial tx + the cosign digest for the cosigner to complete + send.
|
|
783
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
784
|
+
/** Append a cosign-session signer to a generated instruction's account metas. */
|
|
785
|
+
function withCosignerSigner(ix, cosignSession) {
|
|
786
|
+
return {
|
|
787
|
+
...ix,
|
|
788
|
+
accounts: [
|
|
789
|
+
...(ix.accounts ?? []),
|
|
790
|
+
{ address: cosignSession, role: AccountRole.READONLY_SIGNER },
|
|
791
|
+
],
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Assemble the compute-budget-prefixed message and OWNER-partial-sign it (the
|
|
796
|
+
* cosigner — a required signer via the appended account meta — signs later).
|
|
797
|
+
* Returns the base64 wire transaction for handoff. Mirrors run()'s message
|
|
798
|
+
* assembly but does NOT send.
|
|
799
|
+
*/
|
|
800
|
+
async function buildOwnerPartialSignedTx(rpc, owner, instructions, opts = {}) {
|
|
801
|
+
const cu = opts.computeUnits ?? CU_OWNER_ACTION;
|
|
802
|
+
const allIx = [
|
|
803
|
+
getSetComputeUnitLimitInstruction({
|
|
804
|
+
units: cu,
|
|
805
|
+
}),
|
|
806
|
+
...(opts.priorityFeeMicroLamports
|
|
807
|
+
? [
|
|
808
|
+
getSetComputeUnitPriceInstruction({
|
|
809
|
+
microLamports: BigInt(opts.priorityFeeMicroLamports),
|
|
810
|
+
}),
|
|
811
|
+
]
|
|
812
|
+
: []),
|
|
813
|
+
...instructions,
|
|
814
|
+
];
|
|
815
|
+
const blockhash = await getBlockhashCache(rpc).get(rpc);
|
|
816
|
+
const txMessage = pipe(createTransactionMessage({ version: 0 }), (tx) => setTransactionMessageFeePayer(owner.address, tx), (tx) => setTransactionMessageLifetimeUsingBlockhash(blockhash, tx), (tx) => appendTransactionMessageInstructions(allIx, tx));
|
|
817
|
+
const withOwner = addSignersToTransactionMessage([owner], txMessage);
|
|
818
|
+
const partial = await partiallySignTransactionMessageWithSigners(withOwner);
|
|
819
|
+
return getBase64EncodedWireTransaction(partial);
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Elevated agent-permissions queue — single-builder dual-sign. The caller holds
|
|
823
|
+
* the cosigner key (server-side / single-operator). Signs [owner, cosigner] and
|
|
824
|
+
* sends. For a true 2-party async flow use `buildQueueAgentPermissionsElevated`.
|
|
825
|
+
*/
|
|
826
|
+
export async function queueAgentPermissionsElevated(rpc, vault, owner, network, agent, permissions, spendingLimit, cooldownSeconds, cosigner, opts) {
|
|
827
|
+
requireValidAddress(agent, "Agent address");
|
|
828
|
+
requireValidPermissions(permissions);
|
|
829
|
+
requireValidAddress(cosigner.address, "Cosigner address");
|
|
830
|
+
if (cosigner.address === owner.address) {
|
|
831
|
+
throw toDxError(new Error("Cosigner must be distinct from the owner (on-chain ErrCosignRequired)"));
|
|
832
|
+
}
|
|
833
|
+
const ix = await getQueueAgentPermissionsUpdateInstructionAsync({
|
|
834
|
+
owner,
|
|
835
|
+
vault,
|
|
836
|
+
agent,
|
|
837
|
+
newCapability: Number(permissions),
|
|
838
|
+
spendingLimitUsd: spendingLimit,
|
|
839
|
+
cooldownSeconds,
|
|
840
|
+
cosignSession: cosigner.address,
|
|
841
|
+
});
|
|
842
|
+
return run(rpc, owner, network, [withCosignerSigner(ix, cosigner.address)], opts, [cosigner]);
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Elevated agent-permissions queue — partial-sign handoff. Owner-signs and
|
|
846
|
+
* returns the partial transaction + cosign digest; the cosigner signs and sends
|
|
847
|
+
* out-of-band (true 2-of-2). Validation mirrors the dual-sign path.
|
|
848
|
+
*/
|
|
849
|
+
export async function buildQueueAgentPermissionsElevated(rpc, vault, owner, agent, permissions, spendingLimit, cooldownSeconds, cosignSession, opts) {
|
|
850
|
+
requireValidAddress(agent, "Agent address");
|
|
851
|
+
requireValidPermissions(permissions);
|
|
852
|
+
requireValidAddress(cosignSession, "Cosigner address");
|
|
853
|
+
if (cosignSession === owner.address) {
|
|
854
|
+
throw toDxError(new Error("Cosigner must be distinct from the owner (on-chain ErrCosignRequired)"));
|
|
855
|
+
}
|
|
856
|
+
const ix = await getQueueAgentPermissionsUpdateInstructionAsync({
|
|
857
|
+
owner,
|
|
858
|
+
vault,
|
|
859
|
+
agent,
|
|
860
|
+
newCapability: Number(permissions),
|
|
861
|
+
spendingLimitUsd: spendingLimit,
|
|
862
|
+
cooldownSeconds,
|
|
863
|
+
cosignSession,
|
|
864
|
+
});
|
|
865
|
+
const partialTransactionBase64 = await buildOwnerPartialSignedTx(rpc, owner, [withCosignerSigner(ix, cosignSession)], opts);
|
|
866
|
+
const cosignDigest = computeAgentPermsCosignDigest({
|
|
867
|
+
cosignSession,
|
|
868
|
+
agent,
|
|
869
|
+
newCapability: Number(permissions),
|
|
870
|
+
spendingLimitUsd: spendingLimit,
|
|
871
|
+
cooldownSeconds,
|
|
872
|
+
});
|
|
873
|
+
return { partialTransactionBase64, cosignSession, cosignDigest };
|
|
874
|
+
}
|
|
376
875
|
export async function applyAgentPermissions(rpc, vault, owner, network, agent, opts) {
|
|
377
876
|
requireValidAddress(agent, "Agent address");
|
|
378
877
|
const [overlayPda] = await getAgentOverlayPDA(vault, 0);
|
|
@@ -395,79 +894,6 @@ export async function cancelAgentPermissions(rpc, vault, owner, network, agent,
|
|
|
395
894
|
});
|
|
396
895
|
return run(rpc, owner, network, [ix], opts);
|
|
397
896
|
}
|
|
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
897
|
// ─── Post-execution assertions (Phase 2) ─────────────────────────────────────
|
|
472
898
|
// Composes with pre-execution InstructionConstraints — NOT a replacement.
|
|
473
899
|
//
|
|
@@ -514,10 +940,21 @@ export async function createPostAssertions(rpc, vault, owner, network, entries,
|
|
|
514
940
|
// DX_ERROR_CODE_UNMAPPED (7999) and break ISC-19's "pinpoint the bad
|
|
515
941
|
// entry" promise. See post-assertion-validation.ts docblock.
|
|
516
942
|
validatePostAssertionEntries(entries);
|
|
943
|
+
// CH-3 (audit 2026-05-23): AL2 gate AFTER client-side validation so the
|
|
944
|
+
// caller learns about entry-shape mistakes (the cheap, fixable error)
|
|
945
|
+
// before they're forced to think about mainnet acknowledgement (the
|
|
946
|
+
// ceremonial gate). Order matches the OwnerClient pattern of running
|
|
947
|
+
// local validation before destructive-action confirmation.
|
|
948
|
+
assertMutationMainnetConfirmed("createPostAssertions", network, vault, opts);
|
|
949
|
+
// PEN-CROSS-3: bind the post-mutation digest (`has_post_assertions=1`).
|
|
950
|
+
const expectedDigest = await siblingHandlerExpectedDigest(rpc, vault, {
|
|
951
|
+
hasPostAssertions: 1,
|
|
952
|
+
});
|
|
517
953
|
const ix = await getCreatePostAssertionsInstructionAsync({
|
|
518
954
|
owner,
|
|
519
955
|
vault,
|
|
520
956
|
entries,
|
|
957
|
+
expectedDigest,
|
|
521
958
|
});
|
|
522
959
|
return run(rpc, owner, network, [ix], opts);
|
|
523
960
|
}
|
|
@@ -539,7 +976,136 @@ export async function createPostAssertions(rpc, vault, owner, network, entries,
|
|
|
539
976
|
* @returns TxResult with the confirmed signature.
|
|
540
977
|
*/
|
|
541
978
|
export async function closePostAssertions(rpc, vault, owner, network, opts) {
|
|
542
|
-
|
|
979
|
+
// CH-3 (audit 2026-05-23): AL2 gate. `closePostAssertions` has no
|
|
980
|
+
// client-side validation step (no entries arg), so the gate runs first.
|
|
981
|
+
assertMutationMainnetConfirmed("closePostAssertions", network, vault, opts);
|
|
982
|
+
// PEN-CROSS-3: bind the post-mutation digest (`has_post_assertions=0`).
|
|
983
|
+
const expectedDigest = await siblingHandlerExpectedDigest(rpc, vault, {
|
|
984
|
+
hasPostAssertions: 0,
|
|
985
|
+
});
|
|
986
|
+
const ix = await getClosePostAssertionsInstructionAsync({
|
|
987
|
+
owner,
|
|
988
|
+
vault,
|
|
989
|
+
expectedDigest,
|
|
990
|
+
});
|
|
991
|
+
return run(rpc, owner, network, [ix], opts);
|
|
992
|
+
}
|
|
993
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
994
|
+
// M-2 (pre-redeploy audit 2026-05-21): Phase 8 ownership-transfer mutations.
|
|
995
|
+
//
|
|
996
|
+
// On-chain reference: programs/sigil/src/instructions/
|
|
997
|
+
// - initiate_ownership_transfer.rs (owner queues transfer + 48h timelock)
|
|
998
|
+
// - accept_ownership_transfer.rs (new wallet-owner finalises after timelock)
|
|
999
|
+
// - accept_ownership_transfer_multisig.rs (Squads V4 PDA accepts via CPI)
|
|
1000
|
+
// - cancel_ownership_transfer.rs (current owner aborts during timelock)
|
|
1001
|
+
//
|
|
1002
|
+
// Cosign gate: when `policy.cosign_required = true`, `queue_policy_update`
|
|
1003
|
+
// AND `initiate_ownership_transfer` BOTH require a non-owner co-signer in
|
|
1004
|
+
// `remaining_accounts` (D4 symmetric cosign gate). The mutations below
|
|
1005
|
+
// expose the `cosignSession` parameter; pass `undefined` when the policy
|
|
1006
|
+
// does not require cosign.
|
|
1007
|
+
//
|
|
1008
|
+
// LBL-01: all four ix derive vault state by reading
|
|
1009
|
+
// `vault.vault_authority` (immutable) — the on-chain accept handler
|
|
1010
|
+
// overwrites `vault.owner` but the PDA address stays put.
|
|
1011
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
1012
|
+
/**
|
|
1013
|
+
* Queue an ownership transfer for `vault`. The pending PDA carries the
|
|
1014
|
+
* target `newOwner` plus the configured timelock (default 48h). The
|
|
1015
|
+
* transfer is finalised only by a follow-up `acceptOwnershipTransfer`
|
|
1016
|
+
* (wallet) or `acceptOwnershipTransferMultisig` (Squads V4).
|
|
1017
|
+
*
|
|
1018
|
+
* @param newOwner The pubkey that will become `vault.owner` after
|
|
1019
|
+
* accept. MUST NOT be a system program / sysvar
|
|
1020
|
+
* (rejected on-chain by `ErrInvalidOwnershipTarget`).
|
|
1021
|
+
* @param isMultisigTarget Set to `true` when `newOwner` is a Squads V4
|
|
1022
|
+
* multisig PDA — the on-chain handler enforces
|
|
1023
|
+
* that the matching accept variant is used.
|
|
1024
|
+
*
|
|
1025
|
+
* Cosign behaviour: when `policy.cosign_required = true`, the on-chain
|
|
1026
|
+
* handler enforces a non-owner co-signer; pass the cosign session pubkey
|
|
1027
|
+
* via the SDK's transaction-signing layer when building the tx. Pre-G6
|
|
1028
|
+
* (audit 2026-05-18) policies without cosign opt-in succeed without one.
|
|
1029
|
+
*
|
|
1030
|
+
* Replays the H-3 "no double-initiate" rule: a second initiate without
|
|
1031
|
+
* an intervening `cancelOwnershipTransfer` fails with
|
|
1032
|
+
* `ErrPendingOwnershipExists` (6103).
|
|
1033
|
+
*/
|
|
1034
|
+
export async function initiateOwnershipTransfer(rpc, vault, owner, network, newOwner, isMultisigTarget, opts) {
|
|
1035
|
+
const ix = await getInitiateOwnershipTransferInstructionAsync({
|
|
1036
|
+
owner,
|
|
1037
|
+
vault,
|
|
1038
|
+
newOwner,
|
|
1039
|
+
isMultisigTarget,
|
|
1040
|
+
});
|
|
543
1041
|
return run(rpc, owner, network, [ix], opts);
|
|
544
1042
|
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Finalise a previously-initiated ownership transfer when the incoming
|
|
1045
|
+
* owner is a wallet (keypair) signer. The new owner MUST be the signer
|
|
1046
|
+
* of the enclosing transaction; the on-chain handler verifies their key
|
|
1047
|
+
* matches `pending.new_owner`.
|
|
1048
|
+
*
|
|
1049
|
+
* Timelock: the transfer is only accepted after the configured timelock
|
|
1050
|
+
* has elapsed (default 48h). Calls before the window expires fail with
|
|
1051
|
+
* `ErrPendingOwnershipNotReady` (6104).
|
|
1052
|
+
*
|
|
1053
|
+
* Note: the `owner` argument on this function is the NEW owner who
|
|
1054
|
+
* accepts — kept as `owner` for parity with the rest of the mutations
|
|
1055
|
+
* surface, but semantically `newOwner.address` is what lands on-chain
|
|
1056
|
+
* as `vault.owner`. `vault.vault_authority` (the immutable PDA seed)
|
|
1057
|
+
* is unchanged by this ix.
|
|
1058
|
+
*/
|
|
1059
|
+
export async function acceptOwnershipTransfer(rpc, vault, newOwner, network, opts) {
|
|
1060
|
+
const ix = await getAcceptOwnershipTransferInstructionAsync({
|
|
1061
|
+
newOwner,
|
|
1062
|
+
vault,
|
|
1063
|
+
});
|
|
1064
|
+
return run(rpc, newOwner, network, [ix], opts);
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Finalise a previously-initiated ownership transfer when the incoming
|
|
1068
|
+
* owner is a Squads V4 multisig PDA (NOT a wallet signer). The Squads
|
|
1069
|
+
* program is the CPI caller; the multisig PDA itself has no private key.
|
|
1070
|
+
*
|
|
1071
|
+
* The on-chain handler verifies:
|
|
1072
|
+
* 1. `multisig_pda.owner == SQUADS_V4_PROGRAM_ID`
|
|
1073
|
+
* 2. `multisig_pda.key() == pending.new_owner`
|
|
1074
|
+
* 3. `pending.is_multisig_target == true`
|
|
1075
|
+
*
|
|
1076
|
+
* Caller is responsible for routing this ix through the Squads V4
|
|
1077
|
+
* proposal flow so it reaches the on-chain handler under the Squads
|
|
1078
|
+
* program signer seeds. The `feePayer` MUST be a wallet signer that
|
|
1079
|
+
* funds the tx; this SDK call accepts that signer separately so the
|
|
1080
|
+
* Squads PDA is NOT a signer at the kit transaction-signing layer.
|
|
1081
|
+
*
|
|
1082
|
+
* Timelock + cosign rules identical to {@link acceptOwnershipTransfer}.
|
|
1083
|
+
*/
|
|
1084
|
+
export async function acceptOwnershipTransferMultisig(rpc, vault, multisigPda, feePayer, network, opts) {
|
|
1085
|
+
const ix = await getAcceptOwnershipTransferMultisigInstructionAsync({
|
|
1086
|
+
multisigPda,
|
|
1087
|
+
vault,
|
|
1088
|
+
});
|
|
1089
|
+
return run(rpc, feePayer, network, [ix], opts);
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Cancel a queued ownership transfer during the timelock window. The
|
|
1093
|
+
* `currentOwner` (signer) MUST match `pending.current_owner` (the
|
|
1094
|
+
* pubkey that called `initiateOwnershipTransfer`); the on-chain handler
|
|
1095
|
+
* rejects with a require-keys-eq violation otherwise.
|
|
1096
|
+
*
|
|
1097
|
+
* Closes the pending PDA and returns rent to the current owner. After
|
|
1098
|
+
* this ix lands, `initiateOwnershipTransfer` is callable again to queue
|
|
1099
|
+
* a different target.
|
|
1100
|
+
*
|
|
1101
|
+
* Cosign behaviour (D4 symmetric gate): if `policy.cosign_required`,
|
|
1102
|
+
* cancellation also requires a non-owner co-signer.
|
|
1103
|
+
*/
|
|
1104
|
+
export async function cancelOwnershipTransfer(rpc, vault, currentOwner, network, opts) {
|
|
1105
|
+
const ix = await getCancelOwnershipTransferInstructionAsync({
|
|
1106
|
+
currentOwner,
|
|
1107
|
+
vault,
|
|
1108
|
+
});
|
|
1109
|
+
return run(rpc, currentOwner, network, [ix], opts);
|
|
1110
|
+
}
|
|
545
1111
|
//# sourceMappingURL=mutations.js.map
|