Skip to content

fix: (HOT) temp solution to correctly handle burned licenses#24

Merged
wzrdx merged 1 commit intomainfrom
develop
Feb 6, 2026
Merged

fix: (HOT) temp solution to correctly handle burned licenses#24
wzrdx merged 1 commit intomainfrom
develop

Conversation

@aledefra
Copy link
Collaborator

@aledefra aledefra commented Feb 6, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 6, 2026 15:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /licenses page 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.

Comment on lines +308 to +309
licenseIds.push(...tokenIds.map((tokenId) => Number(tokenId)));
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +293 to +297
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);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@wzrdx wzrdx merged commit b40426f into main Feb 6, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants