fixed - supported token not loading#41
Conversation
📝 WalkthroughWalkthroughTokenPicker.jsx gains testnet detection and conditional error/UI flows that show testnet warnings and tailored error messages; useTokenList.js exports Changes
Sequence Diagram(s)(omitted — changes are UI/logic tweaks that do not introduce new multi-component sequential flows) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
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. Comment |
|
@kumawatkaran523 please review |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/src/components/TokenPicker.jsx (1)
318-348: Consider using error types instead of string matching.The current approach uses
.includes()to parse error message strings, which tightly couples the UI to the exact wording of error messages fromuseTokenList. This makes the code fragile and harder to maintain.Consider refactoring to use structured error objects or error codes:
// In useTokenList.js, return structured errors: setError({ type: 'TESTNET_NOT_SUPPORTED', message: '...', chainId }); setError({ type: 'CHAIN_NOT_SUPPORTED', message: '...', chainId }); // In TokenPicker.jsx, check error type: {tokensError.type === 'TESTNET_NOT_SUPPORTED' ? ( // testnet UI ) : tokensError.type === 'CHAIN_NOT_SUPPORTED' ? ( // unsupported chain UI ) : ( // generic error UI )}This approach is more maintainable, supports i18n better, and decouples UI logic from error message text.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
frontend/src/components/TokenPicker.jsxfrontend/src/hooks/useTokenList.js
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/src/components/TokenPicker.jsx (1)
frontend/src/hooks/useTokenList.js (2)
ChainIdToName(12-16)ChainIdToName(12-16)
🔇 Additional comments (1)
frontend/src/hooks/useTokenList.js (1)
28-29: Good fix for UI state consistency.Explicitly clearing the error and loading states when returning cached tokens prevents stale UI states from persisting. This ensures the component consuming this hook receives consistent state regardless of whether data comes from cache or a fresh fetch.
|
@Arnav-Nehra, What I think that opening the token search only on Mainnet will be a good idea. It reduces confusion for users who are connected to testnets or other chains, where the token list is often empty or not relevant. What I Recommend :
Pros
What you think ?? |
|
Yes, I think this is a better approach.
|
|
Yes @Arnav-Nehra ,go ahead |
5aafbb8 to
780537d
Compare
|
please review @kumawatkaran523 I have disabled the button on testnet and also added an message below it
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
frontend/src/components/TokenPicker.jsx (2)
267-274: Consider condition refinement for testnet warning.The testnet warning banner provides clear feedback to users. However, it displays whenever
isOnTestnetis true, even if the component is already disabled via thedisabledprop for unrelated reasons.Consider refining the condition to
isOnTestnet && !disabledto avoid redundant warnings when the component is disabled for other reasons.🔎 Proposed refinement
- {isOnTestnet && ( + {isOnTestnet && !disabled && ( <div className="mt-2 flex items-start gap-2 p-3 bg-amber-50 border border-amber-200 rounded-lg">
329-359: Refactor to use structured error handling instead of string matching.The error rendering logic relies on string matching (
tokensError.includes("manually input")andtokensError.includes("not supported")), which is fragile. TheuseTokenListhook returns error messages with these strings embedded (line 38 and 45 ofuseTokenList.js). If the error messages change, this conditional logic will break and users will see generic error messages instead of the intended testnet-specific or chain-specific feedback.Consider refactoring
useTokenListto return structured errors (error codes or error types) instead of relying on string matching:// Example structured approach: if (tokensError?.type === 'TESTNET_NOT_SUPPORTED') { // render testnet message } else if (tokensError?.type === 'CHAIN_NOT_SUPPORTED') { // render chain not supported message }This would make the code more maintainable and resilient to error message wording changes.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
frontend/src/components/TokenPicker.jsxfrontend/src/hooks/useTokenList.js
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/src/hooks/useTokenList.js
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/src/components/TokenPicker.jsx (3)
frontend/src/hooks/useTokenList.js (4)
isTestnet(10-10)isTestnet(10-10)ChainIdToName(12-16)ChainIdToName(12-16)frontend/src/components/ui/button.jsx (1)
Button(37-45)frontend/src/lib/utils.js (1)
cn(4-6)
🔇 Additional comments (3)
frontend/src/components/TokenPicker.jsx (3)
15-15: LGTM! Imports are correctly added.The newly imported
ChainIdToNameandisTestnetutilities are properly exported from the hook and used appropriately in the component.
219-219: LGTM! Testnet detection is correctly implemented.The
isOnTestnetvariable properly uses the importedisTestnetutility with the providedchainId.
224-234: Verify if "Switch to Mainnet" button should be implemented.The button correctly disables on testnets and applies appropriate styling. However, based on the PR discussion, there was an agreement to add a secondary "Switch to Mainnet" button (similar to the existing pattern on Sent/Received Invoices pages) to help users switch networks when on testnets.
This implementation only shows a warning message (lines 267-274) without the interactive button to switch networks. Please confirm whether:
- The "Switch to Mainnet" button feature should be added in this PR
- Or if it's deferred to a future PR

Tokens were already loading on Mainnet but they were not working on Testnet so Added proper error logging for better UX
fixes #31
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.