Skip to content

refactor: extract shared pagination helper from duplicated boilerplate#434

Open
va932555-art wants to merge 1 commit into
HubDApp:mainfrom
va932555-art:extract-pagination-helper
Open

refactor: extract shared pagination helper from duplicated boilerplate#434
va932555-art wants to merge 1 commit into
HubDApp:mainfrom
va932555-art:extract-pagination-helper

Conversation

@va932555-art

Copy link
Copy Markdown

Summary

Extracts the duplicated "clamp limit, skip start, break at count" pagination loop into a shared generic paginate() function in a new pagination.rs module.

Changes

  • New dongle-smartcontract/src/pagination.rs — generic paginate<T: Clone>(env, items, start, limit) -> Vec<T> with MAX_PAGE_LIMIT = 100
  • Updated lib.rs — added pub mod pagination;
  • Updated featured_registry.rslist_featured_projects now calls paginate() on IDs, then looks up projects
  • Updated collection_registry.rs — both list_collections and list_collection_projects now call paginate()

What was removed

~30 lines of identical pagination boilerplate across 3 functions, replaced with 3 one-line paginate() calls.

Fixes #336

@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@va932555-art 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

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.

Pagination boilerplate duplicated verbatim across featured_registry.rs and collection_registry.rs

2 participants