Skip to content

Invoice Soft-Delete with Tombstone Record #562

Description

@Kingsman-99

Description

Invoices that are cancelled or abandoned have their storage entries left in an ambiguous terminal state or removed outright, destroying the audit trail needed for dispute resolution and off-chain reporting. A soft-delete mechanism must mark an invoice as Deleted in its status enum while writing an immutable tombstone record capturing the deletion ledger and acting address.

Technical Context

contracts/split/src/types.rs — add InvoiceStatus::Deleted variant and a Tombstone { invoice_id: u64, deleted_at_ledger: u32, deleted_by: Address } struct; contracts/split/src/storage.rs — add DataKey::Tombstone(u64) persistent key; contracts/split/src/lib.rsdelete_invoice(invoice_id: u64) entry point that requires auth from the creator, transitions status to Deleted, and writes Tombstone atomically; contracts/split/src/error.rs — add Error::InvoiceDeleted returned by all mutating entry points when status is Deleted, and Error::FundsUnclaimed to block deletion of invoices with non-zero balances.

Acceptance Criteria

  • delete_invoice() writes both InvoiceStatus::Deleted and the Tombstone record in the same invocation with no intermediate observable state
  • All mutating entry points (pay(), release_funds(), update_split_ratio()) return Error::InvoiceDeleted immediately when invoice status is Deleted
  • delete_invoice() returns Error::FundsUnclaimed and makes no state changes when TotalContributed > TotalReleased
  • A get_tombstone(invoice_id: u64) -> Tombstone view function is exposed for off-chain queries and returns Error::NotDeleted if the invoice is not in the Deleted state
  • Tests in contracts/split/src/tests/soft_delete_tests.rs verify tombstone field correctness, post-delete mutation rejection, query availability, and the unclaimed-funds guard
  • All CI checks (cargo build --target wasm32-unknown-unknown, cargo test, cargo clippy) pass and the branch has no merge conflicts

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsstorageStorage layout and TTL optimisation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions