Skip to content

Document the full escrow state machine (open → funded → settled/withdrawn) in docs/escrow-lifecycle.md #271

@mikewheeleer

Description

@mikewheeleer

Description

InvoiceEscrow.status uses integer codes (0 open, 1 funded, 2 settled, 3 withdrawn) scattered across fund_impl, settle, and withdraw, but there is no single authoritative state diagram. Produce a complete state-transition table in docs/escrow-lifecycle.md covering every entrypoint, its allowed source states, target state, required authority, and legal-hold interaction.

Requirements and context

  • Scoped to the LiquiFact escrow Soroban contract.
  • Enumerate transitions: init→0, fund/fund_with_commitment 0→0/1, settle 1→2, withdraw 1→3, plus terminal-only sweep_terminal_dust.
  • Note which transitions are blocked by DataKey::LegalHold and which require admin vs SME vs investor auth.
  • Cross-link ADR-001 state model; include the FundingCloseSnapshot write trigger.
  • Invariant: documentation must match the exact assert!(status == ...) guards in lib.rs.
  • Must be accurate, reviewed, and aligned with code.

Suggested execution

  • Fork the repo and create a branch:
    • git checkout -b docs/lifecycle-state-machine
  • Implement changes:
    • escrow/src/lib.rs
    • Tests: escrow/src/tests/integration.rs
    • Docs: docs/escrow-lifecycle.md
    • Include rustdoc/NatSpec-style doc comments on public functions
    • Validate security assumptions (auth, overflow, storage TTL, double-spend)

Test and commit

  • Run tests: cargo test
  • Cover edge cases (zero amounts, overflow, unauthorized callers, double-spend, state-machine misuse)
  • Include test output and security notes in the PR

Example commit message

docs(escrow): authoritative lifecycle state machine

Guidelines

  • Minimum 95% test coverage on new/changed code
  • Clear documentation
  • Timeframe: 96 hours from assignment

Metadata

Metadata

Assignees

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions