-
Notifications
You must be signed in to change notification settings - Fork 615
[MNY-257] Dashboard: Add query params in bridge page to configure token selection #8293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
WalkthroughPage converted to an async React server component that resolves URL searchParams, validates/parses input/output chain and currency query parameters (address/number), constructs buyTab and swapTab token+chain configs (falling back to native token), and passes them to BridgePageUI. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Browser
participant Page as apps/dashboard/src/app/bridge/page.tsx
participant UI as BridgePageUI
User->>Browser: Navigate to /bridge?outputChain=1&outputCurrency=0x...
Browser->>Page: Request (searchParams Promise)
Note over Page: await searchParams\nparse input/output params\nvalidate address/number
Page->>Page: compute sellChain/sellCurrency\ncompute buyChain/buyCurrency\napply NATIVE_TOKEN_ADDRESS fallback
Page->>UI: render with buyTab & swapTab configs
UI->>Browser: render configured bridge widget
Browser->>User: display preset route
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8293 +/- ##
=======================================
Coverage 54.90% 54.90%
=======================================
Files 919 919
Lines 60665 60665
Branches 4129 4129
=======================================
Hits 33310 33310
Misses 27254 27254
Partials 101 101
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/dashboard/src/app/bridge/page.tsx (2)
18-20: Consider using Next.js built-in type if available.The
SearchParamstype definition matches Next.js conventions. If Next.js 15 exports a type for searchParams (e.g., fromnext/types), consider importing it to reduce duplication.
22-87: Add explicit return type and server-only import.The component logic is correct, but two guideline requirements are missing:
- Missing explicit return type: According to coding guidelines, TypeScript functions should have explicit return types.
- Missing server-only import: Server components should start with
import "server-only"per coding guidelines.Apply this diff to add the return type:
-export default async function Page(props: { +export default async function Page(props: { searchParams: Promise<SearchParams>; -}) { +}): Promise<JSX.Element> {Add this import at the top of the file:
+import "server-only"; import type { Metadata } from "next"; import { isAddress, NATIVE_TOKEN_ADDRESS } from "thirdweb";As per coding 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.
📒 Files selected for processing (1)
apps/dashboard/src/app/bridge/page.tsx(3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{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@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless 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@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless 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/app/bridge/page.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/app/bridge/page.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
UseNavLinkfor internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Usecn()from@/lib/utilsfor conditional class logic
Use design system tokens (e.g.,bg-card,border-border,text-muted-foreground)
Server Components (Node edge): Start files withimport "server-only";
Client Components (browser): Begin files with'use client';
Always callgetAuthToken()to retrieve JWT from cookies on server side
UseAuthorization: Bearerheader – never embed tokens in URLs
Return typed results (e.g.,Project[],User[]) – avoidany
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stablequeryKeysfor React Query cache hits
ConfigurestaleTime/cacheTimein React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never importposthog-jsin server components
Files:
apps/dashboard/src/app/bridge/page.tsx
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)
UseNavLinkfor internal navigation to get active state handling
Use Tailwind CSS for styling; no inline styles
Merge class names withcn()from@/lib/utilsfor conditional classes
Stick to design tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components must start withimport "server-only"; usenext/headers, server‑only env, heavy data fetching, andredirect()where appropriate
Client Components must start with'use client'; handle interactivity with hooks and browser APIs
Server-side data fetching: callgetAuthToken()from cookies, sendAuthorization: Bearer <token>header, and return typed results (avoidany)
Client-side data fetching: wrap calls in React Query with descriptive, stablequeryKeysand set sensiblestaleTime/cacheTime(≥ 60s default); keep tokens secret via internal routes or server actions
Do not importposthog-jsin server components (client-side only)
Files:
apps/dashboard/src/app/bridge/page.tsx
apps/{dashboard,playground}/**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Expose a
classNameprop on the root element of every component
Files:
apps/dashboard/src/app/bridge/page.tsx
🧬 Code graph analysis (1)
apps/dashboard/src/app/bridge/page.tsx (3)
apps/dashboard/src/app/bridge/exchange/[token-pair]/page.tsx (1)
Page(53-93)apps/dashboard/src/app/bridge/components/bridge-page.tsx (1)
BridgePageUI(7-30)packages/thirdweb/src/exports/thirdweb.ts (1)
NATIVE_TOKEN_ADDRESS(31-31)
⏰ 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). (3)
- GitHub Check: Lint Packages
- GitHub Check: Size
- GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/dashboard/src/app/bridge/page.tsx (2)
2-2: LGTM!The thirdweb imports are correctly used for address validation and native token fallback handling.
89-98: Helper function correctly handles single-value query params.The function has an explicit return type and correctly extracts string values. Note that it silently ignores the
string[]case (when the same query param appears multiple times), which is likely intentional for this use case.
size-limit report 📦
|
Merge activity
|
…en selection (#8293) <!-- ## 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 enhances the `Page` component in `apps/dashboard/src/app/bridge/page.tsx` by introducing asynchronous handling of search parameters and improving the logic for processing input and output chains and currencies. ### Detailed summary - Added a `SearchParams` type to define search parameters. - Updated `Page` to accept `searchParams` as a `Promise`. - Implemented `onlyAddress` and `onlyNumber` functions for validation. - Introduced a `parse` function to extract values from search parameters. - Updated the `BridgePageUI` props for `buyTab` and `swapTab` to handle dynamic token data. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
fd06633 to
c36cfbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 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.
📒 Files selected for processing (1)
apps/dashboard/src/app/bridge/page.tsx(3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{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@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless 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@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless 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/app/bridge/page.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/app/bridge/page.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
UseNavLinkfor internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Usecn()from@/lib/utilsfor conditional class logic
Use design system tokens (e.g.,bg-card,border-border,text-muted-foreground)
Server Components (Node edge): Start files withimport "server-only";
Client Components (browser): Begin files with'use client';
Always callgetAuthToken()to retrieve JWT from cookies on server side
UseAuthorization: Bearerheader – never embed tokens in URLs
Return typed results (e.g.,Project[],User[]) – avoidany
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stablequeryKeysfor React Query cache hits
ConfigurestaleTime/cacheTimein React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never importposthog-jsin server components
Files:
apps/dashboard/src/app/bridge/page.tsx
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)
UseNavLinkfor internal navigation to get active state handling
Use Tailwind CSS for styling; no inline styles
Merge class names withcn()from@/lib/utilsfor conditional classes
Stick to design tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components must start withimport "server-only"; usenext/headers, server‑only env, heavy data fetching, andredirect()where appropriate
Client Components must start with'use client'; handle interactivity with hooks and browser APIs
Server-side data fetching: callgetAuthToken()from cookies, sendAuthorization: Bearer <token>header, and return typed results (avoidany)
Client-side data fetching: wrap calls in React Query with descriptive, stablequeryKeysand set sensiblestaleTime/cacheTime(≥ 60s default); keep tokens secret via internal routes or server actions
Do not importposthog-jsin server components (client-side only)
Files:
apps/dashboard/src/app/bridge/page.tsx
apps/{dashboard,playground}/**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Expose a
classNameprop on the root element of every component
Files:
apps/dashboard/src/app/bridge/page.tsx
🧬 Code graph analysis (1)
apps/dashboard/src/app/bridge/page.tsx (3)
apps/dashboard/src/app/bridge/exchange/[token-pair]/page.tsx (1)
Page(53-93)apps/dashboard/src/app/bridge/components/bridge-page.tsx (1)
BridgePageUI(7-30)packages/thirdweb/src/exports/thirdweb.ts (1)
NATIVE_TOKEN_ADDRESS(31-31)
⏰ 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: E2E Tests (pnpm, vite)
- GitHub Check: Lint Packages
- GitHub Check: Size
- GitHub Check: Analyze (javascript)
| const onlyNumber = (v: string) => | ||
| Number.isNaN(Number(v)) ? undefined : Number(v); | ||
|
|
||
| // output is buy, input is sell | ||
| const sellChain = parse(searchParams.inputChain, onlyNumber); | ||
| const sellCurrency = parse(searchParams.inputCurrency, onlyAddress); | ||
|
|
||
| const buyChain = parse(searchParams.outputChain, onlyNumber); | ||
| const buyCurrency = parse(searchParams.outputCurrency, onlyAddress); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Harden chain ID parsing to reject empty/invalid values.
onlyNumber currently accepts values like "" or " " (coerced to 0) and any non-integer such as "1.5", so a query like ?outputChain= ends up sending chainId: 0. That’s not a valid EVM chain ID and will surface downstream as a broken bridge configuration. Please tighten the validator to bail out on blank strings and non-integer values before we build the embed props.
- const onlyNumber = (v: string) =>
- Number.isNaN(Number(v)) ? undefined : Number(v);
+ const onlyNumber = (v: string) => {
+ if (v.trim() === "") {
+ return undefined;
+ }
+ const parsed = Number(v);
+ return Number.isInteger(parsed) ? parsed : undefined;
+ };📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const onlyNumber = (v: string) => | |
| Number.isNaN(Number(v)) ? undefined : Number(v); | |
| // output is buy, input is sell | |
| const sellChain = parse(searchParams.inputChain, onlyNumber); | |
| const sellCurrency = parse(searchParams.inputCurrency, onlyAddress); | |
| const buyChain = parse(searchParams.outputChain, onlyNumber); | |
| const buyCurrency = parse(searchParams.outputCurrency, onlyAddress); | |
| const onlyNumber = (v: string) => { | |
| if (v.trim() === "") { | |
| return undefined; | |
| } | |
| const parsed = Number(v); | |
| return Number.isInteger(parsed) ? parsed : undefined; | |
| }; | |
| // output is buy, input is sell | |
| const sellChain = parse(searchParams.inputChain, onlyNumber); | |
| const sellCurrency = parse(searchParams.inputCurrency, onlyAddress); | |
| const buyChain = parse(searchParams.outputChain, onlyNumber); | |
| const buyCurrency = parse(searchParams.outputCurrency, onlyAddress); |
🤖 Prompt for AI Agents
In apps/dashboard/src/app/bridge/page.tsx around lines 28 to 36, the onlyNumber
validator currently coerces blank/whitespace and non-integer strings to 0 (e.g.
"" -> 0) which allows invalid chainId values; update the validator to first trim
and reject empty strings, then verify the raw string strictly represents an
integer (no decimals, no signs, e.g. using a /^\d+$/-style check or equivalent)
before converting to a Number, returning undefined for anything that fails so
parse(...) won't produce chainId: 0.

PR-Codex overview
This PR enhances the
Pagecomponent in theapps/dashboard/src/app/bridge/page.tsxfile by adding search parameter handling, improving the logic for processing token addresses and chain IDs, and updating the UI props for theBridgePageUIcomponent.Detailed summary
SearchParamstype for better type safety.Pagefunction to acceptsearchParamsas a Promise.onlyAddressandonlyNumberfor validation.parsefunction for extracting and validating search parameters.BridgePageUIprops to include structuredbuyTabandswapTabdata based on parsed parameters.Summary by CodeRabbit