Skip to content

Fix: list_credits includes Retired and Flagged credits with no opt-ou…#173

Merged
legend-esc merged 1 commit into
legend-esc:mainfrom
akindoyinabraham0-collab:fix/163-list-credits-status
May 30, 2026
Merged

Fix: list_credits includes Retired and Flagged credits with no opt-ou…#173
legend-esc merged 1 commit into
legend-esc:mainfrom
akindoyinabraham0-collab:fix/163-list-credits-status

Conversation

@akindoyinabraham0-collab
Copy link
Copy Markdown
Contributor

@akindoyinabraham0-collab akindoyinabraham0-collab commented May 29, 2026

Closes #163


Summary

Changes

Layer(s) affected

  • Smart contracts (Rust / Soroban)
  • API (NestJS)
  • Frontend (Angular)
  • Shared types
  • Docs / config

Testing

  • cargo test passes
  • npm run test passes (api)
  • npm run test passes (frontend)
  • Manually tested on testnet

Checklist

  • No private keys or secrets committed
  • New functions have at least one test
  • Error codes follow the stable range (100–120)
  • Breaking changes documented below

Breaking changes

Title: Fix: list_credits defaults to Active and supports optional status filter (#163)

Summary

Add an optional status parameter to list_credits, defaulting to returning only Active credits when status is None. This reduces client-side filtering and response payloads for marketplace/portfolio views.

What changed

  • Storage: added a global index of all credits (DataKey::AllCredits) and helpers add_credit_to_all / get_all_credits in src/storage.rs.
  • Submit flow: submit_credit now appends new credit IDs to the global index.
  • API: added pub fn list_credits(env: Env, status: Option<CreditStatus>) -> Vec<BytesN<32>> in src/lib.rs which filters by status and defaults to CreditStatus::Active when None.
  • Tests: added test_list_credits_optional_status in src/lib.rs covering None (default) and explicit status values.

Files changed

  • CarbonChain/contracts/credit_registry/src/types.rs
  • CarbonChain/contracts/credit_registry/src/storage.rs
  • CarbonChain/contracts/credit_registry/src/lib.rs

Testing

Run the crate tests locally (requires Rust toolchain):

cd "CarbonChain/contracts/credit_registry"
cargo test

Notes

  • Default behavior now matches marketplace expectations: callers that don't provide status get only Active credits.
  • Storage overhead: the global index is append-only on credit creation; this slightly increases storage but enables efficient server-side filtering by status.

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 status filter to list_credits (defaults to Active) to avoid returning Retired/Flagged credits and reduce client-side filtering.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@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! 🚀

Learn more about application limits

@legend-esc legend-esc merged commit d7da055 into legend-esc:main May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: list_credits includes Retired and Flagged credits with no opt-out

2 participants