Skip to content

Commit 345f1cd

Browse files
committed
Changed commenting style to use /** */
1 parent 3d50278 commit 345f1cd

File tree

115 files changed

+6239
-3122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+6239
-3122
lines changed

script/ERC20.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// SPDX-License-Identifier: MIT
1+
/**
2+
* SPDX-License-Identifier: MIT
3+
*/
24
pragma solidity ^0.8.13;
35

46
import {Script} from "forge-std/Script.sol";

src/access/AccessControl/AccessControlFacet.sol

Lines changed: 121 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,124 @@
1-
// SPDX-License-Identifier: MIT
1+
/**
2+
* SPDX-License-Identifier: MIT
3+
*/
24
pragma solidity >=0.8.30;
35

46
contract AccessControlFacet {
5-
/// @notice Emitted when the admin role for a role is changed.
6-
/// @param _role The role that was changed.
7-
/// @param _previousAdminRole The previous admin role.
8-
/// @param _newAdminRole The new admin role.
7+
/**
8+
* @notice Emitted when the admin role for a role is changed.
9+
* @param _role The role that was changed.
10+
* @param _previousAdminRole The previous admin role.
11+
* @param _newAdminRole The new admin role.
12+
*/
913
event RoleAdminChanged(bytes32 indexed _role, bytes32 indexed _previousAdminRole, bytes32 indexed _newAdminRole);
1014

11-
/// @notice Emitted when a role is granted to an account.
12-
/// @param _role The role that was granted.
13-
/// @param _account The account that was granted the role.
14-
/// @param _sender The sender that granted the role.
15+
/**
16+
* @notice Emitted when a role is granted to an account.
17+
* @param _role The role that was granted.
18+
* @param _account The account that was granted the role.
19+
* @param _sender The sender that granted the role.
20+
*/
1521
event RoleGranted(bytes32 indexed _role, address indexed _account, address indexed _sender);
1622

17-
/// @notice Emitted when a role is revoked from an account.
18-
/// @param _role The role that was revoked.
19-
/// @param _account The account from which the role was revoked.
20-
/// @param _sender The account that revoked the role.
23+
/**
24+
* @notice Emitted when a role is revoked from an account.
25+
* @param _role The role that was revoked.
26+
* @param _account The account from which the role was revoked.
27+
* @param _sender The account that revoked the role.
28+
*/
2129
event RoleRevoked(bytes32 indexed _role, address indexed _account, address indexed _sender);
2230

23-
/// @notice Thrown when the account does not have a specific role.
24-
/// @param _role The role that the account does not have.
25-
/// @param _account The account that does not have the role.
31+
/**
32+
* @notice Thrown when the account does not have a specific role.
33+
* @param _role The role that the account does not have.
34+
* @param _account The account that does not have the role.
35+
*/
2636
error AccessControlUnauthorizedAccount(address _account, bytes32 _role);
2737

28-
/// @notice Thrown when the sender is not the account to renounce the role from.
29-
/// @param _sender The sender that is not the account to renounce the role from.
30-
/// @param _account The account to renounce the role from.
38+
/**
39+
* @notice Thrown when the sender is not the account to renounce the role from.
40+
* @param _sender The sender that is not the account to renounce the role from.
41+
* @param _account The account to renounce the role from.
42+
*/
3143
error AccessControlUnauthorizedSender(address _sender, address _account);
3244

33-
/// @notice Storage slot identifier.
45+
/**
46+
* @notice Storage slot identifier.
47+
*/
3448
bytes32 constant STORAGE_POSITION = keccak256("compose.accesscontrol");
3549

36-
/// @notice Default admin role.
50+
/**
51+
* @notice Default admin role.
52+
*/
3753
bytes32 constant DEFAULT_ADMIN_ROLE = 0x00;
3854

39-
/// @notice storage struct for the AccessControl.
55+
/**
56+
* @notice storage struct for the AccessControl.
57+
*/
4058
struct AccessControlStorage {
4159
mapping(address account => mapping(bytes32 role => bool hasRole)) hasRole;
4260
mapping(bytes32 role => bytes32 adminRole) adminRole;
4361
}
4462

45-
/// @notice Returns the storage for the AccessControl.
46-
/// @return s The storage for the AccessControl.
63+
/**
64+
* @notice Returns the storage for the AccessControl.
65+
* @return s The storage for the AccessControl.
66+
*/
4767
function getStorage() internal pure returns (AccessControlStorage storage s) {
4868
bytes32 position = STORAGE_POSITION;
4969
assembly {
5070
s.slot := position
5171
}
5272
}
5373

54-
/// @notice Returns if an account has a role.
55-
/// @param _role The role to check.
56-
/// @param _account The account to check the role for.
57-
/// @return True if the account has the role, false otherwise.
74+
/**
75+
* @notice Returns if an account has a role.
76+
* @param _role The role to check.
77+
* @param _account The account to check the role for.
78+
* @return True if the account has the role, false otherwise.
79+
*/
5880
function hasRole(bytes32 _role, address _account) external view returns (bool) {
5981
AccessControlStorage storage s = getStorage();
6082
return s.hasRole[_account][_role];
6183
}
6284

63-
/// @notice Checks if an account has a required role.
64-
/// @param _role The role to check.
65-
/// @param _account The account to check the role for.
66-
/// @custom:error AccessControlUnauthorizedAccount If the account does not have the role.
85+
/**
86+
* @notice Checks if an account has a required role.
87+
* @param _role The role to check.
88+
* @param _account The account to check the role for.
89+
* @custom:error AccessControlUnauthorizedAccount If the account does not have the role.
90+
*/
6791
function requireRole(bytes32 _role, address _account) external view {
6892
AccessControlStorage storage s = getStorage();
6993
if (!s.hasRole[_account][_role]) {
7094
revert AccessControlUnauthorizedAccount(_account, _role);
7195
}
7296
}
7397

74-
/// @notice Returns the admin role for a role.
75-
/// @param _role The role to get the admin for.
76-
/// @return The admin role for the role.
98+
/**
99+
* @notice Returns the admin role for a role.
100+
* @param _role The role to get the admin for.
101+
* @return The admin role for the role.
102+
*/
77103
function getRoleAdmin(bytes32 _role) external view returns (bytes32) {
78104
AccessControlStorage storage s = getStorage();
79105
return s.adminRole[_role];
80106
}
81107

82-
/// @notice Sets the admin role for a role.
83-
/// @param _role The role to set the admin for.
84-
/// @param _adminRole The new admin role to set.
85-
/// @dev Emits a {RoleAdminChanged} event.
86-
/// @custom:error AccessControlUnauthorizedAccount If the caller is not the current admin of the role.
108+
/**
109+
* @notice Sets the admin role for a role.
110+
* @param _role The role to set the admin for.
111+
* @param _adminRole The new admin role to set.
112+
* @dev Emits a {RoleAdminChanged} event.
113+
* @custom:error AccessControlUnauthorizedAccount If the caller is not the current admin of the role.
114+
*/
87115
function setRoleAdmin(bytes32 _role, bytes32 _adminRole) external {
88116
AccessControlStorage storage s = getStorage();
89117
bytes32 previousAdminRole = s.adminRole[_role];
90118

91-
// Check if the caller is the current admin of the role.
119+
/**
120+
* Check if the caller is the current admin of the role.
121+
*/
92122
if (!s.hasRole[msg.sender][previousAdminRole]) {
93123
revert AccessControlUnauthorizedAccount(msg.sender, previousAdminRole);
94124
}
@@ -97,16 +127,20 @@ contract AccessControlFacet {
97127
emit RoleAdminChanged(_role, previousAdminRole, _adminRole);
98128
}
99129

100-
/// @notice Grants a role to an account.
101-
/// @param _role The role to grant.
102-
/// @param _account The account to grant the role to.
103-
/// @dev Emits a {RoleGranted} event.
104-
/// @custom:error AccessControlUnauthorizedAccount If the caller is not the admin of the role.
130+
/**
131+
* @notice Grants a role to an account.
132+
* @param _role The role to grant.
133+
* @param _account The account to grant the role to.
134+
* @dev Emits a {RoleGranted} event.
135+
* @custom:error AccessControlUnauthorizedAccount If the caller is not the admin of the role.
136+
*/
105137
function grantRole(bytes32 _role, address _account) external {
106138
AccessControlStorage storage s = getStorage();
107139
bytes32 adminRole = s.adminRole[_role];
108140

109-
// Check if the caller is the admin of the role.
141+
/**
142+
* Check if the caller is the admin of the role.
143+
*/
110144
if (!s.hasRole[msg.sender][adminRole]) {
111145
revert AccessControlUnauthorizedAccount(msg.sender, adminRole);
112146
}
@@ -118,16 +152,20 @@ contract AccessControlFacet {
118152
}
119153
}
120154

121-
/// @notice Revokes a role from an account.
122-
/// @param _role The role to revoke.
123-
/// @param _account The account to revoke the role from.
124-
/// @dev Emits a {RoleRevoked} event.
125-
/// @custom:error AccessControlUnauthorizedAccount If the caller is not the admin of the role.
155+
/**
156+
* @notice Revokes a role from an account.
157+
* @param _role The role to revoke.
158+
* @param _account The account to revoke the role from.
159+
* @dev Emits a {RoleRevoked} event.
160+
* @custom:error AccessControlUnauthorizedAccount If the caller is not the admin of the role.
161+
*/
126162
function revokeRole(bytes32 _role, address _account) external {
127163
AccessControlStorage storage s = getStorage();
128164
bytes32 adminRole = s.adminRole[_role];
129165

130-
// Check if the caller is the admin of the role.
166+
/**
167+
* Check if the caller is the admin of the role.
168+
*/
131169
if (!s.hasRole[msg.sender][adminRole]) {
132170
revert AccessControlUnauthorizedAccount(msg.sender, adminRole);
133171
}
@@ -139,16 +177,20 @@ contract AccessControlFacet {
139177
}
140178
}
141179

142-
/// @notice Grants a role to multiple accounts in a single transaction.
143-
/// @param _role The role to grant.
144-
/// @param _accounts The accounts to grant the role to.
145-
/// @dev Emits a {RoleGranted} event for each newly granted account.
146-
/// @custom:error AccessControlUnauthorizedAccount If the caller is not the admin of the role.
180+
/**
181+
* @notice Grants a role to multiple accounts in a single transaction.
182+
* @param _role The role to grant.
183+
* @param _accounts The accounts to grant the role to.
184+
* @dev Emits a {RoleGranted} event for each newly granted account.
185+
* @custom:error AccessControlUnauthorizedAccount If the caller is not the admin of the role.
186+
*/
147187
function grantRoleBatch(bytes32 _role, address[] calldata _accounts) external {
148188
AccessControlStorage storage s = getStorage();
149189
bytes32 adminRole = s.adminRole[_role];
150190

151-
// Check if the caller is the admin of the role.
191+
/**
192+
* Check if the caller is the admin of the role.
193+
*/
152194
if (!s.hasRole[msg.sender][adminRole]) {
153195
revert AccessControlUnauthorizedAccount(msg.sender, adminRole);
154196
}
@@ -164,16 +206,20 @@ contract AccessControlFacet {
164206
}
165207
}
166208

167-
/// @notice Revokes a role from multiple accounts in a single transaction.
168-
/// @param _role The role to revoke.
169-
/// @param _accounts The accounts to revoke the role from.
170-
/// @dev Emits a {RoleRevoked} event for each account the role is revoked from.
171-
/// @custom:error AccessControlUnauthorizedAccount If the caller is not the admin of the role.
209+
/**
210+
* @notice Revokes a role from multiple accounts in a single transaction.
211+
* @param _role The role to revoke.
212+
* @param _accounts The accounts to revoke the role from.
213+
* @dev Emits a {RoleRevoked} event for each account the role is revoked from.
214+
* @custom:error AccessControlUnauthorizedAccount If the caller is not the admin of the role.
215+
*/
172216
function revokeRoleBatch(bytes32 _role, address[] calldata _accounts) external {
173217
AccessControlStorage storage s = getStorage();
174218
bytes32 adminRole = s.adminRole[_role];
175219

176-
// Check if the caller is the admin of the role.
220+
/**
221+
* Check if the caller is the admin of the role.
222+
*/
177223
if (!s.hasRole[msg.sender][adminRole]) {
178224
revert AccessControlUnauthorizedAccount(msg.sender, adminRole);
179225
}
@@ -189,15 +235,19 @@ contract AccessControlFacet {
189235
}
190236
}
191237

192-
/// @notice Renounces a role from the caller.
193-
/// @param _role The role to renounce.
194-
/// @param _account The account to renounce the role from.
195-
/// @dev Emits a {RoleRevoked} event.
196-
/// @custom:error AccessControlUnauthorizedSender If the caller is not the account to renounce the role from.
238+
/**
239+
* @notice Renounces a role from the caller.
240+
* @param _role The role to renounce.
241+
* @param _account The account to renounce the role from.
242+
* @dev Emits a {RoleRevoked} event.
243+
* @custom:error AccessControlUnauthorizedSender If the caller is not the account to renounce the role from.
244+
*/
197245
function renounceRole(bytes32 _role, address _account) external {
198246
AccessControlStorage storage s = getStorage();
199247

200-
// Check If the caller is not the account to renounce the role from.
248+
/**
249+
* Check If the caller is not the account to renounce the role from.
250+
*/
201251
if (msg.sender != _account) {
202252
revert AccessControlUnauthorizedSender(msg.sender, _account);
203253
}

0 commit comments

Comments
 (0)