Conversation
roiLeo
commented
Jun 23, 2025
- might be related with Error in display of Floor price of Collectibles by Kus nft-gallery#11591
⚠️ I didn't test it
There was a problem hiding this comment.
Pull Request Overview
This pull request adds collection-level statistics updates to the swap claim handler. When an NFT swap is claimed, the handler now calculates and updates the collection's floor price, owner count, and distribution metrics.
- Imports helper functions for calculating collection floor and owner statistics
- Calculates collection floor price after a swap is claimed
- Calculates and updates collection owner count and distribution
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const { floor } = await calculateCollectionFloor(context.store, collection.id, id) | ||
| const { ownerCount, distribution } = await calculateCollectionOwnerCountAndDistribution( | ||
| context.store, | ||
| collection.id, | ||
| event.currentOwner, | ||
| event.sent.owner | ||
| ) | ||
| collection.floor = floor | ||
| collection.ownerCount = ownerCount | ||
| collection.distribution = distribution |
There was a problem hiding this comment.
A swap involves two collections, but only the received collection's statistics are being updated. The sent collection (event.sent.collectionId) should also have its floor, ownerCount, and distribution recalculated and updated, as it loses an NFT owner and potentially gains a new one. This is inconsistent with how similar operations work - for example, in a swap, both NFTs change owners across potentially different collections.
| collection.floor = floor | ||
| collection.ownerCount = ownerCount | ||
| collection.distribution = distribution | ||
| collection.updatedAt = event.timestamp |
There was a problem hiding this comment.
The updatedAt field is set twice: once on line 30 and again on line 49. The first assignment on line 30 is redundant since it gets overwritten. Consider removing the duplicate assignment on line 30.