Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Oct 15, 2025


PR-Codex overview

This PR updates the onSuccess prop for several components to include both statuses and quote objects, enhancing the data returned upon successful transactions.

Detailed summary

  • Updated onSuccess prop in BuyWidget, CheckoutWidget, SwapWidget, and BridgeWidget to accept an object containing quote and statuses.
  • Modified function signatures to reflect the new structure.
  • Adjusted implementation in respective components to use the new data format.

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

Summary by CodeRabbit

  • New Features

    • onSuccess callbacks for Buy, Checkout, Swap, and Bridge widgets now return an object with the original quote plus an array of completion statuses.
    • Added public type exports to improve typing: BridgePrepareResult, CompletedStatusResult, and BuyOrOnrampPrepareResult.
  • Documentation

    • Updated guides and examples to show the new onSuccess payload shape and recommended destructuring usage in callbacks.

@linear
Copy link

linear bot commented Oct 15, 2025

@vercel
Copy link

vercel bot commented Oct 15, 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 Oct 16, 2025 5:21pm
nebula Ready Ready Preview Comment Oct 16, 2025 5:21pm
thirdweb_playground Ready Ready Preview Comment Oct 16, 2025 5:21pm
thirdweb-www Building Building Oct 16, 2025 5:21pm
wallet-ui Ready Ready Preview Comment Oct 16, 2025 5:21pm

@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2025

🦋 Changeset detected

Latest commit: ae0159e

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

This PR includes changesets to release 4 packages
Name Type
thirdweb Minor
@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

@MananTank MananTank marked this pull request as ready for review October 15, 2025 17:27
@github-actions github-actions bot added Dashboard Involves changes to the Dashboard. Portal Involves changes to the Portal (docs) codebase. packages labels Oct 15, 2025
@MananTank MananTank requested a review from a team as a code owner October 15, 2025 17:27
@github-actions github-actions bot added the SDK Involves changes to the thirdweb SDK label Oct 15, 2025
@MananTank MananTank requested a review from a team as a code owner October 15, 2025 17:27
Copy link
Member Author


How to use the Graphite Merge Queue

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

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

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

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

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

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

The onSuccess callback signature for BuyWidget, CheckoutWidget, SwapWidget, and BridgeWidget changed: handlers now receive an object { quote, statuses } (with statuses: CompletedStatusResult[]) instead of a single quote. Call sites, script exports, types, docs, and a changeset were updated.

Changes

Cohort / File(s) Summary
Widget API updates (onSuccess payload)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx, packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx, packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx, packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx
Update onSuccess prop signatures to accept an object { quote, statuses } where statuses: CompletedStatusResult[]; adjust internal calls to invoke onSuccess({ quote, statuses }) and add/import CompletedStatusResult where required.
Script exports and public types
packages/thirdweb/src/script-exports/bridge-widget-script.tsx, packages/thirdweb/src/exports/react.ts
Update BridgeWidgetScriptProps buy.onSuccess and swap.onSuccess to the new data shape; add/export type-only exports: BridgePrepareResult, CompletedStatusResult, and BuyOrOnrampPrepareResult.
App usage updates
apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx
Local onSuccess handlers updated to destructure the new payload (e.g., onSuccess={({ quote }) => ... }); internal logic unchanged.
Docs (Bridge Widget Script)
apps/portal/src/app/bridge/bridge-widget-script/page.mdx
Documentation Options type updated: buy.onSuccess and swap.onSuccess now receive { quote, statuses } instead of plain quote.
Changeset note
.changeset/strong-buses-love.md
Adds a patch note describing the API change and a minimal example demonstrating access to data.statuses and data.quote.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as App / Developer
  participant W as Widget (Buy/Swap/Checkout/Bridge)
  participant Exec as Execution Flow
  participant CB as onSuccess Callback

  Dev->>W: Render widget with onSuccess(handler)
  W->>Exec: Execute flow (swap/buy/checkout)
  Exec-->>W: Success -> returns quote + completedStatuses
  W->>CB: onSuccess({ quote, statuses: completedStatuses })
  Note right of CB #cdeccf: Handler receives both quote and statuses
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The PR includes updates to BuyWidget, SwapWidget, BridgeWidget, and additional type exports that are not mentioned in the linked issue MNY-256 and thus appear to be outside the scope defined by that issue. Either restrict the PR to only the CheckoutWidget changes or update the linked issues to reference the additional widget updates so that all changes align with defined objectives.
Description Check ⚠️ Warning The PR description retains the placeholder template comments without replacing them with an actual title, reviewer notes, or testing instructions, leaving required sections unfilled. The author should remove the placeholder template comments and fill in the title, notes for the reviewer, and clear testing instructions under the How to test section.
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 (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title lists the core API change and the affected components, accurately reflecting the update to the onSuccess prop across BuyWidget, CheckoutWidget, SwapWidget, and BridgeWidget.
Linked Issues Check ✅ Passed The PR updates the CheckoutWidget onSuccess callback to accept and pass an object containing quote and statuses, fulfilling the linked issue’s requirement to include transaction-related information in its callback payload.
✨ 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-256

📜 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 58c5ac8 and ae0159e.

📒 Files selected for processing (9)
  • .changeset/strong-buses-love.md (1 hunks)
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx (2 hunks)
  • apps/portal/src/app/bridge/bridge-widget-script/page.mdx (2 hunks)
  • packages/thirdweb/src/exports/react.ts (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (2 hunks)
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx
  • apps/portal/src/app/bridge/bridge-widget-script/page.mdx
🧰 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 @/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/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
  • packages/thirdweb/src/exports/react.ts
**/*.{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/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
  • packages/thirdweb/src/exports/react.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/BuyWidget.tsx
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
  • packages/thirdweb/src/exports/react.ts
packages/thirdweb/src/exports/**

📄 CodeRabbit inference engine (CLAUDE.md)

packages/thirdweb/src/exports/**: Export everything via exports/ directory, grouped by feature in the SDK public API
Every public symbol must have comprehensive TSDoc with at least one @example block that compiles and custom annotation tags (@beta, @internal, @experimental)

Files:

  • packages/thirdweb/src/exports/react.ts
.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/strong-buses-love.md
🧠 Learnings (7)
📓 Common learnings
Learnt from: MananTank
PR: thirdweb-dev/js#8106
File: packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx:34-41
Timestamp: 2025-09-24T11:08:43.783Z
Learning: In BridgeWidgetProps for packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx, the Swap onError callback signature requires a non-undefined SwapPreparedQuote parameter (unlike Buy's onError which allows undefined quote). This is intentional - SwapWidget's onError is only called when a quote is available.
📚 Learning: 2025-09-24T11:08:43.783Z
Learnt from: MananTank
PR: thirdweb-dev/js#8106
File: packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx:34-41
Timestamp: 2025-09-24T11:08:43.783Z
Learning: In BridgeWidgetProps for packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx, the Swap onError callback signature requires a non-undefined SwapPreparedQuote parameter (unlike Buy's onError which allows undefined quote). This is intentional - SwapWidget's onError is only called when a quote is available.

Applied to files:

  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
  • .changeset/strong-buses-love.md
📚 Learning: 2025-09-24T11:09:45.142Z
Learnt from: MananTank
PR: thirdweb-dev/js#8106
File: packages/thirdweb/src/script-exports/readme.md:6-7
Timestamp: 2025-09-24T11:09:45.142Z
Learning: For thirdweb Bridge Widget script exports, the module is exported with globalName: "BridgeWidget" in tsup config, making the global API `BridgeWidget.render()` rather than `window.thirdweb.BridgeWidget.render()`.

Applied to files:

  • packages/thirdweb/src/script-exports/bridge-widget-script.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/exports/react.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/exports/react.native.ts : React Native specific exports are in `src/exports/react.native.ts`

Applied to files:

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

Applied to files:

  • packages/thirdweb/src/exports/react.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 .changeset/*.md : Version bump rules: patch for non‑API changes; minor for new/modified public API

Applied to files:

  • .changeset/strong-buses-love.md
🧬 Code graph analysis (4)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (2)
packages/thirdweb/src/exports/react.ts (2)
  • BuyOrOnrampPrepareResult (138-138)
  • CompletedStatusResult (81-81)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
  • CompletedStatusResult (19-26)
packages/thirdweb/src/script-exports/bridge-widget-script.tsx (3)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • SwapPreparedQuote (154-157)
packages/thirdweb/src/exports/react.ts (2)
  • CompletedStatusResult (81-81)
  • BuyOrOnrampPrepareResult (138-138)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (1)
  • BuyOrOnrampPrepareResult (40-43)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (2)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • SwapPreparedQuote (154-157)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
  • CompletedStatusResult (19-26)
packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (1)
packages/thirdweb/src/exports/react.ts (2)
  • BridgePrepareResult (76-76)
  • CompletedStatusResult (81-81)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Unit Tests
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (11)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (2)

24-24: LGTM!

The CompletedStatusResult import supports the updated onSuccess signature.


161-164: LGTM!

The onSuccess signature correctly updated to accept an object containing both quote and statuses, providing callers with comprehensive transaction information.

packages/thirdweb/src/exports/react.ts (1)

76-76: LGTM!

The new type exports (BridgePrepareResult, CompletedStatusResult, BuyOrOnrampPrepareResult) properly expose the types needed for consumers to type their onSuccess callbacks with the updated signature.

Also applies to: 81-81, 138-138

packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (3)

25-25: LGTM!

The CompletedStatusResult import supports the updated onSuccess signature.


173-176: LGTM!

The onSuccess signature correctly updated to accept an object containing both quote and statuses, consistent with the other widgets in this PR.


666-669: LGTM!

The onSuccess invocation correctly passes the new payload structure with both quote and statuses, enabling consumers to access detailed transaction information.

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

15-15: LGTM!

The CompletedStatusResult import supports the updated onSuccess signature.


148-151: LGTM!

The onSuccess signature correctly updated to accept an object containing both quote and statuses, aligning with the API changes across all bridge widgets.


471-474: LGTM!

The onSuccess invocation correctly passes the new payload structure, providing consumers with both the quote and completion statuses.

packages/thirdweb/src/script-exports/bridge-widget-script.tsx (2)

10-10: LGTM!

The CompletedStatusResult import supports the updated callback signatures for both swap and buy operations.


27-30: LGTM!

The onSuccess signatures for both swap and buy operations correctly updated to accept the composite payload { quote, statuses }, maintaining consistency with the underlying widget components.

Also applies to: 58-61

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 draft October 15, 2025 17:29
@MananTank MananTank changed the title [MNY-256] SDK: Update onSuccess prop of BuyWidget, CheckoutWidget, BridgeWidget components [MNY-256] SDK: Update onSuccess prop of BuyWidget, CheckoutWidget, SwapWidget, BridgeWidget components Oct 15, 2025
@MananTank MananTank marked this pull request as ready for review October 15, 2025 17:33
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

Caution

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

⚠️ Outside diff range comments (1)
apps/portal/src/app/bridge/bridge-widget-script/page.mdx (1)

163-328: Fix inconsistent onSuccess typings in docs.

Lines 163‑324 still document onSuccess as receiving only a quote, contradicting the updated API (lines 107‑141) where it now receives { quote, statuses }. This mismatch will mislead integrators. Please update both the Swap and Buy type snippets here to mirror the new object payload.

-    onSuccess?: (quote: SwapPreparedQuote) => void;
+    onSuccess?: (data: {
+      quote: SwapPreparedQuote;
+      statuses: CompletedStatusResult[];
+    }) => void;
@@
-    onSuccess?: (quote: BuyOrOnrampPrepareResult) => void;
+    onSuccess?: (data: {
+      quote: BuyOrOnrampPrepareResult;
+      statuses: CompletedStatusResult[];
+    }) => void;
📜 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 e830109 and 6a8c4c3.

📒 Files selected for processing (9)
  • .changeset/strong-buses-love.md (1 hunks)
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx (2 hunks)
  • apps/portal/src/app/bridge/bridge-widget-script/page.mdx (2 hunks)
  • packages/thirdweb/src/exports/react.ts (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (2 hunks)
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{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/Bridge/bridge-widget/bridge-widget.tsx
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx
  • packages/thirdweb/src/exports/react.ts
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.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/Bridge/bridge-widget/bridge-widget.tsx
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx
  • packages/thirdweb/src/exports/react.ts
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.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/Bridge/bridge-widget/bridge-widget.tsx
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • packages/thirdweb/src/exports/react.ts
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
.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/strong-buses-love.md
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/@/components/blocks/BuyAndSwapEmbed.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)
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/@/components/blocks/BuyAndSwapEmbed.tsx
apps/{dashboard,playground}/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Expose a className prop on the root element of every component

Files:

  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx
packages/thirdweb/src/exports/**

📄 CodeRabbit inference engine (CLAUDE.md)

packages/thirdweb/src/exports/**: Export everything via exports/ directory, grouped by feature in the SDK public API
Every public symbol must have comprehensive TSDoc with at least one @example block that compiles and custom annotation tags (@beta, @internal, @experimental)

Files:

  • packages/thirdweb/src/exports/react.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: MananTank
PR: thirdweb-dev/js#8106
File: packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx:34-41
Timestamp: 2025-09-24T11:08:43.783Z
Learning: In BridgeWidgetProps for packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx, the Swap onError callback signature requires a non-undefined SwapPreparedQuote parameter (unlike Buy's onError which allows undefined quote). This is intentional - SwapWidget's onError is only called when a quote is available.
📚 Learning: 2025-09-24T11:08:43.783Z
Learnt from: MananTank
PR: thirdweb-dev/js#8106
File: packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx:34-41
Timestamp: 2025-09-24T11:08:43.783Z
Learning: In BridgeWidgetProps for packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx, the Swap onError callback signature requires a non-undefined SwapPreparedQuote parameter (unlike Buy's onError which allows undefined quote). This is intentional - SwapWidget's onError is only called when a quote is available.

Applied to files:

  • apps/portal/src/app/bridge/bridge-widget-script/page.mdx
  • packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx
  • .changeset/strong-buses-love.md
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.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 src/exports/react.native.ts : React Native specific exports are in `src/exports/react.native.ts`

Applied to files:

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

Applied to files:

  • packages/thirdweb/src/exports/react.ts
🧬 Code graph analysis (4)
packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx (3)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • SwapPreparedQuote (154-157)
packages/thirdweb/src/exports/react.ts (2)
  • CompletedStatusResult (81-81)
  • BuyOrOnrampPrepareResult (138-138)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (1)
  • BuyOrOnrampPrepareResult (40-43)
packages/thirdweb/src/script-exports/bridge-widget-script.tsx (2)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • SwapPreparedQuote (154-157)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (1)
  • BuyOrOnrampPrepareResult (40-43)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (1)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
  • CompletedStatusResult (19-26)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (2)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • SwapPreparedQuote (154-157)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
  • CompletedStatusResult (19-26)
⏰ 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 (13)
packages/thirdweb/src/exports/react.ts (1)

76-76: LGTM: Type exports correctly added.

The new type exports (BridgePrepareResult, CompletedStatusResult, BuyOrOnrampPrepareResult) properly surface the types needed for the updated onSuccess callback signature. Using export type is appropriate for type-only exports.

Also applies to: 81-81, 138-138

packages/thirdweb/src/script-exports/bridge-widget-script.tsx (2)

10-10: LGTM: Import added correctly.

The CompletedStatusResult type is imported to support the updated onSuccess callback signatures.


27-30: LGTM: Callback signatures updated consistently.

Both swap.onSuccess and buy.onSuccess now accept a data object containing both quote and statuses, aligning with the PR objectives and the underlying widget implementations.

Also applies to: 58-61

.changeset/strong-buses-love.md (1)

5-14: LGTM: Clear documentation of the API change.

The example code clearly demonstrates the new usage pattern for the onSuccess callback, showing how to access both statuses and quote from the data object.

apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx (1)

150-150: LGTM: Correctly adapted to new onSuccess signature.

The onSuccess handlers now destructure { quote } from the data object parameter, correctly adapting to the updated API. The rest of the logic remains unchanged, accessing quote properties as before.

Also applies to: 211-211

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

148-151: LGTM: Type definition updated correctly.

The onSuccess prop type is updated to accept a data object containing both quote and statuses, aligning with the PR objectives.


471-474: LGTM: Implementation matches type definition.

The onSuccess callback is invoked with the correct object structure { quote, statuses }, matching the updated type definition. The completedStatuses from the onComplete callback are properly passed through.

packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (2)

161-164: LGTM: Type definition updated correctly.

The onSuccess prop type is updated to accept a data object containing both quote and statuses, consistent with the other widget components.


622-625: LGTM: Implementation correctly guarded and structured.

The onSuccess callback invocation is properly guarded by a type check ensuring the quote type is "buy" or "onramp" (matching BuyOrOnrampPrepareResult), and correctly passes the object with { quote, statuses }.

packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (2)

173-176: LGTM: Type definition updated correctly.

The onSuccess prop type is updated to accept a data object containing both quote and statuses, maintaining consistency across all widget components.


666-669: LGTM: Implementation matches type definition.

The onSuccess callback is invoked with the correct object structure { quote, statuses }, consistent with the updated type definition and other widget implementations.

packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx (2)

16-16: LGTM: Import added correctly.

The CompletedStatusResult type is imported to support the updated onSuccess callback signatures in the BridgeWidget props.


86-89: LGTM: Callback signatures updated consistently.

Both swap.onSuccess and buy.onSuccess in BridgeWidgetProps are updated to accept data objects containing quote and statuses, maintaining consistency with the underlying SwapWidget and BuyWidget implementations.

Also applies to: 179-182

@codecov
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.01%. Comparing base (8c58c13) to head (58c5ac8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ges/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8259      +/-   ##
==========================================
- Coverage   55.01%   55.01%   -0.01%     
==========================================
  Files         919      919              
  Lines       60588    60591       +3     
  Branches     4126     4125       -1     
==========================================
  Hits        33334    33334              
- Misses      27150    27153       +3     
  Partials      104      104              
Flag Coverage Δ
packages 55.01% <0.00%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
...ges/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx 5.76% <0.00%> (-0.06%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 15, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.51 KB (0%) 1.3 s (0%) 167 ms (+172.39% 🔺) 1.5 s
thirdweb (cjs) 365.68 KB (0%) 7.4 s (0%) 576 ms (+16.9% 🔺) 7.9 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 79 ms (+2688.58% 🔺) 193 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 89 ms (+5037.99% 🔺) 99 ms
thirdweb/react (minimal + tree-shaking) 19.13 KB (0%) 383 ms (0%) 75 ms (+1328.21% 🔺) 458 ms

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

Caution

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

⚠️ Outside diff range comments (1)
apps/portal/src/app/bridge/bridge-widget-script/page.mdx (1)

163-184: Update the collapsed type definitions to match the new signatures.

The type definitions in the collapsed <Details> sections still show the old callback signatures:

  • Line 166: onSuccess?: (quote: SwapPreparedQuote) => void;
  • Line 324: onSuccess?: (quote: BuyOrOnrampPrepareResult) => void;

These should be updated to match the new signatures shown in the main Options type definition above.

Apply these diffs to fix the inconsistency:

For the Swap type at line 166:

     className?: string;
     style?: React.CSSProperties;
-    onSuccess?: (quote: SwapPreparedQuote) => void;
+    onSuccess?: (data: {
+      quote: SwapPreparedQuote;
+      statuses: CompletedStatusResult[];
+    }) => void;
     onError?: (error: Error, quote: SwapPreparedQuote) => void;

For the Buy type at line 324:

     onError?: (
       error: Error,
       quote: BuyOrOnrampPrepareResult | undefined,
     ) => void;
-    onSuccess?: (quote: BuyOrOnrampPrepareResult) => void;
+    onSuccess?: (data: {
+      quote: BuyOrOnrampPrepareResult;
+      statuses: CompletedStatusResult[];
+    }) => void;
     className?: string;

Also applies to: 314-329

🧹 Nitpick comments (7)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (1)

161-164: Document the new payload shape and add an example in TSDoc.

Please expand the onSuccess prop doc to state it receives { quote, statuses }, and include a short example. Consider extracting a shared type alias (e.g., OnSuccessData<Q> = { quote: Q; statuses: CompletedStatusResult[] }) to reuse across widgets and script props.

For the public alias declared earlier in this file, add TSDoc so it meets the package docs requirement:

/**
 * Result type for Buy or Onramp prepared quotes.
 * @example
 * ```ts
 * function onSuccess(data: { quote: BuyOrOnrampPrepareResult; statuses: CompletedStatusResult[] }) {
 *   console.log(data.quote.type, data.statuses.length);
 * }
 * ```
 * @beta
 */
export type BuyOrOnrampPrepareResult = Extract<
  BridgePrepareResult,
  { type: "buy" | "onramp" }
>;
apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx (2)

150-175: Optionally include statuses to enrich analytics.

You can destructure { quote, statuses } and use statuses-derived tx details (hashes, chains) in reports.


211-219: Same here: consider using statuses as well.

Statuses can improve success reporting (e.g., tx hash, final chain).

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

148-151: Clarify onSuccess payload in docs and add example.

Document { quote, statuses } and include a minimal code example for consumers. Also, fix the nearby onCancel comment that says “purchase” (it should say “swap”).

Example TSDoc snippet for onSuccess:

/**
 * Callback when the swap completes.
 * @example
 * ```tsx
 * <SwapWidget onSuccess={({ quote, statuses }) => {
 *   console.log(quote.type, statuses.map(s => s.status));
 * }} />
 * ```
 */

Doc wording fix (near Lines 157-159):

-  /**
-   * Callback to be called when the user cancels the purchase.
-   */
+  /**
+   * Callback to be called when the user cancels the swap.
+   */
packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (1)

173-176: Enhance TSDoc to describe { quote, statuses } and add an example.

Update the onSuccess prop comment to explicitly state the payload shape and include a concise example.

Optional: Update the earlier example to show destructuring:

- *   onSuccess={() => {
- *     alert("Purchase successful!");
- *   }}
+ *   onSuccess={({ quote, statuses }) => {
+ *     console.log(quote.type, statuses.length);
+ *     alert("Purchase successful!");
+ *   }}
packages/thirdweb/src/script-exports/bridge-widget-script.tsx (2)

27-31: Consistent payload for script onSuccess.

Looks good. To avoid repeating the object shape, consider a local generic alias and reuse it in both swap and buy.

@@
-import type { CompletedStatusResult } from "../react/core/hooks/useStepExecutor.js";
+import type { CompletedStatusResult } from "../react/core/hooks/useStepExecutor.js";
@@
-export type BridgeWidgetScriptProps = {
+type OnSuccessData<Q> = { quote: Q; statuses: CompletedStatusResult[] };
+
+export type BridgeWidgetScriptProps = {
@@
-    onSuccess?: (data: {
-      quote: SwapPreparedQuote;
-      statuses: CompletedStatusResult[];
-    }) => void;
+    onSuccess?: (data: OnSuccessData<SwapPreparedQuote>) => void;
@@
-    onSuccess?: (data: {
-      quote: BuyOrOnrampPrepareResult;
-      statuses: CompletedStatusResult[];
-    }) => void;
+    onSuccess?: (data: OnSuccessData<BuyOrOnrampPrepareResult>) => void;

58-61: Same suggestion applies here (reuse alias).

📜 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 e830109 and c227e12.

📒 Files selected for processing (9)
  • .changeset/strong-buses-love.md (1 hunks)
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx (2 hunks)
  • apps/portal/src/app/bridge/bridge-widget-script/page.mdx (2 hunks)
  • packages/thirdweb/src/exports/react.ts (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (2 hunks)
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
.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/strong-buses-love.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:

  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx
  • packages/thirdweb/src/exports/react.ts
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.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/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx
  • packages/thirdweb/src/exports/react.ts
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.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/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx
  • packages/thirdweb/src/exports/react.ts
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
packages/thirdweb/src/exports/**

📄 CodeRabbit inference engine (CLAUDE.md)

packages/thirdweb/src/exports/**: Export everything via exports/ directory, grouped by feature in the SDK public API
Every public symbol must have comprehensive TSDoc with at least one @example block that compiles and custom annotation tags (@beta, @internal, @experimental)

Files:

  • packages/thirdweb/src/exports/react.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/dashboard/src/@/components/blocks/BuyAndSwapEmbed.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)
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/@/components/blocks/BuyAndSwapEmbed.tsx
apps/{dashboard,playground}/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Expose a className prop on the root element of every component

Files:

  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx
🧠 Learnings (6)
📓 Common learnings
Learnt from: MananTank
PR: thirdweb-dev/js#8106
File: packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx:34-41
Timestamp: 2025-09-24T11:08:43.783Z
Learning: In BridgeWidgetProps for packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx, the Swap onError callback signature requires a non-undefined SwapPreparedQuote parameter (unlike Buy's onError which allows undefined quote). This is intentional - SwapWidget's onError is only called when a quote is available.
📚 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 .changeset/*.md : Version bump rules: patch for non‑API changes; minor for new/modified public API

Applied to files:

  • .changeset/strong-buses-love.md
📚 Learning: 2025-09-24T11:08:43.783Z
Learnt from: MananTank
PR: thirdweb-dev/js#8106
File: packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx:34-41
Timestamp: 2025-09-24T11:08:43.783Z
Learning: In BridgeWidgetProps for packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx, the Swap onError callback signature requires a non-undefined SwapPreparedQuote parameter (unlike Buy's onError which allows undefined quote). This is intentional - SwapWidget's onError is only called when a quote is available.

Applied to files:

  • .changeset/strong-buses-love.md
  • apps/portal/src/app/bridge/bridge-widget-script/page.mdx
  • packages/thirdweb/src/script-exports/bridge-widget-script.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx
  • apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.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/exports/react.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/exports/react.native.ts : React Native specific exports are in `src/exports/react.native.ts`

Applied to files:

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

Applied to files:

  • packages/thirdweb/src/exports/react.ts
🧬 Code graph analysis (5)
packages/thirdweb/src/script-exports/bridge-widget-script.tsx (3)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • SwapPreparedQuote (154-157)
packages/thirdweb/src/exports/react.ts (2)
  • CompletedStatusResult (81-81)
  • BuyOrOnrampPrepareResult (138-138)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (1)
  • BuyOrOnrampPrepareResult (40-43)
packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx (3)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • SwapPreparedQuote (154-157)
packages/thirdweb/src/exports/react.ts (2)
  • CompletedStatusResult (81-81)
  • BuyOrOnrampPrepareResult (138-138)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (1)
  • BuyOrOnrampPrepareResult (40-43)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (2)
packages/thirdweb/src/exports/react.ts (2)
  • BuyOrOnrampPrepareResult (138-138)
  • CompletedStatusResult (81-81)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
  • CompletedStatusResult (19-26)
packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (1)
packages/thirdweb/src/exports/react.ts (2)
  • BridgePrepareResult (76-76)
  • CompletedStatusResult (81-81)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (2)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • SwapPreparedQuote (154-157)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
  • CompletedStatusResult (19-26)
🪛 GitHub Check: codecov/patch
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx

[warning] 622-625: packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx#L622-L625
Added lines #L622 - L625 were not covered by tests

⏰ 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: Analyze (javascript)
🔇 Additional comments (12)
.changeset/strong-buses-love.md (2)

1-3: Correct bump level for public API change.

Minor bump aligns with modified callback signature. Looks good.


5-14: Clear changeset example.

Example correctly demonstrates new { statuses, quote } payload.

packages/thirdweb/src/exports/react.ts (3)

76-76: Type export looks correct.


81-81: Type export looks correct.


138-139: Public alias export added properly.

Ensure the alias’ defining site includes TSDoc (see note in BuyWidget comment).

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

471-474: LGTM: passes { quote, statuses } to onSuccess.

packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (1)

666-669: LGTM: calls onSuccess with { quote, statuses }.

packages/thirdweb/src/script-exports/bridge-widget-script.tsx (1)

10-10: Type-only import is correct.

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

16-16: LGTM!

The import of CompletedStatusResult is correctly added to support the updated onSuccess callback signatures.


179-182: Verify all external invocations of BridgeWidget’s buy.onSuccess
No occurrences found via automated search; manually confirm that any consumers handle the new { quote, statuses } signature.


86-89: Ensure all BridgeWidget swap.onSuccess consumers are updated
The onSuccess callback now receives { quote, statuses } instead of just quote. This is a breaking change—verify every usage handles the new object signature.

apps/portal/src/app/bridge/bridge-widget-script/page.mdx (1)

107-110: LGTM!

The main Options type definition correctly documents the updated onSuccess callback signatures for both swap and buy, accurately reflecting the breaking API changes.

Also applies to: 138-141

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 16, 2025

Merge activity

  • Oct 16, 4:37 PM UTC: MananTank added this pull request to the Graphite merge queue.
  • Oct 16, 4:52 PM UTC: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Unit Tests').

graphite-app bot pushed a commit that referenced this pull request Oct 16, 2025
…apWidget, BridgeWidget components (#8259)

<!--

## 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 updates the `onSuccess` prop across multiple components to include both `statuses` and `quote` objects, enhancing the data returned upon successful transactions.

### Detailed summary
- Updated `onSuccess` prop in `BuyWidget`, `CheckoutWidget`, `SwapWidget`, and `BridgeWidget` to accept an object with `quote` and `statuses`.
- Adjusted the implementation in `BuyAndSwapEmbed`, `BridgeWidgetContent`, `CheckoutWidgetContent`, and `SwapWidgetContent` to utilize the new structure.
- Modified type definitions to reflect the changes in the `onSuccess` prop across various components.

> ✨ 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**
  * onSuccess callbacks for Buy, Checkout, Swap, and Bridge widgets now return an object containing the quote and an array of completion statuses.
  * Added public type exports for richer typing: BridgePrepareResult, CompletedStatusResult, and BuyOrOnrampPrepareResult.

* **Documentation**
  * Updated guides and examples to show the new onSuccess payload shape and recommended destructuring usage in callbacks.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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/BuyWidget.tsx (1)

622-625: Verify test coverage for the updated onSuccess invocation.

The implementation correctly passes { quote, statuses } to onSuccess. However, as noted in a previous review, these lines lack test coverage. Consider adding a test that verifies onSuccess is called with the correct payload structure upon completion.

#!/bin/bash
# Search for existing tests covering BuyWidget onSuccess callback
rg -n "BuyWidget" --type ts --type tsx -g "*.{test,spec}.{ts,tsx}" -A 10 -B 2 | head -100
🧹 Nitpick comments (1)
apps/portal/src/app/bridge/bridge-widget-script/page.mdx (1)

107-110: Documentation correctly reflects the API change.

The type definitions for swap.onSuccess and buy.onSuccess have been updated to show they now receive an object containing both quote and statuses. This correctly documents the breaking change.

Consider adding a usage example showing how to access both fields:

#### Example: Accessing quote and statuses in onSuccess

```js
BridgeWidget.render(container, {
  clientId: "your-thirdweb-client-id",
  swap: {
    onSuccess: (data) => {
      console.log("Quote:", data.quote);
      console.log("Statuses:", data.statuses);
      // Process completion statuses for additional logic
    },
  },
});


Also applies to: 138-141

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**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.

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between c227e12023f59b7b4803f592ada95ff756699124 and 58c5ac874de91d560971adb235b5a2d6d47b479d.

</details>

<details>
<summary>📒 Files selected for processing (9)</summary>

* `.changeset/strong-buses-love.md` (1 hunks)
* `apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx` (2 hunks)
* `apps/portal/src/app/bridge/bridge-widget-script/page.mdx` (2 hunks)
* `packages/thirdweb/src/exports/react.ts` (2 hunks)
* `packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx` (2 hunks)
* `packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx` (2 hunks)
* `packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx` (3 hunks)
* `packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx` (2 hunks)
* `packages/thirdweb/src/script-exports/bridge-widget-script.tsx` (3 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (3)</summary>

* .changeset/strong-buses-love.md
* packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx
* packages/thirdweb/src/script-exports/bridge-widget-script.tsx

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>📓 Path-based instructions (7)</summary>

<details>
<summary>**/*.{ts,tsx}</summary>


**📄 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/Bridge/swap-widget/SwapWidget.tsx`
- `apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx`
- `packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx`
- `packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx`
- `packages/thirdweb/src/exports/react.ts`

</details>
<details>
<summary>**/*.{ts,tsx,js,jsx}</summary>


**📄 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/Bridge/swap-widget/SwapWidget.tsx`
- `apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx`
- `packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx`
- `packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx`
- `packages/thirdweb/src/exports/react.ts`

</details>
<details>
<summary>packages/thirdweb/**/*.{ts,tsx}</summary>


**📄 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`
- `packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx`
- `packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx`
- `packages/thirdweb/src/exports/react.ts`

</details>
<details>
<summary>apps/{dashboard,playground-web}/**/*.{ts,tsx}</summary>


**📄 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/@/components/blocks/BuyAndSwapEmbed.tsx`

</details>
<details>
<summary>apps/{dashboard,playground}/**/*.{ts,tsx}</summary>


**📄 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/@/components/blocks/BuyAndSwapEmbed.tsx`

</details>
<details>
<summary>apps/{dashboard,playground}/**/*.tsx</summary>


**📄 CodeRabbit inference engine (AGENTS.md)**

> Expose a `className` prop on the root element of every component

Files:
- `apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx`

</details>
<details>
<summary>packages/thirdweb/src/exports/**</summary>


**📄 CodeRabbit inference engine (CLAUDE.md)**

> `packages/thirdweb/src/exports/**`: Export everything via `exports/` directory, grouped by feature in the SDK public API
> Every public symbol must have comprehensive TSDoc with at least one `@example` block that compiles and custom annotation tags (`@beta`, `@internal`, `@experimental`)

Files:
- `packages/thirdweb/src/exports/react.ts`

</details>

</details><details>
<summary>🧠 Learnings (5)</summary>

<details>
<summary>📓 Common learnings</summary>

Learnt from: MananTank
PR: #8106
File: packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx:34-41
Timestamp: 2025-09-24T11:08:43.783Z
Learning: In BridgeWidgetProps for packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx, the Swap onError callback signature requires a non-undefined SwapPreparedQuote parameter (unlike Buy's onError which allows undefined quote). This is intentional - SwapWidget's onError is only called when a quote is available.


</details>
<details>
<summary>📚 Learning: 2025-09-24T11:08:43.783Z</summary>

Learnt from: MananTank
PR: #8106
File: packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx:34-41
Timestamp: 2025-09-24T11:08:43.783Z
Learning: In BridgeWidgetProps for packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx, the Swap onError callback signature requires a non-undefined SwapPreparedQuote parameter (unlike Buy's onError which allows undefined quote). This is intentional - SwapWidget's onError is only called when a quote is available.


**Applied to files:**
- `apps/portal/src/app/bridge/bridge-widget-script/page.mdx`
- `packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx`
- `apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx`
- `packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx`
- `packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx`

</details>
<details>
<summary>📚 Learning: 2025-06-17T18:30:52.976Z</summary>

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


**Applied to files:**
- `packages/thirdweb/src/exports/react.ts`

</details>
<details>
<summary>📚 Learning: 2025-07-18T19:19:55.613Z</summary>

Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to src/exports/react.native.ts : React Native specific exports are in src/exports/react.native.ts


**Applied to files:**
- `packages/thirdweb/src/exports/react.ts`

</details>
<details>
<summary>📚 Learning: 2025-10-03T23:36:00.631Z</summary>

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


**Applied to files:**
- `packages/thirdweb/src/exports/react.ts`

</details>

</details><details>
<summary>🧬 Code graph analysis (3)</summary>

<details>
<summary>packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (2)</summary><blockquote>

<details>
<summary>packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)</summary>

* `SwapPreparedQuote` (154-157)

</details>
<details>
<summary>packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)</summary>

* `CompletedStatusResult` (19-26)

</details>

</blockquote></details>
<details>
<summary>packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (1)</summary><blockquote>

<details>
<summary>packages/thirdweb/src/exports/react.ts (2)</summary>

* `BridgePrepareResult` (76-76)
* `CompletedStatusResult` (81-81)

</details>

</blockquote></details>
<details>
<summary>packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (2)</summary><blockquote>

<details>
<summary>packages/thirdweb/src/exports/react.ts (2)</summary>

* `BuyOrOnrampPrepareResult` (138-138)
* `CompletedStatusResult` (81-81)

</details>
<details>
<summary>packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)</summary>

* `CompletedStatusResult` (19-26)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>⏰ 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)</summary>

* GitHub Check: E2E Tests (pnpm, webpack)
* GitHub Check: Size
* GitHub Check: Lint Packages
* GitHub Check: Analyze (javascript)

</details>

<details>
<summary>🔇 Additional comments (7)</summary><blockquote>

<details>
<summary>apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx (1)</summary><blockquote>

`150-150`: **LGTM!**

The `onSuccess` handlers have been correctly updated to destructure `quote` from the new object parameter shape `{ quote, statuses }`. The implementation is consistent across both `BuyWidget` and `SwapWidget`.




Also applies to: 211-211

</blockquote></details>
<details>
<summary>packages/thirdweb/src/exports/react.ts (1)</summary><blockquote>

`76-76`: **LGTM!**

The type exports correctly expose `BridgePrepareResult`, `CompletedStatusResult`, and `BuyOrOnrampPrepareResult` to the public API surface, enabling consumers to properly type their `onSuccess` handlers with the new payload structure.




Also applies to: 81-81, 138-138

</blockquote></details>
<details>
<summary>packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (1)</summary><blockquote>

`161-164`: **LGTM!**

The `onSuccess` prop signature has been correctly updated to accept an object containing both `quote` and `statuses`, aligning with the PR objective to include transaction info in the callback.

</blockquote></details>
<details>
<summary>packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (2)</summary><blockquote>

`173-176`: **LGTM!**

The `onSuccess` prop signature has been correctly updated to accept an object containing both `quote` and `statuses`, consistent with the changes across all widget components.

---

`666-669`: **LGTM!**

The `onSuccess` callback is correctly invoked with the composite payload `{ quote, statuses }`, providing consumers with both the quote and completion statuses.

</blockquote></details>
<details>
<summary>packages/thirdweb/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx (2)</summary><blockquote>

`148-151`: **LGTM!**

The `onSuccess` prop signature has been correctly updated to accept an object containing both `quote` and `statuses`, maintaining consistency with the other widget components.

---

`471-474`: **LGTM!**

The `onSuccess` callback is correctly invoked with the composite payload `{ quote, statuses }`, consistent with the implementation across all widget components.

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

…apWidget, BridgeWidget components (#8259)

<!--

## 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 updates the `onSuccess` prop across several components to include both `statuses` and `quote` objects, enhancing the data provided upon successful transactions.

### Detailed summary
- Updated `onSuccess` prop in `BuyWidget`, `CheckoutWidget`, `SwapWidget`, and `BridgeWidget` to accept an object containing `quote` and `statuses`.
- Modified the implementation in `BuyAndSwapEmbed` to destructure the `quote`.
- Adjusted type definitions for `onSuccess` in various components to reflect the new structure.

> ✨ 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**
  * onSuccess callbacks for Buy, Checkout, Swap and Bridge widgets now return an object containing the quote plus an array of completion statuses.
  * Added public type exports to improve typing: BridgePrepareResult, CompletedStatusResult, and BuyOrOnrampPrepareResult.

* **Documentation**
  * Updated guides and examples to demonstrate the new onSuccess payload shape and recommended destructuring usage in callbacks.
<!-- 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

Dashboard Involves changes to the Dashboard. packages Portal Involves changes to the Portal (docs) codebase. SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants