Trait AccessControlRegistry

Source
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§

Source

const DEFAULT_ADMIN_ROLE: Bytes32 = _

Default admin role, align with Openzepplin’s definition

Source

const NAME_SETTER_ROLE_DESCRIPTION: &'static str = "Name setter"

Source

const UNLIMITED_READER_ROLE_DESCRIPTION: &'static str = "Unlimited reader"

Required Methods§

Source

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

Source

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

Source

fn get_role_admin(&self, role: &Bytes32) -> Option<Bytes32>

Get the admin role of role role The role to check

Source

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

Source

fn renounce_role( &mut self, role: &Bytes32, account: &Self::Address, ) -> Result<(), Error>

Called by the account to renounce the role Override to disallow managers to renounce their root roles. role Role to be renounced account Account to renounce the role

Source

fn revoke_role( &mut self, role: &Bytes32, account: &Self::Address, ) -> Result<(), Error>

Called by the role admin to renounce the role Override to disallow managers to renounce their root roles. role Role to be renounced account Account to renounce the role

Provided Methods§

Source

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

Source

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

Source

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

Source

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

Source

fn derive_admin_role(&self, manager: &Self::Address) -> Bytes32

Derives the admin role of the manager manager Manager address

Source

fn derive_root_role(&self, manager: &Self::Address) -> Bytes32

Derives the root role of the manager manager Manager address

Source

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.

Implementors§

Source§

impl<Address> AccessControlRegistry for DummyAccess<Address>
where Address: AsRef<[u8]> + Zero + Default + PartialEq,