Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
d3487207
Commit
d3487207
authored
Sep 27, 2017
by
yann300
Committed by
GitHub
Sep 27, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #832 from holgerd77/fix-example-contract
Example Contract - Fix compiler warnings / reduce static analysis warning
parents
ec522a1e
82cdfd45
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
example-contracts.js
src/app/editor/example-contracts.js
+16
-16
No files found.
src/app/editor/example-contracts.js
View file @
d3487207
...
...
@@ -18,21 +18,21 @@ contract Ballot {
Proposal[] proposals;
/// Create a new ballot with $(_numProposals) different proposals.
function Ballot(uint8 _numProposals) {
function Ballot(uint8 _numProposals)
public
{
chairperson = msg.sender;
voters[chairperson].weight = 1;
proposals.length = _numProposals;
}
/// Give $(
v
oter) the right to vote on this ballot.
/// Give $(
toV
oter) the right to vote on this ballot.
/// May only be called by $(chairperson).
function giveRightToVote(address
voter)
{
if (msg.sender != chairperson || voters[
v
oter].voted) return;
voters[
v
oter].weight = 1;
function giveRightToVote(address
toVoter) public
{
if (msg.sender != chairperson || voters[
toV
oter].voted) return;
voters[
toV
oter].weight = 1;
}
/// Delegate your vote to the voter $(to).
function delegate(address to) {
function delegate(address to)
public
{
Voter storage sender = voters[msg.sender]; // assigns reference
if (sender.voted) return;
while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender)
...
...
@@ -47,21 +47,21 @@ contract Ballot {
delegateTo.weight += sender.weight;
}
/// Give a single vote to proposal $(
p
roposal).
function vote(uint8
proposal)
{
/// Give a single vote to proposal $(
toP
roposal).
function vote(uint8
toProposal) public
{
Voter storage sender = voters[msg.sender];
if (sender.voted ||
p
roposal >= proposals.length) return;
if (sender.voted ||
toP
roposal >= proposals.length) return;
sender.voted = true;
sender.vote =
p
roposal;
proposals[
p
roposal].voteCount += sender.weight;
sender.vote =
toP
roposal;
proposals[
toP
roposal].voteCount += sender.weight;
}
function winningProposal() constant returns (uint8 _winningProposal) {
function winningProposal()
public
constant returns (uint8 _winningProposal) {
uint256 winningVoteCount = 0;
for (uint8 prop
osal = 0; proposal < proposals.length; proposal
++)
if (proposals[prop
osal
].voteCount > winningVoteCount) {
winningVoteCount = proposals[prop
osal
].voteCount;
_winningProposal = prop
osal
;
for (uint8 prop
= 0; prop < proposals.length; prop
++)
if (proposals[prop].voteCount > winningVoteCount) {
winningVoteCount = proposals[prop].voteCount;
_winningProposal = prop;
}
}
}`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment