From 2a241edd265a00ab8c432eaaed037f172307bd53 Mon Sep 17 00:00:00 2001 From: r4bbit <445106+0x-r4bbit@users.noreply.github.com> Date: Tue, 26 Sep 2023 10:07:47 +0200 Subject: [PATCH] fix(MiniMeBase): make `burn()` and `mint()` virtual Otherwise they can't be overriden, which is necessary when inheriting contracts. This commit also renames `burn()` to `_burn()` and `mint()` to `_mint()`, simply to allow inheriting contracts to make use of those non-underscored function names instead. --- contracts/MiniMeBase.sol | 4 ++-- contracts/MiniMeToken.sol | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/MiniMeBase.sol b/contracts/MiniMeBase.sol index 96347cd..7f22ff3 100644 --- a/contracts/MiniMeBase.sol +++ b/contracts/MiniMeBase.sol @@ -368,7 +368,7 @@ abstract contract MiniMeBase is Controlled, IERC20, IERC20Permit, EIP712, Nonces /// @param _owner The address that will be assigned the new tokens /// @param _amount The quantity of tokens generated /// @return True if the tokens are generated correctly - function mint(address _owner, uint256 _amount) internal returns (bool) { + function _mint(address _owner, uint256 _amount) internal virtual returns (bool) { uint256 curTotalSupply = totalSupply(); if (uint128(curTotalSupply + _amount) < curTotalSupply) revert Overflow(); // Check for overflow uint256 previousBalanceTo = balanceOf(_owner); @@ -383,7 +383,7 @@ abstract contract MiniMeBase is Controlled, IERC20, IERC20Permit, EIP712, Nonces /// @param _owner The address that will lose the tokens /// @param _amount The quantity of tokens to burn /// @return True if the tokens are burned correctly - function burn(address _owner, uint256 _amount) internal returns (bool) { + function _burn(address _owner, uint256 _amount) internal virtual returns (bool) { uint256 curTotalSupply = totalSupply(); if (curTotalSupply < _amount) revert NotEnoughSupply(); uint256 previousBalanceFrom = balanceOf(_owner); diff --git a/contracts/MiniMeToken.sol b/contracts/MiniMeToken.sol index 26f154b..30d35e2 100644 --- a/contracts/MiniMeToken.sol +++ b/contracts/MiniMeToken.sol @@ -48,7 +48,7 @@ contract MiniMeToken is MiniMeBase { /// @param _amount The quantity of tokens generated /// @return True if the tokens are generated correctly function generateTokens(address _owner, uint256 _amount) public onlyController returns (bool) { - return mint(_owner, _amount); + return _mint(_owner, _amount); } /// @notice Burns `_amount` tokens from `_owner` @@ -56,6 +56,6 @@ contract MiniMeToken is MiniMeBase { /// @param _amount The quantity of tokens to burn /// @return True if the tokens are burned correctly function destroyTokens(address _owner, uint256 _amount) public onlyController returns (bool) { - return burn(_owner, _amount); + return _burn(_owner, _amount); } }