Skip to content

[SDK] Fix: only require missing token amount for transaction widget #7591

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

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented Jul 11, 2025


PR-Codex overview

This PR focuses on fixing a regression in the TransactionWidget that incorrectly required users to pay the full amount instead of the difference from their current balance. It also includes improvements in handling token values and user balance queries.

Detailed summary

  • Fixed regression in TransactionWidget for payment amount calculation.
  • Updated getToken function to use optional chaining for erc20Value.
  • Modified total cost calculation to account for erc20Value correctly.
  • Enhanced FiatProviderSelection to format the displayed amount.
  • Added user balance query in TransactionPayment to handle async erc20Value.

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

Summary by CodeRabbit

  • Bug Fixes

    • Corrected the payment prompt in the TransactionWidget to display only the amount due after accounting for the user's current balance, instead of the full transaction amount.
  • New Features

    • Enhanced transaction details to display the user's token balance and provide more accurate cost calculations based on token type.
    • Updated payment flow to calculate and display the correct amount due by subtracting the user's balance from the total cost, ensuring no negative payment prompts.
  • Improvements

    • Applied consistent numeric formatting to token amounts for clearer display during payment selection.

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

linear bot commented Jul 11, 2025

Copy link

changeset-bot bot commented Jul 11, 2025

🦋 Changeset detected

Latest commit: dfbd33e

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 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 Jul 11, 2025 9:04am
nebula ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2025 9:04am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2025 9:04am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2025 9:04am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2025 9:04am

Copy link
Contributor

coderabbitai bot commented Jul 11, 2025

Walkthrough

A regression in the TransactionWidget was addressed by updating the payment prompt logic to require users to pay only the remaining amount after accounting for their current balance. The useTransactionDetails hook was enhanced to use optional chaining for token address retrieval, refine total cost calculations by excluding gas for non-native tokens, and improve token address handling. The payment calculation in the UI was adjusted to subtract the user's token balance from the total cost before proceeding. Additionally, token amount display formatting was improved in the fiat provider selection component.

Changes

File(s) Change Summary
.changeset/few-moments-add.md Added a changeset describing the fix for the TransactionWidget payment prompt regression.
packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts Used optional chaining for token address; refined total cost calculation excluding gas for non-native tokens.
packages/thirdweb/src/react/web/ui/Bridge/TransactionPayment.tsx Added React Query hook to fetch user token balance; adjusted payment amount calculation to subtract user balance before continuing.
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx Added numeric formatting for token amount display using a utility function.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TransactionPayment (UI)
    participant useTransactionDetails (Hook)
    participant Wallet/TokenContract

    User->>TransactionPayment (UI): Initiate transaction
    TransactionPayment (UI)->>useTransactionDetails (Hook): Fetch transaction details (including user balance)
    useTransactionDetails (Hook)->>Wallet/TokenContract: Get user balance and token info
    useTransactionDetails (Hook)-->>TransactionPayment (UI): Return transaction details with balance
    User->>TransactionPayment (UI): Click "Continue"
    TransactionPayment (UI)->>TransactionPayment (UI): Calculate amount = max(0, totalCost - userBalance)
    TransactionPayment (UI)->>onContinue: Pass (amount, tokenInfo, account)
Loading

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 75e0eab and dfbd33e.

📒 Files selected for processing (3)
  • packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionPayment.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx
  • packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionPayment.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: Size
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • 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 Jul 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

github-actions bot commented Jul 11, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.25 KB (0%) 1.3 s (0%) 214 ms (+81.9% 🔺) 1.5 s
thirdweb (cjs) 353.31 KB (0%) 7.1 s (0%) 870 ms (-2.29% 🔽) 8 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 62 ms (+928.22% 🔺) 176 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 13 ms (+510.3% 🔺) 23 ms
thirdweb/react (minimal + tree-shaking) 19.59 KB (0%) 392 ms (0%) 77 ms (+264.05% 🔺) 469 ms

Copy link

codecov bot commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 10.86957% with 41 lines in your changes missing coverage. Please review.

Project coverage is 56.46%. Comparing base (4111d0e) to head (dfbd33e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...web/src/react/web/ui/Bridge/TransactionPayment.tsx 12.90% 27 Missing ⚠️
...Bridge/payment-selection/FiatProviderSelection.tsx 11.11% 8 Missing ⚠️
...dweb/src/react/core/hooks/useTransactionDetails.ts 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7591      +/-   ##
==========================================
- Coverage   56.46%   56.46%   -0.01%     
==========================================
  Files         906      906              
  Lines       58072    58110      +38     
  Branches     4222     4222              
==========================================
+ Hits        32790    32810      +20     
- Misses      25174    25190      +16     
- Partials      108      110       +2     
Flag Coverage Δ
packages 56.46% <10.86%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
...dweb/src/react/core/hooks/useTransactionDetails.ts 11.27% <0.00%> (-0.18%) ⬇️
...Bridge/payment-selection/FiatProviderSelection.tsx 20.98% <11.11%> (-0.17%) ⬇️
...web/src/react/web/ui/Bridge/TransactionPayment.tsx 6.90% <12.90%> (+0.63%) ⬆️

... and 3 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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ffb7b64 and e17b0ae.

📒 Files selected for processing (3)
  • .changeset/few-moments-add.md (1 hunks)
  • packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts (6 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionPayment.tsx (1 hunks)
🧰 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/Bridge/TransactionPayment.tsx
  • packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts
🧠 Learnings (4)
📓 Common learnings
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} : Unified `Wallet` and `Account` interfaces 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: MananTank
PR: thirdweb-dev/js#7307
File: apps/dashboard/src/app/nebula-app/move-funds/move-funds.tsx:324-346
Timestamp: 2025-06-09T15:15:02.350Z
Learning: In the move-funds functionality, MananTank prefers having both individual toast.promise notifications for each token transfer AND batch summary toasts, even though this creates multiple notifications. This dual notification approach is acceptable for the move-funds user experience.
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} : Smart wallets with account abstraction in wallet architecture
Learnt from: MananTank
PR: thirdweb-dev/js#7081
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/assets/create/create-token-page-impl.tsx:110-118
Timestamp: 2025-05-20T18:54:15.781Z
Learning: In the thirdweb dashboard's token asset creation flow, the `transferBatch` function from `thirdweb/extensions/erc20` accepts the raw quantity values from the form without requiring explicit conversion to wei using `toUnits()`. The function appears to handle this conversion internally or is designed to work with the values in the format they're already provided.
.changeset/few-moments-add.md (2)
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.488Z
Learning: Surface breaking changes prominently in PR descriptions
Learnt from: MananTank
PR: thirdweb-dev/js#7081
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/assets/create/create-token-page-impl.tsx:110-118
Timestamp: 2025-05-20T18:54:15.781Z
Learning: In the thirdweb dashboard's token asset creation flow, the `transferBatch` function from `thirdweb/extensions/erc20` accepts the raw quantity values from the form without requiring explicit conversion to wei using `toUnits()`. The function appears to handle this conversion internally or is designed to work with the values in the format they're already provided.
packages/thirdweb/src/react/web/ui/Bridge/TransactionPayment.tsx (6)
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.
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} : Unified `Wallet` and `Account` interfaces 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} : Smart wallets with account abstraction 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 for in-app wallets (social/email login) in wallet architecture
Learnt from: MananTank
PR: thirdweb-dev/js#7298
File: apps/dashboard/src/app/nebula-app/move-funds/move-funds.tsx:255-277
Timestamp: 2025-06-06T23:47:55.122Z
Learning: The `transfer` function from `thirdweb/extensions/erc20` accepts human-readable amounts via the `amount` property and automatically handles conversion to base units (wei) by fetching the token decimals internally. Manual conversion using `toWei()` is not required when using the `amount` property.
Learnt from: MananTank
PR: thirdweb-dev/js#7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenPriceData.ts:49-49
Timestamp: 2025-05-27T19:55:25.056Z
Learning: In the ERC20 public pages token price data hook (`useTokenPriceData.ts`), direct array access on `json.data[0]` without optional chaining is intentionally correct and should not be changed to use safety checks.
packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts (14)
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} : Unified `Wallet` and `Account` interfaces 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} : Smart wallets with account abstraction 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).
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: 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.
Learnt from: MananTank
PR: thirdweb-dev/js#7081
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/assets/create/create-token-page-impl.tsx:110-118
Timestamp: 2025-05-20T18:54:15.781Z
Learning: In the thirdweb dashboard's token asset creation flow, the `transferBatch` function from `thirdweb/extensions/erc20` accepts the raw quantity values from the form without requiring explicit conversion to wei using `toUnits()`. The function appears to handle this conversion internally or is designed to work with the values in the format they're already provided.
Learnt from: MananTank
PR: thirdweb-dev/js#7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenPriceData.ts:49-49
Timestamp: 2025-05-27T19:55:25.056Z
Learning: In the ERC20 public pages token price data hook (`useTokenPriceData.ts`), direct array access on `json.data[0]` without optional chaining is intentionally correct and should not be changed to use safety checks.
Learnt from: MananTank
PR: thirdweb-dev/js#7298
File: apps/dashboard/src/app/nebula-app/move-funds/move-funds.tsx:255-277
Timestamp: 2025-06-06T23:47:55.122Z
Learning: The `transfer` function from `thirdweb/extensions/erc20` accepts human-readable amounts via the `amount` property and automatically handles conversion to base units (wei) by fetching the token decimals internally. Manual conversion using `toWei()` is not required when using the `amount` property.
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/extensions/**/*.{ts,tsx} : Auto-generated contracts from ABI definitions in extensions
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.488Z
Learning: Applies to test/src/test-wallets.ts : Predefined test accounts are in `test/src/test-wallets.ts`
Learnt from: MananTank
PR: thirdweb-dev/js#7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/erc20.tsx:15-17
Timestamp: 2025-05-27T19:54:55.885Z
Learning: The `fetchDashboardContractMetadata` function from "@3rdweb-sdk/react/hooks/useDashboardContractMetadata" has internal error handlers for all promises and cannot throw errors, so external error handling is not needed when calling this function.
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.488Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{tsx,ts} : Use design system tokens (e.g., `bg-card`, `border-border`, `text-muted-foreground`)
⏰ 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). (3)
  • GitHub Check: Unit Tests
  • GitHub Check: Size
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts (5)

11-11: LGTM!

The imports for balance fetching functions are appropriate for the new functionality.

Also applies to: 21-21


35-36: Good interface design!

The balance properties follow the existing pattern of storing both formatted string and raw bigint values, maintaining consistency with other amount fields in the interface.


90-111: Well-implemented balance fetching logic

The code correctly distinguishes between ERC20 and native token balance fetching, with appropriate fallback to 0n on failure. The use of IIFE for conditional async logic within Promise.all is a clean approach.


179-183: Correct fix for total cost calculation

The logic properly separates ERC20 token costs from gas costs. For ERC20 transactions, only the token amount is included since gas is paid in native tokens. For native token transactions, both value and gas are summed. This accurately reflects blockchain transaction mechanics.


193-194: LGTM!

The balance values are properly formatted and added to the return object, maintaining consistency with the interface definition.

.changeset/few-moments-add.md (1)

1-5: Well-documented patch

The changeset clearly describes the regression fix and is appropriately versioned as a patch.

@gregfromstl gregfromstl force-pushed the greg/tool-5026-fix-regression-in-widget-for-onrampingswapping-amounts branch from 75e0eab to dfbd33e Compare July 11, 2025 08:54
@gregfromstl gregfromstl merged commit f33e31a into main Jul 11, 2025
21 of 24 checks passed
@gregfromstl gregfromstl deleted the greg/tool-5026-fix-regression-in-widget-for-onrampingswapping-amounts branch July 11, 2025 09:02
@joaquim-verges joaquim-verges mentioned this pull request Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-queue Adds the pull request to Graphite's merge queue. packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants