Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 03cbebe The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TokensCollectiontracked the minting token by its array index (#minting = { index, metadata }), but nothing updated that index when the collection mutated. Any insertion or removal before the minting token detached the minting metadata from the token it belongs to:mint({ amount: 100n }), add token B, then remove A —collection.mintingreported B's amount (e.g.10n) instead of100n. Inserting a token at an index before the minting token corrupted it the same way.collection.mintingstill returned the minting metadata, now paired with token A's amount. Downstream,OutputBuilder.build()treats such an output as a minting output (writing EIP-4 registers from the phantom metadata) andtoArray()kept throwingUndefinedMintingContextfor a collection with no minting token; a secondmint()also kept throwing "Only one minting token is allowed" even though the minting token was gone.collection.mintingthrewTypeError: Cannot read properties of undefined (reading 'amount').Fix
Track the minting item by reference instead of by index:
#mintingnow holds the stored item object; themintinggetter returnsundefinedwhen that item is no longer in the collection, and otherwise reads the amount from the item itself — so partial removals of the minting token are reflected, and insertions/removals of other tokens cannot affect it.mint()resolves the stored item after adding: the newly appended item normally, or the existing item when the amount was summed into one with the same token id. The "only one minting token" guard now goes through the live getter, so minting again works after the minting token has been removed.No API changes; behavior for collections that never remove/insert around a mint is unchanged.
Tests
Tests-first: the 4 new
tokensCollection.spec.tscases all fail on currentmaster(wrong amount, phantom minting metadata, and theTypeErrorabove) and pass with this fix:minting,toArray()no longer throws, and a new token can be mintedmintingafter removing the last preceding token does not throwFull monorepo suite: 1136/1136 tests pass (66 files;
masterbaseline is 1132, +4 new). Biome clean on the changed files.Includes a changeset (
@fleet-sdk/core: patch).Built by @Kshot9000 — https://x.com/kshot9000
Tips (ERG): 9fcM5RWnAjmP4vx5bnW6yohB6H9bLq8sJbaPLHtwZLtQPB32Pvy