Skip to content

Invoice Status Transition Enforcement #519

Description

@Kingsman-99

Description

The contract lacks explicit validation of which status transitions are permissible, allowing operations to succeed in logically invalid states. A state-machine guard should enforce that transitions only follow the defined flow: Open → PartiallyFunded → Funded → Finalised (with Cancelled and Disputed as side exits).

Technical Context

Add a valid_transition(from: InvoiceStatus, to: InvoiceStatus) -> bool function in contracts/split/src/lib.rs. Call it before every status write using the stored current status. Transition table lives as a match block returning bool. Return InvalidStateTransition { from, to } error (defined in types.rs) on invalid attempts.

Acceptance Criteria

  • Transitioning from Finalised to any other state is rejected
  • Transitioning from Cancelled to any state is rejected
  • Open → Funded without passing through PartiallyFunded is permitted (edge: single contribution)
  • InvalidStateTransition error carries both from and to status values
  • A test exhaustively checks all invalid transitions in a table-driven format
  • All CI checks (cargo build --target wasm32-unknown-unknown, cargo test, cargo clippy) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsfeatureNew contract feature or operation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions