Skip to content

feat(split): emit events for overfunding, penalty, deadline & whitelist changes (#686–689) - #716

Merged
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
Tisan1000:feat/events-686-687-688-689
Aug 31, 2026
Merged

feat(split): emit events for overfunding, penalty, deadline & whitelist changes (#686–689)#716
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
Tisan1000:feat/events-686-687-688-689

Conversation

@Tisan1000

Copy link
Copy Markdown
Contributor

What

Adds four indexer-facing events in contracts/split/src/events.rs and wires them into the relevant code paths in lib.rs, so payers and off-chain monitors can explain balance / state changes that were previously silent.

Issue Event Topics Data
#686 overfunding_triggered (split, ovf_trig, invoice_id) (payer, policy, surplus, event_seq)
#687 penalty_applied (split, pen_appl, invoice_id) (payer, penalty_amount, penalty_bps, event_seq)
#688 deadline_extended (split, dl_ext, invoice_id) (old_deadline, new_deadline, event_seq)
#689 recipient_whitelist_updated (split, rcp_wl_up, invoice_id) (enabled, added, removed, event_seq)

#686 — overfunding policy

Emitted from _pay only when an AcceptAll or ReturnSurplus policy actually pushes funded past total:

  • ReturnSurplus: surplus = stroops transferred straight back to the payer.
  • AcceptAll: surplus = stroops accepted beyond the target (funded + credited - total).
  • Cap is intentionally excluded — it defers to overflow_behavior, which already has its own events.

#687 — late-payment penalty

Emitted from the existing penalty branch in _pay when penalty_bps > 0 and penalty_deadline has passed, after the penalty has been distributed. penalty_amount is the actual amount deducted from the payment (amount * penalty_bps / 10_000).

#688 — deadline extension

Emitted from extend_deadline after the new deadline is persisted, carrying the previous value. Topics/data match the issue spec exactly.

#689 — recipient whitelist

Emitted from both add_to_recipient_whitelist and remove_from_recipient_whitelist whenever the list actually changes. added / removed are Vec<Address> (single entry in practice, vector leaves room for batch updates); enabled reflects recipient_whitelist_enabled. The pre-existing recipient_whitelisted / recipient_removed_from_whitelist events are left in place.

Tests

8 new unit tests in contracts/split/src/test.rs:

  • overfunding event emitted for ReturnSurplus and AcceptAll, and not emitted on an exact fill (funded + payment == total)
  • penalty event emitted for a late payment, not for an on-time one
  • deadline event carries correct before/after values
  • whitelist event on enable + add, and on remove

⚠️ Pre-existing build breakage on main

main does not currently compile. Fixing the four target issues surfaced this. There is one unclosed-delimiter merge artifact directly in the target file (events.rs) — a half-written duplicate invoice_expired — which this PR fixes, plus a duplicated use line in test.rs. Beyond that, main has ~39 further pre-existing compile errors from earlier bad merges that are unrelated to these issues and out of scope here, e.g.:

  • duplicate mod validation; and a stale validation.rs / storage.rs using an old soroban-sdk API (Map::has, Vec::to_vec, Persistent::bump)
  • missing calc_platform_fee / ContractError::TooFewRecipients
  • InvoiceStatus::PayoutInProgress not handled in 6 match expressions
  • invoice_refunded called with 3 args against a 2-arg definition
  • env.storage().*.get() calls needing type annotations

Because of those, cargo test --workspace cannot build yet. The event functions and their call sites in this PR are self-contained, follow the existing events.rs conventions, and introduce no new errors.

Closes #686
Closes #687
Closes #688
Closes #689

🤖 Generated with Claude Code

…st changes

Adds four indexer-facing events so payers and off-chain monitors can
explain balance/state changes that were previously silent:

- overfunding_triggered(invoice_id, payer, policy, surplus)  (Stellar-split#686)
  Emitted from _pay when an AcceptAll / ReturnSurplus policy pushes
  funded past total. `surplus` is the amount refunded (ReturnSurplus)
  or accepted beyond the target (AcceptAll). Cap keeps its existing
  overflow_behavior events.

- penalty_applied(invoice_id, payer, penalty_amount, penalty_bps)  (Stellar-split#687)
  Emitted from the late-payment path when penalty_bps > 0 and
  penalty_deadline has passed. penalty_amount is the actual stroops
  deducted and distributed to recipients.

- deadline_extended(invoice_id, old_deadline, new_deadline)  (Stellar-split#688)
  Emitted from extend_deadline. Topics (split, dl_ext, invoice_id),
  data (old_deadline, new_deadline, event_seq).

- recipient_whitelist_updated(invoice_id, enabled, added, removed)  (Stellar-split#689)
  Emitted from add_to_recipient_whitelist / remove_from_recipient_whitelist
  whenever the whitelist mutates; added/removed are address vectors.

Also fixes an unclosed-delimiter merge artifact in events.rs (a
half-written duplicate invoice_expired) and a duplicated `use` line in
test.rs, both of which prevented the crate from compiling at all.

Tests: 8 new unit tests in test.rs covering each event's presence,
absence on the negative path, and payload values.

Note: `main` currently has ~39 further pre-existing compile errors from
earlier bad merges (unrelated to these issues), so the full `cargo test`
suite does not yet build; these events and their call sites are
self-contained and follow the existing events.rs conventions.

Closes Stellar-split#686
Closes Stellar-split#687
Closes Stellar-split#688
Closes Stellar-split#689

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RESwkFykGpG3KJdWhGQC2E
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Tisan1000 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Kingsman-99
Kingsman-99 merged commit fb61a94 into Stellar-split:main Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants