Skip to content
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

BUG: Sharded Collection Contract Deposit event has nil owner field #5

Open
joshuahannan opened this issue Dec 8, 2021 · 3 comments

Comments

@joshuahannan
Copy link

Description

In the sharded collection contract deposit function, the function removes the needed collection from the dictionary before depositing the NFT and putting the collection back.

            // Remove the collection
            let collection <- self.collections.remove(key: bucket)!

            // Deposit the nft into the bucket
            collection.deposit(token: <-token)

            // Put the Collection back in storage
            self.collections[bucket] <-! collection

With a recent upgrade to cadence, this will clear the owner field of the collection, which means that the deposit event that is emitted will have nil as the owner. Services monitoring these events will not be able to monitor any NFTs that are deposited into a sharded collection.

Recommendation

Borrow a reference to the collection instead of removing it from the dictionary, like we do in the top shot smart contract

            // Find the bucket this corresponds to
            let bucket = token.id % self.numBuckets

            let collectionRef = &self.collections[bucket] as! &TopShot.Collection

            // Deposit the nft into the bucket
            collectionRef.deposit(token: <-token)

@sadief

@sadief
Copy link
Contributor

sadief commented Dec 10, 2021

hey @joshuahannan thank you for this! Would this still apply if we aren't using sharded collections for NFL ALLDAY? Since we knew the spork was happening on Dec 8th with the storage layer upgrade we set up the minting account with a normal collection.

@joshuahannan
Copy link
Author

If this contract was never deployed, then it wouldn't matter, but if that is the case, can you just remove it from this repo so there isn't any more confusion?

@sadief
Copy link
Contributor

sadief commented Dec 14, 2021

Good point, absolutely - PR here! #6 @joshuahannan

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

No branches or pull requests

2 participants