Skip to content

feat: dynamic asset data loading from GitHub - #201

Merged
premiumjibles merged 2 commits into
mainfrom
feat/dynamic-asset-loading
Mar 9, 2026
Merged

premiumjibles merged 2 commits into
mainfrom
feat/dynamic-asset-loading

Conversation

@premiumjibles

@premiumjibles premiumjibles commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Replace ~5.4MB of bundled static JSON (encodedAssetData, relatedAssetIndex, 17 CoinGecko adapters) with runtime fetching from GitHub at server startup
  • Backend enriches all tool responses with icon URLs so frontend no longer needs assetService
  • Frontend AssetIcon is now prop-based (icon?: string), portfolio grouping uses relatedAssetKey from backend
  • Stale-while-revalidate: data auto-refreshes in background after 2 weeks

Test plan

  • bun run build passes
  • bun test — 558 pass, 0 fail
  • bun run dev — server initializes asset data from GitHub, starts serving
  • Frontend: AssetIcon renders icons from backend responses
  • Portfolio: icons and grouping work via relatedAssetKey
  • Transaction history: token transfer icons display
  • Trending/gainers/new coins: icons from CoinGecko/backend

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Asset icons now display consistently across portfolio, asset lists, and trending token sections
    • Enhanced visual representation of multi-chain assets with improved network badge handling
    • Improved icon rendering for transaction history and token transfers
  • Improvements

    • Optimized asset data initialization and refreshing at startup
    • Streamlined icon management system for better performance

@vercel

vercel Bot commented Mar 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
shapeshift-agentic Ready Ready Preview, Comment Mar 9, 2026 1:59am

Request Review

@coderabbitai

coderabbitai Bot commented Mar 9, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Refactoring asset representation across the codebase: components and tools transition from assetId-based lookups to direct icon and symbol props. AssetService shifts from pre-instantiated singleton to lazy-initialized with remote data fetching. Backend tools enrich API responses with icon data. Related asset index moves from static to dynamically fetched at initialization.

Changes

Cohort / File(s) Summary
Frontend Icon Rendering Components
apps/agentic-chat/src/components/Portfolio/GroupedAssetRow.tsx, apps/agentic-chat/src/components/Portfolio/PortfolioAssetRow.tsx, apps/agentic-chat/src/components/tools/GetAssetsUI.tsx, apps/agentic-chat/src/components/tools/NewCoinsUI.tsx, apps/agentic-chat/src/components/tools/TopGainersLosersUI.tsx, apps/agentic-chat/src/components/tools/TrendingTokensUI.tsx, apps/agentic-chat/src/components/tools/TransactionInfographic.tsx
Replaced assetId prop with icon and symbol props when calling AssetIcon or AssetListItem components, shifting from ID-based lookups to direct icon string passing.
Asset Icon & List Item Components
apps/agentic-chat/src/components/ui/AssetIcon.tsx, apps/agentic-chat/src/components/ui/AssetListItem.tsx
Refactored to accept icon string directly instead of assetId. Removed assetService dependency and internal icon-fetching logic; now relies entirely on provided icon prop.
Frontend Portfolio Service & Logic
apps/agentic-chat/src/services/portfolioService.ts, apps/agentic-chat/src/lib/portfolio.ts
Added icon and relatedAssetKey fields to portfolio assets. Rewrote asset grouping to use relatedAssetKey-based Map instead of getRelatedAssetIds lookups.
Backend AssetService Architecture
packages/utils/src/AssetService.ts, packages/utils/src/assetData/relatedAssetIndex.ts, packages/utils/src/index.ts
Transformed AssetService from pre-instantiated singleton to lazy-initialized with async initialize() and refresh() methods. Moved asset and related-asset data from static encoded files to remote fetch at initialization. Added lifecycle management with stale callbacks and getIcon() accessor.
Backend Asset Initialization & Orchestration
apps/agentic-server/src/lib/assetInit.ts, apps/agentic-server/src/server.ts
Introduced new asset initialization module with initializeAllAssetData() and refreshAllAssetData() functions. Integrated startup sequence in server to initialize assets before handling requests and register background refresh callbacks.
Backend Tool Asset Enrichment
apps/agentic-server/src/tools/getAssets.ts, apps/agentic-server/src/tools/getAssetPrices.ts, apps/agentic-server/src/tools/getNewCoins.ts, apps/agentic-server/src/tools/getTopGainersLosers.ts, apps/agentic-server/src/tools/getTrendingTokens.ts, apps/agentic-server/src/tools/limitOrder/getLimitOrders.ts, apps/agentic-server/src/tools/vault/vaultWithdrawAll.ts, apps/agentic-server/src/utils/assetHelpers.ts, apps/agentic-server/src/lib/asset/prices.ts
Migrated all tools from assetService instance import to AssetService.getInstance() pattern. Added icon field derivation for trending, new coins, and gainers/losers outputs.
Backend Portfolio Tool
apps/agentic-server/src/tools/portfolio.ts
Added icon and relatedAssetKey fields to portfolio asset output. Computed relatedAssetKey using isMultiChainAsset and getPrimaryAssetId helpers for multi-chain asset linking.
Backend Transaction Parsing
apps/agentic-server/src/lib/transactionHistory/evmParser.ts, apps/agentic-server/src/lib/transactionHistory/solanaParser.ts, apps/agentic-server/src/lib/transactionHistory/schemas.ts
Added icon field to token transfer objects in both EVM and Solana parsers via AssetService.getIcon(). Updated schema to include optional icon field on transfers.
CoinGecko Adapter Initialization
packages/caip/src/adapters/coingecko/index.ts
Introduced dynamic runtime initialization of CoinGecko adapters via initializeCoinGeckoAdapters(). Replaces static in-file aggregation with fetch-based adapter loading per chain. Added assetIdToCoingecko lookup function.
Type Definitions
packages/types/src/tx.ts, apps/agentic-server/src/lib/asset/coingecko/types.ts
Extended TokenTransfer type with optional icon field. Added icon field to TrimmedTrendingCoin, TrimmedGainerLoserCoin, and TrimmedNewCoin types.
Data File & Scripts
packages/utils/src/assetData/encodedRelatedAssetIndex.json (deleted), scripts/updateAssetData.js, scripts/updateAssetData.ts
Removed precomputed encoded related asset index file. Updated script messaging to reflect local development context and removed Arbitrum Nova from chain list.

Sequence Diagram(s)

sequenceDiagram
    participant Server
    participant AssetService
    participant CoinGeckoAdapters
    participant RelatedAssetIndex
    participant App

    Server->>Server: Application startup
    Server->>AssetService: initialize()
    par Parallel Initialization
        AssetService->>AssetService: fetch asset data from remote
    and
        Server->>CoinGeckoAdapters: initializeCoinGeckoAdapters()
        CoinGeckoAdapters->>CoinGeckoAdapters: fetch adapters per chain
    and
        Server->>RelatedAssetIndex: initializeRelatedAssetIndex()
        RelatedAssetIndex->>RelatedAssetIndex: fetch related asset mappings
    end
    AssetService->>Server: initialize complete
    Server->>AssetService: setOnStale(refreshCallback)
    Server->>App: start listening & handle requests
    
    Note over AssetService,Server: Background: on stale, AssetService<br/>triggers refresh callback
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 Hops through icons, strings so bright,
From ID's chains to rendered light,
AssetService learns to wake and grow,
Fetching data from the flow,
Related assets linked with care,
A cleaner design, fresh in the air! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: dynamic asset data loading from GitHub' clearly and concisely describes the main objective of the pull request: replacing bundled static asset data with runtime fetching from GitHub.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/dynamic-asset-loading

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Backend fetches asset data, CoinGecko adapters, and related asset index
at startup instead of bundling ~5.4MB of static JSON. All tool responses
are enriched with icon URLs so the frontend no longer needs assetService.
Frontend AssetIcon is now prop-based, portfolio grouping uses
relatedAssetKey from backend.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…edAssetKey, cleanup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@premiumjibles
premiumjibles marked this pull request as ready for review March 9, 2026 01:58
@premiumjibles
premiumjibles merged commit 0ca0c10 into main Mar 9, 2026
3 of 4 checks passed
@premiumjibles
premiumjibles deleted the feat/dynamic-asset-loading branch March 9, 2026 02:00

This branch was successfully deployed

1 active deployment
Preview — 7601acdc Deployed Mar 9, 2026 by vercel[bot]
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.

1 participant