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