-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Docs Syncer
committed
Feb 24, 2024
1 parent
ebd4f58
commit fe6cc40
Showing
2 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
docs/reference/contracts/diamond/access/DiamondAccessControl.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# DiamondAccessControl | ||
|
||
## Overview | ||
|
||
#### License: MIT | ||
|
||
```solidity | ||
abstract contract DiamondAccessControl is DiamondAccessControlStorage | ||
``` | ||
|
||
The Diamond standard module | ||
|
||
This is modified version of OpenZeppelin's AccessControl contract to be used as a Storage contract | ||
by the Diamond Standard. | ||
## Modifiers info | ||
|
||
### onlyRole | ||
|
||
```solidity | ||
modifier onlyRole(bytes32 role_) | ||
``` | ||
|
||
Modifier that checks that an account has a specific role. Reverts | ||
with a standardized message including the required role. | ||
|
||
The format of the revert reason is given by the following regular expression: | ||
|
||
/^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ | ||
## Functions info | ||
|
||
### grantRole (0x2f2ff15d) | ||
|
||
```solidity | ||
function grantRole( | ||
bytes32 role_, | ||
address account_ | ||
) public virtual override onlyRole(getRoleAdmin(role_)) | ||
``` | ||
|
||
Grants `role` to `account`. | ||
|
||
If `account` had not been already granted `role`, emits a {RoleGranted} | ||
event. | ||
|
||
Requirements: | ||
|
||
- the caller must have ``role``'s admin role. | ||
### revokeRole (0xd547741f) | ||
|
||
```solidity | ||
function revokeRole( | ||
bytes32 role_, | ||
address account_ | ||
) public virtual override onlyRole(getRoleAdmin(role_)) | ||
``` | ||
|
||
Revokes `role` from `account`. | ||
|
||
If `account` had been granted `role`, emits a {RoleRevoked} event. | ||
|
||
Requirements: | ||
|
||
- the caller must have ``role``'s admin role. | ||
### renounceRole (0x36568abe) | ||
|
||
```solidity | ||
function renounceRole(bytes32 role_, address account_) public virtual override | ||
``` | ||
|
||
Revokes `role` from the calling account. | ||
|
||
Roles are often managed via {grantRole} and {revokeRole}: this function's | ||
purpose is to provide a mechanism for accounts to lose their privileges | ||
if they are compromised (such as when a trusted device is misplaced). | ||
|
||
If the calling account had been granted `role`, emits a {RoleRevoked} | ||
event. | ||
|
||
Requirements: | ||
|
||
- the caller must be `account`. |
74 changes: 74 additions & 0 deletions
74
docs/reference/contracts/diamond/access/DiamondAccessControlStorage.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# DiamondAccessControlStorage | ||
|
||
## Overview | ||
|
||
#### License: MIT | ||
|
||
```solidity | ||
abstract contract DiamondAccessControlStorage is IAccessControl, InitializableStorage | ||
``` | ||
|
||
The Diamond standard module | ||
|
||
This is an AccessControl Storage contract with Diamond Standard support | ||
## Structs info | ||
|
||
### RoleData | ||
|
||
```solidity | ||
struct RoleData { | ||
mapping(address => bool) members; | ||
bytes32 adminRole; | ||
} | ||
``` | ||
|
||
|
||
### DACStorage | ||
|
||
```solidity | ||
struct DACStorage { | ||
mapping(bytes32 => DiamondAccessControlStorage.RoleData) roles; | ||
} | ||
``` | ||
|
||
|
||
## Constants info | ||
|
||
### DIAMOND_ACCESS_CONTROL_STORAGE_SLOT (0xb29b3bc0) | ||
|
||
```solidity | ||
bytes32 constant DIAMOND_ACCESS_CONTROL_STORAGE_SLOT = keccak256("diamond.standard.diamond.access.control.storage") | ||
``` | ||
|
||
|
||
### DEFAULT_ADMIN_ROLE (0xa217fddf) | ||
|
||
```solidity | ||
bytes32 constant DEFAULT_ADMIN_ROLE = 0x00 | ||
``` | ||
|
||
|
||
## Functions info | ||
|
||
### hasRole (0x91d14854) | ||
|
||
```solidity | ||
function hasRole( | ||
bytes32 role_, | ||
address account_ | ||
) public view virtual override returns (bool) | ||
``` | ||
|
||
Returns `true` if `account` has been granted `role`. | ||
### getRoleAdmin (0x248a9ca3) | ||
|
||
```solidity | ||
function getRoleAdmin( | ||
bytes32 role_ | ||
) public view virtual override returns (bytes32) | ||
``` | ||
|
||
Returns the admin role that controls `role`. See {grantRole} and | ||
{revokeRole}. | ||
|
||
To change a role's admin, use {AccessControl-_setRoleAdmin}. |