@maci-protocol/sdk 0.0.0-ci.f433bba → 0.0.0-ci.f54316d
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.
- package/LICENSE +1 -2
- package/build/package.json +12 -4
- package/build/ts/browser/index.d.ts +1 -1
- package/build/ts/browser/index.d.ts.map +1 -1
- package/build/ts/browser/index.js +5 -1
- package/build/ts/browser/index.js.map +1 -1
- package/build/ts/browser/joinPoll.d.ts +4 -2
- package/build/ts/browser/joinPoll.d.ts.map +1 -1
- package/build/ts/browser/joinPoll.js +22 -20
- package/build/ts/browser/joinPoll.js.map +1 -1
- package/build/ts/browser/utils.d.ts +1 -1
- package/build/ts/browser/utils.d.ts.map +1 -1
- package/build/ts/browser/utils.js +3 -3
- package/build/ts/browser/utils.js.map +1 -1
- package/build/ts/deploy/index.d.ts +2 -2
- package/build/ts/deploy/index.d.ts.map +1 -1
- package/build/ts/deploy/index.js +3 -3
- package/build/ts/deploy/index.js.map +1 -1
- package/build/ts/deploy/maci.js +1 -1
- package/build/ts/deploy/maci.js.map +1 -1
- package/build/ts/deploy/poll.d.ts +1 -1
- package/build/ts/deploy/poll.d.ts.map +1 -1
- package/build/ts/deploy/poll.js +9 -8
- package/build/ts/deploy/poll.js.map +1 -1
- package/build/ts/deploy/types.d.ts +13 -8
- package/build/ts/deploy/types.d.ts.map +1 -1
- package/build/ts/deploy/utils.js +1 -1
- package/build/ts/deploy/utils.js.map +1 -1
- package/build/ts/deploy/verifyingKeysRegistry.d.ts +7 -0
- package/build/ts/deploy/verifyingKeysRegistry.d.ts.map +1 -0
- package/build/ts/deploy/verifyingKeysRegistry.js +14 -0
- package/build/ts/deploy/verifyingKeysRegistry.js.map +1 -0
- package/build/ts/index.d.ts +1 -1
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +11 -7
- package/build/ts/index.js.map +1 -1
- package/build/ts/maci/policy.d.ts +13 -1
- package/build/ts/maci/policy.d.ts.map +1 -1
- package/build/ts/maci/policy.js +40 -1
- package/build/ts/maci/policy.js.map +1 -1
- package/build/ts/maci/state.d.ts +1 -1
- package/build/ts/maci/state.js +8 -8
- package/build/ts/maci/state.js.map +1 -1
- package/build/ts/maci/types.d.ts +34 -2
- package/build/ts/maci/types.d.ts.map +1 -1
- package/build/ts/maci/types.js +2 -0
- package/build/ts/maci/types.js.map +1 -1
- package/build/ts/maciKeys/__tests__/keypair.test.js +7 -7
- package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -1
- package/build/ts/maciKeys/__tests__/publicKeys.test.js +7 -7
- package/build/ts/maciKeys/__tests__/publicKeys.test.js.map +1 -1
- package/build/ts/maciKeys/keypair.js +3 -3
- package/build/ts/maciKeys/keypair.js.map +1 -1
- package/build/ts/maciKeys/publicKeys.d.ts +2 -2
- package/build/ts/maciKeys/publicKeys.d.ts.map +1 -1
- package/build/ts/maciKeys/publicKeys.js +6 -6
- package/build/ts/maciKeys/publicKeys.js.map +1 -1
- package/build/ts/poll/poll.js +7 -7
- package/build/ts/poll/poll.js.map +1 -1
- package/build/ts/poll/types.d.ts +6 -7
- package/build/ts/poll/types.d.ts.map +1 -1
- package/build/ts/proof/__tests__/download.test.js +7 -4
- package/build/ts/proof/__tests__/download.test.js.map +1 -1
- package/build/ts/proof/download.d.ts +3 -3
- package/build/ts/proof/download.d.ts.map +1 -1
- package/build/ts/proof/download.js +5 -7
- package/build/ts/proof/download.js.map +1 -1
- package/build/ts/proof/generate.d.ts +2 -2
- package/build/ts/proof/generate.d.ts.map +1 -1
- package/build/ts/proof/generate.js +6 -6
- package/build/ts/proof/generate.js.map +1 -1
- package/build/ts/proof/prove.js +10 -10
- package/build/ts/proof/prove.js.map +1 -1
- package/build/ts/proof/types.d.ts +30 -4
- package/build/ts/proof/types.d.ts.map +1 -1
- package/build/ts/proof/utils.d.ts +10 -0
- package/build/ts/proof/utils.d.ts.map +1 -0
- package/build/ts/proof/utils.js +24 -0
- package/build/ts/proof/utils.js.map +1 -0
- package/build/ts/relayer/__tests__/messages.test.js +1 -1
- package/build/ts/relayer/__tests__/messages.test.js.map +1 -1
- package/build/ts/relayer/__tests__/utils.test.js +3 -3
- package/build/ts/relayer/__tests__/utils.test.js.map +1 -1
- package/build/ts/relayer/messages.js +1 -1
- package/build/ts/relayer/utils.js +1 -1
- package/build/ts/relayer/utils.js.map +1 -1
- package/build/ts/tally/commitments.d.ts.map +1 -1
- package/build/ts/tally/commitments.js +8 -7
- package/build/ts/tally/commitments.js.map +1 -1
- package/build/ts/tally/index.d.ts +2 -1
- package/build/ts/tally/index.d.ts.map +1 -1
- package/build/ts/tally/index.js +4 -1
- package/build/ts/tally/index.js.map +1 -1
- package/build/ts/tally/results.d.ts +14 -0
- package/build/ts/tally/results.d.ts.map +1 -0
- package/build/ts/tally/results.js +44 -0
- package/build/ts/tally/results.js.map +1 -0
- package/build/ts/tally/types.d.ts +40 -13
- package/build/ts/tally/types.d.ts.map +1 -1
- package/build/ts/tally/utils.d.ts +3 -3
- package/build/ts/tally/utils.d.ts.map +1 -1
- package/build/ts/tally/utils.js +9 -9
- package/build/ts/tally/utils.js.map +1 -1
- package/build/ts/tally/verification.d.ts +1 -1
- package/build/ts/tally/verification.d.ts.map +1 -1
- package/build/ts/tally/verification.js +10 -10
- package/build/ts/tally/verification.js.map +1 -1
- package/build/ts/trees/index.d.ts +2 -2
- package/build/ts/trees/index.d.ts.map +1 -1
- package/build/ts/trees/index.js +2 -1
- package/build/ts/trees/index.js.map +1 -1
- package/build/ts/trees/stateTree.d.ts +15 -1
- package/build/ts/trees/stateTree.d.ts.map +1 -1
- package/build/ts/trees/stateTree.js +61 -10
- package/build/ts/trees/stateTree.js.map +1 -1
- package/build/ts/trees/types.d.ts +11 -2
- package/build/ts/trees/types.d.ts.map +1 -1
- package/build/ts/user/index.d.ts +2 -2
- package/build/ts/user/index.d.ts.map +1 -1
- package/build/ts/user/index.js +5 -1
- package/build/ts/user/index.js.map +1 -1
- package/build/ts/user/joinPoll.d.ts.map +1 -1
- package/build/ts/user/joinPoll.js +9 -10
- package/build/ts/user/joinPoll.js.map +1 -1
- package/build/ts/user/signup.d.ts +3 -3
- package/build/ts/user/signup.d.ts.map +1 -1
- package/build/ts/user/signup.js +8 -8
- package/build/ts/user/signup.js.map +1 -1
- package/build/ts/user/types.d.ts +60 -20
- package/build/ts/user/types.d.ts.map +1 -1
- package/build/ts/user/utils.d.ts +26 -14
- package/build/ts/user/utils.d.ts.map +1 -1
- package/build/ts/user/utils.js +79 -50
- package/build/ts/user/utils.js.map +1 -1
- package/build/ts/utils/params.d.ts +1 -1
- package/build/ts/utils/params.d.ts.map +1 -1
- package/build/ts/utils/params.js +3 -3
- package/build/ts/utils/params.js.map +1 -1
- package/build/ts/utils/proofs.d.ts +2 -2
- package/build/ts/utils/proofs.d.ts.map +1 -1
- package/build/ts/utils/proofs.js +4 -4
- package/build/ts/utils/proofs.js.map +1 -1
- package/build/ts/utils/types.d.ts +2 -2
- package/build/ts/utils/types.d.ts.map +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.js +14 -15
- package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/index.d.ts +2 -2
- package/build/ts/verifyingKeys/index.d.ts.map +1 -1
- package/build/ts/verifyingKeys/index.js +5 -5
- package/build/ts/verifyingKeys/index.js.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.js +45 -35
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/types.d.ts +41 -37
- package/build/ts/verifyingKeys/types.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.d.ts +10 -10
- package/build/ts/verifyingKeys/utils.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.js +73 -60
- package/build/ts/verifyingKeys/utils.js.map +1 -1
- package/build/ts/vote/generate.d.ts +1 -1
- package/build/ts/vote/generate.d.ts.map +1 -1
- package/build/ts/vote/generate.js +4 -4
- package/build/ts/vote/generate.js.map +1 -1
- package/build/ts/vote/index.d.ts +1 -1
- package/build/ts/vote/index.d.ts.map +1 -1
- package/build/ts/vote/index.js +2 -2
- package/build/ts/vote/index.js.map +1 -1
- package/build/ts/vote/invalidate.js +3 -3
- package/build/ts/vote/invalidate.js.map +1 -1
- package/build/ts/vote/publish.d.ts +1 -1
- package/build/ts/vote/publish.d.ts.map +1 -1
- package/build/ts/vote/publish.js +19 -19
- package/build/ts/vote/publish.js.map +1 -1
- package/build/ts/vote/submit.js +2 -2
- package/build/ts/vote/submit.js.map +1 -1
- package/build/ts/vote/types.d.ts +6 -6
- package/build/ts/vote/types.d.ts.map +1 -1
- package/build/ts/vote/utils.d.ts +2 -2
- package/build/ts/vote/utils.d.ts.map +1 -1
- package/build/ts/vote/utils.js +5 -5
- package/build/ts/vote/utils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +18 -10
- package/build/ts/deploy/vkRegistry.d.ts +0 -7
- package/build/ts/deploy/vkRegistry.d.ts.map +0 -1
- package/build/ts/deploy/vkRegistry.js +0 -14
- package/build/ts/deploy/vkRegistry.js.map +0 -1
- package/build/ts/proof/constants.d.ts +0 -17
- package/build/ts/proof/constants.d.ts.map +0 -1
- package/build/ts/proof/constants.js +0 -20
- package/build/ts/proof/constants.js.map +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getResults = exports.getResultPerOption = void 0;
|
|
4
|
+
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
5
|
+
/**
|
|
6
|
+
* Get result per option
|
|
7
|
+
* @param {IGetResultPerOptionsArgs} - The arguments to get result per option
|
|
8
|
+
* @returns The result per option
|
|
9
|
+
*/
|
|
10
|
+
const getResultPerOption = async ({ maciAddress, pollId, index, signer, }) => {
|
|
11
|
+
const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
|
|
12
|
+
const pollContracts = await maciContract.getPoll(pollId);
|
|
13
|
+
const tallyContract = typechain_types_1.Tally__factory.connect(pollContracts.tally, signer);
|
|
14
|
+
const result = await tallyContract.tallyResults(index);
|
|
15
|
+
if (!result.flag) {
|
|
16
|
+
throw new Error("Tally result is not set");
|
|
17
|
+
}
|
|
18
|
+
return result.value;
|
|
19
|
+
};
|
|
20
|
+
exports.getResultPerOption = getResultPerOption;
|
|
21
|
+
/**
|
|
22
|
+
* Get all results from the Tally contract
|
|
23
|
+
* @param {IGetResultsArgs} - The arguments to get all the results
|
|
24
|
+
* @returns The results array (The final result of vote option n is in index n-1)
|
|
25
|
+
*/
|
|
26
|
+
const getResults = async ({ maciAddress, pollId, signer }) => {
|
|
27
|
+
const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
|
|
28
|
+
const pollContracts = await maciContract.getPoll(pollId);
|
|
29
|
+
const pollContract = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer);
|
|
30
|
+
const numberOfVoteOptions = await pollContract.voteOptions();
|
|
31
|
+
const tallyContract = typechain_types_1.Tally__factory.connect(pollContracts.tally, signer);
|
|
32
|
+
const results = [];
|
|
33
|
+
for (let i = 0; i < numberOfVoteOptions; i += 1) {
|
|
34
|
+
// eslint-disable-next-line no-await-in-loop
|
|
35
|
+
const result = await tallyContract.tallyResults(i);
|
|
36
|
+
if (!result.flag) {
|
|
37
|
+
throw new Error(`Tally result for option ${i} is not set`);
|
|
38
|
+
}
|
|
39
|
+
results.push(result.value);
|
|
40
|
+
}
|
|
41
|
+
return results;
|
|
42
|
+
};
|
|
43
|
+
exports.getResults = getResults;
|
|
44
|
+
//# sourceMappingURL=results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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ExE,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,4CAA4C;QAC5C,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAEnD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,aAAa,CAAC,CAAC;QAC7D,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAxBW,QAAA,UAAU,cAwBrB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EMode } from "@maci-protocol/core";
|
|
1
2
|
import type { Signer } from "ethers";
|
|
2
3
|
/**
|
|
3
4
|
* Interface for the tally file data.
|
|
@@ -21,9 +22,9 @@ export interface ITallyData {
|
|
|
21
22
|
*/
|
|
22
23
|
chainId?: string;
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
+
* Voting mode
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
+
mode: EMode;
|
|
27
28
|
/**
|
|
28
29
|
* The address of the Tally contract.
|
|
29
30
|
*/
|
|
@@ -67,19 +68,19 @@ export interface ITallyData {
|
|
|
67
68
|
commitment: string;
|
|
68
69
|
};
|
|
69
70
|
/**
|
|
70
|
-
* The per
|
|
71
|
+
* The per vote option spent voice credits.
|
|
71
72
|
*/
|
|
72
|
-
|
|
73
|
+
perVoteOptionSpentVoiceCredits?: {
|
|
73
74
|
/**
|
|
74
|
-
* The tally of the per
|
|
75
|
+
* The tally of the per vote option spent voice credits.
|
|
75
76
|
*/
|
|
76
77
|
tally: string[];
|
|
77
78
|
/**
|
|
78
|
-
* The salt of the per
|
|
79
|
+
* The salt of the per vote option spent voice credits.
|
|
79
80
|
*/
|
|
80
81
|
salt: string;
|
|
81
82
|
/**
|
|
82
|
-
* The commitment of the per
|
|
83
|
+
* The commitment of the per vote option spent voice credits.
|
|
83
84
|
*/
|
|
84
85
|
commitment: string;
|
|
85
86
|
};
|
|
@@ -111,7 +112,7 @@ export interface IVerifyArgs {
|
|
|
111
112
|
/**
|
|
112
113
|
* The number of vote options
|
|
113
114
|
*/
|
|
114
|
-
|
|
115
|
+
totalVoteOptions: number;
|
|
115
116
|
/**
|
|
116
117
|
* The vote option tree depth
|
|
117
118
|
*/
|
|
@@ -145,7 +146,7 @@ export interface ITallyCommitments {
|
|
|
145
146
|
/**
|
|
146
147
|
* The new per vote option spent voice credits commitment
|
|
147
148
|
*/
|
|
148
|
-
|
|
149
|
+
newPerVoteOptionSpentVoiceCreditsCommitment?: bigint;
|
|
149
150
|
/**
|
|
150
151
|
* The commitment to the results tree root
|
|
151
152
|
*/
|
|
@@ -159,7 +160,7 @@ export interface ITallyVotesInputs {
|
|
|
159
160
|
ballotRoot: bigint;
|
|
160
161
|
sbSalt: bigint;
|
|
161
162
|
index: bigint;
|
|
162
|
-
|
|
163
|
+
totalSignups: bigint;
|
|
163
164
|
sbCommitment: bigint;
|
|
164
165
|
currentTallyCommitment: bigint;
|
|
165
166
|
newTallyCommitment: bigint;
|
|
@@ -170,10 +171,36 @@ export interface ITallyVotesInputs {
|
|
|
170
171
|
currentResultsRootSalt: bigint;
|
|
171
172
|
currentSpentVoiceCreditSubtotal: bigint;
|
|
172
173
|
currentSpentVoiceCreditSubtotalSalt: bigint;
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
currentPerVoteOptionSpentVoiceCredits: bigint[];
|
|
175
|
+
currentPerVoteOptionSpentVoiceCreditsRootSalt: bigint;
|
|
175
176
|
newResultsRootSalt: bigint;
|
|
176
|
-
|
|
177
|
+
newPerVoteOptionSpentVoiceCreditsRootSalt: bigint;
|
|
177
178
|
newSpentVoiceCreditSubtotalSalt: bigint;
|
|
178
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Get results args
|
|
182
|
+
*/
|
|
183
|
+
export interface IGetResultsArgs {
|
|
184
|
+
/**
|
|
185
|
+
* The address of the MACI contract
|
|
186
|
+
*/
|
|
187
|
+
maciAddress: string;
|
|
188
|
+
/**
|
|
189
|
+
* The ID of the poll
|
|
190
|
+
*/
|
|
191
|
+
pollId: string;
|
|
192
|
+
/**
|
|
193
|
+
* The signer
|
|
194
|
+
*/
|
|
195
|
+
signer: Signer;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Get result per option args
|
|
199
|
+
*/
|
|
200
|
+
export interface IGetResultPerOptionArgs extends IGetResultsArgs {
|
|
201
|
+
/**
|
|
202
|
+
* The index of the vote option
|
|
203
|
+
*/
|
|
204
|
+
index: number;
|
|
205
|
+
}
|
|
179
206
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/tally/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/tally/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH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EAAE,MAAM,CAAC;CACf"}
|
|
@@ -10,15 +10,15 @@ import type { Tally } from "@maci-protocol/contracts";
|
|
|
10
10
|
* @param newResultsCommitment The tally result commitment
|
|
11
11
|
* @returns list of the indexes of the tally result that failed on-chain verification
|
|
12
12
|
*/
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const verifyPerVoteOptionSpentVoiceCredits: (tallyContract: Tally, tallyData: ITallyData, voteOptionTreeDepth: number, newSpentVoiceCreditsCommitment: bigint, newResultsCommitment: bigint) => Promise<number[]>;
|
|
14
14
|
/**
|
|
15
15
|
* Loop through each tally result and verify it on-chain
|
|
16
16
|
* @param tallyContract The tally contract
|
|
17
17
|
* @param tallyData The tally.json file data
|
|
18
18
|
* @param voteOptionTreeDepth The vote option tree depth
|
|
19
19
|
* @param newSpentVoiceCreditsCommitment The total spent voice credits commitment
|
|
20
|
-
* @param
|
|
20
|
+
* @param newPerVoteOptionSpentVoiceCreditsCommitment The per vote option voice credits commitment
|
|
21
21
|
* @returns list of the indexes of the tally result that failed on-chain verification
|
|
22
22
|
*/
|
|
23
|
-
export declare const verifyTallyResults: (tallyContract: Tally, tallyData: ITallyData, voteOptionTreeDepth: number, newSpentVoiceCreditsCommitment: bigint,
|
|
23
|
+
export declare const verifyTallyResults: (tallyContract: Tally, tallyData: ITallyData, voteOptionTreeDepth: number, newSpentVoiceCreditsCommitment: bigint, newPerVoteOptionSpentVoiceCreditsCommitment?: bigint) => Promise<number[]>;
|
|
24
24
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/tally/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEtD;;;;;;;;;GASG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/tally/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEtD;;;;;;;;;GASG;AACH,eAAO,MAAM,oCAAoC,GAC/C,eAAe,KAAK,EACpB,WAAW,UAAU,EACrB,qBAAqB,MAAM,EAC3B,gCAAgC,MAAM,EACtC,sBAAsB,MAAM,KAC3B,OAAO,CAAC,MAAM,EAAE,CA2BlB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,eAAe,KAAK,EACpB,WAAW,UAAU,EACrB,qBAAqB,MAAM,EAC3B,gCAAgC,MAAM,EACtC,8CAA8C,MAAM,KACnD,OAAO,CAAC,MAAM,EAAE,CA2BlB,CAAC"}
|
package/build/ts/tally/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyTallyResults = exports.
|
|
3
|
+
exports.verifyTallyResults = exports.verifyPerVoteOptionSpentVoiceCredits = void 0;
|
|
4
4
|
const crypto_1 = require("@maci-protocol/crypto");
|
|
5
5
|
/**
|
|
6
6
|
* Loop through each per vote option spent voice credits and verify it on-chain
|
|
@@ -12,34 +12,34 @@ const crypto_1 = require("@maci-protocol/crypto");
|
|
|
12
12
|
* @param newResultsCommitment The tally result commitment
|
|
13
13
|
* @returns list of the indexes of the tally result that failed on-chain verification
|
|
14
14
|
*/
|
|
15
|
-
const
|
|
15
|
+
const verifyPerVoteOptionSpentVoiceCredits = async (tallyContract, tallyData, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newResultsCommitment) => {
|
|
16
16
|
const failedIndices = [];
|
|
17
|
-
for (let i = 0; i < tallyData.
|
|
18
|
-
const proof = (0, crypto_1.genTreeProof)(i, tallyData.
|
|
17
|
+
for (let i = 0; i < tallyData.perVoteOptionSpentVoiceCredits.tally.length; i += 1) {
|
|
18
|
+
const proof = (0, crypto_1.genTreeProof)(i, tallyData.perVoteOptionSpentVoiceCredits.tally.map((x) => BigInt(x)), voteOptionTreeDepth);
|
|
19
19
|
// eslint-disable-next-line no-await-in-loop
|
|
20
|
-
const isValid = await tallyContract.
|
|
20
|
+
const isValid = await tallyContract.verifyPerVoteOptionSpentVoiceCredits(i, tallyData.perVoteOptionSpentVoiceCredits.tally[i], proof, tallyData.perVoteOptionSpentVoiceCredits.salt, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newResultsCommitment);
|
|
21
21
|
if (!isValid) {
|
|
22
22
|
failedIndices.push(i);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
return failedIndices;
|
|
26
26
|
};
|
|
27
|
-
exports.
|
|
27
|
+
exports.verifyPerVoteOptionSpentVoiceCredits = verifyPerVoteOptionSpentVoiceCredits;
|
|
28
28
|
/**
|
|
29
29
|
* Loop through each tally result and verify it on-chain
|
|
30
30
|
* @param tallyContract The tally contract
|
|
31
31
|
* @param tallyData The tally.json file data
|
|
32
32
|
* @param voteOptionTreeDepth The vote option tree depth
|
|
33
33
|
* @param newSpentVoiceCreditsCommitment The total spent voice credits commitment
|
|
34
|
-
* @param
|
|
34
|
+
* @param newPerVoteOptionSpentVoiceCreditsCommitment The per vote option voice credits commitment
|
|
35
35
|
* @returns list of the indexes of the tally result that failed on-chain verification
|
|
36
36
|
*/
|
|
37
|
-
const verifyTallyResults = async (tallyContract, tallyData, voteOptionTreeDepth, newSpentVoiceCreditsCommitment,
|
|
37
|
+
const verifyTallyResults = async (tallyContract, tallyData, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newPerVoteOptionSpentVoiceCreditsCommitment) => {
|
|
38
38
|
const failedIndices = [];
|
|
39
39
|
for (let i = 0; i < tallyData.results.tally.length; i += 1) {
|
|
40
40
|
const proof = (0, crypto_1.genTreeProof)(i, tallyData.results.tally.map((x) => BigInt(x)), voteOptionTreeDepth);
|
|
41
41
|
// eslint-disable-next-line no-await-in-loop
|
|
42
|
-
const isValid = await tallyContract.verifyTallyResult(i, tallyData.results.tally[i], proof, tallyData.results.salt, voteOptionTreeDepth, newSpentVoiceCreditsCommitment,
|
|
42
|
+
const isValid = await tallyContract.verifyTallyResult(i, tallyData.results.tally[i], proof, tallyData.results.salt, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newPerVoteOptionSpentVoiceCreditsCommitment ?? 0n);
|
|
43
43
|
if (!isValid) {
|
|
44
44
|
failedIndices.push(i);
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/tally/utils.ts"],"names":[],"mappings":";;;AAAA,kDAAqD;AAKrD;;;;;;;;;GASG;AACI,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/tally/utils.ts"],"names":[],"mappings":";;;AAAA,kDAAqD;AAKrD;;;;;;;;;GASG;AACI,MAAM,oCAAoC,GAAG,KAAK,EACvD,aAAoB,EACpB,SAAqB,EACrB,mBAA2B,EAC3B,8BAAsC,EACtC,oBAA4B,EACT,EAAE;IACrB,MAAM,aAAa,GAAa,EAAE,CAAC;IAEnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,8BAA+B,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACnF,MAAM,KAAK,GAAG,IAAA,qBAAY,EACxB,CAAC,EACD,SAAS,CAAC,8BAA+B,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EACrE,mBAAmB,CACpB,CAAC;QAEF,4CAA4C;QAC5C,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,oCAAoC,CACtE,CAAC,EACD,SAAS,CAAC,8BAA+B,CAAC,KAAK,C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@ -3,5 +3,5 @@ import type { IVerifyArgs } from "./types";
|
|
|
3
3
|
* Verify the results of a poll on-chain
|
|
4
4
|
* @param VerifyArgs - The arguments for the verify command
|
|
5
5
|
*/
|
|
6
|
-
export declare const verify: ({ pollId, tallyData, signer, tallyCommitments,
|
|
6
|
+
export declare const verify: ({ pollId, tallyData, signer, tallyCommitments, totalVoteOptions, voteOptionTreeDepth, }: IVerifyArgs) => Promise<boolean>;
|
|
7
7
|
//# sourceMappingURL=verification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../ts/tally/verification.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../ts/tally/verification.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM3C;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAU,yFAO1B,WAAW,KAAG,OAAO,CAAC,OAAO,CAgG/B,CAAC"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verify = void 0;
|
|
4
4
|
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
5
|
+
const core_1 = require("@maci-protocol/core");
|
|
5
6
|
const contracts_1 = require("../utils/contracts");
|
|
6
7
|
const utils_1 = require("./utils");
|
|
7
8
|
/**
|
|
8
9
|
* Verify the results of a poll on-chain
|
|
9
10
|
* @param VerifyArgs - The arguments for the verify command
|
|
10
11
|
*/
|
|
11
|
-
const verify = async ({ pollId, tallyData, signer, tallyCommitments,
|
|
12
|
-
const useQv = tallyData.isQuadratic;
|
|
12
|
+
const verify = async ({ pollId, tallyData, signer, tallyCommitments, totalVoteOptions, voteOptionTreeDepth, }) => {
|
|
13
13
|
const maciContractAddress = tallyData.maci;
|
|
14
14
|
const validContract = await (0, contracts_1.contractExists)(signer.provider, maciContractAddress);
|
|
15
15
|
if (!validContract) {
|
|
@@ -26,33 +26,33 @@ const verify = async ({ pollId, tallyData, signer, tallyCommitments, numVoteOpti
|
|
|
26
26
|
if (!validResultsCommitment) {
|
|
27
27
|
throw new Error("Invalid results commitment format");
|
|
28
28
|
}
|
|
29
|
-
if (tallyData.results.tally.length !==
|
|
29
|
+
if (tallyData.results.tally.length !== totalVoteOptions) {
|
|
30
30
|
throw new Error("Wrong number of vote options.");
|
|
31
31
|
}
|
|
32
32
|
// destructure the tally commitments
|
|
33
|
-
const { newTallyCommitment, newSpentVoiceCreditsCommitment,
|
|
34
|
-
// verify that the results commitment matches the output of
|
|
33
|
+
const { newTallyCommitment, newSpentVoiceCreditsCommitment, newPerVoteOptionSpentVoiceCreditsCommitment, newResultsCommitment, } = tallyCommitments;
|
|
34
|
+
// verify that the results commitment matches the output of generateTreeCommitment()
|
|
35
35
|
if (onChainTallyCommitment !== newTallyCommitment) {
|
|
36
36
|
throw new Error("The on-chain tally commitment does not match.");
|
|
37
37
|
}
|
|
38
38
|
// verify total spent voice credits on-chain
|
|
39
|
-
const verified = await tallyContract.verifySpentVoiceCredits(tallyData.totalSpentVoiceCredits.spent, tallyData.totalSpentVoiceCredits.salt, newResultsCommitment,
|
|
39
|
+
const verified = await tallyContract.verifySpentVoiceCredits(tallyData.totalSpentVoiceCredits.spent, tallyData.totalSpentVoiceCredits.salt, newResultsCommitment, newPerVoteOptionSpentVoiceCreditsCommitment ?? 0n);
|
|
40
40
|
if (!verified) {
|
|
41
41
|
throw new Error("The on-chain verification of total spent voice credits failed.");
|
|
42
42
|
}
|
|
43
43
|
// verify tally result on-chain for each vote option
|
|
44
|
-
const failedPerVOSpentCredits = await (0, utils_1.verifyTallyResults)(tallyContract, tallyData, voteOptionTreeDepth, newSpentVoiceCreditsCommitment,
|
|
44
|
+
const failedPerVOSpentCredits = await (0, utils_1.verifyTallyResults)(tallyContract, tallyData, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newPerVoteOptionSpentVoiceCreditsCommitment);
|
|
45
45
|
if (failedPerVOSpentCredits.length > 0) {
|
|
46
46
|
throw new Error(`At least one spent voice credits entry in the tally results failed the on-chain verification. Please check your tally results at these indexes: ${failedPerVOSpentCredits.join(", ")}`);
|
|
47
47
|
}
|
|
48
|
-
if (
|
|
48
|
+
if (tallyData.mode !== core_1.EMode.QV) {
|
|
49
49
|
return true;
|
|
50
50
|
}
|
|
51
|
-
if (tallyData.
|
|
51
|
+
if (tallyData.perVoteOptionSpentVoiceCredits?.tally.length !== totalVoteOptions) {
|
|
52
52
|
throw new Error("Wrong number of vote options.");
|
|
53
53
|
}
|
|
54
54
|
// verify per vote option voice credits on-chain
|
|
55
|
-
const failedSpentCredits = await (0, utils_1.
|
|
55
|
+
const failedSpentCredits = await (0, utils_1.verifyPerVoteOptionSpentVoiceCredits)(tallyContract, tallyData, voteOptionTreeDepth, newSpentVoiceCreditsCommitment, newResultsCommitment);
|
|
56
56
|
if (failedSpentCredits.length > 0) {
|
|
57
57
|
throw new Error(`At least one tally result failed the on-chain verification. Please check your Tally data at these indexes: ${failedSpentCredits.join(", ")}`);
|
|
58
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../../../ts/tally/verification.ts"],"names":[],"mappings":";;;AAAA,8EAAwH;
|
|
1
|
+
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../../../ts/tally/verification.ts"],"names":[],"mappings":";;;AAAA,8EAAwH;AACxH,8CAA4C;AAI5C,kDAAoD;AAEpD,mCAAmF;AAEnF;;;GAGG;AACI,MAAM,MAAM,GAAG,KAAK,EAAE,EAC3B,MAAM,EACN,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACP,EAAoB,EAAE;IAClC,MAAM,mBAAmB,GAAG,SAAS,CAAC,IAAI,CAAC;IAE3C,MAAM,aAAa,GAAG,MAAM,IAAA,0BAAc,EAAC,MAAM,CAAC,QAA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BAAoB,EACpB,2CAA2C,IAAI,EAAE,CAClD,CAAC;IAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IAED,oDAAoD;IACpD,MAAM,uBAAuB,GAAG,MAAM,IAAA,0BAAkB,EACtD,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,8BAA8B,EAC9B,2CAA2C,CAC5C,CAAC;IAEF,IAAI,uBAAuB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CACb,mJAAmJ,uBAAuB,CAAC,IAAI,CAC7K,IAAI,CACL,EAAE,CACJ,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,IAAI,KAAK,YAAK,CAAC,EAAE,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,SAAS,CAAC,8BAA8B,EAAE,KAAK,CAAC,MAAM,KAAK,gBAAgB,EAAE,CAAC;QAChF,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,gDAAgD;IAChD,MAAM,kBAAkB,GAAG,MAAM,IAAA,4CAAoC,EACnE,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,8BAA8B,EAC9B,oBAAoB,CACrB,CAAC;IAEF,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,8GAA8G,kBAAkB,CAAC,IAAI,CACnI,IAAI,CACL,EAAE,CACJ,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAvGW,QAAA,MAAM,UAuGjB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { generateSignUpTree } from "./stateTree";
|
|
2
|
-
export type { IGenerateSignUpTreeArgs, IGenerateSignUpTree } from "./types";
|
|
1
|
+
export { generateSignUpTree, generateSignUpTreeWithEndKey } from "./stateTree";
|
|
2
|
+
export type { IGenerateSignUpTreeArgs, IGenerateSignUpTree, IGenerateSignUpTreeWithEndKeyArgs } from "./types";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/trees/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/trees/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC/E,YAAY,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC"}
|
package/build/ts/trees/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateSignUpTree = void 0;
|
|
3
|
+
exports.generateSignUpTreeWithEndKey = exports.generateSignUpTree = void 0;
|
|
4
4
|
var stateTree_1 = require("./stateTree");
|
|
5
5
|
Object.defineProperty(exports, "generateSignUpTree", { enumerable: true, get: function () { return stateTree_1.generateSignUpTree; } });
|
|
6
|
+
Object.defineProperty(exports, "generateSignUpTreeWithEndKey", { enumerable: true, get: function () { return stateTree_1.generateSignUpTreeWithEndKey; } });
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/trees/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/trees/index.ts"],"names":[],"mappings":";;;AAAA,yCAA+E;AAAtE,+GAAA,kBAAkB,OAAA;AAAE,yHAAA,4BAA4B,OAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IGenerateSignUpTreeArgs, IGenerateSignUpTree } from "./types";
|
|
1
|
+
import type { IGenerateSignUpTreeArgs, IGenerateSignUpTree, IGenerateSignUpTreeWithEndKeyArgs } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Generate a State tree object from the events of a MACI smart contracts
|
|
4
4
|
* @param provider - the ethereum provider
|
|
@@ -10,4 +10,18 @@ import type { IGenerateSignUpTreeArgs, IGenerateSignUpTree } from "./types";
|
|
|
10
10
|
* @returns State tree
|
|
11
11
|
*/
|
|
12
12
|
export declare const generateSignUpTree: ({ provider, address, fromBlock, blocksPerRequest, endBlock, sleepAmount, }: IGenerateSignUpTreeArgs) => Promise<IGenerateSignUpTree>;
|
|
13
|
+
/**
|
|
14
|
+
* Generate a State tree object from the events of a MACI smart contracts
|
|
15
|
+
* @param provider - the ethereum provider
|
|
16
|
+
* @param address - the address of the MACI contract
|
|
17
|
+
* @param fromBlock - the block number from which to start fetching events
|
|
18
|
+
* @param blocksPerRequest - the number of blocks to fetch in each request
|
|
19
|
+
* @param endBlock - the block number at which to stop fetching events
|
|
20
|
+
* @param sleepAmount - the amount of time to sleep between each request
|
|
21
|
+
* @param userPublicKey - the user public key where we end/stop the signUpTree replica.
|
|
22
|
+
* If user public key is 4th then the returned signUpTree will have only 4 leaves
|
|
23
|
+
* (does not matter if MACI' signUpTree has more).
|
|
24
|
+
* @returns State tree
|
|
25
|
+
*/
|
|
26
|
+
export declare const generateSignUpTreeWithEndKey: ({ provider, address, fromBlock, blocksPerRequest, endBlock, sleepAmount, userPublicKey, }: IGenerateSignUpTreeWithEndKeyArgs) => Promise<IGenerateSignUpTree>;
|
|
13
27
|
//# sourceMappingURL=stateTree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stateTree.d.ts","sourceRoot":"","sources":["../../../ts/trees/stateTree.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stateTree.d.ts","sourceRoot":"","sources":["../../../ts/trees/stateTree.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAI/G;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAU,4EAOtC,uBAAuB,KAAG,OAAO,CAAC,mBAAmB,CAoCvD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,GAAU,2FAQhD,iCAAiC,KAAG,OAAO,CAAC,mBAAmB,CA8CjE,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateSignUpTree = void 0;
|
|
3
|
+
exports.generateSignUpTreeWithEndKey = exports.generateSignUpTree = void 0;
|
|
4
4
|
/* eslint-disable no-underscore-dangle */
|
|
5
5
|
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
6
6
|
const crypto_1 = require("@maci-protocol/crypto");
|
|
7
7
|
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
8
8
|
const lean_imt_1 = require("@zk-kit/lean-imt");
|
|
9
|
-
const console_1 = require("console");
|
|
10
9
|
const utils_1 = require("../utils/utils");
|
|
11
10
|
/**
|
|
12
11
|
* Generate a State tree object from the events of a MACI smart contracts
|
|
@@ -23,7 +22,7 @@ const generateSignUpTree = async ({ provider, address, fromBlock = 0, blocksPerR
|
|
|
23
22
|
const maciContract = typechain_types_1.MACI__factory.connect(address, provider);
|
|
24
23
|
const signUpTree = new lean_imt_1.LeanIMT(crypto_1.hashLeanIMT);
|
|
25
24
|
signUpTree.insert(crypto_1.PAD_KEY_HASH);
|
|
26
|
-
const
|
|
25
|
+
const publicKeys = [];
|
|
27
26
|
// Fetch event logs in batches (lastBlock inclusive)
|
|
28
27
|
for (let i = fromBlock; i <= lastBlock; i += blocksPerRequest + 1) {
|
|
29
28
|
// the last block batch will be either current iteration block + blockPerRequest
|
|
@@ -32,12 +31,11 @@ const generateSignUpTree = async ({ provider, address, fromBlock = 0, blocksPerR
|
|
|
32
31
|
// eslint-disable-next-line no-await-in-loop
|
|
33
32
|
const signUpLogs = await maciContract.queryFilter(maciContract.filters.SignUp(), i, toBlock);
|
|
34
33
|
signUpLogs.forEach((event) => {
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
signUpTree.insert((0, crypto_1.hashLeftRight)(pubKeyX, pubKeyY));
|
|
34
|
+
const publicKeyX = event.args._userPublicKeyX;
|
|
35
|
+
const publicKeyY = event.args._userPublicKeyY;
|
|
36
|
+
const publicKey = new domainobjs_1.PublicKey([publicKeyX, publicKeyY]);
|
|
37
|
+
publicKeys.push(publicKey);
|
|
38
|
+
signUpTree.insert((0, crypto_1.hashLeftRight)(publicKeyX, publicKeyY));
|
|
41
39
|
});
|
|
42
40
|
if (sleepAmount) {
|
|
43
41
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -46,8 +44,61 @@ const generateSignUpTree = async ({ provider, address, fromBlock = 0, blocksPerR
|
|
|
46
44
|
}
|
|
47
45
|
return {
|
|
48
46
|
signUpTree,
|
|
49
|
-
|
|
47
|
+
publicKeys,
|
|
50
48
|
};
|
|
51
49
|
};
|
|
52
50
|
exports.generateSignUpTree = generateSignUpTree;
|
|
51
|
+
/**
|
|
52
|
+
* Generate a State tree object from the events of a MACI smart contracts
|
|
53
|
+
* @param provider - the ethereum provider
|
|
54
|
+
* @param address - the address of the MACI contract
|
|
55
|
+
* @param fromBlock - the block number from which to start fetching events
|
|
56
|
+
* @param blocksPerRequest - the number of blocks to fetch in each request
|
|
57
|
+
* @param endBlock - the block number at which to stop fetching events
|
|
58
|
+
* @param sleepAmount - the amount of time to sleep between each request
|
|
59
|
+
* @param userPublicKey - the user public key where we end/stop the signUpTree replica.
|
|
60
|
+
* If user public key is 4th then the returned signUpTree will have only 4 leaves
|
|
61
|
+
* (does not matter if MACI' signUpTree has more).
|
|
62
|
+
* @returns State tree
|
|
63
|
+
*/
|
|
64
|
+
const generateSignUpTreeWithEndKey = async ({ provider, address, fromBlock = 0, blocksPerRequest = 50, endBlock, sleepAmount, userPublicKey, }) => {
|
|
65
|
+
const lastBlock = endBlock || (await provider.getBlockNumber());
|
|
66
|
+
const maciContract = typechain_types_1.MACI__factory.connect(address, provider);
|
|
67
|
+
const signUpTree = new lean_imt_1.LeanIMT(crypto_1.hashLeanIMT);
|
|
68
|
+
signUpTree.insert(crypto_1.PAD_KEY_HASH);
|
|
69
|
+
const publicKeys = [];
|
|
70
|
+
// Fetch event logs in batches (lastBlock inclusive)
|
|
71
|
+
for (let i = fromBlock; i <= lastBlock; i += blocksPerRequest + 1) {
|
|
72
|
+
// the last block batch will be either current iteration block + blockPerRequest
|
|
73
|
+
// or the end block if it is set
|
|
74
|
+
const toBlock = i + blocksPerRequest >= lastBlock ? lastBlock : i + blocksPerRequest;
|
|
75
|
+
// eslint-disable-next-line no-await-in-loop
|
|
76
|
+
const signUpLogs = await maciContract.queryFilter(maciContract.filters.SignUp(), i, toBlock);
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
78
|
+
for (let j = 0; j < signUpLogs.length; j += 1) {
|
|
79
|
+
const event = signUpLogs[j];
|
|
80
|
+
const publicKeyX = event.args._userPublicKeyX;
|
|
81
|
+
const publicKeyY = event.args._userPublicKeyY;
|
|
82
|
+
const publicKey = new domainobjs_1.PublicKey([publicKeyX, publicKeyY]);
|
|
83
|
+
publicKeys.push(publicKey);
|
|
84
|
+
signUpTree.insert((0, crypto_1.hashLeftRight)(publicKeyX, publicKeyY));
|
|
85
|
+
// early return cause we found the user
|
|
86
|
+
if (publicKey.equals(userPublicKey)) {
|
|
87
|
+
return {
|
|
88
|
+
signUpTree,
|
|
89
|
+
publicKeys,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (sleepAmount) {
|
|
94
|
+
// eslint-disable-next-line no-await-in-loop
|
|
95
|
+
await (0, utils_1.sleep)(sleepAmount);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
signUpTree,
|
|
100
|
+
publicKeys,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
exports.generateSignUpTreeWithEndKey = generateSignUpTreeWithEndKey;
|
|
53
104
|
//# sourceMappingURL=stateTree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stateTree.js","sourceRoot":"","sources":["../../../ts/trees/stateTree.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,8EAAwF;AACxF,kDAAiF;AACjF,
|
|
1
|
+
{"version":3,"file":"stateTree.js","sourceRoot":"","sources":["../../../ts/trees/stateTree.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,8EAAwF;AACxF,kDAAiF;AACjF,0DAAsD;AACtD,+CAAgE;AAIhE,0CAAuC;AAEvC;;;;;;;;;GASG;AACI,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACvC,QAAQ,EACR,OAAO,EACP,SAAS,GAAG,CAAC,EACb,gBAAgB,GAAG,EAAE,EACrB,QAAQ,EACR,WAAW,GACa,EAAgC,EAAE;IAC1D,MAAM,SAAS,GAAG,QAAQ,IAAI,CAAC,MAAM,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;IAEhE,MAAM,YAAY,GAAG,+BAAW,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAG,IAAI,kBAAO,CAAC,oBAAkC,CAAC,CAAC;IACnE,UAAU,CAAC,MAAM,CAAC,qBAAY,CAAC,CAAC;IAChC,MAAM,UAAU,GAAgB,EAAE,CAAC;IAEnC,oDAAoD;IACpD,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC,IAAI,gBAAgB,GAAG,CAAC,EAAE,CAAC;QAClE,gFAAgF;QA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ACL,UAAU;oBACV,UAAU;iBACX,CAAC;YACJ,CAAC;QACH,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YAChB,4CAA4C;YAC5C,MAAM,IAAA,aAAK,EAAC,WAAW,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO;QACL,UAAU;QACV,UAAU;KACX,CAAC;AACJ,CAAC,CAAC;AAtDW,QAAA,4BAA4B,gCAsDvC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PublicKey } from "@maci-protocol/domainobjs";
|
|
2
2
|
import type { LeanIMT } from "@zk-kit/lean-imt";
|
|
3
3
|
import type { Provider } from "ethers";
|
|
4
4
|
/**
|
|
@@ -30,6 +30,15 @@ export interface IGenerateSignUpTreeArgs {
|
|
|
30
30
|
*/
|
|
31
31
|
sleepAmount?: number;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* An interface that represents arguments of generation sign up tree which stops fetching at a given public key
|
|
35
|
+
*/
|
|
36
|
+
export interface IGenerateSignUpTreeWithEndKeyArgs extends IGenerateSignUpTreeArgs {
|
|
37
|
+
/**
|
|
38
|
+
* The public key of the user
|
|
39
|
+
*/
|
|
40
|
+
userPublicKey: PublicKey;
|
|
41
|
+
}
|
|
33
42
|
/**
|
|
34
43
|
* An interface that represents sign up tree and state leaves
|
|
35
44
|
*/
|
|
@@ -41,6 +50,6 @@ export interface IGenerateSignUpTree {
|
|
|
41
50
|
/**
|
|
42
51
|
* State leaves
|
|
43
52
|
*/
|
|
44
|
-
|
|
53
|
+
publicKeys: PublicKey[];
|
|
45
54
|
}
|
|
46
55
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/trees/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/trees/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iCAAkC,SAAQ,uBAAuB;IAChF;;OAEG;IACH,aAAa,EAAE,SAAS,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB"}
|
package/build/ts/user/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { joinPoll } from "./joinPoll";
|
|
2
2
|
export { getSignedupUserData, signup, hasUserSignedUp } from "./signup";
|
|
3
|
-
export { getJoinedUserData, hasUserJoinedPoll } from "./utils";
|
|
4
|
-
export type { IJoinedUserArgs, IIsRegisteredUser, IIsJoinedUser, ISignupArgs, IRegisteredUserArgs, IPollJoinedCircuitInputs, IPollJoiningCircuitInputs, IJoinPollArgs, IIsNullifierOnChainArgs, IGetPollJoiningCircuitEventsArgs, IGetPollJoiningCircuitInputsFromStateFileArgs, IJoinPollData, IParsePollJoinEventsArgs, IParseSignupEventsArgs, ISignupData, IHasUserSignedUpArgs, } from "./types";
|
|
3
|
+
export { getJoinedUserData, hasUserJoinedPoll, generateMaciStateTree as genMaciStateTree, generateMaciStateTreeWithEndKey as genMaciStateTreeWithEndKey, getPollJoiningCircuitEvents, joiningCircuitInputs, } from "./utils";
|
|
4
|
+
export type { IJoinedUserArgs, IIsRegisteredUser, IIsJoinedUser, ISignupArgs, IRegisteredUserArgs, IPollJoinedCircuitInputs, IPollJoiningCircuitInputs, IJoinPollArgs, IIsNullifierOnChainArgs, IGetPollJoiningCircuitEventsArgs, IGetPollJoiningCircuitInputsFromStateFileArgs, IJoinPollData, IParsePollJoinEventsArgs, IParseSignupEventsArgs, ISignupData, IHasUserSignedUpArgs, IGenMaciStateTreeArgs, IGenMaciStateTreeWithEndKeyArgs, } from "./types";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/user/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/user/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,IAAI,gBAAgB,EACzC,+BAA+B,IAAI,0BAA0B,EAC7D,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,aAAa,EACb,uBAAuB,EACvB,gCAAgC,EAChC,6CAA6C,EAC7C,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,WAAW,EACX,oBAAoB,EACpB,qBAAqB,EACrB,+BAA+B,GAChC,MAAM,SAAS,CAAC"}
|
package/build/ts/user/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasUserJoinedPoll = exports.getJoinedUserData = exports.hasUserSignedUp = exports.signup = exports.getSignedupUserData = exports.joinPoll = void 0;
|
|
3
|
+
exports.joiningCircuitInputs = exports.getPollJoiningCircuitEvents = exports.genMaciStateTreeWithEndKey = exports.genMaciStateTree = exports.hasUserJoinedPoll = exports.getJoinedUserData = exports.hasUserSignedUp = exports.signup = exports.getSignedupUserData = exports.joinPoll = void 0;
|
|
4
4
|
var joinPoll_1 = require("./joinPoll");
|
|
5
5
|
Object.defineProperty(exports, "joinPoll", { enumerable: true, get: function () { return joinPoll_1.joinPoll; } });
|
|
6
6
|
var signup_1 = require("./signup");
|
|
@@ -10,4 +10,8 @@ Object.defineProperty(exports, "hasUserSignedUp", { enumerable: true, get: funct
|
|
|
10
10
|
var utils_1 = require("./utils");
|
|
11
11
|
Object.defineProperty(exports, "getJoinedUserData", { enumerable: true, get: function () { return utils_1.getJoinedUserData; } });
|
|
12
12
|
Object.defineProperty(exports, "hasUserJoinedPoll", { enumerable: true, get: function () { return utils_1.hasUserJoinedPoll; } });
|
|
13
|
+
Object.defineProperty(exports, "genMaciStateTree", { enumerable: true, get: function () { return utils_1.generateMaciStateTree; } });
|
|
14
|
+
Object.defineProperty(exports, "genMaciStateTreeWithEndKey", { enumerable: true, get: function () { return utils_1.generateMaciStateTreeWithEndKey; } });
|
|
15
|
+
Object.defineProperty(exports, "getPollJoiningCircuitEvents", { enumerable: true, get: function () { return utils_1.getPollJoiningCircuitEvents; } });
|
|
16
|
+
Object.defineProperty(exports, "joiningCircuitInputs", { enumerable: true, get: function () { return utils_1.joiningCircuitInputs; } });
|
|
13
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/user/index.ts"],"names":[],"mappings":";;;AAAA,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,mCAAwE;AAA/D,6GAAA,mBAAmB,OAAA;AAAE,gGAAA,MAAM,OAAA;AAAE,yGAAA,eAAe,OAAA;AACrD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/user/index.ts"],"names":[],"mappings":";;;AAAA,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,mCAAwE;AAA/D,6GAAA,mBAAmB,OAAA;AAAE,gGAAA,MAAM,OAAA;AAAE,yGAAA,eAAe,OAAA;AACrD,iCAOiB;AANf,0GAAA,iBAAiB,OAAA;AACjB,0GAAA,iBAAiB,OAAA;AACjB,yGAAA,qBAAqB,OAAoB;AACzC,mHAAA,+BAA+B,OAA8B;AAC7D,oHAAA,2BAA2B,OAAA;AAC3B,6GAAA,oBAAoB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joinPoll.d.ts","sourceRoot":"","sources":["../../../ts/user/joinPoll.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAQ5D;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAU,mLAgB5B,aAAa,KAAG,OAAO,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"joinPoll.d.ts","sourceRoot":"","sources":["../../../ts/user/joinPoll.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAQ5D;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAU,mLAgB5B,aAAa,KAAG,OAAO,CAAC,aAAa,CA4FvC,CAAC"}
|