Enhance EchoVote Smart Contract with Comments, Configuration, and API Endpoint#1
Open
nicholas-source wants to merge 12 commits intomainfrom
Open
Enhance EchoVote Smart Contract with Comments, Configuration, and API Endpoint#1nicholas-source wants to merge 12 commits intomainfrom
nicholas-source wants to merge 12 commits intomainfrom
Conversation
- 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.
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
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.
Overview:
This pull request introduces a series of enhancements to the EchoVote decentralized voting system, primarily focusing on improving code clarity, maintainability, and extending functionality. Key changes include the addition of detailed comments, configuration setup, and the implementation of a basic API endpoint.
Changes:
Added Detailed Comments:
Initial Contract Setup:
contract-ownerand various error codes.proposal-count,proposals,votes, andvote-countsto support the EchoVote functionality.Core Functionality Implementation:
create-proposal: Allows the contract owner to create new proposals with validation on the proposal’s title, description, and start/end blocks.vote: Enables users to vote on active proposals while ensuring the proposal exists, is active, and the vote option is valid.get-proposal,get-vote,get-vote-count, andget-total-votes: Implemented read-only functions to retrieve proposal details, vote information, and vote statistics.Validation and Error Handling:
Refactoring:
increment-total-votesandget-total-votesfunctions to usematchexpressions for cleaner and more concise logic.Configuration and API Endpoint:
index.tsto manage various configuration options for the EchoVote application.Commit History:
e721e3e: Added contract-owner constant and error constants.75a4255: Addedproposal-countdata variable and core maps (proposals,votes,vote-counts).8893839: Implementedcreate-proposalfunction with validation and proposal count update.f425c1c: Implementedvotefunction with necessary validation and vote counting logic.a09ef13: Added read-only functions for retrieving proposal details, vote data, and total votes.1c1c10c: Implemented validation for proposal title, description, and block constraints.62a4f1c: Refactored vote counting logic and added error constant for proposal not found.8cde11d: Added detailed comments to all aspects of the smart contract.index.ts: Added configuration file and new API endpoint to indicate the status of the EchoVote API.Testing:
Notes:
This PR represents a significant improvement to the EchoVote smart contract and application, making the code more maintainable while laying the groundwork for future extensions. Please review the changes and provide feedback.