@ensuro/access-managed-proxy 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +15 -0
  2. package/build/build-info.json +1 -0
  3. package/build/contracts/AccessManagedProxy.sol/AccessManagedProxy.json +105 -0
  4. package/build/contracts/amps/AccessManagedProxyS1.sol/AccessManagedProxyS1.json +123 -0
  5. package/build/contracts/amps/AccessManagedProxyS10.sol/AccessManagedProxyS10.json +123 -0
  6. package/build/contracts/amps/AccessManagedProxyS11.sol/AccessManagedProxyS11.json +123 -0
  7. package/build/contracts/amps/AccessManagedProxyS12.sol/AccessManagedProxyS12.json +123 -0
  8. package/build/contracts/amps/AccessManagedProxyS13.sol/AccessManagedProxyS13.json +123 -0
  9. package/build/contracts/amps/AccessManagedProxyS14.sol/AccessManagedProxyS14.json +123 -0
  10. package/build/contracts/amps/AccessManagedProxyS15.sol/AccessManagedProxyS15.json +123 -0
  11. package/build/contracts/amps/AccessManagedProxyS16.sol/AccessManagedProxyS16.json +123 -0
  12. package/build/contracts/amps/AccessManagedProxyS17.sol/AccessManagedProxyS17.json +123 -0
  13. package/build/contracts/amps/AccessManagedProxyS18.sol/AccessManagedProxyS18.json +123 -0
  14. package/build/contracts/amps/AccessManagedProxyS19.sol/AccessManagedProxyS19.json +123 -0
  15. package/build/contracts/amps/AccessManagedProxyS2.sol/AccessManagedProxyS2.json +123 -0
  16. package/build/contracts/amps/AccessManagedProxyS20.sol/AccessManagedProxyS20.json +123 -0
  17. package/build/contracts/amps/AccessManagedProxyS21.sol/AccessManagedProxyS21.json +123 -0
  18. package/build/contracts/amps/AccessManagedProxyS22.sol/AccessManagedProxyS22.json +123 -0
  19. package/build/contracts/amps/AccessManagedProxyS23.sol/AccessManagedProxyS23.json +123 -0
  20. package/build/contracts/amps/AccessManagedProxyS24.sol/AccessManagedProxyS24.json +123 -0
  21. package/build/contracts/amps/AccessManagedProxyS3.sol/AccessManagedProxyS3.json +123 -0
  22. package/build/contracts/amps/AccessManagedProxyS4.sol/AccessManagedProxyS4.json +123 -0
  23. package/build/contracts/amps/AccessManagedProxyS5.sol/AccessManagedProxyS5.json +123 -0
  24. package/build/contracts/amps/AccessManagedProxyS6.sol/AccessManagedProxyS6.json +123 -0
  25. package/build/contracts/amps/AccessManagedProxyS7.sol/AccessManagedProxyS7.json +123 -0
  26. package/build/contracts/amps/AccessManagedProxyS8.sol/AccessManagedProxyS8.json +123 -0
  27. package/build/contracts/amps/AccessManagedProxyS9.sol/AccessManagedProxyS9.json +123 -0
  28. package/build/contracts/mock/DummyImplementation.sol/DummyImplementation.json +225 -0
  29. package/contracts/AccessManagedProxy.sol +85 -0
  30. package/contracts/amps/AccessManagedProxyS1.sol +63 -0
  31. package/contracts/amps/AccessManagedProxyS10.sol +99 -0
  32. package/contracts/amps/AccessManagedProxyS11.sol +103 -0
  33. package/contracts/amps/AccessManagedProxyS12.sol +107 -0
  34. package/contracts/amps/AccessManagedProxyS13.sol +111 -0
  35. package/contracts/amps/AccessManagedProxyS14.sol +115 -0
  36. package/contracts/amps/AccessManagedProxyS15.sol +119 -0
  37. package/contracts/amps/AccessManagedProxyS16.sol +123 -0
  38. package/contracts/amps/AccessManagedProxyS17.sol +127 -0
  39. package/contracts/amps/AccessManagedProxyS18.sol +131 -0
  40. package/contracts/amps/AccessManagedProxyS19.sol +135 -0
  41. package/contracts/amps/AccessManagedProxyS2.sol +67 -0
  42. package/contracts/amps/AccessManagedProxyS20.sol +139 -0
  43. package/contracts/amps/AccessManagedProxyS21.sol +143 -0
  44. package/contracts/amps/AccessManagedProxyS22.sol +147 -0
  45. package/contracts/amps/AccessManagedProxyS23.sol +151 -0
  46. package/contracts/amps/AccessManagedProxyS24.sol +155 -0
  47. package/contracts/amps/AccessManagedProxyS3.sol +71 -0
  48. package/contracts/amps/AccessManagedProxyS4.sol +75 -0
  49. package/contracts/amps/AccessManagedProxyS5.sol +79 -0
  50. package/contracts/amps/AccessManagedProxyS6.sol +83 -0
  51. package/contracts/amps/AccessManagedProxyS7.sol +87 -0
  52. package/contracts/amps/AccessManagedProxyS8.sol +91 -0
  53. package/contracts/amps/AccessManagedProxyS9.sol +95 -0
  54. package/contracts/mock/DummyImplementation.sol +53 -0
  55. package/package.json +28 -0
@@ -0,0 +1,103 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {AccessManagedProxy} from "../AccessManagedProxy.sol";
5
+ import {IAccessManager} from "@openzeppelin/contracts/access/manager/IAccessManager.sol";
6
+
7
+ /**
8
+ * @title AccessManagedProxyS11
9
+ * @notice Specialization of AccessManagedProxy with pass thru (skips AM) for some messages for gas optimization
10
+ *
11
+ * @custom:security-contact security@ensuro.co
12
+ * @author Ensuro
13
+ */
14
+ contract AccessManagedProxyS11 is AccessManagedProxy {
15
+ bytes4 internal immutable PASS_THRU_METHODS_0;
16
+ bytes4 internal immutable PASS_THRU_METHODS_1;
17
+ bytes4 internal immutable PASS_THRU_METHODS_2;
18
+ bytes4 internal immutable PASS_THRU_METHODS_3;
19
+ bytes4 internal immutable PASS_THRU_METHODS_4;
20
+ bytes4 internal immutable PASS_THRU_METHODS_5;
21
+ bytes4 internal immutable PASS_THRU_METHODS_6;
22
+ bytes4 internal immutable PASS_THRU_METHODS_7;
23
+ bytes4 internal immutable PASS_THRU_METHODS_8;
24
+ bytes4 internal immutable PASS_THRU_METHODS_9;
25
+ bytes4 internal immutable PASS_THRU_METHODS_10;
26
+
27
+ /**
28
+ * @notice Constructor of the proxy, defining the implementation and the access manager
29
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
30
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
31
+ *
32
+ * @param implementation The initial implementation contract.
33
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
34
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
35
+ * @param manager The access manager that will handle access control
36
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
37
+ * views and other methods for gas optimization.
38
+ *
39
+ * Requirements:
40
+ *
41
+ * - If `data` is empty, `msg.value` must be zero.
42
+ */
43
+ constructor(
44
+ address implementation,
45
+ bytes memory _data,
46
+ IAccessManager manager,
47
+ bytes4[11] memory passThruMethods
48
+ ) payable AccessManagedProxy(implementation, _data, manager) {
49
+ PASS_THRU_METHODS_0 = passThruMethods[0];
50
+ PASS_THRU_METHODS_1 = passThruMethods[1];
51
+ PASS_THRU_METHODS_2 = passThruMethods[2];
52
+ PASS_THRU_METHODS_3 = passThruMethods[3];
53
+ PASS_THRU_METHODS_4 = passThruMethods[4];
54
+ PASS_THRU_METHODS_5 = passThruMethods[5];
55
+ PASS_THRU_METHODS_6 = passThruMethods[6];
56
+ PASS_THRU_METHODS_7 = passThruMethods[7];
57
+ PASS_THRU_METHODS_8 = passThruMethods[8];
58
+ PASS_THRU_METHODS_9 = passThruMethods[9];
59
+ PASS_THRU_METHODS_10 = passThruMethods[10];
60
+ }
61
+
62
+ /*
63
+ * @notice Skips the access control if the method called is one of the passThruMethods
64
+ * @dev See {PASS_THRU_METHODS()}
65
+ * @param selector The selector of the method called
66
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
67
+ */
68
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
69
+ return
70
+ selector == PASS_THRU_METHODS_0 ||
71
+ selector == PASS_THRU_METHODS_1 ||
72
+ selector == PASS_THRU_METHODS_2 ||
73
+ selector == PASS_THRU_METHODS_3 ||
74
+ selector == PASS_THRU_METHODS_4 ||
75
+ selector == PASS_THRU_METHODS_5 ||
76
+ selector == PASS_THRU_METHODS_6 ||
77
+ selector == PASS_THRU_METHODS_7 ||
78
+ selector == PASS_THRU_METHODS_8 ||
79
+ selector == PASS_THRU_METHODS_9 ||
80
+ selector == PASS_THRU_METHODS_10;
81
+ }
82
+
83
+ /**
84
+ * @notice Gives observability to the methods that are skipped from access control
85
+ * @dev This list is fixed and defined on contract construction
86
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
87
+ */
88
+ // solhint-disable-next-line func-name-mixedcase
89
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
90
+ methods = new bytes4[](11);
91
+ methods[0] = PASS_THRU_METHODS_0;
92
+ methods[1] = PASS_THRU_METHODS_1;
93
+ methods[2] = PASS_THRU_METHODS_2;
94
+ methods[3] = PASS_THRU_METHODS_3;
95
+ methods[4] = PASS_THRU_METHODS_4;
96
+ methods[5] = PASS_THRU_METHODS_5;
97
+ methods[6] = PASS_THRU_METHODS_6;
98
+ methods[7] = PASS_THRU_METHODS_7;
99
+ methods[8] = PASS_THRU_METHODS_8;
100
+ methods[9] = PASS_THRU_METHODS_9;
101
+ methods[10] = PASS_THRU_METHODS_10;
102
+ }
103
+ }
@@ -0,0 +1,107 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {AccessManagedProxy} from "../AccessManagedProxy.sol";
5
+ import {IAccessManager} from "@openzeppelin/contracts/access/manager/IAccessManager.sol";
6
+
7
+ /**
8
+ * @title AccessManagedProxyS12
9
+ * @notice Specialization of AccessManagedProxy with pass thru (skips AM) for some messages for gas optimization
10
+ *
11
+ * @custom:security-contact security@ensuro.co
12
+ * @author Ensuro
13
+ */
14
+ contract AccessManagedProxyS12 is AccessManagedProxy {
15
+ bytes4 internal immutable PASS_THRU_METHODS_0;
16
+ bytes4 internal immutable PASS_THRU_METHODS_1;
17
+ bytes4 internal immutable PASS_THRU_METHODS_2;
18
+ bytes4 internal immutable PASS_THRU_METHODS_3;
19
+ bytes4 internal immutable PASS_THRU_METHODS_4;
20
+ bytes4 internal immutable PASS_THRU_METHODS_5;
21
+ bytes4 internal immutable PASS_THRU_METHODS_6;
22
+ bytes4 internal immutable PASS_THRU_METHODS_7;
23
+ bytes4 internal immutable PASS_THRU_METHODS_8;
24
+ bytes4 internal immutable PASS_THRU_METHODS_9;
25
+ bytes4 internal immutable PASS_THRU_METHODS_10;
26
+ bytes4 internal immutable PASS_THRU_METHODS_11;
27
+
28
+ /**
29
+ * @notice Constructor of the proxy, defining the implementation and the access manager
30
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
31
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
32
+ *
33
+ * @param implementation The initial implementation contract.
34
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
35
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
36
+ * @param manager The access manager that will handle access control
37
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
38
+ * views and other methods for gas optimization.
39
+ *
40
+ * Requirements:
41
+ *
42
+ * - If `data` is empty, `msg.value` must be zero.
43
+ */
44
+ constructor(
45
+ address implementation,
46
+ bytes memory _data,
47
+ IAccessManager manager,
48
+ bytes4[12] memory passThruMethods
49
+ ) payable AccessManagedProxy(implementation, _data, manager) {
50
+ PASS_THRU_METHODS_0 = passThruMethods[0];
51
+ PASS_THRU_METHODS_1 = passThruMethods[1];
52
+ PASS_THRU_METHODS_2 = passThruMethods[2];
53
+ PASS_THRU_METHODS_3 = passThruMethods[3];
54
+ PASS_THRU_METHODS_4 = passThruMethods[4];
55
+ PASS_THRU_METHODS_5 = passThruMethods[5];
56
+ PASS_THRU_METHODS_6 = passThruMethods[6];
57
+ PASS_THRU_METHODS_7 = passThruMethods[7];
58
+ PASS_THRU_METHODS_8 = passThruMethods[8];
59
+ PASS_THRU_METHODS_9 = passThruMethods[9];
60
+ PASS_THRU_METHODS_10 = passThruMethods[10];
61
+ PASS_THRU_METHODS_11 = passThruMethods[11];
62
+ }
63
+
64
+ /*
65
+ * @notice Skips the access control if the method called is one of the passThruMethods
66
+ * @dev See {PASS_THRU_METHODS()}
67
+ * @param selector The selector of the method called
68
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
69
+ */
70
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
71
+ return
72
+ selector == PASS_THRU_METHODS_0 ||
73
+ selector == PASS_THRU_METHODS_1 ||
74
+ selector == PASS_THRU_METHODS_2 ||
75
+ selector == PASS_THRU_METHODS_3 ||
76
+ selector == PASS_THRU_METHODS_4 ||
77
+ selector == PASS_THRU_METHODS_5 ||
78
+ selector == PASS_THRU_METHODS_6 ||
79
+ selector == PASS_THRU_METHODS_7 ||
80
+ selector == PASS_THRU_METHODS_8 ||
81
+ selector == PASS_THRU_METHODS_9 ||
82
+ selector == PASS_THRU_METHODS_10 ||
83
+ selector == PASS_THRU_METHODS_11;
84
+ }
85
+
86
+ /**
87
+ * @notice Gives observability to the methods that are skipped from access control
88
+ * @dev This list is fixed and defined on contract construction
89
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
90
+ */
91
+ // solhint-disable-next-line func-name-mixedcase
92
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
93
+ methods = new bytes4[](12);
94
+ methods[0] = PASS_THRU_METHODS_0;
95
+ methods[1] = PASS_THRU_METHODS_1;
96
+ methods[2] = PASS_THRU_METHODS_2;
97
+ methods[3] = PASS_THRU_METHODS_3;
98
+ methods[4] = PASS_THRU_METHODS_4;
99
+ methods[5] = PASS_THRU_METHODS_5;
100
+ methods[6] = PASS_THRU_METHODS_6;
101
+ methods[7] = PASS_THRU_METHODS_7;
102
+ methods[8] = PASS_THRU_METHODS_8;
103
+ methods[9] = PASS_THRU_METHODS_9;
104
+ methods[10] = PASS_THRU_METHODS_10;
105
+ methods[11] = PASS_THRU_METHODS_11;
106
+ }
107
+ }
@@ -0,0 +1,111 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {AccessManagedProxy} from "../AccessManagedProxy.sol";
5
+ import {IAccessManager} from "@openzeppelin/contracts/access/manager/IAccessManager.sol";
6
+
7
+ /**
8
+ * @title AccessManagedProxyS13
9
+ * @notice Specialization of AccessManagedProxy with pass thru (skips AM) for some messages for gas optimization
10
+ *
11
+ * @custom:security-contact security@ensuro.co
12
+ * @author Ensuro
13
+ */
14
+ contract AccessManagedProxyS13 is AccessManagedProxy {
15
+ bytes4 internal immutable PASS_THRU_METHODS_0;
16
+ bytes4 internal immutable PASS_THRU_METHODS_1;
17
+ bytes4 internal immutable PASS_THRU_METHODS_2;
18
+ bytes4 internal immutable PASS_THRU_METHODS_3;
19
+ bytes4 internal immutable PASS_THRU_METHODS_4;
20
+ bytes4 internal immutable PASS_THRU_METHODS_5;
21
+ bytes4 internal immutable PASS_THRU_METHODS_6;
22
+ bytes4 internal immutable PASS_THRU_METHODS_7;
23
+ bytes4 internal immutable PASS_THRU_METHODS_8;
24
+ bytes4 internal immutable PASS_THRU_METHODS_9;
25
+ bytes4 internal immutable PASS_THRU_METHODS_10;
26
+ bytes4 internal immutable PASS_THRU_METHODS_11;
27
+ bytes4 internal immutable PASS_THRU_METHODS_12;
28
+
29
+ /**
30
+ * @notice Constructor of the proxy, defining the implementation and the access manager
31
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
32
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
33
+ *
34
+ * @param implementation The initial implementation contract.
35
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
36
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
37
+ * @param manager The access manager that will handle access control
38
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
39
+ * views and other methods for gas optimization.
40
+ *
41
+ * Requirements:
42
+ *
43
+ * - If `data` is empty, `msg.value` must be zero.
44
+ */
45
+ constructor(
46
+ address implementation,
47
+ bytes memory _data,
48
+ IAccessManager manager,
49
+ bytes4[13] memory passThruMethods
50
+ ) payable AccessManagedProxy(implementation, _data, manager) {
51
+ PASS_THRU_METHODS_0 = passThruMethods[0];
52
+ PASS_THRU_METHODS_1 = passThruMethods[1];
53
+ PASS_THRU_METHODS_2 = passThruMethods[2];
54
+ PASS_THRU_METHODS_3 = passThruMethods[3];
55
+ PASS_THRU_METHODS_4 = passThruMethods[4];
56
+ PASS_THRU_METHODS_5 = passThruMethods[5];
57
+ PASS_THRU_METHODS_6 = passThruMethods[6];
58
+ PASS_THRU_METHODS_7 = passThruMethods[7];
59
+ PASS_THRU_METHODS_8 = passThruMethods[8];
60
+ PASS_THRU_METHODS_9 = passThruMethods[9];
61
+ PASS_THRU_METHODS_10 = passThruMethods[10];
62
+ PASS_THRU_METHODS_11 = passThruMethods[11];
63
+ PASS_THRU_METHODS_12 = passThruMethods[12];
64
+ }
65
+
66
+ /*
67
+ * @notice Skips the access control if the method called is one of the passThruMethods
68
+ * @dev See {PASS_THRU_METHODS()}
69
+ * @param selector The selector of the method called
70
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
71
+ */
72
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
73
+ return
74
+ selector == PASS_THRU_METHODS_0 ||
75
+ selector == PASS_THRU_METHODS_1 ||
76
+ selector == PASS_THRU_METHODS_2 ||
77
+ selector == PASS_THRU_METHODS_3 ||
78
+ selector == PASS_THRU_METHODS_4 ||
79
+ selector == PASS_THRU_METHODS_5 ||
80
+ selector == PASS_THRU_METHODS_6 ||
81
+ selector == PASS_THRU_METHODS_7 ||
82
+ selector == PASS_THRU_METHODS_8 ||
83
+ selector == PASS_THRU_METHODS_9 ||
84
+ selector == PASS_THRU_METHODS_10 ||
85
+ selector == PASS_THRU_METHODS_11 ||
86
+ selector == PASS_THRU_METHODS_12;
87
+ }
88
+
89
+ /**
90
+ * @notice Gives observability to the methods that are skipped from access control
91
+ * @dev This list is fixed and defined on contract construction
92
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
93
+ */
94
+ // solhint-disable-next-line func-name-mixedcase
95
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
96
+ methods = new bytes4[](13);
97
+ methods[0] = PASS_THRU_METHODS_0;
98
+ methods[1] = PASS_THRU_METHODS_1;
99
+ methods[2] = PASS_THRU_METHODS_2;
100
+ methods[3] = PASS_THRU_METHODS_3;
101
+ methods[4] = PASS_THRU_METHODS_4;
102
+ methods[5] = PASS_THRU_METHODS_5;
103
+ methods[6] = PASS_THRU_METHODS_6;
104
+ methods[7] = PASS_THRU_METHODS_7;
105
+ methods[8] = PASS_THRU_METHODS_8;
106
+ methods[9] = PASS_THRU_METHODS_9;
107
+ methods[10] = PASS_THRU_METHODS_10;
108
+ methods[11] = PASS_THRU_METHODS_11;
109
+ methods[12] = PASS_THRU_METHODS_12;
110
+ }
111
+ }
@@ -0,0 +1,115 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {AccessManagedProxy} from "../AccessManagedProxy.sol";
5
+ import {IAccessManager} from "@openzeppelin/contracts/access/manager/IAccessManager.sol";
6
+
7
+ /**
8
+ * @title AccessManagedProxyS14
9
+ * @notice Specialization of AccessManagedProxy with pass thru (skips AM) for some messages for gas optimization
10
+ *
11
+ * @custom:security-contact security@ensuro.co
12
+ * @author Ensuro
13
+ */
14
+ contract AccessManagedProxyS14 is AccessManagedProxy {
15
+ bytes4 internal immutable PASS_THRU_METHODS_0;
16
+ bytes4 internal immutable PASS_THRU_METHODS_1;
17
+ bytes4 internal immutable PASS_THRU_METHODS_2;
18
+ bytes4 internal immutable PASS_THRU_METHODS_3;
19
+ bytes4 internal immutable PASS_THRU_METHODS_4;
20
+ bytes4 internal immutable PASS_THRU_METHODS_5;
21
+ bytes4 internal immutable PASS_THRU_METHODS_6;
22
+ bytes4 internal immutable PASS_THRU_METHODS_7;
23
+ bytes4 internal immutable PASS_THRU_METHODS_8;
24
+ bytes4 internal immutable PASS_THRU_METHODS_9;
25
+ bytes4 internal immutable PASS_THRU_METHODS_10;
26
+ bytes4 internal immutable PASS_THRU_METHODS_11;
27
+ bytes4 internal immutable PASS_THRU_METHODS_12;
28
+ bytes4 internal immutable PASS_THRU_METHODS_13;
29
+
30
+ /**
31
+ * @notice Constructor of the proxy, defining the implementation and the access manager
32
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
33
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
34
+ *
35
+ * @param implementation The initial implementation contract.
36
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
37
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
38
+ * @param manager The access manager that will handle access control
39
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
40
+ * views and other methods for gas optimization.
41
+ *
42
+ * Requirements:
43
+ *
44
+ * - If `data` is empty, `msg.value` must be zero.
45
+ */
46
+ constructor(
47
+ address implementation,
48
+ bytes memory _data,
49
+ IAccessManager manager,
50
+ bytes4[14] memory passThruMethods
51
+ ) payable AccessManagedProxy(implementation, _data, manager) {
52
+ PASS_THRU_METHODS_0 = passThruMethods[0];
53
+ PASS_THRU_METHODS_1 = passThruMethods[1];
54
+ PASS_THRU_METHODS_2 = passThruMethods[2];
55
+ PASS_THRU_METHODS_3 = passThruMethods[3];
56
+ PASS_THRU_METHODS_4 = passThruMethods[4];
57
+ PASS_THRU_METHODS_5 = passThruMethods[5];
58
+ PASS_THRU_METHODS_6 = passThruMethods[6];
59
+ PASS_THRU_METHODS_7 = passThruMethods[7];
60
+ PASS_THRU_METHODS_8 = passThruMethods[8];
61
+ PASS_THRU_METHODS_9 = passThruMethods[9];
62
+ PASS_THRU_METHODS_10 = passThruMethods[10];
63
+ PASS_THRU_METHODS_11 = passThruMethods[11];
64
+ PASS_THRU_METHODS_12 = passThruMethods[12];
65
+ PASS_THRU_METHODS_13 = passThruMethods[13];
66
+ }
67
+
68
+ /*
69
+ * @notice Skips the access control if the method called is one of the passThruMethods
70
+ * @dev See {PASS_THRU_METHODS()}
71
+ * @param selector The selector of the method called
72
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
73
+ */
74
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
75
+ return
76
+ selector == PASS_THRU_METHODS_0 ||
77
+ selector == PASS_THRU_METHODS_1 ||
78
+ selector == PASS_THRU_METHODS_2 ||
79
+ selector == PASS_THRU_METHODS_3 ||
80
+ selector == PASS_THRU_METHODS_4 ||
81
+ selector == PASS_THRU_METHODS_5 ||
82
+ selector == PASS_THRU_METHODS_6 ||
83
+ selector == PASS_THRU_METHODS_7 ||
84
+ selector == PASS_THRU_METHODS_8 ||
85
+ selector == PASS_THRU_METHODS_9 ||
86
+ selector == PASS_THRU_METHODS_10 ||
87
+ selector == PASS_THRU_METHODS_11 ||
88
+ selector == PASS_THRU_METHODS_12 ||
89
+ selector == PASS_THRU_METHODS_13;
90
+ }
91
+
92
+ /**
93
+ * @notice Gives observability to the methods that are skipped from access control
94
+ * @dev This list is fixed and defined on contract construction
95
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
96
+ */
97
+ // solhint-disable-next-line func-name-mixedcase
98
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
99
+ methods = new bytes4[](14);
100
+ methods[0] = PASS_THRU_METHODS_0;
101
+ methods[1] = PASS_THRU_METHODS_1;
102
+ methods[2] = PASS_THRU_METHODS_2;
103
+ methods[3] = PASS_THRU_METHODS_3;
104
+ methods[4] = PASS_THRU_METHODS_4;
105
+ methods[5] = PASS_THRU_METHODS_5;
106
+ methods[6] = PASS_THRU_METHODS_6;
107
+ methods[7] = PASS_THRU_METHODS_7;
108
+ methods[8] = PASS_THRU_METHODS_8;
109
+ methods[9] = PASS_THRU_METHODS_9;
110
+ methods[10] = PASS_THRU_METHODS_10;
111
+ methods[11] = PASS_THRU_METHODS_11;
112
+ methods[12] = PASS_THRU_METHODS_12;
113
+ methods[13] = PASS_THRU_METHODS_13;
114
+ }
115
+ }
@@ -0,0 +1,119 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {AccessManagedProxy} from "../AccessManagedProxy.sol";
5
+ import {IAccessManager} from "@openzeppelin/contracts/access/manager/IAccessManager.sol";
6
+
7
+ /**
8
+ * @title AccessManagedProxyS15
9
+ * @notice Specialization of AccessManagedProxy with pass thru (skips AM) for some messages for gas optimization
10
+ *
11
+ * @custom:security-contact security@ensuro.co
12
+ * @author Ensuro
13
+ */
14
+ contract AccessManagedProxyS15 is AccessManagedProxy {
15
+ bytes4 internal immutable PASS_THRU_METHODS_0;
16
+ bytes4 internal immutable PASS_THRU_METHODS_1;
17
+ bytes4 internal immutable PASS_THRU_METHODS_2;
18
+ bytes4 internal immutable PASS_THRU_METHODS_3;
19
+ bytes4 internal immutable PASS_THRU_METHODS_4;
20
+ bytes4 internal immutable PASS_THRU_METHODS_5;
21
+ bytes4 internal immutable PASS_THRU_METHODS_6;
22
+ bytes4 internal immutable PASS_THRU_METHODS_7;
23
+ bytes4 internal immutable PASS_THRU_METHODS_8;
24
+ bytes4 internal immutable PASS_THRU_METHODS_9;
25
+ bytes4 internal immutable PASS_THRU_METHODS_10;
26
+ bytes4 internal immutable PASS_THRU_METHODS_11;
27
+ bytes4 internal immutable PASS_THRU_METHODS_12;
28
+ bytes4 internal immutable PASS_THRU_METHODS_13;
29
+ bytes4 internal immutable PASS_THRU_METHODS_14;
30
+
31
+ /**
32
+ * @notice Constructor of the proxy, defining the implementation and the access manager
33
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
34
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
35
+ *
36
+ * @param implementation The initial implementation contract.
37
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
38
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
39
+ * @param manager The access manager that will handle access control
40
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
41
+ * views and other methods for gas optimization.
42
+ *
43
+ * Requirements:
44
+ *
45
+ * - If `data` is empty, `msg.value` must be zero.
46
+ */
47
+ constructor(
48
+ address implementation,
49
+ bytes memory _data,
50
+ IAccessManager manager,
51
+ bytes4[15] memory passThruMethods
52
+ ) payable AccessManagedProxy(implementation, _data, manager) {
53
+ PASS_THRU_METHODS_0 = passThruMethods[0];
54
+ PASS_THRU_METHODS_1 = passThruMethods[1];
55
+ PASS_THRU_METHODS_2 = passThruMethods[2];
56
+ PASS_THRU_METHODS_3 = passThruMethods[3];
57
+ PASS_THRU_METHODS_4 = passThruMethods[4];
58
+ PASS_THRU_METHODS_5 = passThruMethods[5];
59
+ PASS_THRU_METHODS_6 = passThruMethods[6];
60
+ PASS_THRU_METHODS_7 = passThruMethods[7];
61
+ PASS_THRU_METHODS_8 = passThruMethods[8];
62
+ PASS_THRU_METHODS_9 = passThruMethods[9];
63
+ PASS_THRU_METHODS_10 = passThruMethods[10];
64
+ PASS_THRU_METHODS_11 = passThruMethods[11];
65
+ PASS_THRU_METHODS_12 = passThruMethods[12];
66
+ PASS_THRU_METHODS_13 = passThruMethods[13];
67
+ PASS_THRU_METHODS_14 = passThruMethods[14];
68
+ }
69
+
70
+ /*
71
+ * @notice Skips the access control if the method called is one of the passThruMethods
72
+ * @dev See {PASS_THRU_METHODS()}
73
+ * @param selector The selector of the method called
74
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
75
+ */
76
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
77
+ return
78
+ selector == PASS_THRU_METHODS_0 ||
79
+ selector == PASS_THRU_METHODS_1 ||
80
+ selector == PASS_THRU_METHODS_2 ||
81
+ selector == PASS_THRU_METHODS_3 ||
82
+ selector == PASS_THRU_METHODS_4 ||
83
+ selector == PASS_THRU_METHODS_5 ||
84
+ selector == PASS_THRU_METHODS_6 ||
85
+ selector == PASS_THRU_METHODS_7 ||
86
+ selector == PASS_THRU_METHODS_8 ||
87
+ selector == PASS_THRU_METHODS_9 ||
88
+ selector == PASS_THRU_METHODS_10 ||
89
+ selector == PASS_THRU_METHODS_11 ||
90
+ selector == PASS_THRU_METHODS_12 ||
91
+ selector == PASS_THRU_METHODS_13 ||
92
+ selector == PASS_THRU_METHODS_14;
93
+ }
94
+
95
+ /**
96
+ * @notice Gives observability to the methods that are skipped from access control
97
+ * @dev This list is fixed and defined on contract construction
98
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
99
+ */
100
+ // solhint-disable-next-line func-name-mixedcase
101
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
102
+ methods = new bytes4[](15);
103
+ methods[0] = PASS_THRU_METHODS_0;
104
+ methods[1] = PASS_THRU_METHODS_1;
105
+ methods[2] = PASS_THRU_METHODS_2;
106
+ methods[3] = PASS_THRU_METHODS_3;
107
+ methods[4] = PASS_THRU_METHODS_4;
108
+ methods[5] = PASS_THRU_METHODS_5;
109
+ methods[6] = PASS_THRU_METHODS_6;
110
+ methods[7] = PASS_THRU_METHODS_7;
111
+ methods[8] = PASS_THRU_METHODS_8;
112
+ methods[9] = PASS_THRU_METHODS_9;
113
+ methods[10] = PASS_THRU_METHODS_10;
114
+ methods[11] = PASS_THRU_METHODS_11;
115
+ methods[12] = PASS_THRU_METHODS_12;
116
+ methods[13] = PASS_THRU_METHODS_13;
117
+ methods[14] = PASS_THRU_METHODS_14;
118
+ }
119
+ }
@@ -0,0 +1,123 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {AccessManagedProxy} from "../AccessManagedProxy.sol";
5
+ import {IAccessManager} from "@openzeppelin/contracts/access/manager/IAccessManager.sol";
6
+
7
+ /**
8
+ * @title AccessManagedProxyS16
9
+ * @notice Specialization of AccessManagedProxy with pass thru (skips AM) for some messages for gas optimization
10
+ *
11
+ * @custom:security-contact security@ensuro.co
12
+ * @author Ensuro
13
+ */
14
+ contract AccessManagedProxyS16 is AccessManagedProxy {
15
+ bytes4 internal immutable PASS_THRU_METHODS_0;
16
+ bytes4 internal immutable PASS_THRU_METHODS_1;
17
+ bytes4 internal immutable PASS_THRU_METHODS_2;
18
+ bytes4 internal immutable PASS_THRU_METHODS_3;
19
+ bytes4 internal immutable PASS_THRU_METHODS_4;
20
+ bytes4 internal immutable PASS_THRU_METHODS_5;
21
+ bytes4 internal immutable PASS_THRU_METHODS_6;
22
+ bytes4 internal immutable PASS_THRU_METHODS_7;
23
+ bytes4 internal immutable PASS_THRU_METHODS_8;
24
+ bytes4 internal immutable PASS_THRU_METHODS_9;
25
+ bytes4 internal immutable PASS_THRU_METHODS_10;
26
+ bytes4 internal immutable PASS_THRU_METHODS_11;
27
+ bytes4 internal immutable PASS_THRU_METHODS_12;
28
+ bytes4 internal immutable PASS_THRU_METHODS_13;
29
+ bytes4 internal immutable PASS_THRU_METHODS_14;
30
+ bytes4 internal immutable PASS_THRU_METHODS_15;
31
+
32
+ /**
33
+ * @notice Constructor of the proxy, defining the implementation and the access manager
34
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
35
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
36
+ *
37
+ * @param implementation The initial implementation contract.
38
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
39
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
40
+ * @param manager The access manager that will handle access control
41
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
42
+ * views and other methods for gas optimization.
43
+ *
44
+ * Requirements:
45
+ *
46
+ * - If `data` is empty, `msg.value` must be zero.
47
+ */
48
+ constructor(
49
+ address implementation,
50
+ bytes memory _data,
51
+ IAccessManager manager,
52
+ bytes4[16] memory passThruMethods
53
+ ) payable AccessManagedProxy(implementation, _data, manager) {
54
+ PASS_THRU_METHODS_0 = passThruMethods[0];
55
+ PASS_THRU_METHODS_1 = passThruMethods[1];
56
+ PASS_THRU_METHODS_2 = passThruMethods[2];
57
+ PASS_THRU_METHODS_3 = passThruMethods[3];
58
+ PASS_THRU_METHODS_4 = passThruMethods[4];
59
+ PASS_THRU_METHODS_5 = passThruMethods[5];
60
+ PASS_THRU_METHODS_6 = passThruMethods[6];
61
+ PASS_THRU_METHODS_7 = passThruMethods[7];
62
+ PASS_THRU_METHODS_8 = passThruMethods[8];
63
+ PASS_THRU_METHODS_9 = passThruMethods[9];
64
+ PASS_THRU_METHODS_10 = passThruMethods[10];
65
+ PASS_THRU_METHODS_11 = passThruMethods[11];
66
+ PASS_THRU_METHODS_12 = passThruMethods[12];
67
+ PASS_THRU_METHODS_13 = passThruMethods[13];
68
+ PASS_THRU_METHODS_14 = passThruMethods[14];
69
+ PASS_THRU_METHODS_15 = passThruMethods[15];
70
+ }
71
+
72
+ /*
73
+ * @notice Skips the access control if the method called is one of the passThruMethods
74
+ * @dev See {PASS_THRU_METHODS()}
75
+ * @param selector The selector of the method called
76
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
77
+ */
78
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
79
+ return
80
+ selector == PASS_THRU_METHODS_0 ||
81
+ selector == PASS_THRU_METHODS_1 ||
82
+ selector == PASS_THRU_METHODS_2 ||
83
+ selector == PASS_THRU_METHODS_3 ||
84
+ selector == PASS_THRU_METHODS_4 ||
85
+ selector == PASS_THRU_METHODS_5 ||
86
+ selector == PASS_THRU_METHODS_6 ||
87
+ selector == PASS_THRU_METHODS_7 ||
88
+ selector == PASS_THRU_METHODS_8 ||
89
+ selector == PASS_THRU_METHODS_9 ||
90
+ selector == PASS_THRU_METHODS_10 ||
91
+ selector == PASS_THRU_METHODS_11 ||
92
+ selector == PASS_THRU_METHODS_12 ||
93
+ selector == PASS_THRU_METHODS_13 ||
94
+ selector == PASS_THRU_METHODS_14 ||
95
+ selector == PASS_THRU_METHODS_15;
96
+ }
97
+
98
+ /**
99
+ * @notice Gives observability to the methods that are skipped from access control
100
+ * @dev This list is fixed and defined on contract construction
101
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
102
+ */
103
+ // solhint-disable-next-line func-name-mixedcase
104
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
105
+ methods = new bytes4[](16);
106
+ methods[0] = PASS_THRU_METHODS_0;
107
+ methods[1] = PASS_THRU_METHODS_1;
108
+ methods[2] = PASS_THRU_METHODS_2;
109
+ methods[3] = PASS_THRU_METHODS_3;
110
+ methods[4] = PASS_THRU_METHODS_4;
111
+ methods[5] = PASS_THRU_METHODS_5;
112
+ methods[6] = PASS_THRU_METHODS_6;
113
+ methods[7] = PASS_THRU_METHODS_7;
114
+ methods[8] = PASS_THRU_METHODS_8;
115
+ methods[9] = PASS_THRU_METHODS_9;
116
+ methods[10] = PASS_THRU_METHODS_10;
117
+ methods[11] = PASS_THRU_METHODS_11;
118
+ methods[12] = PASS_THRU_METHODS_12;
119
+ methods[13] = PASS_THRU_METHODS_13;
120
+ methods[14] = PASS_THRU_METHODS_14;
121
+ methods[15] = PASS_THRU_METHODS_15;
122
+ }
123
+ }