From 921f0ee2fb4a1862d7b07a2bcada69d6b6558106 Mon Sep 17 00:00:00 2001 From: Ashwin Joisa Date: Fri, 16 Aug 2019 16:17:33 +0530 Subject: [PATCH 1/5] Election closing --- build/contracts/Election.json | 6 ++-- build/contracts/Migrations.json | 6 ++-- src/index.html | 6 ++-- src/js/app.js | 62 +++++++++++++++++++++++++++++++-- 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/build/contracts/Election.json b/build/contracts/Election.json index 4c98b761..0a9e4655 100644 --- a/build/contracts/Election.json +++ b/build/contracts/Election.json @@ -2603,12 +2603,12 @@ "5777": { "events": {}, "links": {}, - "address": "0x0D29712aA3034DEDca41C64993951d476c766908", - "transactionHash": "0x336aa67af69c1cf50a5062f77f5cf6fd280a625cdf421836f131b70078311f46" + "address": "0x9e309fAa91BEf552C539dF4F94FC29E3514d322A", + "transactionHash": "0x788830a32f912747035670bae7d0e5c501843681ea2f4c49c5cf5f170199c692" } }, "schemaVersion": "3.0.11", - "updatedAt": "2019-08-15T08:36:45.289Z", + "updatedAt": "2019-08-15T12:50:53.889Z", "devdoc": { "methods": {} }, diff --git a/build/contracts/Migrations.json b/build/contracts/Migrations.json index 5f0c50d7..18d3eb76 100644 --- a/build/contracts/Migrations.json +++ b/build/contracts/Migrations.json @@ -1379,12 +1379,12 @@ "5777": { "events": {}, "links": {}, - "address": "0xda0c592565De44F73f105953b4Eff91BaeCe993d", - "transactionHash": "0x1428b42b70a5024e6ef20eb2cf8be4dde9ffb787fe810750421505287239fff3" + "address": "0xd33eF960eB5cdbFb3430Ef028c180192D54995BC", + "transactionHash": "0x76d6be26fa8a8c2f296172b0a3c38b2d7d757e4c8adfbb3f95c4eab8ac4d350f" } }, "schemaVersion": "3.0.11", - "updatedAt": "2019-08-15T08:36:45.291Z", + "updatedAt": "2019-08-15T12:50:53.892Z", "devdoc": { "methods": {} }, diff --git a/src/index.html b/src/index.html index e201afb8..70a6bcbf 100644 --- a/src/index.html +++ b/src/index.html @@ -21,7 +21,7 @@
-

Election Results

+



@@ -33,7 +33,7 @@

Election Results

# Name - Votes + Votes @@ -50,6 +50,8 @@

Election Results


+

+

diff --git a/src/js/app.js b/src/js/app.js index 2e119d06..44d44021 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -3,6 +3,15 @@ App = { contracts: {}, account: '0x0', hasVoted: false, + closingTime: { + year: 2019, + month: 7, + date: 16, + hour: 21, + minutes: 0, + seconds: 0, + milliseconds: 0 + }, init: function() { return App.initWeb3(); @@ -52,13 +61,54 @@ App = { }); }, + electionResults : function () { + $("#Title").html('Election Results'); + }, + + displayTime: function() { + var today = new Date(); + var closingDate = new Date(App.closingTime.year, App.closingTime.month, App.closingTime.date, + App.closingTime.hour, App.closingTime.minutes, App.closingTime.seconds, + App.closingTime.milliseconds); + + $("#ClosingTime").html('Voting ends at : ' + closingDate); + + var remSeconds = Math.max(0, Math.floor((closingDate.getTime() - today.getTime()) / 1000)); + var remDays = Math.floor(remSeconds / (60 * 60 * 24)); + remSeconds -= remDays * 60 * 60 * 24; + + var remHours = Math.floor(remSeconds / (60*60)); + remSeconds -= remHours * 60 * 60; + + var remMinutes = Math.floor(remSeconds / 60); + remSeconds -= remMinutes * 60; + + $("#RemainingTime").html('Time left until closing : ' + remDays + ' Day(s), ' + + remHours + ' Hour(s), ' + remMinutes + ' Minute(s), ' + remSeconds + ' Second(s)'); + + var refresh=1000; // Refresh rate in milli seconds + mytime=setTimeout('App.displayTime()',refresh) + }, + render: function() { var electionInstance; var loader = $("#loader"); var content = $("#content"); + var closingDate = new Date(App.closingTime.year, App.closingTime.month, App.closingTime.date, + App.closingTime.hour, App.closingTime.minutes, App.closingTime.seconds, + App.closingTime.milliseconds); + var now = new Date(); loader.show(); - content.hide(); + content.hide + $('#Title').html('Cast your vote!'); + if(now < closingDate) + $('#Votes').hide(); + else { + $('#Votes').show(); + $('#Title').html('Election Results'); + } + App.displayTime(); // Load account data web3.eth.getCoinbase(function(err, account) { @@ -93,7 +143,13 @@ App = { var voteCount = candidate[2]; // Render candidate Result - var candidateTemplate = "" + id + "" + name + "" + voteCount + "" + var candidateTemplate = "" + id + "" + name + ""; + if(now < closingDate) { + candidateTemplate += ""; + } + else { + candidateTemplate += "" + voteCount + ""; + } candidatesResults.append(candidateTemplate); // Render candidate ballot option @@ -107,6 +163,8 @@ App = { // Do not allow a user to vote if(hasVoted) { $('form').hide(); + if(now < closingDate) + $("#Title").html('Thank you for casting your vote!'); } loader.hide(); content.show(); From dafb8a038beb478dcea4d0ae000da8ab55f54cb8 Mon Sep 17 00:00:00 2001 From: Ashwin Joisa Date: Sat, 17 Aug 2019 14:26:28 +0530 Subject: [PATCH 2/5] OTP validation --- src/index.html | 1 + src/js/app.js | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/index.html b/src/index.html index 70a6bcbf..db83c5ac 100644 --- a/src/index.html +++ b/src/index.html @@ -46,6 +46,7 @@

+
diff --git a/src/js/app.js b/src/js/app.js index 44d44021..e35c0bdc 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -3,10 +3,11 @@ App = { contracts: {}, account: '0x0', hasVoted: false, + PRIME: 1000000007, closingTime: { year: 2019, month: 7, - date: 16, + date: 17, hour: 21, minutes: 0, seconds: 0, @@ -61,9 +62,6 @@ App = { }); }, - electionResults : function () { - $("#Title").html('Election Results'); - }, displayTime: function() { var today = new Date(); @@ -173,8 +171,25 @@ App = { }); }, + getOTP : function (address) { + var hash = 0; + for(var i=0; i Date: Mon, 19 Aug 2019 22:22:20 +0530 Subject: [PATCH 3/5] Closing elections --- src/js/app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/js/app.js b/src/js/app.js index e35c0bdc..14085b51 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -7,7 +7,7 @@ App = { closingTime: { year: 2019, month: 7, - date: 17, + date: 22, hour: 21, minutes: 0, seconds: 0, @@ -105,6 +105,7 @@ App = { else { $('#Votes').show(); $('#Title').html('Election Results'); + $('form').hide(); } App.displayTime(); @@ -162,7 +163,7 @@ App = { if(hasVoted) { $('form').hide(); if(now < closingDate) - $("#Title").html('Thank you for casting your vote!'); + $("#Title").html('Thank you for casting your vote!'); } loader.hide(); content.show(); From aa7c1c703a4984fb1a752515273a90d831cae9f5 Mon Sep 17 00:00:00 2001 From: Ashwin Joisa Date: Wed, 21 Aug 2019 14:47:23 +0530 Subject: [PATCH 4/5] ui --- build/contracts/Election.json | 350 ++++++++++++++++---------------- build/contracts/Migrations.json | 6 +- contracts/Election.sol | 4 +- src/index.html | 2 +- src/js/app.js | 2 +- 5 files changed, 182 insertions(+), 182 deletions(-) diff --git a/build/contracts/Election.json b/build/contracts/Election.json index 0a9e4655..4099091b 100644 --- a/build/contracts/Election.json +++ b/build/contracts/Election.json @@ -94,12 +94,12 @@ "type": "function" } ], - "metadata": "{\"compiler\":{\"version\":\"0.4.25+commit.59dbf8f1\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":false,\"inputs\":[{\"name\":\"_candidateId\",\"type\":\"uint256\"}],\"name\":\"vote\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"candidatesCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"candidates\",\"outputs\":[{\"name\":\"id\",\"type\":\"uint256\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"voteCount\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"voters\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_candidateId\",\"type\":\"uint256\"}],\"name\":\"votedEvent\",\"type\":\"event\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/aj/Files/Projects/Codefundo/CodeFunDo19/contracts/Election.sol\":\"Election\"},\"evmVersion\":\"byzantium\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/home/aj/Files/Projects/Codefundo/CodeFunDo19/contracts/Election.sol\":{\"keccak256\":\"0xa63aa373d8debbc774b1e8254dc686700ece7fcc265e85f0dc0de0a6d398b187\",\"urls\":[\"bzzr://7fb96ba9ca4d5a93e46942c6d2eb80cc37a4c3ab29d8a2203c332ef6457350ba\"]}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b5061005e6040805190810160405280600b81526020017f43616e64696461746520310000000000000000000000000000000000000000008152506100b0640100000000026401000000009004565b6100ab6040805190810160405280600b81526020017f43616e64696461746520320000000000000000000000000000000000000000008152506100b0640100000000026401000000009004565b6101d2565b6002600081548092919060010191905055506060604051908101604052806002548152602001828152602001600081525060016000600254815260200190815260200160002060008201518160000155602082015181600101908051906020019061011c92919061012d565b506040820151816002015590505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061016e57805160ff191683800117855561019c565b8280016001018555821561019c579182015b8281111561019b578251825591602001919060010190610180565b5b5090506101a991906101ad565b5090565b6101cf91905b808211156101cb5760008160009055506001016101b3565b5090565b90565b610404806101e16000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630121b93f146100675780632d35a8a2146100945780633477ee2e146100bf578063a3ec138d14610173575b600080fd5b34801561007357600080fd5b50610092600480360381019080803590602001909291905050506101ce565b005b3480156100a057600080fd5b506100a96102f0565b6040518082815260200191505060405180910390f35b3480156100cb57600080fd5b506100ea600480360381019080803590602001909291905050506102f6565b6040518084815260200180602001838152602001828103825284818151815260200191508051906020019080838360005b8381101561013657808201518184015260208101905061011b565b50505050905090810190601f1680156101635780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b34801561017f57600080fd5b506101b4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103b8565b604051808215151515815260200191505060405180910390f35b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561022657600080fd5b60008111801561023857506002548111155b151561024357600080fd5b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600082815260200190815260200160002060020160008154809291906001019190505550807ffff3c900d938d21d0990d786e819f29b8d05c1ef587b462b939609625b684b1660405160405180910390a250565b60025481565b6001602052806000526040600020600091509050806000015490806001018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103a85780601f1061037d576101008083540402835291602001916103a8565b820191906000526020600020905b81548152906001019060200180831161038b57829003601f168201915b5050505050908060020154905083565b60006020528060005260406000206000915054906101000a900460ff16815600a165627a7a7230582062f4d8499705f17a683c29aade712c1971260c45913d5c6f7a294160262fca2f0029", - "deployedBytecode": "0x608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630121b93f146100675780632d35a8a2146100945780633477ee2e146100bf578063a3ec138d14610173575b600080fd5b34801561007357600080fd5b50610092600480360381019080803590602001909291905050506101ce565b005b3480156100a057600080fd5b506100a96102f0565b6040518082815260200191505060405180910390f35b3480156100cb57600080fd5b506100ea600480360381019080803590602001909291905050506102f6565b6040518084815260200180602001838152602001828103825284818151815260200191508051906020019080838360005b8381101561013657808201518184015260208101905061011b565b50505050905090810190601f1680156101635780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b34801561017f57600080fd5b506101b4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103b8565b604051808215151515815260200191505060405180910390f35b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561022657600080fd5b60008111801561023857506002548111155b151561024357600080fd5b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600082815260200190815260200160002060020160008154809291906001019190505550807ffff3c900d938d21d0990d786e819f29b8d05c1ef587b462b939609625b684b1660405160405180910390a250565b60025481565b6001602052806000526040600020600091509050806000015490806001018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103a85780601f1061037d576101008083540402835291602001916103a8565b820191906000526020600020905b81548152906001019060200180831161038b57829003601f168201915b5050505050908060020154905083565b60006020528060005260406000206000915054906101000a900460ff16815600a165627a7a7230582062f4d8499705f17a683c29aade712c1971260c45913d5c6f7a294160262fca2f0029", - "sourceMap": "25:1218:0:-;;;493:103;8:9:-1;5:2;;;30:1;27;20:12;5:2;493:103:0;525:27;;;;;;;;;;;;;;;;;;;:12;;;:27;;;:::i;:::-;562;;;;;;;;;;;;;;;;;;;:12;;;:27;;;:::i;:::-;25:1218;;602:156;657:15;;:18;;;;;;;;;;;;;715:36;;;;;;;;;725:15;;715:36;;;;742:5;715:36;;;;749:1;715:36;;;685:10;:27;696:15;;685:27;;;;;;;;;;;:66;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;602:156;:::o;25:1218::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;", - "deployedSourceMap": "25:1218:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;764:477;;8:9:-1;5:2;;;30:1;27;20:12;5:2;764:477:0;;;;;;;;;;;;;;;;;;;;;;;;;;375:27;;8:9:-1;5:2;;;30:1;27;20:12;5:2;375:27:0;;;;;;;;;;;;;;;;;;;;;;;295:44;;8:9:-1;5:2;;;30:1;27;20:12;5:2;295:44:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;295:44:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;204:38;;8:9:-1;5:2;;;30:1;27;20:12;5:2;204:38:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;764:477;874:6;:18;881:10;874:18;;;;;;;;;;;;;;;;;;;;;;;;;873:19;865:28;;;;;;;;964:1;949:12;:16;:51;;;;;985:15;;969:12;:31;;949:51;941:60;;;;;;;;1072:4;1051:6;:18;1058:10;1051:18;;;;;;;;;;;;;;;;:25;;;;;;;;;;;;;;;;;;1126:10;:24;1137:12;1126:24;;;;;;;;;;;:34;;;:37;;;;;;;;;;;;;1221:12;1210:24;;;;;;;;;;764:477;:::o;375:27::-;;;;:::o;295:44::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;204:38::-;;;;;;;;;;;;;;;;;;;;;;:::o", - "source": "pragma solidity 0.4.25;\n\ncontract Election {\n // Model a Candidate\n struct Candidate {\n uint id;\n string name;\n uint voteCount;\n }\n\n // Store accounts that have voted\n mapping(address => bool) public voters;\n // Store Candidates\n // Fetch Candidate\n mapping(uint => Candidate) public candidates;\n // Store Candidates Count\n uint public candidatesCount;\n\n // voted event\n event votedEvent (\n uint indexed _candidateId\n );\n\n constructor () public {\n addCandidate(\"Candidate 1\");\n addCandidate(\"Candidate 2\");\n }\n\n function addCandidate (string _name) private {\n candidatesCount ++;\n candidates[candidatesCount] = Candidate(candidatesCount, _name, 0);\n }\n\n function vote (uint _candidateId) public {\n // require that they haven't voted before\n require(!voters[msg.sender]);\n\n // require a valid candidate\n require(_candidateId > 0 && _candidateId <= candidatesCount);\n\n // record that voter has voted\n voters[msg.sender] = true;\n\n // update candidate vote Count\n candidates[_candidateId].voteCount ++;\n\n // trigger voted event\n emit votedEvent(_candidateId);\n }\n}\n", + "metadata": "{\"compiler\":{\"version\":\"0.4.25+commit.59dbf8f1\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":false,\"inputs\":[{\"name\":\"_candidateId\",\"type\":\"uint256\"}],\"name\":\"vote\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"candidatesCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"candidates\",\"outputs\":[{\"name\":\"id\",\"type\":\"uint256\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"voteCount\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"voters\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_candidateId\",\"type\":\"uint256\"}],\"name\":\"votedEvent\",\"type\":\"event\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/aj/Files/Projects/Codefundo/CodeFunDo19/contracts/Election.sol\":\"Election\"},\"evmVersion\":\"byzantium\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/home/aj/Files/Projects/Codefundo/CodeFunDo19/contracts/Election.sol\":{\"keccak256\":\"0x2a43bc0cc446b9e8776e51327338b9d5dede6ce62deecfe1edd9168b7bd1e9c3\",\"urls\":[\"bzzr://f25379e930c60592c988098cb13588395b8bc12ef45265f8e6b69b4aafe08f33\"]}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061005e6040805190810160405280600581526020017f416c6963650000000000000000000000000000000000000000000000000000008152506100b0640100000000026401000000009004565b6100ab6040805190810160405280600381526020017f426f6200000000000000000000000000000000000000000000000000000000008152506100b0640100000000026401000000009004565b6101d2565b6002600081548092919060010191905055506060604051908101604052806002548152602001828152602001600081525060016000600254815260200190815260200160002060008201518160000155602082015181600101908051906020019061011c92919061012d565b506040820151816002015590505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061016e57805160ff191683800117855561019c565b8280016001018555821561019c579182015b8281111561019b578251825591602001919060010190610180565b5b5090506101a991906101ad565b5090565b6101cf91905b808211156101cb5760008160009055506001016101b3565b5090565b90565b610404806101e16000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630121b93f146100675780632d35a8a2146100945780633477ee2e146100bf578063a3ec138d14610173575b600080fd5b34801561007357600080fd5b50610092600480360381019080803590602001909291905050506101ce565b005b3480156100a057600080fd5b506100a96102f0565b6040518082815260200191505060405180910390f35b3480156100cb57600080fd5b506100ea600480360381019080803590602001909291905050506102f6565b6040518084815260200180602001838152602001828103825284818151815260200191508051906020019080838360005b8381101561013657808201518184015260208101905061011b565b50505050905090810190601f1680156101635780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b34801561017f57600080fd5b506101b4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103b8565b604051808215151515815260200191505060405180910390f35b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561022657600080fd5b60008111801561023857506002548111155b151561024357600080fd5b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600082815260200190815260200160002060020160008154809291906001019190505550807ffff3c900d938d21d0990d786e819f29b8d05c1ef587b462b939609625b684b1660405160405180910390a250565b60025481565b6001602052806000526040600020600091509050806000015490806001018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103a85780601f1061037d576101008083540402835291602001916103a8565b820191906000526020600020905b81548152906001019060200180831161038b57829003601f168201915b5050505050908060020154905083565b60006020528060005260406000206000915054906101000a900460ff16815600a165627a7a72305820be74b9215f4b9f2954bfd90249041855315f42edea35e48e92846f7eac64a30a0029", + "deployedBytecode": "0x608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630121b93f146100675780632d35a8a2146100945780633477ee2e146100bf578063a3ec138d14610173575b600080fd5b34801561007357600080fd5b50610092600480360381019080803590602001909291905050506101ce565b005b3480156100a057600080fd5b506100a96102f0565b6040518082815260200191505060405180910390f35b3480156100cb57600080fd5b506100ea600480360381019080803590602001909291905050506102f6565b6040518084815260200180602001838152602001828103825284818151815260200191508051906020019080838360005b8381101561013657808201518184015260208101905061011b565b50505050905090810190601f1680156101635780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b34801561017f57600080fd5b506101b4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103b8565b604051808215151515815260200191505060405180910390f35b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561022657600080fd5b60008111801561023857506002548111155b151561024357600080fd5b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600082815260200190815260200160002060020160008154809291906001019190505550807ffff3c900d938d21d0990d786e819f29b8d05c1ef587b462b939609625b684b1660405160405180910390a250565b60025481565b6001602052806000526040600020600091509050806000015490806001018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103a85780601f1061037d576101008083540402835291602001916103a8565b820191906000526020600020905b81548152906001019060200180831161038b57829003601f168201915b5050505050908060020154905083565b60006020528060005260406000206000915054906101000a900460ff16815600a165627a7a72305820be74b9215f4b9f2954bfd90249041855315f42edea35e48e92846f7eac64a30a0029", + "sourceMap": "25:1204:0:-;;;493:89;8:9:-1;5:2;;;30:1;27;20:12;5:2;493:89:0;525:21;;;;;;;;;;;;;;;;;;;:12;;;:21;;;:::i;:::-;556:19;;;;;;;;;;;;;;;;;;;:12;;;:19;;;:::i;:::-;25:1204;;588:156;643:15;;:18;;;;;;;;;;;;;701:36;;;;;;;;;711:15;;701:36;;;;728:5;701:36;;;;735:1;701:36;;;671:10;:27;682:15;;671:27;;;;;;;;;;;:66;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;588:156;:::o;25:1204::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;", + "deployedSourceMap": "25:1204:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;750:477;;8:9:-1;5:2;;;30:1;27;20:12;5:2;750:477:0;;;;;;;;;;;;;;;;;;;;;;;;;;375:27;;8:9:-1;5:2;;;30:1;27;20:12;5:2;375:27:0;;;;;;;;;;;;;;;;;;;;;;;295:44;;8:9:-1;5:2;;;30:1;27;20:12;5:2;295:44:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;295:44:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;204:38;;8:9:-1;5:2;;;30:1;27;20:12;5:2;204:38:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;750:477;860:6;:18;867:10;860:18;;;;;;;;;;;;;;;;;;;;;;;;;859:19;851:28;;;;;;;;950:1;935:12;:16;:51;;;;;971:15;;955:12;:31;;935:51;927:60;;;;;;;;1058:4;1037:6;:18;1044:10;1037:18;;;;;;;;;;;;;;;;:25;;;;;;;;;;;;;;;;;;1112:10;:24;1123:12;1112:24;;;;;;;;;;;:34;;;:37;;;;;;;;;;;;;1207:12;1196:24;;;;;;;;;;750:477;:::o;375:27::-;;;;:::o;295:44::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;204:38::-;;;;;;;;;;;;;;;;;;;;;;:::o", + "source": "pragma solidity 0.4.25;\n\ncontract Election {\n // Model a Candidate\n struct Candidate {\n uint id;\n string name;\n uint voteCount;\n }\n\n // Store accounts that have voted\n mapping(address => bool) public voters;\n // Store Candidates\n // Fetch Candidate\n mapping(uint => Candidate) public candidates;\n // Store Candidates Count\n uint public candidatesCount;\n\n // voted event\n event votedEvent (\n uint indexed _candidateId\n );\n\n constructor () public {\n addCandidate(\"Alice\");\n addCandidate(\"Bob\");\n }\n\n function addCandidate (string _name) private {\n candidatesCount ++;\n candidates[candidatesCount] = Candidate(candidatesCount, _name, 0);\n }\n\n function vote (uint _candidateId) public {\n // require that they haven't voted before\n require(!voters[msg.sender]);\n\n // require a valid candidate\n require(_candidateId > 0 && _candidateId <= candidatesCount);\n\n // record that voter has voted\n voters[msg.sender] = true;\n\n // update candidate vote Count\n candidates[_candidateId].voteCount ++;\n\n // trigger voted event\n emit votedEvent(_candidateId);\n }\n}\n", "sourcePath": "/home/aj/Files/Projects/Codefundo/CodeFunDo19/contracts/Election.sol", "ast": { "absolutePath": "/home/aj/Files/Projects/Codefundo/CodeFunDo19/contracts/Election.sol", @@ -387,7 +387,7 @@ "body": { "id": 33, "nodeType": "Block", - "src": "515:81:0", + "src": "515:67:0", "statements": [ { "expression": { @@ -395,7 +395,7 @@ "arguments": [ { "argumentTypes": null, - "hexValue": "43616e6469646174652031", + "hexValue": "416c696365", "id": 26, "isConstant": false, "isLValue": false, @@ -403,20 +403,20 @@ "kind": "string", "lValueRequested": false, "nodeType": "Literal", - "src": "538:13:0", + "src": "538:7:0", "subdenomination": null, "typeDescriptions": { - "typeIdentifier": "t_stringliteral_41f9dcbd43e9b33194759b5a51b1df9864cdc2b2138ff106f03091eb79861f0c", - "typeString": "literal_string \"Candidate 1\"" + "typeIdentifier": "t_stringliteral_81376b9868b292a46a1c486d344e427a3088657fda629b5f4a647822d329cd6a", + "typeString": "literal_string \"Alice\"" }, - "value": "Candidate 1" + "value": "Alice" } ], "expression": { "argumentTypes": [ { - "typeIdentifier": "t_stringliteral_41f9dcbd43e9b33194759b5a51b1df9864cdc2b2138ff106f03091eb79861f0c", - "typeString": "literal_string \"Candidate 1\"" + "typeIdentifier": "t_stringliteral_81376b9868b292a46a1c486d344e427a3088657fda629b5f4a647822d329cd6a", + "typeString": "literal_string \"Alice\"" } ], "id": 25, @@ -438,7 +438,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "525:27:0", + "src": "525:21:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -446,7 +446,7 @@ }, "id": 28, "nodeType": "ExpressionStatement", - "src": "525:27:0" + "src": "525:21:0" }, { "expression": { @@ -454,7 +454,7 @@ "arguments": [ { "argumentTypes": null, - "hexValue": "43616e6469646174652032", + "hexValue": "426f62", "id": 30, "isConstant": false, "isLValue": false, @@ -462,20 +462,20 @@ "kind": "string", "lValueRequested": false, "nodeType": "Literal", - "src": "575:13:0", + "src": "569:5:0", "subdenomination": null, "typeDescriptions": { - "typeIdentifier": "t_stringliteral_f1f17440f69835dafba5c9fd0e4caa6c780807a80f8d1745ec7af1408d6cca4a", - "typeString": "literal_string \"Candidate 2\"" + "typeIdentifier": "t_stringliteral_28cac318a86c8a0a6a9156c2dba2c8c2363677ba0514ef616592d81557e679b6", + "typeString": "literal_string \"Bob\"" }, - "value": "Candidate 2" + "value": "Bob" } ], "expression": { "argumentTypes": [ { - "typeIdentifier": "t_stringliteral_f1f17440f69835dafba5c9fd0e4caa6c780807a80f8d1745ec7af1408d6cca4a", - "typeString": "literal_string \"Candidate 2\"" + "typeIdentifier": "t_stringliteral_28cac318a86c8a0a6a9156c2dba2c8c2363677ba0514ef616592d81557e679b6", + "typeString": "literal_string \"Bob\"" } ], "id": 29, @@ -483,7 +483,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 53, - "src": "562:12:0", + "src": "556:12:0", "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$_t_string_memory_ptr_$returns$__$", "typeString": "function (string memory)" @@ -497,7 +497,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "562:27:0", + "src": "556:19:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -505,7 +505,7 @@ }, "id": 32, "nodeType": "ExpressionStatement", - "src": "562:27:0" + "src": "556:19:0" } ] }, @@ -531,7 +531,7 @@ "src": "515:0:0" }, "scope": 95, - "src": "493:103:0", + "src": "493:89:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -540,7 +540,7 @@ "body": { "id": 52, "nodeType": "Block", - "src": "647:111:0", + "src": "633:111:0", "statements": [ { "expression": { @@ -553,7 +553,7 @@ "nodeType": "UnaryOperation", "operator": "++", "prefix": false, - "src": "657:18:0", + "src": "643:18:0", "subExpression": { "argumentTypes": null, "id": 39, @@ -561,7 +561,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 18, - "src": "657:15:0", + "src": "643:15:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -574,7 +574,7 @@ }, "id": 41, "nodeType": "ExpressionStatement", - "src": "657:18:0" + "src": "643:18:0" }, { "expression": { @@ -593,7 +593,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 16, - "src": "685:10:0", + "src": "671:10:0", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", "typeString": "mapping(uint256 => struct Election.Candidate storage ref)" @@ -607,7 +607,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 18, - "src": "696:15:0", + "src": "682:15:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -618,7 +618,7 @@ "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", - "src": "685:27:0", + "src": "671:27:0", "typeDescriptions": { "typeIdentifier": "t_struct$_Candidate_$8_storage", "typeString": "struct Election.Candidate storage ref" @@ -636,7 +636,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 18, - "src": "725:15:0", + "src": "711:15:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -649,7 +649,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, - "src": "742:5:0", + "src": "728:5:0", "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string memory" @@ -665,7 +665,7 @@ "kind": "number", "lValueRequested": false, "nodeType": "Literal", - "src": "749:1:0", + "src": "735:1:0", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", @@ -694,7 +694,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 8, - "src": "715:9:0", + "src": "701:9:0", "typeDescriptions": { "typeIdentifier": "t_type$_t_struct$_Candidate_$8_storage_ptr_$", "typeString": "type(struct Election.Candidate storage pointer)" @@ -708,13 +708,13 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "715:36:0", + "src": "701:36:0", "typeDescriptions": { "typeIdentifier": "t_struct$_Candidate_$8_memory", "typeString": "struct Election.Candidate memory" } }, - "src": "685:66:0", + "src": "671:66:0", "typeDescriptions": { "typeIdentifier": "t_struct$_Candidate_$8_storage", "typeString": "struct Election.Candidate storage ref" @@ -722,7 +722,7 @@ }, "id": 51, "nodeType": "ExpressionStatement", - "src": "685:66:0" + "src": "671:66:0" } ] }, @@ -744,7 +744,7 @@ "name": "_name", "nodeType": "VariableDeclaration", "scope": 53, - "src": "625:12:0", + "src": "611:12:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -755,7 +755,7 @@ "id": 35, "name": "string", "nodeType": "ElementaryTypeName", - "src": "625:6:0", + "src": "611:6:0", "typeDescriptions": { "typeIdentifier": "t_string_storage_ptr", "typeString": "string" @@ -765,17 +765,17 @@ "visibility": "internal" } ], - "src": "624:14:0" + "src": "610:14:0" }, "payable": false, "returnParameters": { "id": 38, "nodeType": "ParameterList", "parameters": [], - "src": "647:0:0" + "src": "633:0:0" }, "scope": 95, - "src": "602:156:0", + "src": "588:156:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "private" @@ -784,7 +784,7 @@ "body": { "id": 93, "nodeType": "Block", - "src": "805:436:0", + "src": "791:436:0", "statements": [ { "expression": { @@ -800,7 +800,7 @@ "nodeType": "UnaryOperation", "operator": "!", "prefix": true, - "src": "873:19:0", + "src": "859:19:0", "subExpression": { "argumentTypes": null, "baseExpression": { @@ -810,7 +810,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 12, - "src": "874:6:0", + "src": "860:6:0", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", "typeString": "mapping(address => bool)" @@ -826,7 +826,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 167, - "src": "881:3:0", + "src": "867:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -840,7 +840,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "881:10:0", + "src": "867:10:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -851,7 +851,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "874:18:0", + "src": "860:18:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -878,7 +878,7 @@ 171 ], "referencedDeclaration": 170, - "src": "865:7:0", + "src": "851:7:0", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" @@ -892,7 +892,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "865:28:0", + "src": "851:28:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -900,7 +900,7 @@ }, "id": 65, "nodeType": "ExpressionStatement", - "src": "865:28:0" + "src": "851:28:0" }, { "expression": { @@ -935,7 +935,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 55, - "src": "949:12:0", + "src": "935:12:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -953,7 +953,7 @@ "kind": "number", "lValueRequested": false, "nodeType": "Literal", - "src": "964:1:0", + "src": "950:1:0", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", @@ -961,7 +961,7 @@ }, "value": "0" }, - "src": "949:16:0", + "src": "935:16:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -987,7 +987,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 55, - "src": "969:12:0", + "src": "955:12:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1002,19 +1002,19 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 18, - "src": "985:15:0", + "src": "971:15:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "969:31:0", + "src": "955:31:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, - "src": "949:51:0", + "src": "935:51:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -1036,7 +1036,7 @@ 171 ], "referencedDeclaration": 170, - "src": "941:7:0", + "src": "927:7:0", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" @@ -1050,7 +1050,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "941:60:0", + "src": "927:60:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -1058,7 +1058,7 @@ }, "id": 75, "nodeType": "ExpressionStatement", - "src": "941:60:0" + "src": "927:60:0" }, { "expression": { @@ -1077,7 +1077,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 12, - "src": "1051:6:0", + "src": "1037:6:0", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", "typeString": "mapping(address => bool)" @@ -1093,7 +1093,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 167, - "src": "1058:3:0", + "src": "1044:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -1107,7 +1107,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "1058:10:0", + "src": "1044:10:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1118,7 +1118,7 @@ "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", - "src": "1051:18:0", + "src": "1037:18:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -1136,7 +1136,7 @@ "kind": "bool", "lValueRequested": false, "nodeType": "Literal", - "src": "1072:4:0", + "src": "1058:4:0", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_bool", @@ -1144,7 +1144,7 @@ }, "value": "true" }, - "src": "1051:25:0", + "src": "1037:25:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -1152,7 +1152,7 @@ }, "id": 82, "nodeType": "ExpressionStatement", - "src": "1051:25:0" + "src": "1037:25:0" }, { "expression": { @@ -1165,7 +1165,7 @@ "nodeType": "UnaryOperation", "operator": "++", "prefix": false, - "src": "1126:37:0", + "src": "1112:37:0", "subExpression": { "argumentTypes": null, "expression": { @@ -1177,7 +1177,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 16, - "src": "1126:10:0", + "src": "1112:10:0", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", "typeString": "mapping(uint256 => struct Election.Candidate storage ref)" @@ -1191,7 +1191,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 55, - "src": "1137:12:0", + "src": "1123:12:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1202,7 +1202,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "1126:24:0", + "src": "1112:24:0", "typeDescriptions": { "typeIdentifier": "t_struct$_Candidate_$8_storage", "typeString": "struct Election.Candidate storage ref" @@ -1216,7 +1216,7 @@ "memberName": "voteCount", "nodeType": "MemberAccess", "referencedDeclaration": 7, - "src": "1126:34:0", + "src": "1112:34:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1229,7 +1229,7 @@ }, "id": 88, "nodeType": "ExpressionStatement", - "src": "1126:37:0" + "src": "1112:37:0" }, { "eventCall": { @@ -1242,7 +1242,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 55, - "src": "1221:12:0", + "src": "1207:12:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1261,7 +1261,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 22, - "src": "1210:10:0", + "src": "1196:10:0", "typeDescriptions": { "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$returns$__$", "typeString": "function (uint256)" @@ -1275,7 +1275,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "1210:24:0", + "src": "1196:24:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -1283,7 +1283,7 @@ }, "id": 92, "nodeType": "EmitStatement", - "src": "1205:29:0" + "src": "1191:29:0" } ] }, @@ -1305,7 +1305,7 @@ "name": "_candidateId", "nodeType": "VariableDeclaration", "scope": 94, - "src": "779:17:0", + "src": "765:17:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -1316,7 +1316,7 @@ "id": 54, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "779:4:0", + "src": "765:4:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1326,27 +1326,27 @@ "visibility": "internal" } ], - "src": "778:19:0" + "src": "764:19:0" }, "payable": false, "returnParameters": { "id": 57, "nodeType": "ParameterList", "parameters": [], - "src": "805:0:0" + "src": "791:0:0" }, "scope": 95, - "src": "764:477:0", + "src": "750:477:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" } ], "scope": 96, - "src": "25:1218:0" + "src": "25:1204:0" } ], - "src": "0:1244:0" + "src": "0:1230:0" }, "legacyAST": { "absolutePath": "/home/aj/Files/Projects/Codefundo/CodeFunDo19/contracts/Election.sol", @@ -1634,7 +1634,7 @@ "body": { "id": 33, "nodeType": "Block", - "src": "515:81:0", + "src": "515:67:0", "statements": [ { "expression": { @@ -1642,7 +1642,7 @@ "arguments": [ { "argumentTypes": null, - "hexValue": "43616e6469646174652031", + "hexValue": "416c696365", "id": 26, "isConstant": false, "isLValue": false, @@ -1650,20 +1650,20 @@ "kind": "string", "lValueRequested": false, "nodeType": "Literal", - "src": "538:13:0", + "src": "538:7:0", "subdenomination": null, "typeDescriptions": { - "typeIdentifier": "t_stringliteral_41f9dcbd43e9b33194759b5a51b1df9864cdc2b2138ff106f03091eb79861f0c", - "typeString": "literal_string \"Candidate 1\"" + "typeIdentifier": "t_stringliteral_81376b9868b292a46a1c486d344e427a3088657fda629b5f4a647822d329cd6a", + "typeString": "literal_string \"Alice\"" }, - "value": "Candidate 1" + "value": "Alice" } ], "expression": { "argumentTypes": [ { - "typeIdentifier": "t_stringliteral_41f9dcbd43e9b33194759b5a51b1df9864cdc2b2138ff106f03091eb79861f0c", - "typeString": "literal_string \"Candidate 1\"" + "typeIdentifier": "t_stringliteral_81376b9868b292a46a1c486d344e427a3088657fda629b5f4a647822d329cd6a", + "typeString": "literal_string \"Alice\"" } ], "id": 25, @@ -1685,7 +1685,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "525:27:0", + "src": "525:21:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -1693,7 +1693,7 @@ }, "id": 28, "nodeType": "ExpressionStatement", - "src": "525:27:0" + "src": "525:21:0" }, { "expression": { @@ -1701,7 +1701,7 @@ "arguments": [ { "argumentTypes": null, - "hexValue": "43616e6469646174652032", + "hexValue": "426f62", "id": 30, "isConstant": false, "isLValue": false, @@ -1709,20 +1709,20 @@ "kind": "string", "lValueRequested": false, "nodeType": "Literal", - "src": "575:13:0", + "src": "569:5:0", "subdenomination": null, "typeDescriptions": { - "typeIdentifier": "t_stringliteral_f1f17440f69835dafba5c9fd0e4caa6c780807a80f8d1745ec7af1408d6cca4a", - "typeString": "literal_string \"Candidate 2\"" + "typeIdentifier": "t_stringliteral_28cac318a86c8a0a6a9156c2dba2c8c2363677ba0514ef616592d81557e679b6", + "typeString": "literal_string \"Bob\"" }, - "value": "Candidate 2" + "value": "Bob" } ], "expression": { "argumentTypes": [ { - "typeIdentifier": "t_stringliteral_f1f17440f69835dafba5c9fd0e4caa6c780807a80f8d1745ec7af1408d6cca4a", - "typeString": "literal_string \"Candidate 2\"" + "typeIdentifier": "t_stringliteral_28cac318a86c8a0a6a9156c2dba2c8c2363677ba0514ef616592d81557e679b6", + "typeString": "literal_string \"Bob\"" } ], "id": 29, @@ -1730,7 +1730,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 53, - "src": "562:12:0", + "src": "556:12:0", "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$_t_string_memory_ptr_$returns$__$", "typeString": "function (string memory)" @@ -1744,7 +1744,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "562:27:0", + "src": "556:19:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -1752,7 +1752,7 @@ }, "id": 32, "nodeType": "ExpressionStatement", - "src": "562:27:0" + "src": "556:19:0" } ] }, @@ -1778,7 +1778,7 @@ "src": "515:0:0" }, "scope": 95, - "src": "493:103:0", + "src": "493:89:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -1787,7 +1787,7 @@ "body": { "id": 52, "nodeType": "Block", - "src": "647:111:0", + "src": "633:111:0", "statements": [ { "expression": { @@ -1800,7 +1800,7 @@ "nodeType": "UnaryOperation", "operator": "++", "prefix": false, - "src": "657:18:0", + "src": "643:18:0", "subExpression": { "argumentTypes": null, "id": 39, @@ -1808,7 +1808,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 18, - "src": "657:15:0", + "src": "643:15:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1821,7 +1821,7 @@ }, "id": 41, "nodeType": "ExpressionStatement", - "src": "657:18:0" + "src": "643:18:0" }, { "expression": { @@ -1840,7 +1840,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 16, - "src": "685:10:0", + "src": "671:10:0", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", "typeString": "mapping(uint256 => struct Election.Candidate storage ref)" @@ -1854,7 +1854,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 18, - "src": "696:15:0", + "src": "682:15:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1865,7 +1865,7 @@ "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", - "src": "685:27:0", + "src": "671:27:0", "typeDescriptions": { "typeIdentifier": "t_struct$_Candidate_$8_storage", "typeString": "struct Election.Candidate storage ref" @@ -1883,7 +1883,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 18, - "src": "725:15:0", + "src": "711:15:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1896,7 +1896,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, - "src": "742:5:0", + "src": "728:5:0", "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string memory" @@ -1912,7 +1912,7 @@ "kind": "number", "lValueRequested": false, "nodeType": "Literal", - "src": "749:1:0", + "src": "735:1:0", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", @@ -1941,7 +1941,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 8, - "src": "715:9:0", + "src": "701:9:0", "typeDescriptions": { "typeIdentifier": "t_type$_t_struct$_Candidate_$8_storage_ptr_$", "typeString": "type(struct Election.Candidate storage pointer)" @@ -1955,13 +1955,13 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "715:36:0", + "src": "701:36:0", "typeDescriptions": { "typeIdentifier": "t_struct$_Candidate_$8_memory", "typeString": "struct Election.Candidate memory" } }, - "src": "685:66:0", + "src": "671:66:0", "typeDescriptions": { "typeIdentifier": "t_struct$_Candidate_$8_storage", "typeString": "struct Election.Candidate storage ref" @@ -1969,7 +1969,7 @@ }, "id": 51, "nodeType": "ExpressionStatement", - "src": "685:66:0" + "src": "671:66:0" } ] }, @@ -1991,7 +1991,7 @@ "name": "_name", "nodeType": "VariableDeclaration", "scope": 53, - "src": "625:12:0", + "src": "611:12:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -2002,7 +2002,7 @@ "id": 35, "name": "string", "nodeType": "ElementaryTypeName", - "src": "625:6:0", + "src": "611:6:0", "typeDescriptions": { "typeIdentifier": "t_string_storage_ptr", "typeString": "string" @@ -2012,17 +2012,17 @@ "visibility": "internal" } ], - "src": "624:14:0" + "src": "610:14:0" }, "payable": false, "returnParameters": { "id": 38, "nodeType": "ParameterList", "parameters": [], - "src": "647:0:0" + "src": "633:0:0" }, "scope": 95, - "src": "602:156:0", + "src": "588:156:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "private" @@ -2031,7 +2031,7 @@ "body": { "id": 93, "nodeType": "Block", - "src": "805:436:0", + "src": "791:436:0", "statements": [ { "expression": { @@ -2047,7 +2047,7 @@ "nodeType": "UnaryOperation", "operator": "!", "prefix": true, - "src": "873:19:0", + "src": "859:19:0", "subExpression": { "argumentTypes": null, "baseExpression": { @@ -2057,7 +2057,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 12, - "src": "874:6:0", + "src": "860:6:0", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", "typeString": "mapping(address => bool)" @@ -2073,7 +2073,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 167, - "src": "881:3:0", + "src": "867:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -2087,7 +2087,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "881:10:0", + "src": "867:10:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -2098,7 +2098,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "874:18:0", + "src": "860:18:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -2125,7 +2125,7 @@ 171 ], "referencedDeclaration": 170, - "src": "865:7:0", + "src": "851:7:0", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" @@ -2139,7 +2139,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "865:28:0", + "src": "851:28:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -2147,7 +2147,7 @@ }, "id": 65, "nodeType": "ExpressionStatement", - "src": "865:28:0" + "src": "851:28:0" }, { "expression": { @@ -2182,7 +2182,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 55, - "src": "949:12:0", + "src": "935:12:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2200,7 +2200,7 @@ "kind": "number", "lValueRequested": false, "nodeType": "Literal", - "src": "964:1:0", + "src": "950:1:0", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", @@ -2208,7 +2208,7 @@ }, "value": "0" }, - "src": "949:16:0", + "src": "935:16:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -2234,7 +2234,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 55, - "src": "969:12:0", + "src": "955:12:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2249,19 +2249,19 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 18, - "src": "985:15:0", + "src": "971:15:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "969:31:0", + "src": "955:31:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, - "src": "949:51:0", + "src": "935:51:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -2283,7 +2283,7 @@ 171 ], "referencedDeclaration": 170, - "src": "941:7:0", + "src": "927:7:0", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" @@ -2297,7 +2297,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "941:60:0", + "src": "927:60:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -2305,7 +2305,7 @@ }, "id": 75, "nodeType": "ExpressionStatement", - "src": "941:60:0" + "src": "927:60:0" }, { "expression": { @@ -2324,7 +2324,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 12, - "src": "1051:6:0", + "src": "1037:6:0", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", "typeString": "mapping(address => bool)" @@ -2340,7 +2340,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 167, - "src": "1058:3:0", + "src": "1044:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -2354,7 +2354,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "1058:10:0", + "src": "1044:10:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -2365,7 +2365,7 @@ "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", - "src": "1051:18:0", + "src": "1037:18:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -2383,7 +2383,7 @@ "kind": "bool", "lValueRequested": false, "nodeType": "Literal", - "src": "1072:4:0", + "src": "1058:4:0", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_bool", @@ -2391,7 +2391,7 @@ }, "value": "true" }, - "src": "1051:25:0", + "src": "1037:25:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -2399,7 +2399,7 @@ }, "id": 82, "nodeType": "ExpressionStatement", - "src": "1051:25:0" + "src": "1037:25:0" }, { "expression": { @@ -2412,7 +2412,7 @@ "nodeType": "UnaryOperation", "operator": "++", "prefix": false, - "src": "1126:37:0", + "src": "1112:37:0", "subExpression": { "argumentTypes": null, "expression": { @@ -2424,7 +2424,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 16, - "src": "1126:10:0", + "src": "1112:10:0", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", "typeString": "mapping(uint256 => struct Election.Candidate storage ref)" @@ -2438,7 +2438,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 55, - "src": "1137:12:0", + "src": "1123:12:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2449,7 +2449,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "1126:24:0", + "src": "1112:24:0", "typeDescriptions": { "typeIdentifier": "t_struct$_Candidate_$8_storage", "typeString": "struct Election.Candidate storage ref" @@ -2463,7 +2463,7 @@ "memberName": "voteCount", "nodeType": "MemberAccess", "referencedDeclaration": 7, - "src": "1126:34:0", + "src": "1112:34:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2476,7 +2476,7 @@ }, "id": 88, "nodeType": "ExpressionStatement", - "src": "1126:37:0" + "src": "1112:37:0" }, { "eventCall": { @@ -2489,7 +2489,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 55, - "src": "1221:12:0", + "src": "1207:12:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2508,7 +2508,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 22, - "src": "1210:10:0", + "src": "1196:10:0", "typeDescriptions": { "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$returns$__$", "typeString": "function (uint256)" @@ -2522,7 +2522,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "1210:24:0", + "src": "1196:24:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -2530,7 +2530,7 @@ }, "id": 92, "nodeType": "EmitStatement", - "src": "1205:29:0" + "src": "1191:29:0" } ] }, @@ -2552,7 +2552,7 @@ "name": "_candidateId", "nodeType": "VariableDeclaration", "scope": 94, - "src": "779:17:0", + "src": "765:17:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -2563,7 +2563,7 @@ "id": 54, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "779:4:0", + "src": "765:4:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2573,27 +2573,27 @@ "visibility": "internal" } ], - "src": "778:19:0" + "src": "764:19:0" }, "payable": false, "returnParameters": { "id": 57, "nodeType": "ParameterList", "parameters": [], - "src": "805:0:0" + "src": "791:0:0" }, "scope": 95, - "src": "764:477:0", + "src": "750:477:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" } ], "scope": 96, - "src": "25:1218:0" + "src": "25:1204:0" } ], - "src": "0:1244:0" + "src": "0:1230:0" }, "compiler": { "name": "solc", @@ -2603,12 +2603,12 @@ "5777": { "events": {}, "links": {}, - "address": "0x9e309fAa91BEf552C539dF4F94FC29E3514d322A", - "transactionHash": "0x788830a32f912747035670bae7d0e5c501843681ea2f4c49c5cf5f170199c692" + "address": "0x1b7d336456823C8818297431106B6280ab52600C", + "transactionHash": "0xdcd747c23681e221039ea4fdc1691cc9be71c0e037782dcddcf7f33633d58778" } }, "schemaVersion": "3.0.11", - "updatedAt": "2019-08-15T12:50:53.889Z", + "updatedAt": "2019-08-21T09:12:27.971Z", "devdoc": { "methods": {} }, diff --git a/build/contracts/Migrations.json b/build/contracts/Migrations.json index 18d3eb76..e9e98c79 100644 --- a/build/contracts/Migrations.json +++ b/build/contracts/Migrations.json @@ -1379,12 +1379,12 @@ "5777": { "events": {}, "links": {}, - "address": "0xd33eF960eB5cdbFb3430Ef028c180192D54995BC", - "transactionHash": "0x76d6be26fa8a8c2f296172b0a3c38b2d7d757e4c8adfbb3f95c4eab8ac4d350f" + "address": "0xfd3855191a4F0c23213c435fa0aC8b0b21F4397f", + "transactionHash": "0xc8e006a91523ede4560a345e8142bbd2dbce95d6c6078bed499a1f9194bb2b6a" } }, "schemaVersion": "3.0.11", - "updatedAt": "2019-08-15T12:50:53.892Z", + "updatedAt": "2019-08-21T09:12:27.974Z", "devdoc": { "methods": {} }, diff --git a/contracts/Election.sol b/contracts/Election.sol index 52cf6c64..2e9d3d22 100644 --- a/contracts/Election.sol +++ b/contracts/Election.sol @@ -22,8 +22,8 @@ contract Election { ); constructor () public { - addCandidate("Candidate 1"); - addCandidate("Candidate 2"); + addCandidate("Alice"); + addCandidate("Bob"); } function addCandidate (string _name) private { diff --git a/src/index.html b/src/index.html index db83c5ac..a91ada4c 100644 --- a/src/index.html +++ b/src/index.html @@ -51,7 +51,7 @@


-

+

diff --git a/src/js/app.js b/src/js/app.js index 14085b51..e8002784 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -7,7 +7,7 @@ App = { closingTime: { year: 2019, month: 7, - date: 22, + date: 21, hour: 21, minutes: 0, seconds: 0, From 3a569390ecfe39feeb06c4e5d929c92a23a41b7c Mon Sep 17 00:00:00 2001 From: Ashwin Joisa Date: Wed, 21 Aug 2019 15:50:34 +0530 Subject: [PATCH 5/5] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1e615641..515183e8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +### Team : WeAreInevitable + # Idea To make an online voting application using Azure Blockchain which can give the poll results immediately after the voting session, and is secure from any kind of manipulation of data. Since an online voting can be done remotely from anywhere in the world, authenticating and authorizing the user is of utmost importance. To do this we use 2-factor authentication ,the first being facial recognition and the second being OTP verification.