Skip to content

Commit

Permalink
Evote
Browse files Browse the repository at this point in the history
for the evoting mechanism
  • Loading branch information
nxansari committed Jul 16, 2021
1 parent ef13415 commit 4666f52
Show file tree
Hide file tree
Showing 24 changed files with 85,111 additions and 0 deletions.
14 changes: 14 additions & 0 deletions votingApp/migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var VotingContract = artifacts.require("VotingContract")
var eVotingToken = artifacts.require("eVotingToken")

module.exports = async function(deployer) {

// Deploy eVotingContract
await deployer.deploy(eVotingToken)
// Fetch the address of deployed eVotingContract
const eVote = await eVotingToken.deployed()

// Deploy votingContract
await deployer.deploy(VotingContract, eVote.address)
await VotingContract.deployed()
};
35,241 changes: 35,241 additions & 0 deletions votingApp/package-lock.json

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions votingApp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "voting-app",
"version": "0.1.0",
"description": "eGovernance Voting App",
"author": "SalMan HaidEr / ravian.salman@hotmail.com",
"dependencies": {
"babel-polyfill": "6.26.0",
"babel-preset-env": "1.7.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-stage-2": "6.24.1",
"babel-preset-stage-3": "6.24.1",
"babel-register": "6.26.0",
"bootstrap": "4.3.1",
"chai": "^4.2.0",
"chai-as-promised": "7.1.1",
"chai-bignumber": "3.0.0",
"dotenv": "^10.0.0",
"identicon.js": "^2.3.3",
"react": "16.8.4",
"react-bootstrap": "1.0.0-beta.5",
"react-dom": "16.8.4",
"react-redux": "^7.2.4",
"react-scripts": "2.1.3",
"redux-thunk": "^2.3.0",
"truffle": "^5.3.0",
"truffle-hdwallet-provider": "^1.0.17",
"web3": "^1.2.11"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
82 changes: 82 additions & 0 deletions votingApp/public/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
App = {
web3Provider: null,
contracts: {},
account: '0x0',

init: function() {
return App.initWeb3();
},

initWeb3: function() {
if (typeof web3 !== 'undefined') {
// If a web3 instance is already provided by Meta Mask.
App.web3Provider = web3.currentProvider;
web3 = new Web3(web3.currentProvider);
} else {
// Specify default instance if no web3 instance provided
App.web3Provider = new Web3.providers.HttpProvider('http://localhost:7545');
web3 = new Web3(App.web3Provider);
}
return App.initContract();
},

initContract: function() {
$.getJSON("Election.json", function(election) {
// Instantiate a new truffle contract from the artifact
App.contracts.Election = TruffleContract(election);
// Connect provider to interact with contract
App.contracts.Election.setProvider(App.web3Provider);

return App.render();
});
},

render: function() {
var electionInstance;
var loader = $("#loader");
var content = $("#content");

loader.show();
content.hide();

// Load account data
web3.eth.getCoinbase(function(err, account) {
if (err === null) {
App.account = account;
$("#accountAddress").html("Your Account: " + account);
}
});

// Load contract data
App.contracts.Election.deployed().then(function(instance) {
electionInstance = instance;
return electionInstance.candidatesCount();
}).then(function(candidatesCount) {
var candidatesResults = $("#candidatesResults");
candidatesResults.empty();

for (var i = 1; i <= candidatesCount; i++) {
electionInstance.candidates(i).then(function(candidate) {
var id = candidate[0];
var name = candidate[1];
var voteCount = candidate[2];

// Render candidate Result
var candidateTemplate = "<tr><th>" + id + "</th><td>" + name + "</td><td>" + voteCount + "</td></tr>"
candidatesResults.append(candidateTemplate);
});
}

loader.hide();
content.show();
}).catch(function(error) {
console.warn(error);
});
}
};

$(function() {
$(window).load(function() {
App.init();
});
});
Binary file added votingApp/public/favicon.ico
Binary file not shown.
41 changes: 41 additions & 0 deletions votingApp/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Dapp Token Farm</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
15 changes: 15 additions & 0 deletions votingApp/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "Starter Kit",
"name": "Dapp Token Farm",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
Loading

0 comments on commit 4666f52

Please sign in to comment.