Skip to content

[SDK] Refactor: Only show user balances in payment selection screens #7827

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 2 commits into from
Aug 11, 2025

Conversation

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented Aug 11, 2025


PR-Codex overview

This PR focuses on enhancing the payment selection UI in the thirdweb package by improving how currency values are displayed and formatted, particularly in payment widgets. It introduces a new method for formatting currency amounts and updates various components to utilize this method.

Detailed summary

  • Added formatCurrencyAmount function to format currency values.
  • Updated FiatProviderSelection to use formatCurrencyAmount for displaying quote values.
  • Modified PaymentMethodTokenRow to calculate and display the currency price based on the selected currency.
  • Changed text in TokenSelection from "Select payment token" to "Your token balances".
  • Passed currency prop to PaymentMethodTokenRow and TokenSelection components for better currency management.

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

Summary by CodeRabbit

  • New Features

    • Token selection now shows fiat prices in the user’s chosen currency (USD fallback) and uses locale-aware currency formatting for provider quotes.
    • Selected currency is propagated across payment selection so pricing is consistent.
    • Token list header updated to "Your token balances" for clarity.
  • Chores

    • Added a changeset for a patch release noting “Hide quote value in payment widgets” (release-note only).

@gregfromstl gregfromstl requested review from a team as code owners August 11, 2025 02:01
Copy link

changeset-bot bot commented Aug 11, 2025

🦋 Changeset detected

Latest commit: a3b2cf6

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 Aug 11, 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 Aug 11, 2025 3:39pm
nebula ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2025 3:39pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2025 3:39pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2025 3:39pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2025 3:39pm

Copy link
Contributor

coderabbitai bot commented Aug 11, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Forwards an optional fiat currency prop through payment selection UI, adds fiat price rendering using formatted currency amounts in TokenSelection and FiatProviderSelection, updates TokenSelection props and rows to accept currency, and adds a changeset noting "Hide quote value in payment widgets."

Changes

Cohort / File(s) Summary
Release note (changeset)
./.changeset/warm-ways-decide.md
Adds a patch changeset for thirdweb with the note "Hide quote value in payment widgets."
Prop plumbing in PaymentSelection
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx
Forwards new currency prop to TokenSelection (currency={currency}) with no other logic changes.
Fiat pricing & prop additions in TokenSelection
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx
Adds currency?: SupportedFiatCurrency to TokenSelectionProps and PaymentMethodTokenRowProps; threads currency to rows; looks up `currencyPrice = originToken.prices[currency
Locale-aware fiat formatting in FiatProviderSelection
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx
Replaces manual string construction with a `formatCurrencyAmount(currency

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant PaymentSelection
  participant TokenSelection
  participant PaymentMethodTokenRow
  participant PriceMap as originToken.prices

  User->>PaymentSelection: Open payment selection (optional currency)
  PaymentSelection->>TokenSelection: Render with props including currency
  TokenSelection->>PriceMap: Lookup price by (currency || "USD")
  PriceMap-->>TokenSelection: Return currencyPrice (if available)
  TokenSelection->>PaymentMethodTokenRow: Render rows with currency and price
  PaymentMethodTokenRow-->>User: Display fiat price (if present) and token balance
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 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

📥 Commits

Reviewing files that changed from the base of the PR and between 727171c and a3b2cf6.

📒 Files selected for processing (2)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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/Bridge/payment-selection/TokenSelection.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/payment-selection/TokenSelection.tsx
🧠 Learnings (1)
📚 Learning: 2025-06-26T19:46:04.024Z
Learnt from: gregfromstl
PR: thirdweb-dev/js#7450
File: packages/thirdweb/src/bridge/Webhook.ts:57-81
Timestamp: 2025-06-26T19:46:04.024Z
Learning: In the onramp webhook schema (`packages/thirdweb/src/bridge/Webhook.ts`), the `currencyAmount` field is intentionally typed as `z.number()` while other amount fields use `z.string()` because `currencyAmount` represents fiat currency amounts in decimals (like $10.50), whereas other amount fields represent token amounts in wei (very large integers that benefit from bigint representation). The different naming convention (`currencyAmount` vs `amount`) reflects this intentional distinction.

Applied to files:

  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx
🧬 Code Graph Analysis (1)
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx (2)
packages/thirdweb/src/pay/convert/type.ts (1)
  • SupportedFiatCurrency (27-27)
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/formatTokenBalance.ts (2)
  • formatCurrencyAmount (36-38)
  • formatTokenAmount (25-34)
⏰ 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, vite)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx (3)

4-11: LGTM! Clean type imports and prop definitions.

The imports are properly typed and the optional currency prop additions to both interfaces follow TypeScript best practices with explicit typing.

Also applies to: 28-29, 39-40


96-104: LGTM! Proper currency formatting approach.

The use of formatCurrencyAmount for fiat price display is correct and follows the established patterns. The calculation logic properly converts token balance to fiat value.


131-132: LGTM! Clean prop threading and header update.

The currency prop is properly destructured, passed through to child components, and the header text change aligns with the PR objectives to focus on user balances rather than payment token selection.

Also applies to: 226-227, 249-250

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch greg/hide-quotes-payment-widget

🪧 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.
  • 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.

Support

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

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 generate unit tests to generate unit tests for 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 Aug 11, 2025
Copy link
Contributor

graphite-app bot commented Aug 11, 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.

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: 3

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a77e98a and 06eb526.

📒 Files selected for processing (3)
  • .changeset/warm-ways-decide.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx (6 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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/Bridge/payment-selection/TokenSelection.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.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/payment-selection/TokenSelection.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.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: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
.changeset/warm-ways-decide.md (1)

1-5: Changeset looks fine

Patch note is concise and appropriate for the scope.

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx (5)

4-4: Type import is appropriate

Importing SupportedFiatCurrency here is correct and keeps prop typing explicit.


25-26: Prop addition looks good

Adding currency?: SupportedFiatCurrency to TokenSelectionProps is correct.


36-37: Prop threading acknowledged

Including currency?: SupportedFiatCurrency in PaymentMethodTokenRowProps is consistent with the parent prop.


43-44: Parameter plumb-through LGTM

Threading currency into PaymentMethodTokenRow keeps data localized to where it’s rendered.


250-251: Prop forwarding LGTM

Passing currency down to each PaymentMethodTokenRow is correct.

Copy link
Contributor

github-actions bot commented Aug 11, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.03 KB (0%) 1.3 s (0%) 134 ms (+65.05% 🔺) 1.5 s
thirdweb (cjs) 357.38 KB (0%) 7.2 s (0%) 356 ms (+0.85% 🔺) 7.6 s
thirdweb (minimal + tree-shaking) 5.72 KB (0%) 115 ms (0%) 57 ms (+419.79% 🔺) 171 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 41 ms (+690.94% 🔺) 52 ms
thirdweb/react (minimal + tree-shaking) 19.16 KB (0%) 384 ms (0%) 34 ms (-1.84% 🔽) 418 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

♻️ Duplicate comments (1)
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx (1)

295-295: Prop threading looks good; align onramp PaymentMethod currency to avoid mismatches

Forwarding currency to TokenSelection is correct. However, handleOnrampProviderSelected still sets currency: "USD", which can diverge from the selected/displayed currency.

Update the onramp path to use the provided currency or default:

// In handleOnrampProviderSelected
const fiatPaymentMethod: PaymentMethod = {
  currency: currency ?? "USD",
  onramp: provider,
  payerWallet,
  type: "fiat",
};

Optionally standardize the fallback at the component boundary:

export function PaymentSelection({
  /* ... */,
  currency = "USD",
}: PaymentSelectionProps) {
  // ...
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d6ad0b1 and 727171c.

📒 Files selected for processing (4)
  • .changeset/warm-ways-decide.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx (7 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/warm-ways-decide.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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/Bridge/payment-selection/PaymentSelection.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.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/payment-selection/PaymentSelection.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx
🧠 Learnings (1)
📚 Learning: 2025-06-26T19:46:04.024Z
Learnt from: gregfromstl
PR: thirdweb-dev/js#7450
File: packages/thirdweb/src/bridge/Webhook.ts:57-81
Timestamp: 2025-06-26T19:46:04.024Z
Learning: In the onramp webhook schema (`packages/thirdweb/src/bridge/Webhook.ts`), the `currencyAmount` field is intentionally typed as `z.number()` while other amount fields use `z.string()` because `currencyAmount` represents fiat currency amounts in decimals (like $10.50), whereas other amount fields represent token amounts in wei (very large integers that benefit from bigint representation). The different naming convention (`currencyAmount` vs `amount`) reflects this intentional distinction.

Applied to files:

  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.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, webpack)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)

Copy link

codecov bot commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 7.14286% with 26 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@a77e98a). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...web/ui/Bridge/payment-selection/TokenSelection.tsx 4.54% 21 Missing ⚠️
...Bridge/payment-selection/FiatProviderSelection.tsx 20.00% 4 Missing ⚠️
...b/ui/Bridge/payment-selection/PaymentSelection.tsx 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (7.14%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7827   +/-   ##
=======================================
  Coverage        ?   56.32%           
=======================================
  Files           ?      905           
  Lines           ?    58820           
  Branches        ?     4148           
=======================================
  Hits            ?    33133           
  Misses          ?    25581           
  Partials        ?      106           
Flag Coverage Δ
packages 56.32% <7.14%> (?)
Files with missing lines Coverage Δ
...b/ui/Bridge/payment-selection/PaymentSelection.tsx 7.61% <0.00%> (ø)
...Bridge/payment-selection/FiatProviderSelection.tsx 21.73% <20.00%> (ø)
...web/ui/Bridge/payment-selection/TokenSelection.tsx 5.29% <4.54%> (ø)
🚀 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.

@gregfromstl gregfromstl merged commit 90f36bc into main Aug 11, 2025
23 of 24 checks passed
@gregfromstl gregfromstl deleted the greg/hide-quotes-payment-widget branch August 11, 2025 15:50
@joaquim-verges joaquim-verges mentioned this pull request Aug 11, 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.

2 participants