-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Proposal Creation and Retrieval with Security Enhancements #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nicholas-source
wants to merge
19
commits into
main
Choose a base branch
from
feature/proposal-management
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added contract-owner constant - Added error constants
- Added proposal-count data variable - Added proposals map - Added votes map - Added vote-counts map
- Added create-proposal function to create new proposals - Includes validation for contract owner - Updates proposal-count
- Added vote function to allow voting on proposals - Includes validation for proposal existence, active status, and vote option range - Updates votes and vote-counts maps
- Added get-proposal function to retrieve proposal details - Added get-vote function to retrieve a specific vote - Added get-vote-count function to retrieve vote count for an option - Added get-total-votes function to retrieve total votes for a proposal
Refactor increment-total-votes function to use match expression Refactor get-total-votes function to use match expression
…EchoVote contract
This commit adds a new configuration file, `index.ts`, which exports an object containing various configuration options for the application. It also adds a new API endpoint in the `index.ts` file, which responds with a simple message to indicate that the EchoVote API is running.
- Added express import - Added proposalService import - Initialized express router
- Added POST route for creating proposals - Handles request body and calls createProposal service - Returns 201 status on success - Returns 500 status on error - Added createProposal function in proposalService
- Added GET route for fetching proposals by ID - Handles request params and calls getProposal service - Returns proposal data on success - Returns 404 status if proposal not found - Returns 500 status on error - Added getProposal function in proposalService
- Improved variable naming - Added comments for better understanding - Structured code for better readability
- Fixed bug in proposal ID parsing - Fixed bug in error handling
- Added validation for request body - Ensured only authorized users can create proposals
- Reverted previous commit due to identified issues
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This pull request introduces essential features for the EchoVote decentralized voting system, focusing on creating and retrieving proposals. Key additions include the implementation of proposal-related routes, services, and security checks. It also includes a rollback of a previous security change due to identified issues.
Summary of Changes:
Initial Setup & Imports:
proposalService
to handle proposal-related business logic.Basic structure and import statements.
Proposal Creation (POST /api/proposals):
POST
route for creating proposals.createProposal
function inproposalService
.201 Created
on success.500 Internal Server Error
on failure.Implement createProposal route and service.
Proposal Retrieval (GET /api/proposals/:id):
GET
route for fetching proposals by ID.getProposal
function inproposalService
.200 OK
with proposal data on success.404 Not Found
if the proposal does not exist.500 Internal Server Error
on failure.Implement getProposal route and service.
Refactoring & Bug Fixes:
Refactor code for readability.
Fix bugs in route handlers and service functions.
Security Enhancements:
Add security checks.
Gitignore & Reversion:
.gitignore
to include the.env
file to protect sensitive information.Add .env file to .gitignore.
Revert changes.
Testing:
POST /api/proposals
to create a proposal.GET /api/proposals/:id
to retrieve proposals by ID.Next Steps:
Additional Notes:
This PR lays the foundation for proposal management in EchoVote and is essential for the upcoming voting-related features. The codebase has been refactored for improved maintainability and clarity, and critical security practices have been integrated to ensure the integrity of the platform.