Skip to content
Merged
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
53 changes: 1 addition & 52 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,12 @@

/// Allows the verifier (or authorized party) to validate milestone completion.
///
<<<<<<< doc/cei-soroban
/// This function follows the **Checks-Effects-Interactions** pattern:
/// 1. **Checks**: Verifies vault exists, is `Active`, and the caller is authorized.
/// 2. **Effects**: Sets `milestone_validated = true` and emits `milestone_validated`.
///
/// # Errors
/// - `Error::VaultNotFound`: if `vault_id` does not exist.
/// - `Error::VaultNotActive`: if the vault is already in a terminal state.
/// - `Error::MilestoneExpired`: if the current time is at or past `end_timestamp`.
/// - `Error::NotAuthorized`: if the caller is not the `verifier` (or `creator` if no verifier).
=======
/// # Safety and Trust
/// When verifier is `Some(addr)`, only that address may validate; when `None`, only the creator may validate.
/// Rejects when current time >= `end_timestamp` (`Error::MilestoneExpired`).
///
/// # Events
/// Emits `milestone_validated` on success.
>>>>>>> main
pub fn validate_milestone(env: Env, vault_id: u32) -> Result<bool, Error> {
let vault_key = DataKey::Vault(vault_id);
let mut vault: ProductivityVault = env
Expand Down Expand Up @@ -230,19 +218,6 @@
// release_funds
// -----------------------------------------------------------------------

<<<<<<< doc/cei-soroban
/// Releases vault funds to the success destination.
///
/// This function follows the **Checks-Effects-Interactions** pattern:
/// 1. **Checks**: Verifies vault exists, is `Active`, and release conditions are met.
/// 2. **Effects**: Sets `status = Completed` and emits `funds_released`.
/// 3. **Interactions**: Transfers USDC tokens from the contract to `success_destination`.
///
/// # Errors
/// - `Error::VaultNotFound`: if `vault_id` does not exist.
/// - `Error::VaultNotActive`: if the vault is already in a terminal state.
/// - `Error::NotAuthorized`: if called before deadline without milestone validation.
=======
/// Release vault funds to `success_destination`.
///
/// # Prerequisites
Expand All @@ -251,7 +226,6 @@
///
/// # Events
/// Emits `funds_released` with the released amount.
>>>>>>> main
pub fn release_funds(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 Expand Up @@ -297,19 +271,6 @@
// redirect_funds
// -----------------------------------------------------------------------

<<<<<<< doc/cei-soroban
/// Redirects funds to the failure destination.
///
/// This function follows the **Checks-Effects-Interactions** pattern:
/// 1. **Checks**: Verifies vault exists, is `Active`, deadline passed, and no validation occurred.
/// 2. **Effects**: Sets `status = Failed` and emits `funds_redirected`.
/// 3. **Interactions**: Transfers USDC tokens from the contract to `failure_destination`.
///
/// # Errors
/// - `Error::VaultNotFound`, `Error::VaultNotActive`.
/// - `Error::InvalidTimestamp`: if called before the `end_timestamp`.
/// - `Error::NotAuthorized`: if the milestone has already been validated.
=======
/// Redirect funds to `failure_destination` (e.g. after deadline without validation).
///
/// # Prerequisites
Expand All @@ -319,7 +280,6 @@
///
/// # Events
/// Emits `funds_redirected` with the redirected amount.
>>>>>>> main
pub fn redirect_funds(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 Expand Up @@ -366,23 +326,12 @@

/// Cancel vault and return funds to creator.
///
<<<<<<< doc/cei-soroban
/// This function follows the **Checks-Effects-Interactions** pattern:
/// 1. **Checks**: Verifies vault exists, is `Active`, and `creator` authorization.
/// 2. **Effects**: Sets `status = Cancelled` and emits `vault_cancelled`.
/// 3. **Interactions**: Transfers USDC tokens back to the `creator`.
///
/// # Errors
/// - `Error::VaultNotFound`, `Error::VaultNotActive`.
/// - `Error::NotAuthorized`: if `creator.require_auth()` fails.
=======
/// # Prerequisites
/// - Only the creator may call this method (`creator.require_auth()`).
/// - Vault status must be `Active`.
///
/// # Events
/// Emits `vault_cancelled`.
>>>>>>> main
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 Expand Up @@ -1332,7 +1281,7 @@
let client = setup.client();
client.cancel_vault(&999u32, &setup.usdc_token);
}
}

Check failure on line 1284 in src/lib.rs

View workflow job for this annotation

GitHub Actions / coverage

unexpected closing delimiter: `}`

#[cfg(test)]
mod test {
Expand Down Expand Up @@ -1608,4 +1557,4 @@
assert_eq!(token_client.balance(&creator), 0);
assert_eq!(token_client.balance(&vault_contract), MIN_AMOUNT);
}
}
}
Loading