add default delegation

This commit is contained in:
Ricardo Guilherme Schmidt 2019-02-20 04:54:14 -03:00
parent c0dd83187d
commit 941ea8f049
No known key found for this signature in database
GPG Key ID: 3F95A3AD0B607030
3 changed files with 66 additions and 6 deletions

View File

@ -0,0 +1,59 @@
pragma solidity >=0.5.0 <0.6.0;
import "./Delegation.sol";
import "../common/Controlled.sol";
contract DefaultDelegation is Delegation, Controlled {
address public defaultDelegate;
constructor(address _defaultDelegate) public {
defaultDelegate = _defaultDelegate;
}
/**
* @notice Changes default delegation
* @param _to What is the default delegate.
*/
function delegate(address _to) external onlyController {
defaultDelegate = _to;
}
function delegatedTo(address)
external
view
returns (address directDelegate)
{
return defaultDelegate;
}
function delegationOf(address)
external
view
returns(address finalDelegate)
{
return defaultDelegate;
}
function delegatedToAt(
address,
uint
)
external
view
returns (address directDelegate)
{
return defaultDelegate;
}
function delegationOfAt(
address,
uint
)
external
view
returns(address finalDelegate)
{
return defaultDelegate;
}
}

View File

@ -2,6 +2,7 @@ pragma solidity >=0.5.0 <0.6.0;
import "../token/MiniMeToken.sol"; import "../token/MiniMeToken.sol";
import "./DelegationFactory.sol"; import "./DelegationFactory.sol";
import "./DefaultDelegation.sol";
import "./TrustNetwork.sol"; import "./TrustNetwork.sol";
import "./ProposalCuration.sol"; import "./ProposalCuration.sol";
import "./ProposalManager.sol"; import "./ProposalManager.sol";
@ -23,7 +24,7 @@ contract Democracy {
constructor(MiniMeToken _token, DelegationFactory _DelegationFactory) public { constructor(MiniMeToken _token, DelegationFactory _DelegationFactory) public {
token = _token; token = _token;
trustNet = new TrustNetwork(_DelegationFactory); trustNet = new TrustNetwork(_DelegationFactory, new DefaultDelegation());
proposalManager = new ProposalCuration(_token, trustNet).proposalManager(); proposalManager = new ProposalCuration(_token, trustNet).proposalManager();
} }

View File

@ -21,9 +21,9 @@ contract TrustNetwork is TrustNetworkInterface, Controlled {
Delegation vetoDelegation; Delegation vetoDelegation;
} }
constructor(DelegationFactory _delegationFactory) public { constructor(DelegationFactory _delegationFactory, Delegation defaultDelegation) public {
delegationFactory = _delegationFactory; delegationFactory = _delegationFactory;
topics[bytes32(0)] = newTopic(address(0), address(0)); topics[bytes32(0)] = newTopic(defaultDelegation, defaultDelegation);
} }
function addTopic(bytes32 topicId, bytes32 parentTopic) public onlyController { function addTopic(bytes32 topicId, bytes32 parentTopic) public onlyController {
@ -67,10 +67,10 @@ contract TrustNetwork is TrustNetworkInterface, Controlled {
} }
function newTopic(address _vote, address _veto) internal returns (Topic memory topic) { function newTopic(Delegation _vote, Delegation _veto) internal returns (Topic memory topic) {
topic = Topic ({ topic = Topic ({
voteDelegation: Delegation(address(delegationFactory.createDelegation(_vote))), voteDelegation: Delegation(address(delegationFactory.createDelegation(address(_vote)))),
vetoDelegation: Delegation(address(delegationFactory.createDelegation(_veto))) vetoDelegation: Delegation(address(delegationFactory.createDelegation(address(_vote))))
}); });
} }