Skip to content

Commit 731947a

Browse files
author
ilitteri
committed
Update scripts
1 parent 5484f06 commit 731947a

File tree

3 files changed

+128
-94
lines changed

3 files changed

+128
-94
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
import "../src/AlignedToken.sol";
5+
import "../src/ClaimableAirdrop.sol";
6+
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
7+
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
8+
import "forge-std/Script.sol";
9+
import {Utils} from "./Utils.sol";
10+
11+
contract DeployAlignedToken is Script {
12+
function run() public {
13+
string memory root = vm.projectRoot();
14+
string memory path = string.concat(root, "/script-config/config.json");
15+
string memory config_json = vm.readFile(path);
16+
17+
address _safe = stdJson.readAddress(config_json, ".safe");
18+
bytes32 _salt = stdJson.readBytes32(config_json, ".salt");
19+
address _deployer = stdJson.readAddress(config_json, ".deployer");
20+
address _foundation = stdJson.readAddress(config_json, ".foundation");
21+
address _claim = stdJson.readAddress(config_json, ".claim");
22+
23+
ProxyAdmin _proxyAdmin = deployProxyAdmin(_safe, _salt, _deployer);
24+
25+
console.log(
26+
"Proxy Admin deployed at address :",
27+
address(_proxyAdmin),
28+
"with owner:",
29+
_safe
30+
);
31+
32+
TransparentUpgradeableProxy _tokenProxy = deployAlignedTokenProxy(
33+
address(_proxyAdmin),
34+
_salt,
35+
_deployer,
36+
_safe,
37+
_foundation,
38+
_claim
39+
);
40+
41+
console.log(
42+
string.concat(
43+
"Aligned Token Proxy deployed at address :",
44+
vm.toString(address(_tokenProxy)),
45+
"with proxy admin:",
46+
vm.toString(address(_proxyAdmin)),
47+
"and owner:",
48+
vm.toString(_safe)
49+
)
50+
);
51+
}
52+
53+
function deployProxyAdmin(
54+
address _safe,
55+
bytes32 _salt,
56+
address _deployer
57+
) internal returns (ProxyAdmin) {
58+
bytes memory _proxyAdminDeploymentData = Utils.proxyAdminDeploymentData(
59+
_safe
60+
);
61+
address _proxyAdminCreate2Address = Utils.deployWithCreate2(
62+
_proxyAdminDeploymentData,
63+
_salt,
64+
_deployer
65+
);
66+
67+
return ProxyAdmin(_proxyAdminCreate2Address);
68+
}
69+
70+
function deployAlignedTokenProxy(
71+
address _proxyAdmin,
72+
bytes32 _salt,
73+
address _deployer,
74+
address _owner,
75+
address _foundation,
76+
address _claim
77+
) internal returns (TransparentUpgradeableProxy) {
78+
vm.broadcast();
79+
AlignedToken _token = new AlignedToken();
80+
81+
bytes memory _alignedTokenDeploymentData = Utils
82+
.alignedTokenProxyDeploymentData(
83+
_proxyAdmin,
84+
address(_token),
85+
_owner,
86+
_foundation,
87+
_claim
88+
);
89+
address _alignedTokenProxy = Utils.deployWithCreate2(
90+
_alignedTokenDeploymentData,
91+
_salt,
92+
_deployer
93+
);
94+
return TransparentUpgradeableProxy(payable(_alignedTokenProxy));
95+
}
96+
}

claim_contracts/script/DeployAll.s.sol

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,12 @@ contract DeployAll is Script {
1717
address _safe = stdJson.readAddress(config_json, ".safe");
1818
bytes32 _salt = stdJson.readBytes32(config_json, ".salt");
1919
address _deployer = stdJson.readAddress(config_json, ".deployer");
20-
address _beneficiary1 = stdJson.readAddress(
20+
address _foundation = stdJson.readAddress(config_json, ".foundation");
21+
address _claim = stdJson.readAddress(config_json, ".claim");
22+
uint256 _claimPrivateKey = stdJson.readUint(
2123
config_json,
22-
".beneficiary1"
24+
".claimPrivateKey"
2325
);
24-
address _beneficiary2 = stdJson.readAddress(
25-
config_json,
26-
".beneficiary2"
27-
);
28-
address _beneficiary3 = stdJson.readAddress(
29-
config_json,
30-
".beneficiary3"
31-
);
32-
uint256 _mintAmount = stdJson.readUint(config_json, ".mintAmount");
3326
uint256 _limitTimestampToClaim = stdJson.readUint(
3427
config_json,
3528
".limitTimestampToClaim"
@@ -38,39 +31,30 @@ contract DeployAll is Script {
3831
config_json,
3932
".claimMerkleRoot"
4033
);
41-
uint256 _holderPrivateKey = stdJson.readUint(
42-
config_json,
43-
".holderPrivateKey"
44-
);
4534

4635
ProxyAdmin _proxyAdmin = deployProxyAdmin(_safe, _salt, _deployer);
4736

4837
TransparentUpgradeableProxy _tokenProxy = deployAlignedTokenProxy(
4938
address(_proxyAdmin),
5039
_salt,
5140
_deployer,
52-
_beneficiary1,
53-
_beneficiary2,
54-
_beneficiary3,
55-
_mintAmount
41+
_safe,
42+
_foundation,
43+
_claim
5644
);
5745

5846
TransparentUpgradeableProxy _airdropProxy = deployClaimableAirdropProxy(
5947
address(_proxyAdmin),
6048
_safe,
61-
_beneficiary1,
49+
_foundation,
6250
_salt,
6351
_deployer,
6452
address(_tokenProxy),
6553
_limitTimestampToClaim,
6654
_claimMerkleRoot
6755
);
6856

69-
approve(
70-
address(_tokenProxy),
71-
address(_airdropProxy),
72-
_holderPrivateKey
73-
);
57+
approve(address(_tokenProxy), address(_airdropProxy), _claimPrivateKey);
7458
}
7559

7660
function deployProxyAdmin(
@@ -107,10 +91,9 @@ contract DeployAll is Script {
10791
address _proxyAdmin,
10892
bytes32 _salt,
10993
address _deployer,
110-
address _beneficiary1,
111-
address _beneficiary2,
112-
address _beneficiary3,
113-
uint256 _mintAmount
94+
address _owner,
95+
address _foundation,
96+
address _claim
11497
) internal returns (TransparentUpgradeableProxy) {
11598
vm.broadcast();
11699
AlignedToken _token = new AlignedToken();
@@ -119,10 +102,9 @@ contract DeployAll is Script {
119102
.alignedTokenProxyDeploymentData(
120103
_proxyAdmin,
121104
address(_token),
122-
_beneficiary1,
123-
_beneficiary2,
124-
_beneficiary3,
125-
_mintAmount
105+
_owner,
106+
_foundation,
107+
_claim
126108
);
127109
address _alignedTokenProxy = Utils.deployWithCreate2(
128110
_alignedTokenDeploymentData,
@@ -194,9 +176,9 @@ contract DeployAll is Script {
194176
function approve(
195177
address _tokenContractProxy,
196178
address _airdropContractProxy,
197-
uint256 _holderPrivateKey
179+
uint256 _claimPrivateKey
198180
) public {
199-
vm.startBroadcast(_holderPrivateKey);
181+
vm.startBroadcast(_claimPrivateKey);
200182
(bool success, bytes memory data) = address(_tokenContractProxy).call(
201183
abi.encodeCall(
202184
IERC20.approve,

claim_contracts/script/Utils.sol

Lines changed: 15 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.so
77
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
88
import "../src/AlignedToken.sol";
99
import "../src/ClaimableAirdrop.sol";
10+
import "../src/ClaimableAirdropV2.sol";
1011

1112
library Utils {
1213
// Cheatcodes address, 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D.
@@ -85,10 +86,9 @@ library Utils {
8586
function alignedTokenProxyDeploymentData(
8687
address _proxyAdmin,
8788
address _implementation,
88-
address _beneficiary1,
89-
address _beneficiary2,
90-
address _beneficiary3,
91-
uint256 _mintAmount
89+
address _owner,
90+
address _foundation,
91+
address _claim
9292
) internal pure returns (bytes memory) {
9393
return
9494
abi.encodePacked(
@@ -98,59 +98,24 @@ library Utils {
9898
_proxyAdmin,
9999
alignedTokenInitData(
100100
_implementation,
101-
_beneficiary1,
102-
_beneficiary2,
103-
_beneficiary3,
104-
_mintAmount
101+
_owner,
102+
_foundation,
103+
_claim
105104
)
106105
)
107106
);
108107
}
109108

110109
function alignedTokenInitData(
111110
address _implementation,
112-
address _beneficiary1,
113-
address _beneficiary2,
114-
address _beneficiary3,
115-
uint256 _mintAmount
111+
address _owner,
112+
address _foundation,
113+
address _claim
116114
) internal pure returns (bytes memory) {
117115
return
118116
abi.encodeCall(
119117
AlignedToken(_implementation).initialize,
120-
(
121-
_beneficiary1,
122-
_mintAmount,
123-
_beneficiary2,
124-
_mintAmount,
125-
_beneficiary3,
126-
_mintAmount
127-
)
128-
);
129-
}
130-
131-
function alignedTokenUpgradeData(
132-
address _proxyAdmin,
133-
address _proxy,
134-
address _newImplementation,
135-
address _beneficiary1,
136-
address _beneficiary2,
137-
address _beneficiary3,
138-
uint256 _mintAmount
139-
) internal pure returns (bytes memory) {
140-
return
141-
abi.encodeCall(
142-
ProxyAdmin(_proxyAdmin).upgradeAndCall,
143-
(
144-
ITransparentUpgradeableProxy(_proxy),
145-
_newImplementation,
146-
Utils.alignedTokenInitData(
147-
_newImplementation,
148-
_beneficiary1,
149-
_beneficiary2,
150-
_beneficiary3,
151-
_mintAmount
152-
)
153-
)
118+
(_owner, _foundation, _claim)
154119
);
155120
}
156121

@@ -212,26 +177,17 @@ library Utils {
212177

213178
function claimableAirdropUpgradeData(
214179
address _proxy,
215-
address _owner,
216-
address _newImplementation,
217-
address _tokenContractAddress,
218-
address _tokenOwnerAddress,
219-
uint256 _limitTimestampToClaim,
220-
bytes32 _claimMerkleRoot
180+
address _newImplementation
221181
) internal pure returns (bytes memory) {
222182
return
223183
abi.encodeCall(
224184
ProxyAdmin(_newImplementation).upgradeAndCall,
225185
(
226186
ITransparentUpgradeableProxy(_proxy),
227187
_newImplementation,
228-
Utils.claimableAirdropInitData(
229-
_owner,
230-
_newImplementation,
231-
_tokenContractAddress,
232-
_tokenOwnerAddress,
233-
_limitTimestampToClaim,
234-
_claimMerkleRoot
188+
abi.encodeCall(
189+
ClaimableAirdropV2(_newImplementation).reinitialize,
190+
()
235191
)
236192
)
237193
);

0 commit comments

Comments
 (0)