@maci-protocol/cli 0.0.0-ci.66d67a4 → 0.0.0-ci.66f9b31

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/build/ts/index.js CHANGED
@@ -45,6 +45,7 @@ const fs_1 = __importDefault(require("fs"));
45
45
  const path_1 = __importDefault(require("path"));
46
46
  require("./cliInit");
47
47
  const utils_1 = require("./utils");
48
+ const constants_1 = require("./utils/constants");
48
49
  const defaults_1 = require("./utils/defaults");
49
50
  // set the description version and name of the cli tool
50
51
  const { description, version, name } = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(__dirname, "..", "package.json"), "utf8"));
@@ -66,25 +67,25 @@ program
66
67
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
67
68
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
68
69
  .requiredOption("-s, --stateTreeDepth <stateTreeDepth>", "the state tree depth", parseInt)
69
- .action(async (cmdOptions) => {
70
+ .action(async (args) => {
70
71
  try {
71
72
  const signer = await getSigner();
72
- (0, utils_1.banner)(cmdOptions.quiet);
73
+ (0, utils_1.banner)(args.quiet);
73
74
  const network = await signer.provider?.getNetwork();
74
75
  const [poseidonT3, poseidonT4, poseidonT5, poseidonT6] = (0, utils_1.readContractAddresses)({
75
76
  contractNames: [sdk_1.EContracts.PoseidonT3, sdk_1.EContracts.PoseidonT4, sdk_1.EContracts.PoseidonT5, sdk_1.EContracts.PoseidonT6],
76
77
  network: network?.name,
77
78
  });
78
79
  let [signupPolicyContractAddress] = (0, utils_1.readContractAddresses)({
79
- contractNames: [cmdOptions.signupPolicyContractName.toString()],
80
+ contractNames: [args.signupPolicyContractName.toString()],
80
81
  network: network?.name,
81
82
  });
82
83
  if (!signupPolicyContractAddress) {
83
- const checkerFactory = cmdOptions.freeForAllCheckerFactoryAddress
84
- ? sdk_1.FreeForAllCheckerFactory__factory.connect(cmdOptions.freeForAllCheckerFactoryAddress, signer)
84
+ const checkerFactory = args.freeForAllCheckerFactoryAddress
85
+ ? sdk_1.FreeForAllCheckerFactory__factory.connect(args.freeForAllCheckerFactoryAddress, signer)
85
86
  : undefined;
86
- const policyFactory = cmdOptions.freeForAllPolicyFactoryAddress
87
- ? sdk_1.FreeForAllPolicyFactory__factory.connect(cmdOptions.freeForAllPolicyFactoryAddress, signer)
87
+ const policyFactory = args.freeForAllPolicyFactoryAddress
88
+ ? sdk_1.FreeForAllPolicyFactory__factory.connect(args.freeForAllPolicyFactoryAddress, signer)
88
89
  : undefined;
89
90
  const [contract] = await (0, sdk_1.deployFreeForAllSignUpPolicy)({ checker: checkerFactory, policy: policyFactory }, signer, true);
90
91
  signupPolicyContractAddress = await contract.getAddress();
@@ -102,13 +103,13 @@ program
102
103
  poseidonT6,
103
104
  },
104
105
  signer,
105
- stateTreeDepth: cmdOptions.stateTreeDepth,
106
+ stateTreeDepth: args.stateTreeDepth,
106
107
  });
107
- const emptyBallotRoots = (0, sdk_1.genEmptyBallotRoots)(cmdOptions.stateTreeDepth);
108
+ const emptyBallotRoots = (0, sdk_1.generateEmptyBallotRoots)(args.stateTreeDepth);
108
109
  // save to the JSON File
109
110
  await (0, utils_1.storeContractAddresses)({
110
111
  data: {
111
- [cmdOptions.signupPolicyContractName]: { address: signupPolicyContractAddress, args: [] },
112
+ [args.signupPolicyContractName]: { address: signupPolicyContractAddress, args: [] },
112
113
  [sdk_1.EContracts.Verifier]: { address: verifierContractAddress, args: [] },
113
114
  [sdk_1.EContracts.MACI]: {
114
115
  address: maciContractAddress,
@@ -117,7 +118,7 @@ program
117
118
  messageProcessorFactoryContractAddress,
118
119
  tallyFactoryContractAddress,
119
120
  signupPolicyContractAddress,
120
- cmdOptions.stateTreeDepth,
121
+ args.stateTreeDepth,
121
122
  emptyBallotRoots.map((root) => root.toString()),
122
123
  ],
123
124
  },
@@ -131,7 +132,7 @@ program
131
132
  },
132
133
  signer,
133
134
  });
134
- (0, sdk_1.logGreen)({ quiet: cmdOptions.quiet, text: (0, sdk_1.success)(`MACI deployed at: ${maciContractAddress}`) });
135
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`MACI deployed at: ${maciContractAddress}`) });
135
136
  }
136
137
  catch (error) {
137
138
  program.error(error.message, { exitCode: 1 });
@@ -140,75 +141,81 @@ program
140
141
  program
141
142
  .command("checkVerifyingKeys")
142
143
  .description("check that the verifying keys in the contract match the local ones")
143
- .option("-u, --use-quadratic-voting <useQuadraticVoting>", "whether to use quadratic voting", (value) => value === "true", true)
144
+ .option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
144
145
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
145
146
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
146
- .option("-k, --vk-contract <vkContract>", "the VkRegistry contract address")
147
+ .option("-k, --vk-contract <vkContract>", "the VerifyingKeysRegistry contract address")
147
148
  .requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
148
- .requiredOption("-i, --int-state-tree-depth <intStateTreeDepth>", "the intermediate state tree depth", parseInt)
149
+ .requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the intermediate state tree depth", parseInt)
149
150
  .requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
150
151
  .requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
151
- .requiredOption("-p, --process-messages-zkey <processMessagesZkeyPath>", "the process messages zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
152
- .requiredOption("-t, --tally-votes-zkey <tallyVotesZkeyPath>", "the tally votes zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
152
+ .requiredOption("-p, --message-processor-zkey <messageProcessorZkeyPath>", "the message processor zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
153
+ .requiredOption("-t, --vote-tally-zkey <voteTallyZkeyPath>", "the vote tally zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
153
154
  .requiredOption("--poll-joining-zkey <pollJoiningZkey>", "the poll joining zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
154
155
  .requiredOption("--poll-joined-zkey <pollJoinedZkey>", "the poll joined zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
155
- .action(async (cmdOptions) => {
156
+ .action(async (args) => {
156
157
  try {
157
158
  const signer = await getSigner();
158
159
  const network = await signer.provider?.getNetwork();
159
- const [vkContractAddress] = (0, utils_1.readContractAddresses)({
160
- contractNames: [sdk_1.EContracts.VkRegistry],
160
+ const [contractAddress] = (0, utils_1.readContractAddresses)({
161
+ contractNames: [sdk_1.EContracts.VerifyingKeysRegistry],
161
162
  network: network?.name,
162
- defaultAddresses: [cmdOptions.vkContract],
163
+ defaultAddresses: [args.vkContract],
163
164
  });
164
- (0, sdk_1.logYellow)({ quiet: cmdOptions.quiet, text: (0, sdk_1.info)("Retrieving verifying keys from the contract...") });
165
+ (0, sdk_1.logYellow)({ quiet: args.quiet, text: (0, sdk_1.info)("Retrieving verifying keys from the contract...") });
165
166
  await (0, sdk_1.checkVerifyingKeys)({
166
- stateTreeDepth: cmdOptions.stateTreeDepth,
167
- intStateTreeDepth: cmdOptions.intStateTreeDepth,
168
- voteOptionTreeDepth: cmdOptions.voteOptionTreeDepth,
169
- messageBatchSize: cmdOptions.messageBatchSize,
170
- processMessagesZkeyPath: cmdOptions.processMessagesZkey,
171
- tallyVotesZkeyPath: cmdOptions.tallyVotesZkey,
172
- pollJoiningZkeyPath: cmdOptions.pollJoiningZkey,
173
- pollJoinedZkeyPath: cmdOptions.pollJoinedZkey,
174
- vkRegistry: vkContractAddress,
175
- useQuadraticVoting: cmdOptions.useQuadraticVoting,
167
+ stateTreeDepth: args.stateTreeDepth,
168
+ tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
169
+ voteOptionTreeDepth: args.voteOptionTreeDepth,
170
+ messageBatchSize: args.messageBatchSize,
171
+ messageProcessorZkeyPath: args.messageProcessorZkey,
172
+ voteTallyZkeyPath: args.voteTallyZkey,
173
+ pollJoiningZkeyPath: args.pollJoiningZkey,
174
+ pollJoinedZkeyPath: args.pollJoinedZkey,
175
+ verifyingKeysRegistry: contractAddress,
176
+ mode: args.mode,
176
177
  signer,
177
178
  });
178
- (0, sdk_1.logGreen)({ quiet: cmdOptions.quiet, text: (0, sdk_1.success)("Verifying keys match") });
179
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)("Verifying keys match") });
179
180
  }
180
181
  catch (error) {
181
182
  program.error(error.message, { exitCode: 1 });
182
183
  }
183
184
  });
184
185
  program
185
- .command("genMaciPubKey")
186
+ .command("generateMaciPubKey")
186
187
  .description("generate a new MACI public key")
187
188
  .requiredOption("-k, --private-key <privateKey>", "the private key")
188
189
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
189
190
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
190
- .action((cmdObj) => {
191
- const publicKey = (0, sdk_1.generateMaciPublicKey)(cmdObj.privateKey);
192
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.success)(`Public key: ${publicKey}`) });
191
+ .action((args) => {
192
+ const publicKey = (0, sdk_1.generateMaciPublicKey)(args.privateKey);
193
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Public key: ${publicKey}`) });
193
194
  });
194
195
  program
195
- .command("genMaciKeyPair")
196
+ .command("generateMaciKeyPair")
196
197
  .description("generate a new MACI key pair")
197
198
  .option("-s, --seed <seed>", "seed value for keypair", (value) => (value ? BigInt(value) : undefined), undefined)
198
199
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
199
- .action((cmdObj) => {
200
- const { publicKey, privateKey } = (0, sdk_1.generateKeypair)({ seed: cmdObj.seed });
201
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.success)(`Public key: ${publicKey}`) });
202
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.success)(`Private key: ${privateKey}`) });
200
+ .action((args) => {
201
+ const { publicKey, privateKey, publicKeyAsContractParam } = (0, sdk_1.generateKeypair)({ seed: args.seed });
202
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Public key: ${publicKey}`) });
203
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Private key: ${privateKey}`) });
204
+ (0, sdk_1.logGreen)({
205
+ quiet: args.quiet,
206
+ text: (0, sdk_1.success)(`Public key as contract param:
207
+ X: ${publicKeyAsContractParam.x}
208
+ Y: ${publicKeyAsContractParam.y}`),
209
+ });
203
210
  });
204
211
  program
205
- .command("deployVkRegistry")
212
+ .command("deployVerifyingKeysRegistry")
206
213
  .description("deploy a new verification key registry contract")
207
214
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
208
215
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
209
- .action(async (cmdObj) => {
216
+ .action(async (args) => {
210
217
  try {
211
- (0, utils_1.banner)(cmdObj.quiet);
218
+ (0, utils_1.banner)(args.quiet);
212
219
  const signer = await getSigner();
213
220
  // assume that the vkRegistry contract is the first one to be deployed
214
221
  const isContractAddressesStoreExists = fs_1.default.existsSync(utils_1.contractAddressesStorePath);
@@ -217,12 +224,15 @@ program
217
224
  (0, utils_1.resetContractAddresses)(network?.name);
218
225
  }
219
226
  // deploy and store the address
220
- const vkRegistryAddress = await (0, sdk_1.deployVkRegistryContract)({ signer });
227
+ const verifyingKeysRegistryAddress = await (0, sdk_1.deployVerifyingKeysRegistryContract)({ signer });
221
228
  await (0, utils_1.storeContractAddresses)({
222
- data: { [sdk_1.EContracts.VkRegistry]: { address: vkRegistryAddress, args: [] } },
229
+ data: { [sdk_1.EContracts.VerifyingKeysRegistry]: { address: verifyingKeysRegistryAddress, args: [] } },
223
230
  signer,
224
231
  });
225
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.success)(`VkRegistry deployed at: ${vkRegistryAddress}`) });
232
+ (0, sdk_1.logGreen)({
233
+ quiet: args.quiet,
234
+ text: (0, sdk_1.success)(`VerifyingKeysRegistry deployed at: ${verifyingKeysRegistryAddress}`),
235
+ });
226
236
  }
227
237
  catch (error) {
228
238
  program.error(error.message, { exitCode: 1 });
@@ -249,37 +259,37 @@ program
249
259
  program
250
260
  .command("deployPoll")
251
261
  .description("deploy a new poll")
252
- .option("-k, --vkRegistryAddress <vkRegistryAddress>", "the vk registry contract address")
253
- .requiredOption("-s, --start <pollStartDate>", "the poll start date", parseInt)
254
- .requiredOption("-e, --end <pollEndDate>", "the poll end date", parseInt)
255
- .requiredOption("-i, --int-state-tree-depth <intStateTreeDepth>", "the int state tree depth", parseInt)
262
+ .option("-k, --verifyingKeysRegistryAddress <verifyingKeysRegistryAddress>", "the vk registry contract address")
263
+ .requiredOption("--start <pollStartDate>", "the poll start date", parseInt)
264
+ .requiredOption("--end <pollEndDate>", "the poll end date", parseInt)
265
+ .requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the int state tree depth", parseInt)
256
266
  .requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
257
267
  .requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
258
268
  .requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
259
269
  .requiredOption("-p, --public-key <publicKey>", "the coordinator public key")
260
- .option("-u, --use-quadratic-voting <useQuadraticVoting>", "whether to use quadratic voting", (value) => value === "true", true)
270
+ .option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
261
271
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
262
- .option("-m, --relayers <relayers>", "the relayer addresses", (value) => value.split(",").map((item) => item.trim()))
272
+ .option("--relayers <relayers>", "the relayer addresses", (value) => value.split(",").map((item) => item.trim()))
263
273
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
264
274
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
265
275
  .option("-o, --vote-options <voteOptions>", "the number of vote options", parseInt)
266
276
  .option("--initial-voice-credits <initialVoiceCredits>", "the initial voice credits", parseInt)
267
277
  .option("--initial-voice-credits-proxy <initialVoiceCreditsProxy>", "the initial voice credits proxy address")
268
278
  .option("--signup-policy <signupPolicy>", "the signup policy contract address")
269
- .action(async (cmdObj) => {
279
+ .action(async (args) => {
270
280
  try {
271
- (0, utils_1.banner)(cmdObj.quiet);
281
+ (0, utils_1.banner)(args.quiet);
272
282
  const signer = await getSigner();
273
283
  const network = await signer.provider?.getNetwork();
274
- const [vkRegistryAddress, maciAddress, initialVoiceCreditProxyAddress, verifierContractAddress] = (0, utils_1.readContractAddresses)({
284
+ const [verifyingKeysRegistryAddress, maciAddress, initialVoiceCreditProxyAddress, verifierContractAddress] = (0, utils_1.readContractAddresses)({
275
285
  contractNames: [
276
- sdk_1.EContracts.VkRegistry,
286
+ sdk_1.EContracts.VerifyingKeysRegistry,
277
287
  sdk_1.EContracts.MACI,
278
288
  sdk_1.EContracts.ConstantInitialVoiceCreditProxy,
279
289
  sdk_1.EContracts.Verifier,
280
290
  ],
281
291
  network: network?.name,
282
- defaultAddresses: [cmdObj.vkRegistryAddress, cmdObj.maciAddress, cmdObj.initialVoiceCreditsProxy],
292
+ defaultAddresses: [args.verifyingKeysRegistryAddress, args.maciAddress, args.initialVoiceCreditsProxy],
283
293
  });
284
294
  const maciContract = sdk_1.MACI__factory.connect(maciAddress, signer);
285
295
  const nextPollId = await maciContract.nextPollId();
@@ -289,40 +299,40 @@ program
289
299
  contractNames: [policyContractName.toString()],
290
300
  keys: [nextPollId.toString()],
291
301
  network: network?.name,
292
- defaultAddresses: [cmdObj.signupPolicy],
302
+ defaultAddresses: [args.signupPolicy],
293
303
  });
294
304
  const { pollId, pollContractAddress, tallyContractAddress, messageProcessorContractAddress, initialVoiceCreditProxyContractAddress, policyContractAddress, } = await (0, sdk_1.deployPoll)({
295
- initialVoiceCredits: cmdObj.initialVoiceCredits || defaults_1.DEFAULT_INITIAL_VOICE_CREDITS,
296
- pollStartTimestamp: cmdObj.start,
297
- pollEndTimestamp: cmdObj.end,
298
- intStateTreeDepth: cmdObj.intStateTreeDepth,
299
- messageBatchSize: cmdObj.messageBatchSize,
300
- stateTreeDepth: cmdObj.stateTreeDepth,
301
- voteOptionTreeDepth: cmdObj.voteOptionTreeDepth,
302
- coordinatorPublicKey: domainobjs_1.PublicKey.deserialize(cmdObj.publicKey),
305
+ initialVoiceCredits: args.initialVoiceCredits || defaults_1.DEFAULT_INITIAL_VOICE_CREDITS,
306
+ pollStartTimestamp: args.start,
307
+ pollEndTimestamp: args.end,
308
+ tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
309
+ messageBatchSize: args.messageBatchSize,
310
+ stateTreeDepth: args.stateTreeDepth,
311
+ voteOptionTreeDepth: args.voteOptionTreeDepth,
312
+ coordinatorPublicKey: domainobjs_1.PublicKey.deserialize(args.publicKey),
303
313
  maciAddress,
304
- vkRegistryContractAddress: vkRegistryAddress,
305
- relayers: cmdObj.relayers ?? [ethers_1.ZeroAddress],
306
- mode: cmdObj.useQuadraticVoting ? sdk_1.EMode.QV : sdk_1.EMode.NON_QV,
314
+ verifyingKeysRegistryContractAddress: verifyingKeysRegistryAddress,
315
+ relayers: args.relayers ?? [ethers_1.ZeroAddress],
316
+ mode: args.mode,
307
317
  signer,
308
- voteOptions: cmdObj.voteOptions ?? defaults_1.DEFAULT_VOTE_OPTIONS,
318
+ voteOptions: args.voteOptions ?? defaults_1.DEFAULT_VOTE_OPTIONS,
309
319
  verifierContractAddress,
310
320
  policyContractAddress: signupPolicyContractAddress,
311
321
  initialVoiceCreditProxyContractAddress: initialVoiceCreditProxyAddress,
312
322
  });
313
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.success)(`Poll ID: ${pollId}`) });
314
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.success)(`Poll contract address: ${pollContractAddress}`) });
315
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.success)(`Tally contract address: ${tallyContractAddress}`) });
323
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Poll ID: ${pollId}`) });
324
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Poll contract address: ${pollContractAddress}`) });
325
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Tally contract address: ${tallyContractAddress}`) });
316
326
  (0, sdk_1.logGreen)({
317
- quiet: cmdObj.quiet,
327
+ quiet: args.quiet,
318
328
  text: (0, sdk_1.success)(`Message processor contract address: ${messageProcessorContractAddress}`),
319
329
  });
320
330
  (0, sdk_1.logGreen)({
321
- quiet: cmdObj.quiet,
331
+ quiet: args.quiet,
322
332
  text: (0, sdk_1.success)(`Initial voice credit proxy contract address: ${initialVoiceCreditProxyContractAddress}`),
323
333
  });
324
334
  (0, sdk_1.logGreen)({
325
- quiet: cmdObj.quiet,
335
+ quiet: args.quiet,
326
336
  text: (0, sdk_1.success)(`Signup policy contract address: ${policyContractAddress}`),
327
337
  });
328
338
  }
@@ -334,7 +344,6 @@ program
334
344
  .command("joinPoll")
335
345
  .description("join the poll")
336
346
  .requiredOption("-k, --private-key <privateKey>", "the private key")
337
- .option("-i, --state-index <stateIndex>", "the user's state index", BigInt)
338
347
  .option("-s, --sg-data <sgData>", "the signup policy data")
339
348
  .option("-v, --ivcp-data <ivcpData>", "the initial voice credit proxy data")
340
349
  .option("-n, --new-voice-credit-balance <newVoiceCreditBalance>", "the voice credit balance of the user for the poll", BigInt)
@@ -350,38 +359,37 @@ program
350
359
  .requiredOption("--poll-joining-zkey <pollZkeyPath>", "the poll join zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
351
360
  .option("-w, --wasm", "whether to use the wasm binaries")
352
361
  .option("-r, --rapidsnark <rapidsnark>", "the path to the rapidsnark binary")
353
- .option("-g, --poll-witnessgen <pollWitnessgen>", "the path to the poll witness generation binary")
354
- .action(async (cmdObj) => {
362
+ .option("-g, --poll-witness-generator <pollWitnessGenerator>", "the path to the poll witness generation binary")
363
+ .action(async (args) => {
355
364
  try {
356
365
  const signer = await getSigner();
357
366
  const network = await signer.provider?.getNetwork();
358
367
  const [maciAddress] = (0, utils_1.readContractAddresses)({
359
368
  contractNames: [sdk_1.EContracts.MACI],
360
369
  network: network?.name,
361
- defaultAddresses: [cmdObj.maciAddress],
370
+ defaultAddresses: [args.maciAddress],
362
371
  });
363
- const privateKey = cmdObj.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
372
+ const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
364
373
  const data = await (0, sdk_1.joinPoll)({
365
374
  maciAddress,
366
375
  privateKey,
367
- stateIndex: cmdObj.stateIndex,
368
- stateFile: cmdObj.stateFile,
369
- pollId: cmdObj.pollId,
376
+ stateFile: args.stateFile,
377
+ pollId: args.pollId,
370
378
  signer,
371
- startBlock: cmdObj.startBlock,
372
- endBlock: cmdObj.endBlock,
373
- blocksPerBatch: cmdObj.blocksPerBatch,
374
- pollJoiningZkey: cmdObj.pollJoiningZkey,
375
- pollWasm: cmdObj.pollWasm,
376
- useWasm: cmdObj.wasm,
377
- rapidsnark: cmdObj.rapidsnark,
378
- pollWitgen: cmdObj.pollWitnessgen,
379
- sgDataArg: cmdObj.sgData ?? utils_1.DEFAULT_SG_DATA,
380
- ivcpDataArg: cmdObj.ivcpData ?? utils_1.DEFAULT_IVCP_DATA,
381
- });
382
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.info)(`User joined poll with nullifier: ${data.nullifier}`) });
383
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.info)(`User joined poll with state index: ${data.pollStateIndex}`) });
384
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.info)(`User joined poll with ${data.voiceCredits} voice credits`) });
379
+ startBlock: args.startBlock,
380
+ endBlock: args.endBlock,
381
+ blocksPerBatch: args.blocksPerBatch,
382
+ pollJoiningZkey: args.pollJoiningZkey,
383
+ pollWasm: args.pollWasm,
384
+ useWasm: args.wasm,
385
+ rapidsnark: args.rapidsnark,
386
+ pollWitnessGenerator: args.pollWitnessGenerator,
387
+ sgDataArg: args.sgData ?? utils_1.DEFAULT_SG_DATA,
388
+ ivcpDataArg: args.ivcpData ?? utils_1.DEFAULT_IVCP_DATA,
389
+ });
390
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with nullifier: ${data.nullifier}`) });
391
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with state index: ${data.pollStateIndex}`) });
392
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with ${data.voiceCredits} voice credits`) });
385
393
  }
386
394
  catch (error) {
387
395
  program.error(error.message, { exitCode: 1 });
@@ -391,49 +399,70 @@ program
391
399
  .command("setVerifyingKeys")
392
400
  .description("set the verifying keys")
393
401
  .requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
394
- .requiredOption("-i, --int-state-tree-depth <intStateTreeDepth>", "the intermediate state tree depth", parseInt)
402
+ .requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the intermediate state tree depth", parseInt)
395
403
  .requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
396
404
  .requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
397
405
  .option("--poll-state-tree-depth <pollStateTreeDepth>", "the poll state tree depth", parseInt)
398
406
  .option("--poll-joining-zkey <pollJoiningZkeyPath>", "the poll joining zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
399
407
  .option("--poll-joined-zkey <pollJoinedZkeyPath>", "the poll joined zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
400
- .option("--process-messages-zkey-qv <processMessagesZkeyPathQv>", "the process messages qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
401
- .option("--tally-votes-zkey-qv <tallyVotesZkeyPathQv>", "the tally votes qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
402
- .option("--process-messages-zkey-non-qv <processMessagesZkeyPathNonQv>", "the process messages non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
403
- .option("--tally-votes-zkey-non-qv <tallyVotesZkeyPathNonQv>", "the tally votes non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
404
- .option("-u, --use-quadratic-voting <useQuadraticVoting>", "whether to use quadratic voting", (value) => value === "true", true)
408
+ .option("--message-processor-zkey-qv <messageProcessorZkeyPathQv>", "the message processor qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
409
+ .option("--vote-tally-zkey-qv <voteTallyZkeyPathQv>", "the vote tally qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
410
+ .option("--message-processor-zkey-non-qv <messageProcessorZkeyPathNonQv>", "the message processor non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
411
+ .option("--vote-tally-zkey-non-qv <voteTallyZkeyPathNonQv>", "the vote tally non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
412
+ .option("--message-processor-zkey-full <messageProcessorZkeyPathFull>", "the message processor full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
413
+ .option("--vote-tally-zkey-full <tallyVotesZkeyPathFull>", "the vote tally full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
414
+ .option("-m, --modes <modes>", "Comma-separated list of voting modes (qv, non-qv, full)", (value) => value.split(",").map((v) => constants_1.MODE_NAME_TO_ENUM[v.trim()]), [sdk_1.EMode.QV])
405
415
  .option("-k, --vk-registry <vkRegistry>", "the vk registry contract address")
406
416
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
407
417
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
408
- .action(async (cmdObj) => {
418
+ .action(async (args) => {
409
419
  try {
410
420
  const signer = await getSigner();
411
421
  const network = await signer.provider?.getNetwork();
412
- const [vkRegistryAddress] = (0, utils_1.readContractAddresses)({
413
- contractNames: [sdk_1.EContracts.VkRegistry],
422
+ const [verifyingKeysRegistryAddress] = (0, utils_1.readContractAddresses)({
423
+ contractNames: [sdk_1.EContracts.VerifyingKeysRegistry],
414
424
  network: network?.name,
415
- defaultAddresses: [cmdObj.vkRegistry],
425
+ defaultAddresses: [args.vkRegistry],
416
426
  });
417
- const { pollJoiningVk, pollJoinedVk, processVk, tallyVk } = await (0, sdk_1.extractAllVks)({
418
- pollJoiningZkeyPath: cmdObj.pollJoiningZkey,
419
- pollJoinedZkeyPath: cmdObj.pollJoinedZkey,
420
- processMessagesZkeyPath: cmdObj.useQuadraticVoting
421
- ? cmdObj.processMessagesZkeyQv
422
- : cmdObj.processMessagesZkeyNonQv,
423
- tallyVotesZkeyPath: cmdObj.useQuadraticVoting ? cmdObj.tallyVotesZkeyQv : cmdObj.tallyVotesZkeyQv,
427
+ const processKeys = {
428
+ [sdk_1.EMode.QV]: args.messageProcessorZkeyQv,
429
+ [sdk_1.EMode.NON_QV]: args.messageProcessorZkeyNonQv,
430
+ [sdk_1.EMode.FULL]: args.messageProcessorZkeyFull,
431
+ };
432
+ const tallyKeys = {
433
+ [sdk_1.EMode.QV]: args.voteTallyZkeyQv,
434
+ [sdk_1.EMode.NON_QV]: args.voteTallyZkeyNonQv,
435
+ [sdk_1.EMode.FULL]: args.voteTallyZkeyFull,
436
+ };
437
+ const { pollJoiningVerifyingKey, pollJoinedVerifyingKey } = await (0, sdk_1.extractAllVerifyingKeys)({
438
+ pollJoiningZkeyPath: args.pollJoiningZkey,
439
+ pollJoinedZkeyPath: args.pollJoinedZkey,
440
+ });
441
+ const keysResults = await Promise.all(args.modes.map((mode) => (0, sdk_1.extractAllVerifyingKeys)({
442
+ messageProcessorZkeyPath: processKeys[mode],
443
+ voteTallyZkeyPath: tallyKeys[mode],
444
+ })));
445
+ const processVerifyingKeys = [];
446
+ const tallyVerifyingKeys = [];
447
+ keysResults.forEach(({ processVerifyingKey, tallyVerifyingKey }, idx) => {
448
+ if (!processVerifyingKey || !tallyVerifyingKey) {
449
+ throw new Error(`Verifying keys for mode ${args.modes[idx]} are not valid`);
450
+ }
451
+ processVerifyingKeys.push(processVerifyingKey);
452
+ tallyVerifyingKeys.push(tallyVerifyingKey);
424
453
  });
425
454
  await (0, sdk_1.setVerifyingKeys)({
426
- stateTreeDepth: cmdObj.stateTreeDepth,
427
- intStateTreeDepth: cmdObj.intStateTreeDepth,
428
- voteOptionTreeDepth: cmdObj.voteOptionTreeDepth,
429
- messageBatchSize: cmdObj.messageBatchSize,
430
- pollStateTreeDepth: cmdObj.pollStateTreeDepth || cmdObj.stateTreeDepth,
431
- pollJoiningVk: pollJoiningVk,
432
- pollJoinedVk: pollJoinedVk,
433
- processMessagesVk: processVk,
434
- tallyVotesVk: tallyVk,
435
- vkRegistryAddress,
436
- mode: cmdObj.useQuadraticVoting ? sdk_1.EMode.QV : sdk_1.EMode.NON_QV,
455
+ stateTreeDepth: args.stateTreeDepth,
456
+ tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
457
+ voteOptionTreeDepth: args.voteOptionTreeDepth,
458
+ messageBatchSize: args.messageBatchSize,
459
+ pollStateTreeDepth: args.pollStateTreeDepth || args.stateTreeDepth,
460
+ pollJoiningVerifyingKey: pollJoiningVerifyingKey,
461
+ pollJoinedVerifyingKey: pollJoinedVerifyingKey,
462
+ processMessagesVerifyingKeys: processVerifyingKeys,
463
+ tallyVotesVerifyingKeys: tallyVerifyingKeys,
464
+ verifyingKeysRegistryAddress,
465
+ modes: args.modes,
437
466
  signer,
438
467
  });
439
468
  }
@@ -455,25 +484,25 @@ program
455
484
  .requiredOption("-w, --new-vote-weight <newVoteWeight>", "the new vote weight", BigInt)
456
485
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
457
486
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
458
- .action(async (cmdObj) => {
487
+ .action(async (args) => {
459
488
  try {
460
489
  const signer = await getSigner();
461
490
  const network = await signer.provider?.getNetwork();
462
491
  const [maciAddress] = (0, utils_1.readContractAddresses)({
463
492
  contractNames: [sdk_1.EContracts.MACI],
464
493
  network: network?.name,
465
- defaultAddresses: [cmdObj.maciAddress],
494
+ defaultAddresses: [args.maciAddress],
466
495
  });
467
- const privateKey = cmdObj.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
496
+ const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
468
497
  await (0, sdk_1.publish)({
469
- publicKey: cmdObj.publicKey,
470
- stateIndex: cmdObj.stateIndex,
471
- voteOptionIndex: cmdObj.voteOptionIndex,
472
- nonce: cmdObj.nonce,
473
- pollId: cmdObj.pollId,
474
- newVoteWeight: cmdObj.newVoteWeight,
498
+ publicKey: args.publicKey,
499
+ stateIndex: args.stateIndex,
500
+ voteOptionIndex: args.voteOptionIndex,
501
+ nonce: args.nonce,
502
+ pollId: args.pollId,
503
+ newVoteWeight: args.newVoteWeight,
475
504
  maciAddress,
476
- salt: cmdObj.salt,
505
+ salt: args.salt,
477
506
  privateKey,
478
507
  signer,
479
508
  });
@@ -488,23 +517,23 @@ program
488
517
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
489
518
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
490
519
  .requiredOption("-p, --poll-id <pollId>", "the poll id", BigInt)
491
- .action(async (cmdObj) => {
520
+ .action(async (args) => {
492
521
  try {
493
522
  const signer = await getSigner();
494
523
  const network = await signer.provider?.getNetwork();
495
524
  const [maciAddress] = (0, utils_1.readContractAddresses)({
496
525
  contractNames: [sdk_1.EContracts.MACI],
497
526
  network: network?.name,
498
- defaultAddresses: [cmdObj.maciAddress],
527
+ defaultAddresses: [args.maciAddress],
499
528
  });
500
529
  const receipt = await (0, sdk_1.mergeSignups)({
501
- pollId: cmdObj.pollId,
530
+ pollId: args.pollId,
502
531
  maciAddress,
503
532
  signer,
504
533
  });
505
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.info)(`Transaction hash: ${receipt.hash}`) });
534
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`Transaction hash: ${receipt.hash}`) });
506
535
  (0, sdk_1.logGreen)({
507
- quiet: cmdObj.quiet,
536
+ quiet: args.quiet,
508
537
  text: (0, sdk_1.success)(`Executed mergeSignups(); gas used: ${receipt.gasUsed.toString()}`),
509
538
  });
510
539
  }
@@ -518,37 +547,39 @@ program
518
547
  .requiredOption("-s, --seconds <seconds>", "the number of seconds to fast-forward", parseInt)
519
548
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
520
549
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
521
- .action(async (cmdObj) => {
550
+ .action(async (args) => {
522
551
  try {
523
- (0, utils_1.banner)(cmdObj.quiet);
552
+ (0, utils_1.banner)(args.quiet);
524
553
  const signer = await getSigner();
525
- await (0, sdk_1.timeTravel)({ seconds: cmdObj.seconds, signer });
526
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.success)(`Fast-forwarded ${cmdObj.seconds} seconds`) });
554
+ await (0, sdk_1.timeTravel)({ seconds: args.seconds, signer });
555
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Fast-forwarded ${args.seconds} seconds`) });
527
556
  }
528
557
  catch (error) {
529
558
  program.error(error.message, { exitCode: 1 });
530
559
  }
531
560
  });
532
561
  program
533
- .command("extractVkToFile")
562
+ .command("extractVerifyingKeyToFile")
534
563
  .description("extract vkey to json file")
535
564
  .requiredOption("--poll-joining-zkey <pollJoiningZkey>", "the poll joining zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
536
565
  .requiredOption("--poll-joined-zkey <pollJoinedZkey>", "the poll joined zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
537
- .requiredOption("--process-messages-zkey-qv <processMessagesZkeyPathQv>", "the process messages qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
538
- .requiredOption("--tally-votes-zkey-qv <tallyVotesZkeyPathQv>", "the tally votes qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
539
- .requiredOption("--process-messages-zkey-non-qv <processMessagesZkeyPathNonQv>", "the process messages non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
540
- .requiredOption("--tally-votes-zkey-non-qv <tallyVotesZkeyPathNonQv>", "the tally votes non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
566
+ .requiredOption("--message-processor-zkey-qv <messageProcessorZkeyPathQv>", "the message processor qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
567
+ .requiredOption("--vote-tally-zkey-qv <voteTallyZkeyPathQv>", "the vote tally qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
568
+ .requiredOption("--message-processor-zkey-non-qv <messageProcessorZkeyPathNonQv>", "the message processor non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
569
+ .requiredOption("--message-processor-zkey-full <messageProcessorZkeyPathFull>", "the message processor full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
570
+ .requiredOption("--vote-tally-zkey-non-qv <voteTallyZkeyPathNonQv>", "the vote tally non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
541
571
  .requiredOption("-o, --output-file <outputFile>", "the output file path of extracted vkeys")
542
- .action(async (cmdObj) => {
572
+ .action(async (args) => {
543
573
  try {
544
- await (0, sdk_1.extractVkToFile)({
545
- processMessagesZkeyPathQv: cmdObj.processMessagesZkeyQv,
546
- tallyVotesZkeyPathQv: cmdObj.tallyVotesZkeyQv,
547
- processMessagesZkeyPathNonQv: cmdObj.processMessagesZkeyNonQv,
548
- tallyVotesZkeyPathNonQv: cmdObj.tallyVotesZkeyNonQv,
549
- pollJoiningZkeyPath: cmdObj.pollJoiningZkey,
550
- pollJoinedZkeyPath: cmdObj.pollJoinedZkey,
551
- outputFilePath: cmdObj.outputFile,
574
+ await (0, sdk_1.extractVerifyingKeyToFile)({
575
+ messageProcessorZkeyPathQv: args.messageProcessorZkeyQv,
576
+ messageProcessorZkeyPathFull: args.messageProcessorZkeyFull,
577
+ voteTallyZkeyPathQv: args.voteTallyZkeyQv,
578
+ messageProcessorZkeyPathNonQv: args.messageProcessorZkeyNonQv,
579
+ voteTallyZkeyPathNonQv: args.voteTallyZkeyNonQv,
580
+ pollJoiningZkeyPath: args.pollJoiningZkey,
581
+ pollJoinedZkeyPath: args.pollJoinedZkey,
582
+ outputFilePath: args.outputFile,
552
583
  });
553
584
  }
554
585
  catch (error) {
@@ -563,23 +594,23 @@ program
563
594
  .option("-s, --sg-data <sgData>", "the signup gateway data")
564
595
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
565
596
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
566
- .action(async (cmdObj) => {
597
+ .action(async (args) => {
567
598
  try {
568
599
  const signer = await getSigner();
569
600
  const network = await signer.provider?.getNetwork();
570
601
  const [maciAddress] = (0, utils_1.readContractAddresses)({
571
602
  contractNames: [sdk_1.EContracts.MACI],
572
603
  network: network?.name,
573
- defaultAddresses: [cmdObj.maciAddress],
604
+ defaultAddresses: [args.maciAddress],
574
605
  });
575
606
  const data = await (0, sdk_1.signup)({
576
- maciPublicKey: cmdObj.publicKey,
607
+ maciPublicKey: args.publicKey,
577
608
  maciAddress,
578
- sgData: cmdObj.sgData ?? utils_1.DEFAULT_SG_DATA,
609
+ sgData: args.sgData ?? utils_1.DEFAULT_SG_DATA,
579
610
  signer,
580
611
  });
581
612
  (0, sdk_1.logGreen)({
582
- quiet: cmdObj.quiet,
613
+ quiet: args.quiet,
583
614
  text: (0, sdk_1.success)(`State index: ${data.stateIndex.toString()}\n Transaction hash: ${data.transactionHash}`),
584
615
  });
585
616
  }
@@ -593,25 +624,25 @@ program
593
624
  .requiredOption("-p, --public-key <publicKey>", "the MACI public key")
594
625
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
595
626
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
596
- .action(async (cmdObj) => {
627
+ .action(async (args) => {
597
628
  try {
598
629
  const signer = await getSigner();
599
630
  const network = await signer.provider?.getNetwork();
600
631
  const [maciAddress] = (0, utils_1.readContractAddresses)({
601
632
  contractNames: [sdk_1.EContracts.MACI],
602
633
  network: network?.name,
603
- defaultAddresses: [cmdObj.maciAddress],
634
+ defaultAddresses: [args.maciAddress],
604
635
  });
605
636
  const data = await (0, sdk_1.getSignedupUserData)({
606
- maciPublicKey: cmdObj.publicKey,
637
+ maciPublicKey: args.publicKey,
607
638
  maciAddress,
608
639
  signer,
609
640
  });
610
641
  if (data.isRegistered) {
611
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.success)(`State index: ${data.stateIndex?.toString()}`) });
642
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`State index: ${data.stateIndex?.toString()}`) });
612
643
  }
613
644
  else {
614
- (0, sdk_1.logRed)({ quiet: cmdObj.quiet, text: "User is not registered" });
645
+ (0, sdk_1.logRed)({ quiet: args.quiet, text: "User is not registered" });
615
646
  }
616
647
  }
617
648
  catch (error) {
@@ -628,25 +659,25 @@ program
628
659
  .option("--start-block <startBlock>", "the block number to start looking for events from", parseInt)
629
660
  .option("--end-block <endBlock>", "the block number to end looking for events from", parseInt)
630
661
  .option("--blocks-per-batch <blockPerBatch>", "the number of blocks to process per batch", parseInt)
631
- .action(async (cmdObj) => {
662
+ .action(async (args) => {
632
663
  try {
633
664
  const signer = await getSigner();
634
665
  const network = await signer.provider?.getNetwork();
635
666
  const [maciAddress] = (0, utils_1.readContractAddresses)({
636
667
  contractNames: [sdk_1.EContracts.MACI],
637
668
  network: network?.name,
638
- defaultAddresses: [cmdObj.maciAddress],
669
+ defaultAddresses: [args.maciAddress],
639
670
  });
640
671
  const data = await (0, sdk_1.getJoinedUserData)({
641
- pollPublicKey: cmdObj.publicKey,
642
- startBlock: cmdObj.startBlock,
672
+ pollPublicKey: args.publicKey,
673
+ startBlock: args.startBlock,
643
674
  maciAddress,
644
- pollId: cmdObj.pollId,
675
+ pollId: args.pollId,
645
676
  signer,
646
677
  });
647
678
  if (data.isJoined) {
648
679
  (0, sdk_1.logGreen)({
649
- quiet: cmdObj.quiet,
680
+ quiet: args.quiet,
650
681
  text: (0, sdk_1.success)([
651
682
  `Poll state index: ${data.pollStateIndex?.toString()}, registered: ${data.isJoined}`,
652
683
  `Voice credits: ${data.voiceCredits?.toString()}`,
@@ -654,7 +685,7 @@ program
654
685
  });
655
686
  }
656
687
  else {
657
- (0, sdk_1.logRed)({ quiet: cmdObj.quiet, text: "User has not joined the poll" });
688
+ (0, sdk_1.logRed)({ quiet: args.quiet, text: "User has not joined the poll" });
658
689
  }
659
690
  }
660
691
  catch (error) {
@@ -666,29 +697,34 @@ program
666
697
  .description("Get deployed poll from MACI contract")
667
698
  .option("-p, --poll <poll>", "the poll id")
668
699
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
669
- .action(async (cmdObj) => {
700
+ .action(async (args) => {
670
701
  try {
671
702
  const signer = await getSigner();
672
703
  const network = await signer.provider?.getNetwork();
673
704
  const [maciAddress] = (0, utils_1.readContractAddresses)({
674
705
  contractNames: [sdk_1.EContracts.MACI],
675
706
  network: network?.name,
676
- defaultAddresses: [cmdObj.maciAddress],
707
+ defaultAddresses: [args.maciAddress],
677
708
  });
678
709
  const details = await (0, sdk_1.getPoll)({
679
- pollId: cmdObj.poll,
710
+ pollId: args.poll,
680
711
  maciAddress,
681
712
  signer,
682
713
  });
714
+ const modeNames = {
715
+ [sdk_1.EMode.QV]: "Quadratic Voting",
716
+ [sdk_1.EMode.NON_QV]: "Non-Quadratic Voting",
717
+ [sdk_1.EMode.FULL]: "Full Credits Voting",
718
+ };
683
719
  (0, sdk_1.logGreen)({
684
720
  quiet: true,
685
721
  text: (0, sdk_1.success)([
686
722
  `ID: ${details.id}`,
687
723
  `Start time: ${new Date(Number(details.startDate) * 1000).toString()}`,
688
724
  `End time: ${new Date(Number(details.endDate) * 1000).toString()}`,
689
- `Number of signups ${details.numSignups}`,
725
+ `Number of signups ${details.totalSignups}`,
690
726
  `State tree merged: ${details.isMerged}`,
691
- `Mode: ${details.mode === 0n ? "Quadratic Voting" : "Non-Quadratic Voting"}`,
727
+ `Mode: ${modeNames[details.mode]}`,
692
728
  ].join("\n")),
693
729
  });
694
730
  }
@@ -703,15 +739,15 @@ program
703
739
  .requiredOption("-w, --address <address>", "the address to fund")
704
740
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
705
741
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
706
- .action(async (cmdObj) => {
742
+ .action(async (args) => {
707
743
  try {
708
- (0, utils_1.banner)(cmdObj.quiet);
744
+ (0, utils_1.banner)(args.quiet);
709
745
  const signer = await getSigner();
710
- const hash = await (0, sdk_1.fundWallet)({ amount: cmdObj.amount, address: cmdObj.address, signer });
711
- (0, sdk_1.logYellow)({ quiet: cmdObj.quiet, text: (0, sdk_1.info)(`Transaction hash: ${hash}`) });
746
+ const hash = await (0, sdk_1.fundWallet)({ amount: args.amount, address: args.address, signer });
747
+ (0, sdk_1.logYellow)({ quiet: args.quiet, text: (0, sdk_1.info)(`Transaction hash: ${hash}`) });
712
748
  (0, sdk_1.logGreen)({
713
- quiet: cmdObj.quiet,
714
- text: (0, sdk_1.success)(`Successfully funded ${cmdObj.address} with ${cmdObj.amount} wei`),
749
+ quiet: args.quiet,
750
+ text: (0, sdk_1.success)(`Successfully funded ${args.address} with ${args.amount} wei`),
715
751
  });
716
752
  }
717
753
  catch (error) {
@@ -726,34 +762,34 @@ program
726
762
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
727
763
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
728
764
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
729
- .action(async (cmdObj) => {
765
+ .action(async (args) => {
730
766
  try {
731
- (0, utils_1.banner)(cmdObj.quiet);
767
+ (0, utils_1.banner)(args.quiet);
732
768
  const signer = await getSigner();
733
769
  const network = await signer.provider?.getNetwork();
734
770
  // read the tally file
735
- const isTallyFileExists = fs_1.default.existsSync(cmdObj.tallyFile);
736
- if (!cmdObj.tallyFile || !isTallyFileExists) {
737
- throw new Error(`Unable to open ${cmdObj.tallyFile}`);
771
+ const isTallyFileExists = fs_1.default.existsSync(args.tallyFile);
772
+ if (!args.tallyFile || !isTallyFileExists) {
773
+ throw new Error(`Unable to open ${args.tallyFile}`);
738
774
  }
739
- const tallyData = await (0, utils_1.readJSONFile)(cmdObj.tallyFile);
775
+ const tallyData = await (0, utils_1.readJSONFile)(args.tallyFile);
740
776
  const [maciAddress] = (0, utils_1.readContractAddresses)({
741
777
  contractNames: [sdk_1.EContracts.MACI],
742
778
  network: network?.name,
743
- defaultAddresses: [cmdObj.maciAddress],
779
+ defaultAddresses: [args.maciAddress],
744
780
  });
745
- const pollParams = await (0, sdk_1.getPollParams)({ pollId: cmdObj.pollId, maciContractAddress: maciAddress, signer });
781
+ const pollParams = await (0, sdk_1.getPollParams)({ pollId: args.pollId, maciContractAddress: maciAddress, signer });
746
782
  const tallyCommitments = (0, sdk_1.generateTallyCommitments)({
747
783
  tallyData,
748
784
  voteOptionTreeDepth: pollParams.voteOptionTreeDepth,
749
785
  });
750
786
  await (0, sdk_1.verify)({
751
787
  tallyData,
752
- pollId: cmdObj.pollId,
788
+ pollId: args.pollId,
753
789
  maciAddress,
754
790
  signer,
755
791
  tallyCommitments,
756
- numVoteOptions: pollParams.numVoteOptions,
792
+ totalVoteOptions: pollParams.totalVoteOptions,
757
793
  voteOptionTreeDepth: pollParams.voteOptionTreeDepth,
758
794
  });
759
795
  }
@@ -762,34 +798,34 @@ program
762
798
  }
763
799
  });
764
800
  program
765
- .command("genProofs")
801
+ .command("generateProofs")
766
802
  .description("generate the proofs for a poll")
767
803
  .option("-k, --private-key <privateKey>", "your serialized MACI private key")
768
804
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
769
805
  .requiredOption("-o, --poll-id <pollId>", "the poll id", BigInt)
770
806
  .requiredOption("-t, --tally-file <tallyFile>", "the tally file with results, per vote option spent credits, spent voice credits total")
771
807
  .option("-r, --rapidsnark <rapidsnark>", "the path to the rapidsnark binary")
772
- .option("-g, --process-witnessgen <processWitnessgen>", "the path to the process witness generation binary")
773
- .option("--process-witnessdat <processWitnessdat>", "the path to the process witness dat file")
774
- .option("--tally-witnessgen <tallyWitnessgen>", "the path to the tally witness generation binary")
775
- .option("--tally-witnessdat <tallyWitnessdat>", "the path to the tally witness dat file")
808
+ .option("-g, --message-processor-witness-generator <messageProcessorWitnessGenerator>", "the path to the process witness generation binary")
809
+ .option("--message-processor-witnessDat <messageProcessorWitnessDat>", "the path to the process witness dat file")
810
+ .option("--vote-tally-witness-generator <voteTallyWitnessGenerator>", "the path to the tally witness generation binary")
811
+ .option("--vote-tally-witnessDat <voteTallyWitnessDat>", "the path to the tally witness dat file")
776
812
  .requiredOption("--poll-joining-zkey <processJoinZkey>", "the path to the poll join zkey")
777
- .requiredOption("--process-zkey <processZkey>", "the path to the process zkey")
778
- .requiredOption("--tally-zkey <tallyZkey>", "the path to the tally zkey")
813
+ .requiredOption("--message-processor-zkey <messageProcessorZkey>", "the path to the process zkey")
814
+ .requiredOption("--vote-tally-zkey <voteTallyZkey>", "the path to the tally zkey")
779
815
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
780
816
  .option("-p, --rpc-provider <provider>", "the rpc provider URL")
781
817
  .requiredOption("-f, --output <outputDir>", "the output directory for proofs")
782
818
  .option("--transaction-hash <transactionHash>", "transaction hash of MACI contract creation")
783
819
  .option("-w, --wasm", "whether to use the wasm binaries")
784
- .option("--process-wasm <processWasm>", "the path to the process witness generation wasm binary")
785
- .option("--tally-wasm <tallyWasm>", "the path to the tally witness generation wasm binary")
820
+ .option("--message-processor-wasm <messageProcessorWasm>", "the path to the process witness generation wasm binary")
821
+ .option("--vote-tally-wasm <voteTallyWasm>", "the path to the tally witness generation wasm binary")
786
822
  .option("--state-file <stateFile>", "the path to the state file containing the serialized maci state")
787
823
  .option("--start-block <startBlock>", "the block number to start looking for events from", parseInt)
788
824
  .option("--end-block <endBlock>", "the block number to end looking for events from", parseInt)
789
825
  .option("--blocks-per-batch <blockPerBatch>", "the number of blocks to process per batch", parseInt)
790
- .option("-u, --use-quadratic-voting <useQuadraticVoting>", "whether to use quadratic voting", (value) => value === "true", true)
826
+ .option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
791
827
  .option("-b, --ipfs-message-backup-files <ipfsMessageBackupFiles>", "Backup files for ipfs messages (name format: ipfsHash1.json, ipfsHash2.json, ..., ipfsHashN.json)", (value) => value?.split(/\s*,\s*/))
792
- .action(async ({ quiet, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, startBlock, endBlock, blocksPerBatch, privateKey, transactionHash, output, tallyFile, tallyZkey, tallyWitnessgen, tallyWasm, processZkey, processWitnessgen, processWasm, useQuadraticVoting, tallyWitnessdat, processWitnessdat, wasm, rapidsnark, }) => {
828
+ .action(async ({ quiet, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, startBlock, endBlock, blocksPerBatch, privateKey, transactionHash, output, tallyFile, voteTallyZkey, voteTallyWitnessGenerator, voteTallyWasm, messageProcessorZkey, messageProcessorWitnessGenerator, messageProcessorWasm, mode, voteTallyWitnessDat, messageProcessorWitnessDat, wasm, rapidsnark, }) => {
793
829
  try {
794
830
  (0, utils_1.banner)(quiet);
795
831
  const signer = await getSigner();
@@ -813,15 +849,15 @@ program
813
849
  signer,
814
850
  outputDir: output,
815
851
  tallyFile,
816
- tallyZkey,
817
- tallyWitgen: tallyWitnessgen,
818
- tallyWasm,
819
- processZkey,
820
- processWitgen: processWitnessgen,
821
- processWasm,
822
- useQuadraticVoting,
823
- tallyDatFile: tallyWitnessdat,
824
- processDatFile: processWitnessdat,
852
+ voteTallyZkey,
853
+ voteTallyWitnessGenerator,
854
+ voteTallyWasm,
855
+ messageProcessorZkey,
856
+ messageProcessorWitnessGenerator,
857
+ messageProcessorWasm,
858
+ mode,
859
+ voteTallyWitnessDatFile: voteTallyWitnessDat,
860
+ messageProcessorWitnessDatFile: messageProcessorWitnessDat,
825
861
  useWasm: wasm,
826
862
  rapidsnark,
827
863
  });
@@ -831,7 +867,7 @@ program
831
867
  }
832
868
  });
833
869
  program
834
- .command("genLocalState")
870
+ .command("generateLocalState")
835
871
  .description("generate a local MACI state from the smart contracts events")
836
872
  .requiredOption("-o, --output <outputPath>", "the path where to write the state")
837
873
  .requiredOption("-p, --poll-id <pollId>", "the id of the poll", BigInt)
@@ -846,30 +882,30 @@ program
846
882
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
847
883
  .option("-b, --ipfs-message-backup-files <ipfsMessageBackupFiles>", "Backup files for ipfs messages (name format: ipfsHash1.json, ipfsHash2.json, ..., ipfsHashN.json)", (value) => value?.split(/\s*,\s*/))
848
884
  .option("-l, --logs-output <logsOutputPath>", "the path where to save the logs for debugging and auditing purposes")
849
- .action(async (cmdObj) => {
885
+ .action(async (args) => {
850
886
  try {
851
887
  const signer = await getSigner();
852
888
  const network = await signer.provider?.getNetwork();
853
889
  const [maciAddress] = (0, utils_1.readContractAddresses)({
854
890
  contractNames: [sdk_1.EContracts.MACI],
855
891
  network: network?.name,
856
- defaultAddresses: [cmdObj.maciAddress],
892
+ defaultAddresses: [args.maciAddress],
857
893
  });
858
- const coordinatorPrivateKey = cmdObj.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
894
+ const coordinatorPrivateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
859
895
  await (0, sdk_1.generateMaciState)({
860
- outputPath: cmdObj.output.toString(),
861
- pollId: cmdObj.pollId,
896
+ outputPath: args.output.toString(),
897
+ pollId: args.pollId,
862
898
  maciAddress,
863
899
  coordinatorPrivateKey,
864
- provider: cmdObj.rpcProvider,
865
- endBlock: cmdObj.endBlock,
866
- startBlock: cmdObj.startBlock,
867
- blockPerBatch: cmdObj.blocksPerBatch,
868
- transactionHash: cmdObj.transactionHash,
869
- ipfsMessageBackupFiles: cmdObj.ipfsMessageBackupFiles,
870
- sleep: cmdObj.sleep,
900
+ provider: args.rpcProvider,
901
+ endBlock: args.endBlock,
902
+ startBlock: args.startBlock,
903
+ blockPerBatch: args.blocksPerBatch,
904
+ transactionHash: args.transactionHash,
905
+ ipfsMessageBackupFiles: args.ipfsMessageBackupFiles,
906
+ sleep: args.sleep,
871
907
  signer,
872
- logsOutputPath: cmdObj.logsOutput,
908
+ logsOutputPath: args.logsOutput,
873
909
  });
874
910
  }
875
911
  catch (error) {
@@ -884,20 +920,20 @@ program
884
920
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
885
921
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
886
922
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
887
- .requiredOption("-f, --proof-dir <proofDir>", "the proof output directory from the genProofs subcommand")
888
- .action(async (cmdObj) => {
923
+ .requiredOption("-f, --proof-dir <proofDir>", "the proof output directory from the generateProofs subcommand")
924
+ .action(async (args) => {
889
925
  try {
890
926
  const signer = await getSigner();
891
927
  const network = await signer.provider?.getNetwork();
892
928
  const [maciAddress] = (0, utils_1.readContractAddresses)({
893
929
  contractNames: [sdk_1.EContracts.MACI],
894
930
  network: network?.name,
895
- defaultAddresses: [cmdObj.maciAddress],
931
+ defaultAddresses: [args.maciAddress],
896
932
  });
897
933
  await (0, sdk_1.proveOnChain)({
898
- pollId: cmdObj.pollId,
899
- tallyFile: cmdObj.tallyFile,
900
- proofDir: cmdObj.proofDir,
934
+ pollId: args.pollId,
935
+ tallyFile: args.tallyFile,
936
+ proofDir: args.proofDir,
901
937
  maciAddress,
902
938
  signer,
903
939
  });