pub trait AccessControlRegistry: AccessControlRegistryAdminnedWithManager {
const DEFAULT_ADMIN_ROLE: Bytes32 = _;
const NAME_SETTER_ROLE_DESCRIPTION: &'static str = "Name setter";
const UNLIMITED_READER_ROLE_DESCRIPTION: &'static str = "Unlimited reader";
Show 13 methods
// Required methods
fn has_role(&self, role: &Bytes32, who: &Self::Address) -> bool;
fn grant_role(
&mut self,
role: &Bytes32,
who: &Self::Address,
) -> Result<(), Error>;
fn get_role_admin(&self, role: &Bytes32) -> Option<Bytes32>;
fn set_role_admin(
&mut self,
role: &Bytes32,
role_admin: Bytes32,
) -> Result<(), Error>;
fn renounce_role(
&mut self,
role: &Bytes32,
account: &Self::Address,
) -> Result<(), Error>;
fn revoke_role(
&mut self,
role: &Bytes32,
account: &Self::Address,
) -> Result<(), Error>;
// Provided methods
fn find_static_role(&self, role: StaticRole) -> Bytes32 { ... }
fn only_role(
&self,
role: &Bytes32,
msg_sender: &Self::Address,
) -> Result<(), Error> { ... }
fn initialize_manager(
&mut self,
manager: &Self::Address,
) -> Result<(), Error> { ... }
fn initialize_role_and_grant_to_sender(
&mut self,
admin_role: Bytes32,
description: String,
msg_sender: &Self::Address,
) -> Result<Bytes32, Error> { ... }
fn derive_admin_role(&self, manager: &Self::Address) -> Bytes32 { ... }
fn derive_root_role(&self, manager: &Self::Address) -> Bytes32 { ... }
fn derive_role(&self, admin_role: Bytes32, description: String) -> Bytes32 { ... }
}
Expand description
The access control registry interface in the solidity contract
Provided Associated Constants§
Sourceconst DEFAULT_ADMIN_ROLE: Bytes32 = _
const DEFAULT_ADMIN_ROLE: Bytes32 = _
Default admin role, align with Openzepplin’s definition
const NAME_SETTER_ROLE_DESCRIPTION: &'static str = "Name setter"
const UNLIMITED_READER_ROLE_DESCRIPTION: &'static str = "Unlimited reader"
Required Methods§
Sourcefn has_role(&self, role: &Bytes32, who: &Self::Address) -> bool
fn has_role(&self, role: &Bytes32, who: &Self::Address) -> bool
Checks if user has a particular role
role
The role to check
who
The address to check
Sourcefn grant_role(
&mut self,
role: &Bytes32,
who: &Self::Address,
) -> Result<(), Error>
fn grant_role( &mut self, role: &Bytes32, who: &Self::Address, ) -> Result<(), Error>
Grant role for the user
role
The role to grant
who
The address to grant role
Sourcefn get_role_admin(&self, role: &Bytes32) -> Option<Bytes32>
fn get_role_admin(&self, role: &Bytes32) -> Option<Bytes32>
Get the admin role of role
role
The role to check
Sourcefn set_role_admin(
&mut self,
role: &Bytes32,
role_admin: Bytes32,
) -> Result<(), Error>
fn set_role_admin( &mut self, role: &Bytes32, role_admin: Bytes32, ) -> Result<(), Error>
Set the role admin for a role
role
The role to grant
role_admin
The role admin
Provided Methods§
Sourcefn find_static_role(&self, role: StaticRole) -> Bytes32
fn find_static_role(&self, role: StaticRole) -> Bytes32
Find the role by its name. Not in the original solidity contract Just for making it work in Rust
Sourcefn only_role(
&self,
role: &Bytes32,
msg_sender: &Self::Address,
) -> Result<(), Error>
fn only_role( &self, role: &Bytes32, msg_sender: &Self::Address, ) -> Result<(), Error>
Checks that an account has a specific role. Reverts
with a standardized message including the required role.
role
The role to check
msg_sender
The address to check
Sourcefn initialize_manager(&mut self, manager: &Self::Address) -> Result<(), Error>
fn initialize_manager(&mut self, manager: &Self::Address) -> Result<(), Error>
Initializes the manager by initializing its root role and
granting it to them
Anyone can initialize a manager. An uninitialized manager
attempting to initialize a role will be initialized automatically.
Once a manager is initialized, subsequent initializations have no
effect.
manager
Manager address to be initialized
Sourcefn initialize_role_and_grant_to_sender(
&mut self,
admin_role: Bytes32,
description: String,
msg_sender: &Self::Address,
) -> Result<Bytes32, Error>
fn initialize_role_and_grant_to_sender( &mut self, admin_role: Bytes32, description: String, msg_sender: &Self::Address, ) -> Result<Bytes32, Error>
Initializes a role by setting its admin role and grants it to
the sender
If the sender should not have the initialized role, they should
explicitly renounce it after initializing it.
Once a role is initialized, subsequent initializations have no effect
other than granting the role to the sender.
The sender must be a member of admin_role
. admin_role
value is not
validated because the sender cannot have the bytes32(0)
role.
If the sender is an uninitialized manager that is initializing a role
directly under their root role, manager initialization will happen
automatically, which will grant the sender admin_role
and allow them
to initialize the role.
admin_role
Admin role to be assigned to the initialized role
description
Human-readable description of the initialized role
msg_sender
The message sender address
Sourcefn derive_admin_role(&self, manager: &Self::Address) -> Bytes32
fn derive_admin_role(&self, manager: &Self::Address) -> Bytes32
Derives the admin role of the manager
manager
Manager address
Sourcefn derive_root_role(&self, manager: &Self::Address) -> Bytes32
fn derive_root_role(&self, manager: &Self::Address) -> Bytes32
Derives the root role of the manager
manager
Manager address
Sourcefn derive_role(&self, admin_role: Bytes32, description: String) -> Bytes32
fn derive_role(&self, admin_role: Bytes32, description: String) -> Bytes32
Derives the role using its admin role and description
This implies that roles adminned by the same role cannot have the
same description
admin_role
Admin role
description
Human-readable description of the role
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.