Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Sep 12, 2025


PR-Codex overview

This PR focuses on enhancing the thirdweb library by introducing new components and functionalities related to token swapping and bridging, alongside various UI improvements and bug fixes.

Detailed summary

  • Added BridgeChain type in Chain.ts.
  • Introduced cleanedChainName function for formatting chain names.
  • Added SwapWidget component for token swapping.
  • Enhanced ConnectButton, Modal, and various UI components with new titles and properties.
  • Updated payment methods in paymentMachine.ts.
  • Improved styling and layout in multiple components.
  • Added new event reporting functions for token swaps and asset purchases.
  • Refactored BuyAndSwapEmbed component to support both buying and swapping tokens.
  • Updated PaymentDetails to handle new props for better flexibility.

The following files were skipped due to too many changes: packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx, packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts, packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx, packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx, packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx

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

Summary by CodeRabbit

  • New Features

    • SwapWidget: in-app token-swap flow with token/chain pickers, search, prefill, multi-step flow, and BuyAndSwapEmbed to toggle Buy/Swap.
  • UI / Style

    • UX refinements: spacing, radii, typography, modal titles, improved image loading/fallbacks and skeletons, spinner styling, new button variant, input background option, new icons, smaller layout tweaks across payment/bridge UIs.
  • Analytics

    • Token swap events (success/failed/cancelled) and asset buy-cancelled reporting.
  • Documentation

    • Storybook stories for SwapWidget, SelectChain, and BuyWidget.
  • Chores

    • Added package typecheck npm script.

@MananTank MananTank requested review from a team as code owners September 12, 2025 22:00
@changeset-bot
Copy link

changeset-bot bot commented Sep 12, 2025

🦋 Changeset detected

Latest commit: b1f23a2

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

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

Not sure what this means? Click here to learn what changesets are.

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

@vercel
Copy link

vercel bot commented Sep 12, 2025

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

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Sep 17, 2025 4:36pm
nebula Ready Ready Preview Comment Sep 17, 2025 4:36pm
thirdweb_playground Ready Ready Preview Comment Sep 17, 2025 4:36pm
thirdweb-www Ready Ready Preview Comment Sep 17, 2025 4:36pm
wallet-ui Ready Ready Preview Comment Sep 17, 2025 4:36pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 12, 2025

Walkthrough

Adds a new SwapWidget (UI, hooks, types, storage, stories) and exports it; introduces many UI/design-system and modal title props changes; updates payment flows to use paymentMethod.action; adds analytics for token swaps; integrates a combined Buy+Swap embed in the dashboard; adds a package-level typecheck script.

Changes

Cohort / File(s) Summary
Tooling
packages/thirdweb/package.json
Adds typecheck npm script running tsc --project ./tsconfig.build.json --module nodenext --moduleResolution nodenext --noEmit.
Bridge core types
packages/thirdweb/src/bridge/types/Chain.ts
Exports type alias BridgeChain = Chain.
Currency symbol refactor
packages/thirdweb/src/pay/convert/type.ts
Replaces switch with currencySymbol map; getFiatSymbol resolves from map with $ fallback; narrows SupportedFiatCurrency to keyof typeof currencySymbol.
Design tokens
packages/thirdweb/src/react/core/design-system/index.ts
Updates skeletonBg mapping; adds radius.full = "9999px" and spacing key md+ = "20px".
Shared UI primitives
packages/thirdweb/src/react/web/ui/components/{Img.tsx,Skeleton.tsx,Spinner.tsx,DynamicHeight.tsx,Modal.tsx}
Img: three-state lifecycle, fallback? and skeletonColor?; Skeleton/Spinner accept style?: React.CSSProperties; DynamicHeight transition easing changed; Modal adds title and optional crossContainerStyles, adjusts radii and close-button container.
Buttons, inputs, layout, text
packages/thirdweb/src/react/web/ui/components/{buttons.tsx,formElements.tsx,basic.tsx,text.tsx}
Button: ghost-solid variant added; Input: optional bg prop; Container: adds pt/pb; Line: supports dashed via borderTop; Text: adds trackingTight? and default weight change.
ConnectWallet modals & icons
packages/thirdweb/src/react/web/ui/ConnectWallet/{ConnectButton.tsx,Details.tsx,Modal/ConnectModal.tsx,NetworkSelector.tsx}
packages/thirdweb/src/react/web/ui/ConnectWallet/icons/{ArrowUpDownIcon.tsx,WalletDotIcon.tsx}
Injects modal titles ("Sign in","Manage Wallet","Connect Wallet","Switch Network"); adds ArrowUpDownIcon and WalletDotIcon.
Bridge UI surface tweaks
packages/thirdweb/src/react/web/ui/Bridge/{UnsupportedTokenScreen.tsx,StepRunner.tsx,DirectPayment.tsx,ErrorBanner.tsx,FundWallet.tsx,QuoteLoader.tsx,TransactionPayment.tsx,common/{TokenAndChain.tsx,WithHeader.tsx},payment-details/PaymentDetails.tsx}
Presentational adjustments (spacing, weights, text); StepRunner adds title?: string and padding changes; PaymentDetails adds title? and confirmButtonLabel?, adds sell handling and validation; QuoteLoader uses paymentMethod.action for amount/type; WithHeader conditionally renders title/description.
Payment selection / providers
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/{FiatProviderSelection.tsx,PaymentSelection.tsx,WalletFiatSelection.tsx}
FiatProviderSelection list/loading redesign and larger loading panel; PaymentSelection refines initial step/back behavior for single card flows and passes connectedWallets; WalletFiatSelection hides crypto header when single method.
SwapWidget core & container
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
Adds SwapWidget and SwapWidgetContainer implementing multi-screen swap flow (swap UI, preview, execute, success, error), prefill, theming, callbacks and state transitions.
SwapWidget submodules
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/{swap-ui.tsx,select-token-ui.tsx,select-chain.tsx,SearchInput.tsx,SelectChainButton.tsx,use-bridge-chains.ts,use-tokens.ts,storage.ts,utils.ts,common.tsx,hooks.ts,types.ts}
Adds token/chain selectors and UIs, SearchInput, SelectChainButton, cleanedChainName, DecimalRenderer, hooks useBridgeChains, useTokens, useTokenBalances, useActiveWalletInfo, localStorage helpers with zod validation (getLastUsedTokens/setLastUsedTokens), and public types (SwapWidgetConnectOptions, ActiveWalletInfo, TokenSelection, SwapPreparedQuote).
SwapWidget stories
packages/thirdweb/src/stories/Bridge/Swap/*
Adds stories: SelectChain, SwapWidget variants, and SwapWidget prefill scenarios.
BuyWidget story
packages/thirdweb/src/stories/BuyWidget.stories.tsx
Adds stories demonstrating BuyWidget variants (unsupported chain/token, payment-method filters).
Exports
packages/thirdweb/src/exports/react.ts
Exports SwapWidget and SwapWidgetProps from the React exports surface.
Payment method shape
packages/thirdweb/src/react/core/hooks/usePaymentMethods.ts,packages/thirdweb/src/react/core/machines/paymentMachine.ts
Adds action to wallet PaymentMethod (`"buy"
App/dashboard integrations
apps/dashboard/src/.../{PayEmbedSection.tsx,BuyAndSwapEmbed.tsx,GridPatternEmbedContainer.tsx,BuyFundsSection.tsx,erc20.tsx,UniversalBridgeEmbed.tsx,page.tsx}
Integrates combined Buy+Swap embed (BuyAndSwapEmbed) and GridPatternEmbedContainer; replaces Buy-only embeds with BuyAndSwapEmbed where applicable; wires analytics for token swap success/failure/cancel; updates copy to Bridge-focused text.
Stories / minor fixes
packages/thirdweb/src/stories/ConnectWallet/*
Minor casing change in story ("usd""USD").
Analytics
apps/dashboard/src/@/analytics/report.ts
Adds token-swap analytics functions (reportTokenSwapSuccessful, reportTokenSwapFailed, reportTokenSwapCancelled) and reportAssetBuyCancelled.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant SwapWidget
  participant SwapUI
  participant QuoteSvc as useSwapQuote
  participant Preview as PaymentDetails
  participant Runner as StepRunner
  participant BridgeAPI

  User->>SwapWidget: Open widget
  SwapWidget->>SwapUI: Render token inputs and selectors
  User->>SwapUI: Select tokens / enter amount
  SwapUI->>QuoteSvc: Request quote (periodic refetch)
  QuoteSvc-->>SwapUI: Quote / prepared request
  User->>SwapUI: Trigger Swap (onSwap)
  SwapWidget->>Preview: Show preview (title/confirm label)
  User->>Preview: Confirm
  Preview->>Runner: Execute (uses paymentMethod.action for request.type)
  Runner->>BridgeAPI: Submit bridge request
  BridgeAPI-->>Runner: Status/result
  alt success
    Runner-->>SwapWidget: onComplete
    SwapWidget->>User: Success screen
  else failure
    Runner-->>SwapWidget: onError
    SwapWidget->>User: Error banner
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description contains the repository template as commented text and a PR-Codex overview, but it does not populate the required template sections (a properly formatted title line, "Notes for the reviewer", and "How to test"), so it does not meet the repository's description-template requirements. The existing PR-Codex summary is useful but does not substitute for the explicit template sections that reviewers rely on. Please update the PR description to follow the repository template: add a title using the "[SDK/Dashboard/Portal] Feature/Fix: ..." format, provide a "Notes for the reviewer" section calling out large/skimmed files and areas needing focused review (e.g., the swap-widget files and analytics changes), and add a "How to test" section with concrete steps (Storybook/playground stories to run, build/typecheck commands, and any manual QA steps).
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title refers to the primary changes in the changeset (adding a SwapWidget, integrating it into the dashboard, and BuyWidget UI adjustments), so it is materially related to the PR contents; however it is somewhat long, lists multiple changes instead of a single focused statement, and does not follow the repository's suggested "[SDK/Dashboard/Portal] Feature/Fix:" prefix.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mnn/swap-ui

📜 Recent 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 d87c23b and b1f23a2.

📒 Files selected for processing (1)
  • .changeset/lucky-turtles-smell.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/lucky-turtles-smell.md
⏰ 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: Socket Security: Pull Request Alerts
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)

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.

@graphite-app
Copy link
Contributor

graphite-app bot commented Sep 12, 2025

How to use the Graphite Merge Queue

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

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

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 12, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.96 KB (0%) 1.3 s (0%) 244 ms (+204.11% 🔺) 1.6 s
thirdweb (cjs) 361.44 KB (0%) 7.3 s (0%) 862 ms (+17.08% 🔺) 8.1 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 102 ms (+3109.21% 🔺) 216 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 92 ms (+2853.23% 🔺) 102 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 104 ms (+2539.45% 🔺) 487 ms

@codecov
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

❌ Patch coverage is 17.56272% with 230 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.48%. Comparing base (210f631) to head (9cf8688).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...Bridge/payment-selection/FiatProviderSelection.tsx 0.00% 83 Missing ⚠️
...t/web/ui/Bridge/payment-details/PaymentDetails.tsx 0.00% 40 Missing ⚠️
...kages/thirdweb/src/react/web/ui/components/Img.tsx 37.83% 23 Missing ⚠️
...dweb/src/react/web/ui/Bridge/common/WithHeader.tsx 0.00% 16 Missing ⚠️
...b/ui/Bridge/payment-selection/PaymentSelection.tsx 0.00% 15 Missing ⚠️
...i/Bridge/payment-selection/WalletFiatSelection.tsx 0.00% 9 Missing ⚠️
...es/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx 0.00% 8 Missing ⚠️
...s/thirdweb/src/react/web/ui/components/buttons.tsx 11.11% 8 Missing ⚠️
...s/thirdweb/src/react/web/ui/Bridge/QuoteLoader.tsx 0.00% 5 Missing ⚠️
...thirdweb/src/react/core/hooks/usePaymentMethods.ts 0.00% 4 Missing ⚠️
... and 11 more

❌ Your patch check has failed because the patch coverage (17.56%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8044      +/-   ##
==========================================
- Coverage   56.51%   56.48%   -0.03%     
==========================================
  Files         904      904              
  Lines       58865    58988     +123     
  Branches     4170     4173       +3     
==========================================
+ Hits        33269    33321      +52     
- Misses      25491    25562      +71     
  Partials      105      105              
Flag Coverage Δ
packages 56.48% <17.56%> (-0.03%) ⬇️
Files with missing lines Coverage Δ
...ges/thirdweb/src/react/core/design-system/index.ts 84.02% <100.00%> (+0.11%) ⬆️
...thirdweb/src/react/core/machines/paymentMachine.ts 72.94% <ø> (ø)
...ges/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx 9.03% <ø> (ø)
...src/react/web/ui/Bridge/UnsupportedTokenScreen.tsx 14.28% <ø> (ø)
...dweb/src/react/web/ui/components/DynamicHeight.tsx 87.17% <100.00%> (ø)
.../thirdweb/src/react/web/ui/components/Skeleton.tsx 96.55% <100.00%> (+0.12%) ⬆️
...s/thirdweb/src/react/web/ui/components/Spinner.tsx 94.44% <100.00%> (+0.15%) ⬆️
packages/thirdweb/src/pay/convert/type.ts 94.64% <96.42%> (+25.75%) ⬆️
...s/thirdweb/src/react/web/ui/Bridge/ErrorBanner.tsx 13.88% <0.00%> (ø)
...t/web/ui/Bridge/payment-success/PaymentReceipt.tsx 5.45% <0.00%> (+0.03%) ⬆️
... and 18 more

... and 7 files with indirect coverage changes

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

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
packages/thirdweb/src/bridge/types/Chain.ts (1)

42-43: Add required TSDoc for public alias per package guidelines

Public symbols here must include TSDoc with an example and a custom stability tag.

Add docs:

+
+/**
+ * Alias of {@link Chain} used across the Bridge UI/API surface.
+ * @beta
+ * @public
+ * @example
+ * import type { BridgeChain } from "thirdweb/bridge";
+ * function onSelect(chain: BridgeChain) {
+ *   console.log(chain.chainId, chain.name);
+ * }
+ */
 export type BridgeChain = Chain;
packages/thirdweb/src/react/web/ui/components/formElements.tsx (1)

36-106: Add TSDoc or mark internal for exported UI primitives

Per repo guidelines, exported symbols in packages/thirdweb need TSDoc with an example or an explicit @internal. Please annotate Label, Input, and InputContainer.

-export const Input = /* @__PURE__ */ StyledInput<InputProps>((props) => {
+/**
+ * @internal
+ */
+export const Input = /* @__PURE__ */ StyledInput<InputProps>((props) => {
packages/thirdweb/src/react/web/ui/components/buttons.tsx (1)

26-157: Add TSDoc or mark internal for Button exports

Please annotate Button, ButtonLink, and IconButton per packages/thirdweb guidelines.

-export const Button = /* @__PURE__ */ StyledButton((props: ButtonProps) => {
+/**
+ * @internal
+ */
+export const Button = /* @__PURE__ */ StyledButton((props: ButtonProps) => {
packages/thirdweb/src/react/web/ui/components/Img.tsx (1)

37-41: Fix “undefinedpx” sizing when width/height are omitted

widthPx/heightPx produce invalid values if props are undefined. Provide safe defaults.

-  const widthPx = `${props.width}px`;
-  const heightPx = `${props.height || props.width}px`;
+  const DEFAULT_SIZE = "24px";
+  const widthPx = props.width ? `${props.width}px` : undefined;
+  const heightPx = props.height
+    ? `${props.height}px`
+    : props.width
+      ? `${props.width}px`
+      : DEFAULT_SIZE;
🧹 Nitpick comments (51)
packages/thirdweb/src/react/web/ui/ConnectWallet/icons/ArrowUpDownIcon.tsx (3)

3-16: Forward SVG props and add a sane default size.

Enable consumers to pass className/aria-label/etc. and avoid undefined width/height.

-export const ArrowUpDownIcon: IconFC = (props) => {
+export const ArrowUpDownIcon: IconFC = ({ size = 24, ...props }) => {
   return (
     <svg
       xmlns="http://www.w3.org/2000/svg"
       viewBox="0 0 24 24"
       fill="none"
       stroke="currentColor"
-      strokeWidth="2"
+      strokeWidth={2}
       strokeLinecap="round"
       strokeLinejoin="round"
-      role="presentation"
-      width={props.size}
-      height={props.size}
+      role="presentation"
+      width={size}
+      height={size}
+      {...props}
     >

13-16: A11y: mark decorative SVGs as hidden to AT (or provide an accessible name).

If this icon is purely decorative, prefer aria-hidden and prevent focus; if it conveys meaning, pass an aria-label via props and keep role="img".

-      role="presentation"
+      aria-hidden="true"
+      focusable="false"

3-3: Add TSDoc with a custom tag per packages/thirdweb policy.

Mark as @internal if not part of the public API; otherwise add an @example.

+/**
+ * Up/down arrows icon used in wallet/bridge UIs.
+ * @internal
+ */
 export const ArrowUpDownIcon: IconFC = ({ size = 24, ...props }) => {
packages/thirdweb/src/react/web/ui/Bridge/UnsupportedTokenScreen.tsx (3)

97-98: Add missing period for consistency and polish.

The preceding testnet message ends with a period. Mirror that here.

-        This token or chain is not supported by the Bridge
+        This token or chain is not supported by the Bridge.

30-40: Don’t use React Query for a side-effect-only analytics ping.

Using useQuery here adds caching semantics and a static key that won’t re-fire if props change within the same mount. Prefer useEffect (or a useMutation) tied to the relevant deps.

-import { useQuery } from "@tanstack/react-query";
+import { useEffect } from "react";
@@
-  useQuery({
-    queryFn: () => {
-      trackPayEvent({
-        chainId: chain.id,
-        client,
-        event: "ub:ui:unsupported_token",
-        fromToken: tokenAddress,
-      });
-    },
-    queryKey: ["unsupported_token"],
-  });
+  useEffect(() => {
+    trackPayEvent({
+      chainId: chain.id,
+      client,
+      event: "ub:ui:unsupported_token",
+      fromToken: tokenAddress,
+    });
+  }, [chain.id, client, tokenAddress]);

If you must keep React Query, at least include chain.id and tokenAddress in the queryKey and set staleTime: Infinity.


25-25: Add explicit return type to match TS guidelines.

Declare the component’s return type for clarity and tooling.

-export function UnsupportedTokenScreen(props: UnsupportedTokenScreenProps) {
+export function UnsupportedTokenScreen(props: UnsupportedTokenScreenProps): JSX.Element {
packages/thirdweb/src/react/web/ui/components/DynamicHeight.tsx (1)

20-21: Smoother height animation and consistency with DS transitions

Consider ease-in-out and explicitly hint painting for slightly smoother expansion; also centralize duration/timing as a design token to keep consistent across components.

Apply this minimal tweak:

-        transition: "height 210ms ease",
+        transition: "height 210ms ease-in-out",
+        willChange: "height",
packages/thirdweb/package.json (1)

344-345: Avoid duplicating tsc invocation between lint and typecheck

You can route lint to call the new typecheck script for one source of truth.

Update scripts:

-    "lint": "knip && biome check ./src && tsc --project ./tsconfig.build.json --module nodenext --moduleResolution nodenext --noEmit",
+    "lint": "knip && biome check ./src && pnpm typecheck",
     "typedoc": "node scripts/typedoc.mjs && node scripts/parse.mjs",
     "typecheck": "tsc --project ./tsconfig.build.json --module nodenext --moduleResolution nodenext --noEmit",
packages/thirdweb/src/react/web/ui/components/Skeleton.tsx (1)

18-26: Hide decorative skeletons from assistive tech

Marking as decorative avoids noisy announcements while loading.

-    <SkeletonDiv
+    <SkeletonDiv
+      aria-hidden
       className={props.className || ""}
       color={props.color}
       style={{
         height: props.height,
         width: props.width || "auto",
         ...props.style,
       }}
     />
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/utils.ts (1)

1-3: Make chain-name cleanup more robust

Limit removal to trailing “Mainnet”, handle case/parentheses, and avoid returning empty strings.

-export function cleanedChainName(name: string) {
-  return name.replace("Mainnet", "");
-}
+export function cleanedChainName(name: string) {
+  const cleaned = name.replace(/\s*\(?Mainnet\)?$/i, "").trim();
+  return cleaned.length > 0 ? cleaned : name;
+}

Happy to add a tiny test matrix (e.g., "Ethereum Mainnet", "Mainnet", "Zora (Mainnet)", "Arbitrum mainnet").

packages/thirdweb/src/react/web/ui/components/buttons.tsx (1)

120-127: Hover styling fine; improve transition and default background

Use transparent (clearer intent) and animate background for smoother UX.

-    transition: "border 200ms ease",
+    transition: "border 200ms ease, background 200ms ease, color 200ms ease",
...
-      if (props.variant === "ghost-solid") {
+      if (props.variant === "ghost-solid") {
         return {
           "&:hover": {
             background: theme.colors.tertiaryBg,
           },
-          border: "1px solid transparent",
+          background: "transparent",
+          border: "1px solid transparent",
         };
       }
packages/thirdweb/src/pay/convert/type.ts (1)

36-60: Optional: disambiguate $-prefixed locales

Consider locale-specific prefixes (e.g., HK$, CA$, A$) if UI needs clarity across multiple “$” currencies.

packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts (1)

1-37: Mark hooks as internal

These widget-specific hooks should be annotated to avoid being treated as public API.

-export function useTokens(options: {
+/**
+ * @internal
+ */
+export function useTokens(options: {
packages/thirdweb/src/react/web/ui/Bridge/StepRunner.tsx (1)

164-177: Simplify background color helper

All branches return the same color; collapse the switch.

-  const getStepBackgroundColor = (
-    status: "pending" | "executing" | "completed" | "failed",
-  ) => {
-    switch (status) {
-      case "completed":
-        return theme.colors.tertiaryBg;
-      case "executing":
-        return theme.colors.tertiaryBg;
-      case "failed":
-        return theme.colors.tertiaryBg;
-      default:
-        return theme.colors.tertiaryBg;
-    }
-  };
+  const getStepBackgroundColor = () => theme.colors.tertiaryBg;
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (2)

5-12: Include client in queryKey; set a sane cache policy

Prevents cross-client cache bleed and reduces refetch churn.

-export function useBridgeChains(client: ThirdwebClient) {
-  return useQuery({
-    queryKey: ["bridge-chains"],
-    queryFn: () => {
-      return chains({ client });
-    },
-  });
-}
+export function useBridgeChains(client: ThirdwebClient) {
+  return useQuery({
+    queryKey: ["bridge-chains", client.clientId],
+    staleTime: 5 * 60 * 1000,
+    queryFn: () => chains({ client }),
+  });
+}

5-12: Mark internal

This is widget plumbing, not a public SDK surface.

-export function useBridgeChains(client: ThirdwebClient) {
+/**
+ * @internal
+ */
+export function useBridgeChains(client: ThirdwebClient) {
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SearchInput.tsx (3)

17-28: Make icon decorative and click‑through

Set the search icon to be ignored by screen readers and not intercept pointer events.

       <Container color="secondaryText">
         <MagnifyingGlassIcon
           width={iconSize.md}
           height={iconSize.md}
+          aria-hidden="true"
           style={{
             position: "absolute",
             left: spacing.sm,
             top: "50%",
             transform: "translateY(-50%)",
+            pointerEvents: "none",
           }}
         />
       </Container>

30-38: Avoid magic number; improve a11y

Compute left padding from tokens, set proper input type, and add an accessible label.

       <Input
-        variant="outline"
+        variant="outline"
+        type="search"
         placeholder={props.placeholder}
         value={props.value}
         style={{
-          paddingLeft: "44px",
+          paddingLeft: `calc(${spacing.sm} + ${iconSize.md}px + ${spacing.xs})`,
         }}
-        onChange={(e) => props.onChange(e.target.value)}
+        aria-label={props.placeholder}
+        onChange={(e) => props.onChange(e.target.value)}
       />

6-10: Add explicit types per guidelines

Add a props alias and explicit return type for the component.

-export function SearchInput(props: {
-  value: string;
-  onChange: (value: string) => void;
-  placeholder: string;
-}) {
+type SearchInputProps = {
+  value: string;
+  onChange: (value: string) => void;
+  placeholder: string;
+};
+
+export function SearchInput(props: SearchInputProps): JSX.Element {
packages/thirdweb/src/stories/Bridge/Swap/SelectBuyToken.stories.tsx (2)

19-39: Loading story renders a non-functional “Load More” button

Passing a no-op showMore causes the button to render while loading. Omit it in the loading story.

-export function ChainLoading() {
+export function ChainLoading(): JSX.Element {
@@
-        showMore={() => {}}
         setSearch={() => {}}
       />

42-53: Add explicit return types to stories

Align with explicit return types guideline.

-export function WithData() {
+export function WithData(): JSX.Element {
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SelectChainButton.tsx (3)

13-17: Add explicit return type

-export function SelectChainButton(props: {
+export function SelectChainButton(props: {
   selectedChain: BridgeChain;
   client: ThirdwebClient;
   onClick: () => void;
-}) {
+}): JSX.Element {

19-31: Button semantics and accessibility

Ensure it doesn’t submit forms and is labeled for screen readers.

     <Button
       variant="secondary"
       fullWidth
+      type="button"
+      aria-label="Select chain"
       style={{
         justifyContent: "flex-start",
         fontWeight: 500,
         fontSize: fontSize.md,
         padding: `${spacing.sm} ${spacing.sm}`,
         minHeight: "48px",
       }}

32-39: Alt text and name cleanup

Provide alt text and trim the cleaned name to avoid trailing spaces.

       <Img
         src={props.selectedChain.icon}
         client={props.client}
         width={iconSize.lg}
         height={iconSize.lg}
+        alt={cleanedChainName(props.selectedChain.name).trim()}
       />
-      <span> {cleanedChainName(props.selectedChain.name)} </span>
+      <span> {cleanedChainName(props.selectedChain.name).trim()} </span>
packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx (2)

19-33: Add explicit return type

-export function WithData() {
+export function WithData(): JSX.Element {

35-51: Add explicit return type

-export function Loading() {
+export function Loading(): JSX.Element {
packages/thirdweb/src/stories/Bridge/Swap/SwapWidget.stories.tsx (3)

13-15: Add explicit return type

-export function BasicUsage() {
+export function BasicUsage(): JSX.Element {

17-19: Add explicit return type

-export function CurrencySet() {
+export function CurrencySet(): JSX.Element {

21-23: Add explicit return type

-export function LightMode() {
+export function LightMode(): JSX.Element {
packages/thirdweb/src/react/web/ui/components/Img.tsx (1)

60-66: Remove unused/ineffective flex property

justifyItems has no effect on flex containers.

       style={{
         alignItems: "center",
         display: "inline-flex",
         flexShrink: 0,
-        justifyItems: "center",
         position: "relative",
       }}
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (3)

45-51: Grammar/clarity in Account Abstraction section.

Small wording fixes for correctness and tone.

- * Enable Account abstraction for all wallets. This will connect to the users's smart account based on the connected personal wallet and the given options.
- *
- * This allows to sponsor gas fees for your user's transaction using the thirdweb account abstraction infrastructure.
+ * Enable Account Abstraction for all wallets. This connects to the user's smart account based on the connected personal wallet and the given options.
+ *
+ * This allows you to sponsor gas fees for your user's transactions using thirdweb's Account Abstraction infrastructure.

121-126: Minor grammar: article before “All Wallets”.

-   * By default, ConnectButton modal shows a "All Wallets" button that shows a list of 500+ wallets.
+   * By default, the ConnectButton modal shows an "All Wallets" button that lists 500+ wallets.

129-134: Typo: “Ethererum” → “Ethereum”.

-   * Enable SIWE (Sign in with Ethererum) by passing an object of type `SiweAuthOptions` to
+   * Enable SIWE (Sign in with Ethereum) by passing an object of type `SiweAuthOptions` to
packages/thirdweb/src/stories/Bridge/Swap/SelectSellToken.stories.tsx (1)

25-70: Add explicit return types for story exports.

Keep TSX explicit per repo guidelines.

-export function ChainLoading() {
+export function ChainLoading(): JSX.Element {
   ...
}
-export function Disconnected() {
+export function Disconnected(): JSX.Element {
   ...
}
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsx (3)

19-26: Rename prop type to match component purpose and add return types.

Type name says “BuyToken” but this is a chain selector. Also add explicit return types.

-type SelectBuyTokenProps = {
+type SelectBridgeChainProps = {
   onBack: () => void;
   client: ThirdwebClient;
   onSelectChain: (chain: BridgeChain) => void;
   selectedChain: BridgeChain | undefined;
 };
 
-export function SelectBridgeChain(props: SelectBuyTokenProps) {
+export function SelectBridgeChain(props: SelectBridgeChainProps): JSX.Element {
   ...
 }
 
 export function SelectBridgeChainUI(
-  props: SelectBuyTokenProps & {
+  props: SelectBridgeChainProps & {
     isPending: boolean;
     chains: BridgeChain[];
     onSelectChain: (chain: BridgeChain) => void;
     selectedChain: BridgeChain | undefined;
-  },
-) {
+  },
+): JSX.Element {

Also applies to: 39-46


95-99: Provide keys instead of suppressing lints on skeleton list.

-{props.isPending &&
-  new Array(20).fill(0).map(() => (
-    // biome-ignore lint/correctness/useJsxKeyInIterable: ok
-    <ChainButtonSkeleton />
-  ))}
+{props.isPending &&
+  new Array(20).fill(0).map((_, i) => <ChainButtonSkeleton key={`sk-${i}`} />)}

156-163: Add accessible alt text for chain icons.

-      <Img
+      <Img
         src={props.chain.icon}
         client={props.client}
         width={iconSize.lg}
         height={iconSize.lg}
+        alt={`${cleanedChainName(props.chain.name)} icon`}
       />
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (2)

65-70: Make className optional in SwapWidgetContainer props.

It’s currently required but can be undefined.

-export function SwapWidgetContainer(props: {
-  theme: SwapWidgetProps["theme"];
-  className: string | undefined;
+export function SwapWidgetContainer(props: {
+  theme: SwapWidgetProps["theme"];
+  className?: string;

28-30: Type annotate useActiveWalletInfo() with the exported type.

Improves readability and avoids structural drift.

-import type { SwapWidgetConnectOptions } from "./types.js";
+import type { ActiveWalletInfo, SwapWidgetConnectOptions } from "./types.js";
-function useActiveWalletInfo() {
+function useActiveWalletInfo(): ActiveWalletInfo | undefined {

Also applies to: 266-280

packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx (3)

500-541: Add an accessible label to the switch button control.

-      <SwitchButtonInner
+      <SwitchButtonInner
+        aria-label="Swap selected tokens"
         variant="outline"
         onClick={(e) => {

435-467: Alt text for token/chain images.

-        <Img
+        <Img
           src={props.selectedToken.iconUri || ""}
           client={props.client}
           width={iconSize.lg}
           height={iconSize.lg}
+          alt={`${props.selectedToken.symbol} token icon`}
           style={{
             borderRadius: radius.full,
           }}
         />
...
-            <Img
+            <Img
               src={props.chain.icon}
               client={props.client}
               width={iconSize.sm}
               height={iconSize.sm}
+              alt={`${cleanedChainName(props.chain.name)} icon`}
               style={{
                 borderRadius: radius.full,
               }}
             />

Also applies to: 459-467


50-58: Explicit return types for exported components.

Keep function return types explicit for TSX per guidelines.

-export function SwapUI(props: SwapUIProps) {
+export function SwapUI(props: SwapUIProps): JSX.Element {
-export function SwapUIBase(
+export function SwapUIBase(
   props: SwapUIProps & { onSelectToken: (type: "buy" | "sell") => void },
-)
+) : JSX.Element
-function TokenSection(props: {
+function TokenSection(props: {
   ...
-}) {
+}): JSX.Element {

Also applies to: 98-101, 321-331

packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-buy-token.tsx (4)

34-39: Graceful default chain fallback when preferred chain not present

Defaulting to chainId 1 may return undefined if it’s not in the list. Fallback to first available.

-  return chains.find((chain) => chain.chainId === (activeChainId || 1));
+  return (
+    chains.find((chain) => chain.chainId === (activeChainId || 1)) ??
+    chains[0]
+  );

45-46: Right-size pagination: start smaller and increment predictably

limit=1000 is heavy for initial render. Start smaller and grow linearly to reduce query/render cost.

-  const [limit, setLimit] = useState(1000);
+  const [limit, setLimit] = useState(50);
@@
-        tokensQuery.data?.length === limit
+        tokensQuery.data?.length === limit
           ? () => {
-              setLimit(limit * 2);
+              setLimit(limit + 50);
             }
           : undefined

Also applies to: 95-99


175-183: Address comparison should be case-insensitive

Normalize both addresses to avoid false negatives.

-                    isSelected={props.selectedToken?.address === token.address}
+                    isSelected={
+                      props.selectedToken
+                        ? props.selectedToken.address.toLowerCase() ===
+                          token.address.toLowerCase()
+                        : false
+                    }

197-201: Add keys for skeleton rows

Prevents React diff churn even if lint is suppressed.

-                {props.isPending &&
-                  new Array(20).fill(0).map(() => (
-                    // biome-ignore lint/correctness/useJsxKeyInIterable: ok
-                    <TokenButtonSkeleton />
-                  ))}
+                {props.isPending &&
+                  new Array(20).fill(0).map((_, i) => (
+                    <TokenButtonSkeleton key={i} />
+                  ))}
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-sell-token.tsx (5)

41-46: Graceful default chain fallback when preferred chain not present

Mirror buy-side fix to avoid undefined default when chainId 1 isn’t available.

-  return chains.find((chain) => chain.chainId === (chainId || 1));
+  return (
+    chains.find((chain) => chain.chainId === (chainId || 1)) ?? chains[0]
+  );

247-276: Reuse shared SearchInput to remove duplicated markup

Use the shared SearchInput component for consistency and less DOM noise. Add the import and replace the inline block.

+import { SearchInput } from "./SearchInput.js";
-            <Container px="md">
-              <div
-                style={{
-                  position: "relative",
-                }}
-              >
-                <Container color="secondaryText">
-                  <MagnifyingGlassIcon
-                    width={iconSize.md}
-                    height={iconSize.md}
-                    style={{
-                      position: "absolute",
-                      left: spacing.sm,
-                      top: "50%",
-                      transform: "translateY(-50%)",
-                    }}
-                  />
-                </Container>
-
-                <Input
-                  variant="outline"
-                  placeholder="Search by Token or Address"
-                  value={props.search}
-                  style={{
-                    paddingLeft: "44px",
-                  }}
-                  onChange={(e) => props.setSearch(e.target.value)}
-                />
-              </div>
-            </Container>
+            <Container px="md">
+              <SearchInput
+                value={props.search}
+                onChange={props.setSearch}
+                placeholder="Search by Token or Address"
+              />
+            </Container>

Also applies to: 1-33


470-471: Use locale-aware currency formatting

Improves readability and i18n.

-            {usdValue < 0.01 ? "~$0.00" : `$${usdValue.toFixed(2)}`}
+            {usdValue < 0.01
+              ? "~$0.00"
+              : usdValue.toLocaleString(undefined, {
+                  style: "currency",
+                  currency: "USD",
+                  maximumFractionDigits: 2,
+                })}

281-289: Consider virtualization for long lists

Height-locked, scrollable lists of balances can render many rows; virtualize to keep perf smooth on slower devices.


319-323: Add keys for skeleton rows

Same nit as buy-side.

-                {props.isPending &&
-                  new Array(20).fill(0).map(() => (
-                    // biome-ignore lint/correctness/useJsxKeyInIterable: ok
-                    <TokenButtonSkeleton />
-                  ))}
+                {props.isPending &&
+                  new Array(20).fill(0).map((_, i) => (
+                    <TokenButtonSkeleton key={i} />
+                  ))}
📜 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 c82b606 and 50c1a19.

📒 Files selected for processing (31)
  • packages/thirdweb/package.json (1 hunks)
  • packages/thirdweb/src/bridge/types/Chain.ts (1 hunks)
  • packages/thirdweb/src/pay/convert/type.ts (1 hunks)
  • packages/thirdweb/src/react/core/design-system/index.ts (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/StepRunner.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/UnsupportedTokenScreen.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SearchInput.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SelectChainButton.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-buy-token.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-sell-token.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/utils.ts (1 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/icons/ArrowUpDownIcon.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/components/DynamicHeight.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/components/Img.tsx (5 hunks)
  • packages/thirdweb/src/react/web/ui/components/Skeleton.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/components/Spinner.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/components/basic.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/components/buttons.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/components/formElements.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/components/text.tsx (2 hunks)
  • packages/thirdweb/src/stories/Bridge/Swap/SelectBuyToken.stories.tsx (1 hunks)
  • packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx (1 hunks)
  • packages/thirdweb/src/stories/Bridge/Swap/SelectSellToken.stories.tsx (1 hunks)
  • packages/thirdweb/src/stories/Bridge/Swap/SwapWidget.stories.tsx (1 hunks)
  • packages/thirdweb/src/stories/BuyWidget.stories.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each 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
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • packages/thirdweb/src/react/web/ui/components/Spinner.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/utils.ts
  • packages/thirdweb/src/react/web/ui/components/DynamicHeight.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SelectChainButton.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/UnsupportedTokenScreen.tsx
  • packages/thirdweb/src/react/web/ui/components/text.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
  • packages/thirdweb/src/react/web/ui/ConnectWallet/icons/ArrowUpDownIcon.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectBuyToken.stories.tsx
  • packages/thirdweb/src/react/web/ui/components/basic.tsx
  • packages/thirdweb/src/react/web/ui/components/Img.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/StepRunner.tsx
  • packages/thirdweb/src/react/core/design-system/index.ts
  • packages/thirdweb/src/bridge/types/Chain.ts
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts
  • packages/thirdweb/src/stories/Bridge/Swap/SwapWidget.stories.tsx
  • packages/thirdweb/src/stories/BuyWidget.stories.tsx
  • packages/thirdweb/src/react/web/ui/components/formElements.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SearchInput.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectSellToken.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-sell-token.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-buy-token.tsx
  • packages/thirdweb/src/pay/convert/type.ts
  • packages/thirdweb/src/react/web/ui/components/buttons.tsx
  • packages/thirdweb/src/react/web/ui/components/Skeleton.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/react/web/ui/components/Spinner.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/utils.ts
  • packages/thirdweb/src/react/web/ui/components/DynamicHeight.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SelectChainButton.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/UnsupportedTokenScreen.tsx
  • packages/thirdweb/src/react/web/ui/components/text.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
  • packages/thirdweb/src/react/web/ui/ConnectWallet/icons/ArrowUpDownIcon.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectBuyToken.stories.tsx
  • packages/thirdweb/src/react/web/ui/components/basic.tsx
  • packages/thirdweb/src/react/web/ui/components/Img.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/StepRunner.tsx
  • packages/thirdweb/src/react/core/design-system/index.ts
  • packages/thirdweb/src/bridge/types/Chain.ts
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts
  • packages/thirdweb/src/stories/Bridge/Swap/SwapWidget.stories.tsx
  • packages/thirdweb/src/stories/BuyWidget.stories.tsx
  • packages/thirdweb/src/react/web/ui/components/formElements.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SearchInput.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectSellToken.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-sell-token.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-buy-token.tsx
  • packages/thirdweb/src/pay/convert/type.ts
  • packages/thirdweb/src/react/web/ui/components/buttons.tsx
  • packages/thirdweb/src/react/web/ui/components/Skeleton.tsx
packages/thirdweb/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling @example and a custom tag (@beta, @internal, @experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g., const { jsPDF } = await import("jspdf"))

Files:

  • packages/thirdweb/src/react/web/ui/components/Spinner.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/utils.ts
  • packages/thirdweb/src/react/web/ui/components/DynamicHeight.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SelectChainButton.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/UnsupportedTokenScreen.tsx
  • packages/thirdweb/src/react/web/ui/components/text.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
  • packages/thirdweb/src/react/web/ui/ConnectWallet/icons/ArrowUpDownIcon.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectBuyToken.stories.tsx
  • packages/thirdweb/src/react/web/ui/components/basic.tsx
  • packages/thirdweb/src/react/web/ui/components/Img.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/StepRunner.tsx
  • packages/thirdweb/src/react/core/design-system/index.ts
  • packages/thirdweb/src/bridge/types/Chain.ts
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts
  • packages/thirdweb/src/stories/Bridge/Swap/SwapWidget.stories.tsx
  • packages/thirdweb/src/stories/BuyWidget.stories.tsx
  • packages/thirdweb/src/react/web/ui/components/formElements.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SearchInput.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectSellToken.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-sell-token.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-buy-token.tsx
  • packages/thirdweb/src/pay/convert/type.ts
  • packages/thirdweb/src/react/web/ui/components/buttons.tsx
  • packages/thirdweb/src/react/web/ui/components/Skeleton.tsx
**/*.stories.tsx

📄 CodeRabbit inference engine (CLAUDE.md)

For new UI components, add Storybook stories (*.stories.tsx) alongside the code

Files:

  • packages/thirdweb/src/stories/Bridge/Swap/SelectBuyToken.stories.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SwapWidget.stories.tsx
  • packages/thirdweb/src/stories/BuyWidget.stories.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectSellToken.stories.tsx
**/types.ts

📄 CodeRabbit inference engine (AGENTS.md)

Provide and re‑use local type barrels in a types.ts file

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts
**/package.json

📄 CodeRabbit inference engine (AGENTS.md)

Track bundle budgets via package.json#size-limit

Files:

  • packages/thirdweb/package.json
🧠 Learnings (16)
📓 Common learnings
Learnt from: CR
PR: thirdweb-dev/js#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:37:38.513Z
Learning: Pull‑request titles must start with the affected workspace in brackets (e.g., [SDK], [Dashboard], [Portal], [Playground])
📚 Learning: 2025-07-02T20:04:53.982Z
Learnt from: MananTank
PR: thirdweb-dev/js#7505
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/components/webhook-metrics.tsx:40-40
Timestamp: 2025-07-02T20:04:53.982Z
Learning: The Spinner component imported from "@/components/ui/Spinner/Spinner" in the dashboard accepts a className prop, not a size prop. The correct usage is <Spinner className="size-4" />, not <Spinner size="sm" />. The component defaults to "size-4" if no className is provided.

Applied to files:

  • packages/thirdweb/src/react/web/ui/components/Spinner.tsx
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Anything that consumes hooks from `tanstack/react-query` or thirdweb SDKs.

Applied to files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
  • packages/thirdweb/src/react/web/ui/components/Img.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Interactive UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks).

Applied to files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
  • packages/thirdweb/src/react/web/ui/components/Img.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Use React Query (`tanstack/react-query`) for all client data fetching.

Applied to files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
📚 Learning: 2025-07-07T21:21:47.488Z
Learnt from: saminacodes
PR: thirdweb-dev/js#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:

  • packages/thirdweb/src/react/web/ui/ConnectWallet/icons/ArrowUpDownIcon.tsx
📚 Learning: 2025-08-29T15:37:38.513Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:37:38.513Z
Learning: Applies to apps/{dashboard,playground}/**/*.stories.tsx : Add Storybook stories (`*.stories.tsx`) alongside new UI components

Applied to files:

  • packages/thirdweb/src/stories/Bridge/Swap/SelectBuyToken.stories.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SwapWidget.stories.tsx
  • packages/thirdweb/src/stories/BuyWidget.stories.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectSellToken.stories.tsx
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to **/*.stories.tsx : For new UI components, add Storybook stories (`*.stories.tsx`) alongside the code

Applied to files:

  • packages/thirdweb/src/stories/Bridge/Swap/SelectBuyToken.stories.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SwapWidget.stories.tsx
  • packages/thirdweb/src/stories/BuyWidget.stories.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SelectSellToken.stories.tsx
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/components/*.{stories,test}.{tsx,ts} : Provide a Storybook story (`MyComponent.stories.tsx`) or unit test alongside the component.

Applied to files:

  • packages/thirdweb/src/stories/Bridge/Swap/SelectBuyToken.stories.tsx
  • packages/thirdweb/src/stories/Bridge/Swap/SwapWidget.stories.tsx
  • packages/thirdweb/src/stories/BuyWidget.stories.tsx
📚 Learning: 2025-05-29T10:49:52.981Z
Learnt from: MananTank
PR: thirdweb-dev/js#7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_components/ContractHeader.tsx:26-43
Timestamp: 2025-05-29T10:49:52.981Z
Learning: In React image components, conditional rendering of the entire image container (e.g., `{props.image && <Img />}`) serves a different purpose than fallback handling. The conditional prevents rendering any image UI when no image metadata exists, while the fallback prop handles cases where image metadata exists but the image fails to load. This pattern is intentional to distinguish between "no image intended" vs "image intended but failed to load".

Applied to files:

  • packages/thirdweb/src/react/web/ui/components/Img.tsx
📚 Learning: 2025-08-09T15:37:30.990Z
Learnt from: MananTank
PR: thirdweb-dev/js#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:

  • packages/thirdweb/src/react/web/ui/components/Img.tsx
📚 Learning: 2025-06-17T18:30:52.976Z
Learnt from: MananTank
PR: thirdweb-dev/js#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:

  • packages/thirdweb/src/react/web/ui/components/Img.tsx
📚 Learning: 2025-08-29T15:37:38.513Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:37:38.513Z
Learning: Applies to **/*.test.{ts,tsx} : Keep tests deterministic and side‑effect free; use Vitest

Applied to files:

  • packages/thirdweb/package.json
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to **/*.test.{ts,tsx} : Keep tests deterministic and side-effect free

Applied to files:

  • packages/thirdweb/package.json
📚 Learning: 2025-06-26T19:46:04.024Z
Learnt from: gregfromstl
PR: thirdweb-dev/js#7450
File: packages/thirdweb/src/bridge/Webhook.ts:57-81
Timestamp: 2025-06-26T19:46:04.024Z
Learning: In the onramp webhook schema (`packages/thirdweb/src/bridge/Webhook.ts`), the `currencyAmount` field is intentionally typed as `z.number()` while other amount fields use `z.string()` because `currencyAmount` represents fiat currency amounts in decimals (like $10.50), whereas other amount fields represent token amounts in wei (very large integers that benefit from bigint representation). The different naming convention (`currencyAmount` vs `amount`) reflects this intentional distinction.

Applied to files:

  • packages/thirdweb/src/pay/convert/type.ts
📚 Learning: 2025-08-28T19:32:53.229Z
Learnt from: MananTank
PR: thirdweb-dev/js#7939
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/_common/step-card.tsx:50-60
Timestamp: 2025-08-28T19:32:53.229Z
Learning: The Button component in packages/ui/src/components/button.tsx has type="button" as the default when no type prop is explicitly provided. This means explicitly adding type="button" to Button components is redundant unless a different type (like "submit") is specifically needed.

Applied to files:

  • packages/thirdweb/src/react/web/ui/components/buttons.tsx
🧬 Code graph analysis (17)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SelectChainButton.tsx (5)
packages/thirdweb/src/bridge/types/Chain.ts (1)
  • BridgeChain (42-42)
packages/thirdweb/src/react/web/ui/components/buttons.tsx (1)
  • Button (26-157)
packages/thirdweb/src/react/core/design-system/index.ts (3)
  • fontSize (164-172)
  • spacing (174-185)
  • iconSize (197-206)
packages/thirdweb/src/react/web/ui/components/Img.tsx (1)
  • Img (12-126)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/utils.ts (1)
  • cleanedChainName (1-3)
packages/thirdweb/src/stories/Bridge/Swap/SelectBuyToken.stories.tsx (4)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-buy-token.tsx (2)
  • SelectBuyTokenUI (105-240)
  • SelectBuyToken (41-103)
packages/thirdweb/src/bridge/types/Chain.ts (1)
  • BridgeChain (42-42)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (1)
  • SwapWidgetContainer (65-84)
packages/thirdweb/src/stories/utils.tsx (1)
  • storyClient (15-17)
packages/thirdweb/src/react/web/ui/components/Img.tsx (3)
packages/thirdweb/src/react/web/ui/components/Skeleton.tsx (1)
  • Skeleton (10-28)
packages/thirdweb/src/react/web/ui/components/basic.tsx (1)
  • Container (77-178)
packages/thirdweb/src/react/core/design-system/index.ts (1)
  • radius (187-195)
packages/thirdweb/src/stories/Bridge/Swap/SelectChain.stories.tsx (4)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsx (2)
  • SelectBridgeChain (26-37)
  • SelectBridgeChainUI (39-118)
packages/thirdweb/src/bridge/types/Chain.ts (1)
  • BridgeChain (42-42)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (1)
  • SwapWidgetContainer (65-84)
packages/thirdweb/src/stories/utils.tsx (1)
  • storyClient (15-17)
packages/thirdweb/src/react/web/ui/Bridge/StepRunner.tsx (1)
packages/thirdweb/src/react/web/ui/components/text.tsx (1)
  • Text (18-34)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (2)
packages/thirdweb/src/wallets/types.ts (1)
  • AppMetadata (3-20)
packages/thirdweb/src/bridge/types/Chain.ts (1)
  • Chain (5-40)
packages/thirdweb/src/stories/Bridge/Swap/SwapWidget.stories.tsx (2)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (1)
  • SwapWidget (45-63)
packages/thirdweb/src/stories/utils.tsx (1)
  • storyClient (15-17)
packages/thirdweb/src/stories/BuyWidget.stories.tsx (1)
packages/thirdweb/src/stories/utils.tsx (1)
  • storyClient (15-17)
packages/thirdweb/src/react/web/ui/components/formElements.tsx (1)
packages/thirdweb/src/react/core/design-system/index.ts (1)
  • Theme (49-96)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx (15)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (2)
  • ActiveWalletInfo (137-141)
  • SwapWidgetConnectOptions (25-135)
packages/thirdweb/src/react/core/design-system/index.ts (5)
  • Theme (49-96)
  • radius (187-195)
  • fontSize (164-172)
  • spacing (174-185)
  • iconSize (197-206)
packages/thirdweb/src/pay/convert/type.ts (2)
  • SupportedFiatCurrency (27-27)
  • getFiatSymbol (29-34)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-buy-token.tsx (1)
  • SelectBuyToken (41-103)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-sell-token.tsx (1)
  • SelectSellToken (48-67)
packages/thirdweb/src/exports/utils.ts (2)
  • toUnits (39-39)
  • toTokens (39-39)
packages/thirdweb/src/react/web/ui/components/basic.tsx (1)
  • Container (77-178)
packages/thirdweb/src/react/web/ui/components/buttons.tsx (1)
  • Button (26-157)
packages/thirdweb/src/react/web/ui/components/formElements.tsx (1)
  • Input (36-106)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1)
  • useBridgeChains (5-12)
packages/thirdweb/src/react/web/ui/components/text.tsx (1)
  • Text (18-34)
packages/thirdweb/src/react/web/ui/components/Skeleton.tsx (1)
  • Skeleton (10-28)
packages/thirdweb/src/react/web/ui/components/Img.tsx (1)
  • Img (12-126)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/utils.ts (1)
  • cleanedChainName (1-3)
packages/thirdweb/src/react/web/ui/ConnectWallet/icons/ArrowUpDownIcon.tsx (1)
  • ArrowUpDownIcon (3-23)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts (1)
packages/thirdweb/src/exports/utils.ts (1)
  • isAddress (148-148)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SearchInput.tsx (3)
packages/thirdweb/src/react/web/ui/components/basic.tsx (1)
  • Container (77-178)
packages/thirdweb/src/react/core/design-system/index.ts (2)
  • iconSize (197-206)
  • spacing (174-185)
packages/thirdweb/src/react/web/ui/components/formElements.tsx (1)
  • Input (36-106)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-chain.tsx (10)
packages/thirdweb/src/bridge/types/Chain.ts (1)
  • BridgeChain (42-42)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1)
  • useBridgeChains (5-12)
packages/thirdweb/src/react/web/ui/components/basic.tsx (3)
  • Container (77-178)
  • ModalHeader (35-65)
  • Line (67-72)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SearchInput.tsx (1)
  • SearchInput (6-41)
packages/thirdweb/src/react/core/design-system/index.ts (3)
  • spacing (174-185)
  • iconSize (197-206)
  • fontSize (164-172)
packages/thirdweb/src/react/web/ui/components/text.tsx (1)
  • Text (18-34)
packages/thirdweb/src/react/web/ui/components/Skeleton.tsx (1)
  • Skeleton (10-28)
packages/thirdweb/src/react/web/ui/components/buttons.tsx (1)
  • Button (26-157)
packages/thirdweb/src/react/web/ui/components/Img.tsx (1)
  • Img (12-126)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/utils.ts (1)
  • cleanedChainName (1-3)
packages/thirdweb/src/stories/Bridge/Swap/SelectSellToken.stories.tsx (4)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-sell-token.tsx (3)
  • SelectSellToken (48-67)
  • SelectSellTokenConnectedUI (190-362)
  • SelectSellTokenDisconnectedUI (69-120)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • ActiveWalletInfo (137-141)
packages/thirdweb/src/stories/utils.tsx (1)
  • storyClient (15-17)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (1)
  • SwapWidgetContainer (65-84)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-sell-token.tsx (12)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • ActiveWalletInfo (137-141)
packages/thirdweb/src/react/web/ui/components/basic.tsx (3)
  • Container (77-178)
  • ModalHeader (35-65)
  • Line (67-72)
packages/thirdweb/src/react/core/design-system/index.ts (4)
  • radius (187-195)
  • iconSize (197-206)
  • spacing (174-185)
  • fontSize (164-172)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1)
  • useBridgeChains (5-12)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts (2)
  • useTokenBalances (71-115)
  • TokenBalance (39-57)
packages/thirdweb/src/react/web/ui/components/Spinner.tsx (1)
  • Spinner (11-36)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SelectChainButton.tsx (1)
  • SelectChainButton (13-47)
packages/thirdweb/src/react/web/ui/components/formElements.tsx (1)
  • Input (36-106)
packages/thirdweb/src/react/web/ui/components/buttons.tsx (1)
  • Button (26-157)
packages/thirdweb/src/pay/convert/get-token.ts (1)
  • getToken (6-37)
packages/thirdweb/src/react/web/ui/components/Img.tsx (1)
  • Img (12-126)
packages/thirdweb/src/react/web/ui/components/Skeleton.tsx (1)
  • Skeleton (10-28)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (15)
packages/thirdweb/src/react/core/design-system/index.ts (1)
  • Theme (49-96)
packages/thirdweb/src/pay/convert/type.ts (1)
  • SupportedFiatCurrency (27-27)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • SwapWidgetConnectOptions (25-135)
packages/thirdweb/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx (1)
  • EmbedContainer (441-466)
packages/thirdweb/src/react/web/ui/components/DynamicHeight.tsx (1)
  • DynamicHeight (8-33)
packages/thirdweb/src/react/core/hooks/useBridgePrepare.ts (2)
  • BridgePrepareResult (23-27)
  • BridgePrepareRequest (14-18)
packages/thirdweb/src/react/web/ui/ConnectWallet/locale/getConnectLocale.ts (1)
  • useConnectLocale (45-54)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1)
  • useBridgeChains (5-12)
packages/thirdweb/src/react/web/ui/components/Spinner.tsx (1)
  • Spinner (11-36)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx (1)
  • SwapUI (50-96)
packages/thirdweb/src/react/web/ui/Bridge/QuoteLoader.tsx (1)
  • QuoteLoader (87-173)
packages/thirdweb/src/exports/utils.ts (1)
  • toTokens (39-39)
packages/thirdweb/src/react/web/ui/Bridge/payment-details/PaymentDetails.tsx (1)
  • PaymentDetails (57-398)
packages/thirdweb/src/react/web/ui/Bridge/StepRunner.tsx (1)
  • StepRunner (66-404)
packages/thirdweb/src/react/web/adapters/WindowAdapter.ts (1)
  • webWindowAdapter (23-23)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-buy-token.tsx (13)
packages/thirdweb/src/bridge/types/Chain.ts (1)
  • BridgeChain (42-42)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1)
  • useBridgeChains (5-12)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts (1)
  • useTokens (7-37)
packages/thirdweb/src/react/web/ui/components/basic.tsx (3)
  • Container (77-178)
  • ModalHeader (35-65)
  • Line (67-72)
packages/thirdweb/src/react/web/ui/components/Spinner.tsx (1)
  • Spinner (11-36)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SelectChainButton.tsx (1)
  • SelectChainButton (13-47)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SearchInput.tsx (1)
  • SearchInput (6-41)
packages/thirdweb/src/react/core/design-system/index.ts (4)
  • radius (187-195)
  • spacing (174-185)
  • fontSize (164-172)
  • iconSize (197-206)
packages/thirdweb/src/react/web/ui/components/buttons.tsx (1)
  • Button (26-157)
packages/thirdweb/src/react/web/ui/components/text.tsx (1)
  • Text (18-34)
packages/thirdweb/src/pay/convert/get-token.ts (1)
  • getToken (6-37)
packages/thirdweb/src/react/web/ui/components/Img.tsx (1)
  • Img (12-126)
packages/thirdweb/src/react/web/ui/components/Skeleton.tsx (1)
  • Skeleton (10-28)
🪛 Gitleaks (8.27.2)
packages/thirdweb/src/stories/BuyWidget.stories.tsx

[high] 31-31: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ 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). (9)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: Analyze (javascript)

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

♻️ Duplicate comments (2)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (2)

159-229: Add the required custom TSDoc tag to the public SwapWidget.

Public symbols under packages/thirdweb must include a custom tag (e.g., @beta). Keep return type as-is per maintainer preference.

 /**
  * A widget for swapping tokens with cross-chain support
+ * @beta
  *
  * @param props - Props of type [`SwapWidgetProps`](https://portal.thirdweb.com/references/typescript/v5/SwapWidgetProps) to configure the SwapWidget component.

396-407: Bug: assigning prepared result where a Quote is required.

screen.quote expects Buy.quote.Result | Sell.quote.Result but data.result is a prepared result. PaymentDetails receives quote: screen.quote, so this is a type/shape mismatch.

Apply this change here:

           setScreen({
             id: "2:preview",
             buyToken: data.buyToken,
             sellToken: data.sellToken,
             sellTokenBalance: data.sellTokenBalance,
             mode: data.mode,
             preparedQuote: data.result,
             request: data.request,
-            quote: data.result,
+            quote: data.quote,
           });

And plumb the non‑prepared quote from SwapUI:

  • In swap-ui.tsx, extend the onSwap payload to include quote: Buy.quote.Result | Sell.quote.Result.
  • In the preparedResult branch of useSwapQuote, return the associated quote (if not already available, fetch/retain it alongside prepare).

If the prepared payload already includes a quote field, pass that through instead of re-fetching.

🧹 Nitpick comments (3)
apps/dashboard/src/@/analytics/report.ts (1)

331-341: Fix JSDoc for “cancelled” event (not an error case).

Second bullet references errors; adjust to reflect cancellations.

- * - To track number of cancelled asset purchases from the token page
- * - To track the errors that users encounter when trying to purchase an asset
+ * - To track number of cancelled asset purchases from the token page
+ * - To understand where/when users abandon the purchase flow
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (2)

355-359: LocalStorage persistence: safe but noisy when both tokens are undefined.

setLastUsedTokens({ buyToken, sellToken }) is called even when both are undefined; the schema likely rejects and no-ops. Optional: guard to skip writes when both unset to avoid unnecessary work.

 useEffect(() => {
-  setLastUsedTokens({ buyToken, sellToken });
+  if (buyToken || sellToken) {
+    setLastUsedTokens({ buyToken, sellToken });
+  }
 }, [buyToken, sellToken]);

488-496: Open TODO: clarify hasPaymentId.

Either expose as a prop or remove the TODO if not needed; leaving TODOs in public surface UI can rot.

📜 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 1405e11 and 43b06e1.

📒 Files selected for processing (4)
  • .changeset/lucky-turtles-smell.md (1 hunks)
  • apps/dashboard/src/@/analytics/report.ts (2 hunks)
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

.changeset/*.md: Each change in packages/* must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API

Files:

  • .changeset/lucky-turtles-smell.md
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each 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
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • apps/dashboard/src/@/analytics/report.ts
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • apps/dashboard/src/@/analytics/report.ts
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
apps/{dashboard,playground-web}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
Use NavLink for internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Use cn() from @/lib/utils for conditional class logic
Use design system tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components (Node edge): Start files with import "server-only";
Client Components (browser): Begin files with 'use client';
Always call getAuthToken() to retrieve JWT from cookies on server side
Use Authorization: Bearer header – never embed tokens in URLs
Return typed results (e.g., Project[], User[]) – avoid any
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stable queryKeys for React Query cache hits
Configure staleTime/cacheTime in React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never import posthog-js in server components

Files:

  • apps/dashboard/src/@/analytics/report.ts
apps/{dashboard,playground}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/{dashboard,playground}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/_ (e.g., Button, Input, Tabs, Card)
Use NavLink for internal navigation to get active state handling
Use Tailwind CSS for styling; no inline styles
Merge class names with cn() from @/lib/utils for conditional classes
Stick to design tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components must start with import "server-only"; use next/headers, server‑only env, heavy data fetching, and redirect() where appropriate
Client Components must start with 'use client'; handle interactivity with hooks and browser APIs
Server-side data fetching: call getAuthToken() from cookies, send Authorization: Bearer <token> header, and return typed results (avoid any)
Client-side data fetching: wrap calls in React Query with descriptive, stable queryKeys and set sensible staleTime/cacheTime (≥ 60s default); keep tokens secret via internal routes or server actions
Do not import posthog-js in server components (client-side only)

Files:

  • apps/dashboard/src/@/analytics/report.ts
apps/{dashboard,playground}/src/@/analytics/report.ts

📄 CodeRabbit inference engine (AGENTS.md)

apps/{dashboard,playground}/src/@/analytics/report.ts: Check report.ts before adding a new analytics event to avoid duplicates
Analytics naming: event name as <subject> <verb>; helper function as report<Subject><Verb> (PascalCase)
Each analytics helper must include a JSDoc header (Why/Owner), accept a single typed properties object, and forward it unchanged to posthog.capture

Files:

  • apps/dashboard/src/@/analytics/report.ts
packages/thirdweb/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling @example and a custom tag (@beta, @internal, @experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g., const { jsPDF } = await import("jspdf"))

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
🧠 Learnings (11)
📚 Learning: 2025-05-30T17:14:25.332Z
Learnt from: MananTank
PR: thirdweb-dev/js#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:

  • .changeset/lucky-turtles-smell.md
📚 Learning: 2025-08-29T15:37:38.513Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:37:38.513Z
Learning: Applies to apps/{dashboard,playground}/src/@/analytics/report.ts : Analytics naming: event name as `<subject> <verb>`; helper function as `report<Subject><Verb>` (PascalCase)

Applied to files:

  • apps/dashboard/src/@/analytics/report.ts
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to src/@/analytics/report.ts : Analytics event name: human-readable `<subject> <verb>` (e.g., "contract deployed"); function: `report<Subject><Verb>` (PascalCase)

Applied to files:

  • apps/dashboard/src/@/analytics/report.ts
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to src/@/analytics/report.ts : Review `src/@/analytics/report.ts` before adding analytics events to check for duplicates

Applied to files:

  • apps/dashboard/src/@/analytics/report.ts
📚 Learning: 2025-08-29T15:37:38.513Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:37:38.513Z
Learning: Applies to apps/{dashboard,playground}/src/@/analytics/report.ts : Check `report.ts` before adding a new analytics event to avoid duplicates

Applied to files:

  • apps/dashboard/src/@/analytics/report.ts
📚 Learning: 2025-08-29T15:37:38.513Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:37:38.513Z
Learning: Applies to apps/{dashboard,playground}/src/@/analytics/report.ts : Each analytics helper must include a JSDoc header (Why/Owner), accept a single typed `properties` object, and forward it unchanged to `posthog.capture`

Applied to files:

  • apps/dashboard/src/@/analytics/report.ts
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/src/@/analytics/report.ts : Mandatory JSDoc: explain Why the event exists and Who owns it (`username`).

Applied to files:

  • apps/dashboard/src/@/analytics/report.ts
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Interactive UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks).

Applied to files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
📚 Learning: 2025-08-29T15:37:38.513Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:37:38.513Z
Learning: Applies to packages/thirdweb/**/*.{ts,tsx} : Every public symbol must have comprehensive TSDoc with at least one compiling `example` and a custom tag (`beta`, `internal`, `experimental`, etc.)

Applied to files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/exports/** : Every public symbol must have comprehensive TSDoc with at least one `example` block that compiles and custom annotation tags (`beta`, `internal`, `experimental`)

Applied to files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
📚 Learning: 2025-09-03T23:35:50.476Z
Learnt from: MananTank
PR: thirdweb-dev/js#7977
File: apps/playground-web/src/app/page.tsx:61-65
Timestamp: 2025-09-03T23:35:50.476Z
Learning: In the thirdweb-dev/js codebase, specifically for React components in **/*.{ts,tsx} files, do not suggest adding explicit return types like `: JSX.Element` or `: React.ReactElement` to function components. The project maintainer MananTank has explicitly declined these suggestions.

Applied to files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
🧬 Code graph analysis (1)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (13)
packages/thirdweb/src/react/core/design-system/index.ts (1)
  • Theme (49-96)
packages/thirdweb/src/pay/convert/type.ts (1)
  • SupportedFiatCurrency (27-27)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (3)
  • SwapWidgetConnectOptions (26-135)
  • SwapPreparedQuote (154-157)
  • TokenSelection (149-152)
packages/thirdweb/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx (1)
  • EmbedContainer (441-466)
packages/thirdweb/src/react/web/ui/components/DynamicHeight.tsx (1)
  • DynamicHeight (8-33)
packages/thirdweb/src/react/core/hooks/useBridgePrepare.ts (1)
  • BridgePrepareRequest (14-18)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
  • CompletedStatusResult (25-32)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/hooks.ts (1)
  • useActiveWalletInfo (7-21)
packages/thirdweb/src/exports/utils.ts (1)
  • getAddress (147-147)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/storage.ts (2)
  • getLastUsedTokens (23-41)
  • setLastUsedTokens (43-56)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1)
  • useBridgeChains (5-14)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx (1)
  • SwapUI (112-406)
packages/thirdweb/src/react/web/adapters/WindowAdapter.ts (1)
  • webWindowAdapter (23-23)
⏰ 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). (1)
  • GitHub Check: Unit Tests
🔇 Additional comments (3)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (1)

446-468: Callback wiring looks correct.

onCancel/onComplete forward to external callbacks and drive screen transitions as expected.

apps/dashboard/src/@/analytics/report.ts (2)

261-299: Approve — naming follows " " and helpers accept a single typed object; no duplicate events found. Repo search returns only the captures in apps/dashboard/src/@/analytics/report.ts.


253-260: Type looks good; confirm upstream normalization of addresses.

TokenSwapParams is declared in apps/dashboard/src/@/analytics/report.ts; repo search found no call sites that normalize buyTokenAddress/sellTokenAddress — verify callers send EIP‑55 checksummed or consistently lower‑cased addresses to avoid analytics cardinality explosions. If normalization is done here, normalize a copy (do not mutate the original) and document the exception to the "forward unchanged" guideline.

@vercel vercel bot temporarily deployed to Preview – thirdweb-www September 17, 2025 16:09 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 September 17, 2025 16:09 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula September 17, 2025 16:09 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui September 17, 2025 16:09 Inactive
@github-actions github-actions bot added the Playground Changes involving the Playground codebase. label Sep 17, 2025
@MananTank MananTank changed the title SDK: Add SwapWidget SDK: Add SwapWidget, add in dashboard, BuyWidget UI improvements Sep 17, 2025
@MananTank MananTank changed the title SDK: Add SwapWidget, add in dashboard, BuyWidget UI improvements Add SwapWidget in SDK, add in dashboard, BuyWidget UI improvements Sep 17, 2025
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/payments/components/types.ts (1)

41-45: Prefer optional properties over string | undefined

Use ? for optional fields; it’s clearer and avoids explicit undefined unions.

-    title: string | undefined;
-    image: string | undefined;
-    description: string | undefined;
-    buttonLabel: string | undefined;
+    title?: string;
+    image?: string;
+    description?: string;
+    buttonLabel?: string;
apps/playground-web/src/app/payments/components/LeftSection.tsx (2)

153-161: Replace unsafe type assertion with a small runtime guard (and single source of truth).

Casting value as SupportedFiatCurrency trusts uncontrolled input from the Select. Add a whitelist guard to avoid impossible states and keep types honest.

Apply this diff to the handler:

-              onValueChange={(value) => {
-                setOptions((v) => ({
-                  ...v,
-                  payOptions: {
-                    ...v.payOptions,
-                    currency: value as SupportedFiatCurrency,
-                  },
-                }));
-              }}
+              onValueChange={(value) => {
+                if (!SUPPORTED_CURRENCIES.has(value as SupportedFiatCurrency)) {
+                  console.warn("Unsupported currency:", value);
+                  return;
+                }
+                setOptions((v) => ({
+                  ...v,
+                  payOptions: {
+                    ...v.payOptions,
+                    currency: value as SupportedFiatCurrency,
+                  },
+                }));
+              }}

Add this near the imports to define an explicit, typed set (keeps JSX list and validation in sync):

// Single source of truth for allowed currencies in this UI:
const SUPPORTED_CURRENCIES = new Set<SupportedFiatCurrency>([
  "USD","EUR","GBP","JPY","KRW","CNY","INR","NOK","SEK","CHF","AUD","CAD",
  "NZD","MXN","BRL","CLP","CZK","DKK","HKD","HUF","IDR","ILS","ISK",
]);

35-41: Add explicit return type to the component to match repo TypeScript guidelines.

Declare : JSX.Element on the component definition.

-export function LeftSection(props: {
+export function LeftSection(props: {
   options: BridgeComponentsPlaygroundOptions;
   setOptions: React.Dispatch<
     React.SetStateAction<BridgeComponentsPlaygroundOptions>
   >;
   lockedWidget?: "buy" | "checkout" | "transaction";
-}) {
+}): JSX.Element {
📜 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 43b06e1 and d87c23b.

📒 Files selected for processing (2)
  • apps/playground-web/src/app/payments/components/LeftSection.tsx (2 hunks)
  • apps/playground-web/src/app/payments/components/types.ts (1 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 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
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • apps/playground-web/src/app/payments/components/LeftSection.tsx
  • apps/playground-web/src/app/payments/components/types.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • apps/playground-web/src/app/payments/components/LeftSection.tsx
  • apps/playground-web/src/app/payments/components/types.ts
apps/{dashboard,playground-web}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
Use NavLink for internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Use cn() from @/lib/utils for conditional class logic
Use design system tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components (Node edge): Start files with import "server-only";
Client Components (browser): Begin files with 'use client';
Always call getAuthToken() to retrieve JWT from cookies on server side
Use Authorization: Bearer header – never embed tokens in URLs
Return typed results (e.g., Project[], User[]) – avoid any
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stable queryKeys for React Query cache hits
Configure staleTime/cacheTime in React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never import posthog-js in server components

Files:

  • apps/playground-web/src/app/payments/components/LeftSection.tsx
  • apps/playground-web/src/app/payments/components/types.ts
**/types.ts

📄 CodeRabbit inference engine (AGENTS.md)

Provide and re‑use local type barrels in a types.ts file

Files:

  • apps/playground-web/src/app/payments/components/types.ts
🧠 Learnings (1)
📚 Learning: 2025-06-26T19:46:04.024Z
Learnt from: gregfromstl
PR: thirdweb-dev/js#7450
File: packages/thirdweb/src/bridge/Webhook.ts:57-81
Timestamp: 2025-06-26T19:46:04.024Z
Learning: In the onramp webhook schema (`packages/thirdweb/src/bridge/Webhook.ts`), the `currencyAmount` field is intentionally typed as `z.number()` while other amount fields use `z.string()` because `currencyAmount` represents fiat currency amounts in decimals (like $10.50), whereas other amount fields represent token amounts in wei (very large integers that benefit from bigint representation). The different naming convention (`currencyAmount` vs `amount`) reflects this intentional distinction.

Applied to files:

  • apps/playground-web/src/app/payments/components/types.ts
🧬 Code graph analysis (2)
apps/playground-web/src/app/payments/components/LeftSection.tsx (1)
packages/thirdweb/src/pay/convert/type.ts (1)
  • SupportedFiatCurrency (27-27)
apps/playground-web/src/app/payments/components/types.ts (1)
packages/thirdweb/src/pay/convert/type.ts (1)
  • SupportedFiatCurrency (27-27)
⏰ 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: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
apps/playground-web/src/app/payments/components/types.ts (2)

31-31: LGTM: safer currency typing

Narrowing to the literal union improves type safety in the playground.


5-31: De-duplicate currency semantics — reuse the canonical SupportedFiatCurrency

Replace the local CURRENCIES/type with the package's canonical SupportedFiatCurrency to avoid drift.

Apply:

@@
 import type { ThemeOverrides } from "thirdweb/react";
 import type { Address } from "thirdweb/utils";
+import type { SupportedFiatCurrency as TWSupportedFiatCurrency } from "thirdweb/pay/convert/type";
@@
-type SupportedFiatCurrency = (typeof CURRENCIES)[number];
+type SupportedFiatCurrency = TWSupportedFiatCurrency;

Canonical export is at packages/thirdweb/src/pay/convert/type.ts — verify the import path and adjust if it's re-exported under a different public path.

apps/playground-web/src/app/payments/components/LeftSection.tsx (1)

30-30: Don't deep‑import types from dist — use the public pay export

SupportedFiatCurrency is declared at packages/thirdweb/src/pay/convert/type.ts and packages/thirdweb/package.json includes a "./pay" export, but I couldn't find a public re‑export of SupportedFiatCurrency in source.

  • If thirdweb/pay already exports it: replace the deep import with import type { SupportedFiatCurrency } from "thirdweb/pay";
  • If not: re‑export SupportedFiatCurrency from the pay public entry (e.g., packages/thirdweb/src/pay/index.ts or packages/thirdweb/src/exports/pay.ts) and then switch this import.

Copy link
Member Author

MananTank commented Sep 17, 2025


How to use the Graphite Merge Queue

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

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

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@joaquim-verges joaquim-verges merged commit 0e3f346 into main Sep 17, 2025
28 of 30 checks passed
@joaquim-verges joaquim-verges deleted the mnn/swap-ui branch September 17, 2025 19:58
@joaquim-verges joaquim-verges mentioned this pull request Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dashboard Involves changes to the Dashboard. packages Playground Changes involving the Playground codebase. SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants