feat: Limit the number of tokens to display to significantly reduce the number of instant requests#839
Conversation
|
@rogaldh is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile OverviewGreptile SummaryThis PR introduces progressive/lazy loading to the tokens UI to reduce bursty RPC traffic, and adds a new Token Info subsystem (chain-id + token-info fetchers + API route) to resolve token labels using chainId derived from cluster/genesisHash. Key UI changes:
Key infra changes:
Fixes needed before merge:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
actor User
participant UI as OwnedTokens/TokenHistory UI
participant SWR as SWR Cache
participant TokenInfoHook as useTokenInfo()
participant Utils as app/utils/token-info.ts
participant API as POST /api/token-info
participant Entity as app/entities/token-info (UTL fetch)
participant UTL as UTL Token List API
participant RPC as Solana RPC
User->>UI: Open /address/:addr/tokens
UI->>RPC: Fetch owned token accounts (existing flow)
UI-->>UI: Render first 4 tokens
User->>UI: Click "Load More" (holdings)
UI-->>UI: Increase visibleCount
UI->>UI: Token history initial state
User->>UI: Click "Load Token History"
UI->>RPC: Fetch history for next 4 token accounts
UI-->>UI: Render tx rows (first 4)
User->>UI: Scroll tx table
UI-->>UI: IntersectionObserver marks details cell visible
User->>UI: Click "Load" on details
UI->>SWR: Request token label info (optional)
SWR->>TokenInfoHook: fetcher
TokenInfoHook->>Utils: getTokenInfo(pubkey, cluster, genesisHash)
Utils->>API: fetch('/api/token-info', {address, cluster, genesisHash})
API->>Entity: getTokenInfos([address], cluster, genesisHash)
Entity->>UTL: POST /v1/mints?chainId=...
UTL-->>Entity: {content: tokenInfo}
Entity-->>API: tokenInfo
API-->>Utils: {content: tokenInfo}
Utils-->>TokenInfoHook: tokenInfo
TokenInfoHook-->>SWR: cache tokenInfo
SWR-->>UI: token label rendered
|
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: app/components/account/TokenHistoryCard.tsx
Line: 670:686
Comment:
**Lazy details never auto-fetch**
`LazyInstructionDetails` sets `isVisible` via IntersectionObserver, but visibility alone doesn’t trigger `fetchDetails(signature)`; the fetch only happens on click via `handleLoadClick` (`TokenHistoryCard.tsx:688-691`). The component comment/PR description says it “uses IntersectionObserver for viewport-based loading”, but as written it stays in the “Load” state after becoming visible until a user clicks. If you intended auto-fetch on intersection, you need to trigger `fetchDetails` when `isVisible` flips true (and `details` is empty).
How can I resolve this? If you propose a fix, please make it concise. |
Removed |
67288af to
cb83434
Compare
|
deb41de to
317675c
Compare

Description
Improve the token history and owned tokens components to prevent excessive RPC requests. Previously, loading the tokens page would trigger simultaneous fetches for all token accounts and their transaction details. This change implements progressive loading with manual triggers.
Type of change
Screenshots
Testing
Visit http://localhost:3000/address/TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb/tokens. Tokens for the Token Program should be loaded with no 429s.
Related Issues
HOO-187
Checklist
build:infoscript to update build informationAdditional Notes
Key changes:
LazyInstructionDetailscomponent uses IntersectionObserver for viewport-based loading