Skip to content

feat: add get_invoice_stats and split rule percentage validation#25

Merged
MarcusDavidG merged 1 commit into
mainfrom
feat/contract-improvements
Jul 3, 2026
Merged

feat: add get_invoice_stats and split rule percentage validation#25
MarcusDavidG merged 1 commit into
mainfrom
feat/contract-improvements

Conversation

@MarcusDavidG

Copy link
Copy Markdown
Contributor

Summary

Two contract improvements closing two open issues.

Changes

get_invoice_stats (closes #10)

New read-only function returning InvoiceStats:

  • funded — current funded amount
  • total — sum of all recipient amounts
  • payment_count — number of individual payments
  • unique_payers — distinct payer addresses
  • completion_bps — funded/total in basis points (0–10000)

Split rule validation (closes #13)

Validates that Percentage and Tiered split rules do not exceed 10000 bps (100%) total when creating an invoice. Prevents overpayment bugs.

Additional fixes

  • Restored CreateInvoiceParams to types.rs (was dropped in multi-token refactor, breaking create_batch)
  • Fixed invoice_refunded event call in resolve_dispute to match updated 5-arg signature

Testing

  • 21/21 tests passing

- Add InvoiceStats struct (funded, total, payment_count, unique_payers, completion_bps)
- Add get_invoice_stats() read-only function
- Validate Percentage/Tiered split rules do not exceed 10000 bps total on create_invoice
- Fix invoice_refunded event call in resolve_dispute to match updated 5-arg signature
- Restore CreateInvoiceParams to types.rs (dropped in multi-token refactor)

Closes #10
Closes #13
@MarcusDavidG
MarcusDavidG merged commit b78f8f7 into main Jul 3, 2026
1 check failed
@MarcusDavidG
MarcusDavidG deleted the feat/contract-improvements branch July 3, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate split rules sum does not exceed 100% for Percentage type Add get_invoice_stats helper returning funded/total/completion_bps

1 participant