Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

InternalTrait

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait

pub trait InternalTrait<
    TContractState,
    +HasComponent<TContractState>,
    impl Immutable: ImmutableConfig,
    impl SRC5: HasComponent<TContractState>,
    +Drop<TContractState>,
>

Trait functions

initializer

Initializes the contract by registering the IAccessControl interface ID and setting the initial delay and default admin.

Requirements:

  • initial_default_admin must not be the zero address.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::initializer

fn initializer(
    ref self: ComponentState<TContractState>,
    initial_admin_transfer_delay: u64,
    initial_default_admin: ContractAddress,
)

assert_only_role

Validates that the caller can act as the given role. Otherwise it panics.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::assert_only_role

fn assert_only_role(self: @ComponentState<TContractState>, role: felt252)

is_role_effective

Returns whether the account can act as the given role.

The account can act as the role if it is active and the effective_from time is before or equal to the current time.

NOTE: If the effective_from timepoint is 0, the role is effective immediately. This is backwards compatible with implementations that didn’t use delays but a single boolean flag.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::is_role_effective

fn is_role_effective(
    self: @ComponentState<TContractState>, role: felt252, account: ContractAddress,
) -> bool

resolve_role_status

Returns the account’s status for the given role.

The possible statuses are:

  • NotGranted: the role has not been granted to the account.
  • Delayed: The role has been granted to the account but is not yet active due to a time delay.
  • Effective: the role has been granted to the account and is currently active.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::resolve_role_status

fn resolve_role_status(
    self: @ComponentState<TContractState>, role: felt252, account: ContractAddress,
) -> RoleStatus

is_role_granted

Returns whether the account has the given role granted.

NOTE: The account may not be able to act as the role yet, if a delay was set and has not passed yet. Use is_role_effective to check if the account can act as the role.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::is_role_granted

fn is_role_granted(
    self: @ComponentState<TContractState>, role: felt252, account: ContractAddress,
) -> bool

set_role_admin

Sets admin_role as role’s admin role.

Internal function without access restriction.

Requirements:

  • role must not be DEFAULT_ADMIN_ROLE.

Emits a RoleAdminChanged event.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::set_role_admin

fn set_role_admin(ref self: ComponentState<TContractState>, role: felt252, admin_role: felt252)

_grant_role

Attempts to grant role to account. The function does nothing if role is already effective for account. If role has been granted to account, but is not yet active due to a time delay, the delay is removed and role becomes effective immediately.

Internal function without access restriction.

For DEFAULT_ADMIN_ROLE, it only allows granting if there isn’t already a default_admin or if the role has been previously renounced.

NOTE: Exposing this function through another mechanism may make the DEFAULT_ADMIN_ROLE assignable again. Make sure to guarantee this is the expected behavior in your implementation.

May emit a RoleGranted event.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::_grant_role

fn _grant_role(ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress)

_grant_role_with_delay

Attempts to grant role to account with the specified activation delay.

The role will become effective after the given delay has passed. If the role is already active (Effective) for the account, the function will panic. If the role has been granted but is not yet active (being in the Delayed state), the existing delay will be overwritten with the new delay.

Internal function without access restriction.

Requirements:

  • delay must be greater than 0.
  • the role must not be already effective for account.
  • role must not be DEFAULT_ADMIN_ROLE.

May emit a RoleGrantedWithDelay event.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::_grant_role_with_delay

fn _grant_role_with_delay(
    ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress, delay: u64,
)

_revoke_role

Attempts to revoke role from account.

Internal function without access restriction.

May emit a RoleRevoked event.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::_revoke_role

fn _revoke_role(ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress)

set_pending_default_admin

Setter of the tuple for pending admin and its schedule.

May emit a DefaultAdminTransferCanceled event.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::set_pending_default_admin

fn set_pending_default_admin(
    ref self: ComponentState<TContractState>, new_admin: ContractAddress, new_schedule: u64,
)

set_pending_delay

Setter of the tuple for pending delay and its schedule.

May emit a DefaultAdminDelayChangeCanceled event.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::set_pending_delay

fn set_pending_delay(ref self: ComponentState<TContractState>, new_delay: u64, new_schedule: u64)

delay_change_wait

Returns the amount of seconds to wait after the new_delay will become the new default_admin_delay.

The value returned guarantees that if the delay is reduced, it will go into effect after a wait that honors the previously set delay.

See default_admin_delay_increase_wait.

Fully qualified path: openzeppelin_access::accesscontrol::extensions::accesscontrol_default_admin_rules::AccessControlDefaultAdminRulesComponent::InternalTrait::delay_change_wait

fn delay_change_wait(self: @ComponentState<TContractState>, new_delay: u64) -> u64