Skip to content

Commit a9df9bc

Browse files
ilitteriMegaRedHandjuanbono
authored
Claimable deploy script (#1655)
Co-authored-by: Tomás Grüner <[email protected]> Co-authored-by: juanbono <[email protected]>
1 parent 5768201 commit a9df9bc

File tree

9 files changed

+287
-328
lines changed

9 files changed

+287
-328
lines changed

claim_contracts/Makefile

Lines changed: 86 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,21 @@ help: ## 📚 Show help for each of the Makefile recipes
88

99
RPC_URL?=http://localhost:8545
1010
PRIVATE_KEY?=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
11-
12-
deploy-all: ## 🚀 Deploy all contracts
11+
CONFIG?=example
12+
deploy-token: ## 🚀 Deploy the token contract
1313
cd script && \
14-
forge script DeployAll.s.sol \
14+
forge script DeployAlignedToken.s.sol \
1515
--sig "run(string)" \
1616
$(CONFIG) \
1717
--private-key $(PRIVATE_KEY) \
1818
--rpc-url $(RPC_URL) \
1919
--broadcast \
20-
-vvv
20+
--verbosity 3
2121

22-
CONFIG?=example
23-
deploy-token: ## 🚀 Deploy the token contract
22+
deploy-token-testnet: ## 🚀 Deploy the token contract
2423
cd script && \
2524
forge script DeployAlignedToken.s.sol \
26-
--sig "run(string)" \
27-
$(CONFIG) \
25+
--sig "run(string)" sepolia
2826
--private-key $(PRIVATE_KEY) \
2927
--rpc-url $(RPC_URL) \
3028
--broadcast \
@@ -40,6 +38,34 @@ deploy-token-prod: ## 🚀 Deploy the token contract
4038
--broadcast \
4139
--verbosity 3
4240

41+
deploy-claimable-local: ## 🚀 Deploy the airdrop contract in localnet
42+
cd script && \
43+
forge script DeployClaimableAirdrop.s.sol \
44+
--sig "run(string)" example \
45+
--private-key $(PRIVATE_KEY) \
46+
--rpc-url http://localhost:8545 \
47+
--broadcast
48+
49+
deploy-claimable-testnet: ## 🚀 Deploy the airdrop contract in Sepolia
50+
cd script && \
51+
forge script DeployClaimableAirdrop.s.sol \
52+
--sig "run(string)" sepolia \
53+
--private-key $(PRIVATE_KEY) \
54+
--rpc-url $(RPC_URL) \
55+
--broadcast \
56+
--verify \
57+
--etherscan-api-key $(ETHERSCAN_API_KEY)
58+
59+
deploy-claimable-mainnet: ## 🚀 Deploy the airdrop contract in Mainnet
60+
cd script && \
61+
forge script DeployClaimableAirdrop.s.sol \
62+
--sig "run(string)" mainnet \
63+
--keystore $(KEYSTORE_PATH) \
64+
--rpc-url https://eth.llamarpc.com \
65+
--broadcast \
66+
--verify \
67+
--etherscan-api-key $(ETHERSCAN_API_KEY)
68+
4369

4470
update_token_proxy:
4571
@NEW_TOKEN_PROXY=$$(jq -r '.tokenProxy' "script-out/deployed_token_addresses.json") && \
@@ -56,6 +82,55 @@ upgrade-token: ## 🚀 Upgrade the token contract
5682
--broadcast \
5783
--verbosity 3
5884

85+
# Miscellaneous
86+
87+
DISTRIBUTOR_PRIVATE_KEY?=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
88+
89+
approve-claimable: ## 🚀 Approve the ClaimableAirdrop contract to spend the token
90+
cast send \
91+
--rpc-url $(RPC_URL) \
92+
--private-key $(DISTRIBUTOR_PRIVATE_KEY) \
93+
$(TOKEN) \
94+
'approve(address,uint256)' $(AIRDROP) 2600000000000000000000000000
95+
96+
claimable-update-root: ## 🚀 Update the merkle root of the ClaimableAirdrop contract
97+
cast send \
98+
--rpc-url $(RPC_URL) \
99+
--private-key $(PRIVATE_KEY) \
100+
$(AIRDROP) \
101+
'updateMerkleRoot(bytes32)' $(MERKLE_ROOT)
102+
103+
claimable-get-root: ## 🚀 Get the merkle root of the ClaimableAirdrop contract
104+
cast call \
105+
--rpc-url $(RPC_URL) \
106+
$(AIRDROP) \
107+
"claimMerkleRoot()(bytes32)"
108+
109+
claimable-update-timestamp: ## 🚀 Update the limit timestamp of the ClaimableAirdrop contract
110+
cast send \
111+
--rpc-url $(RPC_URL) \
112+
--private-key $(PRIVATE_KEY) \
113+
$(AIRDROP) \
114+
'extendClaimPeriod(uint256)' $(TIMESTAMP)
115+
116+
claimable-get-timestamp: ## 🚀 Get the limit timestamp of the ClaimableAirdrop contract
117+
cast call \
118+
--rpc-url $(RPC_URL) \
119+
$(AIRDROP) \
120+
"limitTimestampToClaim()(uint256)"
121+
122+
pause:
123+
cast send \
124+
--rpc-url $(RPC_URL) \
125+
--private-key $(PRIVATE_KEY) \
126+
$(AIRDROP) "pause()"
127+
128+
unpause:
129+
cast send \
130+
--rpc-url $(RPC_URL) \
131+
--private-key $(PRIVATE_KEY) \
132+
$(AIRDROP) "unpause()"
133+
59134
# Upgrades
60135

61136
upgrade-aligned-token-implementation: ## 🚀 Upgrade the AlignedToken implementation contract
@@ -86,8 +161,6 @@ test-claimed:
86161

87162
OWNER_PRIVATE_KEY?=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
88163

89-
test-pause:
90-
cast send $(AIRDROP) --private-key $(OWNER_PRIVATE_KEY) "pause()" --rpc-url $(RPC_URL)
91-
92-
test-unpause:
93-
cast send $(AIRDROP) --private-key $(OWNER_PRIVATE_KEY) "unpause()" --rpc-url $(RPC_URL)
164+
test-airdrop:
165+
cast call $(AIRDROP) "paused()(bool)" --rpc-url $(RPC_URL)
166+
cast call $(AIRDROP) "owner()(address)" --rpc-url $(RPC_URL)

claim_contracts/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
3+
## Local
4+
5+
### Requisites
6+
7+
- Foundry
8+
9+
### Run
10+
11+
1. Run anvil in one terminal:
12+
```
13+
anvil
14+
```
15+
2. Deploy the token
16+
```
17+
make deploy-token
18+
```
19+
3. Write down the token proxy address that is printed in the console output. Do this in the `config.example.json` file, under the `tokenProxy` key.
20+
4. Deploy the claimable contract
21+
```
22+
make deploy-claimable-local
23+
```
24+
5. Write down the claimable contract proxy address that is printed in the console output.
25+
6. Approve the claimable contract to spend the token from the distributor
26+
```
27+
make approve-claimable TOKEN=<token-proxy-address> AIRDROP=<claimable-proxy-address> PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
28+
```
29+
30+
## Testnet (Sepolia)
31+
32+
### Requisites
33+
34+
- Foundry
35+
- Etherscan API key
36+
37+
### Run
38+
39+
1. Create a file `script-config/config.sepolia.json` following the example in `script-config/config.sepolia.example.json`.
40+
2. Deploy the token
41+
```
42+
make deploy-token-testnet RPC_URL=<sepolia-rpc-url> PRIVATE_KEY=<sepolia-funded-account-private-key>
43+
```
44+
3. Write down the `token-proxy-address` that is printed in the console output. Do this in the `config.sepolia.json` file, under the `tokenProxy` key.
45+
4. Deploy the claimable contract
46+
```
47+
make deploy-claimable-testnet RPC_URL=<sepolia-rpc-url> PRIVATE_KEY=<sepolia-funded-account-private-key> ETHERSCAN_API_KEY=<etherscan-api-key>
48+
```
49+
5. Write down the `claimable-proxy-address` that is printed in the console output.
50+
6. Approve the claimable contract to spend the token from the distributor
51+
```
52+
make approve-claimable TOKEN=<token-proxy-address> AIRDROP=<claimable-proxy-address> PRIVATE_KEY=<sepolia-funded-distributor-private-key>
53+
```
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
2-
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
3-
"deployer": "0x4e59b44847b379578588920cA78FbF26c0B4956C",
42
"foundation": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
53
"tokenDistributor": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
6-
"limitTimestampToClaim": 2733427549,
7-
"claimMerkleRoot": "0x90076b5fb9a6c81d9fce83dfd51760987b8c49e7c861ea25b328e6e63d2cd3df",
84
"airdropProxy": "0x882b82f4E9014164Af87ecdAB64955cf7C252C4f",
9-
"tokenProxy": "0x82720a392C037B708370A1c2FCfd64d01e851e81"
5+
"tokenProxy": "0x2E983A1Ba5e8b38AAAeC4B440B9dDcFBf72E15d1"
106
}

claim_contracts/script-config/config.mainnet.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
"salt": "0xb254f45e54b7faa70154efcd4fc206f1ca27235419244dd07d64afdc4cc10b1e",
3-
"deployer": "0x4e59b44847b379578588920cA78FbF26c0B4956C",
42
"foundation": "",
53
"tokenDistributor": "",
64
"tokenProxy": "0x0000000000000000000000000000000000000000"

claim_contracts/script/DeployAlignedToken.s.sol

Lines changed: 21 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,30 @@ contract DeployAlignedToken is Script {
2020
);
2121
string memory config_json = vm.readFile(path);
2222

23-
bytes32 _salt = stdJson.readBytes32(config_json, ".salt");
24-
address _deployer = stdJson.readAddress(config_json, ".deployer");
2523
address _foundation = stdJson.readAddress(config_json, ".foundation");
2624
address _tokenDistributor = stdJson.readAddress(
2725
config_json,
2826
".tokenDistributor"
2927
);
3028

31-
TransparentUpgradeableProxy _tokenProxy = deployAlignedTokenProxy(
32-
_foundation,
33-
_salt,
34-
_deployer,
35-
_foundation,
36-
_tokenDistributor
37-
);
29+
vm.broadcast();
30+
AlignedToken _token = new AlignedToken();
31+
32+
console.log("Aligned Token deployed at address:", address(_token));
33+
34+
vm.broadcast();
35+
TransparentUpgradeableProxy _tokenProxy = new TransparentUpgradeableProxy(
36+
address(_token),
37+
_foundation,
38+
Utils.alignedTokenInitData(_foundation, _tokenDistributor)
39+
);
40+
41+
bytes memory _alignedTokenProxyConstructorData = Utils
42+
.alignedTokenProxyConstructorData(
43+
address(_token),
44+
_foundation,
45+
_tokenDistributor
46+
);
3847

3948
console.log(
4049
string.concat(
@@ -43,58 +52,10 @@ contract DeployAlignedToken is Script {
4352
" with proxy admin: ",
4453
vm.toString(Utils.getAdminAddress(address(_tokenProxy))),
4554
" and owner: ",
46-
vm.toString(_foundation)
55+
vm.toString(_foundation),
56+
" with constructor args: ",
57+
vm.toString(_alignedTokenProxyConstructorData)
4758
)
4859
);
49-
50-
string memory deployedAddressesJson = "deployedAddressesJson";
51-
string memory finalJson = vm.serializeAddress(
52-
deployedAddressesJson,
53-
"tokenProxy",
54-
address(_tokenProxy)
55-
);
56-
57-
vm.writeJson(
58-
finalJson,
59-
_getOutputPath("deployed_token_addresses.json")
60-
);
61-
}
62-
63-
function _getOutputPath(
64-
string memory fileName
65-
) internal returns (string memory) {
66-
string memory outputDir = "script-out/";
67-
68-
// Create output directory if it doesn't exist
69-
if (!vm.exists(outputDir)) {
70-
vm.createDir(outputDir, true);
71-
}
72-
73-
return string.concat(outputDir, fileName);
74-
}
75-
76-
function deployAlignedTokenProxy(
77-
address _proxyAdminOwner,
78-
bytes32 _salt,
79-
address _deployer,
80-
address _foundation,
81-
address _claim
82-
) internal returns (TransparentUpgradeableProxy) {
83-
vm.broadcast();
84-
AlignedToken _token = new AlignedToken();
85-
86-
bytes memory _alignedTokenDeploymentData = Utils
87-
.alignedTokenProxyDeploymentData(
88-
_proxyAdminOwner,
89-
address(_token),
90-
_foundation,
91-
_claim
92-
);
93-
address _alignedTokenProxy = Utils.deployWithCreate2(
94-
_alignedTokenDeploymentData,
95-
_salt,
96-
_deployer
97-
);
98-
return TransparentUpgradeableProxy(payable(_alignedTokenProxy));
9960
}
10061
}

0 commit comments

Comments
 (0)