From acd26579c569a676226eb55f77710a2f89a56729 Mon Sep 17 00:00:00 2001 From: Tranquil-Flow <66773372+Tranquil-Flow@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:40:06 +1000 Subject: [PATCH] refactor: remove fallback() --- src/PositionFactory.sol | 10 ---------- src/services/AdminService.sol | 11 ----------- test/FeeCollector.t.sol | 23 ----------------------- test/PositionFactory.t.sol | 23 ----------------------- test/services/AdminService.t.sol | 23 ----------------------- 5 files changed, 90 deletions(-) diff --git a/src/PositionFactory.sol b/src/PositionFactory.sol index 4dd7beb..d2c17ba 100644 --- a/src/PositionFactory.sol +++ b/src/PositionFactory.sol @@ -77,14 +77,4 @@ contract PositionFactory is Ownable, IPositionFactory { SafeTransferLib.safeTransfer(ERC20(_token), msg.sender, balance); } - /** -<<<<<<< HEAD - * @notice Executes when native is sent to this contract through a non-existent function. - */ - fallback() external payable { } // solhint-disable-line no-empty-blocks -======= - * @notice Executes when native is sent to this contract with a plain transaction. - */ - receive() external payable { } // solhint-disable-line no-empty-blocks ->>>>>>> f79c7b55671c8204d3d03bb5efe0ec65e1f85a29 } diff --git a/src/services/AdminService.sol b/src/services/AdminService.sol index d04f1ca..4244d61 100644 --- a/src/services/AdminService.sol +++ b/src/services/AdminService.sol @@ -36,17 +36,6 @@ contract AdminService is IAdminService { SafeTransferLib.safeTransfer(ERC20(_token), msg.sender, balance); } - /** -<<<<<<< HEAD - * @notice Executes when native is sent to this contract through a non-existent function. - */ - fallback() external payable { } // solhint-disable-line no-empty-blocks -======= - * @notice Executes when native is sent to this contract with a plain transaction. - */ - receive() external payable { } // solhint-disable-line no-empty-blocks ->>>>>>> f79c7b55671c8204d3d03bb5efe0ec65e1f85a29 - /// @notice Check if the caller is the owner of the Position contract modifier onlyOwner() { if (msg.sender != OWNER) revert Unauthorized(); diff --git a/test/FeeCollector.t.sol b/test/FeeCollector.t.sol index da1291f..4e71e67 100644 --- a/test/FeeCollector.t.sol +++ b/test/FeeCollector.t.sol @@ -483,27 +483,4 @@ contract FeeCollectorTest is Test, TokenUtils, FeeUtils { feeCollector.extractERC20(token); } } - - /// @dev - // - The FeeCollector's native balance should increase by the amount transferred. - function testFuzz_Fallback(uint256 _amount, address _sender) public { - // Assumptions - vm.assume(_amount != 0 && _amount <= 1000 ether); - uint256 gasMoney = 1 ether; - vm.deal(_sender, _amount + gasMoney); - - // Pre-Act Data - uint256 preContractBalance = feeCollectorAddr.balance; - - // Act - vm.prank(_sender); - (bool success,) = feeCollectorAddr.call{ value: _amount }(abi.encodeWithSignature("nonExistentFn()")); - - // Post-Act Data - uint256 postContractBalance = feeCollectorAddr.balance; - - // Assertions - assertTrue(success); - assertEq(postContractBalance, preContractBalance + _amount); - } } diff --git a/test/PositionFactory.t.sol b/test/PositionFactory.t.sol index 70dcd8f..b748941 100644 --- a/test/PositionFactory.t.sol +++ b/test/PositionFactory.t.sol @@ -266,27 +266,4 @@ contract PositionFactoryTest is Test, TokenUtils { positionFactory.extractERC20(supportedAssets[i]); } } - - /// @dev - // - The contract's native balance should increase by the amount transferred. - function testFuzz_Fallback(uint256 _amount, address _sender) public { - // Assumptions - vm.assume(_amount != 0 && _amount <= 1000 ether); - uint256 gasMoney = 1 ether; - vm.deal(_sender, _amount + gasMoney); - - // Pre-Act Data - uint256 preContractBalance = address(positionFactory).balance; - - // Act - vm.prank(_sender); - (bool success,) = address(positionFactory).call{ value: _amount }(abi.encodeWithSignature("nonExistentFn()")); - - // Post-Act Data - uint256 postContractBalance = address(positionFactory).balance; - - // Assertions - assertTrue(success); - assertEq(postContractBalance, preContractBalance + _amount); - } } diff --git a/test/services/AdminService.t.sol b/test/services/AdminService.t.sol index 0c13786..f64ef3b 100644 --- a/test/services/AdminService.t.sol +++ b/test/services/AdminService.t.sol @@ -138,29 +138,6 @@ contract AdminServiceTest is Test, TokenUtils { } } - /// @dev - // - The contract's native balance should increase by the amount transferred. - function testFuzz_Fallback(uint256 _amount, address _sender) public { - // Assumptions - vm.assume(_amount != 0 && _amount <= 1000 ether); - uint256 gasMoney = 1 ether; - vm.deal(_sender, _amount + gasMoney); - - // Pre-Act Data - uint256 preContractBalance = positionAddr.balance; - - // Act - vm.prank(_sender); - (bool success,) = positionAddr.call{ value: _amount }(abi.encodeWithSignature("nonExistentFn()")); - - // Post-Act Data - uint256 postContractBalance = positionAddr.balance; - - // Assertions - assertTrue(success); - assertEq(postContractBalance, preContractBalance + _amount); - } - /// @dev Necessary for the owner, address(this), to receive native extractNative tests receive() external payable { } }