Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,21 @@ impl DisciplrVault {
// cancel_vault
// -----------------------------------------------------------------------

/// Cancel vault and return funds to creator.
/// Cancel an active vault and return its escrowed funds to the creator.
///
/// Only the original vault creator may cancel, and the creator must authorize
/// the call. Cancellation is available only while the vault is still Active;
/// terminal vault states are rejected before any token transfer is attempted.
///
/// # Preconditions
/// - `vault_id` must identify an existing vault.
/// - The vault must still be `VaultStatus::Active`.
/// - The vault creator must authorize the call.
///
/// # Errors
/// - Returns `Error::VaultNotFound` when the vault id is unknown.
/// - Returns `Error::VaultNotActive` for terminal vault states.
/// - Soroban authorization fails if the creator does not authorize the call.
pub fn cancel_vault(env: Env, vault_id: u32, usdc_token: Address) -> Result<bool, Error> {
let vault_key = DataKey::Vault(vault_id);
let mut vault: ProductivityVault = env
Expand Down
Loading