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

add dictator.sol #752

Merged
merged 3 commits into from
May 25, 2020
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
36 changes: 36 additions & 0 deletions contracts/schemes/Dictator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pragma solidity ^0.5.17;

import "../controller/Avatar.sol";
import "../controller/Controller.sol";
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/ownership/Ownable.sol";

/**
* @title A scheme for register other scheme with full permission.
*/

contract Dictator is Initializable, Ownable {

Avatar public avatar;

/**
* @dev registerScheme
* @param _scheme the scheme to register (with full permission)
*/
function registerScheme(address _scheme) external onlyOwner {
//register a scheme with full permission :)
require(Controller(avatar.owner()).registerScheme(_scheme, 0x0000001f), "Fail to register scheme");
}

/**
* @dev _initialize
* @param _avatar the scheme avatar
* @param _owner the contract owner
*/
function initialize(Avatar _avatar, address _owner) public initializer {
Copy link
Contributor

@ben-kaufman ben-kaufman May 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not register the owner as admin right away in the initialize and then unregister self?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the initialize function is called as the process of instance the scheme before the scheme is registered .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, so nevermind

require(address(_avatar) != address(0), "Scheme must have avatar");
Ownable.initialize(_owner);
avatar = _avatar;
}

}
Loading