generated from vacp2p/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
822 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.18; | ||
abstract contract ApproveAndCallFallBack { | ||
function receiveApproval(address from, uint256 _amount, address _token, bytes memory _data) virtual public; | ||
} |
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,28 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.18; | ||
|
||
contract Controlled { | ||
string internal constant ERR_BAD_PARAMETER = "Bad parameter"; | ||
string internal constant ERR_UNAUTHORIZED = "Unauthorized"; | ||
event NewController(address controller); | ||
/// @notice The address of the controller is the only address that can call | ||
/// a function with this modifier | ||
modifier onlyController { | ||
require(msg.sender == controller, "Unauthorized"); | ||
_; | ||
} | ||
|
||
address public controller; | ||
|
||
constructor(address _initController) { | ||
require(_initController != address(0), ERR_BAD_PARAMETER); | ||
controller = _initController; | ||
} | ||
|
||
/// @notice Changes the controller of the contract | ||
/// @param _newController The new controller of the contract | ||
function changeController(address _newController) public onlyController { | ||
controller = _newController; | ||
emit NewController(_newController); | ||
} | ||
} |
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,90 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.18; | ||
/* | ||
Copyright 2016, Jordi Baylina | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
/** | ||
* @title MiniMeToken Contract | ||
* @author Jordi Baylina | ||
* @dev This token contract's goal is to make it easy for anyone to clone this | ||
* token using the token distribution at a given block, this will allow DAO's | ||
* and DApps to upgrade their features in a decentralized manner without | ||
* affecting the original token | ||
* @dev It is ERC20 compliant, but still needs to under go further testing. | ||
*/ | ||
|
||
import "./MiniMeTokenCore.sol"; | ||
|
||
/** | ||
* @dev The actual token contract, the default controller is the msg.sender | ||
* that deploys the contract, so usually this token will be deployed by a | ||
* token controller contract, which Giveth will call a "Campaign" | ||
*/ | ||
contract MiniMeToken is MiniMeTokenCore { | ||
|
||
constructor( | ||
address _tokenFactory, | ||
address payable _parentToken, | ||
uint _parentSnapShotBlock, | ||
string memory _tokenName, | ||
uint8 _decimalUnits, | ||
string memory _tokenSymbol, | ||
bool _transfersEnabled | ||
) MiniMeTokenCore(_tokenFactory, _parentToken, _parentSnapShotBlock, _tokenName, _decimalUnits, _tokenSymbol, _transfersEnabled) Semver(1, 0, 1) { | ||
|
||
} | ||
|
||
//////////////// | ||
// Generate and destroy tokens | ||
//////////////// | ||
|
||
/** | ||
* @notice Generates `_amount` tokens that are assigned to `_owner` | ||
* @param _owner The address that will be assigned the new tokens | ||
* @param _amount The quantity of tokens generated | ||
* @return True if the tokens are generated correctly | ||
*/ | ||
function generateTokens( | ||
address _owner, | ||
uint _amount | ||
) | ||
public | ||
onlyController | ||
returns (bool) | ||
{ | ||
_mint(_owner, _amount); | ||
return true; | ||
} | ||
|
||
/** | ||
* @notice Burns `_amount` tokens from `_owner` | ||
* @param _owner The address that will lose the tokens | ||
* @param _amount The quantity of tokens to burn | ||
* @return True if the tokens are burned correctly | ||
*/ | ||
function destroyTokens( | ||
address _owner, | ||
uint _amount | ||
) | ||
public | ||
onlyController | ||
returns (bool) | ||
{ | ||
_burn(_owner, _amount); | ||
return true; | ||
} | ||
|
||
} |
Oops, something went wrong.