@maci-protocol/cli 0.0.0-ci.044d30d → 0.0.0-ci.07174de

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