Skip to content

feat: move batch utils into shared pkg - #211

Open
taran-a wants to merge 2 commits into
mainfrom
feat/move-batch-utils-into-shared-pkg
Open

feat: move batch utils into shared pkg#211
taran-a wants to merge 2 commits into
mainfrom
feat/move-batch-utils-into-shared-pkg

Conversation

@taran-a

@taran-a taran-a commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Consolidates shared async batching utilities into @metamask/snap-networks-utils.

The Solana and Tron token API clients now use the shared chunking helper instead of maintaining equivalent local logic. Stellar now imports the shared batching utilities and removes its duplicate implementation. The shared utility package includes the migrated Stellar test coverage, preserving chunk ordering, bounded batch concurrency, and rejected-request handling.

This pull request improves the sharing and reuse of async batching utilities across packages, updates their usage in wallet snaps, and adds new tests for chunked token metadata fetching. It also removes now-unnecessary local async helpers and makes minor related test and config updates.

Explanation

Async utilities centralization and exports:

  • Added shared async batching utilities (batchesAll, batchesAllSettled, batchesAllSettledWithChunks, batchesAllWithChunks, chunks) to @metamask/snap-networks-utils, exporting them from a new entry point and updating the changelog to reflect this addition. [1] [2]
  • Updated stellar-wallet-snap to re-export these utilities from @metamask/snap-networks-utils instead of its own implementation.

Refactoring usage in wallet snaps:

  • Refactored both solana-wallet-snap and tron-wallet-snap to use the shared chunks utility from @metamask/snap-networks-utils for batching token metadata requests, replacing local chunking logic. [1] [2] [3] [4]

Test improvements:

  • Added tests to ensure that token metadata requests in both Solana and Tron snaps correctly merge results from multiple chunked API responses. [1] [2]
  • Updated test files for the async utilities, including more explicit return types and improved test coverage for batching and chunking logic. [1] [2] [3] [4]

Code cleanup:

  • Removed the now-redundant local retry utility from solana-wallet-snap.
  • Removed the local async utility test file from stellar-wallet-snap in favor of the centralized version.

Manifest and config updates:

  • Updated snap manifest files and shasums to reflect the new build outputs after these changes. [1] [2]

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@taran-a
taran-a requested review from a team as code owners August 26, 2026 14:26
@taran-a
taran-a deployed to default-branch August 26, 2026 14:26 — with GitHub Actions Active
@taran-a
taran-a force-pushed the feat/move-batch-utils-into-shared-pkg branch from 917041a to d8a9b0e Compare August 26, 2026 15:29

@Battambang Battambang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have added some automatic description in the PR, feel free to remove if it's too much.
LGTM.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants