paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

pallet-nfts: AttributeNamespace inconsistency between collection_attribute and set_collection_attribute #14295

Open erkkonet opened 1 year ago

erkkonet commented 1 year ago

Is there an existing issue?

Experiencing problems? Have you tried our Stack Exchange first?

Description of bug

When using the frame_support::traits::tokens::nonfungibles_v2::Inspect/Mutate traits implementation in pallet-nfts, there is a discrepancy between the AttributeNamespace used for storing and retrieving collection attributes.

The setter fn set_collection_attribute uses AttributeNamespace::Pallet whereas the getter fn collection_attribute uses AttributeNamespace::CollectionOwner.

The result is that no data is found when trying to retrieve a previously stored value. The methods should be using the same namespace, probably CollectionOwner is the most appropriate.

Steps to reproduce

<T as Config>::Nonfungible::set_collection_attribute(collection, key, value)?;

let result = <T as Config>::Nonfungible::collection_attribute(collection, key);

The result will be None instead of the expected Some(value).