From cf99ee5b6ab48cb36802cdc7a62c115e512b7443 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt Date: Thu, 28 Mar 2019 19:09:21 -0300 Subject: [PATCH] support controller init and modifiers for model access. --- .../democracy/delegation/DelegationInit.sol | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/contracts/democracy/delegation/DelegationInit.sol b/contracts/democracy/delegation/DelegationInit.sol index a6ddad6..1a30567 100644 --- a/contracts/democracy/delegation/DelegationInit.sol +++ b/contracts/democracy/delegation/DelegationInit.sol @@ -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) {} } \ No newline at end of file