Skip to content

[SDK] Fix: stringify bigint erc20Value in useTransactionDetails #7360

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

Conversation

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented Jun 17, 2025


PR-Codex overview

This PR focuses on enhancing the TransactionWidget by allowing an explicit amount to be set and updating the handling of erc20Value. It also removes outdated documentation regarding payment method toggling.

Detailed summary

  • Updated transaction.erc20Value to transaction.erc20Value?.toString().
  • Added amount={100n} to the TransactionWidget in transaction-button.tsx.
  • Removed documentation sections on enabling/disabling payment methods for CheckoutWidget and TransactionWidget.

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

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue by setting an explicit amount on the transaction widget to ensure correct transaction handling.
  • Documentation

    • Removed documentation sections related to disabling onramp payment methods in transaction and checkout widgets. No functional changes to these features.

@gregfromstl gregfromstl requested review from a team as code owners June 17, 2025 21:06
Copy link

linear bot commented Jun 17, 2025

Copy link

changeset-bot bot commented Jun 17, 2025

🦋 Changeset detected

Latest commit: 51d1bd9

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 17, 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 17, 2025 9:56pm
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2025 9:56pm
nebula 🛑 Canceled (Inspect) Jun 17, 2025 9:56pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2025 9:56pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2025 9:56pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2025 9:56pm

Copy link
Contributor

coderabbitai bot commented Jun 17, 2025

Walkthrough

The changes update the rendering logic of the PayTransactionPreview component to always display the TransactionWidget with an explicit amount prop set to 100n. Additionally, query key handling for transaction details is standardized, and documentation about disabling onramps is removed from relevant widget components. A patch changeset is added for tracking.

Changes

File(s) Change Summary
apps/playground-web/src/components/pay/transaction-button.tsx Renders TransactionWidget unconditionally with amount={100n}; removes conditional UI wrappers.
packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts Converts erc20Value to string in the query key for consistent cache behavior.
packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
.../TransactionWidget.tsx
Removes JSDoc documentation about the disableOnramps prop and related usage examples.
.changeset/fluffy-paws-slide.md Adds a patch changeset describing the explicit amount fix for TransactionWidget.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PayTransactionPreview
    participant TransactionWidget

    User->>PayTransactionPreview: Render component
    PayTransactionPreview->>TransactionWidget: Render with amount=100n
    TransactionWidget-->>User: Display transaction UI
Loading

Possibly related PRs

  • thirdweb-dev/js#7145: Addresses stringification of bigint values in transaction contexts, which relates to the explicit handling of amounts in TransactionWidget.

Suggested reviewers

  • jnsdls

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 9396cab and ae7e82c.

📒 Files selected for processing (5)
  • .changeset/fluffy-paws-slide.md (1 hunks)
  • apps/playground-web/src/components/pay/transaction-button.tsx (1 hunks)
  • packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (0 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx (0 hunks)
💤 Files with no reviewable changes (2)
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
✅ Files skipped from review due to trivial changes (1)
  • .changeset/fluffy-paws-slide.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts
  • apps/playground-web/src/components/pay/transaction-button.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • 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 Jun 17, 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: 0

🔭 Outside diff range comments (1)
packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts (1)

55-61: transaction.erc20Value?.toString() risks cache-key collisions – stringify the amount, not the object

erc20Value is later treated as an object (erc20Value.tokenAddress, erc20Value.amountWei).
Calling .toString() on that object will coerce it to "[object Object]", meaning all ERC-20 values produce the same cache key segment. Different amounts or token addresses will therefore share React-Query cache entries → stale or cross-polluted results.

- transaction.erc20Value?.toString(),
+ transaction.erc20Value
+   ? `${transaction.erc20Value.tokenAddress}-${transaction.erc20Value.amountWei.toString()}`
+   : undefined,

This keeps the key stable while uniquely identifying both the token and the amount.

🧹 Nitpick comments (1)
apps/playground-web/src/components/pay/transaction-button.tsx (1)

35-37: Unused account fetch in this component once gated

If you decide to keep the widget unconditional, the account hook can be removed, otherwise it remains required for the conditional render above. Keep the import list tidy accordingly.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2b5941f and 43ca3c7.

📒 Files selected for processing (2)
  • apps/playground-web/src/components/pay/transaction-button.tsx (1 hunks)
  • packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/playground-web/src/components/pay/transaction-button.tsx (1)
apps/playground-web/src/lib/client.ts (1)
  • THIRDWEB_CLIENT (20-43)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Unit Tests
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
apps/playground-web/src/components/pay/transaction-button.tsx (1)

42-56: ```shell
#!/bin/bash

Locate and print the TransactionButton component for review

file=$(fd -t f "transaction-button.tsx")
echo "Found file: $file"
echo "---- Begin file content ----"
sed -n '1,200p' "$file"
echo "---- Continue file content ----"
sed -n '201,400p' "$file"


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Copy link
Contributor

github-actions bot commented Jun 17, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 62.49 KB (0%) 1.3 s (0%) 346 ms (+45.24% 🔺) 1.6 s
thirdweb (cjs) 350.88 KB (0%) 7.1 s (0%) 1.9 s (+3.94% 🔺) 9 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 138 ms (+785.55% 🔺) 252 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 114 ms (+1971.9% 🔺) 124 ms
thirdweb/react (minimal + tree-shaking) 19.59 KB (0%) 392 ms (0%) 155 ms (+348.09% 🔺) 547 ms

@gregfromstl gregfromstl force-pushed the greg/tool-4834-fix-bigint-serialization-on-payment-widgets branch from b5cb3fe to 51d1bd9 Compare June 17, 2025 21:40
Copy link

codecov bot commented Jun 17, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 52.36%. Comparing base (55baa99) to head (ae7e82c).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...dweb/src/react/core/hooks/useTransactionDetails.ts 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) 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    #7360   +/-   ##
=======================================
  Coverage   52.35%   52.36%           
=======================================
  Files         939      939           
  Lines       63160    63160           
  Branches     4215     4216    +1     
=======================================
+ Hits        33070    33073    +3     
+ Misses      29983    29980    -3     
  Partials      107      107           
Flag Coverage Δ
packages 52.36% <0.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
...dweb/src/react/core/hooks/useTransactionDetails.ts 11.20% <0.00%> (ø)

... and 1 file 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.

@gregfromstl gregfromstl merged commit 78b9c8e into main Jun 17, 2025
24 of 25 checks passed
@gregfromstl gregfromstl deleted the greg/tool-4834-fix-bigint-serialization-on-payment-widgets branch June 17, 2025 22:32
@joaquim-verges joaquim-verges mentioned this pull request Jun 17, 2025
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