feat: add get_invoice_stats and split rule percentage validation#25
Merged
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two contract improvements closing two open issues.
Changes
get_invoice_stats (closes #10)
New read-only function returning
InvoiceStats:funded— current funded amounttotal— sum of all recipient amountspayment_count— number of individual paymentsunique_payers— distinct payer addressescompletion_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
CreateInvoiceParamsto types.rs (was dropped in multi-token refactor, breakingcreate_batch)invoice_refundedevent call inresolve_disputeto match updated 5-arg signatureTesting