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