Skip to content

Fix CheckoutWidget transaction invalidation and NFT filtering in connect UI #7761

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

joaquim-verges
Copy link
Member

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

Fixes TOOL-5090


PR-Codex overview

This PR focuses on fixing transaction invalidation in the CheckoutWidget and enhancing NFT filtering in the connection UI. It updates various functions to support multiple contract addresses and improves query invalidation for wallet balances and NFTs.

Detailed summary

  • Updated getOwnedNFTs in erc721 and erc1155 to use contractAddresses instead of contractAddress.
  • Enhanced invalidateWalletBalance to invalidate queries for NFTs and tokens.
  • Modified useTransactionDetails to stringify the transaction for the query key.
  • Changed getOwnedTokens to accept tokenAddresses instead of tokenAddress.
  • Updated ViewNFTsContent to filter NFTs based on the active chain and account.
  • Adjusted getOwnedNFTs to accept contractAddresses and modified the request payload accordingly.

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

Summary by CodeRabbit

  • Bug Fixes

    • Resolved transaction invalidation issues in the CheckoutWidget.
    • Corrected NFT filtering logic in the connect UI for more accurate results.
  • New Features

    • Enhanced NFT and token queries to support filtering by multiple contract or token addresses.
    • Token queries now sort results by balance for improved clarity.
  • Improvements

    • Optimized cache invalidation to include NFTs and tokens, ensuring up-to-date wallet balances.
    • Improved query performance and accuracy by updating cache keys and removing redundant client-side filtering.

Copy link

vercel bot commented Jul 30, 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 30, 2025 10:16am
nebula ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2025 10:16am
thirdweb_playground 🛑 Canceled (Inspect) Jul 30, 2025 10:16am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2025 10:16am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2025 10:16am

Copy link

changeset-bot bot commented Jul 30, 2025

🦋 Changeset detected

Latest commit: 0cb1948

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
Contributor

coderabbitai bot commented Jul 30, 2025

"""

Walkthrough

This change updates NFT and token fetching logic to support querying multiple contract or token addresses at once, adjusts cache key construction for transaction details to use a full serialized transaction, and broadens cache invalidation to include NFTs and tokens. NFT filtering in the connect UI is now performed server-side.

Changes

Cohort / File(s) Change Summary
Docs & Metadata
.changeset/petite-wasps-leave.md
Adds a patch changelog entry summarizing fixes for transaction invalidation and NFT filtering logic.
NFT Fetch: ERC721 & ERC1155
packages/thirdweb/src/extensions/erc721/read/getOwnedNFTs.ts, packages/thirdweb/src/extensions/erc1155/read/getOwnedNFTs.ts
Updates internal calls to pass contractAddresses array instead of single contractAddress to NFT fetching logic.
Insight NFT Fetch
packages/thirdweb/src/insight/get-nfts.ts
Changes function signature to accept contractAddresses array, updates parameter handling accordingly.
Insight Token Fetch
packages/thirdweb/src/insight/get-tokens.ts
Changes function signature to accept tokenAddresses array, updates parameter handling, and adds sorting by balance in query options.
Transaction Details Cache Key
packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts
Modifies cache key for transaction details query to use a serialized transaction object instead of selected fields.
Wallet Balance Invalidation
packages/thirdweb/src/react/core/providers/invalidateWalletBalance.ts
Extends cache invalidation to include NFT and token queries, in addition to wallet balances.
Connect Wallet NFT Filtering
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/ViewNFTs.tsx
Moves NFT filtering for supported contracts to the server side by passing contractAddresses in the query, removes client-side filtering, and updates query key for cache consistency.

Sequence Diagram(s)

sequenceDiagram
    participant UI as ConnectWallet UI
    participant Hook as useQuery Hook
    participant Insight as getOwnedNFTs (Insight API)
    participant Server as Thirdweb Backend

    UI->>Hook: Query NFTs with supported contractAddresses
    Hook->>Insight: getOwnedNFTs({ contractAddresses: [...] })
    Insight->>Server: Fetch NFTs for owner, filtered by contractAddresses
    Server-->>Insight: Return filtered NFTs
    Insight-->>Hook: Return NFTs
    Hook-->>UI: Provide NFTs (already filtered)
Loading
sequenceDiagram
    participant Widget as CheckoutWidget
    participant Hook as useTransactionDetails
    participant Cache as React Query Cache

    Widget->>Hook: Request transaction details (with transaction object)
    Hook->>Cache: useQuery([stringify(transaction)], ...)
    Cache-->>Hook: Return cached or fetch new transaction details
    Hook-->>Widget: Provide up-to-date transaction info
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix NFTs not showing in View Assets due to supportedNFTs filtering (TOOL-5090)
Ensure NFT filtering is performed server-side and cache keys are updated for supportedNFTs (TOOL-5090)
Fix transaction widget caching issue so UI reflects latest values on update (TOOL-5090)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found. All modifications are directly related to the stated objectives in the linked issue.
"""

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 4ec515b and 0cb1948.

📒 Files selected for processing (8)
  • .changeset/petite-wasps-leave.md (1 hunks)
  • packages/thirdweb/src/extensions/erc1155/read/getOwnedNFTs.ts (1 hunks)
  • packages/thirdweb/src/extensions/erc721/read/getOwnedNFTs.ts (1 hunks)
  • packages/thirdweb/src/insight/get-nfts.ts (3 hunks)
  • packages/thirdweb/src/insight/get-tokens.ts (3 hunks)
  • packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts (2 hunks)
  • packages/thirdweb/src/react/core/providers/invalidateWalletBalance.ts (1 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/ViewNFTs.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • .changeset/petite-wasps-leave.md
  • packages/thirdweb/src/extensions/erc721/read/getOwnedNFTs.ts
  • packages/thirdweb/src/extensions/erc1155/read/getOwnedNFTs.ts
  • packages/thirdweb/src/react/core/hooks/useTransactionDetails.ts
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/ViewNFTs.tsx
  • packages/thirdweb/src/react/core/providers/invalidateWalletBalance.ts
  • packages/thirdweb/src/insight/get-nfts.ts
  • packages/thirdweb/src/insight/get-tokens.ts
⏰ 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). (5)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Fix_CheckoutWidget_transaction_invalidation_and_NFT_filtering_in_connect_UI

🪧 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 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 Jul 30, 2025
Copy link

linear bot commented Jul 30, 2025

@joaquim-verges joaquim-verges marked this pull request as ready for review July 30, 2025 09:57
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 requested review from a team as code owners July 30, 2025 09:57
Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.15 KB (-0.02% 🔽) 1.3 s (-0.02% 🔽) 364 ms (+63.93% 🔺) 1.7 s
thirdweb (cjs) 353.02 KB (+0.04% 🔺) 7.1 s (+0.04% 🔺) 1.6 s (+0.31% 🔺) 8.7 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 94 ms (+666.94% 🔺) 208 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 4 ms (-56.54% 🔽) 15 ms
thirdweb/react (minimal + tree-shaking) 19.3 KB (+0.28% 🔺) 386 ms (+0.28% 🔺) 73 ms (+184.64% 🔺) 459 ms

Copy link

codecov bot commented Jul 30, 2025

Codecov Report

❌ Patch coverage is 42.30769% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.40%. Comparing base (be80318) to head (0cb1948).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...rc/react/web/ui/ConnectWallet/screens/ViewNFTs.tsx 0.00% 10 Missing ⚠️
packages/thirdweb/src/insight/get-tokens.ts 0.00% 3 Missing ⚠️
packages/thirdweb/src/insight/get-nfts.ts 66.66% 1 Missing ⚠️
...dweb/src/react/core/hooks/useTransactionDetails.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7761      +/-   ##
==========================================
- Coverage   56.42%   56.40%   -0.02%     
==========================================
  Files         904      904              
  Lines       58665    58674       +9     
  Branches     4133     4136       +3     
==========================================
- Hits        33100    33095       -5     
- Misses      25460    25476      +16     
+ Partials      105      103       -2     
Flag Coverage Δ
packages 56.40% <42.30%> (-0.02%) ⬇️
Files with missing lines Coverage Δ
...irdweb/src/extensions/erc1155/read/getOwnedNFTs.ts 94.02% <100.00%> (ø)
...hirdweb/src/extensions/erc721/read/getOwnedNFTs.ts 95.65% <100.00%> (ø)
...rc/react/core/providers/invalidateWalletBalance.ts 100.00% <100.00%> (ø)
packages/thirdweb/src/insight/get-nfts.ts 86.64% <66.66%> (+0.05%) ⬆️
...dweb/src/react/core/hooks/useTransactionDetails.ts 12.12% <50.00%> (+0.84%) ⬆️
packages/thirdweb/src/insight/get-tokens.ts 0.00% <0.00%> (ø)
...rc/react/web/ui/ConnectWallet/screens/ViewNFTs.tsx 7.14% <0.00%> (-0.06%) ⬇️

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

@joaquim-verges joaquim-verges merged commit d35b6fc into main Jul 30, 2025
23 of 25 checks passed
@joaquim-verges joaquim-verges deleted the Fix_CheckoutWidget_transaction_invalidation_and_NFT_filtering_in_connect_UI branch July 30, 2025 10:16
@joaquim-verges joaquim-verges mentioned this pull request Jul 30, 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.

1 participant