@ensuro/access-managed-proxy 0.1.0 → 0.2.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 (38) hide show
  1. package/README.md +38 -2
  2. package/build/build-info.json +1 -1
  3. package/build/contracts/AMPUtils.sol/AMPUtils.json +22 -0
  4. package/build/contracts/amps/AccessManagedProxyS25.sol/AccessManagedProxyS25.json +123 -0
  5. package/build/contracts/amps/AccessManagedProxyS26.sol/AccessManagedProxyS26.json +123 -0
  6. package/build/contracts/amps/AccessManagedProxyS27.sol/AccessManagedProxyS27.json +123 -0
  7. package/build/contracts/amps/AccessManagedProxyS28.sol/AccessManagedProxyS28.json +123 -0
  8. package/build/contracts/amps/AccessManagedProxyS29.sol/AccessManagedProxyS29.json +123 -0
  9. package/build/contracts/amps/AccessManagedProxyS30.sol/AccessManagedProxyS30.json +123 -0
  10. package/build/contracts/amps/AccessManagedProxyS31.sol/AccessManagedProxyS31.json +123 -0
  11. package/build/contracts/amps/AccessManagedProxyS32.sol/AccessManagedProxyS32.json +123 -0
  12. package/build/contracts/amps/AccessManagedProxyS33.sol/AccessManagedProxyS33.json +123 -0
  13. package/build/contracts/amps/AccessManagedProxyS34.sol/AccessManagedProxyS34.json +123 -0
  14. package/build/contracts/amps/AccessManagedProxyS35.sol/AccessManagedProxyS35.json +123 -0
  15. package/build/contracts/amps/AccessManagedProxyS36.sol/AccessManagedProxyS36.json +123 -0
  16. package/build/contracts/amps/AccessManagedProxyS37.sol/AccessManagedProxyS37.json +123 -0
  17. package/build/contracts/amps/AccessManagedProxyS38.sol/AccessManagedProxyS38.json +123 -0
  18. package/build/contracts/amps/AccessManagedProxyS39.sol/AccessManagedProxyS39.json +123 -0
  19. package/build/contracts/amps/AccessManagedProxyS40.sol/AccessManagedProxyS40.json +123 -0
  20. package/contracts/AMPUtils.sol +37 -0
  21. package/contracts/amps/AccessManagedProxyS25.sol +159 -0
  22. package/contracts/amps/AccessManagedProxyS26.sol +163 -0
  23. package/contracts/amps/AccessManagedProxyS27.sol +167 -0
  24. package/contracts/amps/AccessManagedProxyS28.sol +171 -0
  25. package/contracts/amps/AccessManagedProxyS29.sol +175 -0
  26. package/contracts/amps/AccessManagedProxyS30.sol +179 -0
  27. package/contracts/amps/AccessManagedProxyS31.sol +183 -0
  28. package/contracts/amps/AccessManagedProxyS32.sol +187 -0
  29. package/contracts/amps/AccessManagedProxyS33.sol +191 -0
  30. package/contracts/amps/AccessManagedProxyS34.sol +195 -0
  31. package/contracts/amps/AccessManagedProxyS35.sol +199 -0
  32. package/contracts/amps/AccessManagedProxyS36.sol +203 -0
  33. package/contracts/amps/AccessManagedProxyS37.sol +207 -0
  34. package/contracts/amps/AccessManagedProxyS38.sol +211 -0
  35. package/contracts/amps/AccessManagedProxyS39.sol +215 -0
  36. package/contracts/amps/AccessManagedProxyS40.sol +219 -0
  37. package/js/deployProxy.js +75 -0
  38. package/package.json +1 -1
@@ -0,0 +1,207 @@
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 AccessManagedProxyS37
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 AccessManagedProxyS37 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
+ bytes4 internal immutable PASS_THRU_METHODS_24;
40
+ bytes4 internal immutable PASS_THRU_METHODS_25;
41
+ bytes4 internal immutable PASS_THRU_METHODS_26;
42
+ bytes4 internal immutable PASS_THRU_METHODS_27;
43
+ bytes4 internal immutable PASS_THRU_METHODS_28;
44
+ bytes4 internal immutable PASS_THRU_METHODS_29;
45
+ bytes4 internal immutable PASS_THRU_METHODS_30;
46
+ bytes4 internal immutable PASS_THRU_METHODS_31;
47
+ bytes4 internal immutable PASS_THRU_METHODS_32;
48
+ bytes4 internal immutable PASS_THRU_METHODS_33;
49
+ bytes4 internal immutable PASS_THRU_METHODS_34;
50
+ bytes4 internal immutable PASS_THRU_METHODS_35;
51
+ bytes4 internal immutable PASS_THRU_METHODS_36;
52
+
53
+ /**
54
+ * @notice Constructor of the proxy, defining the implementation and the access manager
55
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
56
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
57
+ *
58
+ * @param implementation The initial implementation contract.
59
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
60
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
61
+ * @param manager The access manager that will handle access control
62
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
63
+ * views and other methods for gas optimization.
64
+ *
65
+ * Requirements:
66
+ *
67
+ * - If `data` is empty, `msg.value` must be zero.
68
+ */
69
+ constructor(
70
+ address implementation,
71
+ bytes memory _data,
72
+ IAccessManager manager,
73
+ bytes4[37] memory passThruMethods
74
+ ) payable AccessManagedProxy(implementation, _data, manager) {
75
+ PASS_THRU_METHODS_0 = passThruMethods[0];
76
+ PASS_THRU_METHODS_1 = passThruMethods[1];
77
+ PASS_THRU_METHODS_2 = passThruMethods[2];
78
+ PASS_THRU_METHODS_3 = passThruMethods[3];
79
+ PASS_THRU_METHODS_4 = passThruMethods[4];
80
+ PASS_THRU_METHODS_5 = passThruMethods[5];
81
+ PASS_THRU_METHODS_6 = passThruMethods[6];
82
+ PASS_THRU_METHODS_7 = passThruMethods[7];
83
+ PASS_THRU_METHODS_8 = passThruMethods[8];
84
+ PASS_THRU_METHODS_9 = passThruMethods[9];
85
+ PASS_THRU_METHODS_10 = passThruMethods[10];
86
+ PASS_THRU_METHODS_11 = passThruMethods[11];
87
+ PASS_THRU_METHODS_12 = passThruMethods[12];
88
+ PASS_THRU_METHODS_13 = passThruMethods[13];
89
+ PASS_THRU_METHODS_14 = passThruMethods[14];
90
+ PASS_THRU_METHODS_15 = passThruMethods[15];
91
+ PASS_THRU_METHODS_16 = passThruMethods[16];
92
+ PASS_THRU_METHODS_17 = passThruMethods[17];
93
+ PASS_THRU_METHODS_18 = passThruMethods[18];
94
+ PASS_THRU_METHODS_19 = passThruMethods[19];
95
+ PASS_THRU_METHODS_20 = passThruMethods[20];
96
+ PASS_THRU_METHODS_21 = passThruMethods[21];
97
+ PASS_THRU_METHODS_22 = passThruMethods[22];
98
+ PASS_THRU_METHODS_23 = passThruMethods[23];
99
+ PASS_THRU_METHODS_24 = passThruMethods[24];
100
+ PASS_THRU_METHODS_25 = passThruMethods[25];
101
+ PASS_THRU_METHODS_26 = passThruMethods[26];
102
+ PASS_THRU_METHODS_27 = passThruMethods[27];
103
+ PASS_THRU_METHODS_28 = passThruMethods[28];
104
+ PASS_THRU_METHODS_29 = passThruMethods[29];
105
+ PASS_THRU_METHODS_30 = passThruMethods[30];
106
+ PASS_THRU_METHODS_31 = passThruMethods[31];
107
+ PASS_THRU_METHODS_32 = passThruMethods[32];
108
+ PASS_THRU_METHODS_33 = passThruMethods[33];
109
+ PASS_THRU_METHODS_34 = passThruMethods[34];
110
+ PASS_THRU_METHODS_35 = passThruMethods[35];
111
+ PASS_THRU_METHODS_36 = passThruMethods[36];
112
+ }
113
+
114
+ /*
115
+ * @notice Skips the access control if the method called is one of the passThruMethods
116
+ * @dev See {PASS_THRU_METHODS()}
117
+ * @param selector The selector of the method called
118
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
119
+ */
120
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
121
+ return
122
+ selector == PASS_THRU_METHODS_0 ||
123
+ selector == PASS_THRU_METHODS_1 ||
124
+ selector == PASS_THRU_METHODS_2 ||
125
+ selector == PASS_THRU_METHODS_3 ||
126
+ selector == PASS_THRU_METHODS_4 ||
127
+ selector == PASS_THRU_METHODS_5 ||
128
+ selector == PASS_THRU_METHODS_6 ||
129
+ selector == PASS_THRU_METHODS_7 ||
130
+ selector == PASS_THRU_METHODS_8 ||
131
+ selector == PASS_THRU_METHODS_9 ||
132
+ selector == PASS_THRU_METHODS_10 ||
133
+ selector == PASS_THRU_METHODS_11 ||
134
+ selector == PASS_THRU_METHODS_12 ||
135
+ selector == PASS_THRU_METHODS_13 ||
136
+ selector == PASS_THRU_METHODS_14 ||
137
+ selector == PASS_THRU_METHODS_15 ||
138
+ selector == PASS_THRU_METHODS_16 ||
139
+ selector == PASS_THRU_METHODS_17 ||
140
+ selector == PASS_THRU_METHODS_18 ||
141
+ selector == PASS_THRU_METHODS_19 ||
142
+ selector == PASS_THRU_METHODS_20 ||
143
+ selector == PASS_THRU_METHODS_21 ||
144
+ selector == PASS_THRU_METHODS_22 ||
145
+ selector == PASS_THRU_METHODS_23 ||
146
+ selector == PASS_THRU_METHODS_24 ||
147
+ selector == PASS_THRU_METHODS_25 ||
148
+ selector == PASS_THRU_METHODS_26 ||
149
+ selector == PASS_THRU_METHODS_27 ||
150
+ selector == PASS_THRU_METHODS_28 ||
151
+ selector == PASS_THRU_METHODS_29 ||
152
+ selector == PASS_THRU_METHODS_30 ||
153
+ selector == PASS_THRU_METHODS_31 ||
154
+ selector == PASS_THRU_METHODS_32 ||
155
+ selector == PASS_THRU_METHODS_33 ||
156
+ selector == PASS_THRU_METHODS_34 ||
157
+ selector == PASS_THRU_METHODS_35 ||
158
+ selector == PASS_THRU_METHODS_36;
159
+ }
160
+
161
+ /**
162
+ * @notice Gives observability to the methods that are skipped from access control
163
+ * @dev This list is fixed and defined on contract construction
164
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
165
+ */
166
+ // solhint-disable-next-line func-name-mixedcase
167
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
168
+ methods = new bytes4[](37);
169
+ methods[0] = PASS_THRU_METHODS_0;
170
+ methods[1] = PASS_THRU_METHODS_1;
171
+ methods[2] = PASS_THRU_METHODS_2;
172
+ methods[3] = PASS_THRU_METHODS_3;
173
+ methods[4] = PASS_THRU_METHODS_4;
174
+ methods[5] = PASS_THRU_METHODS_5;
175
+ methods[6] = PASS_THRU_METHODS_6;
176
+ methods[7] = PASS_THRU_METHODS_7;
177
+ methods[8] = PASS_THRU_METHODS_8;
178
+ methods[9] = PASS_THRU_METHODS_9;
179
+ methods[10] = PASS_THRU_METHODS_10;
180
+ methods[11] = PASS_THRU_METHODS_11;
181
+ methods[12] = PASS_THRU_METHODS_12;
182
+ methods[13] = PASS_THRU_METHODS_13;
183
+ methods[14] = PASS_THRU_METHODS_14;
184
+ methods[15] = PASS_THRU_METHODS_15;
185
+ methods[16] = PASS_THRU_METHODS_16;
186
+ methods[17] = PASS_THRU_METHODS_17;
187
+ methods[18] = PASS_THRU_METHODS_18;
188
+ methods[19] = PASS_THRU_METHODS_19;
189
+ methods[20] = PASS_THRU_METHODS_20;
190
+ methods[21] = PASS_THRU_METHODS_21;
191
+ methods[22] = PASS_THRU_METHODS_22;
192
+ methods[23] = PASS_THRU_METHODS_23;
193
+ methods[24] = PASS_THRU_METHODS_24;
194
+ methods[25] = PASS_THRU_METHODS_25;
195
+ methods[26] = PASS_THRU_METHODS_26;
196
+ methods[27] = PASS_THRU_METHODS_27;
197
+ methods[28] = PASS_THRU_METHODS_28;
198
+ methods[29] = PASS_THRU_METHODS_29;
199
+ methods[30] = PASS_THRU_METHODS_30;
200
+ methods[31] = PASS_THRU_METHODS_31;
201
+ methods[32] = PASS_THRU_METHODS_32;
202
+ methods[33] = PASS_THRU_METHODS_33;
203
+ methods[34] = PASS_THRU_METHODS_34;
204
+ methods[35] = PASS_THRU_METHODS_35;
205
+ methods[36] = PASS_THRU_METHODS_36;
206
+ }
207
+ }
@@ -0,0 +1,211 @@
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 AccessManagedProxyS38
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 AccessManagedProxyS38 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
+ bytes4 internal immutable PASS_THRU_METHODS_24;
40
+ bytes4 internal immutable PASS_THRU_METHODS_25;
41
+ bytes4 internal immutable PASS_THRU_METHODS_26;
42
+ bytes4 internal immutable PASS_THRU_METHODS_27;
43
+ bytes4 internal immutable PASS_THRU_METHODS_28;
44
+ bytes4 internal immutable PASS_THRU_METHODS_29;
45
+ bytes4 internal immutable PASS_THRU_METHODS_30;
46
+ bytes4 internal immutable PASS_THRU_METHODS_31;
47
+ bytes4 internal immutable PASS_THRU_METHODS_32;
48
+ bytes4 internal immutable PASS_THRU_METHODS_33;
49
+ bytes4 internal immutable PASS_THRU_METHODS_34;
50
+ bytes4 internal immutable PASS_THRU_METHODS_35;
51
+ bytes4 internal immutable PASS_THRU_METHODS_36;
52
+ bytes4 internal immutable PASS_THRU_METHODS_37;
53
+
54
+ /**
55
+ * @notice Constructor of the proxy, defining the implementation and the access manager
56
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
57
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
58
+ *
59
+ * @param implementation The initial implementation contract.
60
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
61
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
62
+ * @param manager The access manager that will handle access control
63
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
64
+ * views and other methods for gas optimization.
65
+ *
66
+ * Requirements:
67
+ *
68
+ * - If `data` is empty, `msg.value` must be zero.
69
+ */
70
+ constructor(
71
+ address implementation,
72
+ bytes memory _data,
73
+ IAccessManager manager,
74
+ bytes4[38] memory passThruMethods
75
+ ) payable AccessManagedProxy(implementation, _data, manager) {
76
+ PASS_THRU_METHODS_0 = passThruMethods[0];
77
+ PASS_THRU_METHODS_1 = passThruMethods[1];
78
+ PASS_THRU_METHODS_2 = passThruMethods[2];
79
+ PASS_THRU_METHODS_3 = passThruMethods[3];
80
+ PASS_THRU_METHODS_4 = passThruMethods[4];
81
+ PASS_THRU_METHODS_5 = passThruMethods[5];
82
+ PASS_THRU_METHODS_6 = passThruMethods[6];
83
+ PASS_THRU_METHODS_7 = passThruMethods[7];
84
+ PASS_THRU_METHODS_8 = passThruMethods[8];
85
+ PASS_THRU_METHODS_9 = passThruMethods[9];
86
+ PASS_THRU_METHODS_10 = passThruMethods[10];
87
+ PASS_THRU_METHODS_11 = passThruMethods[11];
88
+ PASS_THRU_METHODS_12 = passThruMethods[12];
89
+ PASS_THRU_METHODS_13 = passThruMethods[13];
90
+ PASS_THRU_METHODS_14 = passThruMethods[14];
91
+ PASS_THRU_METHODS_15 = passThruMethods[15];
92
+ PASS_THRU_METHODS_16 = passThruMethods[16];
93
+ PASS_THRU_METHODS_17 = passThruMethods[17];
94
+ PASS_THRU_METHODS_18 = passThruMethods[18];
95
+ PASS_THRU_METHODS_19 = passThruMethods[19];
96
+ PASS_THRU_METHODS_20 = passThruMethods[20];
97
+ PASS_THRU_METHODS_21 = passThruMethods[21];
98
+ PASS_THRU_METHODS_22 = passThruMethods[22];
99
+ PASS_THRU_METHODS_23 = passThruMethods[23];
100
+ PASS_THRU_METHODS_24 = passThruMethods[24];
101
+ PASS_THRU_METHODS_25 = passThruMethods[25];
102
+ PASS_THRU_METHODS_26 = passThruMethods[26];
103
+ PASS_THRU_METHODS_27 = passThruMethods[27];
104
+ PASS_THRU_METHODS_28 = passThruMethods[28];
105
+ PASS_THRU_METHODS_29 = passThruMethods[29];
106
+ PASS_THRU_METHODS_30 = passThruMethods[30];
107
+ PASS_THRU_METHODS_31 = passThruMethods[31];
108
+ PASS_THRU_METHODS_32 = passThruMethods[32];
109
+ PASS_THRU_METHODS_33 = passThruMethods[33];
110
+ PASS_THRU_METHODS_34 = passThruMethods[34];
111
+ PASS_THRU_METHODS_35 = passThruMethods[35];
112
+ PASS_THRU_METHODS_36 = passThruMethods[36];
113
+ PASS_THRU_METHODS_37 = passThruMethods[37];
114
+ }
115
+
116
+ /*
117
+ * @notice Skips the access control if the method called is one of the passThruMethods
118
+ * @dev See {PASS_THRU_METHODS()}
119
+ * @param selector The selector of the method called
120
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
121
+ */
122
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
123
+ return
124
+ selector == PASS_THRU_METHODS_0 ||
125
+ selector == PASS_THRU_METHODS_1 ||
126
+ selector == PASS_THRU_METHODS_2 ||
127
+ selector == PASS_THRU_METHODS_3 ||
128
+ selector == PASS_THRU_METHODS_4 ||
129
+ selector == PASS_THRU_METHODS_5 ||
130
+ selector == PASS_THRU_METHODS_6 ||
131
+ selector == PASS_THRU_METHODS_7 ||
132
+ selector == PASS_THRU_METHODS_8 ||
133
+ selector == PASS_THRU_METHODS_9 ||
134
+ selector == PASS_THRU_METHODS_10 ||
135
+ selector == PASS_THRU_METHODS_11 ||
136
+ selector == PASS_THRU_METHODS_12 ||
137
+ selector == PASS_THRU_METHODS_13 ||
138
+ selector == PASS_THRU_METHODS_14 ||
139
+ selector == PASS_THRU_METHODS_15 ||
140
+ selector == PASS_THRU_METHODS_16 ||
141
+ selector == PASS_THRU_METHODS_17 ||
142
+ selector == PASS_THRU_METHODS_18 ||
143
+ selector == PASS_THRU_METHODS_19 ||
144
+ selector == PASS_THRU_METHODS_20 ||
145
+ selector == PASS_THRU_METHODS_21 ||
146
+ selector == PASS_THRU_METHODS_22 ||
147
+ selector == PASS_THRU_METHODS_23 ||
148
+ selector == PASS_THRU_METHODS_24 ||
149
+ selector == PASS_THRU_METHODS_25 ||
150
+ selector == PASS_THRU_METHODS_26 ||
151
+ selector == PASS_THRU_METHODS_27 ||
152
+ selector == PASS_THRU_METHODS_28 ||
153
+ selector == PASS_THRU_METHODS_29 ||
154
+ selector == PASS_THRU_METHODS_30 ||
155
+ selector == PASS_THRU_METHODS_31 ||
156
+ selector == PASS_THRU_METHODS_32 ||
157
+ selector == PASS_THRU_METHODS_33 ||
158
+ selector == PASS_THRU_METHODS_34 ||
159
+ selector == PASS_THRU_METHODS_35 ||
160
+ selector == PASS_THRU_METHODS_36 ||
161
+ selector == PASS_THRU_METHODS_37;
162
+ }
163
+
164
+ /**
165
+ * @notice Gives observability to the methods that are skipped from access control
166
+ * @dev This list is fixed and defined on contract construction
167
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
168
+ */
169
+ // solhint-disable-next-line func-name-mixedcase
170
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
171
+ methods = new bytes4[](38);
172
+ methods[0] = PASS_THRU_METHODS_0;
173
+ methods[1] = PASS_THRU_METHODS_1;
174
+ methods[2] = PASS_THRU_METHODS_2;
175
+ methods[3] = PASS_THRU_METHODS_3;
176
+ methods[4] = PASS_THRU_METHODS_4;
177
+ methods[5] = PASS_THRU_METHODS_5;
178
+ methods[6] = PASS_THRU_METHODS_6;
179
+ methods[7] = PASS_THRU_METHODS_7;
180
+ methods[8] = PASS_THRU_METHODS_8;
181
+ methods[9] = PASS_THRU_METHODS_9;
182
+ methods[10] = PASS_THRU_METHODS_10;
183
+ methods[11] = PASS_THRU_METHODS_11;
184
+ methods[12] = PASS_THRU_METHODS_12;
185
+ methods[13] = PASS_THRU_METHODS_13;
186
+ methods[14] = PASS_THRU_METHODS_14;
187
+ methods[15] = PASS_THRU_METHODS_15;
188
+ methods[16] = PASS_THRU_METHODS_16;
189
+ methods[17] = PASS_THRU_METHODS_17;
190
+ methods[18] = PASS_THRU_METHODS_18;
191
+ methods[19] = PASS_THRU_METHODS_19;
192
+ methods[20] = PASS_THRU_METHODS_20;
193
+ methods[21] = PASS_THRU_METHODS_21;
194
+ methods[22] = PASS_THRU_METHODS_22;
195
+ methods[23] = PASS_THRU_METHODS_23;
196
+ methods[24] = PASS_THRU_METHODS_24;
197
+ methods[25] = PASS_THRU_METHODS_25;
198
+ methods[26] = PASS_THRU_METHODS_26;
199
+ methods[27] = PASS_THRU_METHODS_27;
200
+ methods[28] = PASS_THRU_METHODS_28;
201
+ methods[29] = PASS_THRU_METHODS_29;
202
+ methods[30] = PASS_THRU_METHODS_30;
203
+ methods[31] = PASS_THRU_METHODS_31;
204
+ methods[32] = PASS_THRU_METHODS_32;
205
+ methods[33] = PASS_THRU_METHODS_33;
206
+ methods[34] = PASS_THRU_METHODS_34;
207
+ methods[35] = PASS_THRU_METHODS_35;
208
+ methods[36] = PASS_THRU_METHODS_36;
209
+ methods[37] = PASS_THRU_METHODS_37;
210
+ }
211
+ }
@@ -0,0 +1,215 @@
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 AccessManagedProxyS39
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 AccessManagedProxyS39 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
+ bytes4 internal immutable PASS_THRU_METHODS_24;
40
+ bytes4 internal immutable PASS_THRU_METHODS_25;
41
+ bytes4 internal immutable PASS_THRU_METHODS_26;
42
+ bytes4 internal immutable PASS_THRU_METHODS_27;
43
+ bytes4 internal immutable PASS_THRU_METHODS_28;
44
+ bytes4 internal immutable PASS_THRU_METHODS_29;
45
+ bytes4 internal immutable PASS_THRU_METHODS_30;
46
+ bytes4 internal immutable PASS_THRU_METHODS_31;
47
+ bytes4 internal immutable PASS_THRU_METHODS_32;
48
+ bytes4 internal immutable PASS_THRU_METHODS_33;
49
+ bytes4 internal immutable PASS_THRU_METHODS_34;
50
+ bytes4 internal immutable PASS_THRU_METHODS_35;
51
+ bytes4 internal immutable PASS_THRU_METHODS_36;
52
+ bytes4 internal immutable PASS_THRU_METHODS_37;
53
+ bytes4 internal immutable PASS_THRU_METHODS_38;
54
+
55
+ /**
56
+ * @notice Constructor of the proxy, defining the implementation and the access manager
57
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation` and
58
+ * with `manager` as the ACCESS_MANAGER that will handle access control.
59
+ *
60
+ * @param implementation The initial implementation contract.
61
+ * @param _data If nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
62
+ * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
63
+ * @param manager The access manager that will handle access control
64
+ * @param passThruMethods The selector of methods that will skip the access control validation, typically used for
65
+ * views and other methods for gas optimization.
66
+ *
67
+ * Requirements:
68
+ *
69
+ * - If `data` is empty, `msg.value` must be zero.
70
+ */
71
+ constructor(
72
+ address implementation,
73
+ bytes memory _data,
74
+ IAccessManager manager,
75
+ bytes4[39] memory passThruMethods
76
+ ) payable AccessManagedProxy(implementation, _data, manager) {
77
+ PASS_THRU_METHODS_0 = passThruMethods[0];
78
+ PASS_THRU_METHODS_1 = passThruMethods[1];
79
+ PASS_THRU_METHODS_2 = passThruMethods[2];
80
+ PASS_THRU_METHODS_3 = passThruMethods[3];
81
+ PASS_THRU_METHODS_4 = passThruMethods[4];
82
+ PASS_THRU_METHODS_5 = passThruMethods[5];
83
+ PASS_THRU_METHODS_6 = passThruMethods[6];
84
+ PASS_THRU_METHODS_7 = passThruMethods[7];
85
+ PASS_THRU_METHODS_8 = passThruMethods[8];
86
+ PASS_THRU_METHODS_9 = passThruMethods[9];
87
+ PASS_THRU_METHODS_10 = passThruMethods[10];
88
+ PASS_THRU_METHODS_11 = passThruMethods[11];
89
+ PASS_THRU_METHODS_12 = passThruMethods[12];
90
+ PASS_THRU_METHODS_13 = passThruMethods[13];
91
+ PASS_THRU_METHODS_14 = passThruMethods[14];
92
+ PASS_THRU_METHODS_15 = passThruMethods[15];
93
+ PASS_THRU_METHODS_16 = passThruMethods[16];
94
+ PASS_THRU_METHODS_17 = passThruMethods[17];
95
+ PASS_THRU_METHODS_18 = passThruMethods[18];
96
+ PASS_THRU_METHODS_19 = passThruMethods[19];
97
+ PASS_THRU_METHODS_20 = passThruMethods[20];
98
+ PASS_THRU_METHODS_21 = passThruMethods[21];
99
+ PASS_THRU_METHODS_22 = passThruMethods[22];
100
+ PASS_THRU_METHODS_23 = passThruMethods[23];
101
+ PASS_THRU_METHODS_24 = passThruMethods[24];
102
+ PASS_THRU_METHODS_25 = passThruMethods[25];
103
+ PASS_THRU_METHODS_26 = passThruMethods[26];
104
+ PASS_THRU_METHODS_27 = passThruMethods[27];
105
+ PASS_THRU_METHODS_28 = passThruMethods[28];
106
+ PASS_THRU_METHODS_29 = passThruMethods[29];
107
+ PASS_THRU_METHODS_30 = passThruMethods[30];
108
+ PASS_THRU_METHODS_31 = passThruMethods[31];
109
+ PASS_THRU_METHODS_32 = passThruMethods[32];
110
+ PASS_THRU_METHODS_33 = passThruMethods[33];
111
+ PASS_THRU_METHODS_34 = passThruMethods[34];
112
+ PASS_THRU_METHODS_35 = passThruMethods[35];
113
+ PASS_THRU_METHODS_36 = passThruMethods[36];
114
+ PASS_THRU_METHODS_37 = passThruMethods[37];
115
+ PASS_THRU_METHODS_38 = passThruMethods[38];
116
+ }
117
+
118
+ /*
119
+ * @notice Skips the access control if the method called is one of the passThruMethods
120
+ * @dev See {PASS_THRU_METHODS()}
121
+ * @param selector The selector of the method called
122
+ * @return Whether the access control using ACCESS_MANAGER should be skipped or not
123
+ */
124
+ function _skipAC(bytes4 selector) internal view override returns (bool) {
125
+ return
126
+ selector == PASS_THRU_METHODS_0 ||
127
+ selector == PASS_THRU_METHODS_1 ||
128
+ selector == PASS_THRU_METHODS_2 ||
129
+ selector == PASS_THRU_METHODS_3 ||
130
+ selector == PASS_THRU_METHODS_4 ||
131
+ selector == PASS_THRU_METHODS_5 ||
132
+ selector == PASS_THRU_METHODS_6 ||
133
+ selector == PASS_THRU_METHODS_7 ||
134
+ selector == PASS_THRU_METHODS_8 ||
135
+ selector == PASS_THRU_METHODS_9 ||
136
+ selector == PASS_THRU_METHODS_10 ||
137
+ selector == PASS_THRU_METHODS_11 ||
138
+ selector == PASS_THRU_METHODS_12 ||
139
+ selector == PASS_THRU_METHODS_13 ||
140
+ selector == PASS_THRU_METHODS_14 ||
141
+ selector == PASS_THRU_METHODS_15 ||
142
+ selector == PASS_THRU_METHODS_16 ||
143
+ selector == PASS_THRU_METHODS_17 ||
144
+ selector == PASS_THRU_METHODS_18 ||
145
+ selector == PASS_THRU_METHODS_19 ||
146
+ selector == PASS_THRU_METHODS_20 ||
147
+ selector == PASS_THRU_METHODS_21 ||
148
+ selector == PASS_THRU_METHODS_22 ||
149
+ selector == PASS_THRU_METHODS_23 ||
150
+ selector == PASS_THRU_METHODS_24 ||
151
+ selector == PASS_THRU_METHODS_25 ||
152
+ selector == PASS_THRU_METHODS_26 ||
153
+ selector == PASS_THRU_METHODS_27 ||
154
+ selector == PASS_THRU_METHODS_28 ||
155
+ selector == PASS_THRU_METHODS_29 ||
156
+ selector == PASS_THRU_METHODS_30 ||
157
+ selector == PASS_THRU_METHODS_31 ||
158
+ selector == PASS_THRU_METHODS_32 ||
159
+ selector == PASS_THRU_METHODS_33 ||
160
+ selector == PASS_THRU_METHODS_34 ||
161
+ selector == PASS_THRU_METHODS_35 ||
162
+ selector == PASS_THRU_METHODS_36 ||
163
+ selector == PASS_THRU_METHODS_37 ||
164
+ selector == PASS_THRU_METHODS_38;
165
+ }
166
+
167
+ /**
168
+ * @notice Gives observability to the methods that are skipped from access control
169
+ * @dev This list is fixed and defined on contract construction
170
+ * @return methods The list of method selectors that skip ACCESS_MANAGER access control
171
+ */
172
+ // solhint-disable-next-line func-name-mixedcase
173
+ function PASS_THRU_METHODS() external view returns (bytes4[] memory methods) {
174
+ methods = new bytes4[](39);
175
+ methods[0] = PASS_THRU_METHODS_0;
176
+ methods[1] = PASS_THRU_METHODS_1;
177
+ methods[2] = PASS_THRU_METHODS_2;
178
+ methods[3] = PASS_THRU_METHODS_3;
179
+ methods[4] = PASS_THRU_METHODS_4;
180
+ methods[5] = PASS_THRU_METHODS_5;
181
+ methods[6] = PASS_THRU_METHODS_6;
182
+ methods[7] = PASS_THRU_METHODS_7;
183
+ methods[8] = PASS_THRU_METHODS_8;
184
+ methods[9] = PASS_THRU_METHODS_9;
185
+ methods[10] = PASS_THRU_METHODS_10;
186
+ methods[11] = PASS_THRU_METHODS_11;
187
+ methods[12] = PASS_THRU_METHODS_12;
188
+ methods[13] = PASS_THRU_METHODS_13;
189
+ methods[14] = PASS_THRU_METHODS_14;
190
+ methods[15] = PASS_THRU_METHODS_15;
191
+ methods[16] = PASS_THRU_METHODS_16;
192
+ methods[17] = PASS_THRU_METHODS_17;
193
+ methods[18] = PASS_THRU_METHODS_18;
194
+ methods[19] = PASS_THRU_METHODS_19;
195
+ methods[20] = PASS_THRU_METHODS_20;
196
+ methods[21] = PASS_THRU_METHODS_21;
197
+ methods[22] = PASS_THRU_METHODS_22;
198
+ methods[23] = PASS_THRU_METHODS_23;
199
+ methods[24] = PASS_THRU_METHODS_24;
200
+ methods[25] = PASS_THRU_METHODS_25;
201
+ methods[26] = PASS_THRU_METHODS_26;
202
+ methods[27] = PASS_THRU_METHODS_27;
203
+ methods[28] = PASS_THRU_METHODS_28;
204
+ methods[29] = PASS_THRU_METHODS_29;
205
+ methods[30] = PASS_THRU_METHODS_30;
206
+ methods[31] = PASS_THRU_METHODS_31;
207
+ methods[32] = PASS_THRU_METHODS_32;
208
+ methods[33] = PASS_THRU_METHODS_33;
209
+ methods[34] = PASS_THRU_METHODS_34;
210
+ methods[35] = PASS_THRU_METHODS_35;
211
+ methods[36] = PASS_THRU_METHODS_36;
212
+ methods[37] = PASS_THRU_METHODS_37;
213
+ methods[38] = PASS_THRU_METHODS_38;
214
+ }
215
+ }