Update example contract functions with default visibility (public) to avoid initial compiler warnings

pull/1/head
holgerd77 7 years ago
parent ec522a1e61
commit d1883d7e4b
  1. 10
      src/app/editor/example-contracts.js

@ -18,7 +18,7 @@ contract Ballot {
Proposal[] proposals; Proposal[] proposals;
/// Create a new ballot with $(_numProposals) different proposals. /// Create a new ballot with $(_numProposals) different proposals.
function Ballot(uint8 _numProposals) { function Ballot(uint8 _numProposals) public {
chairperson = msg.sender; chairperson = msg.sender;
voters[chairperson].weight = 1; voters[chairperson].weight = 1;
proposals.length = _numProposals; proposals.length = _numProposals;
@ -26,13 +26,13 @@ contract Ballot {
/// 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) public {
if (msg.sender != chairperson || voters[voter].voted) return; if (msg.sender != chairperson || voters[voter].voted) return;
voters[voter].weight = 1; voters[voter].weight = 1;
} }
/// Delegate your vote to the voter $(to). /// Delegate your vote to the voter $(to).
function delegate(address to) { function delegate(address to) public {
Voter storage sender = voters[msg.sender]; // assigns reference Voter storage sender = voters[msg.sender]; // assigns reference
if (sender.voted) return; if (sender.voted) return;
while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender) while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender)
@ -48,7 +48,7 @@ contract Ballot {
} }
/// Give a single vote to proposal $(proposal). /// Give a single vote to proposal $(proposal).
function vote(uint8 proposal) { function vote(uint8 proposal) public {
Voter storage sender = voters[msg.sender]; Voter storage sender = voters[msg.sender];
if (sender.voted || proposal >= proposals.length) return; if (sender.voted || proposal >= proposals.length) return;
sender.voted = true; sender.voted = true;
@ -56,7 +56,7 @@ contract Ballot {
proposals[proposal].voteCount += sender.weight; proposals[proposal].voteCount += sender.weight;
} }
function winningProposal() constant returns (uint8 _winningProposal) { function winningProposal() public constant returns (uint8 _winningProposal) {
uint256 winningVoteCount = 0; uint256 winningVoteCount = 0;
for (uint8 proposal = 0; proposal < proposals.length; proposal++) for (uint8 proposal = 0; proposal < proposals.length; proposal++)
if (proposals[proposal].voteCount > winningVoteCount) { if (proposals[proposal].voteCount > winningVoteCount) {

Loading…
Cancel
Save