From 0f49ee75bb7f2a6ccf619687e05048dc2bd0f5ac Mon Sep 17 00:00:00 2001 From: DrZoltanFazekas Date: Wed, 18 Dec 2024 09:02:21 +0100 Subject: [PATCH] Get rid of compiler warnings --- script/CheckVariant.s.sol | 2 +- src/LiquidDelegation.sol | 18 +++++++++--------- src/LiquidDelegationV2.sol | 4 ++-- src/NonLiquidDelegation.sol | 30 +++++++++++++++--------------- src/NonLiquidDelegationV2.sol | 4 ++-- test/BaseDelegation.t.sol | 17 ++++++++++------- 6 files changed, 39 insertions(+), 36 deletions(-) diff --git a/script/CheckVariant.s.sol b/script/CheckVariant.s.sol index 63c86f6..214a562 100644 --- a/script/CheckVariant.s.sol +++ b/script/CheckVariant.s.sol @@ -11,7 +11,7 @@ import {console} from "forge-std/console.sol"; contract CheckVariant is Script { using ERC165Checker for address; - function run(address proxy) external { + function run(address proxy) external view { if (proxy.supportsInterface(type(ILiquidDelegation).interfaceId)) console.log("ILiquidDelegation"); diff --git a/src/LiquidDelegation.sol b/src/LiquidDelegation.sol index b6d64cc..bd4c297 100644 --- a/src/LiquidDelegation.sol +++ b/src/LiquidDelegation.sol @@ -57,11 +57,11 @@ contract LiquidDelegation is BaseDelegation, ILiquidDelegation { bytes calldata, bytes calldata, bytes calldata - ) public override { + ) public pure override { revert("not implemented"); } - function migrate(bytes calldata) public override { + function migrate(bytes calldata) public pure override { revert("not implemented"); } @@ -69,28 +69,28 @@ contract LiquidDelegation is BaseDelegation, ILiquidDelegation { revert("not implemented"); } - function unstake(uint256) external override returns(uint256) { + function unstake(uint256) external pure override returns(uint256) { revert("not implemented"); } - function claim() external override { + function claim() external pure override { revert("not implemented"); } - function collectCommission() public override { + function collectCommission() public pure override { revert("not implemented"); } - function stakeRewards() public override { + function stakeRewards() public pure override { revert("not implemented"); } - function getPrice() public view returns(uint256) { + function getPrice() public pure returns(uint256) { revert("not implemented"); } - function supportsInterface(bytes4 interfaceId) public view override returns (bool) { - return interfaceId == type(ILiquidDelegation).interfaceId || super.supportsInterface(interfaceId); + function supportsInterface(bytes4 _interfaceId) public view override returns (bool) { + return _interfaceId == type(ILiquidDelegation).interfaceId || super.supportsInterface(_interfaceId); } function interfaceId() public pure returns (bytes4) { diff --git a/src/LiquidDelegationV2.sol b/src/LiquidDelegationV2.sol index eda0e6e..7a8f828 100644 --- a/src/LiquidDelegationV2.sol +++ b/src/LiquidDelegationV2.sol @@ -210,8 +210,8 @@ contract LiquidDelegationV2 is BaseDelegation, ILiquidDelegation { return $.lst; } - function supportsInterface(bytes4 interfaceId) public view override returns (bool) { - return interfaceId == type(ILiquidDelegation).interfaceId || super.supportsInterface(interfaceId); + function supportsInterface(bytes4 _interfaceId) public view override returns (bool) { + return _interfaceId == type(ILiquidDelegation).interfaceId || super.supportsInterface(_interfaceId); } function interfaceId() public pure returns (bytes4) { diff --git a/src/NonLiquidDelegation.sol b/src/NonLiquidDelegation.sol index 7778488..a2f0b33 100644 --- a/src/NonLiquidDelegation.sol +++ b/src/NonLiquidDelegation.sol @@ -52,11 +52,11 @@ contract NonLiquidDelegation is BaseDelegation, INonLiquidDelegation { bytes calldata, bytes calldata, bytes calldata - ) public override { + ) public pure override { revert("not implemented"); } - function migrate(bytes calldata) public override { + function migrate(bytes calldata) public pure override { revert("not implemented"); } @@ -64,52 +64,52 @@ contract NonLiquidDelegation is BaseDelegation, INonLiquidDelegation { revert("not implemented"); } - function unstake(uint256) external override returns(uint256) { + function unstake(uint256) external pure override returns(uint256) { revert("not implemented"); } - function claim() external override { + function claim() external pure override { revert("not implemented"); } - function collectCommission() public override { + function collectCommission() public pure override { revert("not implemented"); } - function stakeRewards() public override { + function stakeRewards() public pure override { revert("not implemented"); } - function rewards() public view returns(uint256) { + function rewards() public pure returns(uint256) { revert("not implemented"); } - function rewards(uint64) public view returns(uint256) { + function rewards(uint64) public pure returns(uint256) { revert("not implemented"); } - function getDelegatedStake() public view returns(uint256) { + function getDelegatedStake() public pure returns(uint256) { revert("not implemented"); } - function withdrawRewards(uint256, uint64) public returns(uint256) { + function withdrawRewards(uint256, uint64) public pure returns(uint256) { revert("not implemented"); } - function withdrawRewards(uint256) public returns(uint256) { + function withdrawRewards(uint256) public pure returns(uint256) { revert("not implemented"); } - function withdrawAllRewards(uint64) public returns(uint256) { + function withdrawAllRewards(uint64) public pure returns(uint256) { revert("not implemented"); } - function withdrawAllRewards() public returns(uint256) { + function withdrawAllRewards() public pure returns(uint256) { revert("not implemented"); } - function supportsInterface(bytes4 interfaceId) public view override returns (bool) { - return interfaceId == type(INonLiquidDelegation).interfaceId || super.supportsInterface(interfaceId); + function supportsInterface(bytes4 _interfaceId) public view override returns (bool) { + return _interfaceId == type(INonLiquidDelegation).interfaceId || super.supportsInterface(_interfaceId); } function interfaceId() public pure returns (bytes4) { diff --git a/src/NonLiquidDelegationV2.sol b/src/NonLiquidDelegationV2.sol index 88e0995..cc4fd17 100644 --- a/src/NonLiquidDelegationV2.sol +++ b/src/NonLiquidDelegationV2.sol @@ -367,8 +367,8 @@ contract NonLiquidDelegationV2 is BaseDelegation, INonLiquidDelegation { function collectCommission() public override {} - function supportsInterface(bytes4 interfaceId) public view override returns (bool) { - return interfaceId == type(INonLiquidDelegation).interfaceId || super.supportsInterface(interfaceId); + function supportsInterface(bytes4 _interfaceId) public view override returns (bool) { + return _interfaceId == type(INonLiquidDelegation).interfaceId || super.supportsInterface(_interfaceId); } function interfaceId() public pure returns (bytes4) { diff --git a/test/BaseDelegation.t.sol b/test/BaseDelegation.t.sol index 0d1497f..901579b 100644 --- a/test/BaseDelegation.t.sol +++ b/test/BaseDelegation.t.sol @@ -241,6 +241,9 @@ abstract contract BaseDelegationTest is Test { vm.deal(address(delegation), address(delegation).balance + 10_000 ether); uint256 totalUnstaked; + uint256 totalPending; + uint256[2][] memory claims; + for (uint256 j = 0; j < steps; j++) { console.log("--------------------------------------------------------------------"); vm.startPrank(stakers[i-1]); @@ -251,12 +254,12 @@ abstract contract BaseDelegationTest is Test { //console.log("block number: %s", block.number); console.log("claimable: %s", delegation.getClaimable()); - uint256[2][] memory claims = delegation.getPendingClaims(); + claims = delegation.getPendingClaims(); console.log("%s pending claims:", claims.length); - uint256 totalPending; - for (uint256 j = 0; j < claims.length; j++) { - console.log("%s can claim %s in block %s", stakers[i-1], claims[j][1], claims[j][0]); - totalPending += claims[j][1]; + totalPending = 0; + for (uint256 k = 0; k < claims.length; k++) { + console.log("%s can claim %s in block %s", stakers[i-1], claims[k][1], claims[k][0]); + totalPending += claims[k][1]; } assertEq(delegation.getClaimable() + totalPending, totalUnstaked, "claims must match unstaked amount"); @@ -271,9 +274,9 @@ abstract contract BaseDelegationTest is Test { console.log("--------------------------------------------------------------------"); console.log("block number: %s", block.number); console.log("claimable: %s", delegation.getClaimable()); - uint256[2][] memory claims = delegation.getPendingClaims(); + claims = delegation.getPendingClaims(); console.log("%s pending claims:", claims.length); - uint256 totalPending; + totalPending = 0; for (uint256 j = 0; j < claims.length; j++) { console.log("%s can claim %s in block %s", stakers[i-1], claims[j][1], claims[j][0]); totalPending += claims[j][1];