diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index d4578ec4e73..aad831477a9 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -1,7 +1,9 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT License -import "../token/ERC20/ERC20.sol"; -import "../math/SafeMath.sol"; +pragma solidity ^0.8.9; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; /** @@ -19,18 +21,29 @@ import "../math/SafeMath.sol"; contract Crowdsale { using SafeMath for uint256; - // The token being sold - ERC20 public token; + // How many token units a buyer gets per wei. + // The rate is the conversion between wei and the smallest and indivisible token unit. + // So, if you are using a rate of 1 with a DetailedERC20 token with 3 decimals called TOK + // 1 wei will give you 1 unit, or 0.001 TOK. + uint256 public rate; - // Address where funds are collected - address public wallet; + // Address where funds are collected + address payable wallet; - // How many token units a buyer gets per wei - uint256 public rate; + // The token being sold + address public token; // Amount of wei raised uint256 public weiRaised; + // Public Supply + uint256 public publicSupply; + + // start and end timestamps where investments are allowed (both inclusive) + uint256 public startTime; + uint256 public endTime; + + /** * Event for token purchase logging * @param purchaser who paid for the tokens @@ -46,20 +59,27 @@ contract Crowdsale { ); /** - * @param _rate Number of token units a buyer gets per wei - * @param _wallet Address where collected funds will be forwarded to - * @param _token Address of the token being sold + * param _rate Number of token units a buyer gets per wei + * param _wallet Address where collected funds will be forwarded to + * param _token Address of the token being sold */ - constructor(uint256 _rate, address _wallet, ERC20 _token) public { + +constructor (uint256 _startTime, uint256 _endTime, uint256 _rate, address payable _wallet, address _token) { + require(_startTime >= block.timestamp); + require(_endTime >= _startTime); require(_rate > 0); require(_wallet != address(0)); - require(_token != address(0)); - + require(address(token) != address(0)); + startTime = _startTime; + endTime = _endTime; rate = _rate; wallet = _wallet; token = _token; + } + + // ----------------------------------------- // Crowdsale external interface // ----------------------------------------- @@ -67,18 +87,23 @@ contract Crowdsale { /** * @dev fallback function ***DO NOT OVERRIDE*** */ - function () external payable { + fallback () external payable { + buyTokens(msg.sender); + } + + receive () external payable { buyTokens(msg.sender); } + /** * @dev low level token purchase ***DO NOT OVERRIDE*** * @param _beneficiary Address performing the token purchase */ - function buyTokens(address _beneficiary) public payable { - + function buyTokens(address _beneficiary) public payable { + require(_beneficiary != address(0)); uint256 weiAmount = msg.value; - _preValidatePurchase(_beneficiary, weiAmount); + // _preValidatePurchase(_beneficiary, weiAmount); // calculate token amount to be created uint256 tokens = _getTokenAmount(weiAmount); @@ -86,18 +111,14 @@ contract Crowdsale { // update state weiRaised = weiRaised.add(weiAmount); - _processPurchase(_beneficiary, tokens); - emit TokenPurchase( - msg.sender, - _beneficiary, - weiAmount, - tokens - ); + // _processPurchase(_beneficiary, token); + emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens); _updatePurchasingState(_beneficiary, weiAmount); _forwardFunds(); - _postValidatePurchase(_beneficiary, weiAmount); + + } // ----------------------------------------- @@ -108,7 +129,7 @@ contract Crowdsale { * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase - */ + function _preValidatePurchase( address _beneficiary, uint256 _weiAmount @@ -118,40 +139,32 @@ contract Crowdsale { require(_beneficiary != address(0)); require(_weiAmount != 0); } - - /** - * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met. - * @param _beneficiary Address performing the token purchase - * @param _weiAmount Value in wei involved in the purchase - */ - function _postValidatePurchase( - address _beneficiary, - uint256 _weiAmount - ) - internal - { - // optional override - } + +*/ /** * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens. * @param _beneficiary Address performing the token purchase * @param _tokenAmount Number of tokens to be emitted - */ + + function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { - token.transfer(_beneficiary, _tokenAmount); + token.transfer(_beneficiary, _tokenAmount); } + */ + + /** * @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _beneficiary Address receiving the tokens * @param _tokenAmount Number of tokens to be purchased - */ + function _processPurchase( address _beneficiary, uint256 _tokenAmount @@ -161,6 +174,9 @@ contract Crowdsale { _deliverTokens(_beneficiary, _tokenAmount); } + */ + + /** * @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.) * @param _beneficiary Address receiving the tokens diff --git a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol index 74b45d16186..b9e8e72faf5 100644 --- a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol +++ b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol @@ -1,22 +1,20 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "../../math/SafeMath.sol"; -import "../../ownership/Ownable.sol"; -import "../validation/TimedCrowdsale.sol"; +pragma solidity ^0.8.7; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/validation/TimedCrowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; /** - * @title FinalizableCrowdsale - * @dev Extension of Crowdsale where an owner can do extra work - * after finishing. + * title FinalizableCrowdsale + * dev Extension of Crowdsale where an owner can do extra work after finishing. */ contract FinalizableCrowdsale is TimedCrowdsale, Ownable { - using SafeMath for uint256; - bool public isFinalized = false; - event Finalized(); - + using SafeMath for uint256; + /** * @dev Must be called after crowdsale ends, to do some extra finalization * work. Calls the contract's finalization function. diff --git a/contracts/crowdsale/emission/AllowanceCrowdsale.sol b/contracts/crowdsale/emission/AllowanceCrowdsale.sol index a79716b32f1..5c059785aae 100644 --- a/contracts/crowdsale/emission/AllowanceCrowdsale.sol +++ b/contracts/crowdsale/emission/AllowanceCrowdsale.sol @@ -1,8 +1,10 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "../Crowdsale.sol"; -import "../../token/ERC20/ERC20.sol"; -import "../../math/SafeMath.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; /** diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index 02ae3d16aaf..5d1c73f7574 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -1,7 +1,9 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT License Modern Variant -import "../Crowdsale.sol"; -import "../../token/ERC20/MintableToken.sol"; +pragma solidity ^0.8.7; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/MintableToken.sol"; /** diff --git a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol index 592749a0a1c..95b64e3d3e9 100644 --- a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol +++ b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol @@ -1,7 +1,9 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "../validation/TimedCrowdsale.sol"; -import "../../math/SafeMath.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/validation/TimedCrowdsale.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; /** diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 87c03282509..3ac2d1606ad 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -1,48 +1,56 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT License Modern Variant -import "../../math/SafeMath.sol"; -import "../Crowdsale.sol"; +pragma solidity ^0.8.7; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; /** * @title CappedCrowdsale * @dev Crowdsale with a limit for total contributions. */ -contract CappedCrowdsale is Crowdsale { - using SafeMath for uint256; - - uint256 public cap; - - /** - * @dev Constructor, takes maximum amount of wei accepted in the crowdsale. - * @param _cap Max amount of wei to be contributed - */ - constructor(uint256 _cap) public { - require(_cap > 0); - cap = _cap; - } - - /** - * @dev Checks whether the cap has been reached. - * @return Whether the cap was reached - */ - function capReached() public view returns (bool) { - return weiRaised >= cap; - } - - /** - * @dev Extend parent behavior requiring purchase to respect the funding cap. - * @param _beneficiary Token purchaser - * @param _weiAmount Amount of wei contributed - */ - function _preValidatePurchase( - address _beneficiary, - uint256 _weiAmount - ) - internal - { - super._preValidatePurchase(_beneficiary, _weiAmount); - require(weiRaised.add(_weiAmount) <= cap); - } +abstract contract ERC20Capped is ERC20 { + + uint256 public _cap=300000000000000000000; // 300 ETH = 300*10^18 wei = 300000000000000000000 wei; + + //minimum investor Contribution - 1 + //maximum investor Contribution - 300 wei is similar maxium daily 300 ETH crowdsale + uint256 public investorMinCap = 1000000000000000000; // 1 ETH = 10^18 wei = 1000000000000000000 wei + uint256 public investorHardCap = 300000000000000000000; // 300 ETH = 300*10^18 wei = 300000000000000000000 wei + + // start and end timestamps where investments are allowed (both inclusive) + uint256 public startTime; + uint256 public endTime; + + mapping(address => uint256) public contributions; + + /** + * @dev Sets the value of the `cap`. This value is immutable, it can only be + * set once during construction. + */ + constructor(uint256 cap_, uint256 _openingTime, uint256 _closingTime) { + require(cap_ > 0, "ERC20Capped: cap is 300000000000000000000"); + require(_openingTime >= block.timestamp); + require(_closingTime >= _openingTime); + _cap = cap_; + } + + /** + * @dev Returns the cap on the token's total supply. + */ + function cap() public view virtual returns (uint256) { + return _cap; + } + + /** + * @dev See {ERC20-_mint}. + */ + function _mint(address account, uint256 amount) internal virtual override { + require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); + super._mint(account, amount); + } + + + } + diff --git a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol index b60466c1646..b4d07b2a7f5 100644 --- a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol +++ b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol @@ -1,8 +1,10 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT License Modern Variant -import "../../math/SafeMath.sol"; -import "../Crowdsale.sol"; -import "../../ownership/Ownable.sol"; +pragma solidity ^0.8.7; + +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; /** diff --git a/contracts/crowdsale/validation/PausableCrowdsale.sol b/contracts/crowdsale/validation/PausableCrowdsale.sol new file mode 100644 index 00000000000..b253f541ad6 --- /dev/null +++ b/contracts/crowdsale/validation/PausableCrowdsale.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Pausable.sol"; + +/** + * @title PausableCrowdsale + * @dev Extension of Crowdsale contract where purchases can be paused and unpaused by the pauser role. + */ +contract PausableCrowdsale is Crowdsale, Pausable { + /** + * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. + * Use super to concatenate validations. + * Adds the validation that the crowdsale must not be paused. + * @param _beneficiary Address performing the token purchase + * @param _weiAmount Value in wei involved in the purchase + */ + function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view whenNotPaused { + return super._preValidatePurchase(_beneficiary, _weiAmount); + } +} diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index 28d6beeca9b..b73c66ecde2 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -1,11 +1,12 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "../../math/SafeMath.sol"; -import "../Crowdsale.sol"; +pragma solidity ^0.8.7; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; /** - * @title TimedCrowdsale + * title TimedCrowdsale * @dev Crowdsale accepting contributions only within a time frame. */ contract TimedCrowdsale is Crowdsale { diff --git a/contracts/crowdsale/validation/WhitelistedCrowdsale.sol b/contracts/crowdsale/validation/WhitelistedCrowdsale.sol index ee4e164770b..d80cf5ab3b4 100644 --- a/contracts/crowdsale/validation/WhitelistedCrowdsale.sol +++ b/contracts/crowdsale/validation/WhitelistedCrowdsale.sol @@ -1,7 +1,7 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; -import "../Crowdsale.sol"; -import "../../ownership/Ownable.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; /** diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index f1c73742765..2511c2839db 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -1,53 +1,71 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT License Modern Variant +pragma solidity ^0.8.7; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; /** - * @title Ownable - * @dev The Ownable contract has an owner address, and provides basic authorization control - * functions, this simplifies the implementation of "user permissions". + * dev Contract module which provides a basic access control mechanism, where + * there is an account (an owner) that can be granted exclusive access to + * specific functions. + * + * By default, the owner account will be the one that deploys the contract. This + * can later be changed with {transferOwnership}. + * + * This module is used through inheritance. It will make available the modifier + * `onlyOwner`, which can be applied to your functions to restrict their use to + * the owner. */ -contract Ownable { - address public owner; - - - event OwnershipRenounced(address indexed previousOwner); - event OwnershipTransferred( - address indexed previousOwner, - address indexed newOwner - ); - - - /** - * @dev The Ownable constructor sets the original `owner` of the contract to the sender - * account. - */ - constructor() public { - owner = msg.sender; - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - /** - * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param newOwner The address to transfer ownership to. - */ - function transferOwnership(address newOwner) public onlyOwner { - require(newOwner != address(0)); - emit OwnershipTransferred(owner, newOwner); - owner = newOwner; - } - - /** - * @dev Allows the current owner to relinquish control of the contract. - */ - function renounceOwnership() public onlyOwner { - emit OwnershipRenounced(owner); - owner = address(0); - } +abstract contract Ownable is Context { + address private _owner; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + /** + * @dev Initializes the contract setting the deployer as the initial owner. + */ + constructor() { + _setOwner(_msgSender()); + } + + /** + * @dev Returns the address of the current owner. + */ + function owner() public view virtual returns (address) { + return _owner; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(owner() == _msgSender(), "Ownable: caller is not the owner"); + _; + } + + /** + * @dev Leaves the contract without owner. It will not be possible to call + * `onlyOwner` functions anymore. Can only be called by the current owner. + * + * NOTE: Renouncing ownership will leave the contract without an owner, + * thereby removing any functionality that is only available to the owner. + */ + function renounceOwnership() public virtual onlyOwner { + _setOwner(address(0)); + } + + /** + * @dev Transfers ownership of the contract to a new account (`newOwner`). + * Can only be called by the current owner. + */ + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), "Ownable: new owner is the zero address"); + _setOwner(newOwner); + } + + function _setOwner(address newOwner) private { + address oldOwner = _owner; + _owner = newOwner; + emit OwnershipTransferred(oldOwner, newOwner); + } } diff --git a/contracts/ownership/rbac/RBAC.sol b/contracts/ownership/rbac/RBAC.sol index 4ecb9ce6f1e..da5f101257e 100644 --- a/contracts/ownership/rbac/RBAC.sol +++ b/contracts/ownership/rbac/RBAC.sol @@ -1,6 +1,8 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./Roles.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/rbac/Roles.sol"; /** diff --git a/contracts/ownership/rbac/Roles.sol b/contracts/ownership/rbac/Roles.sol index 842f8595ecc..3c8bedc0309 100644 --- a/contracts/ownership/rbac/Roles.sol +++ b/contracts/ownership/rbac/Roles.sol @@ -1,4 +1,6 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.4; /** diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index 1042c2f17e2..d3142b1e106 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -1,50 +1,68 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.7; -import "./ERC20Basic.sol"; -import "../../math/SafeMath.sol"; - - -/** - * @title Basic token - * @dev Basic version of StandardToken, with no allowances. - */ -contract BasicToken is ERC20Basic { - using SafeMath for uint256; - - mapping(address => uint256) balances; - - uint256 totalSupply_; +contract BasicToken { + /* *This creates an array with all balancesOf */ + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + + string private _name; + string private _symbol; + uint8 public _decimals; + uint256 private _totalSupply; + + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** - * @dev total number of tokens in existence + * dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { - return totalSupply_; + return _totalSupply; } - /** - * @dev transfer token for a specified address - * @param _to The address to transfer to. - * @param _value The amount to be transferred. - */ - function transfer(address _to, uint256 _value) public returns (bool) { - require(_to != address(0)); - require(_value <= balances[msg.sender]); + - balances[msg.sender] = balances[msg.sender].sub(_value); - balances[_to] = balances[_to].add(_value); - emit Transfer(msg.sender, _to, _value); +/** + * @dev Transfer tokens from one address to another + * @param _from address The address which you want to send tokens from + * @param _to address The address which you want to transfer to + * @param _value uint256 the amount of tokens to be transferred + */ + function transferFrom( + address _from, + address _to, + uint256 _value + ) + public returns (bool){ + require(_to != address(0)); + + emit Transfer(_from, _to, _value); return true; } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address owner) public view returns (uint256) { + return _balances[owner]; + } - /** - * @dev Gets the balance of the specified address. - * @param _owner The address to query the the balance of. - * @return An uint256 representing the amount owned by the passed address. - */ - function balanceOf(address _owner) public view returns (uint256) { - return balances[_owner]; } - -} diff --git a/contracts/token/ERC20/BurnableToken.sol b/contracts/token/ERC20/BurnableToken.sol index ad5c0ab8b1c..a580a6ef7cf 100644 --- a/contracts/token/ERC20/BurnableToken.sol +++ b/contracts/token/ERC20/BurnableToken.sol @@ -1,6 +1,8 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./BasicToken.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BasicToken.sol"; /** diff --git a/contracts/token/ERC20/CappedToken.sol b/contracts/token/ERC20/CappedToken.sol index d8e67ac636a..bd74f4b6bea 100644 --- a/contracts/token/ERC20/CappedToken.sol +++ b/contracts/token/ERC20/CappedToken.sol @@ -1,7 +1,8 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./MintableToken.sol"; +pragma solidity ^0.8.4; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/MintableToken.sol"; /** * @title Capped token diff --git a/contracts/token/ERC20/Context.sol b/contracts/token/ERC20/Context.sol new file mode 100644 index 00000000000..fb0c0fa2a66 --- /dev/null +++ b/contracts/token/ERC20/Context.sol @@ -0,0 +1,26 @@ +// File: @openzeppelin/contracts/utils/Context.sol + +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.7; + +/* + * @dev Provides information about the current execution context, including the + * sender of the transaction and its data. While these are generally available + * via msg.sender and msg.data, they should not be accessed in such a direct + * manner, since when dealing with meta-transactions the account sending and + * paying for execution may not be the actual sender (as far as an application + * is concerned). + * + * This contract is only required for intermediate, library-like contracts. + */ +abstract contract Context { + function _msgSender() internal view virtual returns (address) { + return msg.sender; + } + + function _msgData() internal view virtual returns (bytes calldata) { + this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 + return msg.data; + } +} diff --git a/contracts/token/ERC20/DetailedERC20.sol b/contracts/token/ERC20/DetailedERC20.sol index 749d960712d..7ac118a7972 100644 --- a/contracts/token/ERC20/DetailedERC20.sol +++ b/contracts/token/ERC20/DetailedERC20.sol @@ -1,6 +1,8 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./ERC20.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; contract DetailedERC20 is ERC20 { diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 0fd454e3412..79f1200684f 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -1,23 +1,357 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT License Modern Variant -import "./ERC20Basic.sol"; +pragma solidity ^0.8.7; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; -/** - * @title ERC20 interface + +/** title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 + * openzeppelin/contracts/utils/Context.sol + * @dev Implementation of the {IERC20} interface. + * + * This implementation is agnostic to the way tokens are created. This means + * that a supply mechanism has to be added in a derived contract using {_mint}. + * For a generic mechanism see {ERC20PresetMinterPauser}. + * + * TIP: For a detailed writeup see our guide + * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How + * to implement supply mechanisms]. + * + * We have followed general OpenZeppelin Contracts guidelines: functions revert + * instead returning `false` on failure. This behavior is nonetheless + * conventional and does not conflict with the expectations of ERC20 + * applications. + * + * Additionally, an {Approval} event is emitted on calls to {transferFrom}. + * This allows applications to reconstruct the allowance for all accounts just + * by listening to said events. Other implementations of the EIP may not emit + * these events, as it isn't required by the specification. + * + * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} + * functions have been added to mitigate the well-known issues around setting + * allowances. See {IERC20-approve}. */ -contract ERC20 is ERC20Basic { - function allowance(address owner, address spender) - public view returns (uint256); - - function transferFrom(address from, address to, uint256 value) - public returns (bool); - - function approve(address spender, uint256 value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); + +contract ERC20 is Context, IERC20, IERC20Metadata { + mapping(address => uint256) private _balances; + + mapping(address => mapping(address => uint256)) private _allowances; + + uint256 private _totalSupply; + + string private _name; + string private _symbol; + + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev Returns the name of the token. + */ + function name() public view virtual override returns (string memory) { + return _name; + } + + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + /** + * @dev Returns the number of decimals used to get its user representation. + * For example, if `decimals` equals `2`, a balance of `505` tokens should + * be displayed to a user as `5.05` (`505 / 10 ** 2`). + * + * Tokens usually opt for a value of 18, imitating the relationship between + * Ether and Wei. This is the value {ERC20} uses, unless this function is + * overridden; + * + * NOTE: This information is only used for _display_ purposes: it in + * no way affects any of the arithmetic of the contract, including + * {IERC20-balanceOf} and {IERC20-transfer}. + */ + function decimals() public view virtual override returns (uint8) { + return 18; + } + + /** + * @dev See {IERC20-totalSupply}. + */ + function totalSupply() public view virtual override returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address account) public view virtual override returns (uint256) { + return _balances[account]; + } + + /** + * @dev See {IERC20-transfer}. + * + * Requirements: + * + * - `recipient` cannot be the zero address. + * - the caller must have a balance of at least `amount`. + */ + function transfer(address recipient, uint256 amount) public virtual override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + /** + * @dev See {IERC20-allowance}. + */ + function allowance(address owner, address spender) public view virtual override returns (uint256) { + return _allowances[owner][spender]; + } + + /** + * @dev See {IERC20-approve}. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 amount) public virtual override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + /** + * @dev See {IERC20-transferFrom}. + * + * Emits an {Approval} event indicating the updated allowance. This is not + * required by the EIP. See the note at the beginning of {ERC20}. + * + * Requirements: + * + * - `sender` and `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + * - the caller must have allowance for ``sender``'s tokens of at least + * `amount`. + */ + function transferFrom( + address sender, + address recipient, + uint256 amount + ) public virtual override returns (bool) { + _transfer(sender, recipient, amount); + + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); + unchecked { + _approve(sender, _msgSender(), currentAllowance - amount); + } + + return true; + } + + /** + * @dev Atomically increases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); + return true; + } + + /** + * @dev Atomically decreases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + * - `spender` must have allowance for the caller of at least + * `subtractedValue`. + */ + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + uint256 currentAllowance = _allowances[_msgSender()][spender]; + require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); + unchecked { + _approve(_msgSender(), spender, currentAllowance - subtractedValue); + } + + return true; + } + + /** + * @dev Moves `amount` of tokens from `sender` to `recipient`. + * + * This internal function is equivalent to {transfer}, and can be used to + * e.g. implement automatic token fees, slashing mechanisms, etc. + * + * Emits a {Transfer} event. + * + * Requirements: + * + * - `sender` cannot be the zero address. + * - `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + */ + function _transfer( + address sender, + address recipient, + uint256 amount + ) internal virtual { + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + + _beforeTokenTransfer(sender, recipient, amount); + + uint256 senderBalance = _balances[sender]; + require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); + unchecked { + _balances[sender] = senderBalance - amount; + } + _balances[recipient] += amount; + + emit Transfer(sender, recipient, amount); + + _afterTokenTransfer(sender, recipient, amount); + } + + /** @dev Creates `amount` tokens and assigns them to `account`, increasing + * the total supply. + * + * Emits a {Transfer} event with `from` set to the zero address. + * + * Requirements: + * + * - `account` cannot be the zero address. + */ + function _mint(address account, uint256 amount) internal virtual { + require(account != address(0), "ERC20: mint to the zero address"); + + _beforeTokenTransfer(address(0), account, amount); + + _totalSupply += amount; + _balances[account] += amount; + emit Transfer(address(0), account, amount); + + _afterTokenTransfer(address(0), account, amount); + } + + /** + * @dev Destroys `amount` tokens from `account`, reducing the + * total supply. + * + * Emits a {Transfer} event with `to` set to the zero address. + * + * Requirements: + * + * - `account` cannot be the zero address. + * - `account` must have at least `amount` tokens. + */ + function _burn(address account, uint256 amount) internal virtual { + require(account != address(0), "ERC20: burn from the zero address"); + + _beforeTokenTransfer(account, address(0), amount); + + uint256 accountBalance = _balances[account]; + require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); + unchecked { + _balances[account] = accountBalance - amount; + } + _totalSupply -= amount; + + emit Transfer(account, address(0), amount); + + _afterTokenTransfer(account, address(0), amount); + } + + /** + * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. + * + * This internal function is equivalent to `approve`, and can be used to + * e.g. set automatic allowances for certain subsystems, etc. + * + * Emits an {Approval} event. + * + * Requirements: + * + * - `owner` cannot be the zero address. + * - `spender` cannot be the zero address. + */ + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + /** + * @dev Hook that is called before any transfer of tokens. This includes + * minting and burning. + * + * Calling conditions: + * + * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens + * will be transferred to `to`. + * - when `from` is zero, `amount` tokens will be minted for `to`. + * - when `to` is zero, `amount` of ``from``'s tokens will be burned. + * - `from` and `to` are never both zero. + * + * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. + */ + function _beforeTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual {} + + /** + * @dev Hook that is called after any transfer of tokens. This includes + * minting and burning. + * + * Calling conditions: + * + * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens + * has been transferred to `to`. + * - when `from` is zero, `amount` tokens have been minted for `to`. + * - when `to` is zero, `amount` of ``from``'s tokens have been burned. + * - `from` and `to` are never both zero. + * + * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. + */ + function _afterTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual {} } diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index 4f02de19eed..b79b8f58f32 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -1,14 +1,267 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT License Modern Variant +pragma solidity ^0.8.7; -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/179 +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; + + + +/** title ERC20 interface + * dev see https://github.com/ethereum/EIPs/issues/20 + * openzeppelin/contracts/utils/Context.sol + * dev Implementation of the {IERC20} interface. + * + * This implementation is agnostic to the way tokens are created. This means + * that a supply mechanism has to be added in a derived contract using {_mint}. + * For a generic mechanism see {ERC20PresetMinterPauser}. + * + * TIP: For a detailed writeup see our guide + * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How + * to implement supply mechanisms]. + * + * We have followed general OpenZeppelin Contracts guidelines: functions revert + * instead returning `false` on failure. This behavior is nonetheless + * conventional and does not conflict with the expectations of ERC20 + * applications. + * + * Additionally, an {Approval} event is emitted on calls to {transferFrom}. + * This allows applications to reconstruct the allowance for all accounts just + * by listening to said events. Other implementations of the EIP may not emit + * these events, as it isn't required by the specification. + * + * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} + * functions have been added to mitigate the well-known issues around setting + * allowances. See {IERC20-approve}. */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address who) public view returns (uint256); - function transfer(address to, uint256 value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); + +contract ERC20 is Context, IERC20, IERC20Metadata { + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + string private _name; + string private _symbol; + uint8 public _decimals; + uint256 private _totalSupply; + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev Returns the name of the token. + */ + function name() public view virtual override returns (string memory) { + return _name; + } + + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + /** + * @dev Returns the number of decimals used to get its user representation. + * For example, if `decimals` equals `2`, a balance of `505` tokens should + * be displayed to a user as `5.05` (`505 / 10 ** 2`). + * + * Tokens usually opt for a value of 18, imitating the relationship between + * Ether and Wei. This is the value {ERC20} uses, unless this function is + * overridden; + * + * NOTE: This information is only used for _display_ purposes: it in + * no way affects any of the arithmetic of the contract, including + * {IERC20-balanceOf} and {IERC20-transfer}. + */ + function decimals() public view virtual override returns (uint8) { + return 18; + } + + /** + * @dev See {IERC20-totalSupply}. + */ + function totalSupply() public view virtual override returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address account) public view virtual override returns (uint256) { + return _balances[account]; + } + + /** + * @dev See {IERC20-transfer}. + * + * Requirements: + * + * - `recipient` cannot be the zero address. + * - the caller must have a balance of at least `amount`. + */ + function transfer(address recipient, uint256 amount) public virtual override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + /** + * @dev See {IERC20-allowance}. + */ + function allowance(address owner, address spender) public view virtual override returns (uint256) { + return _allowances[owner][spender]; + } + + /** + * @dev See {IERC20-approve}. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 amount) public virtual override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + /** + * @dev See {IERC20-transferFrom}. + * + * Emits an {Approval} event indicating the updated allowance. This is not + * required by the EIP. See the note at the beginning of {ERC20}. + * + * Requirements: + * + * - `sender` and `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + * - the caller must have allowance for ``sender``'s tokens of at least + * `amount`. + */ + function transferFrom( + address sender, + address recipient, + uint256 amount + ) public virtual override returns (bool) { + _transfer(sender, recipient, amount); + + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); + unchecked { + _approve(sender, _msgSender(), currentAllowance - amount); + } + + return true; + } + + /** + * @dev Atomically increases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); + return true; + } + + /** + * @dev Atomically decreases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + * - `spender` must have allowance for the caller of at least + * `subtractedValue`. + */ + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + uint256 currentAllowance = _allowances[_msgSender()][spender]; + require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); + unchecked { + _approve(_msgSender(), spender, currentAllowance - subtractedValue); + } + + return true; + } + + /** + * @dev Moves `amount` of tokens from `sender` to `recipient`. + * + * This internal function is equivalent to {transfer}, and can be used to + * e.g. implement automatic token fees, slashing mechanisms, etc. + * + * Emits a {Transfer} event. + * + * Requirements: + * + * - `sender` cannot be the zero address. + * - `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + */ + function _transfer( + address sender, + address recipient, + uint256 amount + ) internal virtual { + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + + uint256 senderBalance = _balances[sender]; + require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); + unchecked { + _balances[sender] = senderBalance - amount; + } + _balances[recipient] += amount; + + emit Transfer(sender, recipient, amount); + + } + + + /** + * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. + * + * This internal function is equivalent to `approve`, and can be used to + * e.g. set automatic allowances for certain subsystems, etc. + * + * Emits an {Approval} event. + * + * Requirements: + * + * - `owner` cannot be the zero address. + * - `spender` cannot be the zero address. + */ + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } } diff --git a/contracts/token/ERC20/IERC20.sol b/contracts/token/ERC20/IERC20.sol new file mode 100644 index 00000000000..10dbf358386 --- /dev/null +++ b/contracts/token/ERC20/IERC20.sol @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: MIT License Modern Variant + +pragma solidity ^0.7.2; + +/** + * @dev Interface of the ERC20 standard as defined in the EIP. + */ +interface IERC20 { + /** + * @dev Returns the amount of tokens in existence. + */ + function totalSupply() external view returns (uint256); + + /** + * @dev Returns the amount of tokens owned by `account`. + */ + function balanceOf(address account) external view returns (uint256); + + /** + * @dev Moves `amount` tokens from the caller's account to `recipient`. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transfer(address recipient, uint256 amount) external returns (bool); + + /** + * @dev Returns the remaining number of tokens that `spender` will be + * allowed to spend on behalf of `owner` through {transferFrom}. This is + * zero by default. + * + * This value changes when {approve} or {transferFrom} are called. + */ + function allowance(address owner, address spender) external view returns (uint256); + + /** + * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * IMPORTANT: Beware that changing an allowance with this method brings the risk + * that someone may use both the old and the new allowance by unfortunate + * transaction ordering. One possible solution to mitigate this race + * condition is to first reduce the spender's allowance to 0 and set the + * desired value afterwards: + * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 + * + * Emits an {Approval} event. + */ + function approve(address spender, uint256 amount) external returns (bool); + + /** + * @dev Moves `amount` tokens from `sender` to `recipient` using the + * allowance mechanism. `amount` is then deducted from the caller's + * allowance. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external returns (bool); + + /** + * @dev Emitted when `value` tokens are moved from one account (`from`) to + * another (`to`). + * + * Note that `value` may be zero. + */ + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Emitted when the allowance of a `spender` for an `owner` is set by + * a call to {approve}. `value` is the new allowance. + */ + event Approval(address indexed owner, address indexed spender, uint256 value); +} diff --git a/contracts/token/ERC20/IERC20Metadata.sol b/contracts/token/ERC20/IERC20Metadata.sol new file mode 100644 index 00000000000..bca2e2f3901 --- /dev/null +++ b/contracts/token/ERC20/IERC20Metadata.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.0; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/master/contracts/token/ERC20/IERC20.sol"; + + +/** + * @dev Interface for the optional metadata functions from the ERC20 standard. + * + * _Available since v4.1._ + */ +interface IERC20Metadata is IERC20 { + /** + * @dev Returns the name of the token. + */ + function name() external view returns (string memory); + + /** + * @dev Returns the symbol of the token. + */ + function symbol() external view returns (string memory); + + /** + * @dev Returns the decimals places of the token. + */ + function decimals() external view returns (uint8); +} diff --git a/contracts/token/ERC20/MintableToken.sol b/contracts/token/ERC20/MintableToken.sol index 590a3065895..8eb630923c0 100644 --- a/contracts/token/ERC20/MintableToken.sol +++ b/contracts/token/ERC20/MintableToken.sol @@ -1,7 +1,8 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./StandardToken.sol"; -import "../../ownership/Ownable.sol"; +pragma solidity ^0.8.7; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; /** @@ -10,7 +11,7 @@ import "../../ownership/Ownable.sol"; * @dev Issue: * https://github.com/OpenZeppelin/openzeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ -contract MintableToken is StandardToken, Ownable { +contract MintableToken is Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); diff --git a/contracts/token/ERC20/Pausable.sol b/contracts/token/ERC20/Pausable.sol new file mode 100644 index 00000000000..20e33bb9514 --- /dev/null +++ b/contracts/token/ERC20/Pausable.sol @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; + + +/** + * @title Pausable + * @dev Base contract which allows children to implement an emergency stop mechanism. + */ +contract Pausable is Ownable { + event Pause(); + event Unpause(); + + bool public paused = false; + + + /** + * @dev Modifier to make a function callable only when the contract is not paused. + */ + modifier whenNotPaused() { + require(!paused); + _; + } + + /** + * @dev Modifier to make a function callable only when the contract is paused. + */ + modifier whenPaused() { + require(paused); + _; + } + + /** + * @dev called by the owner to pause, triggers stopped state + */ + function pause() onlyOwner whenNotPaused public { + paused = true; + emit Pause(); + } + + /** + * @dev called by the owner to unpause, returns to normal state + */ + function unpause() onlyOwner whenPaused public { + paused = false; + emit Unpause(); + } +} diff --git a/contracts/token/ERC20/PausableToken.sol b/contracts/token/ERC20/PausableToken.sol index 28c622df5fb..2c32bfe8e9d 100644 --- a/contracts/token/ERC20/PausableToken.sol +++ b/contracts/token/ERC20/PausableToken.sol @@ -1,7 +1,9 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./StandardToken.sol"; -import "../../lifecycle/Pausable.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/StandardToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Pausable.sol"; /** diff --git a/contracts/token/ERC20/RBACMintableToken.sol b/contracts/token/ERC20/RBACMintableToken.sol index 923d2fe3952..beadc445e30 100644 --- a/contracts/token/ERC20/RBACMintableToken.sol +++ b/contracts/token/ERC20/RBACMintableToken.sol @@ -1,7 +1,9 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./MintableToken.sol"; -import "../../ownership/rbac/RBAC.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/MintableToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/rbac/RBAC.sol"; /** diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index 4994ce49c50..ccf68ab0d68 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -1,8 +1,5 @@ -pragma solidity ^0.4.23; - -import "./ERC20Basic.sol"; -import "./ERC20.sol"; - +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.7; /** * @title SafeERC20 diff --git a/contracts/token/ERC20/SafeMath.sol b/contracts/token/ERC20/SafeMath.sol new file mode 100644 index 00000000000..9a76141f105 --- /dev/null +++ b/contracts/token/ERC20/SafeMath.sol @@ -0,0 +1,227 @@ +// SPDX-License-Identifier: MIT License Modern Variant + +pragma solidity ^0.8.0; + +// CAUTION +// This version of SafeMath should only be used with Solidity 0.8 or later, +// because it relies on the compiler's built in overflow checks. + +/** + * @dev Wrappers over Solidity's arithmetic operations. + * + * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler + * now has built in overflow checking. + */ +library SafeMath { + /** + * @dev Returns the addition of two unsigned integers, with an overflow flag. + * + * _Available since v3.4._ + */ + function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { + + unchecked { + uint256 c = a + b; + if (c < a) return (false, 0); + return (true, c); + } + } + + /** + * @dev Returns the substraction of two unsigned integers, with an overflow flag. + * + * _Available since v3.4._ + */ + function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b > a) return (false, 0); + return (true, a - b); + } + } + + /** + * @dev Returns the multiplication of two unsigned integers, with an overflow flag. + * + * _Available since v3.4._ + */ + function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + // Gas optimization: this is cheaper than requiring 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 + if (a == 0) return (true, 0); + uint256 c = a * b; + if (c / a != b) return (false, 0); + return (true, c); + } + } + + /** + * @dev Returns the division of two unsigned integers, with a division by zero flag. + * + * _Available since v3.4._ + */ + function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b == 0) return (false, 0); + return (true, a / b); + } + } + + /** + * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. + * + * _Available since v3.4._ + */ + function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b == 0) return (false, 0); + return (true, a % b); + } + } + + /** + * @dev Returns the addition of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `+` operator. + * + * Requirements: + * + * - Addition cannot overflow. + */ + function add(uint256 a, uint256 b) internal pure returns (uint256) { + return a + b; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return a - b; + } + + /** + * @dev Returns the multiplication of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `*` operator. + * + * Requirements: + * + * - Multiplication cannot overflow. + */ + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + return a * b; + } + + /** + * @dev Returns the integer division of two unsigned integers, reverting on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return a / b; + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * reverting when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + return a % b; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting with custom message on + * overflow (when the result is negative). + * + * CAUTION: This function is deprecated because it requires allocating memory for the error + * message unnecessarily. For custom revert reasons use {trySub}. + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { + unchecked { + require(b <= a, errorMessage); + return a - b; + } + } + + /** + * @dev Returns the integer division of two unsigned integers, reverting with custom message on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { + unchecked { + require(b > 0, errorMessage); + return a / b; + } + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * reverting with custom message when dividing by zero. + * + * CAUTION: This function is deprecated because it requires allocating memory for the error + * message unnecessarily. For custom revert reasons use {tryMod}. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { + unchecked { + require(b > 0, errorMessage); + return a % b; + } + } +} diff --git a/contracts/token/ERC20/StandardBurnableToken.sol b/contracts/token/ERC20/StandardBurnableToken.sol index 94ca1a7882f..9e10e52df55 100644 --- a/contracts/token/ERC20/StandardBurnableToken.sol +++ b/contracts/token/ERC20/StandardBurnableToken.sol @@ -1,7 +1,9 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./BurnableToken.sol"; -import "./StandardToken.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BurnableToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/StandardToken.sol"; /** diff --git a/contracts/token/ERC20/StandardToken.sol b/contracts/token/ERC20/StandardToken.sol index 67310dbc6df..b71c991e864 100644 --- a/contracts/token/ERC20/StandardToken.sol +++ b/contracts/token/ERC20/StandardToken.sol @@ -1,22 +1,47 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: UNLICENSED -import "./BasicToken.sol"; -import "./ERC20.sol"; +pragma solidity ^0.8.7; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; -/** - * @title Standard ERC20 token - * - * @dev Implementation of the basic standard token. - * @dev https://github.com/ethereum/EIPs/issues/20 - * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol - */ -contract StandardToken is ERC20, BasicToken { - - mapping (address => mapping (address => uint256)) internal allowed; +contract BasicToken { + /* *This creates an array with all balancesOf */ + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + + string private _name; + string private _symbol; + uint8 public _decimals; + uint256 private _totalSupply; + + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + + /** + * dev total number of tokens in existence + */ + function totalSupply() public view returns (uint256) { + return _totalSupply; + } + - /** +/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to @@ -27,101 +52,284 @@ contract StandardToken is ERC20, BasicToken { address _to, uint256 _value ) - public - returns (bool) - { + public returns (bool){ require(_to != address(0)); - require(_value <= balances[_from]); - require(_value <= allowed[_from][msg.sender]); - - balances[_from] = balances[_from].sub(_value); - balances[_to] = balances[_to].add(_value); - allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); + emit Transfer(_from, _to, _value); return true; } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address owner) public view returns (uint256) { + return _balances[owner]; + } - /** - * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. - * - * Beware that changing an allowance with this method brings the risk that someone may use both the old - * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this - * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: - * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 - * @param _spender The address which will spend the funds. - * @param _value The amount of tokens to be spent. - */ - function approve(address _spender, uint256 _value) public returns (bool) { - allowed[msg.sender][_spender] = _value; - emit Approval(msg.sender, _spender, _value); - return true; } - /** - * @dev Function to check the amount of tokens that an owner allowed to a spender. - * @param _owner address The address which owns the funds. - * @param _spender address The address which will spend the funds. - * @return A uint256 specifying the amount of tokens still available for the spender. - */ - function allowance( - address _owner, - address _spender - ) - public - view - returns (uint256) - { - return allowed[_owner][_spender]; - } + +pragma solidity ^0.8.7; - /** - * @dev Increase the amount of tokens that an owner allowed to a spender. - * - * approve should be called when allowed[_spender] == 0. To increment - * allowed value is better to use this function to avoid 2 calls (and wait until - * the first transaction is mined) - * From MonolithDAO Token.sol - * @param _spender The address which will spend the funds. - * @param _addedValue The amount of tokens to increase the allowance by. - */ - function increaseApproval( - address _spender, - uint _addedValue - ) - public - returns (bool) - { - allowed[msg.sender][_spender] = ( - allowed[msg.sender][_spender].add(_addedValue)); - emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); - return true; - } +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; - /** - * @dev Decrease the amount of tokens that an owner allowed to a spender. - * - * approve should be called when allowed[_spender] == 0. To decrement - * allowed value is better to use this function to avoid 2 calls (and wait until - * the first transaction is mined) - * From MonolithDAO Token.sol - * @param _spender The address which will spend the funds. - * @param _subtractedValue The amount of tokens to decrease the allowance by. - */ - function decreaseApproval( - address _spender, - uint _subtractedValue - ) - public - returns (bool) - { - uint oldValue = allowed[msg.sender][_spender]; - if (_subtractedValue > oldValue) { - allowed[msg.sender][_spender] = 0; - } else { - allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); - } - emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); - return true; - } + +/** title ERC20 interface + * dev see https://github.com/ethereum/EIPs/issues/20 + * openzeppelin/contracts/utils/Context.sol + * dev Implementation of the {IERC20} interface. + * + * This implementation is agnostic to the way tokens are created. This means + * that a supply mechanism has to be added in a derived contract using {_mint}. + * For a generic mechanism see {ERC20PresetMinterPauser}. + * + * TIP: For a detailed writeup see our guide + * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How + * to implement supply mechanisms]. + * + * We have followed general OpenZeppelin Contracts guidelines: functions revert + * instead returning `false` on failure. This behavior is nonetheless + * conventional and does not conflict with the expectations of ERC20 + * applications. + * + * Additionally, an {Approval} event is emitted on calls to {transferFrom}. + * This allows applications to reconstruct the allowance for all accounts just + * by listening to said events. Other implementations of the EIP may not emit + * these events, as it isn't required by the specification. + * + * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} + * functions have been added to mitigate the well-known issues around setting + * allowances. See {IERC20-approve}. + */ + +contract ERC20 is Context, IERC20, IERC20Metadata { + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + string private _name; + string private _symbol; + uint8 public _decimals; + uint256 private _totalSupply; + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev Returns the name of the token. + */ + function name() public view virtual override returns (string memory) { + return _name; + } + + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + /** + * @dev Returns the number of decimals used to get its user representation. + * For example, if `decimals` equals `2`, a balance of `505` tokens should + * be displayed to a user as `5.05` (`505 / 10 ** 2`). + * + * Tokens usually opt for a value of 18, imitating the relationship between + * Ether and Wei. This is the value {ERC20} uses, unless this function is + * overridden; + * + * NOTE: This information is only used for _display_ purposes: it in + * no way affects any of the arithmetic of the contract, including + * {IERC20-balanceOf} and {IERC20-transfer}. + */ + function decimals() public view virtual override returns (uint8) { + return 18; + } + + /** + * @dev See {IERC20-totalSupply}. + */ + function totalSupply() public view virtual override returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address account) public view virtual override returns (uint256) { + return _balances[account]; + } + + /** + * @dev See {IERC20-transfer}. + * + * Requirements: + * + * - `recipient` cannot be the zero address. + * - the caller must have a balance of at least `amount`. + */ + function transfer(address recipient, uint256 amount) public virtual override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + /** + * @dev See {IERC20-allowance}. + */ + function allowance(address owner, address spender) public view virtual override returns (uint256) { + return _allowances[owner][spender]; + } + + /** + * @dev See {IERC20-approve}. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 amount) public virtual override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + /** + * @dev See {IERC20-transferFrom}. + * + * Emits an {Approval} event indicating the updated allowance. This is not + * required by the EIP. See the note at the beginning of {ERC20}. + * + * Requirements: + * + * - `sender` and `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + * - the caller must have allowance for ``sender``'s tokens of at least + * `amount`. + */ + function transferFrom( + address sender, + address recipient, + uint256 amount + ) public virtual override returns (bool) { + _transfer(sender, recipient, amount); + + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); + + unchecked { + _approve(sender, _msgSender(), currentAllowance - amount); + } + + return true; + } + + /** + * @dev Atomically increases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); + return true; + } + + /** + * @dev Atomically decreases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + * - `spender` must have allowance for the caller of at least + * `subtractedValue`. + */ + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + uint256 currentAllowance = _allowances[_msgSender()][spender]; + require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); + unchecked { + _approve(_msgSender(), spender, currentAllowance - subtractedValue); + } + + return true; + } + + /** + * @dev Moves `amount` of tokens from `sender` to `recipient`. + * + * This internal function is equivalent to {transfer}, and can be used to + * e.g. implement automatic token fees, slashing mechanisms, etc. + * + * Emits a {Transfer} event. + * + * Requirements: + * + * - `sender` cannot be the zero address. + * - `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + */ + function _transfer( + address sender, + address recipient, + uint256 amount + ) internal virtual { + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + + uint256 senderBalance = _balances[sender]; + require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); + unchecked { + _balances[sender] = senderBalance - amount; + } + _balances[recipient] += amount; + + emit Transfer(sender, recipient, amount); + + } + + /** + * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. + * + * This internal function is equivalent to `approve`, and can be used to + * e.g. set automatic allowances for certain subsystems, etc. + * + * Emits an {Approval} event. + * Requirements: + * + * - `owner` cannot be the zero address. + * - `spender` cannot be the zero address. + */ + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } } diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index 8556a533aa7..893beff8667 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -1,6 +1,8 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./SafeERC20.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeERC20.sol"; /** diff --git a/contracts/token/ERC20/TokenVesting.sol b/contracts/token/ERC20/TokenVesting.sol index d078ba998a8..abbb55c455e 100644 --- a/contracts/token/ERC20/TokenVesting.sol +++ b/contracts/token/ERC20/TokenVesting.sol @@ -1,11 +1,12 @@ /* solium-disable security/no-block-members */ +// SPDX-License-Identifier: MIT -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; -import "./ERC20Basic.sol"; -import "./SafeERC20.sol"; -import "../../ownership/Ownable.sol"; -import "../../math/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; /**