support controller init and modifiers for model access.

This commit is contained in:
Ricardo Guilherme Schmidt 2019-03-28 19:09:21 -03:00
parent fe7e4cdf7e
commit cf99ee5b6a
No known key found for this signature in database
GPG Key ID: BFB3F5C8ED618A94
1 changed files with 25 additions and 10 deletions

View File

@ -5,35 +5,50 @@ import "./DelegationAbstract.sol";
/**
* @title DelegationInit
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
* @notice Initialization Model for Delegation. Is library of functions to initialize instance as Delegation.
*/
contract DelegationInit is DelegationAbstract {
modifier notInModel { //avoids control of Init contract
require(address(parentDelegation) == address(0), "Bad call");
_;
}
modifier notImplemented {
revert("Wrong model");
_;
}
/**
* @notice Constructor of the model - only knows about watchdog that can trigger upgrade
* @notice Constructor of the model
*/
constructor() public {
parentDelegation = Delegation(address(-1)); //avoids calling create delegation within the Init contract.
}
/**
* @notice Creates a new Delegation with `_parentDelegation` as default delegation.
* @notice Creates a new Delegation with parent as `_parentDelegation`
* @param _parentDelegation lookup delegation of unset users
*/
function createDelegation(Delegation _parentDelegation) external {
require(address(parentDelegation) == address(0), "Bad call"); //avoids control of Init contract
function createDelegation(Delegation _parentDelegation) external notInModel {
parentDelegation = _parentDelegation;
}
/**
* @notice Creates a new Delegation with `_parentDelegation` as default delegation.
*/
function createDelegation(Delegation _parentDelegation, address defaultDelegate) external {
require(address(parentDelegation) == address(0), "Bad call"); //avoids control of Init contract
function createDelegation(
Delegation _parentDelegation,
address payable _controller,
address _defaultDelegate
) external notInModel {
controller = _controller;
parentDelegation = _parentDelegation;
updateDelegate(address(0), defaultDelegate);
updateDelegate(address(0), _defaultDelegate);
}
function delegate(address) external {}
function delegatedTo(address) external view returns (address) {}
function delegatedToAt(address,uint) external view returns (address) {}
function delegate(address) external notImplemented {}
function delegatedTo(address) external view notImplemented returns (address) {}
function delegatedToAt(address,uint) external view notImplemented returns (address) {}
}