-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
a1b3f95
commit 13dac97
Showing
5 changed files
with
199 additions
and
9 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,63 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; | ||
|
||
contract AdminRoleUpgrade { | ||
using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; | ||
|
||
EnumerableSetUpgradeable.AddressSet private _admins; | ||
|
||
event AdminAdded(address indexed account); | ||
event AdminRemoved(address indexed account); | ||
|
||
// constructor() { | ||
// _addAdmin(msg.sender); | ||
// } | ||
|
||
modifier onlyAdmin() { | ||
require( | ||
isAdmin(msg.sender), | ||
"AdminRole: caller does not have the Admin role" | ||
); | ||
_; | ||
} | ||
|
||
function isAdmin(address account) public view returns (bool) { | ||
return _admins.contains(account); | ||
} | ||
|
||
function allAdmins() public view returns (address[] memory admins) { | ||
admins = new address[](_admins.length()); | ||
for (uint256 i = 0; i < _admins.length(); i++) { | ||
admins[i] = _admins.at(i); | ||
} | ||
} | ||
|
||
function batchAddAdmin(address[] memory amounts) public onlyAdmin{ | ||
for(uint256 i=0; i < amounts.length; i++){ | ||
addAdmin(amounts[i]); | ||
} | ||
} | ||
|
||
function addAdmin(address account) public onlyAdmin { | ||
_addAdmin(account); | ||
} | ||
|
||
function removeAdmin(address account) public onlyAdmin { | ||
_removeAdmin(account); | ||
} | ||
|
||
function renounceAdmin() public { | ||
_removeAdmin(msg.sender); | ||
} | ||
|
||
function _addAdmin(address account) internal { | ||
_admins.add(account); | ||
emit AdminAdded(account); | ||
} | ||
|
||
function _removeAdmin(address account) internal { | ||
_admins.remove(account); | ||
emit AdminRemoved(account); | ||
} | ||
} |
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
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,46 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; | ||
import "@openzeppelin/contracts/utils/math/SafeMath.sol"; | ||
import "./AdminRole.sol"; | ||
|
||
|
||
contract INTO is ERC20Burnable, AdminRole { | ||
using SafeMath for uint256; | ||
|
||
constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) | ||
{ | ||
|
||
} | ||
|
||
function decimals() public pure override returns (uint8) { | ||
return 18; | ||
} | ||
|
||
function mint(address recipient_, uint256 amount_) | ||
public | ||
onlyAdmin | ||
returns (bool) | ||
{ | ||
uint256 balanceBefore = balanceOf(recipient_); | ||
_mint(recipient_, amount_); | ||
uint256 balanceAfter = balanceOf(recipient_); | ||
|
||
return balanceAfter > balanceBefore; | ||
} | ||
|
||
function burn(uint256 amount) public override onlyAdmin { | ||
super.burn(amount); | ||
} | ||
|
||
function burnFrom(address account, uint256 amount) | ||
public | ||
override | ||
onlyAdmin | ||
{ | ||
super.burnFrom(account, amount); | ||
} | ||
|
||
} | ||
|
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,8 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; | ||
|
||
contract MyBeacon is UpgradeableBeacon { | ||
constructor(address _implementation, address _admin) UpgradeableBeacon(_implementation, _admin) {} | ||
} |
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,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; | ||
|
||
contract MyProxy is BeaconProxy { | ||
bytes32 internal data; | ||
constructor(address beaconAddress) BeaconProxy(beaconAddress, abi.encodePacked(data)) { | ||
data = keccak256("initialize()"); | ||
} | ||
} |