Skip to content

Commit 30e18e9

Browse files
Transpile d27635f
1 parent c48092e commit 30e18e9

File tree

5 files changed

+166
-281
lines changed

5 files changed

+166
-281
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
--- access/manager/AccessManager.sol 2023-10-05 12:17:09.694051809 -0300
2+
+++ access/manager/AccessManager.sol 2023-10-05 12:26:18.498688718 -0300
3+
@@ -6,7 +6,6 @@
4+
import {IAccessManaged} from "./IAccessManaged.sol";
5+
import {Address} from "../../utils/Address.sol";
6+
import {Context} from "../../utils/Context.sol";
7+
-import {Multicall} from "../../utils/Multicall.sol";
8+
import {Math} from "../../utils/math/Math.sol";
9+
import {Time} from "../../utils/types/Time.sol";
10+
11+
@@ -57,7 +56,8 @@
12+
* mindful of the danger associated with functions such as {{Ownable-renounceOwnership}} or
13+
* {{AccessControl-renounceRole}}.
14+
*/
15+
-contract AccessManager is Context, Multicall, IAccessManager {
16+
+// NOTE: The FV version of this contract doesn't include Multicall because CVL HAVOCs on any `delegatecall`.
17+
+contract AccessManager is Context, IAccessManager {
18+
using Time for *;
19+
20+
// Structure that stores the details for a target contract.
21+
@@ -105,7 +105,7 @@
22+
23+
// Used to identify operations that are currently being executed via {execute}.
24+
// This should be transient storage when supported by the EVM.
25+
- bytes32 private _executionId;
26+
+ bytes32 internal _executionId; // private → internal for FV
27+
28+
/**
29+
* @dev Check that the caller is authorized to perform the operation, following the restrictions encoded in
30+
@@ -253,6 +253,11 @@
31+
_setGrantDelay(roleId, newDelay);
32+
}
33+
34+
+ // Exposed for FV
35+
+ function _getTargetAdminDelayFull(address target) internal view virtual returns (uint32, uint32, uint48) {
36+
+ return _targets[target].adminDelay.getFull();
37+
+ }
38+
+
39+
/**
40+
* @dev Internal version of {grantRole} without access control. Returns true if the role was newly granted.
41+
*
42+
@@ -287,6 +292,11 @@
43+
return newMember;
44+
}
45+
46+
+ // Exposed for FV
47+
+ function _getRoleGrantDelayFull(uint64 roleId) internal view virtual returns (uint32, uint32, uint48) {
48+
+ return _roles[roleId].grantDelay.getFull();
49+
+ }
50+
+
51+
/**
52+
* @dev Internal version of {revokeRole} without access control. This logic is also used by {renounceRole}.
53+
* Returns true if the role was previously granted.
54+
@@ -586,7 +596,7 @@
55+
/**
56+
* @dev Check if the current call is authorized according to admin logic.
57+
*/
58+
- function _checkAuthorized() private {
59+
+ function _checkAuthorized() internal virtual { // private → internal virtual for FV
60+
address caller = _msgSender();
61+
(bool immediate, uint32 delay) = _canCallSelf(caller, _msgData());
62+
if (!immediate) {
63+
@@ -609,7 +619,7 @@
64+
*/
65+
function _getAdminRestrictions(
66+
bytes calldata data
67+
- ) private view returns (bool restricted, uint64 roleAdminId, uint32 executionDelay) {
68+
+ ) internal view returns (bool restricted, uint64 roleAdminId, uint32 executionDelay) { // private → internal for FV
69+
if (data.length < 4) {
70+
return (false, 0, 0);
71+
}
72+
@@ -662,7 +672,7 @@
73+
address caller,
74+
address target,
75+
bytes calldata data
76+
- ) private view returns (bool immediate, uint32 delay) {
77+
+ ) internal view returns (bool immediate, uint32 delay) { // private → internal for FV
78+
if (target == address(this)) {
79+
return _canCallSelf(caller, data);
80+
} else {
81+
@@ -716,14 +726,14 @@
82+
/**
83+
* @dev Extracts the selector from calldata. Panics if data is not at least 4 bytes
84+
*/
85+
- function _checkSelector(bytes calldata data) private pure returns (bytes4) {
86+
+ function _checkSelector(bytes calldata data) internal pure returns (bytes4) { // private → internal for FV
87+
return bytes4(data[0:4]);
88+
}
89+
90+
/**
91+
* @dev Hashing function for execute protection
92+
*/
93+
- function _hashExecutionId(address target, bytes4 selector) private pure returns (bytes32) {
94+
+ function _hashExecutionId(address target, bytes4 selector) internal pure returns (bytes32) { // private → internal for FV
95+
return keccak256(abi.encode(target, selector));
96+
}
97+
}

contracts/access/README.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ This directory provides ways to restrict who can access the functions of a contr
3232

3333
{{IAuthority}}
3434

35+
{{IAccessManager}}
36+
3537
{{AccessManager}}
3638

39+
{{IAccessManaged}}
40+
3741
{{AccessManaged}}
3842

39-
{{AccessManagerAdapter}}
43+
{{AuthorityUtils}}

contracts/access/manager/AccessManagedUpgradeable.sol

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,13 @@ abstract contract AccessManagedUpgradeable is Initializable, ContextUpgradeable,
7575
_;
7676
}
7777

78-
/**
79-
* @dev Returns the current authority.
80-
*/
78+
/// @inheritdoc IAccessManaged
8179
function authority() public view virtual returns (address) {
8280
AccessManagedStorage storage $ = _getAccessManagedStorage();
8381
return $._authority;
8482
}
8583

86-
/**
87-
* @dev Transfers control to a new authority. The caller must be the current authority.
88-
*/
84+
/// @inheritdoc IAccessManaged
8985
function setAuthority(address newAuthority) public virtual {
9086
address caller = _msgSender();
9187
if (caller != authority()) {
@@ -97,11 +93,7 @@ abstract contract AccessManagedUpgradeable is Initializable, ContextUpgradeable,
9793
_setAuthority(newAuthority);
9894
}
9995

100-
/**
101-
* @dev Returns true only in the context of a delayed restricted call, at the moment that the scheduled operation is
102-
* being consumed. Prevents denial of service for delayed restricted calls in the case that the contract performs
103-
* attacker controlled calls.
104-
*/
96+
/// @inheritdoc IAccessManaged
10597
function isConsumingScheduledOp() public view returns (bytes4) {
10698
AccessManagedStorage storage $ = _getAccessManagedStorage();
10799
return $._consumingSchedule ? this.isConsumingScheduledOp.selector : bytes4(0);

0 commit comments

Comments
 (0)