mirror of
https://github.com/status-im/snt-voting.git
synced 2025-02-20 14:18:34 +00:00
Added TODOs to point places where decimals need to be used
This commit is contained in:
parent
f4701ccd51
commit
e1f1e58930
@ -28,6 +28,8 @@ class ConnectYourWallet extends Component {
|
||||
|
||||
if(cont){
|
||||
const tknVotes = await PollManager.methods.getVote(idPoll, web3.eth.defaultAccount).call({from: web3.eth.defaultAccount});
|
||||
|
||||
// TODO: use decimals
|
||||
const votes = tknVotes.map(x => Math.sqrt(parseInt(web3.utils.fromWei(x, "ether"))));
|
||||
|
||||
if(web3.currentProvider.isStatus){
|
||||
|
@ -38,6 +38,8 @@ class ExternalWallet extends Component {
|
||||
if(cont){
|
||||
// TODO: extract this code to utils. It's repeated in ConnectYourWallt, ExternalWallet and HowVotingWorks
|
||||
const tknVotes = await PollManager.methods.getVote(idPoll, web3.eth.defaultAccount).call({from: web3.eth.defaultAccount});
|
||||
|
||||
// TODO: use decimals
|
||||
const votes = tknVotes.map(x => Math.sqrt(parseInt(web3.utils.fromWei(x, "ether"))));
|
||||
const tokenBalance = await DappToken.methods.balanceOfAt(web3.eth.defaultAccount, poll._startBlock).call({from: web3.eth.defaultAccount});
|
||||
const ethBalance = await web3.eth.getBalance(web3.eth.defaultAccount);
|
||||
|
@ -66,6 +66,7 @@ class HowVotingWorks extends Component {
|
||||
const poll = polls.find(p => p.idPoll == idPoll);
|
||||
if(!poll) return null;
|
||||
|
||||
// TODO: use decimals
|
||||
const tknVotes = await PollManager.methods.getVote(idPoll, web3.eth.defaultAccount).call({from: web3.eth.defaultAccount});
|
||||
const votes = tknVotes.map(x => Math.sqrt(parseInt(web3.utils.fromWei(x, "ether"))));
|
||||
const tokenBalance = await DappToken.methods.balanceOfAt(web3.eth.defaultAccount, poll._startBlock).call({from: web3.eth.defaultAccount});
|
||||
|
@ -85,6 +85,7 @@ class LandingPage extends Component {
|
||||
openPoll._tokenSum = 0;
|
||||
openPoll._votesSum = 0;
|
||||
for(let i = 0; i < openPoll._numBallots; i++){
|
||||
// TODO: use decimals
|
||||
openPoll._tokenSum += parseInt(web3.utils.fromWei(openPoll._tokenTotal[i], "ether"), 10);
|
||||
openPoll._votesSum += parseInt(web3.utils.fromWei(openPoll._quadraticVotes[i], "ether"), 10);
|
||||
}
|
||||
@ -94,6 +95,7 @@ class LandingPage extends Component {
|
||||
closedPoll._tokenSum = 0;
|
||||
closedPoll._votesSum = 0;
|
||||
for(let i = 0; i < closedPoll._numBallots; i++){
|
||||
// TODO: use decimals
|
||||
closedPoll._tokenSum += parseInt(web3.utils.fromWei(closedPoll._tokenTotal[i], "ether"), 10);
|
||||
closedPoll._votesSum += parseInt(closedPoll._quadraticVotes[i], 10);
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ class OtherPolls extends Component {
|
||||
p._tokenSum = 0;
|
||||
p._votesSum = 0;
|
||||
for(let i = 0; i < p._numBallots; i++){
|
||||
// TODO: use decimals
|
||||
p._tokenSum += parseInt(web3.utils.fromWei(p._tokenTotal[i], "ether"), 10);
|
||||
p._votesSum += parseInt(p._quadraticVotes[i], 10);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class PollVoting extends Component {
|
||||
|
||||
const title = poll.content.title;
|
||||
const ballots = poll.content.ballots
|
||||
|
||||
// TODO: use decimals
|
||||
const balance = fromWei(balances[idPoll].tokenBalance, "ether");
|
||||
const cantVote = balance == 0 || !poll._canVote;
|
||||
const availableCredits = parseInt(balance, 10) - votes.reduce((prev, curr) => prev + curr * curr, 0);
|
||||
|
@ -173,7 +173,7 @@ class BallotResult extends Component {
|
||||
</ul>}
|
||||
</Fragment>);
|
||||
}
|
||||
|
||||
// TODO: use decimals
|
||||
}
|
||||
|
||||
export default Results;
|
||||
|
@ -29,6 +29,7 @@ class ReviewVotes extends Component {
|
||||
}
|
||||
|
||||
const ballots = votes.map(el => {
|
||||
// TODO: use token decimals
|
||||
let num = toBN(el);
|
||||
num = num.mul(num);
|
||||
return toWei(num, "ether");
|
||||
@ -86,6 +87,7 @@ class ReviewVotes extends Component {
|
||||
if(!poll) return null;
|
||||
|
||||
const ballots = poll.content.ballots
|
||||
// TODO: use decimals
|
||||
const balance = fromWei(balances[idPoll].tokenBalance, "ether");
|
||||
const availableCredits = parseInt(balance, 10) - votes.reduce((prev, curr) => prev + curr * curr, 0);
|
||||
|
||||
|
@ -70,6 +70,7 @@ class VotingCredits extends Component {
|
||||
let title = poll.content.title;
|
||||
let description = poll.content.description;
|
||||
let ethBalance = web3.utils.fromWei(balances[idPoll].ethBalance, "ether");
|
||||
// TODO: use decimals
|
||||
let tokenBalance = Math.floor(web3.utils.fromWei(balances[idPoll].tokenBalance, "ether"));
|
||||
|
||||
|
||||
|
@ -58,6 +58,7 @@ class PollCreationCredits extends Component {
|
||||
this.setState({tokenBalance, ethBalance});
|
||||
|
||||
if(web3.utils.fromWei(ethBalance.toString(), "ether") > 0 &&
|
||||
// TODO: use decimals
|
||||
Math.floor(web3.utils.fromWei(tokenBalance.toString(), "ether")) >= 1
|
||||
){
|
||||
history.push('/poll/title');
|
||||
@ -69,6 +70,7 @@ class PollCreationCredits extends Component {
|
||||
|
||||
render(){
|
||||
let ethBalance = web3.utils.fromWei(this.state.ethBalance, "ether");
|
||||
// TODO: use decimals
|
||||
let tokenBalance = this.state.tokenBalance != "-" ? Math.floor(web3.utils.fromWei(this.state.tokenBalance, "ether")) : "-";
|
||||
|
||||
return <Fragment><div className="section">
|
||||
|
@ -11,6 +11,7 @@ export const getBalance = async (startBlock) => {
|
||||
const { fromWei } = web3.utils;
|
||||
const { balanceOfAt } = DappToken.methods;
|
||||
const balance = await balanceOfAt(web3.eth.defaultAccount, startBlock - 1).call();
|
||||
// TODO: use decimals
|
||||
return fromWei(balance);
|
||||
}
|
||||
export const getVote = async(idPoll) => {
|
||||
|
@ -7,7 +7,7 @@ var rlp = require('rlp');
|
||||
const PollManager = embark.require('Embark/contracts/PollManager');
|
||||
const DappToken = embark.require('Embark/contracts/DappToken');
|
||||
|
||||
|
||||
// TODO: use tokens decimals
|
||||
const decimals = (amount) => web3.utils.toWei(amount.toString(), "ether");
|
||||
|
||||
config({
|
||||
|
Loading…
x
Reference in New Issue
Block a user