Skip to content

[SDK] Respect feePayer property in Payment widgets #7533

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

Merged
merged 1 commit into from
Jul 6, 2025

Conversation

joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Jul 6, 2025

Fixes #7518


PR-Codex overview

This PR focuses on enhancing payment widget functionality by properly respecting the feePayer property and incorporating uiOptions into various components for better payment handling.

Detailed summary

  • Updated PayEmbed.tsx to set feePayer based on props.payOptions.paymentInfo.feePayer.
  • Added uiOptions prop to BridgeOrchestrator.
  • Modified QuoteLoader to accept uiOptions and derive feePayer and mode from it.

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

Summary by CodeRabbit

  • Bug Fixes

    • Payment widgets now properly respect the feePayer setting, ensuring accurate fee handling during transactions.
  • Refactor

    • Improved configuration management in payment and bridge widgets by consolidating multiple options into a single settings object for better maintainability and clarity.

Copy link

changeset-bot bot commented Jul 6, 2025

🦋 Changeset detected

Latest commit: 26abea8

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

vercel bot commented Jul 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 6, 2025 8:14am
nebula ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 6, 2025 8:14am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 6, 2025 8:14am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 6, 2025 8:14am
wallet-ui 🛑 Canceled (Inspect) Jul 6, 2025 8:14am

Copy link
Contributor

coderabbitai bot commented Jul 6, 2025

"""

Walkthrough

The changes refactor how the feePayer and mode options are passed to the QuoteLoader component within the thirdweb payment widget. Instead of being individual props, these options are now encapsulated within a uiOptions object, centralizing configuration and updating internal logic to respect the feePayer property during payment processing. Additionally, PayEmbed now conditionally passes the feePayer prop to CheckoutWidget when in "direct_payment" mode.

Changes

File(s) Change Summary
packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx Updated to pass uiOptions prop (instead of separate mode) to QuoteLoader.
packages/thirdweb/src/react/web/ui/Bridge/QuoteLoader.tsx Refactored QuoteLoaderProps to accept uiOptions instead of separate feePayer and mode props. Logic updated to extract feePayer and mode from uiOptions.
packages/thirdweb/src/react/web/ui/PayEmbed.tsx Added conditional passing of feePayer prop to CheckoutWidget when payOptions.mode is "direct_payment".
.changeset/angry-dragons-smash.md Added changeset describing the patch update and its focus on respecting feePayer in payment widgets.

Sequence Diagram(s)

sequenceDiagram
    participant BridgeOrchestrator
    participant QuoteLoader
    participant PaymentWidgetLogic
    participant PayEmbed
    participant CheckoutWidget

    BridgeOrchestrator->>QuoteLoader: Pass uiOptions (includes mode, feePayer)
    QuoteLoader->>QuoteLoader: Extract mode, feePayer from uiOptions
    QuoteLoader->>PaymentWidgetLogic: Process payment with correct feePayer logic

    PayEmbed->>CheckoutWidget: Pass feePayer if mode == "direct_payment"
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure feePayer="seller" prevents fee from being added to sender amount (#7518)
Refactor to centralize feePayer and mode handling via uiOptions object (#7518)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found.
"""

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

📥 Commits

Reviewing files that changed from the base of the PR and between 565b67d and 26abea8.

📒 Files selected for processing (4)
  • .changeset/angry-dragons-smash.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/QuoteLoader.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/PayEmbed.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • .changeset/angry-dragons-smash.md
  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/QuoteLoader.tsx
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{ts,tsx}`: Write idiomatic TypeScript with explicit function declarations ...

**/*.{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
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

📄 Source: CodeRabbit Inference Engine (CLAUDE.md)

List of files the instruction was applied to:

  • packages/thirdweb/src/react/web/ui/PayEmbed.tsx
🧠 Learnings (2)
📓 Common learnings
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.
packages/thirdweb/src/react/web/ui/PayEmbed.tsx (5)
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.
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/wallets/**/*.{ts,tsx} : Support for in-app wallets (social/email login) in wallet architecture
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/wallets/**/*.{ts,tsx} : Support EIP-1193, EIP-5792, EIP-7702 standards in wallet architecture
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{tsx,ts} : Client Components: Handle interactive UI with React hooks (`useState`, `useEffect`, React Query, wallet hooks)
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-06-30T10:26:04.389Z
Learning: Applies to dashboard/**/components/*.client.tsx : Interactive UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks).
🔇 Additional comments (1)
packages/thirdweb/src/react/web/ui/PayEmbed.tsx (1)

383-385: feePayer is already part of PaymentInfo—no type error

The PaymentInfo type in ConnectButtonProps.ts includes

feePayer?: "sender" | "receiver";

so accessing props.payOptions.paymentInfo.feePayer is fully type-safe. You can safely drop the ad-hoc cast on paymentInfo when reading .amount and rely on the built-in typing:

• File: packages/thirdweb/src/react/web/ui/PayEmbed.tsx
Replace:

-       amount={(props.payOptions.paymentInfo as { amount: string }).amount}
+       amount={props.payOptions.paymentInfo.amount}
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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 Jul 6, 2025
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.

@joaquim-verges joaquim-verges changed the title Respect feePayer property in Payment widgets [SDK] Respect feePayer property in Payment widgets Jul 6, 2025
@joaquim-verges joaquim-verges marked this pull request as ready for review July 6, 2025 07:54
@joaquim-verges joaquim-verges requested review from a team as code owners July 6, 2025 07:54
@joaquim-verges joaquim-verges force-pushed the Respect_feePayer_property_in_Payment_widgets branch from 565b67d to 7d8e1d2 Compare July 6, 2025 07:56
Copy link
Contributor

github-actions bot commented Jul 6, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.2 KB (0%) 1.3 s (0%) 206 ms (+74.03% 🔺) 1.5 s
thirdweb (cjs) 352.68 KB (0%) 7.1 s (0%) 943 ms (+6.13% 🔺) 8 s
thirdweb (minimal + tree-shaking) 5.69 KB (0%) 114 ms (0%) 88 ms (+1096.44% 🔺) 202 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 10 ms (+250% 🔺) 20 ms
thirdweb/react (minimal + tree-shaking) 19.57 KB (0%) 392 ms (0%) 54 ms (+247.77% 🔺) 446 ms

@joaquim-verges joaquim-verges merged commit cb77544 into main Jul 6, 2025
19 of 22 checks passed
@joaquim-verges joaquim-verges deleted the Respect_feePayer_property_in_Payment_widgets branch July 6, 2025 08:08
@joaquim-verges joaquim-verges mentioned this pull request Jul 6, 2025
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.

feePayer="seller" still adds fee to sender amount in CheckoutWidget
1 participant