Skip to content

Commit

Permalink
Created Election Transaction Logic
Browse files Browse the repository at this point in the history
Missing ID Hashing
#10
  • Loading branch information
Arpit007 committed Mar 6, 2019
1 parent 6378fc2 commit bb254bc
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions chain_code/lib/election.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,19 @@ async function createElection(electionData) {
const namespace = 'org.astria.election';
const resourceId = 'Election';

const { adminId, electionName, startDate, endDate } = electionData;

const electionRegistry = await getAssetRegistry(`${namespace}.${resourceId}`);
const factory = getFactory();

const electionId = generateId('Election');
const electionId = `${resourceId}-${adminId}-1`;
const election = factory.newResource(namespace, resourceId, electionId);

election.electionName = electionData.electionName;
election.startDate = electionData.startDate;
election.endDate = electionData.endDate;
election.electionName = electionName;
election.startDate = startDate;
election.endDate = endDate;
election.candidates = [];
election.admin = factory.newRelationship('org.astria.participant', 'AstriaAdmin', electionData.adminId);
election.admin = factory.newRelationship('org.astria.participant', 'AstriaAdmin', adminId);

return electionRegistry.add(election);
}

function generateId(role) {
/*
* Todo: Fix
* */
return `${role}${new Date().getTime()}`;
}

0 comments on commit bb254bc

Please sign in to comment.