@maci-protocol/cli 0.0.0-ci.5209133 → 0.0.0-ci.52ce07e

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,75 @@ 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
- .requiredOption("-b, --msg-batch-size <messageBatchSize>", "the message batch size", parseInt)
151
+ .requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
151
152
  .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
153
  .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
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.msgBatchSize,
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
+ processMessagesZkeyPath: args.processMessagesZkey,
172
+ tallyVotesZkeyPath: args.tallyVotesZkey,
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
- .requiredOption("-k, --privkey <privkey>", "the private key")
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.privkey);
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 } = (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}`) });
203
204
  });
204
205
  program
205
- .command("deployVkRegistry")
206
+ .command("deployVerifyingKeysRegistry")
206
207
  .description("deploy a new verification key registry contract")
207
208
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
208
209
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
209
- .action(async (cmdObj) => {
210
+ .action(async (args) => {
210
211
  try {
211
- (0, utils_1.banner)(cmdObj.quiet);
212
+ (0, utils_1.banner)(args.quiet);
212
213
  const signer = await getSigner();
213
214
  // assume that the vkRegistry contract is the first one to be deployed
214
215
  const isContractAddressesStoreExists = fs_1.default.existsSync(utils_1.contractAddressesStorePath);
@@ -217,12 +218,15 @@ program
217
218
  (0, utils_1.resetContractAddresses)(network?.name);
218
219
  }
219
220
  // deploy and store the address
220
- const vkRegistryAddress = await (0, sdk_1.deployVkRegistryContract)({ signer });
221
+ const verifyingKeysRegistryAddress = await (0, sdk_1.deployVerifyingKeysRegistryContract)({ signer });
221
222
  await (0, utils_1.storeContractAddresses)({
222
- data: { [sdk_1.EContracts.VkRegistry]: { address: vkRegistryAddress, args: [] } },
223
+ data: { [sdk_1.EContracts.VerifyingKeysRegistry]: { address: verifyingKeysRegistryAddress, args: [] } },
223
224
  signer,
224
225
  });
225
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.success)(`VkRegistry deployed at: ${vkRegistryAddress}`) });
226
+ (0, sdk_1.logGreen)({
227
+ quiet: args.quiet,
228
+ text: (0, sdk_1.success)(`VerifyingKeysRegistry deployed at: ${verifyingKeysRegistryAddress}`),
229
+ });
226
230
  }
227
231
  catch (error) {
228
232
  program.error(error.message, { exitCode: 1 });
@@ -249,36 +253,37 @@ program
249
253
  program
250
254
  .command("deployPoll")
251
255
  .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)
256
- .requiredOption("-b, --msg-batch-size <messageBatchSize>", "the message batch size", parseInt)
256
+ .option("-k, --verifyingKeysRegistryAddress <verifyingKeysRegistryAddress>", "the vk registry contract address")
257
+ .requiredOption("--start <pollStartDate>", "the poll start date", parseInt)
258
+ .requiredOption("--end <pollEndDate>", "the poll end date", parseInt)
259
+ .requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the int state tree depth", parseInt)
260
+ .requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
261
+ .requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
257
262
  .requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
258
- .requiredOption("-p, --pubkey <coordinatorPubkey>", "the coordinator public key")
259
- .option("-u, --use-quadratic-voting <useQuadraticVoting>", "whether to use quadratic voting", (value) => value === "true", true)
263
+ .requiredOption("-p, --public-key <publicKey>", "the coordinator public key")
264
+ .option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
260
265
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
261
- .option("-m, --relayers <relayers>", "the relayer addresses", (value) => value.split(",").map((item) => item.trim()))
266
+ .option("--relayers <relayers>", "the relayer addresses", (value) => value.split(",").map((item) => item.trim()))
262
267
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
263
268
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
264
269
  .option("-o, --vote-options <voteOptions>", "the number of vote options", parseInt)
265
270
  .option("--initial-voice-credits <initialVoiceCredits>", "the initial voice credits", parseInt)
266
271
  .option("--initial-voice-credits-proxy <initialVoiceCreditsProxy>", "the initial voice credits proxy address")
267
272
  .option("--signup-policy <signupPolicy>", "the signup policy contract address")
268
- .action(async (cmdObj) => {
273
+ .action(async (args) => {
269
274
  try {
270
- (0, utils_1.banner)(cmdObj.quiet);
275
+ (0, utils_1.banner)(args.quiet);
271
276
  const signer = await getSigner();
272
277
  const network = await signer.provider?.getNetwork();
273
- const [vkRegistryAddress, maciAddress, initialVoiceCreditProxyAddress, verifierContractAddress] = (0, utils_1.readContractAddresses)({
278
+ const [verifyingKeysRegistryAddress, maciAddress, initialVoiceCreditProxyAddress, verifierContractAddress] = (0, utils_1.readContractAddresses)({
274
279
  contractNames: [
275
- sdk_1.EContracts.VkRegistry,
280
+ sdk_1.EContracts.VerifyingKeysRegistry,
276
281
  sdk_1.EContracts.MACI,
277
282
  sdk_1.EContracts.ConstantInitialVoiceCreditProxy,
278
283
  sdk_1.EContracts.Verifier,
279
284
  ],
280
285
  network: network?.name,
281
- defaultAddresses: [cmdObj.vkRegistryAddress, cmdObj.maciAddress, cmdObj.initialVoiceCreditsProxy],
286
+ defaultAddresses: [args.verifyingKeysRegistryAddress, args.maciAddress, args.initialVoiceCreditsProxy],
282
287
  });
283
288
  const maciContract = sdk_1.MACI__factory.connect(maciAddress, signer);
284
289
  const nextPollId = await maciContract.nextPollId();
@@ -288,39 +293,40 @@ program
288
293
  contractNames: [policyContractName.toString()],
289
294
  keys: [nextPollId.toString()],
290
295
  network: network?.name,
291
- defaultAddresses: [cmdObj.signupPolicy],
296
+ defaultAddresses: [args.signupPolicy],
292
297
  });
293
298
  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),
299
+ initialVoiceCredits: args.initialVoiceCredits || defaults_1.DEFAULT_INITIAL_VOICE_CREDITS,
300
+ pollStartTimestamp: args.start,
301
+ pollEndTimestamp: args.end,
302
+ tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
303
+ messageBatchSize: args.messageBatchSize,
304
+ stateTreeDepth: args.stateTreeDepth,
305
+ voteOptionTreeDepth: args.voteOptionTreeDepth,
306
+ coordinatorPublicKey: domainobjs_1.PublicKey.deserialize(args.publicKey),
301
307
  maciAddress,
302
- vkRegistryContractAddress: vkRegistryAddress,
303
- relayers: cmdObj.relayers ?? [ethers_1.ZeroAddress],
304
- mode: cmdObj.useQuadraticVoting ? sdk_1.EMode.QV : sdk_1.EMode.NON_QV,
308
+ verifyingKeysRegistryContractAddress: verifyingKeysRegistryAddress,
309
+ relayers: args.relayers ?? [ethers_1.ZeroAddress],
310
+ mode: args.mode,
305
311
  signer,
306
- voteOptions: cmdObj.voteOptions ?? defaults_1.DEFAULT_VOTE_OPTIONS,
312
+ voteOptions: args.voteOptions ?? defaults_1.DEFAULT_VOTE_OPTIONS,
307
313
  verifierContractAddress,
308
314
  policyContractAddress: signupPolicyContractAddress,
309
315
  initialVoiceCreditProxyContractAddress: initialVoiceCreditProxyAddress,
310
316
  });
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}`) });
317
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Poll ID: ${pollId}`) });
318
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Poll contract address: ${pollContractAddress}`) });
319
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Tally contract address: ${tallyContractAddress}`) });
314
320
  (0, sdk_1.logGreen)({
315
- quiet: cmdObj.quiet,
321
+ quiet: args.quiet,
316
322
  text: (0, sdk_1.success)(`Message processor contract address: ${messageProcessorContractAddress}`),
317
323
  });
318
324
  (0, sdk_1.logGreen)({
319
- quiet: cmdObj.quiet,
325
+ quiet: args.quiet,
320
326
  text: (0, sdk_1.success)(`Initial voice credit proxy contract address: ${initialVoiceCreditProxyContractAddress}`),
321
327
  });
322
328
  (0, sdk_1.logGreen)({
323
- quiet: cmdObj.quiet,
329
+ quiet: args.quiet,
324
330
  text: (0, sdk_1.success)(`Signup policy contract address: ${policyContractAddress}`),
325
331
  });
326
332
  }
@@ -331,7 +337,7 @@ program
331
337
  program
332
338
  .command("joinPoll")
333
339
  .description("join the poll")
334
- .requiredOption("-k, --priv-key <privKey>", "the private key")
340
+ .requiredOption("-k, --private-key <privateKey>", "the private key")
335
341
  .option("-i, --state-index <stateIndex>", "the user's state index", BigInt)
336
342
  .option("-s, --sg-data <sgData>", "the signup policy data")
337
343
  .option("-v, --ivcp-data <ivcpData>", "the initial voice credit proxy data")
@@ -349,37 +355,37 @@ program
349
355
  .option("-w, --wasm", "whether to use the wasm binaries")
350
356
  .option("-r, --rapidsnark <rapidsnark>", "the path to the rapidsnark binary")
351
357
  .option("-g, --poll-witnessgen <pollWitnessgen>", "the path to the poll witness generation binary")
352
- .action(async (cmdObj) => {
358
+ .action(async (args) => {
353
359
  try {
354
360
  const signer = await getSigner();
355
361
  const network = await signer.provider?.getNetwork();
356
362
  const [maciAddress] = (0, utils_1.readContractAddresses)({
357
363
  contractNames: [sdk_1.EContracts.MACI],
358
364
  network: network?.name,
359
- defaultAddresses: [cmdObj.maciAddress],
365
+ defaultAddresses: [args.maciAddress],
360
366
  });
361
- const privateKey = cmdObj.privKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
367
+ const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
362
368
  const data = await (0, sdk_1.joinPoll)({
363
369
  maciAddress,
364
370
  privateKey,
365
- stateIndex: cmdObj.stateIndex,
366
- stateFile: cmdObj.stateFile,
367
- pollId: cmdObj.pollId,
371
+ stateIndex: args.stateIndex,
372
+ stateFile: args.stateFile,
373
+ pollId: args.pollId,
368
374
  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`) });
375
+ startBlock: args.startBlock,
376
+ endBlock: args.endBlock,
377
+ blocksPerBatch: args.blocksPerBatch,
378
+ pollJoiningZkey: args.pollJoiningZkey,
379
+ pollWasm: args.pollWasm,
380
+ useWasm: args.wasm,
381
+ rapidsnark: args.rapidsnark,
382
+ pollWitgen: args.pollWitnessgen,
383
+ sgDataArg: args.sgData ?? utils_1.DEFAULT_SG_DATA,
384
+ ivcpDataArg: args.ivcpData ?? utils_1.DEFAULT_IVCP_DATA,
385
+ });
386
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with nullifier: ${data.nullifier}`) });
387
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with state index: ${data.pollStateIndex}`) });
388
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with ${data.voiceCredits} voice credits`) });
383
389
  }
384
390
  catch (error) {
385
391
  program.error(error.message, { exitCode: 1 });
@@ -389,47 +395,59 @@ program
389
395
  .command("setVerifyingKeys")
390
396
  .description("set the verifying keys")
391
397
  .requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
392
- .requiredOption("-i, --int-state-tree-depth <intStateTreeDepth>", "the intermediate state tree depth", parseInt)
398
+ .requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the intermediate state tree depth", parseInt)
393
399
  .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)
400
+ .requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
401
+ .option("--poll-state-tree-depth <pollStateTreeDepth>", "the poll state tree depth", parseInt)
395
402
  .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
403
  .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
404
  .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)")
398
405
  .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)")
399
406
  .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)")
400
407
  .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)")
401
- .option("-u, --use-quadratic-voting <useQuadraticVoting>", "whether to use quadratic voting", (value) => value === "true", true)
408
+ .option("--process-messages-zkey-full <processMessagesZkeyPathFull>", "the process messages 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)")
409
+ .option("--tally-votes-zkey-full <tallyVotesZkeyPathFull>", "the tally votes 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)")
410
+ .option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
402
411
  .option("-k, --vk-registry <vkRegistry>", "the vk registry contract address")
403
412
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
404
413
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
405
- .action(async (cmdObj) => {
414
+ .action(async (args) => {
406
415
  try {
407
416
  const signer = await getSigner();
408
417
  const network = await signer.provider?.getNetwork();
409
- const [vkRegistryAddress] = (0, utils_1.readContractAddresses)({
410
- contractNames: [sdk_1.EContracts.VkRegistry],
418
+ const [verifyingKeysRegistryAddress] = (0, utils_1.readContractAddresses)({
419
+ contractNames: [sdk_1.EContracts.VerifyingKeysRegistry],
411
420
  network: network?.name,
412
- defaultAddresses: [cmdObj.vkRegistry],
421
+ defaultAddresses: [args.vkRegistry],
413
422
  });
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,
423
+ const processKeys = {
424
+ [sdk_1.EMode.QV]: args.processMessagesZkeyQv,
425
+ [sdk_1.EMode.NON_QV]: args.processMessagesZkeyNonQv,
426
+ [sdk_1.EMode.FULL]: args.processMessagesZkeyFull,
427
+ };
428
+ const tallyKeys = {
429
+ [sdk_1.EMode.QV]: args.tallyVotesZkeyQv,
430
+ [sdk_1.EMode.NON_QV]: args.tallyVotesZkeyNonQv,
431
+ [sdk_1.EMode.FULL]: args.tallyVotesZkeyFull,
432
+ };
433
+ const { pollJoiningVerifyingKey, pollJoinedVerifyingKey, processVerifyingKey, tallyVerifyingKey } = await (0, sdk_1.extractAllVerifyingKeys)({
434
+ pollJoiningZkeyPath: args.pollJoiningZkey,
435
+ pollJoinedZkeyPath: args.pollJoinedZkey,
436
+ processMessagesZkeyPath: processKeys[args.mode],
437
+ tallyVotesZkeyPath: tallyKeys[args.mode],
421
438
  });
422
439
  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,
440
+ stateTreeDepth: args.stateTreeDepth,
441
+ tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
442
+ voteOptionTreeDepth: args.voteOptionTreeDepth,
443
+ messageBatchSize: args.messageBatchSize,
444
+ pollStateTreeDepth: args.pollStateTreeDepth || args.stateTreeDepth,
445
+ pollJoiningVerifyingKey: pollJoiningVerifyingKey,
446
+ pollJoinedVerifyingKey: pollJoinedVerifyingKey,
447
+ processMessagesVerifyingKey: processVerifyingKey,
448
+ tallyVotesVerifyingKey: tallyVerifyingKey,
449
+ verifyingKeysRegistryAddress,
450
+ mode: args.mode,
433
451
  signer,
434
452
  });
435
453
  }
@@ -440,9 +458,9 @@ program
440
458
  program
441
459
  .command("publish")
442
460
  .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")
461
+ .requiredOption("-p, --public-key <publicKey>", "the MACI public key which should replace the user's public key in the state tree")
444
462
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
445
- .option("-k, --privkey <privkey>", "your serialized MACI private key")
463
+ .option("-k, --private-key <privateKey>", "your serialized MACI private key")
446
464
  .requiredOption("-i, --state-index <stateIndex>", "the user's state index", BigInt)
447
465
  .requiredOption("-v, --vote-option-index <voteOptionIndex>", "the vote option index", BigInt)
448
466
  .requiredOption("-n, --nonce <nonce>", "the message nonce", BigInt)
@@ -451,25 +469,25 @@ program
451
469
  .requiredOption("-w, --new-vote-weight <newVoteWeight>", "the new vote weight", BigInt)
452
470
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
453
471
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
454
- .action(async (cmdObj) => {
472
+ .action(async (args) => {
455
473
  try {
456
474
  const signer = await getSigner();
457
475
  const network = await signer.provider?.getNetwork();
458
476
  const [maciAddress] = (0, utils_1.readContractAddresses)({
459
477
  contractNames: [sdk_1.EContracts.MACI],
460
478
  network: network?.name,
461
- defaultAddresses: [cmdObj.maciAddress],
479
+ defaultAddresses: [args.maciAddress],
462
480
  });
463
- const privateKey = cmdObj.privkey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
481
+ const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
464
482
  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,
483
+ publicKey: args.publicKey,
484
+ stateIndex: args.stateIndex,
485
+ voteOptionIndex: args.voteOptionIndex,
486
+ nonce: args.nonce,
487
+ pollId: args.pollId,
488
+ newVoteWeight: args.newVoteWeight,
471
489
  maciAddress,
472
- salt: cmdObj.salt,
490
+ salt: args.salt,
473
491
  privateKey,
474
492
  signer,
475
493
  });
@@ -484,23 +502,23 @@ program
484
502
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
485
503
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
486
504
  .requiredOption("-p, --poll-id <pollId>", "the poll id", BigInt)
487
- .action(async (cmdObj) => {
505
+ .action(async (args) => {
488
506
  try {
489
507
  const signer = await getSigner();
490
508
  const network = await signer.provider?.getNetwork();
491
509
  const [maciAddress] = (0, utils_1.readContractAddresses)({
492
510
  contractNames: [sdk_1.EContracts.MACI],
493
511
  network: network?.name,
494
- defaultAddresses: [cmdObj.maciAddress],
512
+ defaultAddresses: [args.maciAddress],
495
513
  });
496
514
  const receipt = await (0, sdk_1.mergeSignups)({
497
- pollId: cmdObj.pollId,
515
+ pollId: args.pollId,
498
516
  maciAddress,
499
517
  signer,
500
518
  });
501
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.info)(`Transaction hash: ${receipt.hash}`) });
519
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`Transaction hash: ${receipt.hash}`) });
502
520
  (0, sdk_1.logGreen)({
503
- quiet: cmdObj.quiet,
521
+ quiet: args.quiet,
504
522
  text: (0, sdk_1.success)(`Executed mergeSignups(); gas used: ${receipt.gasUsed.toString()}`),
505
523
  });
506
524
  }
@@ -514,37 +532,39 @@ program
514
532
  .requiredOption("-s, --seconds <seconds>", "the number of seconds to fast-forward", parseInt)
515
533
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
516
534
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
517
- .action(async (cmdObj) => {
535
+ .action(async (args) => {
518
536
  try {
519
- (0, utils_1.banner)(cmdObj.quiet);
537
+ (0, utils_1.banner)(args.quiet);
520
538
  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`) });
539
+ await (0, sdk_1.timeTravel)({ seconds: args.seconds, signer });
540
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Fast-forwarded ${args.seconds} seconds`) });
523
541
  }
524
542
  catch (error) {
525
543
  program.error(error.message, { exitCode: 1 });
526
544
  }
527
545
  });
528
546
  program
529
- .command("extractVkToFile")
547
+ .command("extractVerifyingKeyToFile")
530
548
  .description("extract vkey to json file")
531
549
  .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
550
  .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)")
533
551
  .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)")
534
552
  .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)")
535
553
  .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)")
554
+ .requiredOption("--process-messages-zkey-full <processMessagesZkeyPathFull>", "the process messages 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)")
536
555
  .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
556
  .requiredOption("-o, --output-file <outputFile>", "the output file path of extracted vkeys")
538
- .action(async (cmdObj) => {
557
+ .action(async (args) => {
539
558
  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,
559
+ await (0, sdk_1.extractVerifyingKeyToFile)({
560
+ processMessagesZkeyPathQv: args.processMessagesZkeyQv,
561
+ processMessagesZkeyPathFull: args.processMessagesZkeyFull,
562
+ tallyVotesZkeyPathQv: args.tallyVotesZkeyQv,
563
+ processMessagesZkeyPathNonQv: args.processMessagesZkeyNonQv,
564
+ tallyVotesZkeyPathNonQv: args.tallyVotesZkeyNonQv,
565
+ pollJoiningZkeyPath: args.pollJoiningZkey,
566
+ pollJoinedZkeyPath: args.pollJoinedZkey,
567
+ outputFilePath: args.outputFile,
548
568
  });
549
569
  }
550
570
  catch (error) {
@@ -554,28 +574,28 @@ program
554
574
  program
555
575
  .command("signup")
556
576
  .description("Sign up to a MACI contract")
557
- .requiredOption("-p, --pubkey <maciPubKey>", "the MACI public key")
577
+ .requiredOption("-p, --public-key <publicKey>", "the MACI public key")
558
578
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
559
579
  .option("-s, --sg-data <sgData>", "the signup gateway data")
560
580
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
561
581
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
562
- .action(async (cmdObj) => {
582
+ .action(async (args) => {
563
583
  try {
564
584
  const signer = await getSigner();
565
585
  const network = await signer.provider?.getNetwork();
566
586
  const [maciAddress] = (0, utils_1.readContractAddresses)({
567
587
  contractNames: [sdk_1.EContracts.MACI],
568
588
  network: network?.name,
569
- defaultAddresses: [cmdObj.maciAddress],
589
+ defaultAddresses: [args.maciAddress],
570
590
  });
571
591
  const data = await (0, sdk_1.signup)({
572
- maciPubKey: cmdObj.pubkey,
592
+ maciPublicKey: args.publicKey,
573
593
  maciAddress,
574
- sgData: cmdObj.sgData ?? utils_1.DEFAULT_SG_DATA,
594
+ sgData: args.sgData ?? utils_1.DEFAULT_SG_DATA,
575
595
  signer,
576
596
  });
577
597
  (0, sdk_1.logGreen)({
578
- quiet: cmdObj.quiet,
598
+ quiet: args.quiet,
579
599
  text: (0, sdk_1.success)(`State index: ${data.stateIndex.toString()}\n Transaction hash: ${data.transactionHash}`),
580
600
  });
581
601
  }
@@ -586,28 +606,28 @@ program
586
606
  program
587
607
  .command("isRegisteredUser")
588
608
  .description("Checks if user is registered with their public key and get their data")
589
- .requiredOption("-p, --pubkey <maciPubKey>", "the MACI public key")
609
+ .requiredOption("-p, --public-key <publicKey>", "the MACI public key")
590
610
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
591
611
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
592
- .action(async (cmdObj) => {
612
+ .action(async (args) => {
593
613
  try {
594
614
  const signer = await getSigner();
595
615
  const network = await signer.provider?.getNetwork();
596
616
  const [maciAddress] = (0, utils_1.readContractAddresses)({
597
617
  contractNames: [sdk_1.EContracts.MACI],
598
618
  network: network?.name,
599
- defaultAddresses: [cmdObj.maciAddress],
619
+ defaultAddresses: [args.maciAddress],
600
620
  });
601
621
  const data = await (0, sdk_1.getSignedupUserData)({
602
- maciPubKey: cmdObj.pubkey,
622
+ maciPublicKey: args.publicKey,
603
623
  maciAddress,
604
624
  signer,
605
625
  });
606
626
  if (data.isRegistered) {
607
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.success)(`State index: ${data.stateIndex?.toString()}`) });
627
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`State index: ${data.stateIndex?.toString()}`) });
608
628
  }
609
629
  else {
610
- (0, sdk_1.logRed)({ quiet: cmdObj.quiet, text: "User is not registered" });
630
+ (0, sdk_1.logRed)({ quiet: args.quiet, text: "User is not registered" });
611
631
  }
612
632
  }
613
633
  catch (error) {
@@ -617,32 +637,32 @@ program
617
637
  program
618
638
  .command("isJoinedUser")
619
639
  .description("Checks if user is joined to the poll with public key")
620
- .requiredOption("-p, --pubkey <pubkey>", "the MACI public key")
640
+ .requiredOption("-p, --public-key <publicKey>", "the MACI public key")
621
641
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
622
642
  .requiredOption("-o, --poll-id <pollId>", "the poll id", BigInt)
623
643
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
624
644
  .option("--start-block <startBlock>", "the block number to start looking for events from", parseInt)
625
645
  .option("--end-block <endBlock>", "the block number to end looking for events from", parseInt)
626
646
  .option("--blocks-per-batch <blockPerBatch>", "the number of blocks to process per batch", parseInt)
627
- .action(async (cmdObj) => {
647
+ .action(async (args) => {
628
648
  try {
629
649
  const signer = await getSigner();
630
650
  const network = await signer.provider?.getNetwork();
631
651
  const [maciAddress] = (0, utils_1.readContractAddresses)({
632
652
  contractNames: [sdk_1.EContracts.MACI],
633
653
  network: network?.name,
634
- defaultAddresses: [cmdObj.maciAddress],
654
+ defaultAddresses: [args.maciAddress],
635
655
  });
636
656
  const data = await (0, sdk_1.getJoinedUserData)({
637
- pollPubKey: cmdObj.pubkey,
638
- startBlock: cmdObj.startBlock,
657
+ pollPublicKey: args.publicKey,
658
+ startBlock: args.startBlock,
639
659
  maciAddress,
640
- pollId: cmdObj.pollId,
660
+ pollId: args.pollId,
641
661
  signer,
642
662
  });
643
663
  if (data.isJoined) {
644
664
  (0, sdk_1.logGreen)({
645
- quiet: cmdObj.quiet,
665
+ quiet: args.quiet,
646
666
  text: (0, sdk_1.success)([
647
667
  `Poll state index: ${data.pollStateIndex?.toString()}, registered: ${data.isJoined}`,
648
668
  `Voice credits: ${data.voiceCredits?.toString()}`,
@@ -650,7 +670,7 @@ program
650
670
  });
651
671
  }
652
672
  else {
653
- (0, sdk_1.logRed)({ quiet: cmdObj.quiet, text: "User has not joined the poll" });
673
+ (0, sdk_1.logRed)({ quiet: args.quiet, text: "User has not joined the poll" });
654
674
  }
655
675
  }
656
676
  catch (error) {
@@ -662,29 +682,34 @@ program
662
682
  .description("Get deployed poll from MACI contract")
663
683
  .option("-p, --poll <poll>", "the poll id")
664
684
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
665
- .action(async (cmdObj) => {
685
+ .action(async (args) => {
666
686
  try {
667
687
  const signer = await getSigner();
668
688
  const network = await signer.provider?.getNetwork();
669
689
  const [maciAddress] = (0, utils_1.readContractAddresses)({
670
690
  contractNames: [sdk_1.EContracts.MACI],
671
691
  network: network?.name,
672
- defaultAddresses: [cmdObj.maciAddress],
692
+ defaultAddresses: [args.maciAddress],
673
693
  });
674
694
  const details = await (0, sdk_1.getPoll)({
675
- pollId: cmdObj.poll,
695
+ pollId: args.poll,
676
696
  maciAddress,
677
697
  signer,
678
698
  });
699
+ const modeNames = {
700
+ [sdk_1.EMode.QV]: "Quadratic Voting",
701
+ [sdk_1.EMode.NON_QV]: "Non-Quadratic Voting",
702
+ [sdk_1.EMode.FULL]: "Full Credits Voting",
703
+ };
679
704
  (0, sdk_1.logGreen)({
680
705
  quiet: true,
681
706
  text: (0, sdk_1.success)([
682
707
  `ID: ${details.id}`,
683
708
  `Start time: ${new Date(Number(details.startDate) * 1000).toString()}`,
684
709
  `End time: ${new Date(Number(details.endDate) * 1000).toString()}`,
685
- `Number of signups ${details.numSignups}`,
710
+ `Number of signups ${details.totalSignups}`,
686
711
  `State tree merged: ${details.isMerged}`,
687
- `Mode: ${details.mode === 0n ? "Quadratic Voting" : "Non-Quadratic Voting"}`,
712
+ `Mode: ${modeNames[details.mode]}`,
688
713
  ].join("\n")),
689
714
  });
690
715
  }
@@ -699,15 +724,15 @@ program
699
724
  .requiredOption("-w, --address <address>", "the address to fund")
700
725
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
701
726
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
702
- .action(async (cmdObj) => {
727
+ .action(async (args) => {
703
728
  try {
704
- (0, utils_1.banner)(cmdObj.quiet);
729
+ (0, utils_1.banner)(args.quiet);
705
730
  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}`) });
731
+ const hash = await (0, sdk_1.fundWallet)({ amount: args.amount, address: args.address, signer });
732
+ (0, sdk_1.logYellow)({ quiet: args.quiet, text: (0, sdk_1.info)(`Transaction hash: ${hash}`) });
708
733
  (0, sdk_1.logGreen)({
709
- quiet: cmdObj.quiet,
710
- text: (0, sdk_1.success)(`Successfully funded ${cmdObj.address} with ${cmdObj.amount} wei`),
734
+ quiet: args.quiet,
735
+ text: (0, sdk_1.success)(`Successfully funded ${args.address} with ${args.amount} wei`),
711
736
  });
712
737
  }
713
738
  catch (error) {
@@ -722,34 +747,34 @@ program
722
747
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
723
748
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
724
749
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
725
- .action(async (cmdObj) => {
750
+ .action(async (args) => {
726
751
  try {
727
- (0, utils_1.banner)(cmdObj.quiet);
752
+ (0, utils_1.banner)(args.quiet);
728
753
  const signer = await getSigner();
729
754
  const network = await signer.provider?.getNetwork();
730
755
  // 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}`);
756
+ const isTallyFileExists = fs_1.default.existsSync(args.tallyFile);
757
+ if (!args.tallyFile || !isTallyFileExists) {
758
+ throw new Error(`Unable to open ${args.tallyFile}`);
734
759
  }
735
- const tallyData = await (0, utils_1.readJSONFile)(cmdObj.tallyFile);
760
+ const tallyData = await (0, utils_1.readJSONFile)(args.tallyFile);
736
761
  const [maciAddress] = (0, utils_1.readContractAddresses)({
737
762
  contractNames: [sdk_1.EContracts.MACI],
738
763
  network: network?.name,
739
- defaultAddresses: [cmdObj.maciAddress],
764
+ defaultAddresses: [args.maciAddress],
740
765
  });
741
- const pollParams = await (0, sdk_1.getPollParams)({ pollId: cmdObj.pollId, maciContractAddress: maciAddress, signer });
766
+ const pollParams = await (0, sdk_1.getPollParams)({ pollId: args.pollId, maciContractAddress: maciAddress, signer });
742
767
  const tallyCommitments = (0, sdk_1.generateTallyCommitments)({
743
768
  tallyData,
744
769
  voteOptionTreeDepth: pollParams.voteOptionTreeDepth,
745
770
  });
746
771
  await (0, sdk_1.verify)({
747
772
  tallyData,
748
- pollId: cmdObj.pollId,
773
+ pollId: args.pollId,
749
774
  maciAddress,
750
775
  signer,
751
776
  tallyCommitments,
752
- numVoteOptions: pollParams.numVoteOptions,
777
+ totalVoteOptions: pollParams.totalVoteOptions,
753
778
  voteOptionTreeDepth: pollParams.voteOptionTreeDepth,
754
779
  });
755
780
  }
@@ -758,9 +783,9 @@ program
758
783
  }
759
784
  });
760
785
  program
761
- .command("genProofs")
786
+ .command("generateProofs")
762
787
  .description("generate the proofs for a poll")
763
- .option("-k, --privkey <privkey>", "your serialized MACI private key")
788
+ .option("-k, --private-key <privateKey>", "your serialized MACI private key")
764
789
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
765
790
  .requiredOption("-o, --poll-id <pollId>", "the poll id", BigInt)
766
791
  .requiredOption("-t, --tally-file <tallyFile>", "the tally file with results, per vote option spent credits, spent voice credits total")
@@ -783,9 +808,9 @@ program
783
808
  .option("--start-block <startBlock>", "the block number to start looking for events from", parseInt)
784
809
  .option("--end-block <endBlock>", "the block number to end looking for events from", parseInt)
785
810
  .option("--blocks-per-batch <blockPerBatch>", "the number of blocks to process per batch", parseInt)
786
- .option("-u, --use-quadratic-voting <useQuadraticVoting>", "whether to use quadratic voting", (value) => value === "true", true)
811
+ .option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
787
812
  .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, }) => {
813
+ .action(async ({ quiet, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, startBlock, endBlock, blocksPerBatch, privateKey, transactionHash, output, tallyFile, tallyZkey, tallyWitnessgen, tallyWasm, processZkey, processWitnessgen, processWasm, mode, tallyWitnessdat, processWitnessdat, wasm, rapidsnark, }) => {
789
814
  try {
790
815
  (0, utils_1.banner)(quiet);
791
816
  const signer = await getSigner();
@@ -795,7 +820,7 @@ program
795
820
  network: network?.name,
796
821
  defaultAddresses: [maciAddress],
797
822
  });
798
- const coordinatorPrivateKey = privkey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
823
+ const coordinatorPrivateKey = privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
799
824
  await (0, sdk_1.generateProofs)({
800
825
  maciAddress: maciContractAddress,
801
826
  coordinatorPrivateKey,
@@ -815,7 +840,7 @@ program
815
840
  processZkey,
816
841
  processWitgen: processWitnessgen,
817
842
  processWasm,
818
- useQuadraticVoting,
843
+ mode,
819
844
  tallyDatFile: tallyWitnessdat,
820
845
  processDatFile: processWitnessdat,
821
846
  useWasm: wasm,
@@ -827,12 +852,12 @@ program
827
852
  }
828
853
  });
829
854
  program
830
- .command("genLocalState")
855
+ .command("generateLocalState")
831
856
  .description("generate a local MACI state from the smart contracts events")
832
857
  .requiredOption("-o, --output <outputPath>", "the path where to write the state")
833
858
  .requiredOption("-p, --poll-id <pollId>", "the id of the poll", BigInt)
834
859
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
835
- .option("-k, --privkey <privkey>", "your serialized MACI private key")
860
+ .option("-k, --private-key <privateKey>", "your serialized MACI private key")
836
861
  .option("--start-block <startBlock>", "the start block number", parseInt)
837
862
  .option("--end-block <endBlock>", "the end block number", parseInt)
838
863
  .option("--blocks-per-batch <blockPerBatch>", "the blocks per batch", parseInt)
@@ -842,30 +867,30 @@ program
842
867
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
843
868
  .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
869
  .option("-l, --logs-output <logsOutputPath>", "the path where to save the logs for debugging and auditing purposes")
845
- .action(async (cmdObj) => {
870
+ .action(async (args) => {
846
871
  try {
847
872
  const signer = await getSigner();
848
873
  const network = await signer.provider?.getNetwork();
849
874
  const [maciAddress] = (0, utils_1.readContractAddresses)({
850
875
  contractNames: [sdk_1.EContracts.MACI],
851
876
  network: network?.name,
852
- defaultAddresses: [cmdObj.maciAddress],
877
+ defaultAddresses: [args.maciAddress],
853
878
  });
854
- const coordinatorPrivateKey = cmdObj.privkey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
879
+ const coordinatorPrivateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
855
880
  await (0, sdk_1.generateMaciState)({
856
- outputPath: cmdObj.output.toString(),
857
- pollId: cmdObj.pollId,
881
+ outputPath: args.output.toString(),
882
+ pollId: args.pollId,
858
883
  maciAddress,
859
884
  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,
885
+ provider: args.rpcProvider,
886
+ endBlock: args.endBlock,
887
+ startBlock: args.startBlock,
888
+ blockPerBatch: args.blocksPerBatch,
889
+ transactionHash: args.transactionHash,
890
+ ipfsMessageBackupFiles: args.ipfsMessageBackupFiles,
891
+ sleep: args.sleep,
867
892
  signer,
868
- logsOutputPath: cmdObj.logsOutput,
893
+ logsOutputPath: args.logsOutput,
869
894
  });
870
895
  }
871
896
  catch (error) {
@@ -880,20 +905,20 @@ program
880
905
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
881
906
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
882
907
  .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) => {
908
+ .requiredOption("-f, --proof-dir <proofDir>", "the proof output directory from the generateProofs subcommand")
909
+ .action(async (args) => {
885
910
  try {
886
911
  const signer = await getSigner();
887
912
  const network = await signer.provider?.getNetwork();
888
913
  const [maciAddress] = (0, utils_1.readContractAddresses)({
889
914
  contractNames: [sdk_1.EContracts.MACI],
890
915
  network: network?.name,
891
- defaultAddresses: [cmdObj.maciAddress],
916
+ defaultAddresses: [args.maciAddress],
892
917
  });
893
918
  await (0, sdk_1.proveOnChain)({
894
- pollId: cmdObj.pollId,
895
- tallyFile: cmdObj.tallyFile,
896
- proofDir: cmdObj.proofDir,
919
+ pollId: args.pollId,
920
+ tallyFile: args.tallyFile,
921
+ proofDir: args.proofDir,
897
922
  maciAddress,
898
923
  signer,
899
924
  });