Fix: list_credits includes Retired and Flagged credits with no opt-ou…#173
Merged
legend-esc merged 1 commit intoMay 30, 2026
Conversation
|
@akindoyinabraham0-collab 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.
Closes #163
Summary
Changes
Layer(s) affected
Testing
cargo testpassesnpm run testpasses (api)npm run testpasses (frontend)Checklist
Breaking changes
Title: Fix: list_credits defaults to Active and supports optional status filter (#163)
Summary
Add an optional
statusparameter tolist_credits, defaulting to returning onlyActivecredits whenstatusisNone. This reduces client-side filtering and response payloads for marketplace/portfolio views.What changed
DataKey::AllCredits) and helpersadd_credit_to_all/get_all_creditsinsrc/storage.rs.submit_creditnow appends new credit IDs to the global index.pub fn list_credits(env: Env, status: Option<CreditStatus>) -> Vec<BytesN<32>>insrc/lib.rswhich filters bystatusand defaults toCreditStatus::ActivewhenNone.test_list_credits_optional_statusinsrc/lib.rscoveringNone(default) and explicit status values.Files changed
CarbonChain/contracts/credit_registry/src/types.rsCarbonChain/contracts/credit_registry/src/storage.rsCarbonChain/contracts/credit_registry/src/lib.rsTesting
Run the crate tests locally (requires Rust toolchain):
Notes
statusget onlyActivecredits.Suggested commit message
"Fix: list_credits defaults to Active and supports optional status filter (#163)"
Suggested PR body
(Use the summary above; include links to changed files if desired.)
Release note (one-liner)
Add optional
statusfilter tolist_credits(defaults toActive) to avoid returningRetired/Flaggedcredits and reduce client-side filtering.