Skip to content

Commit 32fe6f4

Browse files
committed
remove tests, and update documentation
1 parent 903a7da commit 32fe6f4

File tree

6 files changed

+2441
-2695
lines changed

6 files changed

+2441
-2695
lines changed

.changeset/crazy-bears-flash.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

contracts/access/README.adoc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/
66
This directory provides ways to restrict who can access the functions of a contract or when they can do it.
77

88
- {AccessManager} is a full-fledged access control solution for smart contract systems. Allows creating and assigning multiple hierarchical roles with execution delays for each account across various contracts.
9-
- {AccessManagerEnumerable} is an extension to {AccessManager} that enumerates role members and target functions each role can call.
109
- {AccessManaged} delegates its access control to an authority that dictates the permissions of the managed contract. It's compatible with an AccessManager as an authority.
1110
- {AccessControl} provides a per-contract role based access control mechanism. Multiple hierarchical roles can be created and assigned each to multiple accounts within the same instance.
1211
- {Ownable} is a simpler mechanism with a single owner "role" that can be assigned to a single account. This simpler mechanism can be useful for quick tests but projects with production concerns are likely to outgrow it.
@@ -44,7 +43,3 @@ This directory provides ways to restrict who can access the functions of a contr
4443
{{AccessManaged}}
4544

4645
{{AuthorityUtils}}
47-
48-
=== Extensions
49-
50-
{{AccessManagerEnumerable}}

docs/modules/ROOT/pages/access-control.adoc

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ image::access-manager.svg[AccessManager]
161161
The AccessManager is designed around the concept of role and target functions:
162162

163163
* Roles are granted to accounts (addresses) following a many-to-many approach for flexibility. This means that each user can have one or multiple roles and multiple users can have the same role.
164-
* Access to a restricted target function is limited to one role. A target function is defined by one https://docs.soliditylang.org/en/v0.8.20/abi-spec.html#function-selector[function selector] on one contract (called target).
164+
* Access to a restricted target function is limited to one role. A target function is defined by one https://docs.soliditylang.org/en/v0.8.20/abi-spec.html#function-selector[function selector] on one contract (called target).
165165

166166
For a call to be authorized, the caller must bear the role that is assigned to the current target function (contract address + function selector).
167167

@@ -210,11 +210,11 @@ const HOUR = 60 * 60;
210210
const GRANT_DELAY = 24 * HOUR;
211211
const EXECUTION_DELAY = 5 * HOUR;
212212
const ACCOUNT = "0x...";
213-
213+
214214
await manager.connect(initialAdmin).setGrantDelay(MINTER, GRANT_DELAY);
215215

216216
// The role will go into effect after the GRANT_DELAY passes
217-
await manager.connect(initialAdmin).grantRole(MINTER, ACCOUNT, EXECUTION_DELAY);
217+
await manager.connect(initialAdmin).grantRole(MINTER, ACCOUNT, EXECUTION_DELAY);
218218
```
219219

220220
Note that roles do not define a name. As opposed to the xref:api:access.adoc#AccessControl[`AccessControl`] case, roles are identified as numeric values instead of being hardcoded in the contract as `bytes32` values. It is still possible to allow for tooling discovery (e.g. for role exploration) using role labeling with the xref:api:access.adoc#AccessManager-labelRole-uint64-string-[`labelRole`] function.
@@ -279,19 +279,13 @@ Similar to `AccessControl`, accounts might be granted and revoked roles dynamica
279279

280280
The base `AccessManager` contract provides comprehensive role-based access control but does not support on-chain enumeration of role members or target function permissions by default. To track which accounts hold roles and which functions are assigned to roles, you should rely on the xref:api:access.adoc#AccessManager-RoleGranted-uint64-address-uint32-uint48-bool-[RoleGranted], xref:api:access.adoc#AccessManager-RoleRevoked-uint64-address-[RoleRevoked], and xref:api:access.adoc#AccessManager-TargetFunctionRoleUpdated-address-bytes4-uint64-[TargetFunctionRoleUpdated] events, which can be processed off-chain.
281281

282-
If on-chain enumeration is required, you can use the xref:api:access.adoc#AccessManagerEnumerable[`AccessManagerEnumerable`] extension. This extension uses `EnumerableSet` internally and provides the following functions for role members:
283-
284-
* xref:api:access.adoc#AccessManagerEnumerable-getRoleTargetFunctionCount-uint64-address-[`getRoleMemberCount`]
285-
* xref:api:access.adoc#AccessManagerEnumerable-getRoleMember-uint64-uint256-[`getRoleMember`]
286-
* xref:api:access.adoc#AccessManagerEnumerable-getRoleMembers-uint64-uint256-uint256-[`getRoleMembers`]
287-
288-
And these functions for target function permissions:
282+
If on-chain enumeration is required, it can be added implemented on top of the existing logic:
289283

290-
* xref:api:access.adoc#AccessManagerEnumerable-getRoleTargetFunctionCount-uint64-address-[`getRoleTargetFunctionCount`]
291-
* xref:api:access.adoc#AccessManagerEnumerable-getRoleTargetFunction-uint64-address-uint256-[`getRoleTargetFunction`]
292-
* xref:api:access.adoc#AccessManagerEnumerable-getRoleTargetFunctions-uint64-address-uint256-uint256-[`getRoleTargetFunctions`]
284+
```solidity
285+
include::api:example$AccessManagerEnumerable.sol[]
286+
```
293287

294-
These can be used to iterate over the accounts that have been granted a role and the functions that a role is allowed to call on specific targets:
288+
This adds function that can be queried to iterate over the accounts that have been granted a role and the functions that a role is allowed to call on specific targets:
295289

296290
```javascript
297291
// Enumerate role members
@@ -318,8 +312,6 @@ for (let i = 0; i < functionCount; ++i) {
318312
const allFunctions = await accessManager.getRoleTargetFunctions(MINTER_ROLE, target, 0, ethers.MaxUint256);
319313
```
320314

321-
Note that target function enumeration is organized per target contract, allowing you to query which functions a role can access on each specific target separately. This provides fine-grained visibility into the permission structure across your entire system of managed contracts.
322-
323315
=== Using with Ownable
324316

325317
Contracts already inheriting from xref:api:access.adoc#Ownable[`Ownable`] can migrate to AccessManager by transferring ownership to the manager. After that, all calls to functions with the `onlyOwner` modifier should be called through the manager's xref:api:access.adoc#AccessManager-execute-address-bytes-[`execute`] function, even if the caller doesn't require a delay.

0 commit comments

Comments
 (0)