Skip to content

Commit b6d26a8

Browse files
author
ilitteri
committed
Rename contracts
1 parent a105b0e commit b6d26a8

File tree

9 files changed

+51
-30
lines changed

9 files changed

+51
-30
lines changed

claim_contracts/script/DeployAll.s.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.19;
33

4-
import "../src/AlignedTokenV1.sol";
5-
import "../src/ClaimableAirdropV1.sol";
4+
import "../src/AlignedToken.sol";
5+
import "../src/ClaimableAirdrop.sol";
66
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
77
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
88
import "forge-std/Script.sol";
@@ -113,7 +113,7 @@ contract DeployAll is Script {
113113
uint256 _mintAmount
114114
) internal returns (TransparentUpgradeableProxy) {
115115
vm.broadcast();
116-
AlignedTokenV1 _token = new AlignedTokenV1();
116+
AlignedToken _token = new AlignedToken();
117117

118118
bytes memory _alignedTokenDeploymentData = Utils
119119
.alignedTokenProxyDeploymentData(
@@ -157,7 +157,7 @@ contract DeployAll is Script {
157157
bytes32 _claimMerkleRoot
158158
) internal returns (TransparentUpgradeableProxy) {
159159
vm.broadcast();
160-
ClaimableAirdropV1 _airdrop = new ClaimableAirdropV1();
160+
ClaimableAirdrop _airdrop = new ClaimableAirdrop();
161161

162162
bytes memory _airdropDeploymentData = Utils
163163
.claimableAirdropProxyDeploymentData(
@@ -176,7 +176,7 @@ contract DeployAll is Script {
176176
);
177177

178178
console.log(
179-
"ClaimableAirdropV1 proxy deployed with address:",
179+
"ClaimableAirdrop proxy deployed with address:",
180180
_airdropProxy,
181181
"and admin:",
182182
_proxyAdmin

claim_contracts/script/Utils.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {Vm} from "forge-std/Vm.sol";
55
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
66
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
77
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
8-
import "../src/AlignedTokenV1.sol";
9-
import "../src/ClaimableAirdropV1.sol";
8+
import "../src/AlignedToken.sol";
9+
import "../src/ClaimableAirdrop.sol";
1010

1111
library Utils {
1212
// Cheatcodes address, 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D.
@@ -78,7 +78,7 @@ library Utils {
7878

7979
function deployAlignedTokenImplementation() internal returns (address) {
8080
vm.broadcast();
81-
AlignedTokenV1 _implementation = new AlignedTokenV1();
81+
AlignedToken _implementation = new AlignedToken();
8282
return address(_implementation);
8383
}
8484

@@ -116,7 +116,7 @@ library Utils {
116116
) internal pure returns (bytes memory) {
117117
return
118118
abi.encodeCall(
119-
AlignedTokenV1(_implementation).initialize,
119+
AlignedToken(_implementation).initialize,
120120
(
121121
_beneficiary1,
122122
_mintAmount,
@@ -158,7 +158,7 @@ library Utils {
158158

159159
function deployClaimableAirdropImplementation() internal returns (address) {
160160
vm.broadcast();
161-
ClaimableAirdropV1 _implementation = new ClaimableAirdropV1();
161+
ClaimableAirdrop _implementation = new ClaimableAirdrop();
162162
return address(_implementation);
163163
}
164164

@@ -199,7 +199,7 @@ library Utils {
199199
) internal pure returns (bytes memory) {
200200
return
201201
abi.encodeCall(
202-
ClaimableAirdropV1(_implementation).initialize,
202+
ClaimableAirdrop(_implementation).initialize,
203203
(
204204
_owner,
205205
_tokenContractAddress,

claim_contracts/script/aligned_token/AlignedTokenCreate2.s.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.19;
33

4-
import "../../src/AlignedTokenV1.sol";
4+
import "../../src/AlignedToken.sol";
55
import "forge-std/Script.sol";
66
import {Utils} from "../Utils.sol";
77

88
contract AlignedTokenCreate2 is Script {
99
function run(bytes32 _salt, address _deployer) public {
1010
address _create2Address = vm.computeCreate2Address(
1111
_salt,
12-
keccak256(type(AlignedTokenV1).creationCode),
12+
keccak256(type(AlignedToken).creationCode),
1313
_deployer
1414
);
1515
console.logAddress(_create2Address);

claim_contracts/script/aligned_token/DeployAlignedTokenImplementation.s.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.19;
33

4-
import "../../src/AlignedTokenV1.sol";
4+
import "../../src/AlignedToken.sol";
55
import "forge-std/Script.sol";
66
import {Utils} from "../Utils.sol";
77

@@ -21,7 +21,7 @@ contract DeployTokenImplementation is Script {
2121
string memory _out = vm.serializeBytes(
2222
"implementation",
2323
"deploymentData",
24-
type(AlignedTokenV1).creationCode
24+
type(AlignedToken).creationCode
2525
);
2626

2727
string memory _path = string.concat(

claim_contracts/script/aligned_token/UpgradeAlignedTokenImplementation.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.19;
33

4-
import "../../src/AlignedTokenV1.sol";
4+
import "../../src/AlignedToken.sol";
55
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
66
import "forge-std/Script.sol";
77
import {Utils} from "../Utils.sol";

claim_contracts/script/claimable_airdrop/ClaimableAirdropCreate2.s.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.19;
33

4-
import "../../src/ClaimableAirdropV1.sol";
4+
import "../../src/ClaimableAirdrop.sol";
55
import "forge-std/Script.sol";
66
import {Utils} from "../Utils.sol";
77

88
contract ClaimableAirdropCreate2 is Script {
99
function run(bytes32 _salt, address _deployer) public {
1010
address _create2Address = vm.computeCreate2Address(
1111
_salt,
12-
keccak256(type(ClaimableAirdropV1).creationCode),
12+
keccak256(type(ClaimableAirdrop).creationCode),
1313
_deployer
1414
);
1515

claim_contracts/script/claimable_airdrop/DeployClaimableAirdropImplementation.s.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.19;
33

4-
import "../../src/ClaimableAirdropV1.sol";
4+
import "../../src/ClaimableAirdrop.sol";
55
import "forge-std/Script.sol";
66
import {Utils} from "../Utils.sol";
77

@@ -24,7 +24,7 @@ contract DeployTokenImplementation is Script {
2424
string memory _out = vm.serializeBytes(
2525
"implementation",
2626
"deploymentData",
27-
type(ClaimableAirdropV1).creationCode
27+
type(ClaimableAirdrop).creationCode
2828
);
2929

3030
string memory _path = string.concat(
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ pragma solidity ^0.8.19;
33

44
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
55
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
6-
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
76

8-
contract AlignedTokenV1 is Initializable, ERC20Upgradeable, ReentrancyGuard {
7+
contract AlignedToken is Initializable, ERC20Upgradeable {
98
/// @custom:oz-upgrades-unsafe-allow constructor
109
constructor() {
1110
_disableInitializers();
@@ -18,8 +17,8 @@ contract AlignedTokenV1 is Initializable, ERC20Upgradeable, ReentrancyGuard {
1817
uint256 _beneficiary2Part,
1918
address _beneficiary3,
2019
uint256 _beneficiary3Part
21-
) public initializer nonReentrant {
22-
__ERC20_init("AlignedTokenV1", "ALI");
20+
) public initializer {
21+
__ERC20_init("AlignedToken", "ALI");
2322
_mint(_beneficiary1, _beneficiary1Part);
2423
_mint(_beneficiary2, _beneficiary2Part);
2524
_mint(_beneficiary3, _beneficiary3Part);

claim_contracts/src/ClaimableAirdropV1.sol renamed to claim_contracts/src/ClaimableAirdrop.sol

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
88
import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
99
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
1010

11-
contract ClaimableAirdropV1 is
11+
contract ClaimableAirdrop is
1212
ReentrancyGuard,
1313
Initializable,
1414
PausableUpgradeable,
@@ -29,13 +29,27 @@ contract ClaimableAirdropV1 is
2929
}
3030

3131
function initialize(
32-
address _initialOwner,
32+
address _multisig,
3333
address _tokenContractAddress,
3434
address _tokenOwnerAddress,
3535
uint256 _limitTimestampToClaim,
3636
bytes32 _claimMerkleRoot
37-
) public initializer nonReentrant {
38-
__Ownable_init(_initialOwner);
37+
) public initializer {
38+
__Ownable_init(_multisig);
39+
__Pausable_init();
40+
41+
require(_multisig != address(0), "Invalid multisig address");
42+
require(
43+
_tokenContractAddress != address(0),
44+
"Invalid token contract address"
45+
);
46+
require(
47+
_tokenOwnerAddress != address(0),
48+
"Invalid token owner address"
49+
);
50+
require(_limitTimestampToClaim > block.timestamp, "Invalid timestamp");
51+
require(_claimMerkleRoot != 0, "Invalid Merkle root");
52+
3953
tokenContractAddress = _tokenContractAddress;
4054
tokenOwnerAddress = _tokenOwnerAddress;
4155
limitTimestampToClaim = _limitTimestampToClaim;
@@ -45,7 +59,7 @@ contract ClaimableAirdropV1 is
4559
function claim(
4660
uint256 amount,
4761
bytes32[] calldata merkleProof
48-
) public nonReentrant {
62+
) public nonReentrant whenNotPaused {
4963
require(
5064
!hasClaimed[msg.sender],
5165
"Account has already claimed the drop"
@@ -62,7 +76,13 @@ contract ClaimableAirdropV1 is
6276

6377
require(verifies, "Invalid Merkle proof");
6478

65-
hasClaimed[msg.sender] = true;
79+
require(
80+
IERC20(tokenContractAddress).allowance(
81+
tokenOwnerAddress,
82+
address(this)
83+
) >= amount,
84+
"Insufficient token allowance"
85+
);
6686

6787
bool success = IERC20(tokenContractAddress).transferFrom(
6888
tokenOwnerAddress,
@@ -72,6 +92,8 @@ contract ClaimableAirdropV1 is
7292

7393
require(success, "Failed to transfer funds");
7494

95+
hasClaimed[msg.sender] = true;
96+
7597
emit TokenClaimed(msg.sender, amount);
7698
}
7799

0 commit comments

Comments
 (0)