Skip to content

Commit 34c6709

Browse files
committed
refactor: forge build warnings
1 parent b0c666d commit 34c6709

9 files changed

Lines changed: 116 additions & 96 deletions

File tree

script/DeployAll.s.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Script, console} from "forge-std/Script.sol";
66
import {MetaTokenDistributor} from "src/tokenDistribution/MetaTokenDistributor.sol";
77
import {Vesting} from "src/tokenDistribution/vesting/Vesting.sol";
88
import {VestingParams} from "src/tokenDistribution/vesting/VestingParams.sol";
9-
import {Beneficiary, VestingType} from "src/tokenDistribution/utils/Common.sol";
9+
import {Beneficiary} from "src/tokenDistribution/utils/Common.sol";
1010

1111
/**
1212
* @title First deploy
@@ -45,7 +45,7 @@ contract DeployAllScript is Script {
4545
vm.stopBroadcast();
4646

4747
console.log("------------------ Deployed contracts --------------------");
48-
console.log("MetaLamp token: ", address(distributor.getMETAAddress()));
48+
console.log("MetaLamp token: ", address(distributor.getMetaAddress()));
4949
console.log("VestingParams address", address(vestingParams));
5050
console.log("MetaToken distributor: ", address(distributor));
5151

src/MetaToken.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {ERC20} from "solmate/tokens/ERC20.sol";
1212
contract MetaToken is ERC20 {
1313
uint256 private constant _INITIAL_TOTAL_SUPPLY = 1_000_000_000e18;
1414

15-
constructor(address distributor) ERC20("Metalamp token", "META", 18) {
15+
constructor(address distributor) ERC20("Metalamp token", "meta", 18) {
1616
_mint(distributor, _INITIAL_TOTAL_SUPPLY);
1717
}
1818
}

src/tokenDistribution/MetaTokenDistributor.sol

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ contract MetaTokenDistributor is IMetaTokenDistributor {
2525
address private _vestingImpl;
2626

2727
/// @notice MetaLamp token for distribution
28-
IERC20 private _META;
28+
IERC20 private _meta;
2929

3030
/// @notice A smart contract that stores vesting parameters (allocation, schedule, etc.)
3131
IVestingParams private _vestingParams;
@@ -35,11 +35,7 @@ contract MetaTokenDistributor is IMetaTokenDistributor {
3535

3636
/// @dev Validate start vesting time
3737
modifier validateTime() {
38-
uint64 startTime = _vestingParams.getStartTime();
39-
40-
if (block.timestamp < startTime) {
41-
revert VestingStartTimeHasNotArrived();
42-
}
38+
_validateTime();
4339

4440
_;
4541
}
@@ -52,11 +48,11 @@ contract MetaTokenDistributor is IMetaTokenDistributor {
5248
_vestingParams = IVestingParams(vestingParams);
5349

5450
_vestingImpl = vestingImpl;
55-
_META = IERC20(address(new MetaToken(address(this))));
51+
_meta = IERC20(address(new MetaToken(address(this))));
5652

57-
assert(_META.balanceOf(address(this)) == _META.totalSupply());
53+
assert(_meta.balanceOf(address(this)) == _meta.totalSupply());
5854

59-
emit MetaTokenDeployed(address(_META));
55+
emit MetaTokenDeployed(address(_meta));
6056
}
6157

6258
/**
@@ -75,17 +71,17 @@ contract MetaTokenDistributor is IMetaTokenDistributor {
7571

7672
vesting = Clones.clone(_vestingImpl);
7773

78-
_META.safeTransfer(vesting, vestingTotalAmount);
79-
IVesting(vesting).initialize(_META, schedule, beneficiaries);
74+
_meta.safeTransfer(vesting, vestingTotalAmount);
75+
IVesting(vesting).initialize(_meta, schedule, beneficiaries);
8076

8177
_vestingAddresses[vestingType] = vesting;
8278

8379
emit VestingStarted(vesting);
8480
}
8581

8682
/// @notice Returns address of MetaLamp token
87-
function getMETAAddress() external view returns (address) {
88-
return address(_META);
83+
function getMetaAddress() external view returns (address) {
84+
return address(_meta);
8985
}
9086

9187
/**
@@ -105,4 +101,12 @@ contract MetaTokenDistributor is IMetaTokenDistributor {
105101
function getVestingImplAddress() external view returns (address) {
106102
return _vestingImpl;
107103
}
104+
105+
function _validateTime() private view {
106+
uint64 startTime = _vestingParams.getStartTime();
107+
108+
if (block.timestamp < startTime) {
109+
revert VestingStartTimeHasNotArrived();
110+
}
111+
}
108112
}

src/tokenDistribution/interfaces/IMetaTokenDistributor.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface IMetaTokenDistributor {
88
event VestingStarted(address vesting);
99

1010
/// @notice Emit when MetaLamp token deployed
11-
event MetaTokenDeployed(address META);
11+
event MetaTokenDeployed(address meta);
1212

1313
/// @notice Revert when trying to start vesting at an earlier start time
1414
error VestingStartTimeHasNotArrived();
@@ -20,7 +20,7 @@ interface IMetaTokenDistributor {
2020
error VestingHasAlreadyStarted();
2121

2222
function startVesting(VestingType vestingType) external returns (address vesting);
23-
function getMETAAddress() external view returns (address);
23+
function getMetaAddress() external view returns (address);
2424
function getVestingAddress(VestingType vestingType) external view returns (address);
2525
function getVestingParamsAddress() external view returns (address);
2626
function getVestingImplAddress() external view returns (address);

test/MetaToken.t.sol

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity 0.8.28;
33

4-
import {Test, console} from "forge-std/Test.sol";
4+
import {Test} from "forge-std/Test.sol";
55
import {MetaToken} from "src/MetaToken.sol";
66

77
contract MetaTokenTest is Test {
8-
MetaToken public META;
8+
MetaToken public meta;
99

1010
address distributor;
1111

1212
function setUp() public {
1313
distributor = makeAddr("distributor");
1414

15-
META = new MetaToken(distributor);
15+
meta = new MetaToken(distributor);
1616
}
1717

1818
function test_deploy() public view {
1919
string memory expectedName = "Metalamp token";
20-
string memory expectedSymbol = "META";
20+
string memory expectedSymbol = "meta";
2121
uint256 expectedDecimals = 18;
2222
uint256 expectedTotalSupply = 1_000_000_000e18;
2323

24-
assertEq(META.name(), expectedName);
25-
assertEq(META.symbol(), expectedSymbol);
26-
assertEq(META.decimals(), expectedDecimals);
27-
assertEq(META.totalSupply(), expectedTotalSupply);
24+
assertEq(meta.name(), expectedName);
25+
assertEq(meta.symbol(), expectedSymbol);
26+
assertEq(meta.decimals(), expectedDecimals);
27+
assertEq(meta.totalSupply(), expectedTotalSupply);
2828

29-
assertEq(META.balanceOf(distributor), expectedTotalSupply);
29+
assertEq(meta.balanceOf(distributor), expectedTotalSupply);
3030
}
3131

3232
function test_transfer() external {
3333
address recipient = makeAddr("recipient");
34-
uint256 totalSupply = META.totalSupply();
34+
uint256 totalSupply = meta.totalSupply();
3535

3636
vm.prank(distributor);
37-
META.transfer(recipient, totalSupply);
37+
bool isSuccess = meta.transfer(recipient, totalSupply);
38+
assertTrue(isSuccess);
3839

39-
assertEq(META.balanceOf(recipient), META.totalSupply());
40-
assertEq(META.balanceOf(distributor), 0);
40+
assertEq(meta.balanceOf(recipient), meta.totalSupply());
41+
assertEq(meta.balanceOf(distributor), 0);
4142
}
4243
}

test/tokenDistribution/MetaTokenDistributor.t.sol

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity 0.8.28;
33

4-
import {Test, console} from "forge-std/Test.sol";
4+
import {Test} from "forge-std/Test.sol";
55
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
66

77
import {MetaTokenDistributor, IMetaTokenDistributor} from "src/tokenDistribution/MetaTokenDistributor.sol";
88
import {Vesting} from "src/tokenDistribution/vesting/Vesting.sol";
99
import {VestingParams} from "src/tokenDistribution/vesting/VestingParams.sol";
10-
import {Beneficiary, VestingType, Schedule} from "src/tokenDistribution/utils/Common.sol";
10+
import {Beneficiary, VestingType} from "src/tokenDistribution/utils/Common.sol";
1111

1212
contract MetaTokenDistributorTest is Test {
1313
uint256 public constant MONTH = 30 days;
@@ -22,6 +22,7 @@ contract MetaTokenDistributorTest is Test {
2222
address liquidityBeneficiary;
2323

2424
function setUp() external {
25+
// forge-lint: disable-next-line(unsafe-typecast)
2526
vestingStartTime = uint64(block.timestamp + MONTH);
2627
(Beneficiary[] memory teamBeneficiaries, Beneficiary[] memory liquidityBeneficiaries) = _generateBeneficiaries();
2728

@@ -34,7 +35,7 @@ contract MetaTokenDistributorTest is Test {
3435

3536
function test_deploy() external view {
3637
assertEq(distributor.getVestingParamsAddress(), address(vestingParams));
37-
assertNotEq(distributor.getMETAAddress(), address(0));
38+
assertNotEq(distributor.getMetaAddress(), address(0));
3839
assertNotEq(distributor.getVestingImplAddress(), address(0));
3940
}
4041

@@ -56,8 +57,8 @@ contract MetaTokenDistributorTest is Test {
5657

5758
assertNotEq(teamVesting, address(0));
5859

59-
IERC20 META = IERC20(distributor.getMETAAddress());
60-
assertEq(META.balanceOf(teamVesting), vestingParams.TEAM_TOTAL_AMOUNT());
60+
IERC20 meta = IERC20(distributor.getMetaAddress());
61+
assertEq(meta.balanceOf(teamVesting), vestingParams.TEAM_TOTAL_AMOUNT());
6162
}
6263

6364
function test_deploy_revertIfZeroAddress() external {
@@ -72,12 +73,12 @@ contract MetaTokenDistributorTest is Test {
7273

7374
function test_startVesting() external {
7475
vm.warp(vestingStartTime);
75-
IERC20 META = IERC20(distributor.getMETAAddress());
76+
IERC20 meta = IERC20(distributor.getMetaAddress());
7677

7778
address vesting = distributor.startVesting(VestingType.TEAM);
7879

79-
assertEq(META.balanceOf(vesting), vestingParams.TEAM_TOTAL_AMOUNT());
80-
assertEq(META.balanceOf(address(distributor)), META.totalSupply() - vestingParams.TEAM_TOTAL_AMOUNT());
80+
assertEq(meta.balanceOf(vesting), vestingParams.TEAM_TOTAL_AMOUNT());
81+
assertEq(meta.balanceOf(address(distributor)), meta.totalSupply() - vestingParams.TEAM_TOTAL_AMOUNT());
8182
assertNotEq(vesting, address(0));
8283
assertNotEq(distributor.getVestingAddress(VestingType.TEAM), address(0));
8384
}

0 commit comments

Comments
 (0)