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:
+30
@@ -0,0 +1,30 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/presets/ERC20PresetFixedSupply.sol)
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../extensions/ERC20Burnable.sol";
|
||||
|
||||
/**
|
||||
* @dev {ERC20} token, including:
|
||||
*
|
||||
* - Preminted initial supply
|
||||
* - Ability for holders to burn (destroy) their tokens
|
||||
* - No access control mechanism (for minting/pausing) and hence no governance
|
||||
*
|
||||
* This contract uses {ERC20Burnable} to include burn capabilities - head to
|
||||
* its documentation for details.
|
||||
*
|
||||
* _Available since v3.4._
|
||||
*
|
||||
* _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._
|
||||
*/
|
||||
contract ERC20PresetFixedSupply is ERC20Burnable {
|
||||
/**
|
||||
* @dev Mints `initialSupply` amount of token and transfers them to `owner`.
|
||||
*
|
||||
* See {ERC20-constructor}.
|
||||
*/
|
||||
constructor(string memory name, string memory symbol, uint256 initialSupply, address owner) ERC20(name, symbol) {
|
||||
_mint(owner, initialSupply);
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/presets/ERC20PresetMinterPauser.sol)
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../ERC20.sol";
|
||||
import "../extensions/ERC20Burnable.sol";
|
||||
import "../extensions/ERC20Pausable.sol";
|
||||
import "../../../access/AccessControlEnumerable.sol";
|
||||
import "../../../utils/Context.sol";
|
||||
|
||||
/**
|
||||
* @dev {ERC20} token, including:
|
||||
*
|
||||
* - ability for holders to burn (destroy) their tokens
|
||||
* - a minter role that allows for token minting (creation)
|
||||
* - a pauser role that allows to stop all token transfers
|
||||
*
|
||||
* This contract uses {AccessControl} to lock permissioned functions using the
|
||||
* different roles - head to its documentation for details.
|
||||
*
|
||||
* The account that deploys the contract will be granted the minter and pauser
|
||||
* roles, as well as the default admin role, which will let it grant both minter
|
||||
* and pauser roles to other accounts.
|
||||
*
|
||||
* _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._
|
||||
*/
|
||||
contract ERC20PresetMinterPauser is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable {
|
||||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
|
||||
|
||||
/**
|
||||
* @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the
|
||||
* account that deploys the contract.
|
||||
*
|
||||
* See {ERC20-constructor}.
|
||||
*/
|
||||
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
|
||||
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
|
||||
|
||||
_setupRole(MINTER_ROLE, _msgSender());
|
||||
_setupRole(PAUSER_ROLE, _msgSender());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Creates `amount` new tokens for `to`.
|
||||
*
|
||||
* See {ERC20-_mint}.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - the caller must have the `MINTER_ROLE`.
|
||||
*/
|
||||
function mint(address to, uint256 amount) public virtual {
|
||||
require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint");
|
||||
_mint(to, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Pauses all token transfers.
|
||||
*
|
||||
* See {ERC20Pausable} and {Pausable-_pause}.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - the caller must have the `PAUSER_ROLE`.
|
||||
*/
|
||||
function pause() public virtual {
|
||||
require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause");
|
||||
_pause();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Unpauses all token transfers.
|
||||
*
|
||||
* See {ERC20Pausable} and {Pausable-_unpause}.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - the caller must have the `PAUSER_ROLE`.
|
||||
*/
|
||||
function unpause() public virtual {
|
||||
require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause");
|
||||
_unpause();
|
||||
}
|
||||
|
||||
function _beforeTokenTransfer(
|
||||
address from,
|
||||
address to,
|
||||
uint256 amount
|
||||
) internal virtual override(ERC20, ERC20Pausable) {
|
||||
super._beforeTokenTransfer(from, to, amount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Contract presets are now deprecated in favor of [Contracts Wizard](https://wizard.openzeppelin.com/) as a more powerful alternative.
|
||||
Reference in New Issue
Block a user