Skip to content

SDK: Fix PayEmbed not rendering anything when mode prop is not set #7858

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

MananTank
Copy link
Member

@MananTank MananTank commented Aug 14, 2025


PR-Codex overview

This PR focuses on enhancing the PayEmbed component in the thirdweb package by fixing the default behavior when the mode prop is not specified and adding multiple storybook examples for various payment scenarios.

Detailed summary

  • Default mode set to "fund_wallet" with amount: "0.01" and chain: ethereum when not specified.
  • Updated logic in PayEmbed to handle payOptions.
  • Added multiple storybook stories for:
    • Basic usage.
    • Fund wallet with and without metadata.
    • Direct payment scenarios with and without metadata.
    • Transaction scenarios with and without metadata.
    • Light mode and custom light theme options.

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

Summary by CodeRabbit

  • Bug Fixes

    • PayEmbed now defaults to a wallet-funding flow when mode is missing (amount 0.01; Ethereum chain) and tolerates partial prefill data.
  • Enhancements

    • Buy flow renders more flexibly when mode is omitted or set to fund_wallet.
  • Documentation

    • Storybook reorganized with a richer PayEmbed stories set (fund wallet, direct payments, transactions, ERC20, metadata, themes); older story variants removed.
  • Tests

    • Existing PayEmbed test suites for connected and disconnected states were removed.
  • Chores

    • Added a changeset for a patch release.

Copy link

vercel bot commented Aug 14, 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 Aug 15, 2025 11:36pm
nebula Ready Ready Preview Comment Aug 15, 2025 11:36pm
thirdweb_playground Ready Ready Preview Comment Aug 15, 2025 11:36pm
thirdweb-www Ready Ready Preview Comment Aug 15, 2025 11:36pm
wallet-ui Ready Ready Preview Comment Aug 15, 2025 11:36pm

Copy link

changeset-bot bot commented Aug 14, 2025

🦋 Changeset detected

Latest commit: 7f11657

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

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

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

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

Copy link
Contributor

coderabbitai bot commented Aug 14, 2025

Walkthrough

Adds a changeset documenting PayEmbed defaults; updates PayEmbed to render BuyWidget when mode is omitted (defaults amount "0.01" and chain ethereum) and uses optional chaining for prefill fields; replaces a TS Storybook file with a new TSX stories module; deletes two PayEmbed test files.

Changes

Cohort / File(s) Summary
PayEmbed UI logic
packages/thirdweb/src/react/web/ui/PayEmbed.tsx
Broadened render condition to include missing mode; use optional chaining for payOptions?.prefillBuy; default amount to "0.01", default chain to imported ethereum, and safely read token?.address; added ethereum import.
Storybook stories
packages/thirdweb/src/stories/PayEmbed.stories.ts (removed), packages/thirdweb/src/stories/PayEmbed.stories.tsx (added)
Removed old TS stories file; added comprehensive TSX stories module exporting many PayEmbed variants (basic, metadata, fund_wallet variants including ERC20/prefill, direct_payment variants, transaction variants, and theme examples) and default meta.
Tests removed
packages/thirdweb/src/react/web/ui/PayEmbed.test.tsx (removed), packages/thirdweb/src/react/web/ui/PayEmbed-disconnected.test.tsx (removed)
Deleted Vitest test suites for connected and disconnected PayEmbed states (gated by env), removing assertions around Connect/Continue button behavior and input interactions.
Changeset
.changeset/cold-pigs-dress.md
Added patch changeset for thirdweb documenting PayEmbed default behavior when mode is omitted (mode defaults to fund_wallet, amount 0.01, chain ethereum).

Sequence Diagram(s)

sequenceDiagram
  participant App as App
  participant PayEmbed as PayEmbed
  participant BuyWidget as BuyWidget

  App->>PayEmbed: render(props)
  alt mode is undefined or "fund_wallet"
    PayEmbed->>BuyWidget: render({ amount: props?.payOptions?.prefillBuy?.amount || "0.01", chain: props?.payOptions?.prefillBuy?.chain || ethereum, tokenAddress: props?.payOptions?.prefillBuy?.token?.address })
  else
    PayEmbed-->>App: render alternate UI for other modes
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

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.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • 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 6949483 and 7f11657.

📒 Files selected for processing (6)
  • .changeset/cold-pigs-dress.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/PayEmbed-disconnected.test.tsx (0 hunks)
  • packages/thirdweb/src/react/web/ui/PayEmbed.test.tsx (0 hunks)
  • packages/thirdweb/src/react/web/ui/PayEmbed.tsx (3 hunks)
  • packages/thirdweb/src/stories/PayEmbed.stories.ts (0 hunks)
  • packages/thirdweb/src/stories/PayEmbed.stories.tsx (1 hunks)
💤 Files with no reviewable changes (3)
  • packages/thirdweb/src/react/web/ui/PayEmbed-disconnected.test.tsx
  • packages/thirdweb/src/react/web/ui/PayEmbed.test.tsx
  • packages/thirdweb/src/stories/PayEmbed.stories.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/cold-pigs-dress.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/thirdweb/src/stories/PayEmbed.stories.tsx
  • packages/thirdweb/src/react/web/ui/PayEmbed.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: Analyze (javascript)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 08-15-sdk_fix_payembed_not_rendering_anything_when_mode_prop_is_not_set

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Aug 14, 2025
@MananTank MananTank marked this pull request as ready for review August 14, 2025 20:10
@MananTank MananTank requested review from a team as code owners August 14, 2025 20:10
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.

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

🔭 Outside diff range comments (1)
packages/thirdweb/src/react/web/ui/PayEmbed.tsx (1)

332-354: Default-to-fund_wallet behavior: good; prefer nullish coalescing for fallbacks

The broadened condition to render BuyWidget when mode is omitted or "fund_wallet" matches the PR goal. For the defaults, prefer ?? over || so we only fall back on null/undefined and not on other falsy-but-valid values (e.g., empty string).

-        amount={props.payOptions?.prefillBuy?.amount || "0.01"}
-        chain={props.payOptions?.prefillBuy?.chain || ethereum}
+        amount={props.payOptions?.prefillBuy?.amount ?? "0.01"}
+        chain={props.payOptions?.prefillBuy?.chain ?? ethereum}

Nit: Consider updating the component JSDoc “Default configuration” section above to mention the default amount ("0.01") and fallback chain (ethereum) to keep docs in sync. Happy to draft that if helpful.

🧹 Nitpick comments (4)
.changeset/cold-pigs-dress.md (1)

1-5: Changelog entry reads well; minor clarity nit

Consider tightening the phrasing and using code formatting for props/values to make the note clearer in release notes.

-Fix PayEmbed UI when mode prop is not specified - Default to mode: "fund_wallet" with amount: "0.01" and chain: ethereum
+Fix PayEmbed UI when the `mode` prop is omitted. Default behavior: `mode: "fund_wallet"`, `amount: "0.01"`, `chain: ethereum`.
packages/thirdweb/src/react/web/ui/PayEmbed.tsx (1)

350-351: Avoid unnecessary type assertions if possible

If prefillBuy.token.address is already typed as Address, the as Address | undefined assertion isn’t needed. If it’s a plain string, consider tightening the PayUIOptions.prefillBuy.token.address type to Address so we can drop the assertion and catch invalid addresses at compile time.

packages/thirdweb/src/stories/PayEmbed.stories.tsx (2)

10-19: Add component to meta for better inference and docs

Adding component: PayEmbed to meta improves arg type inference and autodocs rendering across Storybook versions.

-const meta = {
+const meta = {
+  component: PayEmbed,
   args: {
     client: storyClient,
   },
   parameters: {
     layout: "centered",
   },
   tags: ["autodocs"],
   title: "Connect/PayEmbed",
 } satisfies Meta<typeof PayEmbed>;

21-217: Deduplicate client prop via meta.args and annotate return types

  • You already set client in meta.args; you can remove client={storyClient} from each story to reduce repetition.
  • Per repo guidelines, add explicit return types to exported story functions.

Example refactor for a couple of stories:

-export function BasicUsage() {
-  return <PayEmbed client={storyClient} />;
+export function BasicUsage(): JSX.Element {
+  return <PayEmbed />;
 }
 
-export function BasicUsageWithMetadata() {
+export function BasicUsageWithMetadata(): JSX.Element {
   return (
     <PayEmbed
-      client={storyClient}
       payOptions={{
         metadata: {
           name: "this is a title",
           // This is not shown in UI - TODO fix this
           description: "this is a description",
         },
       }}
     />
   );
 }

Apply the same pattern to the remaining stories for consistency. If you prefer keeping explicit client props in stories, consider removing meta.args.client instead.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 98eefdf and 3009c69.

📒 Files selected for processing (4)
  • .changeset/cold-pigs-dress.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/PayEmbed.tsx (3 hunks)
  • packages/thirdweb/src/stories/PayEmbed.stories.ts (0 hunks)
  • packages/thirdweb/src/stories/PayEmbed.stories.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/thirdweb/src/stories/PayEmbed.stories.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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

Files:

  • packages/thirdweb/src/react/web/ui/PayEmbed.tsx
  • packages/thirdweb/src/stories/PayEmbed.stories.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/PayEmbed.tsx
  • packages/thirdweb/src/stories/PayEmbed.stories.tsx
**/*.stories.tsx

📄 CodeRabbit Inference Engine (CLAUDE.md)

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

Files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • packages/thirdweb/src/stories/PayEmbed.stories.tsx
⏰ 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: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/thirdweb/src/react/web/ui/PayEmbed.tsx (1)

4-4: Fallback chain import LGTM

Importing ethereum as the default fallback chain aligns with the new default behavior and avoids null/undefined issues when no chain is provided.

Copy link
Contributor

github-actions bot commented Aug 14, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.06 KB (0%) 1.3 s (0%) 258 ms (+108.17% 🔺) 1.6 s
thirdweb (cjs) 357.05 KB (0%) 7.2 s (0%) 949 ms (+5.79% 🔺) 8.1 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 76 ms (+1048.86% 🔺) 191 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 65 ms (+2809.01% 🔺) 75 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 103 ms (+528.53% 🔺) 485 ms

Copy link

codecov bot commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.54%. Comparing base (d227bc3) to head (7f11657).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7858      +/-   ##
==========================================
+ Coverage   56.33%   56.54%   +0.21%     
==========================================
  Files         907      904       -3     
  Lines       58965    58586     -379     
  Branches     4159     4140      -19     
==========================================
- Hits        33216    33126      -90     
+ Misses      25643    25354     -289     
  Partials      106      106              
Flag Coverage Δ
packages 56.54% <ø> (+0.21%) ⬆️
see 7 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
packages/thirdweb/src/stories/PayEmbed.stories.tsx (1)

1-1: Switch Storybook type import to @storybook/react (not @storybook/react-vite).

Unifies typings across the repo and avoids version-specific type resolution issues.

-import type { Meta } from "@storybook/react-vite";
+import type { Meta } from "@storybook/react";
🧹 Nitpick comments (3)
packages/thirdweb/src/stories/PayEmbed.stories.tsx (3)

10-16: Add component: PayEmbed to meta for proper autodocs and controls.

Without component, Storybook may not link docs/controls correctly even with satisfies Meta<typeof PayEmbed>.

 const meta = {
   parameters: {
     layout: "centered",
   },
   tags: ["autodocs"],
+  component: PayEmbed,
   title: "Connect/PayEmbed",
 } satisfies Meta<typeof PayEmbed>;

Optional: You can also DRY the stories by setting default args here:

// Example
args: { client: storyClient },

…and drop client={storyClient} from individual stories.


18-21: Add explicit return types to story functions.

Guideline for TS/TSX: explicit return types. Declare : JSX.Element on each exported story.

-export function BasicUsage() {
+export function BasicUsage(): JSX.Element {
   return <PayEmbed client={storyClient} />;
 }
 
-export function BasicUsageWithMetadata() {
+export function BasicUsageWithMetadata(): JSX.Element {
   return (
     <PayEmbed
       client={storyClient}
       payOptions={{
         metadata: {
           name: "this is a title",
           // This is not shown in UI - TODO fix this
           description: "this is a description",
         },
       }}
     />
   );
 }
 
-export function FundWallet() {
+export function FundWallet(): JSX.Element {
   return (
     <PayEmbed
       client={storyClient}
       payOptions={{
         mode: "fund_wallet",
       }}
     />
   );
 }
 
-export function FundWalletWithMetadata() {
+export function FundWalletWithMetadata(): JSX.Element {
   return (
     <PayEmbed
       client={storyClient}
       payOptions={{
         mode: "fund_wallet",
         metadata: {
           name: "this is a title",
           // This is not shown in UI - TODO fix this
           description: "this is a description",
         },
       }}
     />
   );
 }
 
-export function FundWalletWithOptions() {
+export function FundWalletWithOptions(): JSX.Element {
   return (
     <PayEmbed
       client={storyClient}
       payOptions={{
         mode: "fund_wallet",
         prefillBuy: {
           amount: "0.123",
           chain: polygon,
         },
       }}
     />
   );
 }
 
-export function FundWalletERC20() {
+export function FundWalletERC20(): JSX.Element {
   return (
     <PayEmbed
       client={storyClient}
       payOptions={{
         mode: "fund_wallet",
         prefillBuy: {
           amount: "0.123",
           chain: base,
           token: {
             address: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
             name: "USDC",
             // This icon is not being used - TODO fix this, either remove this prop or use it
             icon: "https://picsum.photos/200/200",
           },
         },
       }}
     />
   );
 }
 
-export function DirectPayment() {
+export function DirectPayment(): JSX.Element {
   return (
     <PayEmbed
       client={storyClient}
       payOptions={{
         mode: "direct_payment",
         paymentInfo: {
           amount: "0.123",
           chain: polygon,
           sellerAddress: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425",
         },
       }}
     />
   );
 }
 
-export function DirectPaymentERC20() {
+export function DirectPaymentERC20(): JSX.Element {
   return (
     <PayEmbed
       client={storyClient}
       payOptions={{
         mode: "direct_payment",
         paymentInfo: {
           amount: "0.123",
           chain: base,
           sellerAddress: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425",
           token: {
             address: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
             name: "USDC",
             // This icon is not being used - TODO fix this, either remove this prop or use it
             icon: "https://coin-images.coingecko.com/coins/images/6319/large/usdc.png",
           },
         },
       }}
     />
   );
 }
 
-export function DirectPaymentWithMetadata() {
+export function DirectPaymentWithMetadata(): JSX.Element {
   return (
     <PayEmbed
       client={storyClient}
       payOptions={{
         mode: "direct_payment",
         paymentInfo: {
           amount: "0.123",
           chain: polygon,
           sellerAddress: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425",
         },
         metadata: {
           name: "this is a title",
           description: "this is a description",
         },
       }}
     />
   );
 }
 
-export function Transaction() {
+export function Transaction(): JSX.Element {
   return (
     <PayEmbed
       client={storyClient}
       payOptions={{
         mode: "transaction",
         transaction: prepareTransaction({
           to: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425",
           chain: polygon,
           client: storyClient,
           value: toWei("0.123"),
         }),
       }}
     />
   );
 }
 
-export function TransactionWithMetadata() {
+export function TransactionWithMetadata(): JSX.Element {
   return (
     <PayEmbed
       client={storyClient}
       payOptions={{
         metadata: {
           name: "this is a title",
           description: "this is a description",
         },
         mode: "transaction",
         transaction: prepareTransaction({
           to: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425",
           chain: polygon,
           client: storyClient,
           value: toWei("0.123"),
         }),
       }}
     />
   );
 }
 
-export function LightMode() {
+export function LightMode(): JSX.Element {
   return <PayEmbed client={storyClient} theme="light" />;
 }
 
-export function CustomLightTheme() {
+export function CustomLightTheme(): JSX.Element {
   return (
     <PayEmbed
       client={storyClient}
       theme={lightTheme({
         colors: {
           modalBg: "#FFFFF0",
           tertiaryBg: "#DBE4C9",
           borderColor: "#8AA624",
           secondaryText: "#3E3F29",
           accentText: "#E43636",
         },
       })}
     />
   );
 }

Also applies to: 22-35, 37-46, 48-62, 64-77, 79-98, 100-114, 116-136, 138-156, 158-173, 175-194, 196-198, 200-215


27-31: Track or resolve TODOs shown in the stories (hidden description and unused token icon).

These props don’t currently affect the UI and may confuse readers of the stories/docs. Either remove them from the examples for now or open an issue to implement support.

Happy to open a tracking issue or submit a follow-up PR to either wire these through or simplify the examples.

Also applies to: 55-58, 91-93, 149-152, 181-183

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • 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 bc960e4 and 6949483.

📒 Files selected for processing (6)
  • .changeset/cold-pigs-dress.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/PayEmbed-disconnected.test.tsx (0 hunks)
  • packages/thirdweb/src/react/web/ui/PayEmbed.test.tsx (0 hunks)
  • packages/thirdweb/src/react/web/ui/PayEmbed.tsx (3 hunks)
  • packages/thirdweb/src/stories/PayEmbed.stories.ts (0 hunks)
  • packages/thirdweb/src/stories/PayEmbed.stories.tsx (1 hunks)
💤 Files with no reviewable changes (3)
  • packages/thirdweb/src/react/web/ui/PayEmbed.test.tsx
  • packages/thirdweb/src/react/web/ui/PayEmbed-disconnected.test.tsx
  • packages/thirdweb/src/stories/PayEmbed.stories.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/thirdweb/src/react/web/ui/PayEmbed.tsx
  • .changeset/cold-pigs-dress.md
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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

Files:

  • packages/thirdweb/src/stories/PayEmbed.stories.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/stories/PayEmbed.stories.tsx
**/*.stories.tsx

📄 CodeRabbit Inference Engine (CLAUDE.md)

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

Files:

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

Applied to files:

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

Applied to files:

  • packages/thirdweb/src/stories/PayEmbed.stories.tsx
🧬 Code Graph Analysis (1)
packages/thirdweb/src/stories/PayEmbed.stories.tsx (4)
packages/thirdweb/src/react/web/ui/PayEmbed.tsx (1)
  • PayEmbed (303-415)
packages/thirdweb/src/stories/utils.tsx (1)
  • storyClient (15-17)
packages/thirdweb/src/exports/chains.ts (2)
  • polygon (60-60)
  • base (17-17)
packages/thirdweb/src/exports/thirdweb.ts (1)
  • prepareTransaction (181-181)
⏰ 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: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)

Copy link
Contributor

graphite-app bot commented Aug 15, 2025

Merge activity

…7858)

<!--

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

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

## Notes for the reviewer

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

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on updating the `PayEmbed` component to default to a mode of "fund_wallet" with an amount of "0.01" and chain set to `ethereum` when no mode is specified. It also includes new story examples for the `PayEmbed` component.

### Detailed summary
- Deleted `PayEmbed.stories.ts` and test files.
- Updated `PayEmbed` component to default `mode` to "fund_wallet" and `amount` to "0.01".
- Added handling for `chain` defaulting to `ethereum`.
- Created multiple story functions for various use cases of `PayEmbed`.
- Included stories for different payment modes and configurations.

> ✨ 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

* **Bug Fixes**
  * PayEmbed now defaults to a wallet-funding flow when mode is missing (amount 0.01; Ethereum chain) and tolerates partial prefill data.

* **Enhancements**
  * Buy flow renders more flexibly when mode is omitted or set to fund_wallet.

* **Documentation**
  * Storybook updated/reorganized with comprehensive PayEmbed examples: fund wallet, direct payments, transactions, ERC20, metadata, and theme variants.

* **Chores**
  * Added a changeset for a patch release.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants