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
14 changes: 12 additions & 2 deletions contracts/invoice-escrow/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ pub enum Error {
/// Contract is paused and the requested operation is temporarily disabled.
Paused = 15,
/// Payer is not the authorized debtor for this invoice.
InvalidPayer = 15,
InvalidPayer = 16,
/// Due date is invalid (e.g., in the past or zero).
InvalidDueDate = 16,
InvalidDueDate = 17,
/// Escrow is already in a disputed state.
AlreadyDisputed = 18,
/// Escrow is not in a disputed state; cannot resolve.
NotDisputed = 19,
/// The dispute timeout window has not yet elapsed.
DisputeNotExpired = 20,
/// The dispute has already been resolved.
DisputeAlreadyResolved = 21,
/// Resolve favour is invalid (must be "seller" or "buyer").
InvalidDisputeFavour = 22,
}
29 changes: 28 additions & 1 deletion contracts/invoice-escrow/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Event definitions for state changes (escrow_created, escrow_funded, payment_settled).

use soroban_sdk::{Address, Env, Symbol};
use soroban_sdk::{Address, Bytes, Env, Symbol};

/// Publish escrow_created event.
pub fn escrow_created(
Expand Down Expand Up @@ -102,3 +102,30 @@ pub fn paused_updated(env: &Env, old_paused: bool, new_paused: bool) {
(old_paused, new_paused),
);
}

/// Publish dispute_raised event.
/// Data: (invoice_id, raiser, reason, raised_at)
pub fn dispute_raised(env: &Env, inv_id: Symbol, raiser: &Address, reason: &Bytes, raised_at: u64) {
env.events().publish(
(Symbol::new(env, "dispute_raised"),),
(inv_id, raiser, reason, raised_at),
);
}

/// Publish dispute_resolved event.
/// Data: (invoice_id, resolved_by, favour, amount_to_winner, timeout_fallback)
/// `favour` is "seller" or "buyer" as a Symbol.
/// `timeout_fallback` is true when the default fallback path was taken.
pub fn dispute_resolved(
env: &Env,
inv_id: Symbol,
resolved_by: &Address,
favour: Symbol,
amount: i128,
timeout_fallback: bool,
) {
env.events().publish(
(Symbol::new(env, "dispute_resolved"),),
(inv_id, resolved_by, favour, amount, timeout_fallback),
);
}
Loading