2017-11-28 03:33:25 +00:00
|
|
|
pragma solidity ^0.4.10;
|
|
|
|
|
|
|
|
import "../common/Controlled.sol";
|
|
|
|
import "./DelegationProxyFactory.sol";
|
|
|
|
import "./DelegationProxy.sol";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @title TrustNetwork
|
|
|
|
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
|
|
|
* Defines two contolled DelegationProxy chains: vote and veto chains.
|
|
|
|
* New layers need to be defined under a unique topic address topic, and all fall back to root topic (topic 0x0)
|
|
|
|
*/
|
|
|
|
contract TrustNetwork is Controlled {
|
2018-03-17 01:55:57 +00:00
|
|
|
mapping (bytes32 => Topic) topics;
|
2017-11-28 03:33:25 +00:00
|
|
|
DelegationProxyFactory delegationFactory;
|
|
|
|
|
|
|
|
struct Topic {
|
|
|
|
DelegationProxy voteProxy;
|
|
|
|
DelegationProxy vetoProxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
function TrustNetwork(address _delegationFactory) public {
|
|
|
|
delegationFactory = DelegationProxyFactory(_delegationFactory);
|
|
|
|
topics[0x0] = newTopic(0x0, 0x0);
|
|
|
|
}
|
|
|
|
|
2018-03-17 01:55:57 +00:00
|
|
|
function addTopic(bytes32 topicId, bytes32 parentTopic) public onlyController {
|
2017-11-28 03:33:25 +00:00
|
|
|
Topic memory parent = topics[parentTopic];
|
|
|
|
address vote = address(parent.voteProxy);
|
|
|
|
address veto = address(parent.vetoProxy);
|
|
|
|
require(vote != 0x0);
|
|
|
|
require(veto != 0x0);
|
|
|
|
|
|
|
|
Topic storage topic = topics[topicId];
|
|
|
|
require(address(topic.voteProxy) == 0x0);
|
|
|
|
require(address(topic.vetoProxy) == 0x0);
|
|
|
|
|
|
|
|
|
|
|
|
topics[topicId] = newTopic(vote, veto);
|
|
|
|
}
|
|
|
|
|
2018-03-17 01:55:57 +00:00
|
|
|
function getTopic(bytes32 _topicId) public constant returns (DelegationProxy vote, DelegationProxy veto) {
|
2017-11-28 03:33:25 +00:00
|
|
|
Topic memory topic = topics[_topicId];
|
|
|
|
vote = topic.voteProxy;
|
|
|
|
veto = topic.vetoProxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
function newTopic(address _vote, address _veto) internal returns (Topic topic) {
|
|
|
|
topic = Topic ({
|
|
|
|
voteProxy: delegationFactory.create(_vote),
|
|
|
|
vetoProxy: delegationFactory.create(_veto)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|