-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathRoleControlInterface.sol
99 lines (87 loc) · 3.44 KB
/
RoleControlInterface.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;
/**
* @dev The interface that defines functions for managing account roles.
*/
interface RoleControlInterface {
/**
* @dev List of available roles.
*/
enum ROLES {
EMPTY,
TRUSTEE,
ENDORSER,
STEWARD
}
/**
* @dev Event emitted when a role successfully assigned to an account.
*/
event RoleAssigned(ROLES role, address indexed account, address indexed sender);
/**
* @dev Event emitted when a role successfully revoked from an account.
*/
event RoleRevoked(ROLES role, address indexed account, address indexed sender);
/**
* @dev Function to assign role to an account.
*
* Restrictions:
* - Only senders with certain roles as specified in the access rules are permitted assign specific roles;
* otherwise, the transaction will revert with an `Unauthorized` error.
*
* Events:
* - On successful role assignment, will emit a `RoleAssigned` event.
*
* @param role The role to be assigned to the account.
* @param account The address of the account to which the role will be assigned.
* @return assignedRole The role that has been successfully assigned.
*/
function assignRole(ROLES role, address account) external returns (ROLES assignedRole);
/**
* @dev Function to revoke role from an account.
*
* Restrictions:
* - Only senders with certain roles as specified in the access rules are permitted revoke specific roles;
* otherwise, the transaction will revert with an `Unauthorized` error.
*
* Events:
* - On successful role revocation, will emit a `RoleRevoked` event.
*
* @param role The role to be revoked from the account.
* @param account The address of the account from which the role will be revoked.
* @return A boolean indicating the success of the revocation.
*/
function revokeRole(ROLES role, address account) external returns (bool);
/**
* @dev Function to check if an account has requested role assigned
* @param role The role to check against.
* @param account The address of the account whose role assignment is being checked.
* @return Returns true if the account has the requested role, and false otherwise.
*/
function hasRole(ROLES role, address account) external view returns (bool);
/**
* @dev Function to return the count of accounts with the provided role.
* @param role The role for which the account count is to be retrieved.
* @return The count of accounts that have been assigned the specified role.
*/
function getRoleCount(ROLES role) external view returns (uint32);
/**
* @dev Function to check that identity has TRUSTEE role.
*/
function isTrustee(address identity) external view;
/**
* @dev Function to check that identity has ENDORSER role.
*/
function isEndorser(address identity) external view;
/**
* @dev Function to check that identity has STEWARD role.
*/
function isSteward(address identity) external view;
/**
* @dev Function to check that identity has either TRUSTEE or ENDORSER role.
*/
function isTrusteeOrEndorser(address identity) external view;
/**
* @dev Function to check that identity has either TRUSTEE or ENDORSER or STEWARD role.
*/
function isTrusteeOrEndorserOrSteward(address identity) external view;
}