Purpose

Access Levels can be assigned to accounts and addresses by Access Level Administrators through the AppManager. They are predefined as 0,1,2,3,4 and are stored as uint8 in the AccessLevels data contract. This data contract is deployed when the AppManager is deployed. The AccessLevels data contract can be migrated to a new AppManager during an upgrade to maintain access level and address data. Access Level administrators can migrate data contracts to a new AppManager through a two step migration process.

The protocol uses access levels to perform access level related rule checks. The levels may be used as needed to suit the needs of the application and the rules.

The default access level for each account is 0.

Scope

Access Levels are applied to addresses. When an access level related rule is activated, all users will be subject to any limitations set by the rule related to their individual access level.

see Access Level Rules

Data Structure

Access Levels are a uint8 number stored in a mapping inside the AccessLevels data contract.

///     address   => levels
mapping(address => uint8) public levels;
see AccessLevels

Enabling/Disabling

  • Access Levels can only be set in the AppManager by an Access Level Administrator.

Revert Messages

The transaction will revert with the following error when attempting to set access level greater than 4:

error AccessLevelIsNotValid();

The selector for this error is 0xfd12da91.

The transaction will revert with the following error when attempting to set access level for 0x0000000000000000000000000000000000000000 address:

error ZeroAddress();

The selector for this error is 0xd92e233d.

Add Functions

Adding an access level is done through the function:

function addAccessLevel(address _account, uint8 _level) public onlyRole(ACCESS_LEVEL_ADMIN_ROLE);

Adding a single access level to multiple accounts or addresses is done through the function:

function addAccessLevelToMultipleAccounts(address[] memory _accounts, uint8 _level) external onlyRole(ACCESS_LEVEL_ADMIN_ROLE);

Adding multiple access levels to multiple accounts or addresses is done through the function:

function addMultipleAccessLevels(address[] memory _accounts, uint8[] memory _level) external onlyRole(ACCESS_LEVEL_ADMIN_ROLE);
see AccessLevels

Remove Function

To remove an access level simply use the remove function:

function removeAccessLevel(address _account, uint8 _level) external onlyRole(ACCESS_LEVEL_ADMIN_ROLE);

Parameters:

  • _level (uint8): access level for an account.
  • _levels (uint8[]): array of access levels for an account.
  • _account (address): address of the account to tag
  • _accounts (address[]): array of addresses to tag

Parameter Optionality:

There are no options for the parameters of the add or remove functions.

Parameter Validation:

The following validation will be carried out by the addAccessLevel function in order to ensure that these parameters are valid and make sense:

  • _level is not greater than 4.
  • _account is an address and not the zero address.
see AccessLevels

Other Functions:

  • In App Manager:
    • Function to get the access level of an address:
      function getAccessLevel(address _account) external view returns (uint8);
      
    • Function to propose a new Access Level Provider
      function proposeAccessLevelsProvider(address _newProvider) external onlyRole(APP_ADMIN_ROLE);
      
    • Function to get the Access Level Provider address
      function getAccessLevelProvider() external view returns (address);
      
    • Function to propose data contract migration to new handler:
      function proposeDataContractMigration(address _newOwner) external  onlyRole(APP_ADMIN_ROLE);
      
    • Function to confirm migration of data contracts to new handler:
      function confirmDataContractMigration(address _oldHandlerAddress) external  onlyRole(APP_ADMIN_ROLE);
      

Events

  • AD1467_AccessLevelAdded(address indexed _address, uint8 indexed _level): emitted when:
    • An access level has been added.
  • AD1467_AccessLevelProviderSet(address indexed _address): emitted when:
    • An access level data contract has been migrated to the app manager address