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
46 changes: 43 additions & 3 deletions contracts/split/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::types::{DisputeOutcome, FeeSplit, InvoicePhase, InvoiceStatus, RepScore, TimelockAction};
//! # Event naming convention
//!
//! All split-contracts events follow a consistent topic layout:
Expand Down Expand Up @@ -1580,15 +1581,15 @@ pub fn invoice_dispute_raised(

/// Emitted on every individual cosigner approval recorded via `approve_release`.
/// Topics: (split, CosignerApproved, invoice_id)
/// Data: (cosigner, ledger)
pub fn cosigner_approved(env: &Env, invoice_id: u64, cosigner: &Address) {
/// Data: (cosigner, approvals_so_far, ledger)
pub fn cosigner_approved(env: &Env, invoice_id: u64, cosigner: &Address, approvals_so_far: u32) {
env.events().publish(
(
symbol_short!("split"),
soroban_sdk::Symbol::new(env, "CosignerApproved"),
invoice_id,
),
(cosigner.clone(), env.ledger().sequence()),
(cosigner.clone(), approvals_so_far, env.ledger().sequence()),
);
}

Expand Down Expand Up @@ -1708,6 +1709,22 @@ pub fn creator_fee_paid(env: &Env, invoice_id: u64, creator: &Address, fee_amoun
);
}

/// Issue #685: Emitted when a creator-declared fee (`creator_fee_bps`) is
/// deducted from recipient payouts at release time.
///
/// Topics: (split, creator_fee_collected, invoice_id)
/// Data: (creator, fee_amount)
pub fn creator_fee_collected(env: &Env, invoice_id: u64, creator: &Address, fee_amount: i128) {
env.events().publish(
(
symbol_short!("split"),
soroban_sdk::Symbol::new(env, "creator_fee_collected"),
invoice_id,
),
(creator.clone(), fee_amount),
);
}

// ---------------------------------------------------------------------------
// Issue #560: Creator Migration
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -1787,6 +1804,29 @@ pub fn recipient_share_locked(
);
}

/// Issue #684: Emitted at every `InvoicePhase` transition (Draft -> Active ->
/// Locked -> Released).
/// Topics: (split, phase_chg, invoice_id)
/// Data: (old_phase, new_phase, event_seq)
pub fn invoice_phase_changed(
env: &Env,
invoice_id: u64,
old_phase: &InvoicePhase,
new_phase: &InvoicePhase,
) {
let phase_sym = |phase: &InvoicePhase| match phase {
InvoicePhase::Draft => symbol_short!("draft"),
InvoicePhase::Active => symbol_short!("active"),
InvoicePhase::Locked => symbol_short!("locked"),
InvoicePhase::Released => symbol_short!("released"),
};
let event_seq = next_seq(env, invoice_id);
env.events().publish(
(symbol_short!("split"), symbol_short!("phase_chg"), invoice_id),
(phase_sym(old_phase), phase_sym(new_phase), event_seq),
);
}

/// Emitted when an admin unlocks a recipient's share of an invoice.
pub fn recipient_share_unlocked(
env: &Env,
Expand Down
4 changes: 3 additions & 1 deletion contracts/split/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8015,7 +8015,7 @@ impl SplitContract {
env.storage()
.persistent()
.set(&cosign_key(invoice_id), &approvals);
events::cosigner_approved(&env, invoice_id, &cosigner);
events::cosigner_approved(&env, invoice_id, &cosigner, approvals.len());
append_audit_entry(&env, invoice_id, symbol_short!("cosign"), &cosigner);

let threshold: u32 = env
Expand Down Expand Up @@ -10470,6 +10470,7 @@ impl SplitContract {
&total_creator_fee,
);
events::creator_fee_paid(env, invoice_id, &invoice.creator, total_creator_fee);
events::creator_fee_collected(env, invoice_id, &invoice.creator, total_creator_fee);
}
}

Expand Down Expand Up @@ -12685,6 +12686,7 @@ impl SplitContract {
env.storage()
.persistent()
.set(&invoice_phase_key(invoice_id), &new_phase);
events::invoice_phase_changed(&env, invoice_id, &current_phase, &new_phase);
}

/// Issue #449 / #676: Get the current phase of an invoice.
Expand Down