Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Roles #84

Merged
merged 3 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions contracts/MeToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,38 @@ pragma solidity ^0.8.0;
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";

import "./Roles.sol";

/// @title meToken
/// @author Carl Farterson (@carlfarterson)
/// @notice Base erc20-like meToken contract used for all meTokens
contract MeToken is Initializable, ERC20Burnable {
contract MeToken is ERC20Burnable {
string public version;
address public foundry;
address public meTokenRegistry;

constructor(string memory _name, string memory _symbol)
ERC20(_name, _symbol)
{
constructor(
string memory _name,
string memory _symbol,
address _foundry,
address _meTokenRegistry
) ERC20(_name, _symbol) {
version = "0.2";
foundry = _foundry;
meTokenRegistry = _meTokenRegistry;
}

function mint(address to, uint256 amount) external {
/* require(
hasRole(FOUNDRY, msg.sender) ||
hasRole(METOKEN_REGISTRY, msg.sender)
); */
require(
msg.sender == foundry || msg.sender == meTokenRegistry,
"!authorized"
);
_mint(to, amount);
}

function burn(address from, uint256 value) external {
/* require(
hasRole(FOUNDRY, msg.sender) ||
hasRole(METOKEN_REGISTRY, msg.sender)
); */
require(
msg.sender == foundry || msg.sender == meTokenRegistry,
"!authorized"
);
_burn(from, value);
}
}
17 changes: 7 additions & 10 deletions contracts/MeTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@ pragma solidity ^0.8.0;

import "./MeToken.sol";

// import "../Roles.sol";

/// @title meToken factory
/// @author Carl Farterson (@carlfarterson)
/// @notice This contract creates and deploys a users' meToken
contract MeTokenFactory {
/// @notice create a meToken
/// @param _name name of meToken
/// @param _symbol symbol of meToken
function create(string calldata _name, string calldata _symbol)
external
returns (address)
{
// TODO: access control
// require(hasRole(METOKEN_REGISTRY, msg.sender), "!meTokenRegistry");

function create(
string calldata _name,
string calldata _symbol,
address _foundry,
address _meTokenRegistry
) external returns (address) {
// Create our meToken
MeToken erc20 = new MeToken(_name, _symbol);
MeToken erc20 = new MeToken(_name, _symbol, _foundry, _meTokenRegistry);
return address(erc20);
}
}
26 changes: 0 additions & 26 deletions contracts/Roles.sol

This file was deleted.

9 changes: 6 additions & 3 deletions contracts/interfaces/IMeTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
pragma solidity ^0.8.0;

interface IMeTokenFactory {
function create(string calldata name, string calldata symbol)
external
returns (address);
function create(
string calldata name,
string calldata symbol,
address foundry,
address meTokenRegistry
) external returns (address);
}
7 changes: 6 additions & 1 deletion contracts/registries/MeTokenRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ contract MeTokenRegistry is Ownable, IMeTokenRegistry {
}

// Create meToken erc20 contract
address meTokenAddr = meTokenFactory.create(_name, _symbol);
address meTokenAddr = meTokenFactory.create(
_name,
_symbol,
foundry,
address(this)
);

// Mint meToken to user
uint256 _meTokensMinted;
Expand Down