@maci-protocol/cli 0.0.0-ci.38ad204 → 0.0.0-ci.38fea56

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)
143
- .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
- .requiredOption("-t, --tally-votes-zkey <tallyVotesZkeyPath>", "the tally votes zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
151
+ .requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
152
+ .requiredOption("-p, --message-processor-zkey <messageProcessorZkeyPath>", "the message processor zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
153
+ .requiredOption("-t, --vote-tally-zkey <voteTallyZkeyPath>", "the vote tally zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
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
+ messageProcessorZkeyPath: args.messageProcessorZkey,
172
+ voteTallyZkeyPath: args.voteTallyZkey,
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,8 +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")
327
- .option("-i, --state-index <stateIndex>", "the user's state index", BigInt)
340
+ .requiredOption("-k, --private-key <privateKey>", "the private key")
328
341
  .option("-s, --sg-data <sgData>", "the signup policy data")
329
342
  .option("-v, --ivcp-data <ivcpData>", "the initial voice credit proxy data")
330
343
  .option("-n, --new-voice-credit-balance <newVoiceCreditBalance>", "the voice credit balance of the user for the poll", BigInt)
@@ -340,38 +353,37 @@ program
340
353
  .requiredOption("--poll-joining-zkey <pollZkeyPath>", "the poll join zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
341
354
  .option("-w, --wasm", "whether to use the wasm binaries")
342
355
  .option("-r, --rapidsnark <rapidsnark>", "the path to the rapidsnark binary")
343
- .option("-g, --poll-witnessgen <pollWitnessgen>", "the path to the poll witness generation binary")
344
- .action(async (cmdObj) => {
356
+ .option("-g, --poll-witness-generator <pollWitnessGenerator>", "the path to the poll witness generation binary")
357
+ .action(async (args) => {
345
358
  try {
346
359
  const signer = await getSigner();
347
360
  const network = await signer.provider?.getNetwork();
348
361
  const [maciAddress] = (0, utils_1.readContractAddresses)({
349
362
  contractNames: [sdk_1.EContracts.MACI],
350
363
  network: network?.name,
351
- defaultAddresses: [cmdObj.maciAddress],
364
+ defaultAddresses: [args.maciAddress],
352
365
  });
353
- const privateKey = cmdObj.privKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
366
+ const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
354
367
  const data = await (0, sdk_1.joinPoll)({
355
368
  maciAddress,
356
369
  privateKey,
357
- stateIndex: cmdObj.stateIndex,
358
- stateFile: cmdObj.stateFile,
359
- pollId: cmdObj.pollId,
370
+ stateFile: args.stateFile,
371
+ pollId: args.pollId,
360
372
  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`) });
373
+ startBlock: args.startBlock,
374
+ endBlock: args.endBlock,
375
+ blocksPerBatch: args.blocksPerBatch,
376
+ pollJoiningZkey: args.pollJoiningZkey,
377
+ pollWasm: args.pollWasm,
378
+ useWasm: args.wasm,
379
+ rapidsnark: args.rapidsnark,
380
+ pollWitnessGenerator: args.pollWitnessGenerator,
381
+ sgDataArg: args.sgData ?? utils_1.DEFAULT_SG_DATA,
382
+ ivcpDataArg: args.ivcpData ?? utils_1.DEFAULT_IVCP_DATA,
383
+ });
384
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with nullifier: ${data.nullifier}`) });
385
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with state index: ${data.pollStateIndex}`) });
386
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with ${data.voiceCredits} voice credits`) });
375
387
  }
376
388
  catch (error) {
377
389
  program.error(error.message, { exitCode: 1 });
@@ -381,47 +393,59 @@ program
381
393
  .command("setVerifyingKeys")
382
394
  .description("set the verifying keys")
383
395
  .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)
396
+ .requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the intermediate state tree depth", parseInt)
385
397
  .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)
398
+ .requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
399
+ .option("--poll-state-tree-depth <pollStateTreeDepth>", "the poll state tree depth", parseInt)
387
400
  .option("--poll-joining-zkey <pollJoiningZkeyPath>", "the poll joining zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
388
401
  .option("--poll-joined-zkey <pollJoinedZkeyPath>", "the poll joined zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
389
- .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
- .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
- .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
- .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)
402
+ .option("--message-processor-zkey-qv <messageProcessorZkeyPathQv>", "the message processor qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
403
+ .option("--vote-tally-zkey-qv <voteTallyZkeyPathQv>", "the vote tally qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
404
+ .option("--message-processor-zkey-non-qv <messageProcessorZkeyPathNonQv>", "the message processor non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
405
+ .option("--vote-tally-zkey-non-qv <voteTallyZkeyPathNonQv>", "the vote tally non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
406
+ .option("--message-processor-zkey-full <messageProcessorZkeyPathFull>", "the message processor full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
407
+ .option("--vote-tally-zkey-full <tallyVotesZkeyPathFull>", "the vote tally full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
408
+ .option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
394
409
  .option("-k, --vk-registry <vkRegistry>", "the vk registry contract address")
395
410
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
396
411
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
397
- .action(async (cmdObj) => {
412
+ .action(async (args) => {
398
413
  try {
399
414
  const signer = await getSigner();
400
415
  const network = await signer.provider?.getNetwork();
401
- const [vkRegistryAddress] = (0, utils_1.readContractAddresses)({
402
- contractNames: [sdk_1.EContracts.VkRegistry],
416
+ const [verifyingKeysRegistryAddress] = (0, utils_1.readContractAddresses)({
417
+ contractNames: [sdk_1.EContracts.VerifyingKeysRegistry],
403
418
  network: network?.name,
404
- defaultAddresses: [cmdObj.vkRegistry],
419
+ defaultAddresses: [args.vkRegistry],
405
420
  });
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,
421
+ const processKeys = {
422
+ [sdk_1.EMode.QV]: args.messageProcessorZkeyQv,
423
+ [sdk_1.EMode.NON_QV]: args.messageProcessorZkeyNonQv,
424
+ [sdk_1.EMode.FULL]: args.messageProcessorZkeyFull,
425
+ };
426
+ const tallyKeys = {
427
+ [sdk_1.EMode.QV]: args.voteTallyZkeyQv,
428
+ [sdk_1.EMode.NON_QV]: args.voteTallyZkeyNonQv,
429
+ [sdk_1.EMode.FULL]: args.voteTallyZkeyFull,
430
+ };
431
+ const { pollJoiningVerifyingKey, pollJoinedVerifyingKey, processVerifyingKey, tallyVerifyingKey } = await (0, sdk_1.extractAllVerifyingKeys)({
432
+ pollJoiningZkeyPath: args.pollJoiningZkey,
433
+ pollJoinedZkeyPath: args.pollJoinedZkey,
434
+ messageProcessorZkeyPath: processKeys[args.mode],
435
+ voteTallyZkeyPath: tallyKeys[args.mode],
413
436
  });
414
437
  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,
438
+ stateTreeDepth: args.stateTreeDepth,
439
+ tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
440
+ voteOptionTreeDepth: args.voteOptionTreeDepth,
441
+ messageBatchSize: args.messageBatchSize,
442
+ pollStateTreeDepth: args.pollStateTreeDepth || args.stateTreeDepth,
443
+ pollJoiningVerifyingKey: pollJoiningVerifyingKey,
444
+ pollJoinedVerifyingKey: pollJoinedVerifyingKey,
445
+ processMessagesVerifyingKey: processVerifyingKey,
446
+ tallyVotesVerifyingKey: tallyVerifyingKey,
447
+ verifyingKeysRegistryAddress,
448
+ mode: args.mode,
425
449
  signer,
426
450
  });
427
451
  }
@@ -432,9 +456,9 @@ program
432
456
  program
433
457
  .command("publish")
434
458
  .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")
459
+ .requiredOption("-p, --public-key <publicKey>", "the MACI public key which should replace the user's public key in the state tree")
436
460
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
437
- .option("-k, --privkey <privkey>", "your serialized MACI private key")
461
+ .option("-k, --private-key <privateKey>", "your serialized MACI private key")
438
462
  .requiredOption("-i, --state-index <stateIndex>", "the user's state index", BigInt)
439
463
  .requiredOption("-v, --vote-option-index <voteOptionIndex>", "the vote option index", BigInt)
440
464
  .requiredOption("-n, --nonce <nonce>", "the message nonce", BigInt)
@@ -443,25 +467,25 @@ program
443
467
  .requiredOption("-w, --new-vote-weight <newVoteWeight>", "the new vote weight", BigInt)
444
468
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
445
469
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
446
- .action(async (cmdObj) => {
470
+ .action(async (args) => {
447
471
  try {
448
472
  const signer = await getSigner();
449
473
  const network = await signer.provider?.getNetwork();
450
474
  const [maciAddress] = (0, utils_1.readContractAddresses)({
451
475
  contractNames: [sdk_1.EContracts.MACI],
452
476
  network: network?.name,
453
- defaultAddresses: [cmdObj.maciAddress],
477
+ defaultAddresses: [args.maciAddress],
454
478
  });
455
- const privateKey = cmdObj.privkey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
479
+ const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
456
480
  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,
481
+ publicKey: args.publicKey,
482
+ stateIndex: args.stateIndex,
483
+ voteOptionIndex: args.voteOptionIndex,
484
+ nonce: args.nonce,
485
+ pollId: args.pollId,
486
+ newVoteWeight: args.newVoteWeight,
463
487
  maciAddress,
464
- salt: cmdObj.salt,
488
+ salt: args.salt,
465
489
  privateKey,
466
490
  signer,
467
491
  });
@@ -476,23 +500,23 @@ program
476
500
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
477
501
  .option("-x, --maci-address <maciAddress>", "the MACI contract address")
478
502
  .requiredOption("-p, --poll-id <pollId>", "the poll id", BigInt)
479
- .action(async (cmdObj) => {
503
+ .action(async (args) => {
480
504
  try {
481
505
  const signer = await getSigner();
482
506
  const network = await signer.provider?.getNetwork();
483
507
  const [maciAddress] = (0, utils_1.readContractAddresses)({
484
508
  contractNames: [sdk_1.EContracts.MACI],
485
509
  network: network?.name,
486
- defaultAddresses: [cmdObj.maciAddress],
510
+ defaultAddresses: [args.maciAddress],
487
511
  });
488
512
  const receipt = await (0, sdk_1.mergeSignups)({
489
- pollId: cmdObj.pollId,
513
+ pollId: args.pollId,
490
514
  maciAddress,
491
515
  signer,
492
516
  });
493
- (0, sdk_1.logGreen)({ quiet: cmdObj.quiet, text: (0, sdk_1.info)(`Transaction hash: ${receipt.hash}`) });
517
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`Transaction hash: ${receipt.hash}`) });
494
518
  (0, sdk_1.logGreen)({
495
- quiet: cmdObj.quiet,
519
+ quiet: args.quiet,
496
520
  text: (0, sdk_1.success)(`Executed mergeSignups(); gas used: ${receipt.gasUsed.toString()}`),
497
521
  });
498
522
  }
@@ -506,37 +530,39 @@ program
506
530
  .requiredOption("-s, --seconds <seconds>", "the number of seconds to fast-forward", parseInt)
507
531
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
508
532
  .option("-r, --rpc-provider <provider>", "the rpc provider URL")
509
- .action(async (cmdObj) => {
533
+ .action(async (args) => {
510
534
  try {
511
- (0, utils_1.banner)(cmdObj.quiet);
535
+ (0, utils_1.banner)(args.quiet);
512
536
  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`) });
537
+ await (0, sdk_1.timeTravel)({ seconds: args.seconds, signer });
538
+ (0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Fast-forwarded ${args.seconds} seconds`) });
515
539
  }
516
540
  catch (error) {
517
541
  program.error(error.message, { exitCode: 1 });
518
542
  }
519
543
  });
520
544
  program
521
- .command("extractVkToFile")
545
+ .command("extractVerifyingKeyToFile")
522
546
  .description("extract vkey to json file")
523
547
  .requiredOption("--poll-joining-zkey <pollJoiningZkey>", "the poll joining zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
524
548
  .requiredOption("--poll-joined-zkey <pollJoinedZkey>", "the poll joined zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
525
- .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)")
526
- .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)")
527
- .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
- .requiredOption("--tally-votes-zkey-non-qv <tallyVotesZkeyPathNonQv>", "the tally votes non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
549
+ .requiredOption("--message-processor-zkey-qv <messageProcessorZkeyPathQv>", "the message processor qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
550
+ .requiredOption("--vote-tally-zkey-qv <voteTallyZkeyPathQv>", "the vote tally qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
551
+ .requiredOption("--message-processor-zkey-non-qv <messageProcessorZkeyPathNonQv>", "the message processor non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
552
+ .requiredOption("--message-processor-zkey-full <messageProcessorZkeyPathFull>", "the message processor full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
553
+ .requiredOption("--vote-tally-zkey-non-qv <voteTallyZkeyPathNonQv>", "the vote tally non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
529
554
  .requiredOption("-o, --output-file <outputFile>", "the output file path of extracted vkeys")
530
- .action(async (cmdObj) => {
555
+ .action(async (args) => {
531
556
  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,
557
+ await (0, sdk_1.extractVerifyingKeyToFile)({
558
+ messageProcessorZkeyPathQv: args.messageProcessorZkeyQv,
559
+ messageProcessorZkeyPathFull: args.messageProcessorZkeyFull,
560
+ voteTallyZkeyPathQv: args.voteTallyZkeyQv,
561
+ messageProcessorZkeyPathNonQv: args.messageProcessorZkeyNonQv,
562
+ voteTallyZkeyPathNonQv: args.voteTallyZkeyNonQv,
563
+ pollJoiningZkeyPath: args.pollJoiningZkey,
564
+ pollJoinedZkeyPath: args.pollJoinedZkey,
565
+ outputFilePath: args.outputFile,
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,34 +781,34 @@ 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")
759
790
  .option("-r, --rapidsnark <rapidsnark>", "the path to the rapidsnark binary")
760
- .option("-g, --process-witnessgen <processWitnessgen>", "the path to the process witness generation binary")
761
- .option("--process-witnessdat <processWitnessdat>", "the path to the process witness dat file")
762
- .option("--tally-witnessgen <tallyWitnessgen>", "the path to the tally witness generation binary")
763
- .option("--tally-witnessdat <tallyWitnessdat>", "the path to the tally witness dat file")
791
+ .option("-g, --message-processor-witness-generator <messageProcessorWitnessGenerator>", "the path to the process witness generation binary")
792
+ .option("--message-processor-witnessDat <messageProcessorWitnessDat>", "the path to the process witness dat file")
793
+ .option("--vote-tally-witness-generator <voteTallyWitnessGenerator>", "the path to the tally witness generation binary")
794
+ .option("--vote-tally-witnessDat <voteTallyWitnessDat>", "the path to the tally witness dat file")
764
795
  .requiredOption("--poll-joining-zkey <processJoinZkey>", "the path to the poll join zkey")
765
- .requiredOption("--process-zkey <processZkey>", "the path to the process zkey")
766
- .requiredOption("--tally-zkey <tallyZkey>", "the path to the tally zkey")
796
+ .requiredOption("--message-processor-zkey <messageProcessorZkey>", "the path to the process zkey")
797
+ .requiredOption("--vote-tally-zkey <voteTallyZkey>", "the path to the tally zkey")
767
798
  .option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
768
799
  .option("-p, --rpc-provider <provider>", "the rpc provider URL")
769
800
  .requiredOption("-f, --output <outputDir>", "the output directory for proofs")
770
801
  .option("--transaction-hash <transactionHash>", "transaction hash of MACI contract creation")
771
802
  .option("-w, --wasm", "whether to use the wasm binaries")
772
- .option("--process-wasm <processWasm>", "the path to the process witness generation wasm binary")
773
- .option("--tally-wasm <tallyWasm>", "the path to the tally witness generation wasm binary")
803
+ .option("--message-processor-wasm <messageProcessorWasm>", "the path to the process witness generation wasm binary")
804
+ .option("--vote-tally-wasm <voteTallyWasm>", "the path to the tally witness generation wasm binary")
774
805
  .option("--state-file <stateFile>", "the path to the state file containing the serialized maci state")
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, voteTallyZkey, voteTallyWitnessGenerator, voteTallyWasm, messageProcessorZkey, messageProcessorWitnessGenerator, messageProcessorWasm, mode, voteTallyWitnessDat, messageProcessorWitnessDat, 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,
@@ -801,15 +832,15 @@ program
801
832
  signer,
802
833
  outputDir: output,
803
834
  tallyFile,
804
- tallyZkey,
805
- tallyWitgen: tallyWitnessgen,
806
- tallyWasm,
807
- processZkey,
808
- processWitgen: processWitnessgen,
809
- processWasm,
810
- useQuadraticVoting,
811
- tallyDatFile: tallyWitnessdat,
812
- processDatFile: processWitnessdat,
835
+ voteTallyZkey,
836
+ voteTallyWitnessGenerator,
837
+ voteTallyWasm,
838
+ messageProcessorZkey,
839
+ messageProcessorWitnessGenerator,
840
+ messageProcessorWasm,
841
+ mode,
842
+ voteTallyWitnessDatFile: voteTallyWitnessDat,
843
+ messageProcessorWitnessDatFile: messageProcessorWitnessDat,
813
844
  useWasm: wasm,
814
845
  rapidsnark,
815
846
  });
@@ -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
  });