Skip to content

Conversation

@joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Dec 1, 2025


PR-Codex overview

This PR introduces a new hook useAllChainsData to fetch and manage chain data, replaces the BridgeNetworkSelector with SingleNetworkSelector, and enhances the TokenSelector to conditionally include native tokens. It also updates API calls for fetching tokens.

Detailed summary

  • Added useAllChainsData hook for fetching chain data.
  • Replaced BridgeNetworkSelector with SingleNetworkSelector in X402LeftSection.
  • Updated TokenSelector to optionally exclude native tokens.
  • Enhanced token fetching logic to include a new API for supported tokens.
  • Improved loading indicators and chain filtering in the SingleNetworkSelector.

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

Summary by CodeRabbit

  • New Features

    • Single-network selector added with improved search, filtering and display.
    • Token selector gains an option to exclude the native token.
    • Payment UI now prompts users to select a payment token before showing full controls.
  • Improvements

    • Connect/payment display simplified: clearer token badge and direct token references.
    • Chain and token data fetching enhanced with a fallback to a payment-specific token list.

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

@vercel
Copy link

vercel bot commented Dec 1, 2025

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

Project Deployment Preview Comments Updated (UTC)
thirdweb_playground Ready Ready Preview Comment Dec 1, 2025 1:04am
4 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs-v2 Skipped Skipped Dec 1, 2025 1:04am
nebula Skipped Skipped Dec 1, 2025 1:04am
thirdweb-www Skipped Skipped Dec 1, 2025 1:04am
wallet-ui Skipped Skipped Dec 1, 2025 1:04am

@changeset-bot
Copy link

changeset-bot bot commented Dec 1, 2025

⚠️ No Changeset found

Latest commit: bfaf06b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel vercel bot temporarily deployed to Preview – wallet-ui December 1, 2025 00:31 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb-www December 1, 2025 00:31 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 December 1, 2025 00:31 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula December 1, 2025 00:31 Inactive
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

Adds SingleNetworkSelector and useAllChainsData, extends TokenSelector with includeNativeToken, updates token fetching to prefer a bridge endpoint with a payments API fallback, and updates X402 UI to prompt when no payment token is selected.

Changes

Cohort / File(s) Summary
X402 UI — Left & Right
apps/playground-web/src/app/x402/components/X402LeftSection.tsx, apps/playground-web/src/app/x402/components/X402RightSection.tsx
Left: replaced BridgeNetworkSelector with SingleNetworkSelector, added className="bg-card" and set TokenSelector prop includeNativeToken={false}. Right: added CircleDollarSignIcon, compute isTokenSelected, show a "Select Payment Token" prompt when none selected, and simplified ConnectButton token mappings and badge/payment text.
Network Selector component
apps/playground-web/src/components/blocks/NetworkSelectors.tsx
Added and exported SingleNetworkSelector which uses useAllChainsData() to build searchable chain options, supports filtering by chainIds, disableTestnets, disableDeprecated, alignment/side/placeholder, and custom option rendering with chain icon and optional chain-id badge. BridgeNetworkSelector remains in the file.
Token Selector UI
apps/playground-web/src/components/ui/TokenSelector.tsx
TokenSelector API extended with optional includeNativeToken?: boolean. When includeNativeToken === false, the native token (matching NATIVE_TOKEN_ADDRESS) is filtered out of selectable tokens.
Chain data hook
apps/playground-web/src/hooks/allChains.ts
New useAllChainsData() hook using React Query to fetch chain metadata from https://api.thirdweb.com/v1/chains (queryKey ["all-chains"]) with basic error handling.
Token data fetching
apps/playground-web/src/hooks/useTokensData.ts
fetchTokensFromApi() now prefers a bridge endpoint (derived from NEXT_PUBLIC_BRIDGE_URL) and, if that returns empty and chainId is present, falls back to an API payments endpoint (/v1/payments/x402/supported) mapping that payload to TokenMetadata. Added error handling and URL split logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Inspect bridge → fallback API mapping and error paths in apps/playground-web/src/hooks/useTokensData.ts.
  • Verify useAllChainsData() caching, loading state, and error handling in apps/playground-web/src/hooks/allChains.ts.
  • Review SingleNetworkSelector option construction, filtering/search behavior, and renderOption layout in apps/playground-web/src/components/blocks/NetworkSelectors.tsx.
  • Confirm TokenSelector filtering logic with includeNativeToken and all places where native token should be excluded.
  • Validate X402 UI conditional rendering using isTokenSelected and ConnectButton token maps in apps/playground-web/src/app/x402/components/X402RightSection.tsx.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The PR description includes a PR-Codex overview summarizing key changes, but lacks the required template sections: no Linear issue tag, minimal reviewer notes, and no testing instructions. Add the Linear issue tag (TEAM-0000 format), expand 'Notes for the reviewer' with important details, and provide specific testing instructions beyond the generic mention.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main improvements to token selection and UI for the x402 playground, which aligns with the changeset's primary focus.
✨ 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 _X402_Improve_token_selection_and_UI_for_payment_playground

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 the Playground Changes involving the Playground codebase. label Dec 1, 2025
Copy link
Member Author


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.

@joaquim-verges joaquim-verges changed the title [X402] Improve token selection and UI for payment playground [Playground] Improve token selection and UI for x402 playground Dec 1, 2025
@joaquim-verges joaquim-verges marked this pull request as ready for review December 1, 2025 00:31
@joaquim-verges joaquim-verges requested review from a team as code owners December 1, 2025 00:32
@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.83%. Comparing base (98d8f29) to head (bfaf06b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8471   +/-   ##
=======================================
  Coverage   54.83%   54.83%           
=======================================
  Files         920      920           
  Lines       60891    60891           
  Branches     4141     4141           
=======================================
  Hits        33390    33390           
  Misses      27399    27399           
  Partials      102      102           
Flag Coverage Δ
packages 54.83% <ø> (ø)
🚀 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.

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: 6

🧹 Nitpick comments (4)
apps/playground-web/src/hooks/allChains.ts (1)

19-28: Consider adding staleTime for chain data.

Chain metadata changes infrequently. Without staleTime, React Query refetches on every mount. Adding a reasonable stale time (e.g., 5 minutes) would reduce unnecessary API calls. Based on learnings, configure staleTime based on freshness requirements.

 export function useAllChainsData() {
   const allChainsQuery = useQuery({
     queryFn: () => fetchChainsFromApi(),
     queryKey: ["all-chains"],
+    staleTime: 1000 * 60 * 5, // 5 minutes
   });

   return allChainsQuery.data;
 }
apps/playground-web/src/app/x402/components/X402LeftSection.tsx (1)

44-44: Unused chainId from useId() – Label association is broken.

The chainId variable from useId() is assigned to the Label's htmlFor, but SingleNetworkSelector doesn't expose an id prop, so the label isn't actually associated with the input. Either remove the unused chainId or add an id prop to SingleNetworkSelector if accessibility association is needed.

-  const chainId = useId();
   const tokenId = useId();
   ...
           <div className="flex flex-col gap-2">
-            <Label htmlFor={chainId}>Chain</Label>
+            <Label>Chain</Label>
             <SingleNetworkSelector

Also applies to: 107-116

apps/playground-web/src/app/x402/components/X402RightSection.tsx (1)

31-34: Consider using a constant for zero address check.

The hardcoded zero address string is duplicated (also used in X402LeftSection.tsx line 58). Consider extracting to a shared constant for consistency and to avoid typos.

+import { ZERO_ADDRESS } from "thirdweb"; // or define locally
+
 const isTokenSelected =
-    props.options.tokenAddress !==
-      "0x0000000000000000000000000000000000000000" &&
+    props.options.tokenAddress !== ZERO_ADDRESS &&
     props.options.tokenSymbol !== "";
apps/playground-web/src/components/blocks/NetworkSelectors.tsx (1)

70-85: Consider using a Map for O(1) chain lookups in search/render.

Both searchFn and renderOption use .find() to look up chains by ID, resulting in O(n) lookup per call. For large chain lists, consider building a Map<number, Chain> in the useMemo alongside chainsToShow.

const chainMap = useMemo(() => {
  return new Map(chainsToShow.map((chain) => [chain.chainId, chain]));
}, [chainsToShow]);

// Then in searchFn/renderOption:
const chain = chainMap.get(Number(option.value));
📜 Review details

Configuration used: CodeRabbit 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 98d8f29 and 21f81a3.

📒 Files selected for processing (6)
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx (3 hunks)
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx (4 hunks)
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx (1 hunks)
  • apps/playground-web/src/components/ui/TokenSelector.tsx (2 hunks)
  • apps/playground-web/src/hooks/allChains.ts (1 hunks)
  • apps/playground-web/src/hooks/useTokensData.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
apps/{dashboard,playground-web}/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/{dashboard,playground-web}/src/**/*.{ts,tsx}: Import UI component primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground
Use Tailwind CSS only – no inline styles or CSS modules in dashboard and playground
Use cn() from @/lib/utils for conditional Tailwind class merging
Use design system tokens for styling (backgrounds: bg-card, borders: border-border, muted text: text-muted-foreground)
Expose className prop on root element for component overrides

Files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/components/blocks/NetworkSelectors.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:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Lazy-import optional features; avoid top-level side-effects

Files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
🧠 Learnings (27)
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : Client Components: Begin files with 'use client'; before imports, handle interactive UI relying on React hooks (useState, useEffect, React Query, wallet hooks), access browser APIs (localStorage, window, IntersectionObserver, etc.), and support fast transitions with client-side data prefetching

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Applies to apps/dashboard/**/*.{ts,tsx} : Use React Query (`tanstack/react-query`) for all client-side data fetching with typed hooks

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Handle interactive UI with React hooks (`useState`, `useEffect`, React Query, wallet hooks) in client components

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : For client-side data fetching: Wrap calls in React Query (tanstack/react-query), use descriptive and stable queryKeys for cache hits, configure staleTime / cacheTime based on freshness requirements (default ≥ 60 s), and keep tokens secret by calling internal API routes or server actions

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Use client components for anything that consumes hooks from `tanstack/react-query` or thirdweb SDKs

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Wrap client-side API calls in React Query (`tanstack/react-query`)

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Applies to apps/dashboard/**/*use*.{ts,tsx} : Keep `queryKey` stable and descriptive in React Query hooks for reliable cache hits

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Use descriptive, stable `queryKeys` in React Query for cache hits

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Use interactive client components for UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks)

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-09-17T11:02:13.528Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 8044
File: packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts:15-17
Timestamp: 2025-09-17T11:02:13.528Z
Learning: The thirdweb `client` object is serializable and can safely be used in React Query keys, similar to the `contract` object.

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-05-27T19:54:55.885Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/erc20.tsx:15-17
Timestamp: 2025-05-27T19:54:55.885Z
Learning: The `fetchDashboardContractMetadata` function from "3rdweb-sdk/react/hooks/useDashboardContractMetadata" has internal error handlers for all promises and cannot throw errors, so external error handling is not needed when calling this function.

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/{dashboard,playground-web}/src/**/*.{ts,tsx} : Use design system tokens for styling (backgrounds: `bg-card`, borders: `border-border`, muted text: `text-muted-foreground`)

Applied to files:

  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-09-18T20:09:57.064Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 8069
File: apps/playground-web/src/app/bridge/swap-widget/components/types.ts:3-12
Timestamp: 2025-09-18T20:09:57.064Z
Learning: The SwapWidgetPlaygroundOptions type should not include persistTokenSelections - the playground intentionally hardcodes persistTokenSelections={false} and doesn't expose it as a configurable option to users.

Applied to files:

  • apps/playground-web/src/components/ui/TokenSelector.tsx
📚 Learning: 2025-05-30T17:14:25.332Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7227
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/OpenEditionMetadata.tsx:26-26
Timestamp: 2025-05-30T17:14:25.332Z
Learning: The ModuleCardUIProps interface already includes a client prop of type ThirdwebClient, so when components use `Omit<ModuleCardUIProps, "children" | "updateButton">`, they inherit the client prop without needing to add it explicitly.

Applied to files:

  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-07-07T21:21:47.488Z
Learnt from: saminacodes
Repo: thirdweb-dev/js PR: 7543
File: apps/portal/src/app/pay/page.mdx:4-4
Timestamp: 2025-07-07T21:21:47.488Z
Learning: In the thirdweb-dev/js repository, lucide-react icons must be imported with the "Icon" suffix (e.g., ExternalLinkIcon, RocketIcon) as required by the new linting rule, contrary to the typical lucide-react convention of importing without the suffix.

Applied to files:

  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Applies to apps/dashboard/**/*.{ts,tsx} : Import icons from `lucide-react` or the project-specific `…/icons` exports; never embed raw SVG

Applied to files:

  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-07-31T16:17:42.753Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7768
File: apps/playground-web/src/app/navLinks.ts:1-1
Timestamp: 2025-07-31T16:17:42.753Z
Learning: Configuration files that import and reference React components (like icon components from lucide-react) need the "use client" directive, even if they primarily export static data, because the referenced components need to be executed in a client context when used by other client components.

Applied to files:

  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-06-17T18:30:52.976Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7356
File: apps/nebula/src/app/not-found.tsx:1-1
Timestamp: 2025-06-17T18:30:52.976Z
Learning: In the thirdweb/js project, the React namespace is available for type annotations (like React.FC) without needing to explicitly import React. This is project-specific configuration that differs from typical TypeScript/React setups.

Applied to files:

  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
📚 Learning: 2025-08-28T12:14:44.134Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7933
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/utils/calculate-tick.ts:1-5
Timestamp: 2025-08-28T12:14:44.134Z
Learning: In thirdweb, ZERO_ADDRESS is not a valid token address value and should not be treated as a representation of native tokens. Native tokens are represented by NATIVE_TOKEN_ADDRESS only.

Applied to files:

  • apps/playground-web/src/components/ui/TokenSelector.tsx
📚 Learning: 2025-05-27T19:55:25.056Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenPriceData.ts:49-49
Timestamp: 2025-05-27T19:55:25.056Z
Learning: In the ERC20 public pages token price data hook (`useTokenPriceData.ts`), direct array access on `json.data[0]` without optional chaining is intentionally correct and should not be changed to use safety checks.

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-08-27T22:11:41.748Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7933
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/create-token-page-impl.tsx:465-473
Timestamp: 2025-08-27T22:11:41.748Z
Learning: In the token creation flow (create-token-page-impl.tsx), the createTokenOnUniversalBridge() call is intentionally not awaited (fire-and-forget pattern) to allow the token creation process to complete immediately without waiting for the bridge operation. This is a deliberate design choice to prioritize user experience by not blocking the main flow with supplementary bridge operations.

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{ts,tsx} : For server-side data fetching: Always call getAuthToken() to retrieve the JWT from cookies and inject the token as an Authorization: Bearer header – never embed it in the URL. Return typed results (Project[], User[], …) – avoid any

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-10-03T23:36:00.631Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 8181
File: packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx:27-27
Timestamp: 2025-10-03T23:36:00.631Z
Learning: In packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx, the component intentionally uses a hardcoded English locale (connectLocaleEn) rather than reading from the provider, as BuyWidget is designed to be English-only and does not require internationalization support.

Applied to files:

  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : Import UI primitives from @/components/ui/_ (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in Dashboard and Playground apps

Applied to files:

  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/{dashboard,playground-web}/src/**/*.{ts,tsx} : Import UI component primitives from `@/components/ui/*` (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : Stick to design tokens for styling: backgrounds (bg-card), borders (border-border), muted text (text-muted-foreground), etc.

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Applies to apps/dashboard/**/*.{ts,tsx} : Always import from the central UI library under `@/components/ui/*` for reusable core UI components like `Button`, `Input`, `Select`, `Tabs`, `Card`, `Sidebar`, `Separator`, `Badge`

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
🧬 Code graph analysis (3)
apps/playground-web/src/components/ui/TokenSelector.tsx (3)
apps/playground-web/src/hooks/useTokensData.ts (1)
  • useTokensData (106-119)
apps/playground-web/src/app/x402/components/constants.ts (1)
  • token (4-9)
packages/thirdweb/src/exports/thirdweb.ts (1)
  • NATIVE_TOKEN_ADDRESS (31-31)
apps/playground-web/src/hooks/useTokensData.ts (2)
apps/playground-web/src/lib/types.ts (1)
  • TokenMetadata (1-8)
apps/playground-web/src/app/x402/components/constants.ts (1)
  • token (4-9)
apps/playground-web/src/app/x402/components/X402LeftSection.tsx (1)
apps/playground-web/src/components/blocks/NetworkSelectors.tsx (1)
  • SingleNetworkSelector (17-145)
⏰ 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). (4)
  • GitHub Check: Vercel Agent Review
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (8)
apps/playground-web/src/app/x402/components/X402LeftSection.tsx (2)

109-115: LGTM!

The SingleNetworkSelector integration is correct, passing the required client prop and maintaining proper chain selection flow.


122-131: LGTM!

The includeNativeToken={false} prop correctly excludes native tokens from the x402 payment token selection, which aligns with the PR objectives for improved token selection.

apps/playground-web/src/components/ui/TokenSelector.tsx (2)

31-41: LGTM!

The native token filtering logic is well-implemented:

  • Case-insensitive address comparison is defensive
  • includeNativeToken === false explicit check ensures native tokens are included by default when prop is undefined
  • Proper memoization with correct dependencies

5-5: LGTM!

Import of NATIVE_TOKEN_ADDRESS from thirdweb is correct for the filtering logic.

apps/playground-web/src/app/x402/components/X402RightSection.tsx (2)

148-157: LGTM!

The empty state card provides clear guidance to users when no token is selected. The UI follows design system tokens with text-muted-foreground and Card component.


165-177: supportedTokens.name cannot use tokenName as it is not available in X402PlaygroundOptions.

The X402PlaygroundOptions type only provides tokenSymbol, not tokenName. Using tokenSymbol for both symbol and name is the correct approach given the available data. If a full token name is needed, it would require extending the type definition and providing it from the caller.

Likely an incorrect or invalid review comment.

apps/playground-web/src/hooks/useTokensData.ts (2)

7-15: LGTM!

The URL construction correctly handles both localhost (dev) and production environments with appropriate protocol selection.


42-56: LGTM!

The fallback logic for fetching x402-supported tokens when the bridge returns empty results is well-structured with proper error handling, enabling testnet support as noted in the comment.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

size-limit report 📦

Path Size
@thirdweb-dev/nexus (esm) 104.88 KB (0%)
@thirdweb-dev/nexus (cjs) 316.6 KB (0%)

@joaquim-verges joaquim-verges force-pushed the _X402_Improve_token_selection_and_UI_for_payment_playground branch from 21f81a3 to 849eeba Compare December 1, 2025 00:48
@vercel vercel bot temporarily deployed to Preview – thirdweb-www December 1, 2025 00:48 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 December 1, 2025 00:48 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula December 1, 2025 00:48 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui December 1, 2025 00:48 Inactive
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)
apps/playground-web/src/app/x402/components/X402RightSection.tsx (1)

31-34: Token selection guard is correct; consider extracting zero address

Using both a non-zero token address and non-empty symbol to derive isTokenSelected is a solid gate for the payment UI. If this zero-address sentinel is used in multiple places, consider extracting it into a shared constant instead of an inline string.

apps/playground-web/src/app/x402/components/X402LeftSection.tsx (2)

55-61: Revisit tokenAddress reset semantics now that native tokens are excluded

On chain change, handleChainChange resets:

tokenAddress: "0x0000000000000000000000000000000000000000" as const,
tokenSymbol: "",
tokenDecimals: 18,

while the TokenSelector is rendered with includeNativeToken={false} and selectedToken is set back to undefined.

If downstream logic treats the zero address as “native token selected” or simply as “some token is present” (e.g., if (options.tokenAddress) { ... }), this combination could bypass “no token selected” checks even though the UI requires the user to pick a non‑native token. It may be safer to clear tokenAddress (e.g., to undefined/null) on chain changes and only set it when handleTokenChange fires, so state and UI stay aligned with includeNativeToken={false}.

Additionally, the <Label htmlFor={tokenId}> is not currently associated with any id on TokenSelector; consider either plumb­ing an id prop through TokenSelector to the underlying focusable element or dropping htmlFor to avoid a broken association.

Also applies to: 119-133


21-24: Add an explicit return type to X402LeftSection

X402LeftSection currently relies on inference for its return type. For exported TSX components, adding an explicit return type (e.g., : React.JSX.Element) improves readability and aligns with the project’s TypeScript guidelines.

Example:

export function X402LeftSection(
  props: {
    options: X402PlaygroundOptions;
    setOptions: React.Dispatch<React.SetStateAction<X402PlaygroundOptions>>;
  },
): React.JSX.Element {
  // ...
}

As per coding guidelines, using explicit return types on exported functions is preferred.

Also applies to: 101-193

📜 Review details

Configuration used: CodeRabbit 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 21f81a3 and 849eeba.

📒 Files selected for processing (6)
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx (3 hunks)
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx (4 hunks)
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx (1 hunks)
  • apps/playground-web/src/components/ui/TokenSelector.tsx (2 hunks)
  • apps/playground-web/src/hooks/allChains.ts (1 hunks)
  • apps/playground-web/src/hooks/useTokensData.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/components/ui/TokenSelector.tsx
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
apps/{dashboard,playground-web}/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/{dashboard,playground-web}/src/**/*.{ts,tsx}: Import UI component primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground
Use Tailwind CSS only – no inline styles or CSS modules in dashboard and playground
Use cn() from @/lib/utils for conditional Tailwind class merging
Use design system tokens for styling (backgrounds: bg-card, borders: border-border, muted text: text-muted-foreground)
Expose className prop on root element for component overrides

Files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.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:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Lazy-import optional features; avoid top-level side-effects

Files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
🧠 Learnings (14)
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/{dashboard,playground-web}/src/**/*.{ts,tsx} : Use design system tokens for styling (backgrounds: `bg-card`, borders: `border-border`, muted text: `text-muted-foreground`)

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : Import UI primitives from @/components/ui/_ (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in Dashboard and Playground apps

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/{dashboard,playground-web}/src/**/*.{ts,tsx} : Import UI component primitives from `@/components/ui/*` (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Handle interactive UI with React hooks (`useState`, `useEffect`, React Query, wallet hooks) in client components

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : Stick to design tokens for styling: backgrounds (bg-card), borders (border-border), muted text (text-muted-foreground), etc.

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : Client Components: Begin files with 'use client'; before imports, handle interactive UI relying on React hooks (useState, useEffect, React Query, wallet hooks), access browser APIs (localStorage, window, IntersectionObserver, etc.), and support fast transitions with client-side data prefetching

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
📚 Learning: 2025-10-03T23:36:00.631Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 8181
File: packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx:27-27
Timestamp: 2025-10-03T23:36:00.631Z
Learning: In packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx, the component intentionally uses a hardcoded English locale (connectLocaleEn) rather than reading from the provider, as BuyWidget is designed to be English-only and does not require internationalization support.

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Applies to apps/dashboard/**/*.{ts,tsx} : Always import from the central UI library under `@/components/ui/*` for reusable core UI components like `Button`, `Input`, `Select`, `Tabs`, `Card`, `Sidebar`, `Separator`, `Badge`

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Use interactive client components for UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks)

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Applies to apps/dashboard/**/*.{ts,tsx} : Import icons from `lucide-react` or the project-specific `…/icons` exports; never embed raw SVG

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-07-07T21:21:47.488Z
Learnt from: saminacodes
Repo: thirdweb-dev/js PR: 7543
File: apps/portal/src/app/pay/page.mdx:4-4
Timestamp: 2025-07-07T21:21:47.488Z
Learning: In the thirdweb-dev/js repository, lucide-react icons must be imported with the "Icon" suffix (e.g., ExternalLinkIcon, RocketIcon) as required by the new linting rule, contrary to the typical lucide-react convention of importing without the suffix.

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-07-31T16:17:42.753Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7768
File: apps/playground-web/src/app/navLinks.ts:1-1
Timestamp: 2025-07-31T16:17:42.753Z
Learning: Configuration files that import and reference React components (like icon components from lucide-react) need the "use client" directive, even if they primarily export static data, because the referenced components need to be executed in a client context when used by other client components.

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Use client components for anything that consumes hooks from `tanstack/react-query` or thirdweb SDKs

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-06-17T18:30:52.976Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7356
File: apps/nebula/src/app/not-found.tsx:1-1
Timestamp: 2025-06-17T18:30:52.976Z
Learning: In the thirdweb/js project, the React namespace is available for type annotations (like React.FC) without needing to explicitly import React. This is project-specific configuration that differs from typical TypeScript/React setups.

Applied to files:

  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
🧬 Code graph analysis (1)
apps/playground-web/src/app/x402/components/X402LeftSection.tsx (1)
apps/playground-web/src/components/blocks/NetworkSelectors.tsx (1)
  • SingleNetworkSelector (17-145)
⏰ 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). (7)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Vercel Agent Review
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
apps/playground-web/src/app/x402/components/X402RightSection.tsx (4)

5-5: Icon import LGTM

CircleDollarSignIcon import fits the existing icon pattern in this file; no issues.


148-157: Empty-state card for missing token improves UX

The “Select Payment Token” card is a nice empty state and uses design tokens like text-muted-foreground consistently with playground styling. Based on learnings, this aligns with the dashboard/playground design system.


159-177: Gating payment UI on isTokenSelected is a good safety net

Rendering the entire Connect/payment block only when isTokenSelected is true prevents confusing states and ensures displayBalanceToken and supportedTokens are only set when there’s a valid token configuration.


185-199: Pricing copy now correctly reflects the selected token

Showing {amount} {tokenSymbol} in the badge and referencing tokenSymbol in the helper text makes the UI copy clearer, especially now that it’s gated on isTokenSelected so the symbol is always defined.

apps/playground-web/src/app/x402/components/X402LeftSection.tsx (1)

6-6: SingleNetworkSelector integration with THIRDWEB_CLIENT looks sound

Importing SingleNetworkSelector from the blocks layer and wiring it with chainId={selectedChain}, client={THIRDWEB_CLIENT}, and onChange={handleChainChange} matches the described API and keeps concerns well separated. Placeholder and bg-card styling also align with the playground design system. I don’t see any functional issues here.

Also applies to: 107-116

@joaquim-verges joaquim-verges force-pushed the _X402_Improve_token_selection_and_UI_for_payment_playground branch from 849eeba to df731a3 Compare December 1, 2025 00:56
@vercel vercel bot temporarily deployed to Preview – nebula December 1, 2025 00:56 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 December 1, 2025 00:56 Inactive
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 (1)
apps/playground-web/src/hooks/useTokensData.ts (1)

84-98: Remove redundant .flat() call after .flatMap().

The .flatMap() method already flattens one level, making the subsequent .flat() call on line 98 redundant. Additionally, the .filter() on line 97 is unnecessary since the mapping always produces valid TokenMetadata objects (the chainId guard on line 42 ensures chainId is defined).

Apply this diff to simplify the mapping:

     const result = apiTokens.kinds
       .flatMap((token) => {
         const assets = token.extra?.defaultAsset
           ? [token.extra?.defaultAsset]
           : (token.extra?.supportedAssets ?? []);
         return assets.map((asset) => ({
           chainId: chainId,
           address: asset.address,
           decimals: asset.decimals,
           symbol: asset.eip712.name,
           name: asset.eip712.name,
-        })) as TokenMetadata[];
+        }));
-      })
-      .filter((token) => token !== undefined)
-      .flat();
+      }) as TokenMetadata[];
     return result;
📜 Review details

Configuration used: CodeRabbit 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 849eeba and df731a3.

📒 Files selected for processing (6)
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx (3 hunks)
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx (4 hunks)
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx (1 hunks)
  • apps/playground-web/src/components/ui/TokenSelector.tsx (2 hunks)
  • apps/playground-web/src/hooks/allChains.ts (1 hunks)
  • apps/playground-web/src/hooks/useTokensData.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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:

  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
apps/{dashboard,playground-web}/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/{dashboard,playground-web}/src/**/*.{ts,tsx}: Import UI component primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground
Use Tailwind CSS only – no inline styles or CSS modules in dashboard and playground
Use cn() from @/lib/utils for conditional Tailwind class merging
Use design system tokens for styling (backgrounds: bg-card, borders: border-border, muted text: text-muted-foreground)
Expose className prop on root element for component overrides

Files:

  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.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:

  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Lazy-import optional features; avoid top-level side-effects

Files:

  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
🧠 Learnings (22)
📚 Learning: 2025-08-27T22:11:41.748Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7933
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/create-token-page-impl.tsx:465-473
Timestamp: 2025-08-27T22:11:41.748Z
Learning: In the token creation flow (create-token-page-impl.tsx), the createTokenOnUniversalBridge() call is intentionally not awaited (fire-and-forget pattern) to allow the token creation process to complete immediately without waiting for the bridge operation. This is a deliberate design choice to prioritize user experience by not blocking the main flow with supplementary bridge operations.

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/{dashboard,playground-web}/src/**/*.{ts,tsx} : Use design system tokens for styling (backgrounds: `bg-card`, borders: `border-border`, muted text: `text-muted-foreground`)

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-05-27T19:55:25.056Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenPriceData.ts:49-49
Timestamp: 2025-05-27T19:55:25.056Z
Learning: In the ERC20 public pages token price data hook (`useTokenPriceData.ts`), direct array access on `json.data[0]` without optional chaining is intentionally correct and should not be changed to use safety checks.

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{ts,tsx} : For server-side data fetching: Always call getAuthToken() to retrieve the JWT from cookies and inject the token as an Authorization: Bearer header – never embed it in the URL. Return typed results (Project[], User[], …) – avoid any

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Use `Authorization: Bearer` header for API calls – never embed tokens in URLs

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Keep tokens secret via internal API routes or server actions

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : For client-side data fetching: Wrap calls in React Query (tanstack/react-query), use descriptive and stable queryKeys for cache hits, configure staleTime / cacheTime based on freshness requirements (default ≥ 60 s), and keep tokens secret by calling internal API routes or server actions

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to packages/thirdweb/src/**/*.{ts,tsx} : Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-10-16T19:00:34.707Z
Learnt from: jnsdls
Repo: thirdweb-dev/js PR: 8267
File: packages/thirdweb/src/extensions/erc20/read/getCurrencyMetadata.ts:47-52
Timestamp: 2025-10-16T19:00:34.707Z
Learning: In the thirdweb SDK's getCurrencyMetadata function (packages/thirdweb/src/extensions/erc20/read/getCurrencyMetadata.ts), zero decimals is not a valid value for native currency. If `options.contract.chain.nativeCurrency.decimals` is 0, it should be treated as missing/invalid data and trigger an API fetch to get the correct native currency metadata.

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-08-28T12:24:37.171Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7933
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/distribution/token-sale.tsx:0-0
Timestamp: 2025-08-28T12:24:37.171Z
Learning: In the token creation flow, the tokenAddress field in erc20Asset_poolMode is always initialized with nativeTokenAddress and is never undefined, so conditional checks for undefined tokenAddress are not needed.

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-05-26T16:27:26.443Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7152
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/table.tsx:304-313
Timestamp: 2025-05-26T16:27:26.443Z
Learning: The `useChainSlug` hook returns a `string`, not `string | undefined`. When the input chainId is undefined or falsy, the hook returns an empty string "", but never returns undefined itself.

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-05-26T16:27:26.443Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7152
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/table.tsx:304-313
Timestamp: 2025-05-26T16:27:26.443Z
Learning: The `useChainSlug` hook returns `string | number`, not `string | undefined` as previously assumed. It does not return undefined values.

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/{dashboard,playground-web}/src/**/*.{ts,tsx} : Import UI component primitives from `@/components/ui/*` (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-07-10T10:18:33.238Z
Learnt from: arcoraven
Repo: thirdweb-dev/js PR: 7505
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/analytics/components/WebhookAnalyticsCharts.tsx:186-204
Timestamp: 2025-07-10T10:18:33.238Z
Learning: The ThirdwebBarChart component in apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/analytics/components/WebhookAnalyticsCharts.tsx does not accept standard accessibility props like `aria-label` and `role` in its TypeScript interface, causing compilation errors when added.

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-05-30T17:14:25.332Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7227
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/OpenEditionMetadata.tsx:26-26
Timestamp: 2025-05-30T17:14:25.332Z
Learning: The ModuleCardUIProps interface already includes a client prop of type ThirdwebClient, so when components use `Omit<ModuleCardUIProps, "children" | "updateButton">`, they inherit the client prop without needing to add it explicitly.

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : Client Components: Begin files with 'use client'; before imports, handle interactive UI relying on React hooks (useState, useEffect, React Query, wallet hooks), access browser APIs (localStorage, window, IntersectionObserver, etc.), and support fast transitions with client-side data prefetching

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-06-06T23:46:08.795Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7298
File: apps/dashboard/src/app/nebula-app/move-funds/move-funds.tsx:424-424
Timestamp: 2025-06-06T23:46:08.795Z
Learning: The thirdweb project has an ESLint rule that restricts direct usage of `defineChain`. When it's necessary to use `defineChain` directly, it's acceptable to disable the rule with `// eslint-disable-next-line no-restricted-syntax`.

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Use client components for anything that consumes hooks from `tanstack/react-query` or thirdweb SDKs

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Use interactive client components for UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks)

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Handle interactive UI with React hooks (`useState`, `useEffect`, React Query, wallet hooks) in client components

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to **/*.test.{ts,tsx} : Use `FORKED_ETHEREUM_CHAIN` for mainnet interactions and `ANVIL_CHAIN` for isolated tests

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-08-09T15:37:30.990Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7822
File: apps/dashboard/src/@/components/contracts/contract-card/contract-publisher.tsx:22-31
Timestamp: 2025-08-09T15:37:30.990Z
Learning: The Img component at apps/dashboard/src/@/components/blocks/Img.tsx properly handles empty string src values by immediately setting status to "fallback" and converting empty strings to undefined in the img element's src attribute, preventing unnecessary network requests.

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
🧬 Code graph analysis (2)
apps/playground-web/src/hooks/useTokensData.ts (2)
apps/playground-web/src/lib/types.ts (1)
  • TokenMetadata (1-8)
apps/playground-web/src/app/x402/components/constants.ts (1)
  • token (4-9)
apps/playground-web/src/components/blocks/NetworkSelectors.tsx (2)
apps/playground-web/src/hooks/allChains.ts (1)
  • useAllChainsData (21-30)
apps/playground-web/src/components/ui/select-with-search.tsx (1)
  • SelectWithSearch (38-198)
⏰ 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). (4)
  • GitHub Check: Lint Packages
  • GitHub Check: Size
  • GitHub Check: Vercel Agent Review
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (10)
apps/playground-web/src/hooks/useTokensData.ts (4)

7-22: LGTM! Clean URL construction with proper environment handling.

The dual-URL setup correctly handles both bridge and API endpoints with appropriate protocol detection and query parameter configuration.


24-40: LGTM! Proper error handling and type assertion.

The initial bridge fetch follows best practices with appropriate error handling and clear error messages.


42-101: Well-structured fallback logic with proper type safety.

The conditional fallback to the x402 API when bridge returns empty results is well-implemented. The chainId guard on line 42 ensures type safety throughout the fallback branch, and the API response mapping correctly extracts token metadata.


104-117: LGTM! Proper React Query implementation.

The hook follows best practices with a stable query key, appropriate stale time for token data, and conditional fetching support.

apps/playground-web/src/components/blocks/NetworkSelectors.tsx (6)

1-12: LGTM! Clean imports and helper function.

The imports follow the coding guidelines, and the cleanChainName helper provides a clear, single-responsibility utility for display formatting.


16-29: LGTM! Well-structured props interface.

The props interface provides appropriate filtering, customization, and configuration options with clear TypeScript types.


30-54: LGTM! Clean and conditional filtering logic.

The chain filtering logic properly applies each filter conditionally based on props, with correct memoization dependencies.


56-80: LGTM! Flexible search implementation.

The search function intelligently handles both numeric chain ID searches and text-based name searches with appropriate case insensitivity.


82-112: LGTM! Comprehensive option rendering with responsive design.

The render function provides rich chain display with icon, cleaned name, and optional chain ID badge, using proper design tokens and responsive classes.


114-139: LGTM! Properly integrated SelectWithSearch with excellent UX.

The component correctly handles loading states, type conversions, and prop forwarding. The undefined handling on line 137 is type-safe, avoiding the string "undefined" issue.

@joaquim-verges joaquim-verges force-pushed the _X402_Improve_token_selection_and_UI_for_payment_playground branch from df731a3 to bfaf06b Compare December 1, 2025 01:01
@vercel vercel bot temporarily deployed to Preview – docs-v2 December 1, 2025 01:01 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb-www December 1, 2025 01:01 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui December 1, 2025 01:01 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula December 1, 2025 01:01 Inactive
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

♻️ Duplicate comments (1)
apps/playground-web/src/hooks/allChains.ts (1)

6-19: Check HTTP status before parsing response.

The function parses res.json() on line 10 before validating res.ok on line 12. Non-2xx responses may have unexpected body shapes, causing json.error checks to silently fail.

Apply this diff to check status first:

 async function fetchChainsFromApi() {
   // always fetch from prod for chains for now
   // TODO: re-visit this
   const res = await fetch("https://api.thirdweb.com/v1/chains");
+
+  if (!res.ok) {
+    throw new Error(`Failed to fetch chains: ${res.status}`);
+  }
+
   const json = await res.json();
 
-  if (json.error || !res.ok) {
+  if (json.error) {
     throw new Error(
-      json.error?.message || `Failed to fetch chains: ${res.status}`,
+      json.error.message,
     );
   }
 
   return json.data as ChainMetadata[];
 }
🧹 Nitpick comments (2)
apps/playground-web/src/hooks/allChains.ts (1)

21-30: Consider adding staleTime for rarely-changing chain data.

Chain metadata changes infrequently. Adding a staleTime (e.g., 5–10 minutes) reduces redundant fetches and improves performance.

Apply this diff:

   const allChainsQuery = useQuery({
     queryFn: () => fetchChainsFromApi(),
     queryKey: ["all-chains"],
+    staleTime: 1000 * 60 * 5, // 5 minutes
   });
apps/playground-web/src/hooks/useTokensData.ts (1)

84-98: Remove redundant .flat() call.

Line 98's .flat() is unnecessary because .flatMap() already flattens one level.

Apply this diff:

     const result = apiTokens.kinds
       .flatMap((token) => {
         const assets = token.extra?.defaultAsset
           ? [token.extra?.defaultAsset]
           : (token.extra?.supportedAssets ?? []);
         return assets.map((asset) => ({
           chainId: chainId,
           address: asset.address,
           decimals: asset.decimals,
           symbol: asset.eip712.name,
           name: asset.eip712.name,
         })) as TokenMetadata[];
       })
-      .filter((token) => token !== undefined)
-      .flat();
+      .filter((token) => token !== undefined);
📜 Review details

Configuration used: CodeRabbit 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 df731a3 and bfaf06b.

📒 Files selected for processing (6)
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx (3 hunks)
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx (4 hunks)
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx (1 hunks)
  • apps/playground-web/src/components/ui/TokenSelector.tsx (2 hunks)
  • apps/playground-web/src/hooks/allChains.ts (1 hunks)
  • apps/playground-web/src/hooks/useTokensData.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/playground-web/src/components/ui/TokenSelector.tsx
  • apps/playground-web/src/app/x402/components/X402LeftSection.tsx
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
apps/{dashboard,playground-web}/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/{dashboard,playground-web}/src/**/*.{ts,tsx}: Import UI component primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground
Use Tailwind CSS only – no inline styles or CSS modules in dashboard and playground
Use cn() from @/lib/utils for conditional Tailwind class merging
Use design system tokens for styling (backgrounds: bg-card, borders: border-border, muted text: text-muted-foreground)
Expose className prop on root element for component overrides

Files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
**/*.{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:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Lazy-import optional features; avoid top-level side-effects

Files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
🧠 Learnings (36)
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Handle interactive UI with React hooks (`useState`, `useEffect`, React Query, wallet hooks) in client components

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Applies to apps/dashboard/**/*.{ts,tsx} : Use React Query (`tanstack/react-query`) for all client-side data fetching with typed hooks

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : Client Components: Begin files with 'use client'; before imports, handle interactive UI relying on React hooks (useState, useEffect, React Query, wallet hooks), access browser APIs (localStorage, window, IntersectionObserver, etc.), and support fast transitions with client-side data prefetching

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : For client-side data fetching: Wrap calls in React Query (tanstack/react-query), use descriptive and stable queryKeys for cache hits, configure staleTime / cacheTime based on freshness requirements (default ≥ 60 s), and keep tokens secret by calling internal API routes or server actions

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Use client components for anything that consumes hooks from `tanstack/react-query` or thirdweb SDKs

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Wrap client-side API calls in React Query (`tanstack/react-query`)

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Use interactive client components for UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks)

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Applies to apps/dashboard/**/*use*.{ts,tsx} : Keep `queryKey` stable and descriptive in React Query hooks for reliable cache hits

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Use descriptive, stable `queryKeys` in React Query for cache hits

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-05-27T19:54:55.885Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/erc20.tsx:15-17
Timestamp: 2025-05-27T19:54:55.885Z
Learning: The `fetchDashboardContractMetadata` function from "3rdweb-sdk/react/hooks/useDashboardContractMetadata" has internal error handlers for all promises and cannot throw errors, so external error handling is not needed when calling this function.

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-05-27T19:55:25.056Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenPriceData.ts:49-49
Timestamp: 2025-05-27T19:55:25.056Z
Learning: In the ERC20 public pages token price data hook (`useTokenPriceData.ts`), direct array access on `json.data[0]` without optional chaining is intentionally correct and should not be changed to use safety checks.

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-10-16T19:00:34.707Z
Learnt from: jnsdls
Repo: thirdweb-dev/js PR: 8267
File: packages/thirdweb/src/extensions/erc20/read/getCurrencyMetadata.ts:47-52
Timestamp: 2025-10-16T19:00:34.707Z
Learning: In the thirdweb SDK's getCurrencyMetadata function (packages/thirdweb/src/extensions/erc20/read/getCurrencyMetadata.ts), zero decimals is not a valid value for native currency. If `options.contract.chain.nativeCurrency.decimals` is 0, it should be treated as missing/invalid data and trigger an API fetch to get the correct native currency metadata.

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-09-17T11:02:13.528Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 8044
File: packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts:15-17
Timestamp: 2025-09-17T11:02:13.528Z
Learning: The thirdweb `client` object is serializable and can safely be used in React Query keys, similar to the `contract` object.

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Local state or effects live inside components; data fetching happens in hooks

Applied to files:

  • apps/playground-web/src/hooks/allChains.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/{dashboard,playground-web}/src/**/*.{ts,tsx} : Import UI component primitives from `@/components/ui/*` (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-07-10T10:18:33.238Z
Learnt from: arcoraven
Repo: thirdweb-dev/js PR: 7505
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/analytics/components/WebhookAnalyticsCharts.tsx:186-204
Timestamp: 2025-07-10T10:18:33.238Z
Learning: The ThirdwebBarChart component in apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/analytics/components/WebhookAnalyticsCharts.tsx does not accept standard accessibility props like `aria-label` and `role` in its TypeScript interface, causing compilation errors when added.

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-05-30T17:14:25.332Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7227
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/OpenEditionMetadata.tsx:26-26
Timestamp: 2025-05-30T17:14:25.332Z
Learning: The ModuleCardUIProps interface already includes a client prop of type ThirdwebClient, so when components use `Omit<ModuleCardUIProps, "children" | "updateButton">`, they inherit the client prop without needing to add it explicitly.

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-06-06T23:46:08.795Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7298
File: apps/dashboard/src/app/nebula-app/move-funds/move-funds.tsx:424-424
Timestamp: 2025-06-06T23:46:08.795Z
Learning: The thirdweb project has an ESLint rule that restricts direct usage of `defineChain`. When it's necessary to use `defineChain` directly, it's acceptable to disable the rule with `// eslint-disable-next-line no-restricted-syntax`.

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to **/*.test.{ts,tsx} : Use `FORKED_ETHEREUM_CHAIN` for mainnet interactions and `ANVIL_CHAIN` for isolated tests

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-05-26T16:27:26.443Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7152
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/table.tsx:304-313
Timestamp: 2025-05-26T16:27:26.443Z
Learning: The `useChainSlug` hook returns a `string`, not `string | undefined`. When the input chainId is undefined or falsy, the hook returns an empty string "", but never returns undefined itself.

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-08-09T15:37:30.990Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7822
File: apps/dashboard/src/@/components/contracts/contract-card/contract-publisher.tsx:22-31
Timestamp: 2025-08-09T15:37:30.990Z
Learning: The Img component at apps/dashboard/src/@/components/blocks/Img.tsx properly handles empty string src values by immediately setting status to "fallback" and converting empty strings to undefined in the img element's src attribute, preventing unnecessary network requests.

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
📚 Learning: 2025-05-26T16:27:26.443Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7152
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/table.tsx:304-313
Timestamp: 2025-05-26T16:27:26.443Z
Learning: The `useChainSlug` hook returns `string | number`, not `string | undefined` as previously assumed. It does not return undefined values.

Applied to files:

  • apps/playground-web/src/components/blocks/NetworkSelectors.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/{dashboard,playground-web}/src/**/*.{ts,tsx} : Use design system tokens for styling (backgrounds: `bg-card`, borders: `border-border`, muted text: `text-muted-foreground`)

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : Import UI primitives from @/components/ui/_ (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in Dashboard and Playground apps

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{tsx,ts} : Stick to design tokens for styling: backgrounds (bg-card), borders (border-border), muted text (text-muted-foreground), etc.

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-10-03T23:36:00.631Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 8181
File: packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx:27-27
Timestamp: 2025-10-03T23:36:00.631Z
Learning: In packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx, the component intentionally uses a hardcoded English locale (connectLocaleEn) rather than reading from the provider, as BuyWidget is designed to be English-only and does not require internationalization support.

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Applies to apps/dashboard/**/*.{ts,tsx} : Import icons from `lucide-react` or the project-specific `…/icons` exports; never embed raw SVG

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-07-07T21:21:47.488Z
Learnt from: saminacodes
Repo: thirdweb-dev/js PR: 7543
File: apps/portal/src/app/pay/page.mdx:4-4
Timestamp: 2025-07-07T21:21:47.488Z
Learning: In the thirdweb-dev/js repository, lucide-react icons must be imported with the "Icon" suffix (e.g., ExternalLinkIcon, RocketIcon) as required by the new linting rule, contrary to the typical lucide-react convention of importing without the suffix.

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-07-31T16:17:42.753Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7768
File: apps/playground-web/src/app/navLinks.ts:1-1
Timestamp: 2025-07-31T16:17:42.753Z
Learning: Configuration files that import and reference React components (like icon components from lucide-react) need the "use client" directive, even if they primarily export static data, because the referenced components need to be executed in a client context when used by other client components.

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-11-24T22:44:20.977Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-11-24T22:44:20.977Z
Learning: Applies to apps/dashboard/**/*.{ts,tsx} : Always import from the central UI library under `@/components/ui/*` for reusable core UI components like `Button`, `Input`, `Select`, `Tabs`, `Card`, `Sidebar`, `Separator`, `Badge`

Applied to files:

  • apps/playground-web/src/app/x402/components/X402RightSection.tsx
📚 Learning: 2025-08-27T22:11:41.748Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7933
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/create-token-page-impl.tsx:465-473
Timestamp: 2025-08-27T22:11:41.748Z
Learning: In the token creation flow (create-token-page-impl.tsx), the createTokenOnUniversalBridge() call is intentionally not awaited (fire-and-forget pattern) to allow the token creation process to complete immediately without waiting for the bridge operation. This is a deliberate design choice to prioritize user experience by not blocking the main flow with supplementary bridge operations.

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:45:01.202Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.202Z
Learning: Applies to apps/{dashboard,playground}/**/*.{ts,tsx} : For server-side data fetching: Always call getAuthToken() to retrieve the JWT from cookies and inject the token as an Authorization: Bearer header – never embed it in the URL. Return typed results (Project[], User[], …) – avoid any

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Use `Authorization: Bearer` header for API calls – never embed tokens in URLs

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to apps/dashboard/src/**/*.{ts,tsx} : Keep tokens secret via internal API routes or server actions

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-11-24T22:43:43.644Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T22:43:43.644Z
Learning: Applies to packages/thirdweb/src/**/*.{ts,tsx} : Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
📚 Learning: 2025-08-28T12:24:37.171Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7933
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/distribution/token-sale.tsx:0-0
Timestamp: 2025-08-28T12:24:37.171Z
Learning: In the token creation flow, the tokenAddress field in erc20Asset_poolMode is always initialized with nativeTokenAddress and is never undefined, so conditional checks for undefined tokenAddress are not needed.

Applied to files:

  • apps/playground-web/src/hooks/useTokensData.ts
🧬 Code graph analysis (2)
apps/playground-web/src/components/blocks/NetworkSelectors.tsx (2)
apps/playground-web/src/hooks/allChains.ts (1)
  • useAllChainsData (21-30)
apps/playground-web/src/components/ui/select-with-search.tsx (1)
  • SelectWithSearch (38-198)
apps/playground-web/src/hooks/useTokensData.ts (2)
apps/playground-web/src/lib/types.ts (1)
  • TokenMetadata (1-8)
apps/playground-web/src/app/x402/components/constants.ts (1)
  • token (4-9)
⏰ 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). (4)
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: Vercel Agent Review
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
apps/playground-web/src/components/blocks/NetworkSelectors.tsx (1)

16-140: Well-structured component with proper filtering and rendering.

The SingleNetworkSelector implementation correctly addresses all previous review concerns:

  • No unused props
  • Single deprecated filter controlled by prop
  • Proper handling of undefined chainId in value prop
  • Clean memoization with correct dependencies
  • Appropriate use of design tokens
apps/playground-web/src/app/x402/components/X402RightSection.tsx (3)

31-34: Correct token selection validation.

The isTokenSelected logic properly validates both the token address (against zero address) and ensures the symbol is present. This defensive check prevents rendering the UI with incomplete token data.


148-157: Well-designed empty state prompt.

The prompt card uses appropriate design tokens, provides clear guidance, and follows the established UI patterns.


159-177: Simplified ConnectButton configuration.

Removing conditional logic and always providing token configuration is correct since the parent condition on line 159 guarantees isTokenSelected is true.

@joaquim-verges joaquim-verges merged commit 68a1dca into main Dec 1, 2025
25 checks passed
@joaquim-verges joaquim-verges deleted the _X402_Improve_token_selection_and_UI_for_payment_playground branch December 1, 2025 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Playground Changes involving the Playground codebase.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants