Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Dec 12, 2025


PR-Codex overview

This PR focuses on improving the sorting of chains in the SwapWidget UI by implementing a new sorting logic that places chains with names starting with numbers at the end.

Detailed summary

  • Updated the queryFn in useQuery to be asynchronous.
  • Added a copy of the fetched data for sorting.
  • Implemented custom sorting logic to handle names starting with numbers, placing them at the end of the sorted list.

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

Summary by CodeRabbit

  • New Features

    • Chains in the SwapWidget are now alphabetically sorted for improved navigation; chain names starting with digits are listed after alphabetic entries.
  • Chores

    • Patch release entry added to the changelog.

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

@vercel
Copy link

vercel bot commented Dec 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 Dec 12, 2025 6:45pm
nebula Ready Ready Preview Comment Dec 12, 2025 6:45pm
thirdweb_playground Ready Ready Preview Comment Dec 12, 2025 6:45pm
thirdweb-www Ready Ready Preview Comment Dec 12, 2025 6:45pm
wallet-ui Ready Ready Preview Comment Dec 12, 2025 6:45pm

@linear
Copy link

linear bot commented Dec 12, 2025

@changeset-bot
Copy link

changeset-bot bot commented Dec 12, 2025

🦋 Changeset detected

Latest commit: 31e24f1

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

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

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

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

Walkthrough

Adds a changeset file for a patch release and updates the SwapWidget chain fetch to asynchronously retrieve chains and return them sorted by name, with names starting with digits moved to the end. No exported/public API changes.

Changes

Cohort / File(s) Change Summary
Changeset entry
\.changeset/ninety-trains-tell\.md
New patch release changeset documenting a UI improvement to alphabetically sort chains in the SwapWidget.
Chain sorting logic
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains\.ts
Converted queryFn to async, awaits chains({ client }), creates a shallow copy and sorts chains by name (names starting with digits are moved to the end) before returning. No public API/signature changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Check sorting edge cases: missing/empty name, numeric-leading names, and localeCompare behavior for special/unicode characters.
  • Verify async queryFn integrates correctly with the query system (keys, refetch behavior) and proper error handling/logging.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title '[MNY-331] SDK: Alphabetically sort chains in SwapWidget UI' clearly summarizes the main change - alphabetically sorting chains in the SwapWidget UI component.
Description check ✅ Passed The PR description provides a clear overview of changes including the asynchronous queryFn update, data copying, and custom sorting logic implementation with PR-Codex summary.
Linked Issues check ✅ Passed The code changes fully implement the MNY-331 requirement to alphabetically organize the chain list, with custom sorting logic to place number-starting chains at the end.
Out of Scope Changes check ✅ Passed All changes in use-bridge-chains.ts and the changeset file are directly related to alphabetically sorting chains in the SwapWidget UI, with no extraneous modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mny-331

📜 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 724a4cb and 31e24f1.

📒 Files selected for processing (2)
  • .changeset/ninety-trains-tell.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
  • .changeset/ninety-trains-tell.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). (8)
  • GitHub Check: Build Packages
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Lint Packages
  • GitHub Check: Unit Tests
  • 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.

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

MananTank commented Dec 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.

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

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

🧹 Nitpick comments (1)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1)

5-24: Consider scoping the React Query cache key by client + add an explicit return type.
If ThirdwebClient can vary, a constant queryKey: ["bridge-chains"] risks cache collisions across clients; also the exported hook lacks an explicit return type (per TS guidelines).

📜 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 1169752 and e53e802.

📒 Files selected for processing (2)
  • .changeset/ninety-trains-tell.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.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 TypeScript file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes in TypeScript
Avoid any and unknown in TypeScript unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.) in TypeScript

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity and testability
Re-use shared types from @/types or local types.ts barrel exports
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics whenever possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic in TypeScript files; avoid restating TypeScript types and signatures in prose

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
packages/thirdweb/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/thirdweb/src/**/*.{ts,tsx}: Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose
Load heavy dependencies inside async paths to keep initial bundle lean (e.g. const { jsPDF } = await import("jspdf");)

Lazy-load heavy dependencies inside async paths to keep the initial bundle lean (e.g., const { jsPDF } = await import('jspdf');)

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Biome governs formatting and linting; its rules live in biome.json. Run pnpm fix & pnpm lint before committing, ensure there are no linting errors

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
⏰ 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). (5)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
🔇 Additional comments (1)
.changeset/ninety-trains-tell.md (1)

1-5: Changeset looks correct for a patch-level UI ordering change.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 12, 2025

size-limit report 📦

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 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 1169752 and e53e802.

📒 Files selected for processing (2)
  • .changeset/ninety-trains-tell.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.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 TypeScript file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes in TypeScript
Avoid any and unknown in TypeScript unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.) in TypeScript

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity and testability
Re-use shared types from @/types or local types.ts barrel exports
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics whenever possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic in TypeScript files; avoid restating TypeScript types and signatures in prose

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
packages/thirdweb/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/thirdweb/src/**/*.{ts,tsx}: Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose
Load heavy dependencies inside async paths to keep initial bundle lean (e.g. const { jsPDF } = await import("jspdf");)

Lazy-load heavy dependencies inside async paths to keep the initial bundle lean (e.g., const { jsPDF } = await import('jspdf');)

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Biome governs formatting and linting; its rules live in biome.json. Run pnpm fix & pnpm lint before committing, ensure there are no linting errors

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
⏰ 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). (2)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
🔇 Additional comments (2)
.changeset/ninety-trains-tell.md (1)

1-5: Changeset looks correct and user-facing text is clear.

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

8-9: LGTM: Correct async handling.

The change to explicitly await the chains() call before sorting is correct, as the bridge API call returns a Promise.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1)

7-25: Fix cache-key isolation and avoid mutating the fetched/cached chains array.

  • queryKey: ["bridge-chains"] (Line 7) risks cache collisions if multiple ThirdwebClient instances exist.
  • data.sort(...) (Line 12) mutates in-place; if chains() returns a cached/shared array, this can leak ordering side-effects across consumers.

Proposed adjustment:

 export function useBridgeChains(client: ThirdwebClient) {
   return useQuery({
-    queryKey: ["bridge-chains"],
+    // TODO: pick a stable client identity (see verification script below)
+    queryKey: ["bridge-chains", client],
     queryFn: async () => {
       const data = await chains({ client });

       // sort by name, but if name starts with number, put it at the end
-      return data.sort((a, b) => {
-        const aStartsWithNumber = a.name[0]?.match(/^\d/);
-        const bStartsWithNumber = b.name[0]?.match(/^\d/);
+      return data.slice().sort((a, b) => {
+        const aStartsWithNumber = /^\d/.test(a.name);
+        const bStartsWithNumber = /^\d/.test(b.name);

         if (aStartsWithNumber && !bStartsWithNumber) {
           return 1;
         }

         if (!aStartsWithNumber && bStartsWithNumber) {
           return -1;
         }

         return a.name.localeCompare(b.name);
       });
     },

Verification script to decide what should go into the queryKey instead of client directly:

#!/bin/bash
set -euo pipefail

# Look for established patterns of scoping react-query keys by ThirdwebClient identity.
rg -n --type=ts --type=tsx 'queryKey:\s*\[[^\]]*client' packages/thirdweb/src/react -S
rg -n --type=ts --type=tsx 'queryKey:\s*\[\s*["'\"'bridge-chains["'\"']' packages/thirdweb/src -S

# Inspect what ThirdwebClient exposes for stable identification (clientId, secretKey, etc.),
# and whether there’s a helper like getClientId(client).
rg -n --type=ts 'export type ThirdwebClient|class ThirdwebClient|function getClientId' packages/thirdweb/src -S
🧹 Nitpick comments (1)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts (1)

5-9: Add an explicit return type for useBridgeChains (per TS guidelines).

Consider annotating the hook return type (whatever the repo’s preferred UseQueryResult<...> shape is) to satisfy the “explicit return types” guideline.

📜 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 e53e802 and ba6f15d.

📒 Files selected for processing (2)
  • .changeset/ninety-trains-tell.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.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 TypeScript file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes in TypeScript
Avoid any and unknown in TypeScript unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.) in TypeScript

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity and testability
Re-use shared types from @/types or local types.ts barrel exports
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics whenever possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic in TypeScript files; avoid restating TypeScript types and signatures in prose

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
packages/thirdweb/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/thirdweb/src/**/*.{ts,tsx}: Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose
Load heavy dependencies inside async paths to keep initial bundle lean (e.g. const { jsPDF } = await import("jspdf");)

Lazy-load heavy dependencies inside async paths to keep the initial bundle lean (e.g., const { jsPDF } = await import('jspdf');)

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Biome governs formatting and linting; its rules live in biome.json. Run pnpm fix & pnpm lint before committing, ensure there are no linting errors

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-bridge-chains.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Size
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
.changeset/ninety-trains-tell.md (1)

1-5: Changeset looks correct for a patch release.

@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.64%. Comparing base (2bb6a4f) to head (31e24f1).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...act/web/ui/Bridge/swap-widget/use-bridge-chains.ts 0.00% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8551      +/-   ##
==========================================
- Coverage   54.64%   54.64%   -0.01%     
==========================================
  Files         921      921              
  Lines       61181    61193      +12     
  Branches     4151     4154       +3     
==========================================
+ Hits        33434    33439       +5     
- Misses      27645    27652       +7     
  Partials      102      102              
Flag Coverage Δ
packages 54.64% <0.00%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
...act/web/ui/Bridge/swap-widget/use-bridge-chains.ts 12.50% <0.00%> (-12.50%) ⬇️

... and 2 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.

@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 12, 2025

Merge activity

<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on improving the `SwapWidget` UI by alphabetically sorting the chains returned by the `use-bridge-chains.ts` module, ensuring that chains with names starting with numbers are placed at the end of the list.

### Detailed summary
- Updated the `queryFn` in `use-bridge-chains.ts` to be asynchronous.
- Introduced a copy of the fetched data to sort it.
- Implemented sorting logic to place chains starting with numbers at the end.
- Used `localeCompare` for alphabetical sorting of chain names.

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

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Chains in the SwapWidget are now alphabetically sorted for improved navigation; chain names beginning with digits appear after alphabetic entries.

* **Chores**
  * Patch release entry added to the changelog.

<sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants