@maci-protocol/cli 0.0.0-ci.f9da2fc → 0.0.0-ci.fc91dc9

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