Skip to content

feat(invoice): implement invoice expiry indexing for efficient batch_expire #2

Description

Description

The current batch_expire implementation accepts a caller-supplied Vec<u64> of IDs to check. Add an on-chain index of pending invoice IDs so callers can query which IDs are candidates for expiry rather than having to enumerate all IDs externally.

Requirements and context

batch_expire in contracts/invoice/src/lib.rs iterates a caller-provided list. For large invoice volumes this places the enumeration burden on the client. An index stored under a DataKey::PendingIndex key would make off-chain tooling simpler and reduce the chance of missing expired invoices.

Suggested execution

Fork the repo and create a branch:

git checkout -b feature/invoice-pending-index

Implement changes:

  • Add DataKey::PendingIndex variant in contracts/invoice/src/invoice.rs
  • Update create_invoice to push new IDs onto the index
  • Update batch_expire, cancel_invoice, mark_paid, and release_escrow to remove IDs from the index on state change
  • Add get_pending_ids read function

Test and commit

Add tests covering add/remove behaviour and verify no regression.

feat(invoice): add pending invoice ID index for efficient batch_expire

Guidelines

Assignment required before starting. PR description must include: Closes #[issue_id]

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions