-
Notifications
You must be signed in to change notification settings - Fork 608
Filter out null-ish values from ERC721 and ERC1155 getNFTs() arrays #8311
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
Filter out null-ish values from ERC721 and ERC1155 getNFTs() arrays #8311
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: e3d11eb The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
WalkthroughAdds filtering logic to remove NFTs with undefined or null Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this 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
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
.changeset/good-regions-dig.md(1 hunks)packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts(1 hunks)packages/thirdweb/src/extensions/erc721/read/getNFTs.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
packages/thirdweb/src/extensions/erc1155/read/getNFTs.tspackages/thirdweb/src/extensions/erc721/read/getNFTs.ts
**/*.{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/extensions/erc1155/read/getNFTs.tspackages/thirdweb/src/extensions/erc721/read/getNFTs.ts
packages/thirdweb/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling@exampleand a custom tag (@beta,@internal,@experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g.,const { jsPDF } = await import("jspdf"))
Files:
packages/thirdweb/src/extensions/erc1155/read/getNFTs.tspackages/thirdweb/src/extensions/erc721/read/getNFTs.ts
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
.changeset/*.md: Each change inpackages/*must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API
Files:
.changeset/good-regions-dig.md
⏰ 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). (7)
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: Build Packages
- GitHub Check: Size
- GitHub Check: Lint Packages
- GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
.changeset/good-regions-dig.md (1)
1-5: LGTM! Changeset version bump is appropriate.The patch version bump is correct for this defensive change that filters out null-ish values. The description accurately reflects the changes.
f4d9b9b to
e3d11eb
Compare
There was a problem hiding this 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
🧹 Nitpick comments (1)
packages/thirdweb/src/extensions/erc721/read/getNFTs.ts (1)
74-85: Critical issue resolved: Token ID 0 is now correctly handled.The filter logic correctly excludes NFTs with null or undefined ids while preserving valid token ID 0 (whether
0,0n, or"0x0"). The explicit null and undefined checks address the previous critical issue where a truthy check would have incorrectly removed NFTs with ID 0.Optional: Simplify using idiomatic null check.
The expression
nft?.id !== undefined && nft?.id !== nullcan be simplified tonft?.id != null(using loose equality!=). In JavaScript/TypeScript,x != nullis equivalent tox !== null && x !== undefinedand is the idiomatic way to check for null-ish values.Apply this diff for a more concise expression:
- return await getNFTsFromInsight(options).then((nfts) => - nfts.filter((nft) => nft?.id !== undefined && nft?.id !== null), - ); + return await getNFTsFromInsight(options).then((nfts) => + nfts.filter((nft) => nft?.id != null), + ); } catch { - return await getNFTsFromRPC(options).then((nfts) => - nfts.filter((nft) => nft?.id !== undefined && nft?.id !== null), - ); + return await getNFTsFromRPC(options).then((nfts) => + nfts.filter((nft) => nft?.id != null), + ); } } - return await getNFTsFromRPC(options).then((nfts) => - nfts.filter((nft) => nft?.id !== undefined && nft?.id !== null), - ); + return await getNFTsFromRPC(options).then((nfts) => + nfts.filter((nft) => nft?.id != null), + );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
.changeset/good-regions-dig.md(1 hunks)packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts(1 hunks)packages/thirdweb/src/extensions/erc721/read/getNFTs.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- .changeset/good-regions-dig.md
- packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
packages/thirdweb/src/extensions/erc721/read/getNFTs.ts
**/*.{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/extensions/erc721/read/getNFTs.ts
packages/thirdweb/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling@exampleand a custom tag (@beta,@internal,@experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g.,const { jsPDF } = await import("jspdf"))
Files:
packages/thirdweb/src/extensions/erc721/read/getNFTs.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). (8)
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Size
- GitHub Check: Build Packages
- GitHub Check: Lint Packages
- GitHub Check: Unit Tests
- GitHub Check: Analyze (javascript)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8311 +/- ##
==========================================
- Coverage 54.90% 54.90% -0.01%
==========================================
Files 919 919
Lines 60675 60687 +12
Branches 4126 4135 +9
==========================================
+ Hits 33315 33319 +4
- Misses 27259 27267 +8
Partials 101 101
🚀 New features to boost your workflow:
|
size-limit report 📦
|

[SDK] Fix: Filter out null-ish values from ERC721 and ERC1155 getNFTs() arrays
Notes for the reviewer
This PR adds filtering to ensure that only NFTs with valid IDs are returned from the
getNFTs()methods in both ERC721 and ERC1155 extensions. The change applies to results from both indexer and RPC data sources.How to test
Verify that
ERC721.getNFTs()andERC1155.getNFTs()no longer return null or undefined values in their result arrays.Summary by CodeRabbit
PR-Codex overview
This PR focuses on filtering out nullish values from the arrays returned by the
ERC721.getNFTs()andERC1155.getNFTs()methods to ensure only valid NFT objects are processed.Detailed summary
ERC721.getNFTs()method.ERC1155.getNFTs()method.getNFTsFromInsightandgetNFTsFromRPCto include the filtering logic.