Commit 7f4b9e20 authored by Miguel Braidot's avatar Miguel Braidot

Haciendo dinámica la lectura de proposals

parent 0b1ec723
......@@ -101,7 +101,7 @@ contract Ballot
{
// May only be called by chairman.
require( msg.sender == ballotChairman );
require( ballotVoteBefore < now );
require( ballotVoteBefore > now );
uint len = voters.length;
uint i = 0;
while ( i < len )
......@@ -147,8 +147,8 @@ contract Ballot
public
{
require( proposal < proposalList.length );
require( ballotVoteStarts >= now );
require( ballotVoteBefore < now );
require( ballotVoteStarts <= now );
require( ballotVoteBefore > now );
int idx = getVoterIdx( msg.sender );
require( idx > -1 );
uint uidx = uint( idx );
......
This diff is collapsed.
......@@ -6,6 +6,7 @@ var netid;
var netname;
var blocknumber = -2;
var nowblock;
var proposalLength = 0;
var netnames = {
"1": 'Ethereum mainnet',
......@@ -20,9 +21,9 @@ var netnames = {
var mainaddr = {
'5445': '0xe5bf7c3e8aa529e42fbd99428137b68db75d85f9',
'47525974938': '0xe3e08934b6fa0b68972c08e0f545cee31ed039c6',
'5777': '0x68bc96dd287Fd7AdAD480b487B16ac5AE7D59B3A'
'5777': '0xeAf032eaC758646E167916028F3abAbF0f33ae5d'
};
var ballot_keccak3 = '0xfd956d3ac857d157367d1a1bfe0e0fddee572dd24aebe34df32c430543377bb0';
var ballot_keccak3 = '0x20ab18e35a65929a015b8faf468469a21d2268ffce74a8888a12eb6b9d10bf43';
var contract_event;
window.addEventListener('load', page_loaded);
......@@ -478,9 +479,10 @@ async function ver_votacion2(addr, code) {
// Getting the title
contract.ballotTitle.call({ gas: 2111000 }, getBallotTitle);
// Getting the proposal list
// @TODO: get the proposal mapping's length
contract.proposalList.call(0, { gas: 2111000 }, getProposalList);
contract.proposalList.call(1, { gas: 2111000 }, getProposalList);
let proposalLength = await getProposalListLength(contract);
for(var i=0;i<proposalLength;i++){
contract.proposalList.call(i, { gas: 2111000 }, getProposalList);
}
// Getting the ballot dates
contract.ballotVoteStarts.call({ gas: 2111000 }, getBallotVoteStarts);
contract.ballotVoteBefore.call({ gas: 2111000 }, getBallotVoteBefore);
......@@ -497,6 +499,18 @@ async function ver_votacion2(addr, code) {
///////////////////////////////////////////////////////////
// UTILS for ballot form creation
///////////////////////////////////////////////////////////
function getProposalListLength (contract) {
return new Promise (function (resolve, reject) {
contract.proposalListLength.call({ gas: 2111000 }, function (error, result) {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});
}
async function getBallotVoteStarts(err, rcpt){
if(err){
alertar(err);
......
......@@ -326,6 +326,9 @@
scrollTop: 0
}, 200);
$('#errorForm').focus();
$("#voterow :input").attr("readonly", false);
$("#voterow :input").attr("disabled", false);
$("#voterow .btn").show();
}
},
submitHandler: function (form) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment