diff --git a/substrate/frame/nfts/src/impl_nonfungibles.rs b/substrate/frame/nfts/src/impl_nonfungibles.rs index a2bb49a947..b9e3951422 100644 --- a/substrate/frame/nfts/src/impl_nonfungibles.rs +++ b/substrate/frame/nfts/src/impl_nonfungibles.rs @@ -135,6 +135,18 @@ impl, I: 'static> Inspect<::AccountId> for Palle } } +impl, I: 'static> InspectRole<::AccountId> for Pallet { + fn is_issuer(collection: &Self::CollectionId, who: &::AccountId) -> bool { + Self::has_role(collection, who, CollectionRole::Issuer) + } + fn is_admin(collection: &Self::CollectionId, who: &::AccountId) -> bool { + Self::has_role(collection, who, CollectionRole::Admin) + } + fn is_freezer(collection: &Self::CollectionId, who: &::AccountId) -> bool { + Self::has_role(collection, who, CollectionRole::Freezer) + } +} + impl, I: 'static> Create<::AccountId, CollectionConfigFor> for Pallet { diff --git a/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs b/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs index f4c3c22ea9..6f428c297e 100644 --- a/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs +++ b/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs @@ -180,6 +180,16 @@ pub trait InspectEnumerable: Inspect { ) -> Self::OwnedInCollectionIterator; } +/// Trait for providing an interface to check the account's role within the collection. +pub trait InspectRole: Inspect { + /// Returns `true` if `who` is the issuer of the `collection`. + fn is_issuer(collection: &Self::CollectionId, who: &AccountId) -> bool; + /// Returns `true` if `who` is the admin of the `collection`. + fn is_admin(collection: &Self::CollectionId, who: &AccountId) -> bool; + /// Returns `true` if `who` is the freezer of the `collection`. + fn is_freezer(collection: &Self::CollectionId, who: &AccountId) -> bool; +} + /// Trait for providing the ability to create collections of nonfungible items. pub trait Create: Inspect { /// Create a `collection` of nonfungible items to be owned by `who` and managed by `admin`.