Skip to content

Commit 12a182e

Browse files
Merge pull request #3 from yeniyan-group/get-election-result-as-read
fix: accredite voted voter resets voter to accredited again
2 parents f48c370 + 044101c commit 12a182e

File tree

5 files changed

+573
-274
lines changed

5 files changed

+573
-274
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ forge build
9191
The VotsEngine contract is currently deployed and live on multiple testnets:
9292

9393
### Sepolia Testnet
94-
**VotsEngine Contract**: `0x91f995B3160af869F8bDB9d031648363CACdC60F`
94+
**VotsEngine Contract**: `0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41`
9595

96-
**NFT Contract**: `0xD34359FCFB6596CBf2ce4b146AF98402CEe4f8B5`
96+
**NFT Contract**: `0x2482E5690D3AF17986a8D17fD847ff444Baa6Ce9`
9797

9898
**Network**: Sepolia Testnet
9999
- **Chain ID**: 11155111
100-
- **VotsEngine Block Explorer**: https://sepolia.etherscan.io/address/0x91f995B3160af869F8bDB9d031648363CACdC60F
101-
- **NFT Contract Block Explorer**: https://sepolia.etherscan.io/address/0xD34359FCFB6596CBf2ce4b146AF98402CEe4f8B5
100+
- **VotsEngine Block Explorer**: https://sepolia.etherscan.io/address/0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41
101+
- **NFT Contract Block Explorer**: https://sepolia.etherscan.io/address/0x2482E5690D3AF17986a8D17fD847ff444Baa6Ce9
102102

103103
### Fuji Testnet (Avalanche)
104104
**VotsEngine Contract**: `0xed7eA5221041A1982d9d257c9617B1448032838d`
@@ -120,7 +120,7 @@ You can interact with the deployed contract using:
120120

121121
```javascript
122122
// Example using ethers.js with Sepolia
123-
const sepoliaContractAddress = "0x91f995B3160af869F8bDB9d031648363CACdC60F....";
123+
const sepoliaContractAddress = "0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41....";
124124
const VotsEngineSepoliaClient = new ethers.Contract(sepoliaContractAddress, abi, sepoliaProvider);
125125

126126
// Example using ethers.js with Fuji
@@ -146,7 +146,7 @@ The VotsEngine system requires a **hybrid physical-digital infrastructure**:
146146
### Deploying the System
147147

148148
The VotsEngine is already deployed on multiple testnets:
149-
- **Sepolia**: `0x91f995B3160af869F8bDB9d031648363CACdC60F....`
149+
- **Sepolia**: `0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41....`
150150
- **Fuji (Avalanche)**: `0xed7eA5221041A1982d9d257c9617B1448032838d`
151151

152152
For local development or custom deployments:
@@ -161,7 +161,7 @@ Or connect to the existing deployments:
161161
```javascript
162162
// Connect to Sepolia deployment
163163
const VotsEngineSepoliaClient = new ethers.Contract(
164-
"0x91f995B3160af869F8bDB9d031648363CACdC60F....",
164+
"0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41....",
165165
VotsEngineABI,
166166
sepoliaProvider
167167
);

broadcast/DeployVotsEngine.s.sol/11155111/run-1753543173.json

Lines changed: 373 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/DeployVotsEngine.s.sol/11155111/run-latest.json

Lines changed: 143 additions & 143 deletions
Large diffs are not rendered by default.

src/Election.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,15 @@ contract Election is IElection, Ownable {
731731
onElectionStarted
732732
noUnknown(voterMatricNo)
733733
{
734-
if (_votersMap[voterMatricNo].voterState == VoterState.ACCREDITED) {
734+
// Add explicit logging for debugging
735+
VoterState currentState = _votersMap[voterMatricNo].voterState;
736+
// if voter is voted or accredited revert
737+
if (currentState == VoterState.ACCREDITED) {
735738
revert Election__VoterAlreadyAccredited();
736739
}
740+
if (currentState == VoterState.VOTED) {
741+
revert Election__VoterAlreadyVoted();
742+
}
737743
_votersMap[voterMatricNo].voterState = VoterState.ACCREDITED;
738744
s_accreditedVotersCount++;
739745
emit AccreditedVoter(voterMatricNo);

transaction.txt

Lines changed: 43 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,176 +1,96 @@
11

2-
== Return ==
3-
0: contract VotsEngine 0x91f995B3160af869F8bDB9d031648363CACdC60F
2+
0: contract VotsEngine 0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41
43

54
## Setting up 1 EVM.
65
==========================
76
Simulated On-chain Traces:
87

9-
[3582502] → new CreateElection@0xC3235ce9C7CF374C435c2066c12d7341d9818428
8+
[3586102] → new CreateElection@0x31bc6680d0918C361F6c2efd5a105D858f414799
109
├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0x688ce0CCf27a0D0B2b578199ACf3125a1F31f1c0)
11-
└─ ← [Return] 17774 bytes of code
10+
└─ ← [Return] 17792 bytes of code
1211

13-
[2303694] → new VotsElectionNft@0xD34359FCFB6596CBf2ce4b146AF98402CEe4f8B5
12+
[2303694] → new VotsElectionNft@0x2482E5690D3AF17986a8D17fD847ff444Baa6Ce9
1413
├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0x688ce0CCf27a0D0B2b578199ACf3125a1F31f1c0)
1514
└─ ← [Return] 11163 bytes of code
1615

17-
[2591461] → new VotsEngine@0x91f995B3160af869F8bDB9d031648363CACdC60F
16+
[2591461] → new VotsEngine@0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41
1817
├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0x688ce0CCf27a0D0B2b578199ACf3125a1F31f1c0)
1918
└─ ← [Return] 12823 bytes of code
2019

21-
[1542915] → new VotsEngineFunctionClient@0xAccf5D57346D6D6C7F0372A9e83b2a2B132B195A
20+
[1542915] → new VotsEngineFunctionClient@0x7fAF6E1382A5DF126548738cC4BAD1aC77C33362
2221
└─ ← [Return] 7704 bytes of code
2322

24-
[26279] VotsEngine::setFunctionClient(VotsEngineFunctionClient: [0xAccf5D57346D6D6C7F0372A9e83b2a2B132B195A])
25-
├─ emit FunctionClientUpdated(oldClient: 0x0000000000000000000000000000000000000000, newClient: VotsEngineFunctionClient: [0xAccf5D57346D6D6C7F0372A9e83b2a2B132B195A])
23+
[26279] VotsEngine::setFunctionClient(VotsEngineFunctionClient: [0x7fAF6E1382A5DF126548738cC4BAD1aC77C33362])
24+
├─ emit FunctionClientUpdated(oldClient: 0x0000000000000000000000000000000000000000, newClient: VotsEngineFunctionClient: [0x7fAF6E1382A5DF126548738cC4BAD1aC77C33362])
2625
└─ ← [Return]
2726

28-
[7036] CreateElection::transferOwnership(VotsEngine: [0x91f995B3160af869F8bDB9d031648363CACdC60F])
29-
├─ emit OwnershipTransferred(previousOwner: 0x688ce0CCf27a0D0B2b578199ACf3125a1F31f1c0, newOwner: VotsEngine: [0x91f995B3160af869F8bDB9d031648363CACdC60F])
27+
[7036] CreateElection::transferOwnership(VotsEngine: [0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41])
28+
├─ emit OwnershipTransferred(previousOwner: 0x688ce0CCf27a0D0B2b578199ACf3125a1F31f1c0, newOwner: VotsEngine: [0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41])
3029
└─ ← [Return]
3130

32-
[7474] VotsElectionNft::transferOwnership(VotsEngine: [0x91f995B3160af869F8bDB9d031648363CACdC60F])
33-
├─ emit OwnershipTransferred(previousOwner: 0x688ce0CCf27a0D0B2b578199ACf3125a1F31f1c0, newOwner: VotsEngine: [0x91f995B3160af869F8bDB9d031648363CACdC60F])
31+
[7474] VotsElectionNft::transferOwnership(VotsEngine: [0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41])
32+
├─ emit OwnershipTransferred(previousOwner: 0x688ce0CCf27a0D0B2b578199ACf3125a1F31f1c0, newOwner: VotsEngine: [0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41])
3433
└─ ← [Stop]
3534

3635

3736
==========================
3837

3938
Chain 11155111
4039

41-
Estimated gas price: 0.001444578 gwei
40+
Estimated gas price: 0.00391987 gwei
4241

43-
Estimated total gas used for script: 14500429
42+
Estimated total gas used for script: 14505467
4443

45-
Estimated amount required: 0.000020947000723962 ETH
44+
Estimated amount required: 0.00005685954492929 ETH
4645

4746
==========================
4847

4948
##### sepolia
50-
✅ [Success] Hash: 0x0f08eeebbc4ef47a40d3b829d2748c7684473c427bea6c93f4e6b32ab61ba8fe
51-
Contract Address: 0xD34359FCFB6596CBf2ce4b146AF98402CEe4f8B5
52-
Block: 8839064
53-
Paid: 0.000003095385333792 ETH (2549724 gas * 0.001214008 gwei)
49+
✅ [Success] Hash: 0x45678cdbfe6d080a46d4150230a07c625018edd7ce0aa1d1d1e7524ddf9793bc
50+
Contract Address: 0xBdAc4C73AdFF22977cA7C8E71D0cb49566147C41
51+
Block: 8847346
52+
Paid: 0.000006807683943934 ETH (2853889 gas * 0.002385406 gwei)
5453

5554

5655
##### sepolia
57-
✅ [Success] Hash: 0x15f65fa3cb8f9704b04f8c3e5c334f7fc2cbc0280fe9c4d80ffeb6e95ae91957
58-
Contract Address: 0x91f995B3160af869F8bDB9d031648363CACdC60F
59-
Block: 8839064
60-
Paid: 0.000003464658645208 ETH (2853901 gas * 0.001214008 gwei)
56+
✅ [Success] Hash: 0xc5b63ef6f37b9c0df7d9f01c27a686e266fc511bd585fc4674b2c615174c7d14
57+
Contract Address: 0x7fAF6E1382A5DF126548738cC4BAD1aC77C33362
58+
Block: 8847346
59+
Paid: 0.00000410601127483 ETH (1721305 gas * 0.002385406 gwei)
6160

6261

6362
##### sepolia
64-
✅ [Success] Hash: 0xa36bac05579ccda5c04c813686cd23a22fa84b88e60ef0a5b27e908957ee3321
65-
Block: 8839064
66-
Paid: 0.000000034560379744 ETH (28468 gas * 0.001214008 gwei)
63+
✅ [Success] Hash: 0xdcae3ab0f82ce93edf6bc5b2599f2182383ec040adaf6547ab5468ce5163f7a4
64+
Contract Address: 0x2482E5690D3AF17986a8D17fD847ff444Baa6Ce9
65+
Block: 8847346
66+
Paid: 0.000006082126927944 ETH (2549724 gas * 0.002385406 gwei)
6767

6868

6969
##### sepolia
70-
✅ [Success] Hash: 0xea62dd80283382ec7222ba70b756c1c2b6e9f651e81ea3d11970d20c7eac2013
71-
Contract Address: 0xAccf5D57346D6D6C7F0372A9e83b2a2B132B195A
72-
Block: 8839064
73-
Paid: 0.00000208967804044 ETH (1721305 gas * 0.001214008 gwei)
70+
✅ [Success] Hash: 0x47b5883cb00b3e7a07da07c81024d2560a5184071414d3d42c9903ec0b25b1f9
71+
Block: 8847346
72+
Paid: 0.000000113810105666 ETH (47711 gas * 0.002385406 gwei)
7473

7574

7675
##### sepolia
77-
✅ [Success] Hash: 0x4f53d8d42718d507037b65019a3fa00057a9543b1791a2d0b3dd0400ed180e7a
78-
Contract Address: 0xC3235ce9C7CF374C435c2066c12d7341d9818428
79-
Block: 8839064
80-
Paid: 0.00000475380038632 ETH (3915790 gas * 0.001214008 gwei)
76+
✅ [Success] Hash: 0xcba78b501e13bae4252ef702e10e995fb15566a3a927de6e5dc0136c0fd5dd17
77+
Block: 8847346
78+
Paid: 0.000000068952545836 ETH (28906 gas * 0.002385406 gwei)
8179

8280

8381
##### sepolia
84-
✅ [Success] Hash: 0x6d2be35a4efa6186381693b325daa17af5ab40583419fb2041ae1bf92811450c
85-
Block: 8839064
86-
Paid: 0.000000035092115248 ETH (28906 gas * 0.001214008 gwei)
82+
✅ [Success] Hash: 0x520ad73d5987a4f8ff3ab6d62fe6e8e7cfe7c9a5fce39d5d6f82e38db3211d78
83+
Block: 8847346
84+
Paid: 0.000000067907738008 ETH (28468 gas * 0.002385406 gwei)
8785

8886

8987
##### sepolia
90-
✅ [Success] Hash: 0x3a34fc677e0cddb5f824dd44bb46042d5d9c73c5a7e057a7a3e152e744983114
91-
Block: 8839064
92-
Paid: 0.000000057921535688 ETH (47711 gas * 0.001214008 gwei)
88+
✅ [Success] Hash: 0x709d230c5d76365feb83a4d898ec9c30b1e7cef2a057bf997372b1a3a7671f2b
89+
Contract Address: 0x31bc6680d0918C361F6c2efd5a105D858f414799
90+
Block: 8847346
91+
Paid: 0.000009350023419268 ETH (3919678 gas * 0.002385406 gwei)
9392

94-
✅ Sequence #1 on sepolia | Total Paid: 0.00001353109643644 ETH (11145805 gas * avg 0.001214008 gwei)
95-
93+
✅ Sequence #1 on sepolia | Total Paid: 0.000026596515955486 ETH (11149681 gas * avg 0.002385406 gwei)
94+
9695

97-
==========================
98-
99-
ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
100-
Warning: We haven't found any matching bytecode for the following contracts: [0xd34359fcfb6596cbf2ce4b146af98402cee4f8b5].
101-
102-
This may occur when resuming a verification, but the underlying source code or compiler version has changed.
103-
##
104-
Start verification for (3) contracts
105-
Start verifying contract `0xC3235ce9C7CF374C435c2066c12d7341d9818428` deployed on sepolia
106-
EVM version: cancun
107-
Compiler version: 0.8.28
108-
Optimizations: 200
109-
110-
Submitting verification for [src/CreateElection.sol:CreateElection] 0xC3235ce9C7CF374C435c2066c12d7341d9818428.
111-
Warning: Could not detect the deployment.; waiting 5 seconds before trying again (4 tries remaining)
112-
113-
Submitting verification for [src/CreateElection.sol:CreateElection] 0xC3235ce9C7CF374C435c2066c12d7341d9818428.
114-
Warning: Could not detect the deployment.; waiting 5 seconds before trying again (3 tries remaining)
115-
116-
Submitting verification for [src/CreateElection.sol:CreateElection] 0xC3235ce9C7CF374C435c2066c12d7341d9818428.
117-
Warning: Could not detect the deployment.; waiting 5 seconds before trying again (2 tries remaining)
118-
119-
Submitting verification for [src/CreateElection.sol:CreateElection] 0xC3235ce9C7CF374C435c2066c12d7341d9818428.
120-
Warning: Could not detect the deployment.; waiting 5 seconds before trying again (1 tries remaining)
121-
122-
Submitting verification for [src/CreateElection.sol:CreateElection] 0xC3235ce9C7CF374C435c2066c12d7341d9818428.
123-
Warning: Could not detect the deployment.; waiting 5 seconds before trying again (0 tries remaining)
124-
125-
Submitting verification for [src/CreateElection.sol:CreateElection] 0xC3235ce9C7CF374C435c2066c12d7341d9818428.
126-
Submitted contract for verification:
127-
Response: `OK`
128-
GUID: `5gattwctg6jrsfsdctwtwaa18wtw6sxabq8q3kccm6wgrzquyj`
129-
URL: https://sepolia.etherscan.io/address/0xc3235ce9c7cf374c435c2066c12d7341d9818428
130-
Contract verification status:
131-
Response: `NOTOK`
132-
Details: `Pending in queue`
133-
Warning: Verification is still pending...; waiting 15 seconds before trying again (7 tries remaining)
134-
Contract verification status:
135-
Response: `OK`
136-
Details: `Pass - Verified`
137-
Contract successfully verified
138-
Start verifying contract `0x91f995B3160af869F8bDB9d031648363CACdC60F` deployed on sepolia
139-
EVM version: cancun
140-
Compiler version: 0.8.28
141-
Optimizations: 200
142-
Constructor args: 000000000000000000000000c3235ce9c7cf374c435c2066c12d7341d9818428000000000000000000000000d34359fcfb6596cbf2ce4b146af98402cee4f8b5
143-
144-
Submitting verification for [src/VotsEngine.sol:VotsEngine] 0x91f995B3160af869F8bDB9d031648363CACdC60F.
145-
Submitted contract for verification:
146-
Response: `OK`
147-
GUID: `jxwx8kbnhhepzbj3ga1vgrcisis5ky7schf83seusvhyzltntx`
148-
URL: https://sepolia.etherscan.io/address/0x91f995b3160af869f8bdb9d031648363cacdc60f
149-
Contract verification status:
150-
Response: `NOTOK`
151-
Details: `Pending in queue`
152-
Warning: Verification is still pending...; waiting 15 seconds before trying again (7 tries remaining)
153-
Contract verification status:
154-
Response: `OK`
155-
Details: `Pass - Verified`
156-
Contract successfully verified
157-
Start verifying contract `0xAccf5D57346D6D6C7F0372A9e83b2a2B132B195A` deployed on sepolia
158-
EVM version: cancun
159-
Compiler version: 0.8.28
160-
Optimizations: 200
161-
Constructor args: 000000000000000000000000b83e47c2bc239b3bf370bc41e1459a34b41238d066756e2d657468657265756d2d7365706f6c69612d310000000000000000000000000000000000000000000091f995b3160af869f8bdb9d031648363cacdc60f
162-
163-
Submitting verification for [src/VotsEngineFunctionClient.sol:VotsEngineFunctionClient] 0xAccf5D57346D6D6C7F0372A9e83b2a2B132B195A.
164-
Submitted contract for verification:
165-
Response: `OK`
166-
GUID: `zkrgxtf7zhiykzbnvpadbnsaqcbhfsqbq77wdwhgi6rzwp4f35`
167-
URL: https://sepolia.etherscan.io/address/0xaccf5d57346d6d6c7f0372a9e83b2a2b132b195a
168-
Contract verification status:
169-
Response: `NOTOK`
170-
Details: `Pending in queue`
171-
Warning: Verification is still pending...; waiting 15 seconds before trying again (7 tries remaining)
172-
Contract verification status:
173-
Response: `OK`
174-
Details: `Pass - Verified`
175-
Contract successfully verified
176-
All (3) contracts were verified!
96+
==========================

0 commit comments

Comments
 (0)