mirror of
https://github.com/th30d4y/OpenLearnX.git
synced 2026-05-27 03:36:32 +00:00
Fix .gitignore: stop tracking ignored files
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Capped.sol)
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../ERC20.sol";
|
||||
|
||||
/**
|
||||
* @dev Extension of {ERC20} that adds a cap to the supply of tokens.
|
||||
*/
|
||||
abstract contract ERC20Capped is ERC20 {
|
||||
uint256 private immutable _cap;
|
||||
|
||||
/**
|
||||
* @dev Sets the value of the `cap`. This value is immutable, it can only be
|
||||
* set once during construction.
|
||||
*/
|
||||
constructor(uint256 cap_) {
|
||||
require(cap_ > 0, "ERC20Capped: cap is 0");
|
||||
_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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user