This repository was archived by the owner on Aug 29, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIVotingSystem.sol
More file actions
181 lines (135 loc) · 4.93 KB
/
Copy pathIVotingSystem.sol
File metadata and controls
181 lines (135 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.26;
/**
* @title Voting System
* @notice Interface for the Voting System contract
*/
interface IVotingSystem {
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
/**
* @notice Emitted when a new proposal is created
* @param _proposal The proposal created
*/
event ProposalCreated(Proposal _proposal);
/**
* @notice Emitted when a new voter is added
* @param _voter The address of the voter added
*/
event VoterAdded(address _voter);
/**
* @notice Emitted when a voter votes
* @param _index The index of the proposal voted
* @param _voter The address of the voter
*/
event ProposalVoted(uint256 _index, address _voter);
/**
* @notice Emitted when a proposal is approved
* @param _proposal The proposal approved
*/
event ProposalApproved(Proposal _proposal);
/*///////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
/**
* @notice Thrown when the user is not a voter
*/
error IVotingSystem_UserIsNotVoter();
/**
* @notice Thrown when the description of the proposal is empty
*/
error IVotingSystem_DescriptionIsRequired();
/**
* @notice Thrown when the proposal does not exist
*/
error IVotingSystem_ProposalNotExists();
/**
* @notice Thrown when the user already voted
*/
error IVotingSystem_UserAlreadyVoted();
/**
* @notice Thrown when the proposal is expired
*/
error IVotingSystem_ProposalExpired();
error IVotingSystem_DescriptionExist();
error IVotingSystem_VoterExsit();
/*///////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
/**
* @notice Struct to represent a proposal
* @param description The description of the proposal
* @param voteCount The number of votes of the proposal
* @param neededVotes The number of votes needed to approve the proposal
* @param finalDate The final date of the proposal
*/
struct Proposal {
string description;
uint256 voteCount;
uint256 neededVotes;
uint256 finalDate;
}
/*///////////////////////////////////////////////////////////////
VIEW FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @notice Returns the expiration time of the proposals
* @return _proposalExpiration The expiration time of the proposals
*/
function PROPOSAL_EXPIRATION() external view returns (uint256 _proposalExpiration);
/**
* @notice Returns the number of proposals
* @return _proposalCount The number of proposals
*/
function proposalCount() external view returns (uint256 _proposalCount);
/**
* @notice Returns the proposals
* @param _index The index of the proposal
* @return _description The description of the proposal
* @return _voteCount The number of votes of the proposal
* @return _neededVotes The number of votes needed to approve the proposal
* @return _finalDate The final date of the proposal
*/
function proposals(uint256 _index)
external
view
returns (string memory _description, uint256 _voteCount, uint256 _neededVotes, uint256 _finalDate);
/**
* @notice Returns if the user voted
* @param _index The index of the proposal
* @param _user The address of the user
* @return _isVoted If the user voted
*/
function proposalIsVoted(uint256 _index, address _user) external view returns (bool _isVoted);
/**
* @notice Returns the proposals
* @return _getProposals The proposals
*/
function getProposals() external view returns (Proposal[] memory _getProposals);
/*///////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @notice Add a new voter
* @param _voter The address of the voter
*/
function addVoter(address _voter) external;
/**
* @notice Create a new proposal
* @param _description The description of the proposal
*/
function createProposal(string memory _description) external;
/**
* @notice Vote a proposal
* @param _index The index of the proposal
*/
function voteProposal(uint256 _index) external;
function _voters() external;
/**
* @notice Finish proposal using a pagination system
* @param _startIndex The start index of the proposal
* @param _lastIndex The last index of the proposal
*/
function finishProposals(uint256 _startIndex, uint256 _lastIndex) external;
}