AccessRegistry

Git Source

Inherits: IAccessRegistry, AccessControl

Author: luoyhang003

Manages whitelist and blacklist for protocol access control.

Uses OpenZeppelin AccessControl for role-based permissions.

State Variables

OPERATOR_ROLE

Role identifier for operator accounts.

Calculated as keccak256("OPERATOR_ROLE").

bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");

_whitelist

Whitelist mapping to track approved users.

Address => true if whitelisted, false otherwise.

mapping(address => bool) private _whitelist;

_blacklist

Blacklist mapping to track blocked users.

Address => true if blacklisted, false otherwise.

mapping(address => bool) private _blacklist;

Functions

constructor

Deploys the contract and assigns initial admin and operator roles.

constructor(address _admin, address _operator);

Parameters

NameTypeDescription
_adminaddressAddress to receive the DEFAULT_ADMIN_ROLE.
_operatoraddressAddress to receive the OPERATOR_ROLE.

isWhitelisted

Checks whether a given address is whitelisted

function isWhitelisted(address _account) external view returns (bool);

Parameters

NameTypeDescription
_accountaddressThe address to check

Returns

NameTypeDescription
<none>boolTrue if the address is whitelisted, false otherwise

isBlacklisted

Checks whether a given address is blacklisted

function isBlacklisted(address _account) external view returns (bool);

Parameters

NameTypeDescription
_accountaddressThe address to check

Returns

NameTypeDescription
<none>boolTrue if the address is blacklisted, false otherwise

addWhitelist

Add multiple users to the whitelist.

Only callable by accounts with OPERATOR_ROLE.

function addWhitelist(address[] memory _users) external onlyRole(OPERATOR_ROLE);

Parameters

NameTypeDescription
_usersaddress[]Array of addresses to be whitelisted.

removeWhitelist

Remove multiple users from the whitelist.

Only callable by accounts with OPERATOR_ROLE.

function removeWhitelist(address[] memory _users) external onlyRole(OPERATOR_ROLE);

Parameters

NameTypeDescription
_usersaddress[]Array of addresses to be removed from whitelist.

addBlacklist

Add multiple users to the blacklist.

Only callable by accounts with OPERATOR_ROLE.

function addBlacklist(address[] memory _users) external onlyRole(OPERATOR_ROLE);

Parameters

NameTypeDescription
_usersaddress[]Array of addresses to be blacklisted.

removeBlacklist

Remove multiple users from the blacklist.

Only callable by accounts with OPERATOR_ROLE.

function removeBlacklist(address[] memory _users) external onlyRole(OPERATOR_ROLE);

Parameters

NameTypeDescription
_usersaddress[]Array of addresses to be removed from blacklist.