@maci-protocol/sdk 0.0.0-ci.fd7cff6 → 0.0.0-ci.ffabe48
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 +15 -6
- package/build/ts/browser/index.d.ts +6 -7
- package/build/ts/browser/index.d.ts.map +1 -1
- package/build/ts/browser/index.js +16 -20
- package/build/ts/browser/index.js.map +1 -1
- package/build/ts/browser/joinPoll.d.ts +10 -0
- package/build/ts/browser/joinPoll.d.ts.map +1 -0
- package/build/ts/browser/joinPoll.js +88 -0
- package/build/ts/browser/joinPoll.js.map +1 -0
- package/build/ts/browser/utils.d.ts +18 -0
- package/build/ts/browser/utils.d.ts.map +1 -0
- package/build/ts/browser/utils.js +37 -0
- package/build/ts/browser/utils.js.map +1 -0
- package/build/ts/deploy/index.d.ts +3 -2
- package/build/ts/deploy/index.d.ts.map +1 -1
- package/build/ts/deploy/index.js +5 -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 +20 -13
- package/build/ts/deploy/poll.js.map +1 -1
- package/build/ts/deploy/types.d.ts +21 -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 +26 -8
- 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 +41 -2
- package/build/ts/maci/policy.js.map +1 -1
- package/build/ts/maci/state.d.ts +1 -1
- package/build/ts/maci/state.js +11 -11
- 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/poll/utils.js +3 -3
- package/build/ts/poll/utils.js.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 +8 -8
- package/build/ts/proof/generate.js.map +1 -1
- package/build/ts/proof/prove.js +14 -14
- package/build/ts/proof/prove.js.map +1 -1
- package/build/ts/proof/types.d.ts +31 -5
- 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 +4 -4
- 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 +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 +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 +76 -12
- 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 +4 -2
- package/build/ts/user/index.d.ts.map +1 -1
- package/build/ts/user/index.js +14 -8
- package/build/ts/user/index.js.map +1 -1
- package/build/ts/user/joinPoll.d.ts +8 -0
- package/build/ts/user/joinPoll.d.ts.map +1 -0
- package/build/ts/user/joinPoll.js +84 -0
- package/build/ts/user/joinPoll.js.map +1 -0
- package/build/ts/user/signup.d.ts +20 -0
- package/build/ts/user/signup.d.ts.map +1 -0
- package/build/ts/user/signup.js +84 -0
- package/build/ts/user/signup.js.map +1 -0
- 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 +42 -14
- package/build/ts/user/utils.d.ts.map +1 -1
- package/build/ts/user/utils.js +116 -49
- 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/utils/utils.d.ts +8 -0
- package/build/ts/utils/utils.d.ts.map +1 -1
- package/build/ts/utils/utils.js +14 -1
- package/build/ts/utils/utils.js.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 +46 -35
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/types.d.ts +45 -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 +76 -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 +5 -5
- 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 +7 -7
- package/build/ts/vote/utils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +21 -12
- 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/user.d.ts +0 -42
- package/build/ts/user/user.d.ts.map +0 -1
- package/build/ts/user/user.js +0 -192
- package/build/ts/user/user.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
|
*/
|
|
@@ -300,6 +297,19 @@ export interface IJoinPollArgs {
|
|
|
300
297
|
*/
|
|
301
298
|
ivcpDataArg: string;
|
|
302
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* Interface for the arguments to the joinPoll command for the browser
|
|
302
|
+
*/
|
|
303
|
+
export interface IJoinPollBrowserArgs extends IJoinPollArgs {
|
|
304
|
+
/**
|
|
305
|
+
* Whether to use of not the latest state index
|
|
306
|
+
*/
|
|
307
|
+
useLatestStateIndex?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* The inclusion proof
|
|
310
|
+
*/
|
|
311
|
+
inclusionProof?: LeanIMTMerkleProof;
|
|
312
|
+
}
|
|
303
313
|
/**
|
|
304
314
|
* Interface for the return data to the joinPoll command
|
|
305
315
|
*/
|
|
@@ -312,10 +322,6 @@ export interface IJoinPollData {
|
|
|
312
322
|
* Voice credits balance
|
|
313
323
|
*/
|
|
314
324
|
voiceCredits: string;
|
|
315
|
-
/**
|
|
316
|
-
* Joining poll timestamp
|
|
317
|
-
*/
|
|
318
|
-
timestamp: string;
|
|
319
325
|
/**
|
|
320
326
|
* Private key nullifier
|
|
321
327
|
*/
|
|
@@ -346,6 +352,40 @@ export interface IIsNullifierOnChainArgs {
|
|
|
346
352
|
*/
|
|
347
353
|
signer: Signer;
|
|
348
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Arguments for IGenerateMaciStateTreeArgs
|
|
357
|
+
*/
|
|
358
|
+
export interface IGenerateMaciStateTreeArgs {
|
|
359
|
+
/**
|
|
360
|
+
* The MACI contract
|
|
361
|
+
*/
|
|
362
|
+
maciContract: MACI;
|
|
363
|
+
/**
|
|
364
|
+
* The signer
|
|
365
|
+
*/
|
|
366
|
+
signer: Signer;
|
|
367
|
+
/**
|
|
368
|
+
* The start block
|
|
369
|
+
*/
|
|
370
|
+
startBlock?: number;
|
|
371
|
+
/**
|
|
372
|
+
* The end block
|
|
373
|
+
*/
|
|
374
|
+
endBlock?: number;
|
|
375
|
+
/**
|
|
376
|
+
* The blocks per batch
|
|
377
|
+
*/
|
|
378
|
+
blocksPerBatch?: number;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Arguments for IGenerateMaciStateTreeWithEndKeyArgs
|
|
382
|
+
*/
|
|
383
|
+
export interface IGenerateMaciStateTreeWithEndKeyArgs extends IGenerateMaciStateTreeArgs {
|
|
384
|
+
/**
|
|
385
|
+
* The public key of the user
|
|
386
|
+
*/
|
|
387
|
+
userPublicKey: PublicKey;
|
|
388
|
+
}
|
|
349
389
|
/**
|
|
350
390
|
* Arguments for getPollJoiningCircuitEvents
|
|
351
391
|
*/
|
|
@@ -365,7 +405,7 @@ export interface IGetPollJoiningCircuitEventsArgs {
|
|
|
365
405
|
/**
|
|
366
406
|
* The user's maci private key
|
|
367
407
|
*/
|
|
368
|
-
|
|
408
|
+
userMaciPrivateKey: PrivateKey;
|
|
369
409
|
/**
|
|
370
410
|
* The signer
|
|
371
411
|
*/
|
|
@@ -402,7 +442,7 @@ export interface IGetPollJoiningCircuitInputsFromStateFileArgs {
|
|
|
402
442
|
/**
|
|
403
443
|
* The user's maci private key
|
|
404
444
|
*/
|
|
405
|
-
|
|
445
|
+
userMaciPrivateKey: PrivateKey;
|
|
406
446
|
}
|
|
407
447
|
/**
|
|
408
448
|
* Interface for the arguments for the is signed up command
|
|
@@ -415,7 +455,7 @@ export interface IHasUserSignedUpArgs {
|
|
|
415
455
|
/**
|
|
416
456
|
* The public key of the user
|
|
417
457
|
*/
|
|
418
|
-
|
|
458
|
+
maciPublicKey: string;
|
|
419
459
|
/**
|
|
420
460
|
* The signer to use for the transaction
|
|
421
461
|
*/
|
|
@@ -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,kBAAk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,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,
|
|
3
|
-
import { IGenerateSignUpTree } from "../trees";
|
|
4
|
-
import {
|
|
1
|
+
import { PrivateKey, PublicKey } from "@maci-protocol/domainobjs";
|
|
2
|
+
import type { IGetPollJoiningCircuitEventsArgs, IGetPollJoiningCircuitInputsFromStateFileArgs, IParsePollJoinEventsArgs, IParseSignupEventsArgs, IJoinedUserArgs, IIsNullifierOnChainArgs, IGenerateMaciStateTreeArgs, IGenerateMaciStateTreeWithEndKeyArgs } from "./types";
|
|
3
|
+
import type { IGenerateSignUpTree } from "../trees/types";
|
|
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
|
*/
|
|
@@ -9,6 +10,22 @@ export declare const parsePollJoinEvents: ({ pollContract, startBlock, currentBl
|
|
|
9
10
|
pollStateIndex?: string;
|
|
10
11
|
voiceCredits?: string;
|
|
11
12
|
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if user is joined to a poll with their public key and get its data
|
|
15
|
+
* @param {IJoinedUserArgs} - The arguments for the join check command
|
|
16
|
+
* @returns user joined or not and poll state index, voice credit balance
|
|
17
|
+
*/
|
|
18
|
+
export declare const getJoinedUserData: ({ maciAddress, pollId, pollPublicKey: serializedPollPublicKey, signer, startBlock, }: IJoinedUserArgs) => Promise<{
|
|
19
|
+
isJoined: boolean;
|
|
20
|
+
pollStateIndex?: string;
|
|
21
|
+
voiceCredits?: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if a user joined a poll with a given nullifier
|
|
25
|
+
* @param {IIsNullifierOnChainArgs} args - The arguments for the is nullifier on chain command
|
|
26
|
+
* @returns whether the nullifier is on chain or not
|
|
27
|
+
*/
|
|
28
|
+
export declare const hasUserJoinedPoll: ({ maciAddress, pollId, nullifier, signer, }: IIsNullifierOnChainArgs) => Promise<boolean>;
|
|
12
29
|
/**
|
|
13
30
|
* Parse the signup events from the MACI contract
|
|
14
31
|
*/
|
|
@@ -17,30 +34,41 @@ export declare const parseSignupEvents: ({ maciContract, startBlock, currentBloc
|
|
|
17
34
|
}>;
|
|
18
35
|
/**
|
|
19
36
|
* Get state index from maci state leaves or from sign up leaves
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
37
|
+
* @param publicKeys Public keys from maci state or sign up tree
|
|
38
|
+
* @param userMaciPublicKey Public key of the maci user
|
|
22
39
|
* @param stateIndex State index from the command
|
|
23
40
|
* @returns State index
|
|
24
41
|
*/
|
|
25
|
-
export declare const getStateIndex: (
|
|
42
|
+
export declare const getStateIndex: (publicKeys: PublicKey[], userMaciPublicKey: PublicKey, stateIndex?: bigint) => bigint | undefined;
|
|
26
43
|
/**
|
|
27
44
|
* Create circuit input for pollJoining
|
|
28
45
|
* @param signUpData Sign up tree and state leaves
|
|
29
46
|
* @param stateTreeDepth Maci state tree depth
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @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
|
|
34
50
|
* @param pollId Poll's id
|
|
35
51
|
* @returns stringified circuit inputs
|
|
36
52
|
*/
|
|
37
|
-
export declare const joiningCircuitInputs: (
|
|
53
|
+
export declare const joiningCircuitInputs: (inclusionProof: LeanIMTMerkleProof, stateTreeDepth: bigint, maciPrivateKey: PrivateKey, pollPublicKey: PublicKey, pollId: bigint) => TCircuitInputs;
|
|
38
54
|
/**
|
|
39
55
|
* Get the poll joining circuit inputs from a state file
|
|
40
56
|
* @param stateFile - The path to the state file
|
|
41
57
|
* @returns The poll joining circuit inputs
|
|
42
58
|
*/
|
|
43
|
-
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: ({ maciContract, 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: ({ maciContract, signer, startBlock, endBlock, blocksPerBatch, userPublicKey, }: IGenerateMaciStateTreeWithEndKeyArgs) => Promise<IGenerateSignUpTree>;
|
|
44
72
|
/**
|
|
45
73
|
* Get the poll joining circuit events from a state file
|
|
46
74
|
* @param maciContract - The MACI contract
|
|
@@ -48,5 +76,5 @@ export declare const getPollJoiningCircuitInputsFromStateFile: ({ stateFile, pol
|
|
|
48
76
|
* @param signer - The signer
|
|
49
77
|
* @returns The poll joining circuit events
|
|
50
78
|
*/
|
|
51
|
-
export declare const getPollJoiningCircuitEvents: ({ maciContract, stateIndex, pollId,
|
|
79
|
+
export declare const getPollJoiningCircuitEvents: ({ maciContract, stateIndex, pollId, userMaciPrivateKey, signer, startBlock, endBlock, blocksPerBatch, }: IGetPollJoiningCircuitEventsArgs) => Promise<TCircuitInputs>;
|
|
52
80
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":"
|
|
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,iEAMzC,0BAA0B,KAAG,OAAO,CAAC,mBAAmB,CAgB1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,GAAU,gFAOnD,oCAAoC,KAAG,OAAO,CAAC,mBAAmB,CAgBpE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GAAU,yGAS/C,gCAAgC,KAAG,OAAO,CAAC,cAAc,CA+B3D,CAAC"}
|
package/build/ts/user/utils.js
CHANGED
|
@@ -3,12 +3,13 @@ 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.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
|
+
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
7
8
|
const core_1 = require("@maci-protocol/core");
|
|
8
9
|
const crypto_1 = require("@maci-protocol/crypto");
|
|
9
10
|
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
10
11
|
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const
|
|
12
|
+
const stateTree_1 = require("../trees/stateTree");
|
|
12
13
|
const constants_1 = require("../utils/constants");
|
|
13
14
|
/**
|
|
14
15
|
* Parse the poll joining events from the Poll contract
|
|
@@ -16,13 +17,13 @@ const constants_1 = require("../utils/constants");
|
|
|
16
17
|
const parsePollJoinEvents = async ({ pollContract, startBlock, currentBlock, pollPublicKey, }) => {
|
|
17
18
|
for (let block = startBlock; block <= currentBlock; block += constants_1.BLOCKS_STEP) {
|
|
18
19
|
const toBlock = Math.min(block + constants_1.BLOCKS_STEP - 1, currentBlock);
|
|
19
|
-
const
|
|
20
|
+
const publicKey = pollPublicKey.asArray();
|
|
20
21
|
// eslint-disable-next-line no-await-in-loop
|
|
21
|
-
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);
|
|
22
23
|
if (newEvents.length > 0) {
|
|
23
24
|
const [event] = newEvents;
|
|
24
25
|
return {
|
|
25
|
-
pollStateIndex: event.args[
|
|
26
|
+
pollStateIndex: event.args[4].toString(),
|
|
26
27
|
voiceCredits: event.args[2].toString(),
|
|
27
28
|
};
|
|
28
29
|
}
|
|
@@ -33,6 +34,43 @@ const parsePollJoinEvents = async ({ pollContract, startBlock, currentBlock, pol
|
|
|
33
34
|
};
|
|
34
35
|
};
|
|
35
36
|
exports.parsePollJoinEvents = parsePollJoinEvents;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if user is joined to a poll with their public key and get its data
|
|
39
|
+
* @param {IJoinedUserArgs} - The arguments for the join check command
|
|
40
|
+
* @returns user joined or not and poll state index, voice credit balance
|
|
41
|
+
*/
|
|
42
|
+
const getJoinedUserData = async ({ maciAddress, pollId, pollPublicKey: serializedPollPublicKey, signer, startBlock, }) => {
|
|
43
|
+
const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
|
|
44
|
+
const pollContracts = await maciContract.getPoll(pollId);
|
|
45
|
+
const pollContract = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer);
|
|
46
|
+
const pollPublicKey = domainobjs_1.PublicKey.deserialize(serializedPollPublicKey);
|
|
47
|
+
const startBlockNumber = startBlock || 0;
|
|
48
|
+
const currentBlock = await signer.provider.getBlockNumber();
|
|
49
|
+
const { pollStateIndex, voiceCredits } = await (0, exports.parsePollJoinEvents)({
|
|
50
|
+
pollContract,
|
|
51
|
+
startBlock: startBlockNumber,
|
|
52
|
+
currentBlock,
|
|
53
|
+
pollPublicKey,
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
isJoined: pollStateIndex !== undefined,
|
|
57
|
+
pollStateIndex,
|
|
58
|
+
voiceCredits,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
exports.getJoinedUserData = getJoinedUserData;
|
|
62
|
+
/**
|
|
63
|
+
* Checks if a user joined a poll with a given nullifier
|
|
64
|
+
* @param {IIsNullifierOnChainArgs} args - The arguments for the is nullifier on chain command
|
|
65
|
+
* @returns whether the nullifier is on chain or not
|
|
66
|
+
*/
|
|
67
|
+
const hasUserJoinedPoll = async ({ maciAddress, pollId, nullifier, signer, }) => {
|
|
68
|
+
const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
|
|
69
|
+
const pollContracts = await maciContract.getPoll(pollId);
|
|
70
|
+
const pollContract = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer);
|
|
71
|
+
return pollContract.pollNullifiers(nullifier);
|
|
72
|
+
};
|
|
73
|
+
exports.hasUserJoinedPoll = hasUserJoinedPoll;
|
|
36
74
|
/**
|
|
37
75
|
* Parse the signup events from the MACI contract
|
|
38
76
|
*/
|
|
@@ -40,7 +78,7 @@ const parseSignupEvents = async ({ maciContract, startBlock, currentBlock, publi
|
|
|
40
78
|
for (let block = startBlock; block <= currentBlock; block += constants_1.BLOCKS_STEP) {
|
|
41
79
|
const toBlock = Math.min(block + constants_1.BLOCKS_STEP - 1, currentBlock);
|
|
42
80
|
// eslint-disable-next-line no-await-in-loop
|
|
43
|
-
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);
|
|
44
82
|
if (newEvents.length > 0) {
|
|
45
83
|
const [event] = newEvents;
|
|
46
84
|
return {
|
|
@@ -55,14 +93,14 @@ const parseSignupEvents = async ({ maciContract, startBlock, currentBlock, publi
|
|
|
55
93
|
exports.parseSignupEvents = parseSignupEvents;
|
|
56
94
|
/**
|
|
57
95
|
* Get state index from maci state leaves or from sign up leaves
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
96
|
+
* @param publicKeys Public keys from maci state or sign up tree
|
|
97
|
+
* @param userMaciPublicKey Public key of the maci user
|
|
60
98
|
* @param stateIndex State index from the command
|
|
61
99
|
* @returns State index
|
|
62
100
|
*/
|
|
63
|
-
const getStateIndex = (
|
|
101
|
+
const getStateIndex = (publicKeys, userMaciPublicKey, stateIndex) => {
|
|
64
102
|
if (!stateIndex) {
|
|
65
|
-
const index =
|
|
103
|
+
const index = publicKeys.findIndex((key) => key.equals(userMaciPublicKey));
|
|
66
104
|
if (index > 0) {
|
|
67
105
|
return BigInt(index);
|
|
68
106
|
}
|
|
@@ -75,18 +113,15 @@ exports.getStateIndex = getStateIndex;
|
|
|
75
113
|
* Create circuit input for pollJoining
|
|
76
114
|
* @param signUpData Sign up tree and state leaves
|
|
77
115
|
* @param stateTreeDepth Maci state tree depth
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
80
|
-
* @param
|
|
81
|
-
* @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
|
|
82
119
|
* @param pollId Poll's id
|
|
83
120
|
* @returns stringified circuit inputs
|
|
84
121
|
*/
|
|
85
|
-
const joiningCircuitInputs = (
|
|
86
|
-
// Get the state leaf on the index position
|
|
87
|
-
const { signUpTree: stateTree } = signUpData;
|
|
122
|
+
const joiningCircuitInputs = (inclusionProof, stateTreeDepth, maciPrivateKey, pollPublicKey, pollId) => {
|
|
88
123
|
// calculate the path elements for the state tree given the original state tree
|
|
89
|
-
const { siblings, index } =
|
|
124
|
+
const { siblings, index, root: stateRoot } = inclusionProof;
|
|
90
125
|
const siblingsLength = siblings.length;
|
|
91
126
|
// The index must be converted to a list of indices, 1 for each tree level.
|
|
92
127
|
// The circuit tree depth is this.stateTreeDepth, so the number of siblings must be this.stateTreeDepth,
|
|
@@ -102,16 +137,14 @@ const joiningCircuitInputs = (signUpData, stateTreeDepth, maciPrivKey, stateLeaf
|
|
|
102
137
|
}
|
|
103
138
|
const siblingsArray = siblings.map((sibling) => [sibling]);
|
|
104
139
|
// Create nullifier from private key
|
|
105
|
-
const inputNullifier = BigInt(
|
|
140
|
+
const inputNullifier = BigInt(maciPrivateKey.asCircuitInputs());
|
|
106
141
|
const nullifier = (0, crypto_1.poseidon)([inputNullifier, pollId]);
|
|
107
|
-
// Get pll state tree's root
|
|
108
|
-
const stateRoot = stateTree.root;
|
|
109
142
|
// Set actualStateTreeDepth as number of initial siblings length
|
|
110
143
|
const actualStateTreeDepth = BigInt(siblingsLength);
|
|
111
144
|
// Calculate public input hash from nullifier, credits and current root
|
|
112
145
|
const circuitInputs = {
|
|
113
|
-
|
|
114
|
-
|
|
146
|
+
privateKey: maciPrivateKey.asCircuitInputs(),
|
|
147
|
+
pollPublicKey: pollPublicKey.asCircuitInputs(),
|
|
115
148
|
siblings: siblingsArray,
|
|
116
149
|
indices,
|
|
117
150
|
nullifier,
|
|
@@ -127,47 +160,38 @@ exports.joiningCircuitInputs = joiningCircuitInputs;
|
|
|
127
160
|
* @param stateFile - The path to the state file
|
|
128
161
|
* @returns The poll joining circuit inputs
|
|
129
162
|
*/
|
|
130
|
-
const getPollJoiningCircuitInputsFromStateFile = async ({ stateFile, pollId, stateIndex,
|
|
163
|
+
const getPollJoiningCircuitInputsFromStateFile = async ({ stateFile, pollId, stateIndex, userMaciPrivateKey, }) => {
|
|
131
164
|
const file = await fs_1.default.promises.readFile(stateFile);
|
|
132
165
|
const content = JSON.parse(file.toString());
|
|
133
166
|
const maciState = core_1.MaciState.fromJSON(content);
|
|
134
167
|
const poll = maciState.polls.get(pollId);
|
|
135
|
-
const {
|
|
136
|
-
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);
|
|
137
170
|
// check < 1 cause index zero is a blank state leaf
|
|
138
171
|
if (loadedStateIndex < 1) {
|
|
139
172
|
throw new Error("Invalid state index");
|
|
140
173
|
}
|
|
141
|
-
poll.updatePoll(BigInt(maciState.
|
|
174
|
+
poll.updatePoll(BigInt(maciState.publicKeys.length));
|
|
142
175
|
const circuitInputs = poll.joiningCircuitInputs({
|
|
143
|
-
|
|
176
|
+
maciPrivateKey: userMaciPrivateKey,
|
|
144
177
|
stateLeafIndex: stateIndex,
|
|
145
|
-
|
|
178
|
+
pollPublicKey: userPublicKey,
|
|
146
179
|
});
|
|
147
180
|
return circuitInputs;
|
|
148
181
|
};
|
|
149
182
|
exports.getPollJoiningCircuitInputsFromStateFile = getPollJoiningCircuitInputsFromStateFile;
|
|
150
183
|
/**
|
|
151
|
-
*
|
|
152
|
-
* @param
|
|
153
|
-
* @
|
|
154
|
-
* @param signer - The signer
|
|
155
|
-
* @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
|
|
156
187
|
*/
|
|
157
|
-
const
|
|
188
|
+
const generateMaciStateTree = async ({ maciContract, signer, startBlock, endBlock, blocksPerBatch, }) => {
|
|
158
189
|
// build an off-chain representation of the MACI contract using data in the contract storage
|
|
159
|
-
const
|
|
160
|
-
maciContract
|
|
161
|
-
|
|
162
|
-
.then((events) => events[0]?.blockNumber ?? 0),
|
|
163
|
-
maciContract
|
|
164
|
-
.queryFilter(maciContract.filters.DeployPoll(), startBlock ?? 0)
|
|
165
|
-
.then((events) => events[0]?.blockNumber ?? 0),
|
|
166
|
-
maciContract.stateTreeDepth(),
|
|
167
|
-
]);
|
|
168
|
-
const defaultStartBlock = Math.min(defaultStartBlockPoll, defaultStartBlockSignup);
|
|
190
|
+
const defaultStartBlock = await maciContract
|
|
191
|
+
.queryFilter(maciContract.filters.SignUp(), startBlock ?? 0)
|
|
192
|
+
.then((events) => events[0]?.blockNumber ?? 0);
|
|
169
193
|
const fromBlock = startBlock ? Number(startBlock) : defaultStartBlock;
|
|
170
|
-
|
|
194
|
+
return (0, stateTree_1.generateSignUpTree)({
|
|
171
195
|
provider: signer.provider,
|
|
172
196
|
address: await maciContract.getAddress(),
|
|
173
197
|
blocksPerRequest: blocksPerBatch || 50,
|
|
@@ -175,12 +199,55 @@ const getPollJoiningCircuitEvents = async ({ maciContract, stateIndex, pollId, u
|
|
|
175
199
|
endBlock,
|
|
176
200
|
sleepAmount: 0,
|
|
177
201
|
});
|
|
178
|
-
|
|
179
|
-
|
|
202
|
+
};
|
|
203
|
+
exports.generateMaciStateTree = generateMaciStateTree;
|
|
204
|
+
/**
|
|
205
|
+
* Generate MACI's state tree from the MACI contract with a given end key
|
|
206
|
+
* @param {IGenerateMaciStateTreeWithEndKeyArgs} args - The arguments for the generate maci state tree command
|
|
207
|
+
* @returns The MACI's state tree
|
|
208
|
+
*/
|
|
209
|
+
const generateMaciStateTreeWithEndKey = async ({ maciContract, signer, startBlock, endBlock, blocksPerBatch, userPublicKey, }) => {
|
|
210
|
+
// build an off-chain representation of the MACI contract using data in the contract storage
|
|
211
|
+
const defaultStartBlock = await maciContract
|
|
212
|
+
.queryFilter(maciContract.filters.SignUp(), startBlock ?? 0)
|
|
213
|
+
.then((events) => events[0]?.blockNumber ?? 0);
|
|
214
|
+
const fromBlock = startBlock ? Number(startBlock) : defaultStartBlock;
|
|
215
|
+
return (0, stateTree_1.generateSignUpTreeWithEndKey)({
|
|
216
|
+
provider: signer.provider,
|
|
217
|
+
address: await maciContract.getAddress(),
|
|
218
|
+
blocksPerRequest: blocksPerBatch || 50,
|
|
219
|
+
fromBlock,
|
|
220
|
+
endBlock,
|
|
221
|
+
userPublicKey,
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
exports.generateMaciStateTreeWithEndKey = generateMaciStateTreeWithEndKey;
|
|
225
|
+
/**
|
|
226
|
+
* Get the poll joining circuit events from a state file
|
|
227
|
+
* @param maciContract - The MACI contract
|
|
228
|
+
* @param startBlock - The start block
|
|
229
|
+
* @param signer - The signer
|
|
230
|
+
* @returns The poll joining circuit events
|
|
231
|
+
*/
|
|
232
|
+
const getPollJoiningCircuitEvents = async ({ maciContract, stateIndex, pollId, userMaciPrivateKey, signer, startBlock, endBlock, blocksPerBatch, }) => {
|
|
233
|
+
const stateTreeDepth = await maciContract.stateTreeDepth();
|
|
234
|
+
const signUpData = await (0, exports.generateMaciStateTree)({
|
|
235
|
+
maciContract,
|
|
236
|
+
signer,
|
|
237
|
+
startBlock,
|
|
238
|
+
endBlock,
|
|
239
|
+
blocksPerBatch,
|
|
240
|
+
});
|
|
241
|
+
const { publicKey: userPublicKey } = new domainobjs_1.Keypair(userMaciPrivateKey);
|
|
242
|
+
const loadedStateIndex = (0, exports.getStateIndex)(signUpData.publicKeys, userPublicKey, stateIndex);
|
|
180
243
|
if (loadedStateIndex < 1) {
|
|
181
244
|
throw new Error("Invalid state index");
|
|
182
245
|
}
|
|
183
|
-
|
|
246
|
+
// Get the state leaf on the index position
|
|
247
|
+
const { signUpTree: stateTree } = signUpData;
|
|
248
|
+
// calculate the path elements for the state tree given the original state tree
|
|
249
|
+
const inclusionProof = stateTree.generateProof(Number(loadedStateIndex));
|
|
250
|
+
return (0, exports.joiningCircuitInputs)(inclusionProof, stateTreeDepth, userMaciPrivateKey, userPublicKey, pollId);
|
|
184
251
|
};
|
|
185
252
|
exports.getPollJoiningCircuitEvents = getPollJoiningCircuitEvents;
|
|
186
253
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAgE;AAChE,kDAAmE;AACnE,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":";;;;;;AAAA,8EAAsH;AACtH,8CAAgE;AAChE,kDAAmE;AACnE,0DAA2E;AAE3E,4CAAoB;AAgBpB,kDAAsF;AACtF,kDAAiD;AAEjD;;GAEG;AACI,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,aAAa,GACY,EAGxB,EAAE;IACH,KAAK,IAAI,KAAK,GAAG,UAAU,EAAE,KAAK,IAAI,YAAY,EAAE,KAAK,IAAI,uBAAW,EA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AI,EAAE;QACtC,SAAS;QACT,QAAQ;QACR,aAAa;KACd,CAAC,CAAC;AACL,CAAC,CAAC;AAvBW,QAAA,+BAA+B,mCAuB1C;AAEF;;;;;;GAMG;AACI,MAAM,2BAA2B,GAAG,KAAK,EAAE,EAChD,YAAY,EACZ,UAAU,EACV,MAAM,EACN,kBAAkB,EAClB,MAAM,EACN,UAAU,EACV,QAAQ,EACR,cAAc,GACmB,EAA2B,EAAE;IAC9D,MAAM,cAAc,GAAG,MAAM,YAAY,CAAC,cAAc,EAAE,CAAC;IAE3D,MAAM,UAAU,GAAG,MAAM,IAAA,6BAAqB,EAAC;QAC7C,YAAY;QACZ,MAAM;QACN,UAAU;QACV,QAAQ;QACR,cAAc;KACf,CAAC,CAAC;IAEH,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI,oBAAO,CAAC,kBAAkB,CAAC,CAAC;IACrE,MAAM,gBAAgB,GAAG,IAAA,qBAAa,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;AAxCW,QAAA,2BAA2B,+BAwCtC"}
|
|
@@ -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;
|