Skip to content

Commit 4c3e352

Browse files
committed
pull from main
2 parents fe26d8f + f3adf99 commit 4c3e352

File tree

13 files changed

+234
-133
lines changed

13 files changed

+234
-133
lines changed

claim_contracts/Makefile

Lines changed: 2 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ help: ## 📚 Show help for each of the Makefile recipes
77
# Deployments
88

99
RPC_URL?=http://localhost:8545
10-
PRIVATE_KEY?=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
10+
PRIVATE_KEY?=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
1111

1212
deploy-all: ## 🚀 Deploy all contracts
1313
cd script && \
@@ -46,57 +46,6 @@ upgrade-token: ## 🚀 Upgrade the token contract
4646
--broadcast \
4747
--verbosity 3
4848

49-
MINT?="1 ether"
50-
OWNER?=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
51-
BENEFICIARY1?=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
52-
BENEFICIARY2?=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
53-
BENEFICIARY3?=0x90F79bf6EB2c4f870365E785982E1f101E93b906
54-
55-
CLAIM_TIME_LIMIT?=1632960000
56-
MERKLE_ROOT?=0x90076b5fb9a6c81d9fce83dfd51760987b8c49e7c861ea25b328e6e63d2cd3df
57-
TOKEN_OWNER?=$(OWNER)
58-
59-
deploy-proxy-admin: ## 🚀 Deploy the ProxyAdmin contract
60-
cd script/proxy_admin && \
61-
forge script DeployProxyAdmin.s.sol \
62-
--sig "run(address)" \
63-
$(OWNER) \
64-
--rpc-url $(RPC_URL) \
65-
--private-key $(PRIVATE_KEY) \
66-
--broadcast
67-
68-
deploy-aligned-token-implementation: ## 🚀 Deploy the AlignedToken implementation contract
69-
cd script/aligned_token && \
70-
forge script DeployAlignedTokenImplementation.s.sol \
71-
--rpc-url $(RPC_URL) \
72-
--private-key $(PRIVATE_KEY) \
73-
--broadcast
74-
75-
deploy-aligned-token-proxy: ## 🚀 Deploy the AlignedToken proxy contract
76-
cd script/aligned_token && \
77-
forge script DeployAlignedTokenProxy.s.sol \
78-
--sig "run(address,address,address,address,address,address,uint256)" \
79-
$(PROXY_ADMIN) $(IMPLEMENTATION) $(OWNER) $(BENEFICIARY1) $(BENEFICIARY2) $(BENEFICIARY3) $(MINT) \
80-
--rpc-url $(RPC_URL) \
81-
--private-key $(PRIVATE_KEY) \
82-
--broadcast
83-
84-
deploy-claimable-airdrop-implementation: ## 🚀 Deploy the ClaimableAirdrop implementation contract
85-
cd script/claimable_airdrop && \
86-
forge script DeployClaimableAirdropImplementation.s.sol \
87-
--rpc-url $(RPC_URL) \
88-
--private-key $(PRIVATE_KEY) \
89-
--broadcast
90-
91-
deploy-claimable-airdrop-proxy: ## 🚀 Deploy the ClaimableAirdrop proxy contract
92-
cd script/claimable_airdrop && \
93-
forge script DeployClaimableAirdropProxy.s.sol \
94-
--sig "run(address,address,address,address,address,uint256,bytes32)" \
95-
$(PROXY_ADMIN) $(IMPLEMENTATION) $(OWNER) $(TOKEN) $(BENEFICIARY1) $(CLAIM_TIME_LIMIT) $(MERKLE_ROOT) \
96-
--rpc-url $(RPC_URL) \
97-
--private-key $(PRIVATE_KEY) \
98-
--broadcast
99-
10049
# Upgrades
10150

10251
upgrade-aligned-token-implementation: ## 🚀 Upgrade the AlignedToken implementation contract
@@ -108,57 +57,11 @@ upgrade-aligned-token-implementation: ## 🚀 Upgrade the AlignedToken implement
10857
--private-key $(PRIVATE_KEY) \
10958
--broadcast
11059

111-
# Deployment Data
112-
113-
aligned-token-proxy-deploy-data: ## 🚀 Generate the deployment data for the AlignedToken proxy contract
114-
cd script/aligned_token && \
115-
forge script AlignedTokenProxyDeploymentData.s.sol \
116-
--sig "run(address,uint256, address,address,address,address,uint256)" \
117-
$(IMPLEMENTATION) $(VERSION) $(OWNER) $(BENEFICIARY1) $(BENEFICIARY2) $(BENEFICIARY3) $(MINT)
118-
119-
aligned-token-init-data: ## 🚀 Generate the init data for the AlignedToken proxy contract
120-
cd script/aligned_token && \
121-
forge script AlignedTokenInitData.s.sol \
122-
--sig "run(address,uint256, address,address,address,address,uint256)" \
123-
$(IMPLEMENTATION) $(VERSION) $(OWNER) $(BENEFICIARY1) $(BENEFICIARY2) $(BENEFICIARY3) $(MINT)
124-
125-
aligned-token-upgrade-data: ## 🚀 Generate the upgrade data for the AlignedToken proxy contract
126-
cd script/aligned_token && \
127-
forge script AlignedTokenUpgradeData.s.sol \
128-
--sig "run(address,uint256, address,address,address,address,uint256)" \
129-
$(IMPLEMENTATION) $(VERSION) $(OWNER) $(BENEFICIARY1) $(BENEFICIARY2) $(BENEFICIARY3) $(MINT)
130-
131-
SALT?=0x0000000000000000000000000000000000000000000000000000000000000000
132-
# Sepolia Safe CreateCall contract.
133-
DEPLOYER?=0x9b35Af71d77eaf8d7e40252370304687390A1A52
134-
135-
aligned-token-create2: ## 🚀 Generate the create2 data for the AlignedToken proxy contract
136-
cd script/aligned_token && \
137-
forge script AlignedTokenCreate2.s.sol \
138-
--sig "run(uint256,bytes32,address)" \
139-
$(VERSION) $(SALT) $(DEPLOYER)
140-
141-
aligned-token-proxy-create2: ## 🚀 Generate the create2 data for the AlignedToken proxy contract
142-
cd script/aligned_token && \
143-
forge script AlignedTokenCreate2.s.sol \
144-
--sig "run(address,uint256, address,address,address,address,uint256,bytes32,address)" \
145-
$(IMPLEMENTATION) $(VERSION) $(OWNER) $(BENEFICIARY1) $(BENEFICIARY2) $(BENEFICIARY3) $(MINT) $(SALT) $(DEPLOYER
146-
147-
# Misc
148-
149-
approve:
150-
cd script && \
151-
forge script ApproveERC20.s.sol \
152-
--sig "run(address,address,uint256)" \
153-
$(TOKEN) $(AIRDROP) $(AMOUNT) \
154-
--rpc-url $(RPC_URL) \
155-
--private-key $(HOLDER_PRIVATE_KEY) \
156-
--broadcast
157-
15860
# Test targets
15961

16062
test-token:
16163
cast call $(ADDRESS) "name()(string)" --rpc-url $(RPC_URL)
64+
cast call $(ADDRESS) "symbol()(string)" --rpc-url $(RPC_URL)
16265
cast call $(ADDRESS) "totalSupply()(uint256)" --rpc-url $(RPC_URL)
16366

16467
# The following target needs the proof API running on localhost:4000

claim_contracts/foundry.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ libs = ["lib"]
55
optimizer = true
66
optimizer_runs = 999_999
77

8+
solc_version = "0.8.28"
9+
810
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
911
fs_permissions = [
1012
{ access = "read-write", path = "script-out/" },

claim_contracts/script-config/config.example.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
2-
"safe": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
32
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
43
"deployer": "0x4e59b44847b379578588920cA78FbF26c0B4956C",
54
"foundation": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
65
"claimSupplier": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
7-
"claimSupplierPrivateKey": "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
86
"limitTimestampToClaim": 2733427549,
97
"claimMerkleRoot": "0x90076b5fb9a6c81d9fce83dfd51760987b8c49e7c861ea25b328e6e63d2cd3df",
108
"airdropProxy": "0x882b82f4E9014164Af87ecdAB64955cf7C252C4f",

claim_contracts/script/DeployAlignedToken.s.sol

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ contract DeployAlignedToken is Script {
1515
string memory path = string.concat(root, "/script-config/config.", config, ".json");
1616
string memory config_json = vm.readFile(path);
1717

18-
address _safe = stdJson.readAddress(config_json, ".safe");
1918
bytes32 _salt = stdJson.readBytes32(config_json, ".salt");
2019
address _deployer = stdJson.readAddress(config_json, ".deployer");
2120
address _foundation = stdJson.readAddress(config_json, ".foundation");
2221
address _claimSupplier = stdJson.readAddress(config_json, ".claimSupplier");
2322

24-
TransparentUpgradeableProxy _tokenProxy =
25-
deployAlignedTokenProxy(_safe, _salt, _deployer, _foundation, _claimSupplier);
23+
TransparentUpgradeableProxy _tokenProxy = deployAlignedTokenProxy(
24+
_foundation,
25+
_salt,
26+
_deployer,
27+
_foundation,
28+
_claimSupplier
29+
);
2630

2731
console.log(
2832
string.concat(
@@ -31,7 +35,7 @@ contract DeployAlignedToken is Script {
3135
" with proxy admin: ",
3236
vm.toString(Utils.getAdminAddress(address(_tokenProxy))),
3337
" and owner: ",
34-
vm.toString(_safe)
38+
vm.toString(_foundation)
3539
)
3640
);
3741

@@ -53,7 +57,7 @@ contract DeployAlignedToken is Script {
5357
}
5458

5559
function deployAlignedTokenProxy(
56-
address _proxyAdmin,
60+
address _proxyAdminOwner,
5761
bytes32 _salt,
5862
address _deployer,
5963
address _foundation,
@@ -62,9 +66,18 @@ contract DeployAlignedToken is Script {
6266
vm.broadcast();
6367
AlignedToken _token = new AlignedToken();
6468

65-
bytes memory _alignedTokenDeploymentData =
66-
Utils.alignedTokenProxyDeploymentData(_proxyAdmin, address(_token), _foundation, _claim);
67-
address _alignedTokenProxy = Utils.deployWithCreate2(_alignedTokenDeploymentData, _salt, _deployer);
69+
bytes memory _alignedTokenDeploymentData = Utils
70+
.alignedTokenProxyDeploymentData(
71+
_proxyAdminOwner,
72+
address(_token),
73+
_foundation,
74+
_claim
75+
);
76+
address _alignedTokenProxy = Utils.deployWithCreate2(
77+
_alignedTokenDeploymentData,
78+
_salt,
79+
_deployer
80+
);
6881
return TransparentUpgradeableProxy(payable(_alignedTokenProxy));
6982
}
7083
}

claim_contracts/script/DeployAll.s.sol

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@ contract DeployAll is Script {
1919
);
2020
string memory config_json = vm.readFile(path);
2121

22-
address _safe = stdJson.readAddress(config_json, ".safe");
2322
bytes32 _salt = stdJson.readBytes32(config_json, ".salt");
2423
address _deployer = stdJson.readAddress(config_json, ".deployer");
2524
address _foundation = stdJson.readAddress(config_json, ".foundation");
25+
address _safe = _foundation;
2626
address _claim = stdJson.readAddress(config_json, ".claimSupplier");
27-
uint256 _claimPrivateKey = stdJson.readUint(
28-
config_json,
29-
".claimSupplierPrivateKey"
30-
);
27+
uint256 _claimPrivateKey = vm.envUint("CLAIM_SUPPLIER_PRIVATE_KEY");
3128
uint256 _limitTimestampToClaim = stdJson.readUint(
3229
config_json,
3330
".limitTimestampToClaim"
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
// import "../src/TestToken.sol";
5+
import "../src/ExampleAlignedTokenV2.sol";
6+
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
7+
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
8+
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
9+
import "forge-std/Script.sol";
10+
import {Vm} from "forge-std/Vm.sol";
11+
import {Utils} from "./Utils.sol";
12+
13+
/// @notice This script upgrades the ClaimableAirdrop contract to ClaimableAirdropV2.
14+
/// @dev The `ProxyAdmin` owner must be the runner of this script since it is the
15+
/// one that will call the upgradeAndCall function of the `ProxyAdmin`.
16+
contract UpgradeToAlignedTokenV2 is Script {
17+
function run(string memory config) public {
18+
string memory root = vm.projectRoot();
19+
string memory path = string.concat(
20+
root,
21+
"/script-config/config.",
22+
config,
23+
".json"
24+
);
25+
string memory config_json = vm.readFile(path);
26+
27+
address _currentTokenProxy = stdJson.readAddress(
28+
config_json,
29+
".tokenProxy"
30+
);
31+
32+
vm.broadcast();
33+
ExampleAlignedTokenV2 _newToken = new ExampleAlignedTokenV2();
34+
35+
bytes memory _tokenUpgradeData = abi.encodeCall(
36+
ProxyAdmin.upgradeAndCall,
37+
(
38+
ITransparentUpgradeableProxy(_currentTokenProxy),
39+
address(_newToken),
40+
abi.encodeCall(ExampleAlignedTokenV2.reinitialize, ())
41+
)
42+
);
43+
44+
console.log(
45+
"To finalize the upgrade, call",
46+
getAdminAddress(_currentTokenProxy),
47+
"with the following calldata"
48+
);
49+
console.logBytes(_tokenUpgradeData);
50+
}
51+
52+
function getAdminAddress(address proxy) internal view returns (address) {
53+
address CHEATCODE_ADDRESS = 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D;
54+
Vm vm = Vm(CHEATCODE_ADDRESS);
55+
56+
bytes32 adminSlot = vm.load(proxy, ERC1967Utils.ADMIN_SLOT);
57+
return address(uint160(uint256(adminSlot)));
58+
}
59+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
// import "../src/TestToken.sol";
5+
import "../src/ExampleAlignedTokenV3.sol";
6+
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
7+
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
8+
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
9+
import "forge-std/Script.sol";
10+
import {Vm} from "forge-std/Vm.sol";
11+
import {Utils} from "./Utils.sol";
12+
13+
/// @notice This script upgrades the ClaimableAirdrop contract to ClaimableAirdropV2.
14+
/// @dev The `ProxyAdmin` owner must be the runner of this script since it is the
15+
/// one that will call the upgradeAndCall function of the `ProxyAdmin`.
16+
contract UpgradeToAlignedTokenV3 is Script {
17+
function run(string memory config) public {
18+
string memory root = vm.projectRoot();
19+
string memory path = string.concat(
20+
root,
21+
"/script-config/config.",
22+
config,
23+
".json"
24+
);
25+
string memory config_json = vm.readFile(path);
26+
27+
address _currentTokenProxy = stdJson.readAddress(
28+
config_json,
29+
".tokenProxy"
30+
);
31+
32+
vm.broadcast();
33+
ExampleAlignedTokenV3 _newToken = new ExampleAlignedTokenV3();
34+
35+
bytes memory _tokenUpgradeData = abi.encodeCall(
36+
ProxyAdmin.upgradeAndCall,
37+
(
38+
ITransparentUpgradeableProxy(_currentTokenProxy),
39+
address(_newToken),
40+
abi.encodeCall(ExampleAlignedTokenV3.reinitialize, ())
41+
)
42+
);
43+
44+
console.log(
45+
"To finalize the upgrade, call",
46+
getAdminAddress(_currentTokenProxy),
47+
"with the following calldata"
48+
);
49+
console.logBytes(_tokenUpgradeData);
50+
}
51+
52+
function getAdminAddress(address proxy) internal view returns (address) {
53+
address CHEATCODE_ADDRESS = 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D;
54+
Vm vm = Vm(CHEATCODE_ADDRESS);
55+
56+
bytes32 adminSlot = vm.load(proxy, ERC1967Utils.ADMIN_SLOT);
57+
return address(uint160(uint256(adminSlot)));
58+
}
59+
}

claim_contracts/script/Utils.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ library Utils {
1414
address(uint160(uint256(keccak256("hevm cheat code"))));
1515
Vm internal constant vm = Vm(VM_ADDRESS);
1616

17-
function getAdminAddress(address proxy) internal view returns (address) {
17+
function getAdminAddress(address proxy) internal view returns (address) {
1818
bytes32 adminSlot = vm.load(proxy, ERC1967Utils.ADMIN_SLOT);
1919
return address(uint160(uint256(adminSlot)));
2020
}
@@ -88,7 +88,7 @@ library Utils {
8888
}
8989

9090
function alignedTokenProxyDeploymentData(
91-
address _proxyAdmin,
91+
address _proxyAdminOwner,
9292
address _implementation,
9393
address _foundation,
9494
address _claim
@@ -98,7 +98,7 @@ library Utils {
9898
type(TransparentUpgradeableProxy).creationCode,
9999
abi.encode(
100100
_implementation,
101-
_proxyAdmin,
101+
_proxyAdminOwner,
102102
alignedTokenInitData(_implementation, _foundation, _claim)
103103
)
104104
);
@@ -125,7 +125,7 @@ library Utils {
125125
}
126126

127127
function claimableAirdropProxyDeploymentData(
128-
address _proxyAdmin,
128+
address _proxyAdminOwner,
129129
address _implementation,
130130
address _owner,
131131
address _tokenContractAddress,
@@ -138,7 +138,7 @@ library Utils {
138138
type(TransparentUpgradeableProxy).creationCode,
139139
abi.encode(
140140
_implementation,
141-
_proxyAdmin,
141+
_proxyAdminOwner,
142142
claimableAirdropInitData(
143143
_implementation,
144144
_owner,

0 commit comments

Comments
 (0)