-
Notifications
You must be signed in to change notification settings - Fork 629
[MNY-338] Add filters when fetching chains in chain selection ui #8573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: ffd5bb0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughAdds API query-parameter support and client-side filtering for bridge chains, introduces three hooks (useBridgeChains, useBridgeChain, useBridgeChainsWithFilters), and threads filter props (type, selections) through bridge token/chain selection components and stories. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant UI as Swap/SelectToken UI
participant SelectChain as SelectBridgeChain
participant Hook as useBridgeChainsWithFilters / useBridgeChain
participant API as chains() Endpoint
User->>UI: Open token/chain selector (type, selections present)
UI->>SelectChain: Render with props type & selections
SelectChain->>Hook: Request chains with mapped options (client, type/origin/destination, chainId)
activate Hook
Hook->>API: HTTP GET /chains?{mapped query params}
activate API
API->>API: Build query from options, apply server filtering
API-->>Hook: Return filtered chains
deactivate API
Hook-->>SelectChain: Return data + isPending
deactivate Hook
SelectChain->>UI: Display chains (or skeleton while isPending)
UI->>User: Show chain list / allow selection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (8.88%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #8573 +/- ##
==========================================
- Coverage 54.47% 54.41% -0.06%
==========================================
Files 922 922
Lines 61361 61427 +66
Branches 4149 4154 +5
==========================================
+ Hits 33425 33428 +3
- Misses 27835 27897 +62
- Partials 101 102 +1
🚀 New features to boost your workflow:
|
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/thirdweb/src/react/web/ui/ConnectWallet/constants.ts (1)
23-23: Verify the timing adjustment resolves the coordination issue.The increased delay from 100ms to 200ms adds an extra 100ms to the modal unmount sequence (total 450ms). While this likely addresses a race condition in the swap widget modal interactions, ensure that:
- The extra delay resolves the intended timing issue.
- The added latency doesn't negatively impact perceived UX during rapid modal transitions.
Consider adding a brief comment explaining why 200ms is needed (e.g., to allow for cleanup after modal fade-out in swap flows), as this would improve maintainability per the SDK coding guidelines.
packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx (1)
19-109: Consider adding stories to demonstrate filter variations.All four stories use identical filter props:
type="buy"with bothbuyChainIdandsellChainIdset toundefined. Consider adding additional story variants to showcase:
type="sell"filtering- Scenarios where
buyChainIdorsellChainIdare defined- How the filter state affects the displayed chains
This would provide better documentation of the filtering feature and help catch edge cases.
Example additional story:
export function WithSellTypeAndSelectedBuyChain() { const [selectedChain, setSelectedChain] = useState<BridgeChain | undefined>( undefined, ); return ( <SwapWidgetContainer theme="dark" className="w-full"> <SelectBridgeChain type="sell" selections={{ buyChainId: 1, // Ethereum mainnet selected sellChainId: undefined, }} isMobile={false} client={storyClient} onSelectChain={setSelectedChain} onBack={() => {}} selectedChain={selectedChain} /> </SwapWidgetContainer> ); }packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsx (1)
136-140: Add keys to skeleton components.The skeleton components are rendered without keys, which React will warn about. While the biome-ignore comment suppresses the linter, React's reconciliation can still be inefficient without keys.
Apply this diff to add keys:
{props.isPending && - new Array(20).fill(0).map(() => ( - // biome-ignore lint/correctness/useJsxKeyInIterable: ok + new Array(20).fill(0).map((_, i) => ( - <ChainButtonSkeleton isMobile={props.isMobile} /> + <ChainButtonSkeleton key={i} isMobile={props.isMobile} /> ))}
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (10)
.changeset/dry-wasps-love.md(1 hunks)packages/thirdweb/src/bridge/Chains.ts(3 hunks)packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx(3 hunks)packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx(1 hunks)packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsx(4 hunks)packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx(7 hunks)packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx(9 hunks)packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts(2 hunks)packages/thirdweb/src/react/web/ui/ConnectWallet/constants.ts(1 hunks)packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx(4 hunks)
✅ Files skipped from review due to trivial changes (2)
- .changeset/dry-wasps-love.md
- packages/thirdweb/src/bridge/Chains.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx
- packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
- packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each TypeScript file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes in TypeScript
Avoidanyandunknownin TypeScript unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.) in TypeScript
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity and testability
Re-use shared types from @/types or local types.ts barrel exports
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics whenever possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic in TypeScript files; avoid restating TypeScript types and signatures in prose
Files:
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsxpackages/thirdweb/src/react/web/ui/ConnectWallet/constants.tspackages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsxpackages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.tspackages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx
packages/thirdweb/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
packages/thirdweb/src/**/*.{ts,tsx}: Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose
Load heavy dependencies inside async paths to keep initial bundle lean (e.g.const { jsPDF } = await import("jspdf");)Lazy-load heavy dependencies inside async paths to keep the initial bundle lean (e.g., const { jsPDF } = await import('jspdf');)
Files:
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsxpackages/thirdweb/src/react/web/ui/ConnectWallet/constants.tspackages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsxpackages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.tspackages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx
**/*.{js,jsx,ts,tsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Biome governs formatting and linting; its rules live in biome.json. Run
pnpm fix&pnpm lintbefore committing, ensure there are no linting errors
Files:
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsxpackages/thirdweb/src/react/web/ui/ConnectWallet/constants.tspackages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsxpackages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.tspackages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Lazy-import optional features; avoid top-level side-effects
Files:
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsxpackages/thirdweb/src/react/web/ui/ConnectWallet/constants.tspackages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsxpackages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.tspackages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx
**/*.stories.tsx
📄 CodeRabbit inference engine (CLAUDE.md)
Add Storybook stories (
*.stories.tsx) alongside new UI components for documentation
Files:
packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
**/*.stories.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
For new UI components, add Storybook stories (*.stories.tsx) alongside the code
Files:
packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
🧬 Code graph analysis (2)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (2)
packages/thirdweb/src/bridge/Chains.ts (1)
chains(55-100)packages/thirdweb/src/exports/thirdweb.ts (1)
ThirdwebClient(25-25)
packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx (1)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1)
useBridgeChain(33-45)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: Build Packages
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Unit Tests
- GitHub Check: Lint Packages
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: Size
- GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx (1)
213-228: Verify the selection state logic for buy flow.The
SelectTokenmodal is invoked withtype="buy"andselections.buyChainIdset to the currently selected token's chain. However, when opening a token selection modal of type"buy", the user is selecting a destination (buy) chain, so the already-selected destination chain shouldn't constrain the available options.Based on the
useBridgeChainsWithFilterslogic:
type="buy"withsellChainId=undefinedmaps to{ type: "destination" }, showing all destination chains ✓- The
buyChainIdvalue is ignored in this caseWhile the current implementation is functionally correct, the state model might be clearer if
selectionswere structured differently or if there were a comment explaining whybuyChainIdis passed but not used for filtering in the buy flow.Consider adding a comment to clarify the selection state:
<SelectToken type="buy" selections={{ + // buyChainId tracks the selected destination but doesn't filter chains in buy flow buyChainId: props.selectedToken?.chainId, sellChainId: undefined, }}

PR-Codex overview
This PR focuses on enhancing the
SwapWidgetand related components in thethirdwebpackage by improving chain selection reliability, updating the handling of bridge chains, and introducing new props for better token selection functionality.Detailed summary
onModalUnmountfunction to increase the delay before executing the callback.useBridgeChainstouseBridgeChainin several files for better specificity.typeandselectionsprops inSelectBridgeChainandSelectTokencomponents.useBridgeChainsWithFiltersto handle buy/sell scenarios.chainsfunction for better chain fetching.SwapUIto manage buy/sell token modals with improved selection handling.Summary by CodeRabbit
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.