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
Description
InvoiceEscrow.statususes integer codes (0 open, 1 funded, 2 settled, 3 withdrawn) scattered acrossfund_impl,settle, andwithdraw, but there is no single authoritative state diagram. Produce a complete state-transition table indocs/escrow-lifecycle.mdcovering every entrypoint, its allowed source states, target state, required authority, and legal-hold interaction.Requirements and context
escrowSoroban contract.init→0,fund/fund_with_commitment0→0/1,settle1→2,withdraw1→3, plus terminal-onlysweep_terminal_dust.DataKey::LegalHoldand which require admin vs SME vs investor auth.FundingCloseSnapshotwrite trigger.assert!(status == ...)guards inlib.rs.Suggested execution
git checkout -b docs/lifecycle-state-machineescrow/src/lib.rsescrow/src/tests/integration.rsdocs/escrow-lifecycle.mdTest and commit
cargo testExample commit message
Guidelines