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]
Description
The current
batch_expireimplementation accepts a caller-suppliedVec<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_expireincontracts/invoice/src/lib.rsiterates a caller-provided list. For large invoice volumes this places the enumeration burden on the client. An index stored under aDataKey::PendingIndexkey would make off-chain tooling simpler and reduce the chance of missing expired invoices.Suggested execution
Fork the repo and create a branch:
Implement changes:
DataKey::PendingIndexvariant incontracts/invoice/src/invoice.rscreate_invoiceto push new IDs onto the indexbatch_expire,cancel_invoice,mark_paid, andrelease_escrowto remove IDs from the index on state changeget_pending_idsread functionTest and commit
Add tests covering add/remove behaviour and verify no regression.
Guidelines
Assignment required before starting. PR description must include:
Closes #[issue_id]