Skip to content

Conversation

@tom2drum
Copy link
Collaborator

Description and Related Issue(s)

This PR introduces a new useApiQueries hook that enables managing multiple API requests to the same resource in parallel. The hook is built on top of React Query's useQueries and provides a consistent interface similar to the existing useApiQuery hook.

The primary motivation is to improve the transaction description feature (Noves integration), which previously required complex manual state management for batching multiple transaction hash requests. The new hook simplifies this by handling parallel queries automatically and providing aggregated loading, error, and success states.

Proposed Changes

  • New useApiQueries hook: A wrapper around React Query's useQueries that manages multiple parallel API requests to the same resource. It provides a unified return type with aggregated loading, error, and success states, making it easy to handle multiple queries as a single unit.

  • Refactored useDescribeTxs hook: Simplified the implementation by replacing manual Promise.all logic with the new useApiQueries hook. The hook now batches transaction hashes into chunks of 10 and makes parallel requests, reducing code complexity from ~96 lines to ~46 lines.

  • Updated transaction components: Modified TxsList, TxsTable, TxsListItem, and TxsTableItem components to work with the new hook's return type structure.

  • Type cleanup: Removed unused type definitions from types/api/noves.ts and types/api/transaction.ts.

Breaking or Incompatible Changes

None. This is a refactoring that maintains backward compatibility with existing functionality.

Additional Information

The useApiQueries hook follows the same patterns as useApiQuery, ensuring consistency across the codebase. It supports all the same features including path params, query params, chain selection, and custom query options. The hook automatically combines results from multiple queries and provides a single aggregated state.

Checklist for PR author

  • I have tested these changes locally.
  • I added tests to cover any new functionality, following this guide
  • Whenever I fix a bug, I include a regression test to ensure that the bug does not reappear silently.
  • If I have added, changed, renamed, or removed an environment variable
    • I updated the list of environment variables in the documentation
    • I made the necessary changes to the validator script according to the guide
    • I added "ENVs" label to this pull request

@tom2drum tom2drum merged commit 34685ac into main Nov 18, 2025
11 checks passed
@tom2drum tom2drum deleted the tom2drum/use-api-queries branch November 18, 2025 18:00
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