@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,143 @@
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 AccessManagedProxyS21
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 AccessManagedProxyS21 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
+ bytes4 internal immutable PASS_THRU_METHODS_16;
32
+ bytes4 internal immutable PASS_THRU_METHODS_17;
33
+ bytes4 internal immutable PASS_THRU_METHODS_18;
34
+ bytes4 internal immutable PASS_THRU_METHODS_19;
35
+ bytes4 internal immutable PASS_THRU_METHODS_20;
36
+
37
+ /**
38
+ * @notice Constructor of the proxy, defining the implementation and the access manager
39
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
40
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
41
+ *
42
+ * @param implementation The initial implementation contract.
43
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
44
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
45
+ * @param manager The access manager that will handle access control
46
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
47
+ * views and other methods for gas optimization.
48
+ *
49
+ * Requirements:
50
+ *
51
+ * - If `data` is empty, `msg.value` must be zero.
52
+ */
53
+ constructor(
54
+ address implementation,
55
+ bytes memory _data,
56
+ IAccessManager manager,
57
+ bytes4[21] memory passThruMethods
58
+ ) payable AccessManagedProxy(implementation, _data, manager) {
59
+ PASS_THRU_METHODS_0 = passThruMethods[0];
60
+ PASS_THRU_METHODS_1 = passThruMethods[1];
61
+ PASS_THRU_METHODS_2 = passThruMethods[2];
62
+ PASS_THRU_METHODS_3 = passThruMethods[3];
63
+ PASS_THRU_METHODS_4 = passThruMethods[4];
64
+ PASS_THRU_METHODS_5 = passThruMethods[5];
65
+ PASS_THRU_METHODS_6 = passThruMethods[6];
66
+ PASS_THRU_METHODS_7 = passThruMethods[7];
67
+ PASS_THRU_METHODS_8 = passThruMethods[8];
68
+ PASS_THRU_METHODS_9 = passThruMethods[9];
69
+ PASS_THRU_METHODS_10 = passThruMethods[10];
70
+ PASS_THRU_METHODS_11 = passThruMethods[11];
71
+ PASS_THRU_METHODS_12 = passThruMethods[12];
72
+ PASS_THRU_METHODS_13 = passThruMethods[13];
73
+ PASS_THRU_METHODS_14 = passThruMethods[14];
74
+ PASS_THRU_METHODS_15 = passThruMethods[15];
75
+ PASS_THRU_METHODS_16 = passThruMethods[16];
76
+ PASS_THRU_METHODS_17 = passThruMethods[17];
77
+ PASS_THRU_METHODS_18 = passThruMethods[18];
78
+ PASS_THRU_METHODS_19 = passThruMethods[19];
79
+ PASS_THRU_METHODS_20 = passThruMethods[20];
80
+ }
81
+
82
+ /*
83
+ * @notice Skips the access control if the method called is one of the passThruMethods
84
+ * @dev See {PASS_THRU_METHODS()}
85
+ * @param selector The selector of the method called
86
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
87
+ */
88
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
89
+ return
90
+ selector == PASS_THRU_METHODS_0 ||
91
+ selector == PASS_THRU_METHODS_1 ||
92
+ selector == PASS_THRU_METHODS_2 ||
93
+ selector == PASS_THRU_METHODS_3 ||
94
+ selector == PASS_THRU_METHODS_4 ||
95
+ selector == PASS_THRU_METHODS_5 ||
96
+ selector == PASS_THRU_METHODS_6 ||
97
+ selector == PASS_THRU_METHODS_7 ||
98
+ selector == PASS_THRU_METHODS_8 ||
99
+ selector == PASS_THRU_METHODS_9 ||
100
+ selector == PASS_THRU_METHODS_10 ||
101
+ selector == PASS_THRU_METHODS_11 ||
102
+ selector == PASS_THRU_METHODS_12 ||
103
+ selector == PASS_THRU_METHODS_13 ||
104
+ selector == PASS_THRU_METHODS_14 ||
105
+ selector == PASS_THRU_METHODS_15 ||
106
+ selector == PASS_THRU_METHODS_16 ||
107
+ selector == PASS_THRU_METHODS_17 ||
108
+ selector == PASS_THRU_METHODS_18 ||
109
+ selector == PASS_THRU_METHODS_19 ||
110
+ selector == PASS_THRU_METHODS_20;
111
+ }
112
+
113
+ /**
114
+ * @notice Gives observability to the methods that are skipped from access control
115
+ * @dev This list is fixed and defined on contract construction
116
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
117
+ */
118
+ // solhint-disable-next-line func-name-mixedcase
119
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
120
+ methods = new bytes4[](21);
121
+ methods[0] = PASS_THRU_METHODS_0;
122
+ methods[1] = PASS_THRU_METHODS_1;
123
+ methods[2] = PASS_THRU_METHODS_2;
124
+ methods[3] = PASS_THRU_METHODS_3;
125
+ methods[4] = PASS_THRU_METHODS_4;
126
+ methods[5] = PASS_THRU_METHODS_5;
127
+ methods[6] = PASS_THRU_METHODS_6;
128
+ methods[7] = PASS_THRU_METHODS_7;
129
+ methods[8] = PASS_THRU_METHODS_8;
130
+ methods[9] = PASS_THRU_METHODS_9;
131
+ methods[10] = PASS_THRU_METHODS_10;
132
+ methods[11] = PASS_THRU_METHODS_11;
133
+ methods[12] = PASS_THRU_METHODS_12;
134
+ methods[13] = PASS_THRU_METHODS_13;
135
+ methods[14] = PASS_THRU_METHODS_14;
136
+ methods[15] = PASS_THRU_METHODS_15;
137
+ methods[16] = PASS_THRU_METHODS_16;
138
+ methods[17] = PASS_THRU_METHODS_17;
139
+ methods[18] = PASS_THRU_METHODS_18;
140
+ methods[19] = PASS_THRU_METHODS_19;
141
+ methods[20] = PASS_THRU_METHODS_20;
142
+ }
143
+ }
@@ -0,0 +1,147 @@
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 AccessManagedProxyS22
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 AccessManagedProxyS22 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
+ bytes4 internal immutable PASS_THRU_METHODS_16;
32
+ bytes4 internal immutable PASS_THRU_METHODS_17;
33
+ bytes4 internal immutable PASS_THRU_METHODS_18;
34
+ bytes4 internal immutable PASS_THRU_METHODS_19;
35
+ bytes4 internal immutable PASS_THRU_METHODS_20;
36
+ bytes4 internal immutable PASS_THRU_METHODS_21;
37
+
38
+ /**
39
+ * @notice Constructor of the proxy, defining the implementation and the access manager
40
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
41
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
42
+ *
43
+ * @param implementation The initial implementation contract.
44
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
45
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
46
+ * @param manager The access manager that will handle access control
47
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
48
+ * views and other methods for gas optimization.
49
+ *
50
+ * Requirements:
51
+ *
52
+ * - If `data` is empty, `msg.value` must be zero.
53
+ */
54
+ constructor(
55
+ address implementation,
56
+ bytes memory _data,
57
+ IAccessManager manager,
58
+ bytes4[22] memory passThruMethods
59
+ ) payable AccessManagedProxy(implementation, _data, manager) {
60
+ PASS_THRU_METHODS_0 = passThruMethods[0];
61
+ PASS_THRU_METHODS_1 = passThruMethods[1];
62
+ PASS_THRU_METHODS_2 = passThruMethods[2];
63
+ PASS_THRU_METHODS_3 = passThruMethods[3];
64
+ PASS_THRU_METHODS_4 = passThruMethods[4];
65
+ PASS_THRU_METHODS_5 = passThruMethods[5];
66
+ PASS_THRU_METHODS_6 = passThruMethods[6];
67
+ PASS_THRU_METHODS_7 = passThruMethods[7];
68
+ PASS_THRU_METHODS_8 = passThruMethods[8];
69
+ PASS_THRU_METHODS_9 = passThruMethods[9];
70
+ PASS_THRU_METHODS_10 = passThruMethods[10];
71
+ PASS_THRU_METHODS_11 = passThruMethods[11];
72
+ PASS_THRU_METHODS_12 = passThruMethods[12];
73
+ PASS_THRU_METHODS_13 = passThruMethods[13];
74
+ PASS_THRU_METHODS_14 = passThruMethods[14];
75
+ PASS_THRU_METHODS_15 = passThruMethods[15];
76
+ PASS_THRU_METHODS_16 = passThruMethods[16];
77
+ PASS_THRU_METHODS_17 = passThruMethods[17];
78
+ PASS_THRU_METHODS_18 = passThruMethods[18];
79
+ PASS_THRU_METHODS_19 = passThruMethods[19];
80
+ PASS_THRU_METHODS_20 = passThruMethods[20];
81
+ PASS_THRU_METHODS_21 = passThruMethods[21];
82
+ }
83
+
84
+ /*
85
+ * @notice Skips the access control if the method called is one of the passThruMethods
86
+ * @dev See {PASS_THRU_METHODS()}
87
+ * @param selector The selector of the method called
88
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
89
+ */
90
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
91
+ return
92
+ selector == PASS_THRU_METHODS_0 ||
93
+ selector == PASS_THRU_METHODS_1 ||
94
+ selector == PASS_THRU_METHODS_2 ||
95
+ selector == PASS_THRU_METHODS_3 ||
96
+ selector == PASS_THRU_METHODS_4 ||
97
+ selector == PASS_THRU_METHODS_5 ||
98
+ selector == PASS_THRU_METHODS_6 ||
99
+ selector == PASS_THRU_METHODS_7 ||
100
+ selector == PASS_THRU_METHODS_8 ||
101
+ selector == PASS_THRU_METHODS_9 ||
102
+ selector == PASS_THRU_METHODS_10 ||
103
+ selector == PASS_THRU_METHODS_11 ||
104
+ selector == PASS_THRU_METHODS_12 ||
105
+ selector == PASS_THRU_METHODS_13 ||
106
+ selector == PASS_THRU_METHODS_14 ||
107
+ selector == PASS_THRU_METHODS_15 ||
108
+ selector == PASS_THRU_METHODS_16 ||
109
+ selector == PASS_THRU_METHODS_17 ||
110
+ selector == PASS_THRU_METHODS_18 ||
111
+ selector == PASS_THRU_METHODS_19 ||
112
+ selector == PASS_THRU_METHODS_20 ||
113
+ selector == PASS_THRU_METHODS_21;
114
+ }
115
+
116
+ /**
117
+ * @notice Gives observability to the methods that are skipped from access control
118
+ * @dev This list is fixed and defined on contract construction
119
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
120
+ */
121
+ // solhint-disable-next-line func-name-mixedcase
122
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
123
+ methods = new bytes4[](22);
124
+ methods[0] = PASS_THRU_METHODS_0;
125
+ methods[1] = PASS_THRU_METHODS_1;
126
+ methods[2] = PASS_THRU_METHODS_2;
127
+ methods[3] = PASS_THRU_METHODS_3;
128
+ methods[4] = PASS_THRU_METHODS_4;
129
+ methods[5] = PASS_THRU_METHODS_5;
130
+ methods[6] = PASS_THRU_METHODS_6;
131
+ methods[7] = PASS_THRU_METHODS_7;
132
+ methods[8] = PASS_THRU_METHODS_8;
133
+ methods[9] = PASS_THRU_METHODS_9;
134
+ methods[10] = PASS_THRU_METHODS_10;
135
+ methods[11] = PASS_THRU_METHODS_11;
136
+ methods[12] = PASS_THRU_METHODS_12;
137
+ methods[13] = PASS_THRU_METHODS_13;
138
+ methods[14] = PASS_THRU_METHODS_14;
139
+ methods[15] = PASS_THRU_METHODS_15;
140
+ methods[16] = PASS_THRU_METHODS_16;
141
+ methods[17] = PASS_THRU_METHODS_17;
142
+ methods[18] = PASS_THRU_METHODS_18;
143
+ methods[19] = PASS_THRU_METHODS_19;
144
+ methods[20] = PASS_THRU_METHODS_20;
145
+ methods[21] = PASS_THRU_METHODS_21;
146
+ }
147
+ }
@@ -0,0 +1,151 @@
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 AccessManagedProxyS23
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 AccessManagedProxyS23 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
+ bytes4 internal immutable PASS_THRU_METHODS_16;
32
+ bytes4 internal immutable PASS_THRU_METHODS_17;
33
+ bytes4 internal immutable PASS_THRU_METHODS_18;
34
+ bytes4 internal immutable PASS_THRU_METHODS_19;
35
+ bytes4 internal immutable PASS_THRU_METHODS_20;
36
+ bytes4 internal immutable PASS_THRU_METHODS_21;
37
+ bytes4 internal immutable PASS_THRU_METHODS_22;
38
+
39
+ /**
40
+ * @notice Constructor of the proxy, defining the implementation and the access manager
41
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
42
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
43
+ *
44
+ * @param implementation The initial implementation contract.
45
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
46
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
47
+ * @param manager The access manager that will handle access control
48
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
49
+ * views and other methods for gas optimization.
50
+ *
51
+ * Requirements:
52
+ *
53
+ * - If `data` is empty, `msg.value` must be zero.
54
+ */
55
+ constructor(
56
+ address implementation,
57
+ bytes memory _data,
58
+ IAccessManager manager,
59
+ bytes4[23] memory passThruMethods
60
+ ) payable AccessManagedProxy(implementation, _data, manager) {
61
+ PASS_THRU_METHODS_0 = passThruMethods[0];
62
+ PASS_THRU_METHODS_1 = passThruMethods[1];
63
+ PASS_THRU_METHODS_2 = passThruMethods[2];
64
+ PASS_THRU_METHODS_3 = passThruMethods[3];
65
+ PASS_THRU_METHODS_4 = passThruMethods[4];
66
+ PASS_THRU_METHODS_5 = passThruMethods[5];
67
+ PASS_THRU_METHODS_6 = passThruMethods[6];
68
+ PASS_THRU_METHODS_7 = passThruMethods[7];
69
+ PASS_THRU_METHODS_8 = passThruMethods[8];
70
+ PASS_THRU_METHODS_9 = passThruMethods[9];
71
+ PASS_THRU_METHODS_10 = passThruMethods[10];
72
+ PASS_THRU_METHODS_11 = passThruMethods[11];
73
+ PASS_THRU_METHODS_12 = passThruMethods[12];
74
+ PASS_THRU_METHODS_13 = passThruMethods[13];
75
+ PASS_THRU_METHODS_14 = passThruMethods[14];
76
+ PASS_THRU_METHODS_15 = passThruMethods[15];
77
+ PASS_THRU_METHODS_16 = passThruMethods[16];
78
+ PASS_THRU_METHODS_17 = passThruMethods[17];
79
+ PASS_THRU_METHODS_18 = passThruMethods[18];
80
+ PASS_THRU_METHODS_19 = passThruMethods[19];
81
+ PASS_THRU_METHODS_20 = passThruMethods[20];
82
+ PASS_THRU_METHODS_21 = passThruMethods[21];
83
+ PASS_THRU_METHODS_22 = passThruMethods[22];
84
+ }
85
+
86
+ /*
87
+ * @notice Skips the access control if the method called is one of the passThruMethods
88
+ * @dev See {PASS_THRU_METHODS()}
89
+ * @param selector The selector of the method called
90
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
91
+ */
92
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
93
+ return
94
+ selector == PASS_THRU_METHODS_0 ||
95
+ selector == PASS_THRU_METHODS_1 ||
96
+ selector == PASS_THRU_METHODS_2 ||
97
+ selector == PASS_THRU_METHODS_3 ||
98
+ selector == PASS_THRU_METHODS_4 ||
99
+ selector == PASS_THRU_METHODS_5 ||
100
+ selector == PASS_THRU_METHODS_6 ||
101
+ selector == PASS_THRU_METHODS_7 ||
102
+ selector == PASS_THRU_METHODS_8 ||
103
+ selector == PASS_THRU_METHODS_9 ||
104
+ selector == PASS_THRU_METHODS_10 ||
105
+ selector == PASS_THRU_METHODS_11 ||
106
+ selector == PASS_THRU_METHODS_12 ||
107
+ selector == PASS_THRU_METHODS_13 ||
108
+ selector == PASS_THRU_METHODS_14 ||
109
+ selector == PASS_THRU_METHODS_15 ||
110
+ selector == PASS_THRU_METHODS_16 ||
111
+ selector == PASS_THRU_METHODS_17 ||
112
+ selector == PASS_THRU_METHODS_18 ||
113
+ selector == PASS_THRU_METHODS_19 ||
114
+ selector == PASS_THRU_METHODS_20 ||
115
+ selector == PASS_THRU_METHODS_21 ||
116
+ selector == PASS_THRU_METHODS_22;
117
+ }
118
+
119
+ /**
120
+ * @notice Gives observability to the methods that are skipped from access control
121
+ * @dev This list is fixed and defined on contract construction
122
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
123
+ */
124
+ // solhint-disable-next-line func-name-mixedcase
125
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
126
+ methods = new bytes4[](23);
127
+ methods[0] = PASS_THRU_METHODS_0;
128
+ methods[1] = PASS_THRU_METHODS_1;
129
+ methods[2] = PASS_THRU_METHODS_2;
130
+ methods[3] = PASS_THRU_METHODS_3;
131
+ methods[4] = PASS_THRU_METHODS_4;
132
+ methods[5] = PASS_THRU_METHODS_5;
133
+ methods[6] = PASS_THRU_METHODS_6;
134
+ methods[7] = PASS_THRU_METHODS_7;
135
+ methods[8] = PASS_THRU_METHODS_8;
136
+ methods[9] = PASS_THRU_METHODS_9;
137
+ methods[10] = PASS_THRU_METHODS_10;
138
+ methods[11] = PASS_THRU_METHODS_11;
139
+ methods[12] = PASS_THRU_METHODS_12;
140
+ methods[13] = PASS_THRU_METHODS_13;
141
+ methods[14] = PASS_THRU_METHODS_14;
142
+ methods[15] = PASS_THRU_METHODS_15;
143
+ methods[16] = PASS_THRU_METHODS_16;
144
+ methods[17] = PASS_THRU_METHODS_17;
145
+ methods[18] = PASS_THRU_METHODS_18;
146
+ methods[19] = PASS_THRU_METHODS_19;
147
+ methods[20] = PASS_THRU_METHODS_20;
148
+ methods[21] = PASS_THRU_METHODS_21;
149
+ methods[22] = PASS_THRU_METHODS_22;
150
+ }
151
+ }
@@ -0,0 +1,155 @@
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 AccessManagedProxyS24
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 AccessManagedProxyS24 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
+ bytes4 internal immutable PASS_THRU_METHODS_16;
32
+ bytes4 internal immutable PASS_THRU_METHODS_17;
33
+ bytes4 internal immutable PASS_THRU_METHODS_18;
34
+ bytes4 internal immutable PASS_THRU_METHODS_19;
35
+ bytes4 internal immutable PASS_THRU_METHODS_20;
36
+ bytes4 internal immutable PASS_THRU_METHODS_21;
37
+ bytes4 internal immutable PASS_THRU_METHODS_22;
38
+ bytes4 internal immutable PASS_THRU_METHODS_23;
39
+
40
+ /**
41
+ * @notice Constructor of the proxy, defining the implementation and the access manager
42
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
43
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
44
+ *
45
+ * @param implementation The initial implementation contract.
46
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
47
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
48
+ * @param manager The access manager that will handle access control
49
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
50
+ * views and other methods for gas optimization.
51
+ *
52
+ * Requirements:
53
+ *
54
+ * - If `data` is empty, `msg.value` must be zero.
55
+ */
56
+ constructor(
57
+ address implementation,
58
+ bytes memory _data,
59
+ IAccessManager manager,
60
+ bytes4[24] memory passThruMethods
61
+ ) payable AccessManagedProxy(implementation, _data, manager) {
62
+ PASS_THRU_METHODS_0 = passThruMethods[0];
63
+ PASS_THRU_METHODS_1 = passThruMethods[1];
64
+ PASS_THRU_METHODS_2 = passThruMethods[2];
65
+ PASS_THRU_METHODS_3 = passThruMethods[3];
66
+ PASS_THRU_METHODS_4 = passThruMethods[4];
67
+ PASS_THRU_METHODS_5 = passThruMethods[5];
68
+ PASS_THRU_METHODS_6 = passThruMethods[6];
69
+ PASS_THRU_METHODS_7 = passThruMethods[7];
70
+ PASS_THRU_METHODS_8 = passThruMethods[8];
71
+ PASS_THRU_METHODS_9 = passThruMethods[9];
72
+ PASS_THRU_METHODS_10 = passThruMethods[10];
73
+ PASS_THRU_METHODS_11 = passThruMethods[11];
74
+ PASS_THRU_METHODS_12 = passThruMethods[12];
75
+ PASS_THRU_METHODS_13 = passThruMethods[13];
76
+ PASS_THRU_METHODS_14 = passThruMethods[14];
77
+ PASS_THRU_METHODS_15 = passThruMethods[15];
78
+ PASS_THRU_METHODS_16 = passThruMethods[16];
79
+ PASS_THRU_METHODS_17 = passThruMethods[17];
80
+ PASS_THRU_METHODS_18 = passThruMethods[18];
81
+ PASS_THRU_METHODS_19 = passThruMethods[19];
82
+ PASS_THRU_METHODS_20 = passThruMethods[20];
83
+ PASS_THRU_METHODS_21 = passThruMethods[21];
84
+ PASS_THRU_METHODS_22 = passThruMethods[22];
85
+ PASS_THRU_METHODS_23 = passThruMethods[23];
86
+ }
87
+
88
+ /*
89
+ * @notice Skips the access control if the method called is one of the passThruMethods
90
+ * @dev See {PASS_THRU_METHODS()}
91
+ * @param selector The selector of the method called
92
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
93
+ */
94
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
95
+ return
96
+ selector == PASS_THRU_METHODS_0 ||
97
+ selector == PASS_THRU_METHODS_1 ||
98
+ selector == PASS_THRU_METHODS_2 ||
99
+ selector == PASS_THRU_METHODS_3 ||
100
+ selector == PASS_THRU_METHODS_4 ||
101
+ selector == PASS_THRU_METHODS_5 ||
102
+ selector == PASS_THRU_METHODS_6 ||
103
+ selector == PASS_THRU_METHODS_7 ||
104
+ selector == PASS_THRU_METHODS_8 ||
105
+ selector == PASS_THRU_METHODS_9 ||
106
+ selector == PASS_THRU_METHODS_10 ||
107
+ selector == PASS_THRU_METHODS_11 ||
108
+ selector == PASS_THRU_METHODS_12 ||
109
+ selector == PASS_THRU_METHODS_13 ||
110
+ selector == PASS_THRU_METHODS_14 ||
111
+ selector == PASS_THRU_METHODS_15 ||
112
+ selector == PASS_THRU_METHODS_16 ||
113
+ selector == PASS_THRU_METHODS_17 ||
114
+ selector == PASS_THRU_METHODS_18 ||
115
+ selector == PASS_THRU_METHODS_19 ||
116
+ selector == PASS_THRU_METHODS_20 ||
117
+ selector == PASS_THRU_METHODS_21 ||
118
+ selector == PASS_THRU_METHODS_22 ||
119
+ selector == PASS_THRU_METHODS_23;
120
+ }
121
+
122
+ /**
123
+ * @notice Gives observability to the methods that are skipped from access control
124
+ * @dev This list is fixed and defined on contract construction
125
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
126
+ */
127
+ // solhint-disable-next-line func-name-mixedcase
128
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
129
+ methods = new bytes4[](24);
130
+ methods[0] = PASS_THRU_METHODS_0;
131
+ methods[1] = PASS_THRU_METHODS_1;
132
+ methods[2] = PASS_THRU_METHODS_2;
133
+ methods[3] = PASS_THRU_METHODS_3;
134
+ methods[4] = PASS_THRU_METHODS_4;
135
+ methods[5] = PASS_THRU_METHODS_5;
136
+ methods[6] = PASS_THRU_METHODS_6;
137
+ methods[7] = PASS_THRU_METHODS_7;
138
+ methods[8] = PASS_THRU_METHODS_8;
139
+ methods[9] = PASS_THRU_METHODS_9;
140
+ methods[10] = PASS_THRU_METHODS_10;
141
+ methods[11] = PASS_THRU_METHODS_11;
142
+ methods[12] = PASS_THRU_METHODS_12;
143
+ methods[13] = PASS_THRU_METHODS_13;
144
+ methods[14] = PASS_THRU_METHODS_14;
145
+ methods[15] = PASS_THRU_METHODS_15;
146
+ methods[16] = PASS_THRU_METHODS_16;
147
+ methods[17] = PASS_THRU_METHODS_17;
148
+ methods[18] = PASS_THRU_METHODS_18;
149
+ methods[19] = PASS_THRU_METHODS_19;
150
+ methods[20] = PASS_THRU_METHODS_20;
151
+ methods[21] = PASS_THRU_METHODS_21;
152
+ methods[22] = PASS_THRU_METHODS_22;
153
+ methods[23] = PASS_THRU_METHODS_23;
154
+ }
155
+ }
@@ -0,0 +1,71 @@
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 AccessManagedProxyS3
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 AccessManagedProxyS3 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
+
19
+ /**
20
+ * @notice Constructor of the proxy, defining the implementation and the access manager
21
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
22
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
23
+ *
24
+ * @param implementation The initial implementation contract.
25
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
26
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
27
+ * @param manager The access manager that will handle access control
28
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
29
+ * views and other methods for gas optimization.
30
+ *
31
+ * Requirements:
32
+ *
33
+ * - If `data` is empty, `msg.value` must be zero.
34
+ */
35
+ constructor(
36
+ address implementation,
37
+ bytes memory _data,
38
+ IAccessManager manager,
39
+ bytes4[3] memory passThruMethods
40
+ ) payable AccessManagedProxy(implementation, _data, manager) {
41
+ PASS_THRU_METHODS_0 = passThruMethods[0];
42
+ PASS_THRU_METHODS_1 = passThruMethods[1];
43
+ PASS_THRU_METHODS_2 = passThruMethods[2];
44
+ }
45
+
46
+ /*
47
+ * @notice Skips the access control if the method called is one of the passThruMethods
48
+ * @dev See {PASS_THRU_METHODS()}
49
+ * @param selector The selector of the method called
50
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
51
+ */
52
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
53
+ return
54
+ selector == PASS_THRU_METHODS_0 ||
55
+ selector == PASS_THRU_METHODS_1 ||
56
+ selector == PASS_THRU_METHODS_2;
57
+ }
58
+
59
+ /**
60
+ * @notice Gives observability to the methods that are skipped from access control
61
+ * @dev This list is fixed and defined on contract construction
62
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
63
+ */
64
+ // solhint-disable-next-line func-name-mixedcase
65
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
66
+ methods = new bytes4[](3);
67
+ methods[0] = PASS_THRU_METHODS_0;
68
+ methods[1] = PASS_THRU_METHODS_1;
69
+ methods[2] = PASS_THRU_METHODS_2;
70
+ }
71
+ }