Skip to content
Merged
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
16 changes: 4 additions & 12 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,10 @@ mirrors `PersistedVault.status` in `src/types/vaults.ts`. Emitted events
`vault_completed`, `vault_cancelled`, `vault_withdrawn`) align with the topics
consumed by the backend event parser.

### Event reference

| Event | Topics | Data | Notes |
|---|---|---|---|
| `vault_created` | `(vault_created, creator)` | `amount` | Emitted by `create_vault`. |
| `vault_staked` | `(vault_staked, from)` | `amount` | Legacy funding event; preserved for backward-compatible listeners. |
| `vault_funded` | `(vault_funded, token, from)` | `net_staked_amount` | Rich funding event emitted alongside `vault_staked`. Carries the SEP-41 token address so `eventParser.ts` can reconcile the contract address without a separate Horizon query. |
| `milestone_checked_in` | `(milestone_checked_in, caller, source)` | `milestone_index` | `source` is `"verifier"` or `"oracle"`. |
| `vault_slashed` | `(vault_slashed, failure_destination)` | `slashed_amount` | Emitted by `slash_on_miss`. |
| `vault_completed` | `(vault_completed, success_destination)` | `released_amount` | Emitted by `claim`. |
| `vault_cancelled` | `(vault_cancelled, creator)` | `0` | Emitted by `cancel_vault` or `withdraw` on Draft. |
| `vault_withdrawn` | `(vault_withdrawn, creator)` | `refunded_amount` | Emitted by `withdraw` on Active. |
### Error Handling & Precise Deadline Errors
To allow the backend to render precise, unambiguous user-facing errors:
- **`Error::DeadlineInPast` (28)**: Returned when the configured `end_timestamp` is less than or equal to the current ledger timestamp.
- **`Error::InvalidDeadline` (4)**: Reserved strictly for structural mismatches (such as a milestone `due_date` exceeding `end_timestamp` or non-monotonic due-date ordering).

## Build & test

Expand Down
4 changes: 3 additions & 1 deletion contracts/accountability_vault/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ crate-type = ["cdylib", "rlib"]
soroban-sdk = "=21.7.7"

[dev-dependencies]
soroban-sdk = { version = "=21.7.7", features = ["testutils"] }
soroban-sdk = { version = "21.0.0", features = ["testutils"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

[lints]
workspace = true
16 changes: 6 additions & 10 deletions contracts/accountability_vault/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,8 @@ pub enum Error {
NothingToWithdraw = 15,
/// Received amount does not match the declared vault amount.
AmountMismatch = 16,
/// Milestone list exceeds the bounded loop limit.
TooManyMilestones = 17,
/// The requested token is not in the deployment-wide allowlist.
TokenNotAllowed = 26,
/// Admin storage is already initialized.
AdminAlreadyInitialized = 27,
/// Caller is not the configured admin.
NotAdmin = 28,
/// Deadline is in the past.
DeadlineInPast = 28,
}

/// Accountability vault contract entry point.
Expand Down Expand Up @@ -224,8 +218,10 @@ impl AccountabilityVault {
if amount <= 0 {
return Err(Error::InvalidAmount);
}
let now = env.ledger().timestamp();
if end_timestamp <= now || end_timestamp > now + MAX_DEADLINE_HORIZON {
if end_timestamp <= env.ledger().timestamp() {
return Err(Error::DeadlineInPast);
}
if end_timestamp > env.ledger().timestamp() + MAX_DEADLINE_HORIZON {
return Err(Error::InvalidDeadline);
}
if milestones.is_empty() {
Expand Down
Loading
Loading