-
Notifications
You must be signed in to change notification settings - Fork 8
/
LensV2UpgradeContract.sol
129 lines (114 loc) · 4.73 KB
/
LensV2UpgradeContract.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import {ProxyAdmin} from 'contracts/misc/access/ProxyAdmin.sol';
import {Governance} from 'contracts/misc/access/Governance.sol';
import {ImmutableOwnable} from 'contracts/misc/ImmutableOwnable.sol';
contract LensV2UpgradeContract is ImmutableOwnable {
ProxyAdmin public immutable PROXY_ADMIN;
Governance public immutable GOVERNANCE;
address public immutable newImplementation;
address[] public oldFollowModulesToUnwhitelist;
address[] public newFollowModulesToWhitelist;
address[] public oldReferenceModulesToUnwhitelist;
address[] public newReferenceModulesToWhitelist;
address[] public oldCollectModulesToUnwhitelist;
address[] public newActionModulesToWhitelist;
constructor(
address proxyAdminAddress,
address governanceAddress,
address owner,
address lensHub,
address newImplementationAddress,
address[] memory oldFollowModulesToUnwhitelist_,
address[] memory newFollowModulesToWhitelist_,
address[] memory oldReferenceModulesToUnwhitelist_,
address[] memory newReferenceModulesToWhitelist_,
address[] memory oldCollectModulesToUnwhitelist_,
address[] memory newActionModulesToWhitelist_
) ImmutableOwnable(owner, lensHub) {
PROXY_ADMIN = ProxyAdmin(proxyAdminAddress);
GOVERNANCE = Governance(governanceAddress);
newImplementation = newImplementationAddress;
oldFollowModulesToUnwhitelist = oldFollowModulesToUnwhitelist_;
newFollowModulesToWhitelist = newFollowModulesToWhitelist_;
oldReferenceModulesToUnwhitelist = oldReferenceModulesToUnwhitelist_;
newReferenceModulesToWhitelist = newReferenceModulesToWhitelist_;
oldCollectModulesToUnwhitelist = oldCollectModulesToUnwhitelist_;
newActionModulesToWhitelist = newActionModulesToWhitelist_;
}
function executeLensV2Upgrade() external onlyOwner {
// _preUpgradeChecks();
_upgrade();
// _postUpgradeChecks();
}
function _upgrade() internal {
_unwhitelistOldFollowModules();
_unwhitelistOldReferenceModules();
_unwhitelistOldCollectModules();
PROXY_ADMIN.proxy_upgrade(newImplementation);
_whitelistNewFollowModules();
_whitelistNewReferenceModules();
_whitelistNewActionModules();
GOVERNANCE.clearControllerContract();
}
function _unwhitelistOldFollowModules() internal {
uint256 oldFollowModulesToUnwhitelistLength = oldFollowModulesToUnwhitelist.length;
uint256 i;
while (i < oldFollowModulesToUnwhitelistLength) {
GOVERNANCE.lensHub_whitelistFollowModule(oldFollowModulesToUnwhitelist[i], false);
unchecked {
++i;
}
}
}
function _unwhitelistOldReferenceModules() internal {
uint256 oldReferenceModulesToUnwhitelistLength = oldReferenceModulesToUnwhitelist.length;
uint256 i;
while (i < oldReferenceModulesToUnwhitelistLength) {
GOVERNANCE.lensHub_whitelistReferenceModule(oldReferenceModulesToUnwhitelist[i], false);
unchecked {
++i;
}
}
}
function _unwhitelistOldCollectModules() internal {
uint256 oldCollectModulesToUnwhitelistLength = oldCollectModulesToUnwhitelist.length;
uint256 i;
while (i < oldCollectModulesToUnwhitelistLength) {
GOVERNANCE.lensHub_whitelistCollectModule(oldCollectModulesToUnwhitelist[i], false);
unchecked {
++i;
}
}
}
function _whitelistNewFollowModules() internal {
uint256 newFollowModulesToWhitelistLength = newFollowModulesToWhitelist.length;
uint256 i;
while (i < newFollowModulesToWhitelistLength) {
GOVERNANCE.lensHub_whitelistFollowModule(newFollowModulesToWhitelist[i], true);
unchecked {
++i;
}
}
}
function _whitelistNewReferenceModules() internal {
uint256 newReferenceModulesToWhitelistLength = newReferenceModulesToWhitelist.length;
uint256 i;
while (i < newReferenceModulesToWhitelistLength) {
GOVERNANCE.lensHub_whitelistReferenceModule(newReferenceModulesToWhitelist[i], true);
unchecked {
++i;
}
}
}
function _whitelistNewActionModules() internal {
uint256 newActionModulesToWhitelistLength = newActionModulesToWhitelist.length;
uint256 i;
while (i < newActionModulesToWhitelistLength) {
GOVERNANCE.lensHub_whitelistActionModule(newActionModulesToWhitelist[i], true);
unchecked {
++i;
}
}
}
}