@maci-protocol/sdk 0.0.0-ci.f433bba → 0.0.0-ci.f4e2c46
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 +2 -1
- package/build/ts/browser/index.d.ts.map +1 -1
- package/build/ts/browser/index.js +6 -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 +2 -2
- 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 +2 -1
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +12 -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.d.ts.map +1 -1
- package/build/ts/maciKeys/keypair.js +4 -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/maciKeys/types.d.ts +5 -0
- package/build/ts/maciKeys/types.d.ts.map +1 -1
- package/build/ts/poll/poll.d.ts.map +1 -1
- package/build/ts/poll/poll.js +8 -8
- 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 +29 -23
- package/build/ts/proof/generate.js.map +1 -1
- package/build/ts/proof/prove.js +13 -13
- package/build/ts/proof/prove.js.map +1 -1
- package/build/ts/proof/types.d.ts +40 -14
- 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/subgraph/index.d.ts +3 -0
- package/build/ts/subgraph/index.d.ts.map +1 -0
- package/build/ts/subgraph/index.js +18 -0
- package/build/ts/subgraph/index.js.map +1 -0
- package/build/ts/subgraph/maciSubgraph.d.ts +28 -0
- package/build/ts/subgraph/maciSubgraph.d.ts.map +1 -0
- package/build/ts/subgraph/maciSubgraph.js +62 -0
- package/build/ts/subgraph/maciSubgraph.js.map +1 -0
- package/build/ts/subgraph/types.d.ts +20 -0
- package/build/ts/subgraph/types.d.ts.map +1 -0
- package/build/ts/subgraph/types.js +3 -0
- package/build/ts/subgraph/types.js.map +1 -0
- 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 +5 -1
- package/build/ts/tally/index.js.map +1 -1
- package/build/ts/tally/results.d.ts +20 -0
- package/build/ts/tally/results.d.ts.map +1 -0
- package/build/ts/tally/results.js +49 -0
- package/build/ts/tally/results.js.map +1 -0
- package/build/ts/tally/types.d.ts +55 -15
- 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 +10 -10
- 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 +3 -1
- package/build/ts/trees/index.js.map +1 -1
- package/build/ts/trees/stateTree.d.ts +23 -1
- package/build/ts/trees/stateTree.d.ts.map +1 -1
- package/build/ts/trees/stateTree.js +74 -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 +1 -1
- package/build/ts/user/joinPoll.d.ts.map +1 -1
- package/build/ts/user/joinPoll.js +11 -12
- 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 +26 -21
- package/build/ts/user/signup.js.map +1 -1
- package/build/ts/user/types.d.ts +63 -27
- 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 +84 -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 +18 -19
- 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 +54 -46
- 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 +75 -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 +2 -1
- package/build/ts/vote/index.d.ts.map +1 -1
- package/build/ts/vote/index.js +4 -2
- package/build/ts/vote/index.js.map +1 -1
- package/build/ts/vote/invalidate.js +4 -4
- 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
package/build/ts/user/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { LeanIMTMerkleProof } from "@zk-kit/lean-imt";
|
|
1
2
|
import type { MACI, Poll } from "@maci-protocol/contracts/typechain-types";
|
|
2
|
-
import type {
|
|
3
|
+
import type { PrivateKey, PublicKey } from "@maci-protocol/domainobjs";
|
|
3
4
|
import type { Signer } from "ethers";
|
|
4
5
|
/**
|
|
5
6
|
* Interface for the arguments to the isJoinedUser command
|
|
@@ -16,7 +17,7 @@ export interface IJoinedUserArgs {
|
|
|
16
17
|
/**
|
|
17
18
|
* Poll public key for the poll
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
pollPublicKey: string;
|
|
20
21
|
/**
|
|
21
22
|
* A signer object
|
|
22
23
|
*/
|
|
@@ -63,7 +64,7 @@ export interface ISignupArgs {
|
|
|
63
64
|
/**
|
|
64
65
|
* The public key of the user
|
|
65
66
|
*/
|
|
66
|
-
|
|
67
|
+
maciPublicKey: string;
|
|
67
68
|
/**
|
|
68
69
|
* A signer object
|
|
69
70
|
*/
|
|
@@ -101,7 +102,7 @@ export interface IRegisteredUserArgs {
|
|
|
101
102
|
/**
|
|
102
103
|
* The public key of the user
|
|
103
104
|
*/
|
|
104
|
-
|
|
105
|
+
maciPublicKey: string;
|
|
105
106
|
/**
|
|
106
107
|
* The address of the MACI contract
|
|
107
108
|
*/
|
|
@@ -130,7 +131,7 @@ export interface IParsePollJoinEventsArgs {
|
|
|
130
131
|
/**
|
|
131
132
|
* The public key
|
|
132
133
|
*/
|
|
133
|
-
pollPublicKey:
|
|
134
|
+
pollPublicKey: PublicKey;
|
|
134
135
|
}
|
|
135
136
|
/**
|
|
136
137
|
* Interface for the arguments to the parseSignupEvents function
|
|
@@ -151,7 +152,7 @@ export interface IParseSignupEventsArgs {
|
|
|
151
152
|
/**
|
|
152
153
|
* The public key
|
|
153
154
|
*/
|
|
154
|
-
publicKey:
|
|
155
|
+
publicKey: PublicKey;
|
|
155
156
|
}
|
|
156
157
|
/**
|
|
157
158
|
* An interface describing the circuit inputs to the PollJoining circuit
|
|
@@ -160,11 +161,11 @@ export interface IPollJoiningCircuitInputs {
|
|
|
160
161
|
/**
|
|
161
162
|
* The private key
|
|
162
163
|
*/
|
|
163
|
-
|
|
164
|
+
privateKey: string;
|
|
164
165
|
/**
|
|
165
166
|
* The poll public key
|
|
166
167
|
*/
|
|
167
|
-
|
|
168
|
+
pollPublicKey: string[];
|
|
168
169
|
/**
|
|
169
170
|
* The state leaf
|
|
170
171
|
*/
|
|
@@ -201,15 +202,11 @@ export interface IPollJoinedCircuitInputs {
|
|
|
201
202
|
/**
|
|
202
203
|
* The private key
|
|
203
204
|
*/
|
|
204
|
-
|
|
205
|
+
privateKey: string;
|
|
205
206
|
/**
|
|
206
207
|
* The voice credits balance
|
|
207
208
|
*/
|
|
208
209
|
voiceCreditsBalance: string;
|
|
209
|
-
/**
|
|
210
|
-
* The join timestamp
|
|
211
|
-
*/
|
|
212
|
-
joinTimestamp: string;
|
|
213
210
|
/**
|
|
214
211
|
* The state leaf
|
|
215
212
|
*/
|
|
@@ -248,11 +245,7 @@ export interface IJoinPollArgs {
|
|
|
248
245
|
*/
|
|
249
246
|
pollId: bigint;
|
|
250
247
|
/**
|
|
251
|
-
*
|
|
252
|
-
*/
|
|
253
|
-
stateIndex?: bigint;
|
|
254
|
-
/**
|
|
255
|
-
* Path to the state file with MACI state
|
|
248
|
+
* Path to the state file with MACI state. Not available in the browser's SDK
|
|
256
249
|
*/
|
|
257
250
|
stateFile?: string;
|
|
258
251
|
/**
|
|
@@ -284,9 +277,9 @@ export interface IJoinPollArgs {
|
|
|
284
277
|
*/
|
|
285
278
|
rapidsnark?: string;
|
|
286
279
|
/**
|
|
287
|
-
* The path to the poll
|
|
280
|
+
* The path to the poll witness generator binary
|
|
288
281
|
*/
|
|
289
|
-
|
|
282
|
+
pollWitnessGenerator?: string;
|
|
290
283
|
/**
|
|
291
284
|
* The path to the poll wasm file
|
|
292
285
|
*/
|
|
@@ -300,6 +293,19 @@ export interface IJoinPollArgs {
|
|
|
300
293
|
*/
|
|
301
294
|
ivcpDataArg: string;
|
|
302
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* Interface for the arguments to the joinPoll command for the browser
|
|
298
|
+
*/
|
|
299
|
+
export interface IJoinPollBrowserArgs extends IJoinPollArgs {
|
|
300
|
+
/**
|
|
301
|
+
* Whether to use of not the latest state index
|
|
302
|
+
*/
|
|
303
|
+
useLatestStateIndex?: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* The inclusion proof
|
|
306
|
+
*/
|
|
307
|
+
inclusionProof?: LeanIMTMerkleProof;
|
|
308
|
+
}
|
|
303
309
|
/**
|
|
304
310
|
* Interface for the return data to the joinPoll command
|
|
305
311
|
*/
|
|
@@ -312,10 +318,6 @@ export interface IJoinPollData {
|
|
|
312
318
|
* Voice credits balance
|
|
313
319
|
*/
|
|
314
320
|
voiceCredits: string;
|
|
315
|
-
/**
|
|
316
|
-
* Joining poll timestamp
|
|
317
|
-
*/
|
|
318
|
-
timestamp: string;
|
|
319
321
|
/**
|
|
320
322
|
* Private key nullifier
|
|
321
323
|
*/
|
|
@@ -346,6 +348,40 @@ export interface IIsNullifierOnChainArgs {
|
|
|
346
348
|
*/
|
|
347
349
|
signer: Signer;
|
|
348
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Arguments for IGenerateMaciStateTreeArgs
|
|
353
|
+
*/
|
|
354
|
+
export interface IGenerateMaciStateTreeArgs {
|
|
355
|
+
/**
|
|
356
|
+
* The MACI contract address
|
|
357
|
+
*/
|
|
358
|
+
maciContractAddress: string;
|
|
359
|
+
/**
|
|
360
|
+
* The signer
|
|
361
|
+
*/
|
|
362
|
+
signer: Signer;
|
|
363
|
+
/**
|
|
364
|
+
* The start block
|
|
365
|
+
*/
|
|
366
|
+
startBlock?: number;
|
|
367
|
+
/**
|
|
368
|
+
* The end block
|
|
369
|
+
*/
|
|
370
|
+
endBlock?: number;
|
|
371
|
+
/**
|
|
372
|
+
* The blocks per batch
|
|
373
|
+
*/
|
|
374
|
+
blocksPerBatch?: number;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Arguments for IGenerateMaciStateTreeWithEndKeyArgs
|
|
378
|
+
*/
|
|
379
|
+
export interface IGenerateMaciStateTreeWithEndKeyArgs extends IGenerateMaciStateTreeArgs {
|
|
380
|
+
/**
|
|
381
|
+
* The public key of the user
|
|
382
|
+
*/
|
|
383
|
+
userPublicKey: PublicKey;
|
|
384
|
+
}
|
|
349
385
|
/**
|
|
350
386
|
* Arguments for getPollJoiningCircuitEvents
|
|
351
387
|
*/
|
|
@@ -365,7 +401,7 @@ export interface IGetPollJoiningCircuitEventsArgs {
|
|
|
365
401
|
/**
|
|
366
402
|
* The user's maci private key
|
|
367
403
|
*/
|
|
368
|
-
|
|
404
|
+
userMaciPrivateKey: PrivateKey;
|
|
369
405
|
/**
|
|
370
406
|
* The signer
|
|
371
407
|
*/
|
|
@@ -402,7 +438,7 @@ export interface IGetPollJoiningCircuitInputsFromStateFileArgs {
|
|
|
402
438
|
/**
|
|
403
439
|
* The user's maci private key
|
|
404
440
|
*/
|
|
405
|
-
|
|
441
|
+
userMaciPrivateKey: PrivateKey;
|
|
406
442
|
}
|
|
407
443
|
/**
|
|
408
444
|
* Interface for the arguments for the is signed up command
|
|
@@ -415,7 +451,7 @@ export interface IHasUserSignedUpArgs {
|
|
|
415
451
|
/**
|
|
416
452
|
* The public key of the user
|
|
417
453
|
*/
|
|
418
|
-
|
|
454
|
+
maciPublicKey: string;
|
|
419
455
|
/**
|
|
420
456
|
* The signer to use for the transaction
|
|
421
457
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/user/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/user/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;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AE/B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,6CAA6C;IAC5D;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,kBAAkB,EAAE,UAAU,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
package/build/ts/user/utils.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { IGetPollJoiningCircuitEventsArgs, IGetPollJoiningCircuitInputsFromStateFileArgs, IParsePollJoinEventsArgs, IParseSignupEventsArgs,
|
|
1
|
+
import { PrivateKey, PublicKey } from "@maci-protocol/domainobjs";
|
|
2
|
+
import type { IGetPollJoiningCircuitEventsArgs, IGetPollJoiningCircuitInputsFromStateFileArgs, IParsePollJoinEventsArgs, IParseSignupEventsArgs, IJoinedUserArgs, IIsNullifierOnChainArgs, IGenerateMaciStateTreeArgs, IGenerateMaciStateTreeWithEndKeyArgs } from "./types";
|
|
3
3
|
import type { IGenerateSignUpTree } from "../trees/types";
|
|
4
|
-
import type {
|
|
4
|
+
import type { TCircuitInputs } from "../utils/types";
|
|
5
|
+
import type { LeanIMTMerkleProof } from "@zk-kit/lean-imt";
|
|
5
6
|
/**
|
|
6
7
|
* Parse the poll joining events from the Poll contract
|
|
7
8
|
*/
|
|
@@ -14,7 +15,7 @@ export declare const parsePollJoinEvents: ({ pollContract, startBlock, currentBl
|
|
|
14
15
|
* @param {IJoinedUserArgs} - The arguments for the join check command
|
|
15
16
|
* @returns user joined or not and poll state index, voice credit balance
|
|
16
17
|
*/
|
|
17
|
-
export declare const getJoinedUserData: ({ maciAddress, pollId,
|
|
18
|
+
export declare const getJoinedUserData: ({ maciAddress, pollId, pollPublicKey: serializedPollPublicKey, signer, startBlock, }: IJoinedUserArgs) => Promise<{
|
|
18
19
|
isJoined: boolean;
|
|
19
20
|
pollStateIndex?: string;
|
|
20
21
|
voiceCredits?: string;
|
|
@@ -33,30 +34,41 @@ export declare const parseSignupEvents: ({ maciContract, startBlock, currentBloc
|
|
|
33
34
|
}>;
|
|
34
35
|
/**
|
|
35
36
|
* Get state index from maci state leaves or from sign up leaves
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
37
|
+
* @param publicKeys Public keys from maci state or sign up tree
|
|
38
|
+
* @param userMaciPublicKey Public key of the maci user
|
|
38
39
|
* @param stateIndex State index from the command
|
|
39
40
|
* @returns State index
|
|
40
41
|
*/
|
|
41
|
-
export declare const getStateIndex: (
|
|
42
|
+
export declare const getStateIndex: (publicKeys: PublicKey[], userMaciPublicKey: PublicKey, stateIndex?: bigint) => bigint | undefined;
|
|
42
43
|
/**
|
|
43
44
|
* Create circuit input for pollJoining
|
|
44
45
|
* @param signUpData Sign up tree and state leaves
|
|
45
46
|
* @param stateTreeDepth Maci state tree depth
|
|
46
|
-
* @param
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
49
|
-
* @param pollPubKey Poll's public key for the poll joining
|
|
47
|
+
* @param maciPrivateKey User's private key for signing up
|
|
48
|
+
* @param pollPrivateKey Poll's private key for the poll joining
|
|
49
|
+
* @param pollPublicKey Poll's public key for the poll joining
|
|
50
50
|
* @param pollId Poll's id
|
|
51
51
|
* @returns stringified circuit inputs
|
|
52
52
|
*/
|
|
53
|
-
export declare const joiningCircuitInputs: (
|
|
53
|
+
export declare const joiningCircuitInputs: (inclusionProof: LeanIMTMerkleProof, stateTreeDepth: bigint, maciPrivateKey: PrivateKey, pollPublicKey: PublicKey, pollId: bigint) => TCircuitInputs;
|
|
54
54
|
/**
|
|
55
55
|
* Get the poll joining circuit inputs from a state file
|
|
56
56
|
* @param stateFile - The path to the state file
|
|
57
57
|
* @returns The poll joining circuit inputs
|
|
58
58
|
*/
|
|
59
|
-
export declare const getPollJoiningCircuitInputsFromStateFile: ({ stateFile, pollId, stateIndex,
|
|
59
|
+
export declare const getPollJoiningCircuitInputsFromStateFile: ({ stateFile, pollId, stateIndex, userMaciPrivateKey, }: IGetPollJoiningCircuitInputsFromStateFileArgs) => Promise<TCircuitInputs>;
|
|
60
|
+
/**
|
|
61
|
+
* Generate MACI's state tree from the MACI contract
|
|
62
|
+
* @param {IGenerateMaciStateTreeArgs} args - The arguments for the generate maci state tree command
|
|
63
|
+
* @returns The MACI's state tree
|
|
64
|
+
*/
|
|
65
|
+
export declare const generateMaciStateTree: ({ maciContractAddress, signer, startBlock, endBlock, blocksPerBatch, }: IGenerateMaciStateTreeArgs) => Promise<IGenerateSignUpTree>;
|
|
66
|
+
/**
|
|
67
|
+
* Generate MACI's state tree from the MACI contract with a given end key
|
|
68
|
+
* @param {IGenerateMaciStateTreeWithEndKeyArgs} args - The arguments for the generate maci state tree command
|
|
69
|
+
* @returns The MACI's state tree
|
|
70
|
+
*/
|
|
71
|
+
export declare const generateMaciStateTreeWithEndKey: ({ maciContractAddress, signer, startBlock, endBlock, blocksPerBatch, userPublicKey, }: IGenerateMaciStateTreeWithEndKeyArgs) => Promise<IGenerateSignUpTree>;
|
|
60
72
|
/**
|
|
61
73
|
* Get the poll joining circuit events from a state file
|
|
62
74
|
* @param maciContract - The MACI contract
|
|
@@ -64,5 +76,5 @@ export declare const getPollJoiningCircuitInputsFromStateFile: ({ stateFile, pol
|
|
|
64
76
|
* @param signer - The signer
|
|
65
77
|
* @returns The poll joining circuit events
|
|
66
78
|
*/
|
|
67
|
-
export declare const getPollJoiningCircuitEvents: ({ maciContract, stateIndex, pollId,
|
|
79
|
+
export declare const getPollJoiningCircuitEvents: ({ maciContract, stateIndex, pollId, userMaciPrivateKey, signer, startBlock, endBlock, blocksPerBatch, }: IGetPollJoiningCircuitEventsArgs) => Promise<TCircuitInputs>;
|
|
68
80
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAI3E,OAAO,KAAK,EACV,gCAAgC,EAChC,6CAA6C,EAC7C,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,uBAAuB,EACvB,0BAA0B,EAC1B,oCAAoC,EACrC,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAK3D;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAU,4DAKvC,wBAAwB,KAAG,OAAO,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAyBA,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAU,sFAMrC,eAAe,KAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAqBjG,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAU,6CAKrC,uBAAuB,KAAG,OAAO,CAAC,OAAO,CAM3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAU,wDAKrC,sBAAsB,KAAG,OAAO,CAAC;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAsB1D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACxB,YAAY,SAAS,EAAE,EACvB,mBAAmB,SAAS,EAC5B,aAAa,MAAM,KAClB,MAAM,GAAG,SAYX,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAC/B,gBAAgB,kBAAkB,EAClC,gBAAgB,MAAM,EACtB,gBAAgB,UAAU,EAC1B,eAAe,SAAS,EACxB,QAAQ,MAAM,KACb,cA0CF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wCAAwC,GAAU,wDAK5D,6CAA6C,KAAG,OAAO,CAAC,cAAc,CAwBxE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAU,wEAMzC,0BAA0B,KAAG,OAAO,CAAC,mBAAmB,CAkB1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,GAAU,uFAOnD,oCAAoC,KAAG,OAAO,CAAC,mBAAmB,CAkBpE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GAAU,yGAS/C,gCAAgC,KAAG,OAAO,CAAC,cAAc,CAkC3D,CAAC"}
|
package/build/ts/user/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPollJoiningCircuitEvents = exports.getPollJoiningCircuitInputsFromStateFile = exports.joiningCircuitInputs = exports.getStateIndex = exports.parseSignupEvents = exports.hasUserJoinedPoll = exports.getJoinedUserData = exports.parsePollJoinEvents = void 0;
|
|
6
|
+
exports.getPollJoiningCircuitEvents = exports.generateMaciStateTreeWithEndKey = exports.generateMaciStateTree = exports.getPollJoiningCircuitInputsFromStateFile = exports.joiningCircuitInputs = exports.getStateIndex = exports.parseSignupEvents = exports.hasUserJoinedPoll = exports.getJoinedUserData = exports.parsePollJoinEvents = void 0;
|
|
7
7
|
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
8
8
|
const core_1 = require("@maci-protocol/core");
|
|
9
9
|
const crypto_1 = require("@maci-protocol/crypto");
|
|
@@ -17,13 +17,13 @@ const constants_1 = require("../utils/constants");
|
|
|
17
17
|
const parsePollJoinEvents = async ({ pollContract, startBlock, currentBlock, pollPublicKey, }) => {
|
|
18
18
|
for (let block = startBlock; block <= currentBlock; block += constants_1.BLOCKS_STEP) {
|
|
19
19
|
const toBlock = Math.min(block + constants_1.BLOCKS_STEP - 1, currentBlock);
|
|
20
|
-
const
|
|
20
|
+
const publicKey = pollPublicKey.asArray();
|
|
21
21
|
// eslint-disable-next-line no-await-in-loop
|
|
22
|
-
const newEvents = await pollContract.queryFilter(pollContract.filters.PollJoined(
|
|
22
|
+
const newEvents = await pollContract.queryFilter(pollContract.filters.PollJoined(publicKey[0], publicKey[1], undefined, undefined, undefined), block, toBlock);
|
|
23
23
|
if (newEvents.length > 0) {
|
|
24
24
|
const [event] = newEvents;
|
|
25
25
|
return {
|
|
26
|
-
pollStateIndex: event.args[
|
|
26
|
+
pollStateIndex: event.args[4].toString(),
|
|
27
27
|
voiceCredits: event.args[2].toString(),
|
|
28
28
|
};
|
|
29
29
|
}
|
|
@@ -39,11 +39,11 @@ exports.parsePollJoinEvents = parsePollJoinEvents;
|
|
|
39
39
|
* @param {IJoinedUserArgs} - The arguments for the join check command
|
|
40
40
|
* @returns user joined or not and poll state index, voice credit balance
|
|
41
41
|
*/
|
|
42
|
-
const getJoinedUserData = async ({ maciAddress, pollId,
|
|
42
|
+
const getJoinedUserData = async ({ maciAddress, pollId, pollPublicKey: serializedPollPublicKey, signer, startBlock, }) => {
|
|
43
43
|
const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
|
|
44
44
|
const pollContracts = await maciContract.getPoll(pollId);
|
|
45
45
|
const pollContract = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer);
|
|
46
|
-
const pollPublicKey = domainobjs_1.
|
|
46
|
+
const pollPublicKey = domainobjs_1.PublicKey.deserialize(serializedPollPublicKey);
|
|
47
47
|
const startBlockNumber = startBlock || 0;
|
|
48
48
|
const currentBlock = await signer.provider.getBlockNumber();
|
|
49
49
|
const { pollStateIndex, voiceCredits } = await (0, exports.parsePollJoinEvents)({
|
|
@@ -78,7 +78,7 @@ const parseSignupEvents = async ({ maciContract, startBlock, currentBlock, publi
|
|
|
78
78
|
for (let block = startBlock; block <= currentBlock; block += constants_1.BLOCKS_STEP) {
|
|
79
79
|
const toBlock = Math.min(block + constants_1.BLOCKS_STEP - 1, currentBlock);
|
|
80
80
|
// eslint-disable-next-line no-await-in-loop
|
|
81
|
-
const newEvents = await maciContract.queryFilter(maciContract.filters.SignUp(undefined, undefined, publicKey.
|
|
81
|
+
const newEvents = await maciContract.queryFilter(maciContract.filters.SignUp(undefined, undefined, publicKey.raw[0], publicKey.raw[1]), block, toBlock);
|
|
82
82
|
if (newEvents.length > 0) {
|
|
83
83
|
const [event] = newEvents;
|
|
84
84
|
return {
|
|
@@ -93,14 +93,14 @@ const parseSignupEvents = async ({ maciContract, startBlock, currentBlock, publi
|
|
|
93
93
|
exports.parseSignupEvents = parseSignupEvents;
|
|
94
94
|
/**
|
|
95
95
|
* Get state index from maci state leaves or from sign up leaves
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
96
|
+
* @param publicKeys Public keys from maci state or sign up tree
|
|
97
|
+
* @param userMaciPublicKey Public key of the maci user
|
|
98
98
|
* @param stateIndex State index from the command
|
|
99
99
|
* @returns State index
|
|
100
100
|
*/
|
|
101
|
-
const getStateIndex = (
|
|
101
|
+
const getStateIndex = (publicKeys, userMaciPublicKey, stateIndex) => {
|
|
102
102
|
if (!stateIndex) {
|
|
103
|
-
const index =
|
|
103
|
+
const index = publicKeys.findIndex((key) => key.equals(userMaciPublicKey));
|
|
104
104
|
if (index > 0) {
|
|
105
105
|
return BigInt(index);
|
|
106
106
|
}
|
|
@@ -113,18 +113,15 @@ exports.getStateIndex = getStateIndex;
|
|
|
113
113
|
* Create circuit input for pollJoining
|
|
114
114
|
* @param signUpData Sign up tree and state leaves
|
|
115
115
|
* @param stateTreeDepth Maci state tree depth
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
119
|
-
* @param pollPubKey Poll's public key for the poll joining
|
|
116
|
+
* @param maciPrivateKey User's private key for signing up
|
|
117
|
+
* @param pollPrivateKey Poll's private key for the poll joining
|
|
118
|
+
* @param pollPublicKey Poll's public key for the poll joining
|
|
120
119
|
* @param pollId Poll's id
|
|
121
120
|
* @returns stringified circuit inputs
|
|
122
121
|
*/
|
|
123
|
-
const joiningCircuitInputs = (
|
|
124
|
-
// Get the state leaf on the index position
|
|
125
|
-
const { signUpTree: stateTree } = signUpData;
|
|
122
|
+
const joiningCircuitInputs = (inclusionProof, stateTreeDepth, maciPrivateKey, pollPublicKey, pollId) => {
|
|
126
123
|
// calculate the path elements for the state tree given the original state tree
|
|
127
|
-
const { siblings, index } =
|
|
124
|
+
const { siblings, index, root: stateRoot } = inclusionProof;
|
|
128
125
|
const siblingsLength = siblings.length;
|
|
129
126
|
// The index must be converted to a list of indices, 1 for each tree level.
|
|
130
127
|
// The circuit tree depth is this.stateTreeDepth, so the number of siblings must be this.stateTreeDepth,
|
|
@@ -140,16 +137,14 @@ const joiningCircuitInputs = (signUpData, stateTreeDepth, maciPrivKey, stateLeaf
|
|
|
140
137
|
}
|
|
141
138
|
const siblingsArray = siblings.map((sibling) => [sibling]);
|
|
142
139
|
// Create nullifier from private key
|
|
143
|
-
const inputNullifier = BigInt(
|
|
140
|
+
const inputNullifier = BigInt(maciPrivateKey.asCircuitInputs());
|
|
144
141
|
const nullifier = (0, crypto_1.poseidon)([inputNullifier, pollId]);
|
|
145
|
-
// Get pll state tree's root
|
|
146
|
-
const stateRoot = stateTree.root;
|
|
147
142
|
// Set actualStateTreeDepth as number of initial siblings length
|
|
148
143
|
const actualStateTreeDepth = BigInt(siblingsLength);
|
|
149
144
|
// Calculate public input hash from nullifier, credits and current root
|
|
150
145
|
const circuitInputs = {
|
|
151
|
-
|
|
152
|
-
|
|
146
|
+
privateKey: maciPrivateKey.asCircuitInputs(),
|
|
147
|
+
pollPublicKey: pollPublicKey.asCircuitInputs(),
|
|
153
148
|
siblings: siblingsArray,
|
|
154
149
|
indices,
|
|
155
150
|
nullifier,
|
|
@@ -165,47 +160,39 @@ exports.joiningCircuitInputs = joiningCircuitInputs;
|
|
|
165
160
|
* @param stateFile - The path to the state file
|
|
166
161
|
* @returns The poll joining circuit inputs
|
|
167
162
|
*/
|
|
168
|
-
const getPollJoiningCircuitInputsFromStateFile = async ({ stateFile, pollId, stateIndex,
|
|
163
|
+
const getPollJoiningCircuitInputsFromStateFile = async ({ stateFile, pollId, stateIndex, userMaciPrivateKey, }) => {
|
|
169
164
|
const file = await fs_1.default.promises.readFile(stateFile);
|
|
170
165
|
const content = JSON.parse(file.toString());
|
|
171
166
|
const maciState = core_1.MaciState.fromJSON(content);
|
|
172
167
|
const poll = maciState.polls.get(pollId);
|
|
173
|
-
const {
|
|
174
|
-
const loadedStateIndex = (0, exports.getStateIndex)(maciState.
|
|
168
|
+
const { publicKey: userPublicKey } = new domainobjs_1.Keypair(userMaciPrivateKey);
|
|
169
|
+
const loadedStateIndex = (0, exports.getStateIndex)(maciState.publicKeys, userPublicKey, stateIndex);
|
|
175
170
|
// check < 1 cause index zero is a blank state leaf
|
|
176
171
|
if (loadedStateIndex < 1) {
|
|
177
172
|
throw new Error("Invalid state index");
|
|
178
173
|
}
|
|
179
|
-
poll.updatePoll(BigInt(maciState.
|
|
174
|
+
poll.updatePoll(BigInt(maciState.publicKeys.length));
|
|
180
175
|
const circuitInputs = poll.joiningCircuitInputs({
|
|
181
|
-
|
|
176
|
+
maciPrivateKey: userMaciPrivateKey,
|
|
182
177
|
stateLeafIndex: stateIndex,
|
|
183
|
-
|
|
178
|
+
pollPublicKey: userPublicKey,
|
|
184
179
|
});
|
|
185
180
|
return circuitInputs;
|
|
186
181
|
};
|
|
187
182
|
exports.getPollJoiningCircuitInputsFromStateFile = getPollJoiningCircuitInputsFromStateFile;
|
|
188
183
|
/**
|
|
189
|
-
*
|
|
190
|
-
* @param
|
|
191
|
-
* @
|
|
192
|
-
* @param signer - The signer
|
|
193
|
-
* @returns The poll joining circuit events
|
|
184
|
+
* Generate MACI's state tree from the MACI contract
|
|
185
|
+
* @param {IGenerateMaciStateTreeArgs} args - The arguments for the generate maci state tree command
|
|
186
|
+
* @returns The MACI's state tree
|
|
194
187
|
*/
|
|
195
|
-
const
|
|
188
|
+
const generateMaciStateTree = async ({ maciContractAddress, signer, startBlock, endBlock, blocksPerBatch, }) => {
|
|
189
|
+
const maciContract = typechain_types_1.MACI__factory.connect(maciContractAddress, signer);
|
|
196
190
|
// build an off-chain representation of the MACI contract using data in the contract storage
|
|
197
|
-
const
|
|
198
|
-
maciContract
|
|
199
|
-
|
|
200
|
-
.then((events) => events[0]?.blockNumber ?? 0),
|
|
201
|
-
maciContract
|
|
202
|
-
.queryFilter(maciContract.filters.DeployPoll(), startBlock ?? 0)
|
|
203
|
-
.then((events) => events[0]?.blockNumber ?? 0),
|
|
204
|
-
maciContract.stateTreeDepth(),
|
|
205
|
-
]);
|
|
206
|
-
const defaultStartBlock = Math.min(defaultStartBlockPoll, defaultStartBlockSignup);
|
|
191
|
+
const defaultStartBlock = await maciContract
|
|
192
|
+
.queryFilter(maciContract.filters.SignUp(), startBlock ?? 0)
|
|
193
|
+
.then((events) => events[0]?.blockNumber ?? 0);
|
|
207
194
|
const fromBlock = startBlock ? Number(startBlock) : defaultStartBlock;
|
|
208
|
-
|
|
195
|
+
return (0, stateTree_1.generateSignUpTree)({
|
|
209
196
|
provider: signer.provider,
|
|
210
197
|
address: await maciContract.getAddress(),
|
|
211
198
|
blocksPerRequest: blocksPerBatch || 50,
|
|
@@ -213,12 +200,59 @@ const getPollJoiningCircuitEvents = async ({ maciContract, stateIndex, pollId, u
|
|
|
213
200
|
endBlock,
|
|
214
201
|
sleepAmount: 0,
|
|
215
202
|
});
|
|
216
|
-
|
|
217
|
-
|
|
203
|
+
};
|
|
204
|
+
exports.generateMaciStateTree = generateMaciStateTree;
|
|
205
|
+
/**
|
|
206
|
+
* Generate MACI's state tree from the MACI contract with a given end key
|
|
207
|
+
* @param {IGenerateMaciStateTreeWithEndKeyArgs} args - The arguments for the generate maci state tree command
|
|
208
|
+
* @returns The MACI's state tree
|
|
209
|
+
*/
|
|
210
|
+
const generateMaciStateTreeWithEndKey = async ({ maciContractAddress, signer, startBlock, endBlock, blocksPerBatch, userPublicKey, }) => {
|
|
211
|
+
const maciContract = typechain_types_1.MACI__factory.connect(maciContractAddress, signer);
|
|
212
|
+
// build an off-chain representation of the MACI contract using data in the contract storage
|
|
213
|
+
const defaultStartBlock = await maciContract
|
|
214
|
+
.queryFilter(maciContract.filters.SignUp(), startBlock ?? 0)
|
|
215
|
+
.then((events) => events[0]?.blockNumber ?? 0);
|
|
216
|
+
const fromBlock = startBlock ? Number(startBlock) : defaultStartBlock;
|
|
217
|
+
return (0, stateTree_1.generateSignUpTreeWithEndKey)({
|
|
218
|
+
provider: signer.provider,
|
|
219
|
+
address: await maciContract.getAddress(),
|
|
220
|
+
blocksPerRequest: blocksPerBatch || 50,
|
|
221
|
+
fromBlock,
|
|
222
|
+
endBlock,
|
|
223
|
+
userPublicKey,
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
exports.generateMaciStateTreeWithEndKey = generateMaciStateTreeWithEndKey;
|
|
227
|
+
/**
|
|
228
|
+
* Get the poll joining circuit events from a state file
|
|
229
|
+
* @param maciContract - The MACI contract
|
|
230
|
+
* @param startBlock - The start block
|
|
231
|
+
* @param signer - The signer
|
|
232
|
+
* @returns The poll joining circuit events
|
|
233
|
+
*/
|
|
234
|
+
const getPollJoiningCircuitEvents = async ({ maciContract, stateIndex, pollId, userMaciPrivateKey, signer, startBlock, endBlock, blocksPerBatch, }) => {
|
|
235
|
+
const [stateTreeDepth, maciContractAddress] = await Promise.all([
|
|
236
|
+
maciContract.stateTreeDepth(),
|
|
237
|
+
maciContract.getAddress(),
|
|
238
|
+
]);
|
|
239
|
+
const signUpData = await (0, exports.generateMaciStateTree)({
|
|
240
|
+
maciContractAddress,
|
|
241
|
+
signer,
|
|
242
|
+
startBlock,
|
|
243
|
+
endBlock,
|
|
244
|
+
blocksPerBatch,
|
|
245
|
+
});
|
|
246
|
+
const { publicKey: userPublicKey } = new domainobjs_1.Keypair(userMaciPrivateKey);
|
|
247
|
+
const loadedStateIndex = (0, exports.getStateIndex)(signUpData.publicKeys, userPublicKey, stateIndex);
|
|
218
248
|
if (loadedStateIndex < 1) {
|
|
219
249
|
throw new Error("Invalid state index");
|
|
220
250
|
}
|
|
221
|
-
|
|
251
|
+
// Get the state leaf on the index position
|
|
252
|
+
const { signUpTree: stateTree } = signUpData;
|
|
253
|
+
// calculate the path elements for the state tree given the original state tree
|
|
254
|
+
const inclusionProof = stateTree.generateProof(Number(loadedStateIndex));
|
|
255
|
+
return (0, exports.joiningCircuitInputs)(inclusionProof, stateTreeDepth, userMaciPrivateKey, userPublicKey, pollId);
|
|
222
256
|
};
|
|
223
257
|
exports.getPollJoiningCircuitEvents = getPollJoiningCircuitEvents;
|
|
224
258
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":";;;;;;AAAA,8EAAsH;AACtH,8CAAgE;AAChE,kDAAmE;AACnE,
|
|
1
|
+
{"version":3,"file":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AAa,EAAC,UAAU,CAAC,UAAU,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IAEzF,IAAI,gBAAiB,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED,2CAA2C;IAC3C,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC;IAE7C,+EAA+E;IAC/E,MAAM,cAAc,GAAG,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEzE,OAAO,IAAA,4BAAoB,EACzB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,MAAM,CACsB,CAAC;AACjC,CAAC,CAAC;AA3CW,QAAA,2BAA2B,+BA2CtC"}
|
|
@@ -3,5 +3,5 @@ import type { ICircuitParams } from "./types";
|
|
|
3
3
|
* Validate the circuit parameters
|
|
4
4
|
* @param params - The circuit parameters
|
|
5
5
|
*/
|
|
6
|
-
export declare const validateParams: ({ stateTreeDepth,
|
|
6
|
+
export declare const validateParams: ({ stateTreeDepth, tallyProcessingStateTreeDepth, voteOptionTreeDepth, messageBatchSize, }: ICircuitParams) => boolean;
|
|
7
7
|
//# sourceMappingURL=params.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../ts/utils/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../ts/utils/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,2FAK5B,cAAc,KAAG,OAWnB,CAAC"}
|
package/build/ts/utils/params.js
CHANGED
|
@@ -5,12 +5,12 @@ exports.validateParams = void 0;
|
|
|
5
5
|
* Validate the circuit parameters
|
|
6
6
|
* @param params - The circuit parameters
|
|
7
7
|
*/
|
|
8
|
-
const validateParams = ({ stateTreeDepth,
|
|
8
|
+
const validateParams = ({ stateTreeDepth, tallyProcessingStateTreeDepth, voteOptionTreeDepth, messageBatchSize, }) => {
|
|
9
9
|
// validate args
|
|
10
|
-
if (stateTreeDepth < 1 ||
|
|
10
|
+
if (stateTreeDepth < 1 || tallyProcessingStateTreeDepth < 1 || voteOptionTreeDepth < 1 || messageBatchSize < 1) {
|
|
11
11
|
throw new Error("Invalid depth or batch size parameters");
|
|
12
12
|
}
|
|
13
|
-
if (stateTreeDepth <
|
|
13
|
+
if (stateTreeDepth < tallyProcessingStateTreeDepth) {
|
|
14
14
|
throw new Error("Invalid state tree depth or intermediate state tree depth");
|
|
15
15
|
}
|
|
16
16
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../../ts/utils/params.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,MAAM,cAAc,GAAG,CAAC,EAC7B,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../../ts/utils/params.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,MAAM,cAAc,GAAG,CAAC,EAC7B,cAAc,EACd,6BAA6B,EAC7B,mBAAmB,EACnB,gBAAgB,GACD,EAAW,EAAE;IAC5B,gBAAgB;IAChB,IAAI,cAAc,GAAG,CAAC,IAAI,6BAA6B,GAAG,CAAC,IAAI,mBAAmB,GAAG,CAAC,IAAI,gBAAgB,GAAG,CAAC,EAAE,CAAC;QAC/G,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,cAAc,GAAG,6BAA6B,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAhBW,QAAA,cAAc,kBAgBzB"}
|