Repository navigation
Conversation
Connecting a wallet looked up every token's name with one /assets/{unit}
call at a time, unpaced, and repeated all of them whenever the asset list
changed. That is a serial waterfall on the site's shared Blockfrost key,
the one fan-out in the browser the wallet refresh's throttle did not cover.
Both connect paths (CIP-30 and UTXOS) now go through
fetchUserAssetMetadata, which skips units already named this session,
joins a lookup another caller has in flight, runs the rest 4 at a time
through a 4/s Blockfrost throttle, and writes each name as it arrives.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2MdLjx7a7nPPhihZNDoMF
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Connecting a wallet looks up the signer's own token names (
/assets/{unit}) for the Deposit page. Both connect paths inconnect-wallet.tsx, CIP-30 and UTXOS, did this one request at a time, with no pacing, and repeated every lookup each time the asset list changed. This was the only Blockfrost fan-out in the browser that the throttle from #414 (266a74e) didn't cover, and it uses the same public key and the same 500-request burst / 10 req/s budget as the wallet refresh and tx building.Both paths now call
fetchUserAssetMetadatain the newsrc/utils/user-asset-metadata.ts. It:createBlockfrostThrottle, with 4 in flight and one start every 250 ms. That is 4 req/s, so one run alongside the refresh's 5 req/s stays under 10 req/s. Repeated 429s trip the throttle's breaker, which stops the batch;onEntry, so names still appear one by one like before;Numbers
These are worked out from the code, not measured in a browser. N is the number of tokens and RTT the round-trip time to Blockfrost.
The first load is not always faster: on a fast connection the pacing makes it slower on purpose. The gains are fewer requests and staying under the shared rate limit. Bundle:
/is 232.6 → 232.7 KB, and every route is still within budget.Behaviour changes to be aware of
userAssetMetadataalready is. After a network switch, a unit that exists on both networks keeps the first network's name. This is rare: it needs the same policy and asset name minted on both networks.Tests
src/__tests__/userAssetMetadata.test.ts, 13 tests. It covers: skip/dedupe, choosing the name field, no request when everything is known, only new units fetched, concurrency limit, failures left out, re-run is a no-op, names reported progressively, in-flight join, no join across networks, default pacing of 250 ms (fake timers), and the breaker stopping after 3 × 429.npx tsc --noEmit: clean.node scripts/run-tests.mjs: 1669 passed, 2 skipped (151 suites), plus 97 passed (11 suites).SKIP_ENV_VALIDATION=1 npx next build --webpackandnode scripts/check-bundle-budget.mjs --report: within budget.Not verified: a manual check in a browser with a real wallet. Playwright runs in CI.
Generated by Claude Code