add default delegation
This commit is contained in:
parent
c0dd83187d
commit
941ea8f049
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ pragma solidity >=0.5.0 <0.6.0;
|
|||
|
||||
import "../token/MiniMeToken.sol";
|
||||
import "./DelegationFactory.sol";
|
||||
import "./DefaultDelegation.sol";
|
||||
import "./TrustNetwork.sol";
|
||||
import "./ProposalCuration.sol";
|
||||
import "./ProposalManager.sol";
|
||||
|
@ -23,7 +24,7 @@ contract Democracy {
|
|||
|
||||
constructor(MiniMeToken _token, DelegationFactory _DelegationFactory) public {
|
||||
token = _token;
|
||||
trustNet = new TrustNetwork(_DelegationFactory);
|
||||
trustNet = new TrustNetwork(_DelegationFactory, new DefaultDelegation());
|
||||
proposalManager = new ProposalCuration(_token, trustNet).proposalManager();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ contract TrustNetwork is TrustNetworkInterface, Controlled {
|
|||
Delegation vetoDelegation;
|
||||
}
|
||||
|
||||
constructor(DelegationFactory _delegationFactory) public {
|
||||
constructor(DelegationFactory _delegationFactory, Delegation defaultDelegation) public {
|
||||
delegationFactory = _delegationFactory;
|
||||
topics[bytes32(0)] = newTopic(address(0), address(0));
|
||||
topics[bytes32(0)] = newTopic(defaultDelegation, defaultDelegation);
|
||||
}
|
||||
|
||||
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 ({
|
||||
voteDelegation: Delegation(address(delegationFactory.createDelegation(_vote))),
|
||||
vetoDelegation: Delegation(address(delegationFactory.createDelegation(_veto)))
|
||||
voteDelegation: Delegation(address(delegationFactory.createDelegation(address(_vote)))),
|
||||
vetoDelegation: Delegation(address(delegationFactory.createDelegation(address(_vote))))
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue