feat: add invoice view functions and fee_paid event test - #643
Open
fejilaup-cloud wants to merge 4 commits into
Open
feat: add invoice view functions and fee_paid event test#643fejilaup-cloud wants to merge 4 commits into
fejilaup-cloud wants to merge 4 commits into
Conversation
- Add get_invoice_deadline(invoice_id: u64) -> Result<u64, ContractError> - Returns deadline timestamp from InvoiceCore - Returns ContractError::InvoiceNotFound for unknown invoice IDs - Includes unit tests verifying deadline value and error handling - Enables efficient frontend expiry countdown UI without loading full struct Closes Stellar-split#590
- Add get_invoice_funded(invoice_id: u64) -> Result<i128, ContractError> - Reads funded amount from InvoiceHot (instance storage) if available, falls back to InvoiceCore - Returns ContractError::InvoiceNotFound if invoice does not exist - Includes unit tests verifying funded value increases after payment and error handling - Enables efficient polling by payment UIs without loading full struct Closes Stellar-split#589
- Add get_invoice_status(invoice_id: u64) -> Result<InvoiceStatus, ContractError> - Loads only the InvoiceHot (or InvoiceCore) struct and returns status field - Returns ContractError::InvoiceNotFound if invoice does not exist - Includes unit tests verifying correct status for Pending and Released invoices - Reduces data fetched and makes intent explicit for clients and integrations Closes Stellar-split#588
- Add test named fee_paid_event_carries_amount_and_treasury in event_log_tests.rs - Generate random treasury address and verify fee_paid event emits correct fields - Assert amount and treasury address match what was passed to fee_paid function - Treasury address is critical for financial auditing Closes Stellar-split#587
|
@fejilaup-cloud 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! 🚀 |
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
Implement four critical view functions and event test for the split-contracts invoice system:
get_invoice_deadlineview function returning deadline timestamp #590: Addget_invoice_deadline()view function returning deadline timestampget_invoice_fundedview function returning funded amount #589: Addget_invoice_funded()view function returning funded amountget_invoice_statusview function returning currentInvoiceStatus#588: Addget_invoice_status()view function returning current invoice statusfee_paidevent carries correct amount and treasury address #587: Add test verifyingfee_paidevent carries correct amount and treasury addressChanges
View Functions (Contracts)
get_invoice_deadline(invoice_id) -> Result<u64>: Enables efficient frontend expiry countdown UIget_invoice_funded(invoice_id) -> Result<i128>: Enables efficient payment UI pollingget_invoice_status(invoice_id) -> Result<InvoiceStatus>: Reduces data fetched for status checksAll three functions:
ContractError::InvoiceNotFoundfor unknown invoice IDsEvent Test
fee_paidevent intests/event_log_tests.rsTest Plan
Closes #590
Closes #589
Closes #588
Closes #587