fix: Send/receive asset selection should handle unsupported assets (#3311) - #12526
fix: Send/receive asset selection should handle unsupported assets (#3311)#12526joan-bisbal wants to merge 3 commits into
Conversation
|
Warning Review limit reached
Next review available in: 18 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughTrade asset search now excludes portfolio assets from chains unsupported by the connected wallet when unsupported assets are disallowed. The memoized filter tracks wallet state, supported chains, and the configuration setting. ChangesAsset search filtering
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/components/TradeAssetSearch/TradeAssetSearch.tsx (2)
218-222: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for wallet-supported portfolio filtering.
Please add or verify tests for these cases:
- A connected wallet with
allowWalletUnsupportedAssets === falseexcludes unsupported chains.- A connected wallet with
allowWalletUnsupportedAssets === trueretains those assets.- No connected wallet does not filter by
walletConnectedChainIds.Use assets with both supported and unsupported
asset.chainIdvalues. This directly covers the back-navigation regression.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/TradeAssetSearch/TradeAssetSearch.tsx` around lines 218 - 222, Add regression tests for the portfolio filtering logic in TradeAssetSearch, covering supported and unsupported asset.chainId values. Verify that a connected wallet excludes unsupported chains when allowWalletUnsupportedAssets is false, retains them when true, and that no connected wallet leaves all assets unfiltered by walletConnectedChainIds.
215-215: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd explicit types to the new filter callbacks.
The callbacks at Line 215 and Line 220 rely on contextual inference. Add
(asset: Asset): booleanto both callbacks.As per coding guidelines, TypeScript function parameters and return values must be explicit.
Proposed change
- asset => assetFilterPredicate?.(asset.assetId) ?? true, + (asset: Asset): boolean => assetFilterPredicate?.(asset.assetId) ?? true, ... - asset => walletConnectedChainIds.includes(asset.chainId), + (asset: Asset): boolean => walletConnectedChainIds.includes(asset.chainId),Run
pnpm run lint --fixandpnpm run type-checkafter the change.Also applies to: 220-220
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/TradeAssetSearch/TradeAssetSearch.tsx` at line 215, Update both filter callbacks in the TradeAssetSearch filtering logic (the callbacks at the referenced lines) to explicitly declare the parameter as Asset and the return type as boolean, including the callback using assetFilterPredicate?. Preserve their existing filtering behavior, then run pnpm run lint --fix and pnpm run type-check.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/components/TradeAssetSearch/TradeAssetSearch.tsx`:
- Around line 218-222: Add regression tests for the portfolio filtering logic in
TradeAssetSearch, covering supported and unsupported asset.chainId values.
Verify that a connected wallet excludes unsupported chains when
allowWalletUnsupportedAssets is false, retains them when true, and that no
connected wallet leaves all assets unfiltered by walletConnectedChainIds.
- Line 215: Update both filter callbacks in the TradeAssetSearch filtering logic
(the callbacks at the referenced lines) to explicitly declare the parameter as
Asset and the return type as boolean, including the callback using
assetFilterPredicate?. Preserve their existing filtering behavior, then run pnpm
run lint --fix and pnpm run type-check.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ecde0be5-9c79-4ece-88e6-919cd8a87601
📒 Files selected for processing (1)
src/components/TradeAssetSearch/TradeAssetSearch.tsx
Fixes #3311
When navigating within an asset view, opening the send/receive modal, and clicking back, the full list of all supported assets is displayed—including assets unsupported by the user's connected wallet.
This PR fixes the issue by ensuring that the fallback \portfolioAssetsSortedByBalance\ is properly filtered against \walletConnectedChainIds\ when \�llowWalletUnsupportedAssets\ is falsy (which is the case for Send/Receive modals).
Summary by CodeRabbit