Skip to content

Add view functions for invoice metadata and payment tracking - #646

Open
chukwudiikeh wants to merge 4 commits into
Stellar-split:mainfrom
chukwudiikeh:feature/add-view-functions
Open

Add view functions for invoice metadata and payment tracking#646
chukwudiikeh wants to merge 4 commits into
Stellar-split:mainfrom
chukwudiikeh:feature/add-view-functions

Conversation

@chukwudiikeh

Copy link
Copy Markdown

Summary

This PR adds four new view functions to the SplitContract for improved ergonomics and reduced instruction budget for frontends and analytics dashboards:

  • get_invoice_creator: Returns the creator address without deserializing the full invoice
  • get_invoice_recipients: Returns the recipient list for display-only use cases
  • get_invoice_payment_count: Returns the payment count without deserializing the full payments vector
  • get_invoice_funding_percentage: Returns funding percentage as basis points to avoid client-side division

Changes

  • Added 4 new pub view functions to contracts/split/src/lib.rs
  • Added corresponding unit tests in contracts/split/src/test.rs
  • Each function is targeted at reducing overhead for specific frontend/dashboard queries

Test Plan

  • ✅ Unit test for get_invoice_creator verifies creator lookup
  • ✅ Unit test for get_invoice_recipients verifies recipient list retrieval
  • ✅ Unit test for get_invoice_payment_count verifies count increments after payments
  • ✅ Unit test for get_invoice_funding_percentage covers 0%, 50%, and 100% cases

Closes #594
Closes #593
Closes #592
Closes #591

- Add pub fn get_invoice_creator(env: Env, invoice_id: u64) -> Address
- Returns the creator address for an invoice
- Unit test covers basic invoice creator lookup

Closes Stellar-split#591
- Add pub fn get_invoice_recipients(env: Env, invoice_id: u64) -> Vec<Address>
- Returns the recipients field from InvoiceCore
- Unit test verifies the returned list matches the one provided at creation

Closes Stellar-split#592
- Add pub fn get_invoice_payment_count(env: Env, invoice_id: u64) -> u32
- Returns invoice.payments.len() as u32
- Unit test confirms count is 0 on a fresh invoice and increases after each pay call

Closes Stellar-split#593
- Add pub fn get_invoice_funding_percentage(env: Env, invoice_id: u64) -> u32
- Returns (funded * 10_000 / total) as u32, or 0 if total is 0
- Unit test covers 0%, 50%, and 100% funding cases

Closes Stellar-split#594
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@chukwudiikeh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant