Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
deploy/crypto_vote_*
4 changes: 1 addition & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ app.get('/', (req, res) => {
res.sendFile('/public/index.html');
})


app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})


app.get('/mock-election', (req, res) => {
const results = mockElection(10)
const results = mockElection(100)
res.send(results)
})

Expand Down
Empty file added deploy/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# stellar contract deploy files
contains WASM files built from soroban-crypto-vote.

each 'election' and 'ballot' instance requires one of these files is deployed to the stellar blockchain.
once we've deployed a contract and created a ledger (aka a 'block' on the chain), we can invoke functions as required.
11 changes: 6 additions & 5 deletions mockElection.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ function generateMockVoter(voteObj) {
// we need to create a way for a voter to access their ballot after it's been created
// maybe a UUID that is returned to the voter... ideally something like a SSN would be "best"
const randomVoterId = randomUUID()
console.log("🚀 ~ generateMockVoter ~ randomVoterId:", randomVoterId)
console.log("randomVoterId:", randomVoterId)
console.log('is voting for:', voteObj)
new Ballot(randomVoterId).sendItem(voteObj, GLOBAL_BALLOT.publicKey);
// console.log('voter ballot '+ voter_ballot)
return 'this is your unique voter ID, save it so you can view your vote later: ' + randomVoterId
}

function generateMockVote() {
const candidates = ['alpha', 'beta', 'gamma'];
const values = [1, 2, 3];
// const candidates = ['bush', 'gore'];
// const values = [1, 2];
const candidates = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'upsilon', 'omega'];
const values = [1, 2, 3, 4, 5, 6, 7, 8];
const obj = {};
candidates.forEach(prop => {
const randomIndex = Math.floor(Math.random() * values.length);
Expand Down Expand Up @@ -53,8 +56,6 @@ function countVotes() {
return GLOBAL_CHAIN.countVotes();
}



module.exports = {
generateMockVotes,
generateMockVote,
Expand Down
Loading