|
|
@ -49,7 +49,7 @@ Source code on the left, compiled code and AST on the right (or error). |
|
|
|
<div id="input"> contract Ballot { |
|
|
|
<div id="input"> contract Ballot { |
|
|
|
// Create a new ballot with $(_numProposals) different proposals. |
|
|
|
// Create a new ballot with $(_numProposals) different proposals. |
|
|
|
function Ballot(uint8 _numProposals) { |
|
|
|
function Ballot(uint8 _numProposals) { |
|
|
|
address sender = 0x123; // msg.sender |
|
|
|
address sender = msg.sender; |
|
|
|
chairperson = sender; |
|
|
|
chairperson = sender; |
|
|
|
numProposals = _numProposals; |
|
|
|
numProposals = _numProposals; |
|
|
|
} |
|
|
|
} |
|
|
@ -57,13 +57,13 @@ Source code on the left, compiled code and AST on the right (or error). |
|
|
|
// Give $(voter) the right to vote on this ballot. |
|
|
|
// Give $(voter) the right to vote on this ballot. |
|
|
|
// May only be called by $(chairperson). |
|
|
|
// May only be called by $(chairperson). |
|
|
|
function giveRightToVote(address voter) { |
|
|
|
function giveRightToVote(address voter) { |
|
|
|
if (/*msg.sender != chairperson ||*/ voted[voter]) return; |
|
|
|
if (msg.sender != chairperson || voted[voter]) return; |
|
|
|
voterWeight[voter] = 1; |
|
|
|
voterWeight[voter] = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Delegate your vote to the voter $(to). |
|
|
|
// Delegate your vote to the voter $(to). |
|
|
|
function delegate(address to) { |
|
|
|
function delegate(address to) { |
|
|
|
address sender = 0x123; // msg.sender |
|
|
|
address sender = msg.sender; |
|
|
|
if (voted[sender]) return; |
|
|
|
if (voted[sender]) return; |
|
|
|
while (delegations[to] != address(0) && delegations[to] != sender) |
|
|
|
while (delegations[to] != address(0) && delegations[to] != sender) |
|
|
|
to = delegations[to]; |
|
|
|
to = delegations[to]; |
|
|
@ -76,7 +76,7 @@ Source code on the left, compiled code and AST on the right (or error). |
|
|
|
|
|
|
|
|
|
|
|
// Give a single vote to proposal $(proposal). |
|
|
|
// Give a single vote to proposal $(proposal). |
|
|
|
function vote(uint8 proposal) { |
|
|
|
function vote(uint8 proposal) { |
|
|
|
address sender = 0x123; // msg.sender |
|
|
|
address sender = msg.sender; |
|
|
|
if (voted[sender] || proposal >= numProposals) return; |
|
|
|
if (voted[sender] || proposal >= numProposals) return; |
|
|
|
voted[sender] = true; |
|
|
|
voted[sender] = true; |
|
|
|
votes[sender] = proposal; |
|
|
|
votes[sender] = proposal; |
|
|
|