@maci-protocol/cli 0.0.0-ci.f4bc8a6 → 0.0.0-ci.f5db322

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