Skip to content

[BLD-71] SDK, Dashboard: Fix Supplies shown in ERC721 contract #7803

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

MananTank
Copy link
Member

@MananTank MananTank commented Aug 6, 2025


PR-Codex overview

This PR updates the getTotalClaimedSupply and getTotalUnclaimedSupply functions in the ERC721 extensions to account for the startTokenId if it is set in the contract, enhancing the accuracy of token supply calculations.

Detailed summary

  • Modified getTotalClaimedSupply to subtract startTokenId from nextTokenIdToClaim.
  • Updated getTotalUnclaimedSupply to subtract both startTokenId and totalClaimedSupply from nextTokenIdToMint.
  • Adjusted the SupplyCards component to use the new supply calculation methods.

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

Summary by CodeRabbit

  • Refactor

    • Improved supply calculations in NFT dashboards by directly using contract data instead of manual computations.
    • Adjusted logic to accurately account for token ID offsets when displaying claimed and unclaimed NFT supply.
  • Bug Fixes

    • Resolved inconsistencies in claimed and unclaimed NFT supply values when contracts use a custom starting token ID.

Copy link

vercel bot commented Aug 6, 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 6, 2025 7:02pm
nebula ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 7:02pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 7:02pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 7:02pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 7:02pm

Copy link

linear bot commented Aug 6, 2025

Copy link

changeset-bot bot commented Aug 6, 2025

🦋 Changeset detected

Latest commit: fd4414b

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 Aug 6, 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

The changes update the logic for calculating claimed and unclaimed NFT supply in ERC721 extensions and the dashboard UI. The new approach incorporates the startTokenId property, ensuring supply calculations accurately reflect token ID offsets. The dashboard now reads supply values directly from contract queries, removing manual computations.

Changes

Cohort / File(s) Change Summary
ERC721 Supply Calculation Logic
packages/thirdweb/src/extensions/erc721/read/getTotalClaimedSupply.ts, packages/thirdweb/src/extensions/erc721/read/getTotalUnclaimedSupply.ts
Updated both functions to incorporate the startTokenId offset in supply calculations. Both now fetch startTokenId (with fallback), and adjust their returned values to account for this offset, ensuring correct supply reporting.
Dashboard Supply Cards Refactor
apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/supply-cards.tsx
Refactored the SupplyCards component to remove manual supply calculations. Now directly queries contract for total, claimed, and unclaimed supply using updated hooks; updates UI rendering and loading logic accordingly.
Documentation/Changelog
.changeset/lemon-mammals-slide.md
Documents the changes made to supply calculation logic in ERC721 extensions, specifically noting the new handling of the startTokenId property.

Sequence Diagram(s)

sequenceDiagram
    participant DashboardUI
    participant ERC721Extension
    participant Contract

    DashboardUI->>ERC721Extension: getTotalSupply()
    ERC721Extension->>Contract: read getTotalSupply
    Contract-->>ERC721Extension: totalSupply

    DashboardUI->>ERC721Extension: getTotalClaimedSupply()
    ERC721Extension->>Contract: read startTokenId
    ERC721Extension->>Contract: read nextTokenIdToClaim
    Contract-->>ERC721Extension: startTokenId, nextTokenIdToClaim
    ERC721Extension-->>DashboardUI: nextTokenIdToClaim - startTokenId

    DashboardUI->>ERC721Extension: getTotalUnclaimedSupply()
    ERC721Extension->>Contract: read startTokenId
    ERC721Extension->>Contract: read nextTokenIdToMint
    ERC721Extension->>ERC721Extension: getTotalClaimedSupply()
    Contract-->>ERC721Extension: startTokenId, nextTokenIdToMint
    ERC721Extension-->>DashboardUI: nextTokenIdToMint - startTokenId - totalClaimedSupply
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
Correct supply rendering on contract page, including proper handling of claimed/unclaimed supply (BLD-71)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

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 0b1793b and fd4414b.

📒 Files selected for processing (4)
  • .changeset/lemon-mammals-slide.md (1 hunks)
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/supply-cards.tsx (2 hunks)
  • packages/thirdweb/src/extensions/erc721/read/getTotalClaimedSupply.ts (2 hunks)
  • packages/thirdweb/src/extensions/erc721/read/getTotalUnclaimedSupply.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • .changeset/lemon-mammals-slide.md
  • packages/thirdweb/src/extensions/erc721/read/getTotalUnclaimedSupply.ts
  • packages/thirdweb/src/extensions/erc721/read/getTotalClaimedSupply.ts
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/supply-cards.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, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Build 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 08-07-_bld-71_sdk_dashboard_fix_supplies_shown_in_erc721_contract

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

@MananTank MananTank marked this pull request as ready for review August 6, 2025 18:34
@MananTank MananTank requested review from a team as code owners August 6, 2025 18:34
@github-actions github-actions bot added Dashboard Involves changes to the Dashboard. packages SDK Involves changes to the thirdweb SDK labels Aug 6, 2025
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.

Copy link
Contributor

github-actions bot commented Aug 6, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.16 KB (0%) 1.3 s (0%) 139 ms (+242.24% 🔺) 1.5 s
thirdweb (cjs) 352.95 KB (0%) 7.1 s (0%) 362 ms (+18.85% 🔺) 7.5 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 48 ms (+2180.04% 🔺) 162 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 25 ms (+2408.14% 🔺) 35 ms
thirdweb/react (minimal + tree-shaking) 19.26 KB (0%) 386 ms (0%) 44 ms (+623.24% 🔺) 429 ms

Copy link

codecov bot commented Aug 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.34%. Comparing base (d10436d) to head (fd4414b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7803   +/-   ##
=======================================
  Coverage   56.34%   56.34%           
=======================================
  Files         905      905           
  Lines       58788    58796    +8     
  Branches     4141     4142    +1     
=======================================
+ Hits        33122    33130    +8     
  Misses      25561    25561           
  Partials      105      105           
Flag Coverage Δ
packages 56.34% <100.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
...rc/extensions/erc721/read/getTotalClaimedSupply.ts 100.00% <100.00%> (ø)
.../extensions/erc721/read/getTotalUnclaimedSupply.ts 100.00% <100.00%> (ø)
🚀 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

graphite-app bot commented Aug 6, 2025

Merge activity

<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the `getTotalClaimedSupply` and `getTotalUnclaimedSupply` functions in the ERC721 extensions to account for `startTokenId`, improving the accuracy of token supply calculations.

### Detailed summary
- Modified `getTotalClaimedSupply` to subtract `startTokenId` from `nextTokenIdToClaim`.
- Updated `getTotalUnclaimedSupply` to subtract `startTokenId` and `totalClaimedSupply` from `nextTokenIdToMint`.
- Changed imports in `supply-cards.tsx` to use the new supply functions.

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

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Refactor**
  * Improved supply calculations in NFT dashboards by directly using contract data instead of manual computations.
  * Adjusted logic to accurately account for token ID offsets when displaying claimed and unclaimed NFT supply.

* **Bug Fixes**
  * Resolved inconsistencies in claimed and unclaimed NFT supply values when contracts use a custom starting token ID.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dashboard Involves changes to the Dashboard. packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants