Skip to content
Snippets Groups Projects
Commit 4abb6025 authored by Stefan's avatar Stefan Committed by GitHub
Browse files

inspect role for nonfungibles_v2 (#14341)


* inspect role

* Update frame/nfts/src/impl_nonfungibles.rs

Co-authored-by: default avatarJegor Sidorenko <5252494+jsidorenko@users.noreply.github.com>

* Update frame/support/src/traits/tokens/nonfungibles_v2.rs

Co-authored-by: default avatarJegor Sidorenko <5252494+jsidorenko@users.noreply.github.com>

* Update as suggested

* Update frame/nfts/src/impl_nonfungibles.rs

Co-authored-by: default avatarJegor Sidorenko <5252494+jsidorenko@users.noreply.github.com>

* Update frame/nfts/src/impl_nonfungibles.rs

Co-authored-by: default avatarJegor Sidorenko <5252494+jsidorenko@users.noreply.github.com>

* Update frame/nfts/src/impl_nonfungibles.rs

Co-authored-by: default avatarJegor Sidorenko <5252494+jsidorenko@users.noreply.github.com>

---------

Co-authored-by: default avatarJegor Sidorenko <5252494+jsidorenko@users.noreply.github.com>
parent 1d2f16ab
No related merge requests found
......@@ -135,6 +135,18 @@ impl<T: Config<I>, I: 'static> Inspect<<T as SystemConfig>::AccountId> for Palle
}
}
impl<T: Config<I>, I: 'static> InspectRole<<T as SystemConfig>::AccountId> for Pallet<T, I> {
fn is_issuer(collection: &Self::CollectionId, who: &<T as SystemConfig>::AccountId) -> bool {
Self::has_role(collection, who, CollectionRole::Issuer)
}
fn is_admin(collection: &Self::CollectionId, who: &<T as SystemConfig>::AccountId) -> bool {
Self::has_role(collection, who, CollectionRole::Admin)
}
fn is_freezer(collection: &Self::CollectionId, who: &<T as SystemConfig>::AccountId) -> bool {
Self::has_role(collection, who, CollectionRole::Freezer)
}
}
impl<T: Config<I>, I: 'static> Create<<T as SystemConfig>::AccountId, CollectionConfigFor<T, I>>
for Pallet<T, I>
{
......
......@@ -180,6 +180,16 @@ pub trait InspectEnumerable<AccountId>: Inspect<AccountId> {
) -> Self::OwnedInCollectionIterator;
}
/// Trait for providing an interface to check the account's role within the collection.
pub trait InspectRole<AccountId>: Inspect<AccountId> {
/// 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<AccountId, CollectionConfig>: Inspect<AccountId> {
/// Create a `collection` of nonfungible items to be owned by `who` and managed by `admin`.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment