-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#13 erc20 timed mint
- Loading branch information
Showing
7 changed files
with
22,667 additions
and
10,624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,60 @@ | ||
//SPDX-License-Identifier: Unlicense | ||
pragma solidity 0.8.6; | ||
//SPDX-License-Identifier: Unlicensed | ||
|
||
import "./@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
pragma solidity ^0.8.6; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
/** | ||
* @title ERC20TimedMint | ||
* @author Javier Gonzalez | ||
* @author Javier Gonzalez and Marco Huberts | ||
* @dev Implementation of minting functionality for a mintable token. | ||
* @notice ERC20TimedMint inherits the ERC20 functionality and prevents | ||
* minting within a timeframe. | ||
*/ | ||
contract ERC20TimedMint is ERC20 { | ||
uint256 timeUntilNexMint | ||
* @notice ERC20TimedMint inherits the ERC20 functionality and prevents | ||
* minting within a timeframe. | ||
*/ | ||
contract Erc20TimedMint is ERC20 { | ||
|
||
constructor( | ||
uint256 public timeUntilNextMint; | ||
uint256 public mintCap; | ||
uint256 public timeDelay; | ||
bool public timeDelayActive = false; | ||
|
||
constructor ( | ||
string memory name, | ||
string memory symbol, | ||
uint256 _timeDelay | ||
) ERC20(name, symbol) { | ||
timeUntilNexMint = block.timeStamp + _timeDelay | ||
string memory symbol | ||
) | ||
ERC20(name, symbol) | ||
{ | ||
|
||
} | ||
|
||
function _mint(address to, uint256 amount) | ||
internal | ||
override(ERC20) | ||
{ | ||
if(timeDelayActive) { | ||
require(block.timestamp >= timeUntilNextMint, "ERC20: Cannot mint yet"); | ||
require(amount <= mintCap, "ERC20: Mint exceeds maximum amount"); | ||
_setNextMintTime(); | ||
} | ||
super._mint(to, amount); | ||
} | ||
/** | ||
* @dev Function has no guards against setting multiple time delays | ||
* in one minting period | ||
*/ | ||
function _setTimeDelay(uint256 _timeDelay) internal { | ||
require(_timeDelay > 0, "time delay must be greater than zero"); | ||
timeDelay = _timeDelay; | ||
_setNextMintTime(); | ||
if(!timeDelayActive) { | ||
timeDelayActive = true; | ||
} | ||
} | ||
|
||
function _setNextMintTime() internal { | ||
timeUntilNextMint = block.timestamp + timeDelay; | ||
} | ||
|
||
function _setMintCap(uint256 _mintCap) internal { | ||
mintCap = _mintCap; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//SPDX-License-Identifier: Unlicense | ||
|
||
pragma solidity ^0.8.6; | ||
|
||
import "./Erc20TimedMint.sol"; | ||
|
||
/** | ||
* @title ERC20TimedMint | ||
* @author Javier Gonzalez and Marco Huberts | ||
* @dev Implementation of minting functionality for a mintable token. | ||
* @notice ExposedTimedMint inherits the Erc20TimedMint functionality | ||
* and prevents minting within a timeframe. | ||
*/ | ||
|
||
contract ExposedTimedMint is Erc20TimedMint { | ||
|
||
constructor ( | ||
string memory _name, | ||
string memory _symbol | ||
) | ||
Erc20TimedMint(_name, _symbol) | ||
{ | ||
|
||
} | ||
|
||
function mint(address to, uint256 amount) public { | ||
return _mint(to, amount); | ||
} | ||
|
||
function setTimeDelay(uint256 _timeDelay) public { | ||
return _setTimeDelay(_timeDelay); | ||
} | ||
|
||
function setNextMintTime() public { | ||
return _setNextMintTime(); | ||
} | ||
|
||
function setMintCap(uint256 _mintCap) public { | ||
return _setMintCap(_mintCap); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.