mirror of
https://github.com/status-im/visual-identity.git
synced 2025-02-12 20:46:35 +00:00
Allowing voting / unvoting
This commit is contained in:
parent
c2ba506f5e
commit
ff338bb7b0
@ -25,15 +25,15 @@ class Poll extends Component {
|
||||
|
||||
this.setState({isSubmitting: true});
|
||||
|
||||
const { customVote, poll } = PollManager.methods;
|
||||
const { customVote, poll, unvote } = PollManager.methods;
|
||||
const { idPoll, value } = this.state;
|
||||
const balance4Voting = value * value;
|
||||
|
||||
const toSend = customVote(idPoll, balance4Voting);
|
||||
const toSend = balance4Voting === 0 ? unvote(idPoll) : customVote(idPoll, balance4Voting);
|
||||
|
||||
toSend.estimateGas()
|
||||
.then(gasEstimated => {
|
||||
console.log("customVote gas estimated: " + gasEstimated);
|
||||
console.log("voting gas estimated: " + gasEstimated);
|
||||
return toSend.send({gas: gasEstimated + 1000});
|
||||
})
|
||||
.then(res => {
|
||||
@ -67,7 +67,6 @@ class Poll extends Component {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
render(){
|
||||
const { _description,
|
||||
_totalCensus,
|
||||
@ -86,7 +85,7 @@ class Poll extends Component {
|
||||
return (
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Typography variant="headline">Proposal: {_description}</Typography>
|
||||
<Typography variant="headline">{_description}</Typography>
|
||||
<Typography variant="subheading" color="textSecondary">
|
||||
Number of voters: {_voters}
|
||||
</Typography>
|
||||
|
@ -137,7 +137,7 @@ contract PollManager is Controlled {
|
||||
|
||||
uint balance = MiniMeToken(p.token).balanceOf(msg.sender);
|
||||
|
||||
require(balance != 0 && balance >= _amount);
|
||||
require(balance != 0 && balance >= _amount && _amount != 0);
|
||||
require(MiniMeToken(p.token).transferFrom(msg.sender, address(this), _amount));
|
||||
|
||||
p.votes[msg.sender] = _amount;
|
||||
|
Loading…
x
Reference in New Issue
Block a user