Skip to content

Commit

Permalink
Upgrade solidity version
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-CZ committed Sep 9, 2024
1 parent c950937 commit e75df19
Show file tree
Hide file tree
Showing 32 changed files with 2,078 additions and 2,228 deletions.
3 changes: 2 additions & 1 deletion contracts/common/Decimal.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

library Decimal {
// unit is used for decimals, e.g. 0.123456
Expand Down
19 changes: 3 additions & 16 deletions contracts/common/Initializable.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pragma solidity >=0.4.24 <0.7.0;

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

/**
* @title Initializable
Expand Down Expand Up @@ -29,7 +29,7 @@ contract Initializable {
* @dev Modifier to use in the initializer function of a contract.
*/
modifier initializer() {
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
require(initializing || !initialized, "Contract instance has already been initialized");

bool isTopLevelCall = !initializing;
if (isTopLevelCall) {
Expand All @@ -44,19 +44,6 @@ contract Initializable {
}
}

/// @dev Returns true if and only if the function is running in the constructor
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly { cs := extcodesize(self) }
return cs == 0;
}

// Reserved storage space to allow for layout changes in the future.
uint256[50] private ______gap;
}
4 changes: 3 additions & 1 deletion contracts/common/ReentrancyGuard.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import "./Initializable.sol";

/**
Expand Down
156 changes: 0 additions & 156 deletions contracts/common/SafeMath.sol

This file was deleted.

31 changes: 17 additions & 14 deletions contracts/erc20/base/ERC20.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import "../../common/SafeMath.sol";
import "./IERC20.sol";
import "../../common/Initializable.sol";

Expand Down Expand Up @@ -29,8 +29,6 @@ import "../../common/Initializable.sol";
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Initializable, IERC20 {
using SafeMath for uint256;

mapping(address => uint256) private _balances;

mapping(address => mapping(address => uint256)) private _allowances;
Expand Down Expand Up @@ -97,7 +95,8 @@ contract ERC20 is Initializable, IERC20 {
*/
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
require(amount <= _allowances[sender][msg.sender], "ERC20: transfer amount exceeds allowance");
_approve(sender, msg.sender, _allowances[sender][msg.sender] - amount);
return true;
}

Expand All @@ -114,7 +113,7 @@ contract ERC20 is Initializable, IERC20 {
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
_approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue);
return true;
}

Expand All @@ -133,7 +132,8 @@ contract ERC20 is Initializable, IERC20 {
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
require(subtractedValue <= _allowances[msg.sender][spender], "ERC20: decreased allowance below zero");
_approve(msg.sender, spender, _allowances[msg.sender][spender] - subtractedValue);
return true;
}

Expand All @@ -155,8 +155,9 @@ contract ERC20 is Initializable, IERC20 {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");

_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
require(_balances[sender] >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = _balances[sender] - amount;
_balances[recipient] = _balances[recipient] + amount;
emit Transfer(sender, recipient, amount);
}

Expand All @@ -172,8 +173,8 @@ contract ERC20 is Initializable, IERC20 {
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");

_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
_totalSupply = _totalSupply + amount;
_balances[account] = _balances[account] + amount;
emit Transfer(address(0), account, amount);
}

Expand All @@ -191,8 +192,9 @@ contract ERC20 is Initializable, IERC20 {
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");

_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
require(_balances[account] >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = _balances[account] - amount;
_totalSupply = _totalSupply - amount;
emit Transfer(account, address(0), amount);
}

Expand Down Expand Up @@ -225,7 +227,8 @@ contract ERC20 is Initializable, IERC20 {
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, msg.sender, _allowances[account][msg.sender].sub(amount, "ERC20: burn amount exceeds allowance"));
require(amount <= _allowances[account][msg.sender], "ERC20: burn amount exceeds allowance");
_approve(account, msg.sender, _allowances[account][msg.sender] - amount);
}

uint256[50] private ______gap;
Expand Down
11 changes: 2 additions & 9 deletions contracts/erc20/base/ERC20Burnable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import "./ERC20.sol";

Expand All @@ -25,12 +26,4 @@ contract ERC20Burnable is ERC20 {
function burnFrom(address from, uint256 value) public {
_burnFrom(from, value);
}

/**
* @dev Overrides ERC20._burn in order for burn and burnFrom to emit
* an additional Burn event.
*/
function _burn(address who, uint256 value) internal {
super._burn(who, value);
}
}
15 changes: 8 additions & 7 deletions contracts/erc20/base/ERC20Detailed.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import "./IERC20.sol";
import "../../common/Initializable.sol";
import {ERC20} from "./ERC20.sol";

/**
* @dev Optional functions from the ERC20 standard.
*/
contract ERC20Detailed is Initializable, IERC20 {
contract ERC20Detailed is ERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
Expand All @@ -16,10 +17,10 @@ contract ERC20Detailed is Initializable, IERC20 {
* these values are immutable: they can only be set once during
* construction.
*/
function initialize(string memory name, string memory symbol, uint8 decimals) internal initializer {
_name = name;
_symbol = symbol;
_decimals = decimals;
function initialize(string memory tokenName, string memory tokenSymbol, uint8 tokenDecimals) internal initializer {
_name = tokenName;
_symbol = tokenSymbol;
_decimals = tokenDecimals;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion contracts/erc20/base/ERC20Mintable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import "./ERC20.sol";
import "./MinterRole.sol";
Expand Down
4 changes: 2 additions & 2 deletions contracts/erc20/base/IERC20.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.5.0;
pragma solidity ^0.8.19;

/**
* @dev Interface of the ERC20 standard as defined in the EIP.
Expand Down
3 changes: 2 additions & 1 deletion contracts/erc20/base/MinterRole.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import "./Roles.sol";

Expand Down
3 changes: 2 additions & 1 deletion contracts/erc20/base/Roles.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;


/**
Expand Down
3 changes: 2 additions & 1 deletion contracts/ownership/Ownable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import "../common/Initializable.sol";

Expand Down
Loading

0 comments on commit e75df19

Please sign in to comment.