diff --git a/app/components/simple-voting/PollsList.js b/app/components/simple-voting/PollsList.js index c362def..58928ae 100644 --- a/app/components/simple-voting/PollsList.js +++ b/app/components/simple-voting/PollsList.js @@ -18,7 +18,7 @@ import CircularProgress from '@material-ui/core/CircularProgress'; import { withStyles } from '@material-ui/core/styles'; import { VotingContext } from '../../context'; import rlp from 'rlp'; - +window.PollManager = PollManager; const styles = { card: { display: 'flex', @@ -102,7 +102,7 @@ class Poll extends PureComponent { this.setState({isSubmitting: true}); - const { vote, poll, unvote } = PollManager.methods; + const { vote, unvote } = PollManager.methods; const { updatePoll, idPoll } = this.props; const { votes } = this.state; const { toWei } = web3.utils; @@ -150,7 +150,6 @@ class Poll extends PureComponent { const cantVote = balance == 0 || !_canVote; const disableVote = cantVote || isSubmitting; - const quadVotes = []; const sntTotals = []; for(let i = 0; i < _numBallots; i++){ @@ -213,7 +212,7 @@ class Poll extends PureComponent { {cantVote && {balance == 0 && Voting disabled for proposals made when there was no SNT in the account} - {balance != 0 && !_canVote && You can not vote on this poll} + {balance != 0 && cantVote && Voting is not enabled for this poll} } @@ -267,7 +266,7 @@ const PollsList = ({ classes }) => ( {rawPolls .sort(sortingFn[pollOrder]) - .map((poll, i) => )} + .map((poll, i) => !poll._canceled && )} } @@ -295,14 +294,13 @@ class BallotSlider extends Component { const {value} = this.state; const nextVote = value + 1; - //cantVote={cantVote} balance={balance} return - - {balance > 0 && Your votes: {value} ({value * value} SNT)} - { nextVote <= maxVotesAvailable ? - Additional vote will cost {nextVote*nextVote - value*value} SNT : (balance > 0 && - Not enough balance available to buy additional votes) } + + {balance > 0 && !cantVote && Your votes: {value} ({value * value} SNT)} + { nextVote <= maxVotesAvailable && !cantVote ? - Additional vote will cost {nextVote*nextVote - value*value} SNT : (balance > 0 && !cantVote && - Not enough balance available to buy additional votes) } } } diff --git a/contracts/polls/PollManager.sol b/contracts/polls/PollManager.sol index 1f3454c..f969f5c 100644 --- a/contracts/polls/PollManager.sol +++ b/contracts/polls/PollManager.sol @@ -119,12 +119,12 @@ contract PollManager is Controlled { Poll storage p = _polls[_idPoll]; require(!p.canceled, "Poll has been canceled already"); - require(p.endBlock < block.number, "Only active polls can be canceled"); + require(p.endBlock > block.number, "Only active polls can be canceled"); - if(p.startBlock <= block.number){ + if(p.startBlock < block.number){ require(msg.sender == controller, "Only the controller can cancel the poll"); } else { - require(p.author == msg.sender, "Only the controller can cancel the poll"); + require(p.author == msg.sender, "Only the owner can cancel the poll"); } p.canceled = true; @@ -247,6 +247,7 @@ contract PollManager is Controlled { uint8 _numBallots, bool _finalized, uint _voters, + address _author, uint[15] _tokenTotal, uint[15] _quadraticVotes ) @@ -261,6 +262,7 @@ contract PollManager is Controlled { _canVote = canVote(_idPoll); _description = p.description; _numBallots = p.numBallots; + _author = p.author; _finalized = (!p.canceled) && (block.number >= _endBlock); _voters = p.voters;