@maci-protocol/cli 0.0.0-ci.6c23c43 → 0.0.0-ci.6ccbb3c
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 +201 -200
- package/build/ts/index.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
package/build/ts/index.js
CHANGED
|
@@ -66,25 +66,25 @@ program
|
|
|
66
66
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
67
67
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
68
68
|
.requiredOption("-s, --stateTreeDepth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
69
|
-
.action(async (
|
|
69
|
+
.action(async (args) => {
|
|
70
70
|
try {
|
|
71
71
|
const signer = await getSigner();
|
|
72
|
-
(0, utils_1.banner)(
|
|
72
|
+
(0, utils_1.banner)(args.quiet);
|
|
73
73
|
const network = await signer.provider?.getNetwork();
|
|
74
74
|
const [poseidonT3, poseidonT4, poseidonT5, poseidonT6] = (0, utils_1.readContractAddresses)({
|
|
75
75
|
contractNames: [sdk_1.EContracts.PoseidonT3, sdk_1.EContracts.PoseidonT4, sdk_1.EContracts.PoseidonT5, sdk_1.EContracts.PoseidonT6],
|
|
76
76
|
network: network?.name,
|
|
77
77
|
});
|
|
78
78
|
let [signupPolicyContractAddress] = (0, utils_1.readContractAddresses)({
|
|
79
|
-
contractNames: [
|
|
79
|
+
contractNames: [args.signupPolicyContractName.toString()],
|
|
80
80
|
network: network?.name,
|
|
81
81
|
});
|
|
82
82
|
if (!signupPolicyContractAddress) {
|
|
83
|
-
const checkerFactory =
|
|
84
|
-
? sdk_1.FreeForAllCheckerFactory__factory.connect(
|
|
83
|
+
const checkerFactory = args.freeForAllCheckerFactoryAddress
|
|
84
|
+
? sdk_1.FreeForAllCheckerFactory__factory.connect(args.freeForAllCheckerFactoryAddress, signer)
|
|
85
85
|
: undefined;
|
|
86
|
-
const policyFactory =
|
|
87
|
-
? sdk_1.FreeForAllPolicyFactory__factory.connect(
|
|
86
|
+
const policyFactory = args.freeForAllPolicyFactoryAddress
|
|
87
|
+
? sdk_1.FreeForAllPolicyFactory__factory.connect(args.freeForAllPolicyFactoryAddress, signer)
|
|
88
88
|
: undefined;
|
|
89
89
|
const [contract] = await (0, sdk_1.deployFreeForAllSignUpPolicy)({ checker: checkerFactory, policy: policyFactory }, signer, true);
|
|
90
90
|
signupPolicyContractAddress = await contract.getAddress();
|
|
@@ -102,13 +102,13 @@ program
|
|
|
102
102
|
poseidonT6,
|
|
103
103
|
},
|
|
104
104
|
signer,
|
|
105
|
-
stateTreeDepth:
|
|
105
|
+
stateTreeDepth: args.stateTreeDepth,
|
|
106
106
|
});
|
|
107
|
-
const emptyBallotRoots = (0, sdk_1.
|
|
107
|
+
const emptyBallotRoots = (0, sdk_1.generateEmptyBallotRoots)(args.stateTreeDepth);
|
|
108
108
|
// save to the JSON File
|
|
109
109
|
await (0, utils_1.storeContractAddresses)({
|
|
110
110
|
data: {
|
|
111
|
-
[
|
|
111
|
+
[args.signupPolicyContractName]: { address: signupPolicyContractAddress, args: [] },
|
|
112
112
|
[sdk_1.EContracts.Verifier]: { address: verifierContractAddress, args: [] },
|
|
113
113
|
[sdk_1.EContracts.MACI]: {
|
|
114
114
|
address: maciContractAddress,
|
|
@@ -117,7 +117,7 @@ program
|
|
|
117
117
|
messageProcessorFactoryContractAddress,
|
|
118
118
|
tallyFactoryContractAddress,
|
|
119
119
|
signupPolicyContractAddress,
|
|
120
|
-
|
|
120
|
+
args.stateTreeDepth,
|
|
121
121
|
emptyBallotRoots.map((root) => root.toString()),
|
|
122
122
|
],
|
|
123
123
|
},
|
|
@@ -131,7 +131,7 @@ program
|
|
|
131
131
|
},
|
|
132
132
|
signer,
|
|
133
133
|
});
|
|
134
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
134
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`MACI deployed at: ${maciContractAddress}`) });
|
|
135
135
|
}
|
|
136
136
|
catch (error) {
|
|
137
137
|
program.error(error.message, { exitCode: 1 });
|
|
@@ -143,7 +143,7 @@ program
|
|
|
143
143
|
.option("-u, --use-quadratic-voting <useQuadraticVoting>", "whether to use quadratic voting", (value) => value === "true", true)
|
|
144
144
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
145
145
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
146
|
-
.option("-k, --vk-contract <vkContract>", "the
|
|
146
|
+
.option("-k, --vk-contract <vkContract>", "the VerifyingKeysRegistry contract address")
|
|
147
147
|
.requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
148
148
|
.requiredOption("-i, --int-state-tree-depth <intStateTreeDepth>", "the intermediate state tree depth", parseInt)
|
|
149
149
|
.requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
|
|
@@ -152,63 +152,63 @@ program
|
|
|
152
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)")
|
|
153
153
|
.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
154
|
.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 (
|
|
155
|
+
.action(async (args) => {
|
|
156
156
|
try {
|
|
157
157
|
const signer = await getSigner();
|
|
158
158
|
const network = await signer.provider?.getNetwork();
|
|
159
|
-
const [
|
|
160
|
-
contractNames: [sdk_1.EContracts.
|
|
159
|
+
const [contractAddress] = (0, utils_1.readContractAddresses)({
|
|
160
|
+
contractNames: [sdk_1.EContracts.VerifyingKeysRegistry],
|
|
161
161
|
network: network?.name,
|
|
162
|
-
defaultAddresses: [
|
|
162
|
+
defaultAddresses: [args.vkContract],
|
|
163
163
|
});
|
|
164
|
-
(0, sdk_1.logYellow)({ quiet:
|
|
164
|
+
(0, sdk_1.logYellow)({ quiet: args.quiet, text: (0, sdk_1.info)("Retrieving verifying keys from the contract...") });
|
|
165
165
|
await (0, sdk_1.checkVerifyingKeys)({
|
|
166
|
-
stateTreeDepth:
|
|
167
|
-
intStateTreeDepth:
|
|
168
|
-
voteOptionTreeDepth:
|
|
169
|
-
messageBatchSize:
|
|
170
|
-
processMessagesZkeyPath:
|
|
171
|
-
tallyVotesZkeyPath:
|
|
172
|
-
pollJoiningZkeyPath:
|
|
173
|
-
pollJoinedZkeyPath:
|
|
174
|
-
|
|
175
|
-
useQuadraticVoting:
|
|
166
|
+
stateTreeDepth: args.stateTreeDepth,
|
|
167
|
+
intStateTreeDepth: args.intStateTreeDepth,
|
|
168
|
+
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
169
|
+
messageBatchSize: args.messageBatchSize,
|
|
170
|
+
processMessagesZkeyPath: args.processMessagesZkey,
|
|
171
|
+
tallyVotesZkeyPath: args.tallyVotesZkey,
|
|
172
|
+
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
173
|
+
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
174
|
+
verifyingKeysRegistry: contractAddress,
|
|
175
|
+
useQuadraticVoting: args.useQuadraticVoting,
|
|
176
176
|
signer,
|
|
177
177
|
});
|
|
178
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
178
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)("Verifying keys match") });
|
|
179
179
|
}
|
|
180
180
|
catch (error) {
|
|
181
181
|
program.error(error.message, { exitCode: 1 });
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
184
|
program
|
|
185
|
-
.command("
|
|
185
|
+
.command("generateMaciPubKey")
|
|
186
186
|
.description("generate a new MACI public key")
|
|
187
187
|
.requiredOption("-k, --private-key <privateKey>", "the private key")
|
|
188
188
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
189
189
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
190
|
-
.action((
|
|
191
|
-
const publicKey = (0, sdk_1.generateMaciPublicKey)(
|
|
192
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
190
|
+
.action((args) => {
|
|
191
|
+
const publicKey = (0, sdk_1.generateMaciPublicKey)(args.privateKey);
|
|
192
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Public key: ${publicKey}`) });
|
|
193
193
|
});
|
|
194
194
|
program
|
|
195
|
-
.command("
|
|
195
|
+
.command("generateMaciKeyPair")
|
|
196
196
|
.description("generate a new MACI key pair")
|
|
197
197
|
.option("-s, --seed <seed>", "seed value for keypair", (value) => (value ? BigInt(value) : undefined), undefined)
|
|
198
198
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
199
|
-
.action((
|
|
200
|
-
const { publicKey, privateKey } = (0, sdk_1.generateKeypair)({ seed:
|
|
201
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
202
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
199
|
+
.action((args) => {
|
|
200
|
+
const { publicKey, privateKey } = (0, sdk_1.generateKeypair)({ seed: args.seed });
|
|
201
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Public key: ${publicKey}`) });
|
|
202
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Private key: ${privateKey}`) });
|
|
203
203
|
});
|
|
204
204
|
program
|
|
205
|
-
.command("
|
|
205
|
+
.command("deployVerifyingKeysRegistry")
|
|
206
206
|
.description("deploy a new verification key registry contract")
|
|
207
207
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
208
208
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
209
|
-
.action(async (
|
|
209
|
+
.action(async (args) => {
|
|
210
210
|
try {
|
|
211
|
-
(0, utils_1.banner)(
|
|
211
|
+
(0, utils_1.banner)(args.quiet);
|
|
212
212
|
const signer = await getSigner();
|
|
213
213
|
// assume that the vkRegistry contract is the first one to be deployed
|
|
214
214
|
const isContractAddressesStoreExists = fs_1.default.existsSync(utils_1.contractAddressesStorePath);
|
|
@@ -217,12 +217,15 @@ program
|
|
|
217
217
|
(0, utils_1.resetContractAddresses)(network?.name);
|
|
218
218
|
}
|
|
219
219
|
// deploy and store the address
|
|
220
|
-
const
|
|
220
|
+
const verifyingKeysRegistryAddress = await (0, sdk_1.deployVerifyingKeysRegistryContract)({ signer });
|
|
221
221
|
await (0, utils_1.storeContractAddresses)({
|
|
222
|
-
data: { [sdk_1.EContracts.
|
|
222
|
+
data: { [sdk_1.EContracts.VerifyingKeysRegistry]: { address: verifyingKeysRegistryAddress, args: [] } },
|
|
223
223
|
signer,
|
|
224
224
|
});
|
|
225
|
-
(0, sdk_1.logGreen)({
|
|
225
|
+
(0, sdk_1.logGreen)({
|
|
226
|
+
quiet: args.quiet,
|
|
227
|
+
text: (0, sdk_1.success)(`VerifyingKeysRegistry deployed at: ${verifyingKeysRegistryAddress}`),
|
|
228
|
+
});
|
|
226
229
|
}
|
|
227
230
|
catch (error) {
|
|
228
231
|
program.error(error.message, { exitCode: 1 });
|
|
@@ -249,9 +252,9 @@ program
|
|
|
249
252
|
program
|
|
250
253
|
.command("deployPoll")
|
|
251
254
|
.description("deploy a new poll")
|
|
252
|
-
.option("-k, --
|
|
253
|
-
.requiredOption("
|
|
254
|
-
.requiredOption("
|
|
255
|
+
.option("-k, --verifyingKeysRegistryAddress <verifyingKeysRegistryAddress>", "the vk registry contract address")
|
|
256
|
+
.requiredOption("--start <pollStartDate>", "the poll start date", parseInt)
|
|
257
|
+
.requiredOption("--end <pollEndDate>", "the poll end date", parseInt)
|
|
255
258
|
.requiredOption("-i, --int-state-tree-depth <intStateTreeDepth>", "the int state tree depth", parseInt)
|
|
256
259
|
.requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
|
|
257
260
|
.requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
@@ -266,20 +269,20 @@ program
|
|
|
266
269
|
.option("--initial-voice-credits <initialVoiceCredits>", "the initial voice credits", parseInt)
|
|
267
270
|
.option("--initial-voice-credits-proxy <initialVoiceCreditsProxy>", "the initial voice credits proxy address")
|
|
268
271
|
.option("--signup-policy <signupPolicy>", "the signup policy contract address")
|
|
269
|
-
.action(async (
|
|
272
|
+
.action(async (args) => {
|
|
270
273
|
try {
|
|
271
|
-
(0, utils_1.banner)(
|
|
274
|
+
(0, utils_1.banner)(args.quiet);
|
|
272
275
|
const signer = await getSigner();
|
|
273
276
|
const network = await signer.provider?.getNetwork();
|
|
274
|
-
const [
|
|
277
|
+
const [verifyingKeysRegistryAddress, maciAddress, initialVoiceCreditProxyAddress, verifierContractAddress] = (0, utils_1.readContractAddresses)({
|
|
275
278
|
contractNames: [
|
|
276
|
-
sdk_1.EContracts.
|
|
279
|
+
sdk_1.EContracts.VerifyingKeysRegistry,
|
|
277
280
|
sdk_1.EContracts.MACI,
|
|
278
281
|
sdk_1.EContracts.ConstantInitialVoiceCreditProxy,
|
|
279
282
|
sdk_1.EContracts.Verifier,
|
|
280
283
|
],
|
|
281
284
|
network: network?.name,
|
|
282
|
-
defaultAddresses: [
|
|
285
|
+
defaultAddresses: [args.verifyingKeysRegistryAddress, args.maciAddress, args.initialVoiceCreditsProxy],
|
|
283
286
|
});
|
|
284
287
|
const maciContract = sdk_1.MACI__factory.connect(maciAddress, signer);
|
|
285
288
|
const nextPollId = await maciContract.nextPollId();
|
|
@@ -289,40 +292,40 @@ program
|
|
|
289
292
|
contractNames: [policyContractName.toString()],
|
|
290
293
|
keys: [nextPollId.toString()],
|
|
291
294
|
network: network?.name,
|
|
292
|
-
defaultAddresses: [
|
|
295
|
+
defaultAddresses: [args.signupPolicy],
|
|
293
296
|
});
|
|
294
297
|
const { pollId, pollContractAddress, tallyContractAddress, messageProcessorContractAddress, initialVoiceCreditProxyContractAddress, policyContractAddress, } = await (0, sdk_1.deployPoll)({
|
|
295
|
-
initialVoiceCredits:
|
|
296
|
-
pollStartTimestamp:
|
|
297
|
-
pollEndTimestamp:
|
|
298
|
-
intStateTreeDepth:
|
|
299
|
-
messageBatchSize:
|
|
300
|
-
stateTreeDepth:
|
|
301
|
-
voteOptionTreeDepth:
|
|
302
|
-
coordinatorPublicKey: domainobjs_1.PublicKey.deserialize(
|
|
298
|
+
initialVoiceCredits: args.initialVoiceCredits || defaults_1.DEFAULT_INITIAL_VOICE_CREDITS,
|
|
299
|
+
pollStartTimestamp: args.start,
|
|
300
|
+
pollEndTimestamp: args.end,
|
|
301
|
+
intStateTreeDepth: args.intStateTreeDepth,
|
|
302
|
+
messageBatchSize: args.messageBatchSize,
|
|
303
|
+
stateTreeDepth: args.stateTreeDepth,
|
|
304
|
+
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
305
|
+
coordinatorPublicKey: domainobjs_1.PublicKey.deserialize(args.publicKey),
|
|
303
306
|
maciAddress,
|
|
304
|
-
|
|
305
|
-
relayers:
|
|
306
|
-
mode:
|
|
307
|
+
verifyingKeysRegistryContractAddress: verifyingKeysRegistryAddress,
|
|
308
|
+
relayers: args.relayers ?? [ethers_1.ZeroAddress],
|
|
309
|
+
mode: args.useQuadraticVoting ? sdk_1.EMode.QV : sdk_1.EMode.NON_QV,
|
|
307
310
|
signer,
|
|
308
|
-
voteOptions:
|
|
311
|
+
voteOptions: args.voteOptions ?? defaults_1.DEFAULT_VOTE_OPTIONS,
|
|
309
312
|
verifierContractAddress,
|
|
310
313
|
policyContractAddress: signupPolicyContractAddress,
|
|
311
314
|
initialVoiceCreditProxyContractAddress: initialVoiceCreditProxyAddress,
|
|
312
315
|
});
|
|
313
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
314
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
315
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
316
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Poll ID: ${pollId}`) });
|
|
317
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Poll contract address: ${pollContractAddress}`) });
|
|
318
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Tally contract address: ${tallyContractAddress}`) });
|
|
316
319
|
(0, sdk_1.logGreen)({
|
|
317
|
-
quiet:
|
|
320
|
+
quiet: args.quiet,
|
|
318
321
|
text: (0, sdk_1.success)(`Message processor contract address: ${messageProcessorContractAddress}`),
|
|
319
322
|
});
|
|
320
323
|
(0, sdk_1.logGreen)({
|
|
321
|
-
quiet:
|
|
324
|
+
quiet: args.quiet,
|
|
322
325
|
text: (0, sdk_1.success)(`Initial voice credit proxy contract address: ${initialVoiceCreditProxyContractAddress}`),
|
|
323
326
|
});
|
|
324
327
|
(0, sdk_1.logGreen)({
|
|
325
|
-
quiet:
|
|
328
|
+
quiet: args.quiet,
|
|
326
329
|
text: (0, sdk_1.success)(`Signup policy contract address: ${policyContractAddress}`),
|
|
327
330
|
});
|
|
328
331
|
}
|
|
@@ -351,37 +354,37 @@ program
|
|
|
351
354
|
.option("-w, --wasm", "whether to use the wasm binaries")
|
|
352
355
|
.option("-r, --rapidsnark <rapidsnark>", "the path to the rapidsnark binary")
|
|
353
356
|
.option("-g, --poll-witnessgen <pollWitnessgen>", "the path to the poll witness generation binary")
|
|
354
|
-
.action(async (
|
|
357
|
+
.action(async (args) => {
|
|
355
358
|
try {
|
|
356
359
|
const signer = await getSigner();
|
|
357
360
|
const network = await signer.provider?.getNetwork();
|
|
358
361
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
359
362
|
contractNames: [sdk_1.EContracts.MACI],
|
|
360
363
|
network: network?.name,
|
|
361
|
-
defaultAddresses: [
|
|
364
|
+
defaultAddresses: [args.maciAddress],
|
|
362
365
|
});
|
|
363
|
-
const privateKey =
|
|
366
|
+
const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
|
|
364
367
|
const data = await (0, sdk_1.joinPoll)({
|
|
365
368
|
maciAddress,
|
|
366
369
|
privateKey,
|
|
367
|
-
stateIndex:
|
|
368
|
-
stateFile:
|
|
369
|
-
pollId:
|
|
370
|
+
stateIndex: args.stateIndex,
|
|
371
|
+
stateFile: args.stateFile,
|
|
372
|
+
pollId: args.pollId,
|
|
370
373
|
signer,
|
|
371
|
-
startBlock:
|
|
372
|
-
endBlock:
|
|
373
|
-
blocksPerBatch:
|
|
374
|
-
pollJoiningZkey:
|
|
375
|
-
pollWasm:
|
|
376
|
-
useWasm:
|
|
377
|
-
rapidsnark:
|
|
378
|
-
pollWitgen:
|
|
379
|
-
sgDataArg:
|
|
380
|
-
ivcpDataArg:
|
|
381
|
-
});
|
|
382
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
383
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
384
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
374
|
+
startBlock: args.startBlock,
|
|
375
|
+
endBlock: args.endBlock,
|
|
376
|
+
blocksPerBatch: args.blocksPerBatch,
|
|
377
|
+
pollJoiningZkey: args.pollJoiningZkey,
|
|
378
|
+
pollWasm: args.pollWasm,
|
|
379
|
+
useWasm: args.wasm,
|
|
380
|
+
rapidsnark: args.rapidsnark,
|
|
381
|
+
pollWitgen: args.pollWitnessgen,
|
|
382
|
+
sgDataArg: args.sgData ?? utils_1.DEFAULT_SG_DATA,
|
|
383
|
+
ivcpDataArg: args.ivcpData ?? utils_1.DEFAULT_IVCP_DATA,
|
|
384
|
+
});
|
|
385
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with nullifier: ${data.nullifier}`) });
|
|
386
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with state index: ${data.pollStateIndex}`) });
|
|
387
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with ${data.voiceCredits} voice credits`) });
|
|
385
388
|
}
|
|
386
389
|
catch (error) {
|
|
387
390
|
program.error(error.message, { exitCode: 1 });
|
|
@@ -405,35 +408,33 @@ program
|
|
|
405
408
|
.option("-k, --vk-registry <vkRegistry>", "the vk registry contract address")
|
|
406
409
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
407
410
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
408
|
-
.action(async (
|
|
411
|
+
.action(async (args) => {
|
|
409
412
|
try {
|
|
410
413
|
const signer = await getSigner();
|
|
411
414
|
const network = await signer.provider?.getNetwork();
|
|
412
|
-
const [
|
|
413
|
-
contractNames: [sdk_1.EContracts.
|
|
415
|
+
const [verifyingKeysRegistryAddress] = (0, utils_1.readContractAddresses)({
|
|
416
|
+
contractNames: [sdk_1.EContracts.VerifyingKeysRegistry],
|
|
414
417
|
network: network?.name,
|
|
415
|
-
defaultAddresses: [
|
|
418
|
+
defaultAddresses: [args.vkRegistry],
|
|
416
419
|
});
|
|
417
|
-
const {
|
|
418
|
-
pollJoiningZkeyPath:
|
|
419
|
-
pollJoinedZkeyPath:
|
|
420
|
-
processMessagesZkeyPath:
|
|
421
|
-
|
|
422
|
-
: cmdObj.processMessagesZkeyNonQv,
|
|
423
|
-
tallyVotesZkeyPath: cmdObj.useQuadraticVoting ? cmdObj.tallyVotesZkeyQv : cmdObj.tallyVotesZkeyQv,
|
|
420
|
+
const { pollJoiningVerifyingKey, pollJoinedVerifyingKey, processVerifyingKey, tallyVerifyingKey } = await (0, sdk_1.extractAllVerifyingKeys)({
|
|
421
|
+
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
422
|
+
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
423
|
+
processMessagesZkeyPath: args.useQuadraticVoting ? args.processMessagesZkeyQv : args.processMessagesZkeyNonQv,
|
|
424
|
+
tallyVotesZkeyPath: args.useQuadraticVoting ? args.tallyVotesZkeyQv : args.tallyVotesZkeyQv,
|
|
424
425
|
});
|
|
425
426
|
await (0, sdk_1.setVerifyingKeys)({
|
|
426
|
-
stateTreeDepth:
|
|
427
|
-
intStateTreeDepth:
|
|
428
|
-
voteOptionTreeDepth:
|
|
429
|
-
messageBatchSize:
|
|
430
|
-
pollStateTreeDepth:
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
mode:
|
|
427
|
+
stateTreeDepth: args.stateTreeDepth,
|
|
428
|
+
intStateTreeDepth: args.intStateTreeDepth,
|
|
429
|
+
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
430
|
+
messageBatchSize: args.messageBatchSize,
|
|
431
|
+
pollStateTreeDepth: args.pollStateTreeDepth || args.stateTreeDepth,
|
|
432
|
+
pollJoiningVerifyingKey: pollJoiningVerifyingKey,
|
|
433
|
+
pollJoinedVerifyingKey: pollJoinedVerifyingKey,
|
|
434
|
+
processMessagesVerifyingKey: processVerifyingKey,
|
|
435
|
+
tallyVotesVerifyingKey: tallyVerifyingKey,
|
|
436
|
+
verifyingKeysRegistryAddress,
|
|
437
|
+
mode: args.useQuadraticVoting ? sdk_1.EMode.QV : sdk_1.EMode.NON_QV,
|
|
437
438
|
signer,
|
|
438
439
|
});
|
|
439
440
|
}
|
|
@@ -455,25 +456,25 @@ program
|
|
|
455
456
|
.requiredOption("-w, --new-vote-weight <newVoteWeight>", "the new vote weight", BigInt)
|
|
456
457
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
457
458
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
458
|
-
.action(async (
|
|
459
|
+
.action(async (args) => {
|
|
459
460
|
try {
|
|
460
461
|
const signer = await getSigner();
|
|
461
462
|
const network = await signer.provider?.getNetwork();
|
|
462
463
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
463
464
|
contractNames: [sdk_1.EContracts.MACI],
|
|
464
465
|
network: network?.name,
|
|
465
|
-
defaultAddresses: [
|
|
466
|
+
defaultAddresses: [args.maciAddress],
|
|
466
467
|
});
|
|
467
|
-
const privateKey =
|
|
468
|
+
const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
|
|
468
469
|
await (0, sdk_1.publish)({
|
|
469
|
-
publicKey:
|
|
470
|
-
stateIndex:
|
|
471
|
-
voteOptionIndex:
|
|
472
|
-
nonce:
|
|
473
|
-
pollId:
|
|
474
|
-
newVoteWeight:
|
|
470
|
+
publicKey: args.publicKey,
|
|
471
|
+
stateIndex: args.stateIndex,
|
|
472
|
+
voteOptionIndex: args.voteOptionIndex,
|
|
473
|
+
nonce: args.nonce,
|
|
474
|
+
pollId: args.pollId,
|
|
475
|
+
newVoteWeight: args.newVoteWeight,
|
|
475
476
|
maciAddress,
|
|
476
|
-
salt:
|
|
477
|
+
salt: args.salt,
|
|
477
478
|
privateKey,
|
|
478
479
|
signer,
|
|
479
480
|
});
|
|
@@ -488,23 +489,23 @@ program
|
|
|
488
489
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
489
490
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
490
491
|
.requiredOption("-p, --poll-id <pollId>", "the poll id", BigInt)
|
|
491
|
-
.action(async (
|
|
492
|
+
.action(async (args) => {
|
|
492
493
|
try {
|
|
493
494
|
const signer = await getSigner();
|
|
494
495
|
const network = await signer.provider?.getNetwork();
|
|
495
496
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
496
497
|
contractNames: [sdk_1.EContracts.MACI],
|
|
497
498
|
network: network?.name,
|
|
498
|
-
defaultAddresses: [
|
|
499
|
+
defaultAddresses: [args.maciAddress],
|
|
499
500
|
});
|
|
500
501
|
const receipt = await (0, sdk_1.mergeSignups)({
|
|
501
|
-
pollId:
|
|
502
|
+
pollId: args.pollId,
|
|
502
503
|
maciAddress,
|
|
503
504
|
signer,
|
|
504
505
|
});
|
|
505
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
506
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`Transaction hash: ${receipt.hash}`) });
|
|
506
507
|
(0, sdk_1.logGreen)({
|
|
507
|
-
quiet:
|
|
508
|
+
quiet: args.quiet,
|
|
508
509
|
text: (0, sdk_1.success)(`Executed mergeSignups(); gas used: ${receipt.gasUsed.toString()}`),
|
|
509
510
|
});
|
|
510
511
|
}
|
|
@@ -518,19 +519,19 @@ program
|
|
|
518
519
|
.requiredOption("-s, --seconds <seconds>", "the number of seconds to fast-forward", parseInt)
|
|
519
520
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
520
521
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
521
|
-
.action(async (
|
|
522
|
+
.action(async (args) => {
|
|
522
523
|
try {
|
|
523
|
-
(0, utils_1.banner)(
|
|
524
|
+
(0, utils_1.banner)(args.quiet);
|
|
524
525
|
const signer = await getSigner();
|
|
525
|
-
await (0, sdk_1.timeTravel)({ seconds:
|
|
526
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
526
|
+
await (0, sdk_1.timeTravel)({ seconds: args.seconds, signer });
|
|
527
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Fast-forwarded ${args.seconds} seconds`) });
|
|
527
528
|
}
|
|
528
529
|
catch (error) {
|
|
529
530
|
program.error(error.message, { exitCode: 1 });
|
|
530
531
|
}
|
|
531
532
|
});
|
|
532
533
|
program
|
|
533
|
-
.command("
|
|
534
|
+
.command("extractVerifyingKeyToFile")
|
|
534
535
|
.description("extract vkey to json file")
|
|
535
536
|
.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
537
|
.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)")
|
|
@@ -539,16 +540,16 @@ program
|
|
|
539
540
|
.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
541
|
.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)")
|
|
541
542
|
.requiredOption("-o, --output-file <outputFile>", "the output file path of extracted vkeys")
|
|
542
|
-
.action(async (
|
|
543
|
+
.action(async (args) => {
|
|
543
544
|
try {
|
|
544
|
-
await (0, sdk_1.
|
|
545
|
-
processMessagesZkeyPathQv:
|
|
546
|
-
tallyVotesZkeyPathQv:
|
|
547
|
-
processMessagesZkeyPathNonQv:
|
|
548
|
-
tallyVotesZkeyPathNonQv:
|
|
549
|
-
pollJoiningZkeyPath:
|
|
550
|
-
pollJoinedZkeyPath:
|
|
551
|
-
outputFilePath:
|
|
545
|
+
await (0, sdk_1.extractVerifyingKeyToFile)({
|
|
546
|
+
processMessagesZkeyPathQv: args.processMessagesZkeyQv,
|
|
547
|
+
tallyVotesZkeyPathQv: args.tallyVotesZkeyQv,
|
|
548
|
+
processMessagesZkeyPathNonQv: args.processMessagesZkeyNonQv,
|
|
549
|
+
tallyVotesZkeyPathNonQv: args.tallyVotesZkeyNonQv,
|
|
550
|
+
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
551
|
+
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
552
|
+
outputFilePath: args.outputFile,
|
|
552
553
|
});
|
|
553
554
|
}
|
|
554
555
|
catch (error) {
|
|
@@ -563,23 +564,23 @@ program
|
|
|
563
564
|
.option("-s, --sg-data <sgData>", "the signup gateway data")
|
|
564
565
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
565
566
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
566
|
-
.action(async (
|
|
567
|
+
.action(async (args) => {
|
|
567
568
|
try {
|
|
568
569
|
const signer = await getSigner();
|
|
569
570
|
const network = await signer.provider?.getNetwork();
|
|
570
571
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
571
572
|
contractNames: [sdk_1.EContracts.MACI],
|
|
572
573
|
network: network?.name,
|
|
573
|
-
defaultAddresses: [
|
|
574
|
+
defaultAddresses: [args.maciAddress],
|
|
574
575
|
});
|
|
575
576
|
const data = await (0, sdk_1.signup)({
|
|
576
|
-
maciPublicKey:
|
|
577
|
+
maciPublicKey: args.publicKey,
|
|
577
578
|
maciAddress,
|
|
578
|
-
sgData:
|
|
579
|
+
sgData: args.sgData ?? utils_1.DEFAULT_SG_DATA,
|
|
579
580
|
signer,
|
|
580
581
|
});
|
|
581
582
|
(0, sdk_1.logGreen)({
|
|
582
|
-
quiet:
|
|
583
|
+
quiet: args.quiet,
|
|
583
584
|
text: (0, sdk_1.success)(`State index: ${data.stateIndex.toString()}\n Transaction hash: ${data.transactionHash}`),
|
|
584
585
|
});
|
|
585
586
|
}
|
|
@@ -593,25 +594,25 @@ program
|
|
|
593
594
|
.requiredOption("-p, --public-key <publicKey>", "the MACI public key")
|
|
594
595
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
595
596
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
596
|
-
.action(async (
|
|
597
|
+
.action(async (args) => {
|
|
597
598
|
try {
|
|
598
599
|
const signer = await getSigner();
|
|
599
600
|
const network = await signer.provider?.getNetwork();
|
|
600
601
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
601
602
|
contractNames: [sdk_1.EContracts.MACI],
|
|
602
603
|
network: network?.name,
|
|
603
|
-
defaultAddresses: [
|
|
604
|
+
defaultAddresses: [args.maciAddress],
|
|
604
605
|
});
|
|
605
606
|
const data = await (0, sdk_1.getSignedupUserData)({
|
|
606
|
-
maciPublicKey:
|
|
607
|
+
maciPublicKey: args.publicKey,
|
|
607
608
|
maciAddress,
|
|
608
609
|
signer,
|
|
609
610
|
});
|
|
610
611
|
if (data.isRegistered) {
|
|
611
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
612
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`State index: ${data.stateIndex?.toString()}`) });
|
|
612
613
|
}
|
|
613
614
|
else {
|
|
614
|
-
(0, sdk_1.logRed)({ quiet:
|
|
615
|
+
(0, sdk_1.logRed)({ quiet: args.quiet, text: "User is not registered" });
|
|
615
616
|
}
|
|
616
617
|
}
|
|
617
618
|
catch (error) {
|
|
@@ -628,25 +629,25 @@ program
|
|
|
628
629
|
.option("--start-block <startBlock>", "the block number to start looking for events from", parseInt)
|
|
629
630
|
.option("--end-block <endBlock>", "the block number to end looking for events from", parseInt)
|
|
630
631
|
.option("--blocks-per-batch <blockPerBatch>", "the number of blocks to process per batch", parseInt)
|
|
631
|
-
.action(async (
|
|
632
|
+
.action(async (args) => {
|
|
632
633
|
try {
|
|
633
634
|
const signer = await getSigner();
|
|
634
635
|
const network = await signer.provider?.getNetwork();
|
|
635
636
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
636
637
|
contractNames: [sdk_1.EContracts.MACI],
|
|
637
638
|
network: network?.name,
|
|
638
|
-
defaultAddresses: [
|
|
639
|
+
defaultAddresses: [args.maciAddress],
|
|
639
640
|
});
|
|
640
641
|
const data = await (0, sdk_1.getJoinedUserData)({
|
|
641
|
-
pollPublicKey:
|
|
642
|
-
startBlock:
|
|
642
|
+
pollPublicKey: args.publicKey,
|
|
643
|
+
startBlock: args.startBlock,
|
|
643
644
|
maciAddress,
|
|
644
|
-
pollId:
|
|
645
|
+
pollId: args.pollId,
|
|
645
646
|
signer,
|
|
646
647
|
});
|
|
647
648
|
if (data.isJoined) {
|
|
648
649
|
(0, sdk_1.logGreen)({
|
|
649
|
-
quiet:
|
|
650
|
+
quiet: args.quiet,
|
|
650
651
|
text: (0, sdk_1.success)([
|
|
651
652
|
`Poll state index: ${data.pollStateIndex?.toString()}, registered: ${data.isJoined}`,
|
|
652
653
|
`Voice credits: ${data.voiceCredits?.toString()}`,
|
|
@@ -654,7 +655,7 @@ program
|
|
|
654
655
|
});
|
|
655
656
|
}
|
|
656
657
|
else {
|
|
657
|
-
(0, sdk_1.logRed)({ quiet:
|
|
658
|
+
(0, sdk_1.logRed)({ quiet: args.quiet, text: "User has not joined the poll" });
|
|
658
659
|
}
|
|
659
660
|
}
|
|
660
661
|
catch (error) {
|
|
@@ -666,17 +667,17 @@ program
|
|
|
666
667
|
.description("Get deployed poll from MACI contract")
|
|
667
668
|
.option("-p, --poll <poll>", "the poll id")
|
|
668
669
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
669
|
-
.action(async (
|
|
670
|
+
.action(async (args) => {
|
|
670
671
|
try {
|
|
671
672
|
const signer = await getSigner();
|
|
672
673
|
const network = await signer.provider?.getNetwork();
|
|
673
674
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
674
675
|
contractNames: [sdk_1.EContracts.MACI],
|
|
675
676
|
network: network?.name,
|
|
676
|
-
defaultAddresses: [
|
|
677
|
+
defaultAddresses: [args.maciAddress],
|
|
677
678
|
});
|
|
678
679
|
const details = await (0, sdk_1.getPoll)({
|
|
679
|
-
pollId:
|
|
680
|
+
pollId: args.poll,
|
|
680
681
|
maciAddress,
|
|
681
682
|
signer,
|
|
682
683
|
});
|
|
@@ -686,7 +687,7 @@ program
|
|
|
686
687
|
`ID: ${details.id}`,
|
|
687
688
|
`Start time: ${new Date(Number(details.startDate) * 1000).toString()}`,
|
|
688
689
|
`End time: ${new Date(Number(details.endDate) * 1000).toString()}`,
|
|
689
|
-
`Number of signups ${details.
|
|
690
|
+
`Number of signups ${details.totalSignups}`,
|
|
690
691
|
`State tree merged: ${details.isMerged}`,
|
|
691
692
|
`Mode: ${details.mode === 0n ? "Quadratic Voting" : "Non-Quadratic Voting"}`,
|
|
692
693
|
].join("\n")),
|
|
@@ -703,15 +704,15 @@ program
|
|
|
703
704
|
.requiredOption("-w, --address <address>", "the address to fund")
|
|
704
705
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
705
706
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
706
|
-
.action(async (
|
|
707
|
+
.action(async (args) => {
|
|
707
708
|
try {
|
|
708
|
-
(0, utils_1.banner)(
|
|
709
|
+
(0, utils_1.banner)(args.quiet);
|
|
709
710
|
const signer = await getSigner();
|
|
710
|
-
const hash = await (0, sdk_1.fundWallet)({ amount:
|
|
711
|
-
(0, sdk_1.logYellow)({ quiet:
|
|
711
|
+
const hash = await (0, sdk_1.fundWallet)({ amount: args.amount, address: args.address, signer });
|
|
712
|
+
(0, sdk_1.logYellow)({ quiet: args.quiet, text: (0, sdk_1.info)(`Transaction hash: ${hash}`) });
|
|
712
713
|
(0, sdk_1.logGreen)({
|
|
713
|
-
quiet:
|
|
714
|
-
text: (0, sdk_1.success)(`Successfully funded ${
|
|
714
|
+
quiet: args.quiet,
|
|
715
|
+
text: (0, sdk_1.success)(`Successfully funded ${args.address} with ${args.amount} wei`),
|
|
715
716
|
});
|
|
716
717
|
}
|
|
717
718
|
catch (error) {
|
|
@@ -726,34 +727,34 @@ program
|
|
|
726
727
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
727
728
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
728
729
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
729
|
-
.action(async (
|
|
730
|
+
.action(async (args) => {
|
|
730
731
|
try {
|
|
731
|
-
(0, utils_1.banner)(
|
|
732
|
+
(0, utils_1.banner)(args.quiet);
|
|
732
733
|
const signer = await getSigner();
|
|
733
734
|
const network = await signer.provider?.getNetwork();
|
|
734
735
|
// read the tally file
|
|
735
|
-
const isTallyFileExists = fs_1.default.existsSync(
|
|
736
|
-
if (!
|
|
737
|
-
throw new Error(`Unable to open ${
|
|
736
|
+
const isTallyFileExists = fs_1.default.existsSync(args.tallyFile);
|
|
737
|
+
if (!args.tallyFile || !isTallyFileExists) {
|
|
738
|
+
throw new Error(`Unable to open ${args.tallyFile}`);
|
|
738
739
|
}
|
|
739
|
-
const tallyData = await (0, utils_1.readJSONFile)(
|
|
740
|
+
const tallyData = await (0, utils_1.readJSONFile)(args.tallyFile);
|
|
740
741
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
741
742
|
contractNames: [sdk_1.EContracts.MACI],
|
|
742
743
|
network: network?.name,
|
|
743
|
-
defaultAddresses: [
|
|
744
|
+
defaultAddresses: [args.maciAddress],
|
|
744
745
|
});
|
|
745
|
-
const pollParams = await (0, sdk_1.getPollParams)({ pollId:
|
|
746
|
+
const pollParams = await (0, sdk_1.getPollParams)({ pollId: args.pollId, maciContractAddress: maciAddress, signer });
|
|
746
747
|
const tallyCommitments = (0, sdk_1.generateTallyCommitments)({
|
|
747
748
|
tallyData,
|
|
748
749
|
voteOptionTreeDepth: pollParams.voteOptionTreeDepth,
|
|
749
750
|
});
|
|
750
751
|
await (0, sdk_1.verify)({
|
|
751
752
|
tallyData,
|
|
752
|
-
pollId:
|
|
753
|
+
pollId: args.pollId,
|
|
753
754
|
maciAddress,
|
|
754
755
|
signer,
|
|
755
756
|
tallyCommitments,
|
|
756
|
-
|
|
757
|
+
totalVoteOptions: pollParams.totalVoteOptions,
|
|
757
758
|
voteOptionTreeDepth: pollParams.voteOptionTreeDepth,
|
|
758
759
|
});
|
|
759
760
|
}
|
|
@@ -762,7 +763,7 @@ program
|
|
|
762
763
|
}
|
|
763
764
|
});
|
|
764
765
|
program
|
|
765
|
-
.command("
|
|
766
|
+
.command("generateProofs")
|
|
766
767
|
.description("generate the proofs for a poll")
|
|
767
768
|
.option("-k, --private-key <privateKey>", "your serialized MACI private key")
|
|
768
769
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
@@ -831,7 +832,7 @@ program
|
|
|
831
832
|
}
|
|
832
833
|
});
|
|
833
834
|
program
|
|
834
|
-
.command("
|
|
835
|
+
.command("generateLocalState")
|
|
835
836
|
.description("generate a local MACI state from the smart contracts events")
|
|
836
837
|
.requiredOption("-o, --output <outputPath>", "the path where to write the state")
|
|
837
838
|
.requiredOption("-p, --poll-id <pollId>", "the id of the poll", BigInt)
|
|
@@ -846,30 +847,30 @@ program
|
|
|
846
847
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
847
848
|
.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
849
|
.option("-l, --logs-output <logsOutputPath>", "the path where to save the logs for debugging and auditing purposes")
|
|
849
|
-
.action(async (
|
|
850
|
+
.action(async (args) => {
|
|
850
851
|
try {
|
|
851
852
|
const signer = await getSigner();
|
|
852
853
|
const network = await signer.provider?.getNetwork();
|
|
853
854
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
854
855
|
contractNames: [sdk_1.EContracts.MACI],
|
|
855
856
|
network: network?.name,
|
|
856
|
-
defaultAddresses: [
|
|
857
|
+
defaultAddresses: [args.maciAddress],
|
|
857
858
|
});
|
|
858
|
-
const coordinatorPrivateKey =
|
|
859
|
+
const coordinatorPrivateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
|
|
859
860
|
await (0, sdk_1.generateMaciState)({
|
|
860
|
-
outputPath:
|
|
861
|
-
pollId:
|
|
861
|
+
outputPath: args.output.toString(),
|
|
862
|
+
pollId: args.pollId,
|
|
862
863
|
maciAddress,
|
|
863
864
|
coordinatorPrivateKey,
|
|
864
|
-
provider:
|
|
865
|
-
endBlock:
|
|
866
|
-
startBlock:
|
|
867
|
-
blockPerBatch:
|
|
868
|
-
transactionHash:
|
|
869
|
-
ipfsMessageBackupFiles:
|
|
870
|
-
sleep:
|
|
865
|
+
provider: args.rpcProvider,
|
|
866
|
+
endBlock: args.endBlock,
|
|
867
|
+
startBlock: args.startBlock,
|
|
868
|
+
blockPerBatch: args.blocksPerBatch,
|
|
869
|
+
transactionHash: args.transactionHash,
|
|
870
|
+
ipfsMessageBackupFiles: args.ipfsMessageBackupFiles,
|
|
871
|
+
sleep: args.sleep,
|
|
871
872
|
signer,
|
|
872
|
-
logsOutputPath:
|
|
873
|
+
logsOutputPath: args.logsOutput,
|
|
873
874
|
});
|
|
874
875
|
}
|
|
875
876
|
catch (error) {
|
|
@@ -884,20 +885,20 @@ program
|
|
|
884
885
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
885
886
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
886
887
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
887
|
-
.requiredOption("-f, --proof-dir <proofDir>", "the proof output directory from the
|
|
888
|
-
.action(async (
|
|
888
|
+
.requiredOption("-f, --proof-dir <proofDir>", "the proof output directory from the generateProofs subcommand")
|
|
889
|
+
.action(async (args) => {
|
|
889
890
|
try {
|
|
890
891
|
const signer = await getSigner();
|
|
891
892
|
const network = await signer.provider?.getNetwork();
|
|
892
893
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
893
894
|
contractNames: [sdk_1.EContracts.MACI],
|
|
894
895
|
network: network?.name,
|
|
895
|
-
defaultAddresses: [
|
|
896
|
+
defaultAddresses: [args.maciAddress],
|
|
896
897
|
});
|
|
897
898
|
await (0, sdk_1.proveOnChain)({
|
|
898
|
-
pollId:
|
|
899
|
-
tallyFile:
|
|
900
|
-
proofDir:
|
|
899
|
+
pollId: args.pollId,
|
|
900
|
+
tallyFile: args.tallyFile,
|
|
901
|
+
proofDir: args.proofDir,
|
|
901
902
|
maciAddress,
|
|
902
903
|
signer,
|
|
903
904
|
});
|