Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the licenses listing to handle “burned” (non-existent) license token IDs by enumerating actual on-chain token IDs instead of assuming IDs are sequential from 1..totalSupply.
Changes:
- Add a new blockchain API helper that enumerates ND/MND token IDs via
tokenByIndex(chunked multicall). - Update
/licensespage to build the list from enumerated token IDs and derive supplies from the resulting arrays.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/api/blockchain.ts | Adds token enumeration helpers (tokenByIndex via multicall) and an exported getAllLicenseTokenIds() API. |
| app/licenses/page.tsx | Switches the licenses page to use enumerated token IDs (supports burned IDs) and updates cached fetch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| licenseIds.push(...tokenIds.map((tokenId) => Number(tokenId))); | ||
| } |
There was a problem hiding this comment.
tokenId values are converted to JS number (Number(tokenId)), which can truncate/round for ids > 2^53-1 and produce wrong license ids (and wrong sorting). Prefer returning bigint[]/string[] from this API (matching the on-chain uint256), or validate that each tokenId fits in Number.MAX_SAFE_INTEGER before converting.
| const total = Number(totalSupply); | ||
| const licenseIds: number[] = []; | ||
|
|
||
| for (let start = 0; start < total; start += LICENSE_ENUMERATION_CHUNK_SIZE) { | ||
| const end = Math.min(start + LICENSE_ENUMERATION_CHUNK_SIZE, total); |
There was a problem hiding this comment.
totalSupply (bigint) is converted to a JS number via Number(totalSupply). If totalSupply ever exceeds Number.MAX_SAFE_INTEGER, this will silently lose precision and the loop will enumerate the wrong indices. Consider iterating using bigint counters (and only converting to number at the UI boundary), or at least guard/throw when totalSupply > BigInt(Number.MAX_SAFE_INTEGER) to avoid incorrect results.
No description provided.