Add Solana native token pricing via Backpack GraphQL API - #2
Merged
jacklevin74 merged 5 commits intoNov 11, 2025
Merged
Conversation
This commit implements dual data sources for token pricing: - Solana networks: Use official Backpack GraphQL API (https://backpack-api.xnfts.dev/v2/graphql) - X1 networks: Continue using x1-json-server REST API Key changes: 1. Created GraphQL types and gql function for Backpack API integration 2. Implemented network-aware TokenBalances component: - SolanaTokenBalances: Uses GraphQL with Apollo Client (60s polling) - X1TokenBalances: Uses REST API with x1-json-server (60s polling) 3. Added backward-compatible ProviderId types (SOLANA, X1, ETHEREUM) 4. Maintained all existing X1 functionality Benefits: - Real-time pricing for ALL Solana SPL tokens (USDC, BONK, JUP, etc.) - Token metadata (logos, names, symbols) from Backpack's registry - 24h price change percentages for Solana tokens - Apollo Client caching for faster subsequent loads - Automatic retry with exponential backoff (10 attempts) - X1 pricing unchanged ($1.00 for XNT) Files modified: - packages/data-components/src/apollo/gql.ts (NEW) - packages/data-components/src/apollo/graphql.ts - packages/data-components/src/apollo/index.ts - packages/data-components/src/components/Balances/index.tsx - packages/data-components/src/components/Balances/utils.ts
The TokenBalances component was always reading connectionUrl from Blockchain.X1, even when displaying a Solana wallet. This caused Solana wallets to show X1 data. Now it correctly: 1. Extracts the blockchain type from the providerId prop 2. Reads the connection URL for the correct blockchain 3. Routes to GraphQL for Solana, REST for X1 This fixes the issue where Solana wallets only showed '0 XNT' instead of actual Solana tokens.
Root cause: Apollo Client was being recreated on every render in the WithApollo component, causing all GraphQL queries to restart continuously and creating an infinite loop. Fixes: 1. Added useMemo to Apollo Client creation in Unlocked/index.tsx - Only recreates client when headers actually change - Prevents unnecessary query restarts 2. Added error logging to SolanaTokenBalances component - Logs GraphQL errors to console for debugging - Helps identify API issues without silent failures This should resolve: - Infinite loading loop when displaying Solana tokens - Excessive API calls to Backpack GraphQL endpoint - Poor performance from constant Apollo Client recreation The duplicate atom warnings (secureBackgroundSenderAtom, notificationListenerAtom) are intentional - they exist in separate RecoilRoot contexts for main app and SecureUI.
Root cause: Apollo Client was POSTing to x1-json-server (http://162.250.126.66:4000/) instead of the official Backpack GraphQL API, resulting in 404 errors and infinite skeleton loading. Changes: 1. Added BACKPACK_GRAPHQL_API_URL constant pointing to https://backpack-api.xnfts.dev/v2/graphql 2. Updated Apollo Client httpLink to use BACKPACK_GRAPHQL_API_URL instead of BACKEND_API_URL 3. Updated logging to show correct GraphQL endpoint This fixes: - 404 errors: POST http://162.250.126.66:4000/ 404 (Not Found) - Infinite skeleton loading for Solana wallets - GraphQL queries now route to correct Backpack API Data source architecture: - Solana tokens: Backpack GraphQL API (https://backpack-api.xnfts.dev) - X1 tokens: x1-json-server REST API (http://162.250.126.66:4000)
Root cause: Backpack GraphQL API enum validation rejected "SOLANA-mainnet" with error: "enumeration type 'ProviderID' does not contain the value" The Backpack API only accepts simple blockchain names without network suffixes: - "SOLANA" (not "SOLANA-mainnet", "SOLANA-devnet", etc.) - "ETHEREUM" (not "ETHEREUM-mainnet", etc.) X1 REST API still uses network suffixes: - "X1-mainnet", "X1-testnet", "X1" Changes: 1. TokenBalances (app-extension): Changed "SOLANA-mainnet" to "SOLANA" 2. Balances (data-components): Removed network detection logic for Solana, kept X1 network detection 3. ProviderId type: Added clarifying comments about which APIs accept which values This fixes: - GraphQL enum validation error - Skeleton loading loop (query now succeeds) - Solana tokens will now load from Backpack API Network-specific details (mainnet/devnet/testnet) are likely handled by Backpack API internally via headers or other parameters.
jacklevin74
pushed a commit
that referenced
this pull request
Nov 11, 2025
Adds a configuration toggle to choose between Backpack GraphQL API and X1 JSON Server for Solana token queries, providing backward compatibility with pre-PR #2 behavior. Features: - New USE_X1_JSON_SERVER_FOR_SOLANA toggle in constants.ts - X1 queries always route to X1 JSON Server (unchanged) - Solana queries route based on toggle setting: - false (default): Use Backpack GraphQL API (new behavior) - true: Use X1 JSON Server (old behavior, pre-PR #2) - Enhanced logging to show which server is handling queries - Comprehensive documentation in GRAPHQL_CONFIG.md This allows testing both the new Backpack API integration and maintaining compatibility with existing X1 JSON Server infrastructure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
6 tasks
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.
Summary
This PR adds native Solana token pricing by integrating the official Backpack GraphQL API (
https://backpack-api.xnfts.dev/v2/graphql) for Solana tokens while maintaining X1 token support via the existing x1-json-server REST API.Key Features
Dual Data Source Architecture
Solana Networks: Use Backpack GraphQL API with Apollo Client
X1 Networks: Continue using x1-json-server REST API
Network-Aware Component
Changes
New Files
packages/data-components/src/apollo/gql.ts- GraphQL query parser for Apollo ClientModified Files
Technical Details
Bug Fixes
ProviderId Mapping
"SOLANA","ETHEREUM"(no network suffix)"X1","X1-mainnet","X1-testnet"(with network suffix)Testing
Solana Wallet
X1 Wallet
Network Switching
Build Status
✅ Extension builds successfully
✅ No TypeScript errors
✅ All packages compile
Related Issues
Resolves Solana token pricing limitation where only X1 tokens had pricing data.
🤖 Generated with Claude Code