@@ -7,10 +7,11 @@ import { Script } from "forge-std/Script.sol";
7
7
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol " ;
8
8
import { AccessManager } from "@openzeppelin/contracts/access/manager/AccessManager.sol " ;
9
9
import { AccessManaged } from "@openzeppelin/contracts/access/manager/AccessManaged.sol " ;
10
- import { AccessController } from "contracts/access/AccessController.sol " ;
11
- import { ProtocolAdmin } from "contracts/lib/ProtocolAdmin.sol " ;
12
- import { IIPAssetRegistry } from "contracts/interfaces/registries/IIPAssetRegistry.sol " ;
13
- import { IVaultController } from "contracts/interfaces/modules/royalty/policies/IVaultController.sol " ;
10
+
11
+ // contracts
12
+ import { ProtocolAdmin } from "../../../../contracts/lib/ProtocolAdmin.sol " ;
13
+ import { IIPAssetRegistry } from "../../../../contracts/interfaces/registries/IIPAssetRegistry.sol " ;
14
+ import { IVaultController } from "../../../../contracts/interfaces/modules/royalty/policies/IVaultController.sol " ;
14
15
15
16
// script
16
17
import { BroadcastManager } from "../BroadcastManager.s.sol " ;
@@ -28,7 +29,6 @@ import { StorageLayoutChecker } from "./StorageLayoutCheck.s.sol";
28
29
*/
29
30
abstract contract UpgradeExecutor is Script , BroadcastManager , JsonDeploymentHandler , JsonBatchTxHelper {
30
31
address internal CREATE3_DEPLOYER = 0x9fBB3DF7C40Da2e5A0dE984fFE2CCB7C47cd0ABf ;
31
- uint256 internal CREATE3_DEFAULT_SEED = 0 ;
32
32
33
33
/// @notice Upgrade modes
34
34
enum UpgradeModes {
@@ -58,19 +58,6 @@ abstract contract UpgradeExecutor is Script, BroadcastManager, JsonDeploymentHan
58
58
/// @notice action accumulator for batch txs
59
59
bytes [] multicallData;
60
60
61
- /// @dev check if the proxy's authority is the accessManager in the file
62
- /// @param proxy The proxy address
63
- modifier onlyMatchingAccessManager (string memory contractKey , address proxy ) {
64
- if (keccak256 (abi.encodePacked (contractKey)) != keccak256 (abi.encodePacked ("IpRoyaltyVault " )) &&
65
- keccak256 (abi.encodePacked (contractKey)) != keccak256 (abi.encodePacked ("IPAccountImplCode " ))) {
66
- require (
67
- AccessManaged (proxy).authority () == address (accessManager),
68
- "Proxy's Authority must equal accessManager "
69
- );
70
- }
71
- _;
72
- }
73
-
74
61
/// @dev check if the caller has the Upgrader role
75
62
modifier onlyUpgraderRole () {
76
63
(bool isMember , ) = accessManager.hasRole (ProtocolAdmin.UPGRADER_ROLE, deployer);
@@ -156,7 +143,8 @@ abstract contract UpgradeExecutor is Script, BroadcastManager, JsonDeploymentHan
156
143
function _scheduleUpgrade (
157
144
string memory key ,
158
145
UpgradedImplHelper.UpgradeProposal memory p
159
- ) private onlyMatchingAccessManager (key, p.proxy) onlyUpgraderRole {
146
+ ) private {
147
+ _checkMatchingAccessManager (key, p.proxy);
160
148
bytes memory data = _getExecutionData (key, p);
161
149
if (data.length == 0 ) {
162
150
revert ("No data to schedule " );
@@ -199,7 +187,8 @@ abstract contract UpgradeExecutor is Script, BroadcastManager, JsonDeploymentHan
199
187
function _executeUpgrade (
200
188
string memory key ,
201
189
UpgradedImplHelper.UpgradeProposal memory p
202
- ) private onlyMatchingAccessManager (key,p.proxy) {
190
+ ) private {
191
+ _checkMatchingAccessManager (key, p.proxy);
203
192
bytes memory data = _getExecutionData (key, p);
204
193
uint48 schedule = accessManager.getSchedule (accessManager.hashOperation (deployer, p.proxy, data));
205
194
console2.log ("schedule " , schedule);
@@ -236,7 +225,8 @@ abstract contract UpgradeExecutor is Script, BroadcastManager, JsonDeploymentHan
236
225
function _cancelScheduledUpgrade (
237
226
string memory key ,
238
227
UpgradedImplHelper.UpgradeProposal memory p
239
- ) private onlyMatchingAccessManager (key, p.proxy) {
228
+ ) private {
229
+ _checkMatchingAccessManager (key, p.proxy);
240
230
bytes memory data = _getExecutionData (key, p);
241
231
if (data.length == 0 ) {
242
232
revert ("No data to schedule " );
@@ -272,7 +262,7 @@ abstract contract UpgradeExecutor is Script, BroadcastManager, JsonDeploymentHan
272
262
function _getExecutionData (
273
263
string memory key ,
274
264
UpgradedImplHelper.UpgradeProposal memory p
275
- ) internal returns (bytes memory data ) {
265
+ ) internal virtual returns (bytes memory data ) {
276
266
if (keccak256 (abi.encodePacked (key)) == keccak256 (abi.encodePacked ("IpRoyaltyVault " ))) {
277
267
console2.log ("encoding upgradeVaults " );
278
268
data = abi.encodeCall (IVaultController.upgradeVaults, (p.newImpl));
@@ -285,4 +275,14 @@ abstract contract UpgradeExecutor is Script, BroadcastManager, JsonDeploymentHan
285
275
}
286
276
return data;
287
277
}
278
+
279
+ function _checkMatchingAccessManager (string memory contractKey , address proxy ) virtual internal {
280
+ if (keccak256 (abi.encodePacked (contractKey)) != keccak256 (abi.encodePacked ("IpRoyaltyVault " )) &&
281
+ keccak256 (abi.encodePacked (contractKey)) != keccak256 (abi.encodePacked ("IPAccountImplCode " ))) {
282
+ require (
283
+ AccessManaged (proxy).authority () == address (accessManager),
284
+ "Proxy's Authority must equal accessManager "
285
+ );
286
+ }
287
+ }
288
288
}
0 commit comments