Skip to content

Refactor: UB widget inputs #7390

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 4 commits into from
Jun 19, 2025
Merged

Refactor: UB widget inputs #7390

merged 4 commits into from
Jun 19, 2025

Conversation

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented Jun 19, 2025


PR-Codex overview

This PR focuses on updating the BuyWidget and related components to use decimal strings for amounts instead of big integers, enhancing usability and consistency across the application.

Detailed summary

  • Changed buyTokenAddress to optional in types.ts.
  • Updated amount fields in various components to accept decimal strings.
  • Removed toUnits conversions in favor of direct string usage for amounts.
  • Adjusted related documentation to reflect new amount format.

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

Summary by CodeRabbit

  • New Features
    • The BuyWidget, CheckoutWidget, and TransactionWidget components now accept the amount as a decimal string (e.g., "1.5") instead of a bigint or wei value, simplifying input for users.
  • Refactor
    • Internal logic for handling token amounts has been streamlined, removing asynchronous token metadata fetching and unit conversions in relevant components.
    • The buyTokenAddress field is now optional in payment options, providing more flexibility in configuration.
    • Default token address values have been adjusted to allow undefined, enhancing configuration defaults.
  • Documentation
    • Updated component documentation and example usages to reflect the new decimal string format for amount inputs.

@gregfromstl gregfromstl requested review from a team as code owners June 19, 2025 23:20
Copy link

changeset-bot bot commented Jun 19, 2025

🦋 Changeset detected

Latest commit: a394384

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/wagmi-adapter Patch
nebula 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 Jun 19, 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 Jun 19, 2025 11:46pm
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2025 11:46pm
nebula ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2025 11:46pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2025 11:46pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2025 11:46pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2025 11:46pm

Copy link
Contributor

coderabbitai bot commented Jun 19, 2025

Walkthrough

This update refactors the handling of token amounts across several components and utilities. The amount prop is now consistently represented as a decimal string (e.g., "1.5") instead of a bigint or raw wei value. Related asynchronous logic for unit conversion and token metadata fetching is removed or simplified, and type definitions are updated accordingly.

Changes

File(s) Change Summary
.changeset/quick-foxes-raise.md Documents patch update: BuyWidget now uses decimal string format for amount.
apps/playground-web/src/app/connect/pay/components/CodeGen.tsx Removes React Query logic and token unit conversion; amount is now a string; updates function signatures and code generation logic.
apps/playground-web/src/app/connect/pay/components/types.ts Makes buyTokenAddress optional in BridgeComponentsPlaygroundOptions.payOptions.
apps/playground-web/src/app/connect/pay/embed/RightSection.tsx Removes token metadata fetching and unit conversion; passes raw string amount to widgets.
apps/playground-web/src/app/connect/pay/embed/page.tsx Removes imports for default token address utilities; sets buyTokenAddress default to undefined.
apps/playground-web/src/components/pay/direct-payment.tsx Removes toUnits import; passes amount as string instead of converted bigint.
apps/playground-web/src/components/pay/transaction-button.tsx Passes amount as string instead of bigint to TransactionWidget.
apps/playground-web/src/components/universal-bridge/buy.tsx Removes toWei import; passes amount as string instead of converted bigint to BuyWidget.
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx Changes amount prop type from bigint to string; updates documentation and usage examples; removes internal unit conversion.
packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx Changes amount prop type from bigint to string; updates documentation and removes internal unit conversion.
packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx Changes amount prop type from bigint to string; updates internal logic to fetch token decimals and convert amount to wei as needed; updates documentation and formatting.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UIComponent
    participant BuyWidget/CheckoutWidget/TransactionWidget
    participant TokenUtils

    User->>UIComponent: Provide buyTokenAmount as decimal string
    UIComponent->>BuyWidget/CheckoutWidget: Pass amount (string)
    BuyWidget/CheckoutWidget->>BuyWidget/CheckoutWidget: Use amount directly (no conversion)
    Note over BuyWidget/CheckoutWidget: No async token metadata fetching

    User->>UIComponent: Provide buyTokenAmount as decimal string
    UIComponent->>TransactionWidget: Pass amount (string)
    TransactionWidget->>TokenUtils: Fetch token decimals (if needed)
    TokenUtils-->>TransactionWidget: Return decimals
    TransactionWidget->>TransactionWidget: Convert amount string to wei using decimals
    TransactionWidget->>TransactionWidget: Prepare transaction with computed value
Loading

Possibly related PRs

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 74550bf and a394384.

📒 Files selected for processing (3)
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (8 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Size
  • GitHub Check: Build Packages
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Lint Packages
  • GitHub Check: Unit Tests
  • GitHub Check: Analyze (javascript)
✨ 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.

Copy link
Contributor

graphite-app bot commented Jun 19, 2025

How to use the Graphite Merge Queue

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

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

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

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

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

@github-actions github-actions bot added Playground Changes involving the Playground codebase. packages SDK Involves changes to the thirdweb SDK labels Jun 19, 2025
Copy link
Contributor

github-actions bot commented Jun 19, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 62.53 KB (0%) 1.3 s (0%) 460 ms (+16.76% 🔺) 1.8 s
thirdweb (cjs) 350.55 KB (0%) 7.1 s (0%) 3.3 s (+9.04% 🔺) 10.3 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 115 ms (+219.52% 🔺) 229 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 8 ms (-47.35% 🔽) 19 ms
thirdweb/react (minimal + tree-shaking) 19.59 KB (0%) 392 ms (0%) 254 ms (+410.01% 🔺) 645 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages Playground Changes involving the Playground codebase. SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant