metaplex-foundation / mpl-token-metadata

Program to attach additional data to Fungible or Non-Fungible tokens on Solana.
https://developers.metaplex.com/token-metadata
Other
99 stars 42 forks source link

Misleading error on verifying collection with supply None #38

Closed saberistic closed 7 months ago

saberistic commented 11 months ago

Team, today I while working on verifying a collection I was logging an error on cluster saying Collection must be a unique Master Edition. So naturally started fiddling with collection_master_edition account of VerifySizedCollectionItem function but no bono!

Further debugging I figured problem was supply being set to None instead of Some(0) and hence the following line was being triggered: https://github.com/metaplex-foundation/mpl-token-metadata/blob/main/programs/token-metadata/program/src/assertions/collection.rs#L145-L147

But what I am puzzling with is why the name of the error is the same for all other exceptions in this function? Does this supply mismatch deserve its own error?

febo commented 10 months ago

Having a max supply of 0 is one of the pre-requisites to be a master edition account – and ultimately a collection – similar to the other conditions that need to be satisfied on the function. The error is the same since it will only happen when an "invalid" master edition account is used.

saberistic commented 10 months ago

Understood, it could save me hours if those errors were slightly different. I could immediately figure what is wrong rather than debugging manually figuring which condition is not satisfied. Thanks for great work.

febo commented 10 months ago

Agree with your point, perhaps we can make sure the documentation is clear on the "constraints" that are validated by the program. There is a bit of a balance between the granularity of the errors, e.g., we could create errors for every single validation or we can have more "generic" error with better documentation.