Skip to content

Commit 04aef1b

Browse files
authored
feat: simplify airdrop initialization (#1656)
2 parents 242d512 + 9e53aef commit 04aef1b

File tree

6 files changed

+62
-68
lines changed

6 files changed

+62
-68
lines changed

claim_contracts/Makefile

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,55 @@ upgrade-token: ## 🚀 Upgrade the token contract
8282
--broadcast \
8383
--verbosity 3
8484

85-
# Approve
85+
# Miscellaneous
8686

87-
approve-claimable: ## 🚀 Approve the claimable airdrop contract to spend the token
87+
DISTRIBUTOR_PRIVATE_KEY?=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
88+
89+
approve-claimable: ## 🚀 Approve the ClaimableAirdrop contract to spend the token
8890
cast send \
8991
--rpc-url $(RPC_URL) \
90-
--private-key $(PRIVATE_KEY) \
92+
--private-key $(DISTRIBUTOR_PRIVATE_KEY) \
9193
$(TOKEN) \
9294
'approve(address,uint256)' $(AIRDROP) 2600000000000000000000000000
9395

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+
94134
# Upgrades
95135

96136
upgrade-aligned-token-implementation: ## 🚀 Upgrade the AlignedToken implementation contract
@@ -124,9 +164,3 @@ OWNER_PRIVATE_KEY?=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f
124164
test-airdrop:
125165
cast call $(AIRDROP) "paused()(bool)" --rpc-url $(RPC_URL)
126166
cast call $(AIRDROP) "owner()(address)" --rpc-url $(RPC_URL)
127-
128-
test-pause:
129-
cast send $(AIRDROP) --private-key $(OWNER_PRIVATE_KEY) "pause()" --rpc-url $(RPC_URL)
130-
131-
test-unpause:
132-
cast send $(AIRDROP) --private-key $(OWNER_PRIVATE_KEY) "unpause()" --rpc-url $(RPC_URL)
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
22
"foundation": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
33
"tokenDistributor": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
4-
"limitTimestampToClaim": 2733427549,
5-
"claimMerkleRoot": "0x90076b5fb9a6c81d9fce83dfd51760987b8c49e7c861ea25b328e6e63d2cd3df",
64
"airdropProxy": "0x882b82f4E9014164Af87ecdAB64955cf7C252C4f",
75
"tokenProxy": "0x2E983A1Ba5e8b38AAAeC4B440B9dDcFBf72E15d1"
86
}
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"foundation": "",
33
"tokenDistributor": "",
4-
5-
"limitTimestampToClaim": 2733427549,
6-
"claimMerkleRoot": "",
74
"tokenProxy": "0x0000000000000000000000000000000000000000"
85
}

claim_contracts/script/DeployClaimableAirdrop.s.sol

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ contract DeployAlignedToken is Script {
2525
".tokenDistributor"
2626
);
2727
address _tokenProxy = stdJson.readAddress(config_json, ".tokenProxy");
28-
uint256 _limitTimestampToClaim = stdJson.readUint(
29-
config_json,
30-
".limitTimestampToClaim"
31-
);
32-
bytes32 _claimMerkleRoot = stdJson.readBytes32(
33-
config_json,
34-
".claimMerkleRoot"
35-
);
3628

3729
vm.broadcast();
3830
ClaimableAirdrop _airdrop = new ClaimableAirdrop();
@@ -50,9 +42,7 @@ contract DeployAlignedToken is Script {
5042
address(_airdrop),
5143
_foundation,
5244
_tokenProxy,
53-
_tokenDistributor,
54-
_limitTimestampToClaim,
55-
_claimMerkleRoot
45+
_tokenDistributor
5646
)
5747
);
5848

@@ -61,9 +51,7 @@ contract DeployAlignedToken is Script {
6151
address(_airdrop),
6252
_foundation,
6353
_tokenProxy,
64-
_tokenDistributor,
65-
_limitTimestampToClaim,
66-
_claimMerkleRoot
54+
_tokenDistributor
6755
);
6856

6957
console.log(

claim_contracts/script/Utils.sol

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,7 @@ library Utils {
140140
address _implementation,
141141
address _owner,
142142
address _tokenContractAddress,
143-
address _tokenOwnerAddress,
144-
uint256 _limitTimestampToClaim,
145-
bytes32 _claimMerkleRoot
143+
address _tokenOwnerAddress
146144
) internal pure returns (bytes memory) {
147145
return
148146
abi.encodePacked(
@@ -154,9 +152,7 @@ library Utils {
154152
_implementation,
155153
_owner,
156154
_tokenContractAddress,
157-
_tokenOwnerAddress,
158-
_limitTimestampToClaim,
159-
_claimMerkleRoot
155+
_tokenOwnerAddress
160156
)
161157
)
162158
);
@@ -166,19 +162,15 @@ library Utils {
166162
address _implementation,
167163
address _foundation,
168164
address _tokenContractAddress,
169-
address _tokenOwnerAddress,
170-
uint256 _limitTimestampToClaim,
171-
bytes32 _claimMerkleRoot
165+
address _tokenOwnerAddress
172166
) internal pure returns (bytes memory) {
173167
return
174168
abi.encodeCall(
175169
ClaimableAirdrop(_implementation).initialize,
176170
(
177171
_foundation,
178172
_tokenContractAddress,
179-
_tokenOwnerAddress,
180-
_limitTimestampToClaim,
181-
_claimMerkleRoot
173+
_tokenOwnerAddress
182174
)
183175
);
184176
}
@@ -187,9 +179,7 @@ library Utils {
187179
address _implementation,
188180
address _foundation,
189181
address _tokenProxy,
190-
address _tokenDistributor,
191-
uint256 _limitTimestampToClaim,
192-
bytes32 _claimMerkleRoot
182+
address _tokenDistributor
193183
) internal pure returns (bytes memory) {
194184
return
195185
abi.encode(
@@ -199,9 +189,7 @@ library Utils {
199189
_implementation,
200190
_foundation,
201191
_tokenProxy,
202-
_tokenDistributor,
203-
_limitTimestampToClaim,
204-
_claimMerkleRoot
192+
_tokenDistributor
205193
)
206194
);
207195
}

claim_contracts/src/ClaimableAirdrop.sol

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,39 +54,28 @@ contract ClaimableAirdrop is
5454

5555
/// @notice Initializes the contract.
5656
/// @dev This initializer should be called only once.
57-
/// @param _owner address of the owner of the token.
57+
/// @param _foundation address of the Aligned foundation.
5858
/// @param _tokenProxy address of the token contract.
5959
/// @param _tokenDistributor address of the wallet that has the tokens to distribute to the claimants.
60-
/// @param _limitTimestampToClaim timestamp until which the claimants can claim the tokens.
61-
/// @param _claimMerkleRoot Merkle root of the claimants.
6260
function initialize(
63-
address _owner,
61+
address _foundation,
6462
address _tokenProxy,
65-
address _tokenDistributor,
66-
uint256 _limitTimestampToClaim,
67-
bytes32 _claimMerkleRoot
63+
address _tokenDistributor
6864
) external initializer {
69-
require(_owner != address(0), "Invalid owner address");
70-
require(
71-
_tokenProxy != address(0) && _tokenProxy != address(this),
72-
"Invalid token contract address"
73-
);
74-
require(
75-
_tokenDistributor != address(0) &&
76-
_tokenDistributor != address(this),
77-
"Invalid token owner address"
78-
);
79-
require(_limitTimestampToClaim > block.timestamp, "Invalid timestamp");
80-
require(_claimMerkleRoot != 0, "Invalid Merkle root");
65+
require(_foundation != address(0), "Invalid foundation address");
66+
require(_tokenProxy != address(0), "Invalid token contract address");
67+
require(_tokenDistributor != address(0), "Invalid token owner address");
8168

82-
__Ownable_init(_owner);
69+
__Ownable_init(_foundation);
8370
__Pausable_init();
8471
__ReentrancyGuard_init();
8572

8673
tokenProxy = _tokenProxy;
8774
tokenDistributor = _tokenDistributor;
88-
limitTimestampToClaim = _limitTimestampToClaim;
89-
claimMerkleRoot = _claimMerkleRoot;
75+
limitTimestampToClaim = 0;
76+
claimMerkleRoot = 0;
77+
78+
_pause();
9079
}
9180

9281
/// @notice Claim the tokens.

0 commit comments

Comments
 (0)