Skip to content

Commit 9c83493

Browse files
author
ilitteri
committed
Add scripts for ClaimableAirdrop
1 parent f775156 commit 9c83493

7 files changed

+300
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
import "../../src/ClaimableAirdropV1.sol";
5+
import "../../src/ClaimableAirdropV2Example.sol";
6+
import "forge-std/Script.sol";
7+
import {Utils} from "../Utils.sol";
8+
9+
contract ClaimableAirdropCreate2 is Script {
10+
function run(uint256 _version, bytes32 _salt, address _deployer) public {
11+
address _create2Address;
12+
if (_version == 1) {
13+
_create2Address = vm.computeCreate2Address(
14+
_salt,
15+
keccak256(type(ClaimableAirdropV1).creationCode),
16+
_deployer
17+
);
18+
} else if (_version == 2) {
19+
_create2Address = vm.computeCreate2Address(
20+
_salt,
21+
keccak256(type(ClaimableAirdropV2Example).creationCode),
22+
_deployer
23+
);
24+
} else {
25+
revert("Unsupported version");
26+
}
27+
28+
console.logAddress(_create2Address);
29+
30+
vm.writeFile(
31+
string.concat(
32+
vm.projectRoot(),
33+
"/script-out/claimable_airdrop_v",
34+
vm.toString(_version),
35+
"_create2_address.hex"
36+
),
37+
vm.toString(_create2Address)
38+
);
39+
}
40+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
import "forge-std/Script.sol";
5+
import {Utils} from "../Utils.sol";
6+
7+
contract AlignedTokenInitData is Script {
8+
function run(
9+
address _implementation,
10+
uint256 _version,
11+
address _safe,
12+
address _tokenContractAddress,
13+
address _tokenOwnerAddress,
14+
uint256 _limitTimestampToClaim,
15+
bytes32 _claimMerkleRoot
16+
) public {
17+
bytes memory data = Utils.claimableAirdropInitData(
18+
_implementation,
19+
_version,
20+
_safe,
21+
_tokenContractAddress,
22+
_tokenOwnerAddress,
23+
_limitTimestampToClaim,
24+
_claimMerkleRoot
25+
);
26+
27+
console.logBytes(data);
28+
29+
vm.writeFile(
30+
string.concat(
31+
vm.projectRoot(),
32+
"/script-out/claimable_airdrop_init_data.hex"
33+
),
34+
vm.toString(data)
35+
);
36+
}
37+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
5+
import "forge-std/Script.sol";
6+
import {Utils} from "../Utils.sol";
7+
8+
contract ClaimableAirdropnProxyCreate2 is Script {
9+
function run(
10+
bytes32 _salt,
11+
address _deployer,
12+
address _implementation,
13+
uint256 _version,
14+
address _safe,
15+
address _tokenContractAddress,
16+
address _tokenOwnerAddress,
17+
uint256 _limitTimestampToClaim,
18+
bytes32 _claimMerkleRoot
19+
) public {
20+
address _create2Address = vm.computeCreate2Address(
21+
_salt,
22+
keccak256(
23+
Utils.claimableAirdropProxyDeploymentData(
24+
_implementation,
25+
_version,
26+
_safe,
27+
_tokenContractAddress,
28+
_tokenOwnerAddress,
29+
_limitTimestampToClaim,
30+
_claimMerkleRoot
31+
)
32+
),
33+
_deployer
34+
);
35+
console.logAddress(_create2Address);
36+
vm.writeFile(
37+
string.concat(
38+
vm.projectRoot(),
39+
"/script-out/claimable_airdrop_proxy_create2_address.hex"
40+
),
41+
vm.toString(_create2Address)
42+
);
43+
}
44+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
import "forge-std/Script.sol";
5+
import {Utils} from "../Utils.sol";
6+
7+
contract AlignedTokenProxyDeploymentData is Script {
8+
function run(
9+
address _implementation,
10+
uint256 _version,
11+
address _safe,
12+
address _tokenContractAddress,
13+
address _tokenOwnerAddress,
14+
uint256 _limitTimestampToClaim,
15+
bytes32 _claimMerkleRoot
16+
) public {
17+
bytes memory data = Utils.claimableAirdropProxyDeploymentData(
18+
_implementation,
19+
_version,
20+
_safe,
21+
_tokenContractAddress,
22+
_tokenOwnerAddress,
23+
_limitTimestampToClaim,
24+
_claimMerkleRoot
25+
);
26+
console.logBytes(data);
27+
vm.writeFile(
28+
string.concat(
29+
vm.projectRoot(),
30+
"/script-out/claimable_airdrop_proxy_deployment_data.hex"
31+
),
32+
vm.toString(data)
33+
);
34+
}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
import "forge-std/Script.sol";
5+
import {Utils} from "../Utils.sol";
6+
7+
contract AlignedTokenUpgradeData is Script {
8+
function run(
9+
address _newImplementation,
10+
uint256 _version,
11+
address _safe,
12+
address _beneficiary1,
13+
address _beneficiary2,
14+
address _beneficiary3,
15+
uint256 _mintAmount
16+
) public {
17+
bytes memory _upgradeData = Utils.alignedTokenUpgradeData(
18+
_newImplementation,
19+
_version,
20+
_safe,
21+
_beneficiary1,
22+
_beneficiary2,
23+
_beneficiary3,
24+
_mintAmount
25+
);
26+
console.logBytes(_upgradeData);
27+
vm.writeFile(
28+
string.concat(
29+
vm.projectRoot(),
30+
"/script-out/aligned_token_upgrade_data.hex"
31+
),
32+
vm.toString(_upgradeData)
33+
);
34+
}
35+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
import "../../src/ClaimableAirdropV1.sol";
5+
import "../../src/ClaimableAirdropV2Example.sol";
6+
import "forge-std/Script.sol";
7+
import {Utils} from "../Utils.sol";
8+
9+
contract DeployTokenImplementation is Script {
10+
function run(uint256 _version) public {
11+
address _implementation_address = Utils
12+
.deployClaimableAirdropImplementation(_version);
13+
14+
console.log(
15+
string.concat(
16+
"Claimable Airdrop Implementation v",
17+
vm.toString(_version),
18+
"Address:"
19+
),
20+
_implementation_address
21+
);
22+
23+
vm.serializeAddress(
24+
"implementation",
25+
"address",
26+
_implementation_address
27+
);
28+
29+
string memory out;
30+
if (_version == 1) {
31+
out = vm.serializeBytes(
32+
"implementation",
33+
"deploymentData",
34+
type(ClaimableAirdropV1).creationCode
35+
);
36+
} else if (_version == 2) {
37+
out = vm.serializeBytes(
38+
"implementation",
39+
"deploymentData",
40+
type(ClaimableAirdropV2Example).creationCode
41+
);
42+
} else {
43+
revert("Unsupported version");
44+
}
45+
46+
string memory path = string.concat(
47+
vm.projectRoot(),
48+
"/script-out/claimable_airdrop_implementation_v",
49+
vm.toString(_version),
50+
".json"
51+
);
52+
53+
vm.writeJson(out, path);
54+
}
55+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
5+
import "forge-std/Script.sol";
6+
import {Utils} from "../Utils.sol";
7+
8+
contract DeployAlignedTokenProxy is Script {
9+
function run(
10+
address _implementation,
11+
uint256 _version,
12+
address _safe,
13+
address _tokenContractAddress,
14+
address _tokenOwnerAddress,
15+
uint256 _limitTimestampToClaim,
16+
bytes32 _claimMerkleRoot
17+
) public {
18+
bytes memory _proxyDeploymentData = Utils.claimableAirdropInitData(
19+
_implementation,
20+
_version,
21+
_safe,
22+
_tokenContractAddress,
23+
_tokenOwnerAddress,
24+
_limitTimestampToClaim,
25+
_claimMerkleRoot
26+
);
27+
vm.broadcast();
28+
ERC1967Proxy _proxy = new ERC1967Proxy(
29+
_implementation,
30+
_proxyDeploymentData
31+
);
32+
console.log("Claimable Airdrop Proxy Address:", address(_proxy));
33+
34+
vm.serializeAddress("proxy", "address", address(_proxy));
35+
string memory _out = vm.serializeBytes(
36+
"proxy",
37+
"deploymentData",
38+
Utils.claimableAirdropProxyDeploymentData(
39+
_implementation,
40+
_version,
41+
_safe,
42+
_tokenContractAddress,
43+
_tokenOwnerAddress,
44+
_limitTimestampToClaim,
45+
_claimMerkleRoot
46+
)
47+
);
48+
string memory _path = string.concat(
49+
vm.projectRoot(),
50+
"/script-out/claimable_airdrop_proxy.json"
51+
);
52+
vm.writeJson(_out, _path);
53+
}
54+
}

0 commit comments

Comments
 (0)