@crisp-e3/contracts 0.5.9 → 0.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,6 +16,14 @@ import { HonkVerifier } from "./CRISPVerifier.sol";
|
|
|
16
16
|
contract CRISPProgram is IE3Program, Ownable {
|
|
17
17
|
using InternalLazyIMT for LazyIMTData;
|
|
18
18
|
|
|
19
|
+
/// @notice Enum to represent credit modes
|
|
20
|
+
enum CreditMode {
|
|
21
|
+
/// @notice Everyone has constant credits
|
|
22
|
+
CONSTANT,
|
|
23
|
+
/// @notice Credits are custom (can be based on token balance, etc)
|
|
24
|
+
CUSTOM
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
/// @notice Struct to store all data related to a voting round
|
|
20
28
|
struct RoundData {
|
|
21
29
|
uint256 merkleRoot;
|
|
@@ -23,6 +31,7 @@ contract CRISPProgram is IE3Program, Ownable {
|
|
|
23
31
|
mapping(address slot => uint40 index) voteSlots;
|
|
24
32
|
LazyIMTData votes;
|
|
25
33
|
uint256 numOptions;
|
|
34
|
+
CreditMode creditMode;
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
// Constants
|
|
@@ -121,10 +130,13 @@ contract CRISPProgram is IE3Program, Ownable {
|
|
|
121
130
|
if (e3Data[e3Id].paramsHash != bytes32(0)) revert E3AlreadyInitialized();
|
|
122
131
|
|
|
123
132
|
// decode custom params to get the number of options
|
|
124
|
-
(, , uint256 numOptions) = abi.decode(customParams, (address, uint256, uint256));
|
|
133
|
+
(, , uint256 numOptions, CreditMode creditMode, ) = abi.decode(customParams, (address, uint256, uint256, CreditMode, uint256));
|
|
125
134
|
if (numOptions < 2) revert InvalidNumOptions();
|
|
126
135
|
|
|
136
|
+
// we need to know the number of options for decoding the tally
|
|
127
137
|
e3Data[e3Id].numOptions = numOptions;
|
|
138
|
+
// we want to save the credit more so it can be verified on chain by everyone
|
|
139
|
+
e3Data[e3Id].creditMode = creditMode;
|
|
128
140
|
|
|
129
141
|
e3Data[e3Id].paramsHash = keccak256(e3ProgramParams);
|
|
130
142
|
|
|
@@ -28,7 +28,7 @@ contract MockEnclave {
|
|
|
28
28
|
encryptionSchemeId: bytes32(0),
|
|
29
29
|
e3Program: IE3Program(program),
|
|
30
30
|
e3ProgramParams: bytes(""),
|
|
31
|
-
customParams: abi.encode(address(0), nextE3Id, 2),
|
|
31
|
+
customParams: abi.encode(address(0), nextE3Id, 2, 0, 0),
|
|
32
32
|
decryptionVerifier: IDecryptionVerifier(address(0)),
|
|
33
33
|
committeePublicKey: committeePublicKey,
|
|
34
34
|
ciphertextOutput: bytes32(0),
|
|
@@ -61,7 +61,7 @@ contract MockEnclave {
|
|
|
61
61
|
encryptionSchemeId: bytes32(0),
|
|
62
62
|
e3Program: IE3Program(address(0)),
|
|
63
63
|
e3ProgramParams: bytes(""),
|
|
64
|
-
customParams: abi.encode(address(0), 0, 2),
|
|
64
|
+
customParams: abi.encode(address(0), 0, 2, 0, 0),
|
|
65
65
|
decryptionVerifier: IDecryptionVerifier(address(0)),
|
|
66
66
|
committeePublicKey: committeePublicKey,
|
|
67
67
|
ciphertextOutput: bytes32(0),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crisp-e3/contracts",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"contracts",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"typechain": "^8.3.0",
|
|
60
60
|
"typescript": "5.8.3",
|
|
61
61
|
"viem": "2.30.6",
|
|
62
|
-
"@crisp-e3/zk-inputs": "^0.5.
|
|
63
|
-
"@crisp-e3/sdk": "^0.5.
|
|
62
|
+
"@crisp-e3/zk-inputs": "^0.5.10",
|
|
63
|
+
"@crisp-e3/sdk": "^0.5.10"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"compile": "hardhat compile",
|