Trait governance_os_support::traits::RoleManager [−][src]
pub trait RoleManager { type AccountId; type Role; fn has_role(target: &Self::AccountId, role: Self::Role) -> bool; fn grant_role(
target: Option<&Self::AccountId>,
role: Self::Role
) -> DispatchResult; fn revoke_role(
target: Option<&Self::AccountId>,
role: Self::Role
) -> DispatchResult; fn ensure_has_role<OuterOrigin>(
origin: OuterOrigin,
role: Self::Role
) -> Result<Self::AccountId, DispatchError>
where
OuterOrigin: Into<Result<RawOrigin<Self::AccountId>, OuterOrigin>>, { ... } }
This trait can be implemented by a pallet to expose an interface for other pallets to manage their own role based access control features.
Associated Types
Loading content...Required methods
fn has_role(target: &Self::AccountId, role: Self::Role) -> bool
[src]
Should return true
if traget
has the role role
. This can be the case
if the role was granted directly to the target or if it was granted to all accounts.
fn grant_role(
target: Option<&Self::AccountId>,
role: Self::Role
) -> DispatchResult
[src]
target: Option<&Self::AccountId>,
role: Self::Role
) -> DispatchResult
Grants target
the role role
. If target is None
then it should give the role to
every account that exists or may exists on the chain.
fn revoke_role(
target: Option<&Self::AccountId>,
role: Self::Role
) -> DispatchResult
[src]
target: Option<&Self::AccountId>,
role: Self::Role
) -> DispatchResult
Should revoke the role role
for target
. If the role wasn’t granted to target
this
should error.
Provided methods
fn ensure_has_role<OuterOrigin>(
origin: OuterOrigin,
role: Self::Role
) -> Result<Self::AccountId, DispatchError> where
OuterOrigin: Into<Result<RawOrigin<Self::AccountId>, OuterOrigin>>,
[src]
origin: OuterOrigin,
role: Self::Role
) -> Result<Self::AccountId, DispatchError> where
OuterOrigin: Into<Result<RawOrigin<Self::AccountId>, OuterOrigin>>,
A helper function that will require the origin to have the role
granted. We provide a
default implementation for it.