[BUG]: Add cancel invoices batch to match create invoices batch and pay invoices batch

Open
#354 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
50/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
solidity
Domain
blockchain

Research direction

Start from the existing cancel invoice(uint256 invoiceId) and pay invoices batch functions in the contract, and check how the batch size constant and duplicate-ID handling from #202 are done. Add cancel invoices batch(uint256[] calldata invoiceIds) with the same per-invoice checks, custom errors, and cancellation event, reverting the whole batch on any failure. Done means the batch cancels valid invoices, reverts on duplicates, an oversized array, or any unauthorized, paid, or already-cancelled invoice, and emits one event per invoice; confirm with the contract's existing test suite.

Written by the indexing model from the issue text.

Description

bug enhancement
Bug Description

Chainvoice has batch functions for creating invoices (create invoice batch, up to 30) and paying them (pay invoices batch, up to 50), but cancelling is single-only through cancel invoice(uint256 invoiceId).

The gap shows up when someone creates a batch of up to 30 invoices in one transaction and then needs to cancel several of them, for example because of a wrong amount or the wrong token. Creating them took one transaction, but cancelling them takes one transaction each.

Proposal: add cancel invoices batch(uint256[] calldata invoiceIds), following the same pattern as pay invoices batch.

How I'd handle the details:

  • Same checks as cancel invoice for each invoice (caller is the creator, not already paid or cancelled), reverting with the existing custom errors, so behavior matches the single version
  • The whole batch reverts if any invoice fails, which is how pay invoices batch behaves, so a batch is all-or-nothing
  • A maximum batch size, using a constant like the other two batch functions
  • Reject duplicate IDs in the array, so the fix in #202 isn't repeated here
  • Emit the same cancellation event for each invoice, so indexers and the frontend don't need changes

I'd like to work on this.

Code of Conduct
  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates
Dominant language
JavaScript
Stars
13
Forks
62
Avg merge
2d 14h
Merged PRs (30d)
18

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from StabilityNexus/Chainvoice

All issues in StabilityNexus/Chainvoice

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.