Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ create_commitment ──► fund_escrow ──► release (matured: p
| --- | --- |
| `initialize(admin, token, fee_recipient, safe_default_penalty_bps, balanced_default_penalty_bps, aggressive_default_penalty_bps)` | One-time setup of admin, escrow token (SAC), fee recipient, and default penalties for each risk profile. |
| `create_commitment(owner, asset, amount, risk, duration_days, penalty_bps)` | Create an unfunded commitment with explicit penalty; returns its `id`. |
| `create_commitment_with_default_penalty(owner, asset, amount, risk, duration_days)` | Create an unfunded commitment using the default penalty for the risk profile; returns its `id`. |
| `create_commitment_default(owner, asset, amount, risk, duration_days)` | Create an unfunded commitment using the default penalty for the risk profile; returns its `id`. |
| `fund_escrow(commitment_id)` | Transfer `amount` from owner into the contract (`Created → Funded`). |
| `deposit_yield_pool(admin, amount)` | Admin-only deposit of yield tokens into the contract yield pool. |
| `get_yield_pool_balance()` | Read the yield pool balance available for matured release payouts. |
| `release(commitment_id, caller)` | Return principal plus accrued yield to owner once matured (`Funded → Released`). |
| `settle_commitment(commitment_id, caller)` | Alias for `release` that returns a settlement result matching backend ABI expectations. |
| `refund(commitment_id)` | Early-exit refund of principal minus `penalty_bps` (`Funded → Refunded`). |
| `dispute(commitment_id, caller, reason)` | Freeze a funded commitment pending admin resolution. The reason is automatically categorized. |
| `resolve_dispute(commitment_id, release_to_owner)` | Admin-only settlement of a disputed commitment. |
Expand Down Expand Up @@ -125,7 +126,7 @@ recipient on `refund` / adverse `resolve_dispute`.
### Default penalties per risk profile

Default penalties are configured once at initialization and automatically applied
to commitments created via `create_commitment_with_default_penalty()`. This
to commitments created via `create_commitment_default()`. This
simplifies commitment creation when consistent penalty tiers are desired.

#### Backend-aligned defaults
Expand All @@ -147,15 +148,15 @@ The contract provides two ways to create commitments:
- Overrides default if needed
- Useful for custom deal terms

2. **Default penalty** (`create_commitment_with_default_penalty`): Use the profile default
2. **Default penalty** (`create_commitment_default`): Use the profile default
- Simplifies API calls
- Ensures consistency across commitments
- No penalty parameter needed

Example:
```rust
// Use default penalty (e.g., 3% for Balanced risk)
let id = contract.create_commitment_with_default_penalty(
let id = contract.create_commitment_default(
&owner, &asset, &1000, &RiskProfile::Balanced, &30
)?;

Expand Down
333 changes: 333 additions & 0 deletions contracts/escrow/cargo_test_output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,333 @@
Compiling commitlabs-escrow v0.1.0 (/workspaces/Commitlabs-Frontend/contracts/escrow)
error: an inner attribute is not permitted in this context
--> escrow/src/test.rs:37:1
|
37 | #![cfg(test)]
| ^^^^^^^^^^^^^
38 |
39 | use super::*;
| ------------- the inner attribute doesn't annotate this `use` import
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
help: to annotate the `use` import, change the attribute from inner to outer style
|
37 - #![cfg(test)]
37 + #[cfg(test)]
|

error: contract function name is too long: 38, max is 32
--> escrow/src/lib.rs:350:12
|
350 | pub fn create_commitment_with_default_penalty(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0592]: duplicate definitions with name `is_paused`
--> escrow/src/lib.rs:786:5
|
268 | pub fn is_paused(env: Env) -> bool {
| ---------------------------------- other definition for `is_paused`
...
786 | fn is_paused(env: &Env) -> bool {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `is_paused`

error[E0599]: no variant, associated function, or constant named `Paused` found for enum `DataKey` in the current scope
--> escrow/src/lib.rs:246:48
|
25 | pub enum DataKey {
| ---------------- variant, associated function, or constant `Paused` not found for this enum
...
246 | env.storage().instance().set(&DataKey::Paused, &true);
| ^^^^^^ variant, associated function, or constant not found in `DataKey`

warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type
--> escrow/src/lib.rs:248:14
|
248 | .publish((Symbol::new(&env, "pause"), admin), ());
| ^^^^^^^
|
= note: `#[warn(deprecated)]` on by default

error[E0599]: no variant, associated function, or constant named `Paused` found for enum `DataKey` in the current scope
--> escrow/src/lib.rs:261:48
|
25 | pub enum DataKey {
| ---------------- variant, associated function, or constant `Paused` not found for this enum
...
261 | env.storage().instance().set(&DataKey::Paused, &false);
| ^^^^^^ variant, associated function, or constant not found in `DataKey`

warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type
--> escrow/src/lib.rs:263:14
|
263 | .publish((Symbol::new(&env, "unpause"), admin), ());
| ^^^^^^^

error[E0599]: no variant, associated function, or constant named `Paused` found for enum `DataKey` in the current scope
--> escrow/src/lib.rs:271:28
|
25 | pub enum DataKey {
| ---------------- variant, associated function, or constant `Paused` not found for this enum
...
271 | .get(&DataKey::Paused)
| ^^^^^^ variant, associated function, or constant not found in `DataKey`

error[E0063]: missing field `accrued_yield` in initializer of `Commitment`
--> escrow/src/lib.rs:316:26
|
316 | let commitment = Commitment {
| ^^^^^^^^^^ missing `accrued_yield`

warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type
--> escrow/src/lib.rs:334:22
|
334 | env.events().publish(
| ^^^^^^^

warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type
--> escrow/src/lib.rs:395:22
|
395 | env.events().publish(
| ^^^^^^^

warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type
--> escrow/src/lib.rs:420:22
|
420 | env.events().publish(
| ^^^^^^^

warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type
--> escrow/src/lib.rs:443:22
|
443 | env.events().publish(
| ^^^^^^^

error[E0599]: no variant, associated function, or constant named `InsufficientYieldPool` found for enum `Error` in the current scope
--> escrow/src/lib.rs:468:31
|
127 | pub enum Error {
| -------------- variant, associated function, or constant `InsufficientYieldPool` not found for this enum
...
468 | return Err(Error::InsufficientYieldPool);
| ^^^^^^^^^^^^^^^^^^^^^ variant, associated function, or constant not found in `Error`

warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type
--> escrow/src/lib.rs:480:22
|
480 | env.events().publish(
| ^^^^^^^

warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type
--> escrow/src/lib.rs:582:22
|
582 | env.events().publish(
| ^^^^^^^

error[E0599]: no variant, associated function, or constant named `InsufficientYieldPool` found for enum `Error` in the current scope
--> escrow/src/lib.rs:617:39
|
127 | pub enum Error {
| -------------- variant, associated function, or constant `InsufficientYieldPool` not found for this enum
...
617 | return Err(Error::InsufficientYieldPool);
| ^^^^^^^^^^^^^^^^^^^^^ variant, associated function, or constant not found in `Error`

warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type
--> escrow/src/lib.rs:633:22
|
633 | env.events().publish(
| ^^^^^^^

error[E0599]: no variant, associated function, or constant named `Attestations` found for enum `DataKey` in the current scope
--> escrow/src/lib.rs:658:28
|
25 | pub enum DataKey {
| ---------------- variant, associated function, or constant `Attestations` not found for this enum
...
658 | .get(&DataKey::Attestations(commitment_id))
| ^^^^^^^^^^^^ variant, associated function, or constant not found in `DataKey`

error[E0599]: no variant, associated function, or constant named `Attestations` found for enum `DataKey` in the current scope
--> escrow/src/lib.rs:669:28
|
25 | pub enum DataKey {
| ---------------- variant, associated function, or constant `Attestations` not found for this enum
...
669 | .set(&DataKey::Attestations(commitment_id), &attestations);
| ^^^^^^^^^^^^ variant, associated function, or constant not found in `DataKey`

warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type
--> escrow/src/lib.rs:671:22
|
671 | env.events().publish(
| ^^^^^^^

error[E0599]: no variant, associated function, or constant named `Attestations` found for enum `DataKey` in the current scope
--> escrow/src/lib.rs:687:28
|
25 | pub enum DataKey {
| ---------------- variant, associated function, or constant `Attestations` not found for this enum
...
687 | .get(&DataKey::Attestations(commitment_id))
| ^^^^^^^^^^^^ variant, associated function, or constant not found in `DataKey`

warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type
--> escrow/src/lib.rs:753:22
|
753 | env.events().publish(
| ^^^^^^^

error[E0599]: no variant, associated function, or constant named `Paused` found for enum `DataKey` in the current scope
--> escrow/src/lib.rs:789:28
|
25 | pub enum DataKey {
| ---------------- variant, associated function, or constant `Paused` not found for this enum
...
789 | .get(&DataKey::Paused)
| ^^^^^^ variant, associated function, or constant not found in `DataKey`

error[E0308]: mismatched types
--> escrow/src/lib.rs:794:28
|
794 | if Self::is_paused(env) {
| --------------- ^^^ expected `Env`, found `&Env`
| |
| arguments to this function are incorrect
|
note: associated function defined here
--> escrow/src/lib.rs:268:12
|
268 | pub fn is_paused(env: Env) -> bool {
| ^^^^^^^^^ --------
help: consider using clone here
|
794 | if Self::is_paused(env.clone()) {
| ++++++++

error[E0599]: no variant, associated function, or constant named `YieldPool` found for enum `DataKey` in the current scope
--> escrow/src/lib.rs:828:28
|
25 | pub enum DataKey {
| ---------------- variant, associated function, or constant `YieldPool` not found for this enum
...
828 | .get(&DataKey::YieldPool)
| ^^^^^^^^^ variant, associated function, or constant not found in `DataKey`

error[E0599]: no variant, associated function, or constant named `YieldPool` found for enum `DataKey` in the current scope
--> escrow/src/lib.rs:833:48
|
25 | pub enum DataKey {
| ---------------- variant, associated function, or constant `YieldPool` not found for this enum
...
833 | env.storage().instance().set(&DataKey::YieldPool, &amount);
| ^^^^^^^^^ variant, associated function, or constant not found in `DataKey`

error[E0599]: no method named `to_lowercase` found for reference `&soroban_sdk::String` in the current scope
--> escrow/src/lib.rs:848:35
|
848 | let reason_lower = reason.to_lowercase();
| ^^^^^^^^^^^^ method not found in `&soroban_sdk::String`

error[E0308]: mismatched types
--> escrow/src/test.rs:8:23
|
8 | f.env.set_auths(&[&f.admin]);
| ^^^^^^^^ expected `SorobanAuthorizationEntry`, found `&Address`

error[E0599]: no method named `set_admin` found for struct `EscrowContractClient<'a>` in the current scope
--> escrow/src/test.rs:9:14
|
9 | f.client.set_admin(&new_admin);
| ^^^^^^^^^ method not found in `EscrowContractClient<'_>`
|
::: escrow/src/lib.rs:177:1
|
177 | #[contract]
| ----------- method `set_admin` not found for this struct
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `set_admin`, perhaps you need to implement it:
candidate #1: `StellarAssetInterface`

error[E0308]: mismatched types
--> escrow/src/test.rs:11:23
|
11 | f.env.set_auths(&[&new_admin]);
| ^^^^^^^^^^ expected `SorobanAuthorizationEntry`, found `&Address`

error[E0599]: no method named `set_fee_recipient` found for struct `EscrowContractClient<'a>` in the current scope
--> escrow/src/test.rs:12:14
|
12 | f.client.set_fee_recipient(&new_fee);
| ^^^^^^^^^^^^^^^^^ method not found in `EscrowContractClient<'_>`
|
::: escrow/src/lib.rs:177:1
|
177 | #[contract]
| ----------- method `set_fee_recipient` not found for this struct

error[E0308]: mismatched types
--> escrow/src/test.rs:29:23
|
29 | f.env.set_auths(&[&not_admin]);
| ^^^^^^^^^^ expected `SorobanAuthorizationEntry`, found `&Address`

error[E0599]: no method named `try_set_admin` found for struct `EscrowContractClient<'a>` in the current scope
--> escrow/src/test.rs:30:24
|
30 | let res = f.client.try_set_admin(&new_admin);
| ^^^^^^^^^^^^^ method not found in `EscrowContractClient<'_>`
|
::: escrow/src/lib.rs:177:1
|
177 | #[contract]
| ----------- method `try_set_admin` not found for this struct

error[E0599]: no method named `try_set_fee_recipient` found for struct `EscrowContractClient<'a>` in the current scope
--> escrow/src/test.rs:34:25
|
34 | let res2 = f.client.try_set_fee_recipient(&new_fee);
| ^^^^^^^^^^^^^^^^^^^^^ method not found in `EscrowContractClient<'_>`
|
::: escrow/src/lib.rs:177:1
|
177 | #[contract]
| ----------- method `try_set_fee_recipient` not found for this struct

error[E0061]: this method takes 6 arguments but 3 arguments were supplied
--> escrow/src/test.rs:110:10
|
110 | .try_initialize(&f.admin, &f.asset, &other);
| ^^^^^^^^^^^^^^---------------------------- three arguments of type `&u32`, `&u32`, and `&u32` are missing
|
note: method defined here
--> escrow/src/lib.rs:194:12
|
194 | pub fn initialize(
| ^^^^^^^^^^
...
199 | safe_default_penalty_bps: u32,
| -----------------------------
200 | balanced_default_penalty_bps: u32,
| ---------------------------------
201 | aggressive_default_penalty_bps: u32,
| -----------------------------------
help: provide the arguments
|
110 | .try_initialize(&f.admin, &f.asset, &other, /* &u32 */, /* &u32 */, /* &u32 */);
| ++++++++++++++++++++++++++++++++++++

error[E0599]: no variant, associated function, or constant named `InsufficientYieldPool` found for enum `Error` in the current scope
--> escrow/src/test.rs:209:35
|
209 | assert_eq!(res, Err(Ok(Error::InsufficientYieldPool)));
| ^^^^^^^^^^^^^^^^^^^^^ variant, associated function, or constant not found in `Error`
|
::: escrow/src/lib.rs:127:1
|
127 | pub enum Error {
| -------------- variant, associated function, or constant `InsufficientYieldPool` not found for this enum

Some errors have detailed explanations: E0061, E0063, E0308, E0592, E0599.
For more information about an error, try `rustc --explain E0061`.
warning: `commitlabs-escrow` (lib test) generated 11 warnings
error: could not compile `commitlabs-escrow` (lib test) due to 26 previous errors; 11 warnings emitted
Loading