Skip to content

feat(indexer): add GET /collections/:address/stats endpoint and tests… - #600

Open
Sensei-Victor wants to merge 2 commits into
Afristore:masterfrom
Sensei-Victor:feat/577-collection-stats-endpoint
Open

feat(indexer): add GET /collections/:address/stats endpoint and tests…#600
Sensei-Victor wants to merge 2 commits into
Afristore:masterfrom
Sensei-Victor:feat/577-collection-stats-endpoint

Conversation

@Sensei-Victor

@Sensei-Victor Sensei-Victor commented Jul 30, 2026

Copy link
Copy Markdown

Closes #565


… (#577)

  • Add route that aggregates totalVolume (sum of Sold listings), floorPrice (min price of Active listings), and totalItems (count) for a collection
  • Route validates the collection exists first, returns 404 if not found
  • Route placed before /collections/:address to prevent param shadowing
  • Add collection.findUnique mock to the test mock setup
  • Add 4 test cases: happy path aggregation, null floor/volume, 404, 500

Description

Resolves Issue: ### Soroban Safety Checklist

  • TTL Extensions: If I modified Persistent storage, I explicitly called extend_ttl for those exact keys immediately after setting them.
  • Instance TTL: I ensured extend_instance_ttl is called if this is a public, state-modifying entry point.
  • Authorization: I verified that require_auth is used correctly and doesn't accidentally block approved operators or token owners.
  • Gas Efficiency: I have avoided putting storage reads/writes or .get(i).unwrap() host calls inside loops.
  • State Bloat: I have not used unbounded Vec arrays for global state tracking.
  • Signature Security: If I implemented off-chain signatures, the digest explicitly includes the contract address to prevent replays.
  • Front-Running Protection: If I used deploy_v2, I hashed the caller's address into the deployment salt.
  • Error Handling: I avoided using .unwrap_or() combined with .saturating_sub() to silently hide balance underflows.

Testing

  • I have added unit tests to cover my changes and tested edge cases.
  • All tests pass locally (cargo test).

Closes #577

Additional Context

…Afristore#577)

- Add route that aggregates totalVolume (sum of Sold listings), floorPrice
  (min price of Active listings), and totalItems (count) for a collection
- Route validates the collection exists first, returns 404 if not found
- Route placed before /collections/:address to prevent param shadowing
- Add collection.findUnique mock to the test mock setup
- Add 4 test cases: happy path aggregation, null floor/volume, 404, 500
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Sensei-Victor is attempting to deploy a commit to the ultratechcode's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Sensei-Victor 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

@Ultra-Tech-code

Copy link
Copy Markdown
Contributor

@Sensei-Victor, Some of the CI checks are failing. Kindly investigate and fix the issue. Thank you your contribution

@Sensei-Victor

Copy link
Copy Markdown
Author

Could someone please approve the pending workflow so the checks can run? Thank you.

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

Labels

None yet

Projects

None yet

2 participants