-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathDeployAlignedToken.s.sol
More file actions
105 lines (93 loc) · 3.22 KB
/
DeployAlignedToken.s.sol
File metadata and controls
105 lines (93 loc) · 3.22 KB
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "../src/AlignedToken.sol";
import "../src/ClaimableAirdrop.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "forge-std/Script.sol";
import {Utils} from "./Utils.sol";
contract DeployAlignedToken is Script {
function run(string memory config) public {
string memory root = vm.projectRoot();
string memory path = string.concat(
root,
"/script-config/config.",
config,
".json"
);
string memory config_json = vm.readFile(path);
address _safe = stdJson.readAddress(config_json, ".safe");
bytes32 _salt = stdJson.readBytes32(config_json, ".salt");
address _deployer = stdJson.readAddress(config_json, ".deployer");
address _foundation = stdJson.readAddress(config_json, ".foundation");
address _claimSupplier = stdJson.readAddress(
config_json,
".claimSupplier"
);
ProxyAdmin _proxyAdmin = deployProxyAdmin(_safe, _salt, _deployer);
console.log(
"Proxy Admin deployed at address:",
address(_proxyAdmin),
"with owner:",
_safe
);
TransparentUpgradeableProxy _tokenProxy = deployAlignedTokenProxy(
address(_proxyAdmin),
_salt,
_deployer,
_foundation,
_claimSupplier
);
console.log(
string.concat(
"Aligned Token Proxy deployed at address: ",
vm.toString(address(_tokenProxy)),
" with proxy admin: ",
vm.toString(address(_proxyAdmin)),
" and owner: ",
vm.toString(_safe)
)
);
console.log(
"Remember that the foundation must accept the ownership of the contract after deployment in another transaction."
);
}
function deployProxyAdmin(
address _safe,
bytes32 _salt,
address _deployer
) internal returns (ProxyAdmin) {
bytes memory _proxyAdminDeploymentData = Utils.proxyAdminDeploymentData(
_safe
);
address _proxyAdminCreate2Address = Utils.deployWithCreate2(
_proxyAdminDeploymentData,
_salt,
_deployer
);
return ProxyAdmin(_proxyAdminCreate2Address);
}
function deployAlignedTokenProxy(
address _proxyAdmin,
bytes32 _salt,
address _deployer,
address _foundation,
address _claim
) internal returns (TransparentUpgradeableProxy) {
vm.broadcast();
AlignedToken _token = new AlignedToken();
bytes memory _alignedTokenDeploymentData = Utils
.alignedTokenProxyDeploymentData(
_proxyAdmin,
address(_token),
_foundation,
_claim
);
address _alignedTokenProxy = Utils.deployWithCreate2(
_alignedTokenDeploymentData,
_salt,
_deployer
);
return TransparentUpgradeableProxy(payable(_alignedTokenProxy));
}
}