mirror of
https://github.com/status-im/topic-democracy.git
synced 2025-02-25 00:28:19 +00:00
proposal manager executes to its controller
This commit is contained in:
parent
c07850d068
commit
9382b4d359
@ -1,10 +1,12 @@
|
|||||||
pragma solidity ^0.4.10;
|
pragma solidity ^0.4.17;
|
||||||
|
|
||||||
import "./TrustNetwork.sol";
|
import "./TrustNetwork.sol";
|
||||||
import "./DelegationProxy.sol";
|
import "./DelegationProxy.sol";
|
||||||
|
import "./ProposalExecutor.sol";
|
||||||
import "../token/MiniMeToken.sol";
|
import "../token/MiniMeToken.sol";
|
||||||
import "../common/Controlled.sol";
|
import "../common/Controlled.sol";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title ProposalManager
|
* @title ProposalManager
|
||||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
||||||
@ -16,12 +18,11 @@ contract ProposalManager is Controlled {
|
|||||||
MiniMeToken public SNT;
|
MiniMeToken public SNT;
|
||||||
address public stakeBank;
|
address public stakeBank;
|
||||||
|
|
||||||
Proposal[] proposals;
|
Proposal[] proposals;
|
||||||
|
|
||||||
struct Proposal {
|
struct Proposal {
|
||||||
address topic;
|
address topic;
|
||||||
|
|
||||||
address destination;
|
|
||||||
uint value;
|
uint value;
|
||||||
bytes data;
|
bytes data;
|
||||||
uint stake;
|
uint stake;
|
||||||
@ -59,14 +60,13 @@ contract ProposalManager is Controlled {
|
|||||||
stakeBank = _stakeBank;
|
stakeBank = _stakeBank;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addProposal(address topic, address destination, uint value, bytes data, uint stake) returns (uint) {
|
function addProposal(address topic, uint value, bytes data, uint stake) public returns (uint) {
|
||||||
require(stake > 1000);
|
require(stake > 1000);
|
||||||
require(SNT.transferFrom(msg.sender, stakeBank, stake));
|
require(SNT.transferFrom(msg.sender, stakeBank, stake));
|
||||||
uint pos = proposals.length++;
|
uint pos = proposals.length++;
|
||||||
Proposal storage p = proposals[pos];
|
Proposal storage p = proposals[pos];
|
||||||
|
|
||||||
p.topic = topic;
|
p.topic = topic;
|
||||||
p.destination = destination;
|
|
||||||
p.value = value;
|
p.value = value;
|
||||||
p.data = data;
|
p.data = data;
|
||||||
p.stake = stake;
|
p.stake = stake;
|
||||||
@ -78,20 +78,22 @@ contract ProposalManager is Controlled {
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProposal(uint id) public constant returns (address topic, address destination, uint value, uint stake, bool approved, bool executed) {
|
function getProposal(uint id) public constant returns (address topic, uint value, uint stake, bool approved, bool executed) {
|
||||||
Proposal memory p = proposals[id];
|
Proposal memory p = proposals[id];
|
||||||
return (p.topic, p.destination, p.value, p.stake, p.approved, p.executed);
|
return (p.topic, p.value, p.stake, p.approved, p.executed);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProposalData(uint id) public constant returns(bytes){
|
function getProposalData(uint id) public constant returns(bytes) {
|
||||||
return proposals[id].data;
|
return proposals[id].data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setExecuted(uint id) public onlyController {
|
function execute(uint id) public {
|
||||||
|
Proposal memory p = proposals[id];
|
||||||
proposals[id].executed = true;
|
proposals[id].executed = true;
|
||||||
|
ProposalExecutor(controller).executeProposal(p.topic, p.value, p.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function vote(uint _proposal, Vote _vote) {
|
function vote(uint _proposal, Vote _vote) public {
|
||||||
Proposal storage proposal = proposals[_proposal];
|
Proposal storage proposal = proposals[_proposal];
|
||||||
require(block.number >= proposal.blockStart);
|
require(block.number >= proposal.blockStart);
|
||||||
if (_vote == Vote.Veto) {
|
if (_vote == Vote.Veto) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user