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.
This commit is contained in:
r4bbit
2023-09-26 10:07:47 +02:00
parent ed9dcfc602
commit 2a241edd26
2 changed files with 4 additions and 4 deletions

View File

@@ -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);

View File

@@ -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);
}
}