feat(invoice): add invoice status counts and get_counts API#40
Merged
Conversation
|
@Ce-Royals 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! 🚀 |
Contributor
|
Resolve conflict @Ce-Royals |
c8c5c84 to
7619c5f
Compare
Contributor
|
Fix Ci Error @Ce-Royals |
…ts, keep get_counts + upstream improvements
- String::from_slice -> String::from_str for &str input - Fix try_invoke_contract arg type (pass tuple, not Val) - Add missing expiry_window_set event emission - Add extend_instance_ttl to initialize - Remove all self:: prefixes from free function calls - Replace all manual .persistent().set()+extend_ttl() with persistent_set - Use persistent_set in add_supported_asset, expire_listing, extend_status_index, increment/decrement_status_count
This reverts commit 2dde354.
…cts" This reverts commit 8685164.
…y_status # Conflicts: # contracts/invoice/src/lib.rs # contracts/invoice/src/types.rs
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.
closes #6
Title
Add invoice status counts and get_counts read API
Summary
This change adds persistent invoice status counts to the invoice contract so the frontend can display counts per status without loading all invoices.
What changed
Added DataKey::StatusCount(u32) to types.rs
Added InvoiceStatus::as_str() helper for stable status name keys
Added get_counts(env) -> Map<String, u64> in lib.rs
Persistently incremented Created count when invoices are created
Updated move_status_index() to decrement the previous status count and increment the new status count on every status transition
Added helper functions:
increment_status_count
decrement_status_count
read_status_count
Added unit test test_get_counts_updates_through_lifecycle in test.rs
Acceptance criteria satisfied
get_counts returns a map of status name to count
It is read-only and requires no auth
Counts are stored and updated on transitions
Unit test verifies counts through full lifecycle
Files changed
lib.rs
types.rs
test.rs