Skip to content

feat: add invoice event filtering and state validation (#1219, #1220) - #1224

Merged
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
adebayoahmad78-tech:feat/issues-1219-1220-adebayoahmad78-tech
Nov 25, 2026
Merged

Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
adebayoahmad78-tech:feat/issues-1219-1220-adebayoahmad78-tech

Conversation

@adebayoahmad78-tech

Copy link
Copy Markdown
Contributor

Closes #1219
Closes #1220

Summary

Two self-contained "first slice" modules, each plain helpers plus inline unit
tests, with its own error enum and a single mod line in lib.rs. Neither
is wired to contract storage or entrypoints, following the established
first-slice pattern.

#1219 — contracts/split/src/invoice_event_filtering.rs

Normalised view (InvoiceEvent / InvoiceEventType) of the events emitted by
events.rs, with a bounded in-memory InvoiceEventLog and a composite
EventFilter (event type, invoice id, inclusive date range, offset/limit),
where every set field is AND-ed. query collects matches with offset/limit
and early-exits once the limit is reached; count counts without
materialising. filter_by_type / filter_by_date_range are shorthands
(inverted range rejected). 7 unit tests.

#1220 — contracts/split/src/contract_state_validation.rs

ContractState lifecycle, is_valid_transition / validate_transition
(explicit allowed edges; a transition must change state, Archived is
terminal), check_invariants / is_valid_state (non-negative total, funded
within [0, total_due], recipients and deadline required off-draft, and
funding-consistency per state), a bounded append-only StateChangeLog, and
apply_transition which validates the edge, checks the prospective snapshot's
invariants, records the change, and commits the state only once logging
succeeds (atomic; a full log leaves the snapshot untouched). 6 unit tests.

Tests

Modules verified in isolation: 14/14 unit tests pass, cargo fmt --check and
cargo clippy clean. Not run against the full workspace build.

Scope / known gaps

  • Not wired to contract storage or entrypoints; status/events are projected
    in, not read live.
  • In-memory only (no persisted log across transactions).
  • Linear-scan query with early-exit (no sorted/binary-search optimisation).
  • Invariants cover amount/funding/recipient/deadline consistency, not the
    full invoice option surface.

@drips-wave

drips-wave Bot commented Nov 24, 2026

Copy link
Copy Markdown

@adebayoahmad78-tech 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 dd202be into Stellar-split:main Nov 25, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement comprehensive contract state validation Add event filtering and query capabilities to invoice events

2 participants