@maci-protocol/cli 0.0.0-ci.cf26211 → 0.0.0-ci.cf2cc5b

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