Skip to content

Comments

fix: Handle pagination in chains API to fetch all chains#224

Merged
gjeanmart merged 3 commits intomainfrom
fix/chains-api-limit
Feb 16, 2026
Merged

fix: Handle pagination in chains API to fetch all chains#224
gjeanmart merged 3 commits intomainfrom
fix/chains-api-limit

Conversation

@gjeanmart
Copy link
Collaborator

📝 Summary

Fixes pagination handling in the chains API to fetch all available chains from the Safe Config Service.

🐛 Problem

The Safe Config Service API (https://safe-config.safe.global/api/v1/chains/) returns paginated results with a default limit of 40 chains per page. The current implementation only fetched the first page, which meant:

  • Only 40 out of 41 available chains were displayed
  • Any future additions beyond the initial page would not be loaded

✅ Solution

Updated the getChains function to handle pagination properly by:

  • Implementing a while loop that iterates through all pages
  • Following the next URL from each response until it becomes null
  • Concatenating all results into a single array before returning

🔍 Changes

File: src/api/getChains.tsx

  • Added pagination loop to fetch all pages
  • Concatenate results from each page into allChains array
  • Continue fetching until next is null

🧪 Testing

  • Verified all 41 chains are now loaded
  • ESLint passes
  • No breaking changes to existing functionality

📊 Impact

  • Before: 40/41 chains displayed (missing 1 chain)
  • After: All 41 chains displayed correctly
  • Future-proof: Will automatically fetch any number of chains as the list grows
image

The Safe Config Service API returns paginated results with a limit of 40
chains per page. Previously, only the first page was fetched, resulting in
missing chains when the total count exceeded 40.

This change implements proper pagination handling by:
- Iterating through all pages until 'next' is null
- Concatenating results from each page into a complete list
- Ensuring all chains are loaded regardless of pagination

Fixes the issue where only 40 of 41 available chains were displayed.

Co-authored-by: Cursor <cursoragent@cursor.com>
gjeanmart and others added 2 commits February 16, 2026 17:04
The Safe Config Service API returns paginated results with a limit of 40
chains per page. Previously, only the first page was fetched, resulting in
missing chains when the total count exceeded 40.

This change implements proper pagination handling by:
- Iterating through all pages until 'next' is null
- Concatenating results from each page into a complete list
- Ensuring all chains are loaded regardless of pagination

Fixes the issue where only 40 of 41 available chains were displayed.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ansaction-service-status-page into fix/chains-api-limit
@gjeanmart gjeanmart merged commit 87d79f6 into main Feb 16, 2026
2 checks passed
@gjeanmart gjeanmart deleted the fix/chains-api-limit branch February 16, 2026 16:10
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.

2 participants