Skip to content
Closed
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
40 changes: 40 additions & 0 deletions contracts/split/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
use soroban_sdk::{symbol_short, Address, Bytes, Env, Vec};

/// Emitted when an invoice reaches a completed state (Released) with a full
/// structured summary optimised for webhook / off-chain processing.
pub fn invoice_completed(
env: &Env,
invoice_id: u64,
creator: &Address,
total: i128,
recipient_count: u32,
completion_timestamp: u64,
) {
env.events().publish(
(symbol_short!("inv_cmpl"), invoice_id),
(invoice_id, creator.clone(), total, recipient_count, completion_timestamp),
);
}

/// Emitted when a new invoice is created.
pub fn invoice_created(env: &Env, invoice_id: u64, creator: &Address, total: i128, metadata: &Option<Bytes>) {
env.events().publish(
Expand Down Expand Up @@ -30,6 +46,30 @@ pub fn invoice_refunded(env: &Env, invoice_id: u64) {
.publish((symbol_short!("inv_ref"), invoice_id), ());
}

/// Emitted when a recipient is added to an existing invoice.
pub fn recipient_added(env: &Env, invoice_id: u64, caller: &Address, recipient: &Address, amount: i128) {
env.events().publish(
(symbol_short!("add_rec"), invoice_id),
(caller.clone(), recipient.clone(), amount),
);
}

/// Emitted when a future payment is scheduled.
pub fn payment_scheduled(env: &Env, invoice_id: u64, payer: &Address, amount: i128, execute_at: u64) {
env.events().publish(
(symbol_short!("sched_pay"), invoice_id),
(payer.clone(), amount, execute_at),
);
}

/// Emitted when the insurance pool is drawn from to cover a refund shortfall.
pub fn insurance_used(env: &Env, invoice_id: u64, shortfall: i128, remaining: i128) {
env.events().publish(
(symbol_short!("ins_used"), invoice_id),
(shortfall, remaining),
);
}

/// Emitted once per unique payer when their refund is transferred.
pub fn payer_refunded(env: &Env, invoice_id: u64, payer: &Address, amount: i128) {
env.events().publish(
Expand Down
Loading