Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Dec 17, 2025


PR-Codex overview

This PR focuses on enhancing the SwapWidget and related components in the thirdweb package by improving chain selection reliability, updating the handling of bridge chains, and introducing new props for better token selection functionality.

Detailed summary

  • Updated the onModalUnmount function to increase the delay before executing the callback.
  • Changed useBridgeChains to useBridgeChain in several files for better specificity.
  • Introduced new type and selections props in SelectBridgeChain and SelectToken components.
  • Enhanced chain selection logic in useBridgeChainsWithFilters to handle buy/sell scenarios.
  • Added testnet and type options in the chains function for better chain fetching.
  • Updated SwapUI to manage buy/sell token modals with improved selection handling.
  • Adjusted skeleton loading components to be responsive based on mobile state.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Bridge filtering supports testnet and mutually exclusive origin/destination filters.
    • Token selection now accepts operation context (buy/sell) and selected chain hints.
  • Improvements

    • Filter-driven chain lists for more relevant token choices.
    • Loading skeletons improved for mobile/desktop sizing.
    • Reduced redundant chain fetches by deferring buy-token assignment until modal close.
    • Slightly longer modal unmount delay for smoother transitions.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Dec 17, 2025

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

Project Deployment Review Updated (UTC)
docs-v2 Ready Ready Preview, Comment Dec 17, 2025 9:16pm
nebula Ready Ready Preview, Comment Dec 17, 2025 9:16pm
thirdweb_playground Ready Ready Preview, Comment Dec 17, 2025 9:16pm
thirdweb-www Ready Ready Preview, Comment Dec 17, 2025 9:16pm
wallet-ui Ready Ready Preview, Comment Dec 17, 2025 9:16pm

@linear
Copy link

linear bot commented Dec 17, 2025

@changeset-bot
Copy link

changeset-bot bot commented Dec 17, 2025

🦋 Changeset detected

Latest commit: ffd5bb0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
thirdweb Patch
@thirdweb-dev/nebula Patch
@thirdweb-dev/wagmi-adapter Patch
wagmi-inapp Patch

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary
Backend chains API filtering
packages/thirdweb/src/bridge/Chains.ts
Add optional testnet and discriminated union filters (type, originChainId, destinationChainId) to chains.Options; append matching query params to requests; make cache key unique per options via JSON serialization.
React bridge chain hooks
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
Change useBridgeChains to accept options: chains.Options; add useBridgeChain({ chainId, client }) for single-chain lookup; add useBridgeChainsWithFilters to map { buyChainId, sellChainId, type } into chains.Options.
Swap UI and TokenSection updates
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx
Replace useBridgeChains with useBridgeChain for TokenSection; extend TokenSection signature with selection (buy/sell chain ids); pass type and selections into SelectToken modals; delay buy-token assignment via onModalUnmount.
Select token UI filtering
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
Replace useBridgeChains with useBridgeChainsWithFilters; add `type: "buy"
Select chain UI filtering & skeletons
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsx
Use useBridgeChainsWithFilters and new type/selections props; update ChainButtonSkeleton to accept { isMobile } and adapt icon/padding/skeleton sizes; pass isMobile on render.
FundWallet integration
packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx
Swap useBridgeChains → useBridgeChain; initialize SelectToken for buy flow with type="buy" and selections (buyChainId from selectedToken.chainId).
SwapWidget hook call shape
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
Change useBridgeChains invocation from props.client to { client: props.client } (wrap client in options).
Modal timing tweak
packages/thirdweb/src/react/web/ui/ConnectWallet/constants.ts
Increase onModalUnmount delay from modalCloseFadeOutDuration + 100 to + 200 ms.
Stories updated
packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
Add type="buy" and selections={{ buyChainId: undefined, sellChainId: undefined }} to story instances for SelectBridgeChain / UI variants.
Changeset
.changeset/dry-wasps-love.md
Add changeset describing the patch release and improved chain listing behavior in token selection UI.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review points:
    • packages/thirdweb/src/bridge/Chains.ts — verify query param mapping and cacheKey formation.
    • use-bridge-chains.ts — confirm options mapping, React Query keys, and correct behavior of new helper hooks.
    • Components threading type and selections (select-token-ui.tsx, select-chain.tsx, swap-ui.tsx, FundWallet.tsx) — ensure prop types align and nothing breaks existing flows.
    • ConnectWallet/constants.ts — check timing change impact around modal unmount logic.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete. It does not follow the required template structure with sections for issue tag, notes for reviewer, and testing instructions. Add the required sections: issue tag (MNY-338), notes for reviewer explaining key changes, and how to test (unit tests, playground usage, etc.).
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: adding filters when fetching chains in the chain selection UI, which aligns with the primary objective.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from MNY-338: extends chains endpoint to accept testnet/originChainId/destinationChainId query parameters, maps 'from' to origin filter and 'to' to destination filter, and integrates these filters throughout the SelectBridgeChain and SelectToken components.
Out of Scope Changes check ✅ Passed All code changes are within scope of MNY-338. The modifications to onModalUnmount delay (100ms to 200ms) and skeleton component props are directly supportive of improving chain selection reliability in the SwapWidget.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mny-338

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

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

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Dec 17, 2025
@MananTank MananTank marked this pull request as ready for review December 17, 2025 20:41
@MananTank MananTank requested review from a team as code owners December 17, 2025 20:41
Copy link
Member Author

MananTank commented Dec 17, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 8.88889% with 82 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.41%. Comparing base (7ebc32a) to head (ffd5bb0).

Files with missing lines Patch % Lines
...act/web/ui/Bridge/swap-widget/use-bridge-chains.ts 11.11% 24 Missing ⚠️
...c/react/web/ui/Bridge/swap-widget/select-chain.tsx 5.55% 17 Missing ⚠️
packages/thirdweb/src/bridge/Chains.ts 5.88% 16 Missing ⚠️
...eact/web/ui/Bridge/swap-widget/select-token-ui.tsx 6.25% 15 Missing ⚠️
...es/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx 9.09% 10 Missing ⚠️

❌ 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     
Flag Coverage Δ
packages 54.41% <8.88%> (-0.06%) ⬇️
Files with missing lines Coverage Δ
...irdweb/src/react/web/ui/ConnectWallet/constants.ts 100.00% <100.00%> (ø)
...es/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx 6.13% <9.09%> (-0.08%) ⬇️
...eact/web/ui/Bridge/swap-widget/select-token-ui.tsx 4.79% <6.25%> (-0.09%) ⬇️
packages/thirdweb/src/bridge/Chains.ts 44.44% <5.88%> (-24.53%) ⬇️
...c/react/web/ui/Bridge/swap-widget/select-chain.tsx 8.38% <5.55%> (-0.60%) ⬇️
...act/web/ui/Bridge/swap-widget/use-bridge-chains.ts 10.41% <11.11%> (-2.09%) ⬇️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

size-limit report 📦

Path Size
@thirdweb-dev/nexus (esm) 105.66 KB (0%)
@thirdweb-dev/nexus (cjs) 319.47 KB (0%)

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 both buyChainId and sellChainId set to undefined. Consider adding additional story variants to showcase:

  • type="sell" filtering
  • Scenarios where buyChainId or sellChainId are 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 2d5b05e and ffd5bb0.

📒 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 @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes in TypeScript
Avoid any and unknown in 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.tsx
  • packages/thirdweb/src/react/web/ui/ConnectWallet/constants.ts
  • packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
  • packages/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.tsx
  • packages/thirdweb/src/react/web/ui/ConnectWallet/constants.ts
  • packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
  • packages/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 lint before committing, ensure there are no linting errors

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsx
  • packages/thirdweb/src/react/web/ui/ConnectWallet/constants.ts
  • packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
  • packages/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.tsx
  • packages/thirdweb/src/react/web/ui/ConnectWallet/constants.ts
  • packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
  • packages/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 SelectToken modal is invoked with type="buy" and selections.buyChainId set 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 useBridgeChainsWithFilters logic:

  • type="buy" with sellChainId=undefined maps to { type: "destination" }, showing all destination chains ✓
  • The buyChainId value is ignored in this case

While the current implementation is functionally correct, the state model might be clearer if selections were structured differently or if there were a comment explaining why buyChainId is 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,
          }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants