@@ -7,7 +7,7 @@ import {IRBAC} from "../interfaces/access/IRBAC.sol";
77
88import {TypeCaster} from "../libs/utils/TypeCaster.sol " ;
99import {SetHelper} from "../libs/arrays/SetHelper.sol " ;
10- import {StringSet } from "../libs/data-structures/StringSet .sol " ;
10+ import {DynamicSet } from "../libs/data-structures/DynamicSet .sol " ;
1111
1212/**
1313 * @notice The Role Based Access Control (RBAC) module
@@ -31,8 +31,8 @@ import {StringSet} from "../libs/data-structures/StringSet.sol";
3131 * Where ROLE is assignable to users
3232 */
3333abstract contract RBAC is IRBAC , Initializable {
34- using StringSet for StringSet.Set ;
35- using SetHelper for StringSet.Set ;
34+ using DynamicSet for DynamicSet.StringSet ;
35+ using SetHelper for DynamicSet.StringSet ;
3636 using TypeCaster for string ;
3737
3838 string public constant MASTER_ROLE = "MASTER " ;
@@ -47,10 +47,11 @@ abstract contract RBAC is IRBAC, Initializable {
4747
4848 string public constant RBAC_RESOURCE = "RBAC_RESOURCE " ;
4949
50- mapping (string => mapping (bool => mapping (string => StringSet.Set))) private _rolePermissions;
51- mapping (string => mapping (bool => StringSet.Set)) private _roleResources;
50+ mapping (string => mapping (bool => mapping (string => DynamicSet.StringSet)))
51+ private _rolePermissions;
52+ mapping (string => mapping (bool => DynamicSet.StringSet)) private _roleResources;
5253
53- mapping (address => StringSet.Set ) private _userRoles;
54+ mapping (address => DynamicSet.StringSet ) private _userRoles;
5455
5556 modifier onlyPermission (string memory resource_ , string memory permission_ ) {
5657 require (
@@ -165,15 +166,15 @@ abstract contract RBAC is IRBAC, Initializable {
165166 ResourceWithPermissions[] memory disallowed_
166167 )
167168 {
168- StringSet.Set storage _allowedResources = _roleResources[role_][true ];
169- StringSet.Set storage _disallowedResources = _roleResources[role_][false ];
169+ DynamicSet.StringSet storage _allowedResources = _roleResources[role_][true ];
170+ DynamicSet.StringSet storage _disallowedResources = _roleResources[role_][false ];
170171
171- mapping (string => StringSet.Set ) storage _allowedPermissions = _rolePermissions[role_] [
172- true
173- ];
174- mapping (string => StringSet.Set ) storage _disallowedPermissions = _rolePermissions[role_] [
175- false
176- ];
172+ mapping (string => DynamicSet.StringSet ) storage _allowedPermissions = _rolePermissions[
173+ role_
174+ ][ true ] ;
175+ mapping (string => DynamicSet.StringSet ) storage _disallowedPermissions = _rolePermissions[
176+ role_
177+ ][ false ] ;
177178
178179 allowed_ = new ResourceWithPermissions [](_allowedResources.length ());
179180 disallowed_ = new ResourceWithPermissions [](_disallowedResources.length ());
@@ -253,8 +254,10 @@ abstract contract RBAC is IRBAC, Initializable {
253254 string [] memory permissionsToAdd_ ,
254255 bool allowed_
255256 ) internal {
256- StringSet.Set storage _resources = _roleResources[role_][allowed_];
257- StringSet.Set storage _permissions = _rolePermissions[role_][allowed_][resourceToAdd_];
257+ DynamicSet.StringSet storage _resources = _roleResources[role_][allowed_];
258+ DynamicSet.StringSet storage _permissions = _rolePermissions[role_][allowed_][
259+ resourceToAdd_
260+ ];
258261
259262 _permissions.add (permissionsToAdd_);
260263 _resources.add (resourceToAdd_);
@@ -275,8 +278,10 @@ abstract contract RBAC is IRBAC, Initializable {
275278 string [] memory permissionsToRemove_ ,
276279 bool allowed_
277280 ) internal {
278- StringSet.Set storage _resources = _roleResources[role_][allowed_];
279- StringSet.Set storage _permissions = _rolePermissions[role_][allowed_][resourceToRemove_];
281+ DynamicSet.StringSet storage _resources = _roleResources[role_][allowed_];
282+ DynamicSet.StringSet storage _permissions = _rolePermissions[role_][allowed_][
283+ resourceToRemove_
284+ ];
280285
281286 _permissions.remove (permissionsToRemove_);
282287
@@ -299,10 +304,10 @@ abstract contract RBAC is IRBAC, Initializable {
299304 string memory resource_ ,
300305 string memory permission_
301306 ) internal view returns (bool ) {
302- mapping (string => StringSet.Set ) storage _resources = _rolePermissions[role_][true ];
307+ mapping (string => DynamicSet.StringSet ) storage _resources = _rolePermissions[role_][true ];
303308
304- StringSet.Set storage _allAllowed = _resources[ALL_RESOURCE];
305- StringSet.Set storage _allowed = _resources[resource_];
309+ DynamicSet.StringSet storage _allAllowed = _resources[ALL_RESOURCE];
310+ DynamicSet.StringSet storage _allowed = _resources[resource_];
306311
307312 return (_allAllowed.contains (ALL_PERMISSION) ||
308313 _allAllowed.contains (permission_) ||
@@ -322,10 +327,12 @@ abstract contract RBAC is IRBAC, Initializable {
322327 string memory resource_ ,
323328 string memory permission_
324329 ) internal view returns (bool ) {
325- mapping (string => StringSet.Set) storage _resources = _rolePermissions[role_][false ];
330+ mapping (string => DynamicSet.StringSet) storage _resources = _rolePermissions[role_][
331+ false
332+ ];
326333
327- StringSet.Set storage _allDisallowed = _resources[ALL_RESOURCE];
328- StringSet.Set storage _disallowed = _resources[resource_];
334+ DynamicSet.StringSet storage _allDisallowed = _resources[ALL_RESOURCE];
335+ DynamicSet.StringSet storage _disallowed = _resources[resource_];
329336
330337 return (_allDisallowed.contains (ALL_PERMISSION) ||
331338 _allDisallowed.contains (permission_) ||
0 commit comments