@maci-protocol/cli 0.0.0-ci.c495700 → 0.0.0-ci.c584537
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/LICENSE +1 -2
- package/build/package.json +4 -4
- package/build/ts/index.js +232 -211
- package/build/ts/index.js.map +1 -1
- package/build/ts/utils/constants.d.ts +2 -0
- package/build/ts/utils/constants.d.ts.map +1 -1
- package/build/ts/utils/constants.js +7 -1
- package/build/ts/utils/constants.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -8
package/build/ts/index.js
CHANGED
|
@@ -45,6 +45,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
45
45
|
const path_1 = __importDefault(require("path"));
|
|
46
46
|
require("./cliInit");
|
|
47
47
|
const utils_1 = require("./utils");
|
|
48
|
+
const constants_1 = require("./utils/constants");
|
|
48
49
|
const defaults_1 = require("./utils/defaults");
|
|
49
50
|
// set the description version and name of the cli tool
|
|
50
51
|
const { description, version, name } = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(__dirname, "..", "package.json"), "utf8"));
|
|
@@ -66,25 +67,25 @@ program
|
|
|
66
67
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
67
68
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
68
69
|
.requiredOption("-s, --stateTreeDepth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
69
|
-
.action(async (
|
|
70
|
+
.action(async (args) => {
|
|
70
71
|
try {
|
|
71
72
|
const signer = await getSigner();
|
|
72
|
-
(0, utils_1.banner)(
|
|
73
|
+
(0, utils_1.banner)(args.quiet);
|
|
73
74
|
const network = await signer.provider?.getNetwork();
|
|
74
75
|
const [poseidonT3, poseidonT4, poseidonT5, poseidonT6] = (0, utils_1.readContractAddresses)({
|
|
75
76
|
contractNames: [sdk_1.EContracts.PoseidonT3, sdk_1.EContracts.PoseidonT4, sdk_1.EContracts.PoseidonT5, sdk_1.EContracts.PoseidonT6],
|
|
76
77
|
network: network?.name,
|
|
77
78
|
});
|
|
78
79
|
let [signupPolicyContractAddress] = (0, utils_1.readContractAddresses)({
|
|
79
|
-
contractNames: [
|
|
80
|
+
contractNames: [args.signupPolicyContractName.toString()],
|
|
80
81
|
network: network?.name,
|
|
81
82
|
});
|
|
82
83
|
if (!signupPolicyContractAddress) {
|
|
83
|
-
const checkerFactory =
|
|
84
|
-
? sdk_1.FreeForAllCheckerFactory__factory.connect(
|
|
84
|
+
const checkerFactory = args.freeForAllCheckerFactoryAddress
|
|
85
|
+
? sdk_1.FreeForAllCheckerFactory__factory.connect(args.freeForAllCheckerFactoryAddress, signer)
|
|
85
86
|
: undefined;
|
|
86
|
-
const policyFactory =
|
|
87
|
-
? sdk_1.FreeForAllPolicyFactory__factory.connect(
|
|
87
|
+
const policyFactory = args.freeForAllPolicyFactoryAddress
|
|
88
|
+
? sdk_1.FreeForAllPolicyFactory__factory.connect(args.freeForAllPolicyFactoryAddress, signer)
|
|
88
89
|
: undefined;
|
|
89
90
|
const [contract] = await (0, sdk_1.deployFreeForAllSignUpPolicy)({ checker: checkerFactory, policy: policyFactory }, signer, true);
|
|
90
91
|
signupPolicyContractAddress = await contract.getAddress();
|
|
@@ -102,13 +103,13 @@ program
|
|
|
102
103
|
poseidonT6,
|
|
103
104
|
},
|
|
104
105
|
signer,
|
|
105
|
-
stateTreeDepth:
|
|
106
|
+
stateTreeDepth: args.stateTreeDepth,
|
|
106
107
|
});
|
|
107
|
-
const emptyBallotRoots = (0, sdk_1.
|
|
108
|
+
const emptyBallotRoots = (0, sdk_1.generateEmptyBallotRoots)(args.stateTreeDepth);
|
|
108
109
|
// save to the JSON File
|
|
109
110
|
await (0, utils_1.storeContractAddresses)({
|
|
110
111
|
data: {
|
|
111
|
-
[
|
|
112
|
+
[args.signupPolicyContractName]: { address: signupPolicyContractAddress, args: [] },
|
|
112
113
|
[sdk_1.EContracts.Verifier]: { address: verifierContractAddress, args: [] },
|
|
113
114
|
[sdk_1.EContracts.MACI]: {
|
|
114
115
|
address: maciContractAddress,
|
|
@@ -117,7 +118,7 @@ program
|
|
|
117
118
|
messageProcessorFactoryContractAddress,
|
|
118
119
|
tallyFactoryContractAddress,
|
|
119
120
|
signupPolicyContractAddress,
|
|
120
|
-
|
|
121
|
+
args.stateTreeDepth,
|
|
121
122
|
emptyBallotRoots.map((root) => root.toString()),
|
|
122
123
|
],
|
|
123
124
|
},
|
|
@@ -131,7 +132,7 @@ program
|
|
|
131
132
|
},
|
|
132
133
|
signer,
|
|
133
134
|
});
|
|
134
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
135
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`MACI deployed at: ${maciContractAddress}`) });
|
|
135
136
|
}
|
|
136
137
|
catch (error) {
|
|
137
138
|
program.error(error.message, { exitCode: 1 });
|
|
@@ -140,75 +141,75 @@ program
|
|
|
140
141
|
program
|
|
141
142
|
.command("checkVerifyingKeys")
|
|
142
143
|
.description("check that the verifying keys in the contract match the local ones")
|
|
143
|
-
.option("-
|
|
144
|
+
.option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
|
|
144
145
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
145
146
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
146
|
-
.option("-k, --vk-contract <vkContract>", "the
|
|
147
|
+
.option("-k, --vk-contract <vkContract>", "the VerifyingKeysRegistry contract address")
|
|
147
148
|
.requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
148
|
-
.requiredOption("-i, --
|
|
149
|
+
.requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the intermediate state tree depth", parseInt)
|
|
149
150
|
.requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
|
|
150
151
|
.requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
|
|
151
152
|
.requiredOption("-p, --process-messages-zkey <processMessagesZkeyPath>", "the process messages zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
152
153
|
.requiredOption("-t, --tally-votes-zkey <tallyVotesZkeyPath>", "the tally votes zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
153
154
|
.requiredOption("--poll-joining-zkey <pollJoiningZkey>", "the poll joining zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
154
155
|
.requiredOption("--poll-joined-zkey <pollJoinedZkey>", "the poll joined zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
155
|
-
.action(async (
|
|
156
|
+
.action(async (args) => {
|
|
156
157
|
try {
|
|
157
158
|
const signer = await getSigner();
|
|
158
159
|
const network = await signer.provider?.getNetwork();
|
|
159
|
-
const [
|
|
160
|
-
contractNames: [sdk_1.EContracts.
|
|
160
|
+
const [contractAddress] = (0, utils_1.readContractAddresses)({
|
|
161
|
+
contractNames: [sdk_1.EContracts.VerifyingKeysRegistry],
|
|
161
162
|
network: network?.name,
|
|
162
|
-
defaultAddresses: [
|
|
163
|
+
defaultAddresses: [args.vkContract],
|
|
163
164
|
});
|
|
164
|
-
(0, sdk_1.logYellow)({ quiet:
|
|
165
|
+
(0, sdk_1.logYellow)({ quiet: args.quiet, text: (0, sdk_1.info)("Retrieving verifying keys from the contract...") });
|
|
165
166
|
await (0, sdk_1.checkVerifyingKeys)({
|
|
166
|
-
stateTreeDepth:
|
|
167
|
-
|
|
168
|
-
voteOptionTreeDepth:
|
|
169
|
-
messageBatchSize:
|
|
170
|
-
processMessagesZkeyPath:
|
|
171
|
-
tallyVotesZkeyPath:
|
|
172
|
-
pollJoiningZkeyPath:
|
|
173
|
-
pollJoinedZkeyPath:
|
|
174
|
-
|
|
175
|
-
|
|
167
|
+
stateTreeDepth: args.stateTreeDepth,
|
|
168
|
+
tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
|
|
169
|
+
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
170
|
+
messageBatchSize: args.messageBatchSize,
|
|
171
|
+
processMessagesZkeyPath: args.processMessagesZkey,
|
|
172
|
+
tallyVotesZkeyPath: args.tallyVotesZkey,
|
|
173
|
+
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
174
|
+
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
175
|
+
verifyingKeysRegistry: contractAddress,
|
|
176
|
+
mode: args.mode,
|
|
176
177
|
signer,
|
|
177
178
|
});
|
|
178
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
179
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)("Verifying keys match") });
|
|
179
180
|
}
|
|
180
181
|
catch (error) {
|
|
181
182
|
program.error(error.message, { exitCode: 1 });
|
|
182
183
|
}
|
|
183
184
|
});
|
|
184
185
|
program
|
|
185
|
-
.command("
|
|
186
|
+
.command("generateMaciPubKey")
|
|
186
187
|
.description("generate a new MACI public key")
|
|
187
188
|
.requiredOption("-k, --private-key <privateKey>", "the private key")
|
|
188
189
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
189
190
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
190
|
-
.action((
|
|
191
|
-
const publicKey = (0, sdk_1.generateMaciPublicKey)(
|
|
192
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
191
|
+
.action((args) => {
|
|
192
|
+
const publicKey = (0, sdk_1.generateMaciPublicKey)(args.privateKey);
|
|
193
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Public key: ${publicKey}`) });
|
|
193
194
|
});
|
|
194
195
|
program
|
|
195
|
-
.command("
|
|
196
|
+
.command("generateMaciKeyPair")
|
|
196
197
|
.description("generate a new MACI key pair")
|
|
197
198
|
.option("-s, --seed <seed>", "seed value for keypair", (value) => (value ? BigInt(value) : undefined), undefined)
|
|
198
199
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
199
|
-
.action((
|
|
200
|
-
const { publicKey, privateKey } = (0, sdk_1.generateKeypair)({ seed:
|
|
201
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
202
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
200
|
+
.action((args) => {
|
|
201
|
+
const { publicKey, privateKey } = (0, sdk_1.generateKeypair)({ seed: args.seed });
|
|
202
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Public key: ${publicKey}`) });
|
|
203
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Private key: ${privateKey}`) });
|
|
203
204
|
});
|
|
204
205
|
program
|
|
205
|
-
.command("
|
|
206
|
+
.command("deployVerifyingKeysRegistry")
|
|
206
207
|
.description("deploy a new verification key registry contract")
|
|
207
208
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
208
209
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
209
|
-
.action(async (
|
|
210
|
+
.action(async (args) => {
|
|
210
211
|
try {
|
|
211
|
-
(0, utils_1.banner)(
|
|
212
|
+
(0, utils_1.banner)(args.quiet);
|
|
212
213
|
const signer = await getSigner();
|
|
213
214
|
// assume that the vkRegistry contract is the first one to be deployed
|
|
214
215
|
const isContractAddressesStoreExists = fs_1.default.existsSync(utils_1.contractAddressesStorePath);
|
|
@@ -217,12 +218,15 @@ program
|
|
|
217
218
|
(0, utils_1.resetContractAddresses)(network?.name);
|
|
218
219
|
}
|
|
219
220
|
// deploy and store the address
|
|
220
|
-
const
|
|
221
|
+
const verifyingKeysRegistryAddress = await (0, sdk_1.deployVerifyingKeysRegistryContract)({ signer });
|
|
221
222
|
await (0, utils_1.storeContractAddresses)({
|
|
222
|
-
data: { [sdk_1.EContracts.
|
|
223
|
+
data: { [sdk_1.EContracts.VerifyingKeysRegistry]: { address: verifyingKeysRegistryAddress, args: [] } },
|
|
223
224
|
signer,
|
|
224
225
|
});
|
|
225
|
-
(0, sdk_1.logGreen)({
|
|
226
|
+
(0, sdk_1.logGreen)({
|
|
227
|
+
quiet: args.quiet,
|
|
228
|
+
text: (0, sdk_1.success)(`VerifyingKeysRegistry deployed at: ${verifyingKeysRegistryAddress}`),
|
|
229
|
+
});
|
|
226
230
|
}
|
|
227
231
|
catch (error) {
|
|
228
232
|
program.error(error.message, { exitCode: 1 });
|
|
@@ -249,37 +253,37 @@ program
|
|
|
249
253
|
program
|
|
250
254
|
.command("deployPoll")
|
|
251
255
|
.description("deploy a new poll")
|
|
252
|
-
.option("-k, --
|
|
253
|
-
.requiredOption("
|
|
254
|
-
.requiredOption("
|
|
255
|
-
.requiredOption("-i, --
|
|
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)
|
|
256
260
|
.requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
|
|
257
261
|
.requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
258
262
|
.requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
|
|
259
263
|
.requiredOption("-p, --public-key <publicKey>", "the coordinator public key")
|
|
260
|
-
.option("-
|
|
264
|
+
.option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
|
|
261
265
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
262
|
-
.option("
|
|
266
|
+
.option("--relayers <relayers>", "the relayer addresses", (value) => value.split(",").map((item) => item.trim()))
|
|
263
267
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
264
268
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
265
269
|
.option("-o, --vote-options <voteOptions>", "the number of vote options", parseInt)
|
|
266
270
|
.option("--initial-voice-credits <initialVoiceCredits>", "the initial voice credits", parseInt)
|
|
267
271
|
.option("--initial-voice-credits-proxy <initialVoiceCreditsProxy>", "the initial voice credits proxy address")
|
|
268
272
|
.option("--signup-policy <signupPolicy>", "the signup policy contract address")
|
|
269
|
-
.action(async (
|
|
273
|
+
.action(async (args) => {
|
|
270
274
|
try {
|
|
271
|
-
(0, utils_1.banner)(
|
|
275
|
+
(0, utils_1.banner)(args.quiet);
|
|
272
276
|
const signer = await getSigner();
|
|
273
277
|
const network = await signer.provider?.getNetwork();
|
|
274
|
-
const [
|
|
278
|
+
const [verifyingKeysRegistryAddress, maciAddress, initialVoiceCreditProxyAddress, verifierContractAddress] = (0, utils_1.readContractAddresses)({
|
|
275
279
|
contractNames: [
|
|
276
|
-
sdk_1.EContracts.
|
|
280
|
+
sdk_1.EContracts.VerifyingKeysRegistry,
|
|
277
281
|
sdk_1.EContracts.MACI,
|
|
278
282
|
sdk_1.EContracts.ConstantInitialVoiceCreditProxy,
|
|
279
283
|
sdk_1.EContracts.Verifier,
|
|
280
284
|
],
|
|
281
285
|
network: network?.name,
|
|
282
|
-
defaultAddresses: [
|
|
286
|
+
defaultAddresses: [args.verifyingKeysRegistryAddress, args.maciAddress, args.initialVoiceCreditsProxy],
|
|
283
287
|
});
|
|
284
288
|
const maciContract = sdk_1.MACI__factory.connect(maciAddress, signer);
|
|
285
289
|
const nextPollId = await maciContract.nextPollId();
|
|
@@ -289,40 +293,40 @@ program
|
|
|
289
293
|
contractNames: [policyContractName.toString()],
|
|
290
294
|
keys: [nextPollId.toString()],
|
|
291
295
|
network: network?.name,
|
|
292
|
-
defaultAddresses: [
|
|
296
|
+
defaultAddresses: [args.signupPolicy],
|
|
293
297
|
});
|
|
294
298
|
const { pollId, pollContractAddress, tallyContractAddress, messageProcessorContractAddress, initialVoiceCreditProxyContractAddress, policyContractAddress, } = await (0, sdk_1.deployPoll)({
|
|
295
|
-
initialVoiceCredits:
|
|
296
|
-
pollStartTimestamp:
|
|
297
|
-
pollEndTimestamp:
|
|
298
|
-
|
|
299
|
-
messageBatchSize:
|
|
300
|
-
stateTreeDepth:
|
|
301
|
-
voteOptionTreeDepth:
|
|
302
|
-
coordinatorPublicKey: domainobjs_1.PublicKey.deserialize(
|
|
299
|
+
initialVoiceCredits: args.initialVoiceCredits || defaults_1.DEFAULT_INITIAL_VOICE_CREDITS,
|
|
300
|
+
pollStartTimestamp: args.start,
|
|
301
|
+
pollEndTimestamp: args.end,
|
|
302
|
+
tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
|
|
303
|
+
messageBatchSize: args.messageBatchSize,
|
|
304
|
+
stateTreeDepth: args.stateTreeDepth,
|
|
305
|
+
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
306
|
+
coordinatorPublicKey: domainobjs_1.PublicKey.deserialize(args.publicKey),
|
|
303
307
|
maciAddress,
|
|
304
|
-
|
|
305
|
-
relayers:
|
|
306
|
-
mode:
|
|
308
|
+
verifyingKeysRegistryContractAddress: verifyingKeysRegistryAddress,
|
|
309
|
+
relayers: args.relayers ?? [ethers_1.ZeroAddress],
|
|
310
|
+
mode: args.mode,
|
|
307
311
|
signer,
|
|
308
|
-
voteOptions:
|
|
312
|
+
voteOptions: args.voteOptions ?? defaults_1.DEFAULT_VOTE_OPTIONS,
|
|
309
313
|
verifierContractAddress,
|
|
310
314
|
policyContractAddress: signupPolicyContractAddress,
|
|
311
315
|
initialVoiceCreditProxyContractAddress: initialVoiceCreditProxyAddress,
|
|
312
316
|
});
|
|
313
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
314
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
315
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
317
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Poll ID: ${pollId}`) });
|
|
318
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Poll contract address: ${pollContractAddress}`) });
|
|
319
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Tally contract address: ${tallyContractAddress}`) });
|
|
316
320
|
(0, sdk_1.logGreen)({
|
|
317
|
-
quiet:
|
|
321
|
+
quiet: args.quiet,
|
|
318
322
|
text: (0, sdk_1.success)(`Message processor contract address: ${messageProcessorContractAddress}`),
|
|
319
323
|
});
|
|
320
324
|
(0, sdk_1.logGreen)({
|
|
321
|
-
quiet:
|
|
325
|
+
quiet: args.quiet,
|
|
322
326
|
text: (0, sdk_1.success)(`Initial voice credit proxy contract address: ${initialVoiceCreditProxyContractAddress}`),
|
|
323
327
|
});
|
|
324
328
|
(0, sdk_1.logGreen)({
|
|
325
|
-
quiet:
|
|
329
|
+
quiet: args.quiet,
|
|
326
330
|
text: (0, sdk_1.success)(`Signup policy contract address: ${policyContractAddress}`),
|
|
327
331
|
});
|
|
328
332
|
}
|
|
@@ -351,37 +355,37 @@ program
|
|
|
351
355
|
.option("-w, --wasm", "whether to use the wasm binaries")
|
|
352
356
|
.option("-r, --rapidsnark <rapidsnark>", "the path to the rapidsnark binary")
|
|
353
357
|
.option("-g, --poll-witnessgen <pollWitnessgen>", "the path to the poll witness generation binary")
|
|
354
|
-
.action(async (
|
|
358
|
+
.action(async (args) => {
|
|
355
359
|
try {
|
|
356
360
|
const signer = await getSigner();
|
|
357
361
|
const network = await signer.provider?.getNetwork();
|
|
358
362
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
359
363
|
contractNames: [sdk_1.EContracts.MACI],
|
|
360
364
|
network: network?.name,
|
|
361
|
-
defaultAddresses: [
|
|
365
|
+
defaultAddresses: [args.maciAddress],
|
|
362
366
|
});
|
|
363
|
-
const privateKey =
|
|
367
|
+
const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
|
|
364
368
|
const data = await (0, sdk_1.joinPoll)({
|
|
365
369
|
maciAddress,
|
|
366
370
|
privateKey,
|
|
367
|
-
stateIndex:
|
|
368
|
-
stateFile:
|
|
369
|
-
pollId:
|
|
371
|
+
stateIndex: args.stateIndex,
|
|
372
|
+
stateFile: args.stateFile,
|
|
373
|
+
pollId: args.pollId,
|
|
370
374
|
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:
|
|
375
|
+
startBlock: args.startBlock,
|
|
376
|
+
endBlock: args.endBlock,
|
|
377
|
+
blocksPerBatch: args.blocksPerBatch,
|
|
378
|
+
pollJoiningZkey: args.pollJoiningZkey,
|
|
379
|
+
pollWasm: args.pollWasm,
|
|
380
|
+
useWasm: args.wasm,
|
|
381
|
+
rapidsnark: args.rapidsnark,
|
|
382
|
+
pollWitgen: args.pollWitnessgen,
|
|
383
|
+
sgDataArg: args.sgData ?? utils_1.DEFAULT_SG_DATA,
|
|
384
|
+
ivcpDataArg: args.ivcpData ?? utils_1.DEFAULT_IVCP_DATA,
|
|
385
|
+
});
|
|
386
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with nullifier: ${data.nullifier}`) });
|
|
387
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with state index: ${data.pollStateIndex}`) });
|
|
388
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with ${data.voiceCredits} voice credits`) });
|
|
385
389
|
}
|
|
386
390
|
catch (error) {
|
|
387
391
|
program.error(error.message, { exitCode: 1 });
|
|
@@ -391,7 +395,7 @@ program
|
|
|
391
395
|
.command("setVerifyingKeys")
|
|
392
396
|
.description("set the verifying keys")
|
|
393
397
|
.requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
394
|
-
.requiredOption("-i, --
|
|
398
|
+
.requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the intermediate state tree depth", parseInt)
|
|
395
399
|
.requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
|
|
396
400
|
.requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
|
|
397
401
|
.option("--poll-state-tree-depth <pollStateTreeDepth>", "the poll state tree depth", parseInt)
|
|
@@ -401,39 +405,49 @@ program
|
|
|
401
405
|
.option("--tally-votes-zkey-qv <tallyVotesZkeyPathQv>", "the tally votes qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
402
406
|
.option("--process-messages-zkey-non-qv <processMessagesZkeyPathNonQv>", "the process messages non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
403
407
|
.option("--tally-votes-zkey-non-qv <tallyVotesZkeyPathNonQv>", "the tally votes non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
404
|
-
.option("
|
|
408
|
+
.option("--process-messages-zkey-full <processMessagesZkeyPathFull>", "the process messages full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
409
|
+
.option("--tally-votes-zkey-full <tallyVotesZkeyPathFull>", "the tally votes full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
410
|
+
.option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
|
|
405
411
|
.option("-k, --vk-registry <vkRegistry>", "the vk registry contract address")
|
|
406
412
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
407
413
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
408
|
-
.action(async (
|
|
414
|
+
.action(async (args) => {
|
|
409
415
|
try {
|
|
410
416
|
const signer = await getSigner();
|
|
411
417
|
const network = await signer.provider?.getNetwork();
|
|
412
|
-
const [
|
|
413
|
-
contractNames: [sdk_1.EContracts.
|
|
418
|
+
const [verifyingKeysRegistryAddress] = (0, utils_1.readContractAddresses)({
|
|
419
|
+
contractNames: [sdk_1.EContracts.VerifyingKeysRegistry],
|
|
414
420
|
network: network?.name,
|
|
415
|
-
defaultAddresses: [
|
|
421
|
+
defaultAddresses: [args.vkRegistry],
|
|
416
422
|
});
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
423
|
+
const processKeys = {
|
|
424
|
+
[sdk_1.EMode.QV]: args.processMessagesZkeyQv,
|
|
425
|
+
[sdk_1.EMode.NON_QV]: args.processMessagesZkeyNonQv,
|
|
426
|
+
[sdk_1.EMode.FULL]: args.processMessagesZkeyFull,
|
|
427
|
+
};
|
|
428
|
+
const tallyKeys = {
|
|
429
|
+
[sdk_1.EMode.QV]: args.tallyVotesZkeyQv,
|
|
430
|
+
[sdk_1.EMode.NON_QV]: args.tallyVotesZkeyNonQv,
|
|
431
|
+
[sdk_1.EMode.FULL]: args.tallyVotesZkeyFull,
|
|
432
|
+
};
|
|
433
|
+
const { pollJoiningVerifyingKey, pollJoinedVerifyingKey, processVerifyingKey, tallyVerifyingKey } = await (0, sdk_1.extractAllVerifyingKeys)({
|
|
434
|
+
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
435
|
+
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
436
|
+
processMessagesZkeyPath: processKeys[args.mode],
|
|
437
|
+
tallyVotesZkeyPath: tallyKeys[args.mode],
|
|
424
438
|
});
|
|
425
439
|
await (0, sdk_1.setVerifyingKeys)({
|
|
426
|
-
stateTreeDepth:
|
|
427
|
-
|
|
428
|
-
voteOptionTreeDepth:
|
|
429
|
-
messageBatchSize:
|
|
430
|
-
pollStateTreeDepth:
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
mode:
|
|
440
|
+
stateTreeDepth: args.stateTreeDepth,
|
|
441
|
+
tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
|
|
442
|
+
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
443
|
+
messageBatchSize: args.messageBatchSize,
|
|
444
|
+
pollStateTreeDepth: args.pollStateTreeDepth || args.stateTreeDepth,
|
|
445
|
+
pollJoiningVerifyingKey: pollJoiningVerifyingKey,
|
|
446
|
+
pollJoinedVerifyingKey: pollJoinedVerifyingKey,
|
|
447
|
+
processMessagesVerifyingKey: processVerifyingKey,
|
|
448
|
+
tallyVotesVerifyingKey: tallyVerifyingKey,
|
|
449
|
+
verifyingKeysRegistryAddress,
|
|
450
|
+
mode: args.mode,
|
|
437
451
|
signer,
|
|
438
452
|
});
|
|
439
453
|
}
|
|
@@ -455,25 +469,25 @@ program
|
|
|
455
469
|
.requiredOption("-w, --new-vote-weight <newVoteWeight>", "the new vote weight", BigInt)
|
|
456
470
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
457
471
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
458
|
-
.action(async (
|
|
472
|
+
.action(async (args) => {
|
|
459
473
|
try {
|
|
460
474
|
const signer = await getSigner();
|
|
461
475
|
const network = await signer.provider?.getNetwork();
|
|
462
476
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
463
477
|
contractNames: [sdk_1.EContracts.MACI],
|
|
464
478
|
network: network?.name,
|
|
465
|
-
defaultAddresses: [
|
|
479
|
+
defaultAddresses: [args.maciAddress],
|
|
466
480
|
});
|
|
467
|
-
const privateKey =
|
|
481
|
+
const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
|
|
468
482
|
await (0, sdk_1.publish)({
|
|
469
|
-
publicKey:
|
|
470
|
-
stateIndex:
|
|
471
|
-
voteOptionIndex:
|
|
472
|
-
nonce:
|
|
473
|
-
pollId:
|
|
474
|
-
newVoteWeight:
|
|
483
|
+
publicKey: args.publicKey,
|
|
484
|
+
stateIndex: args.stateIndex,
|
|
485
|
+
voteOptionIndex: args.voteOptionIndex,
|
|
486
|
+
nonce: args.nonce,
|
|
487
|
+
pollId: args.pollId,
|
|
488
|
+
newVoteWeight: args.newVoteWeight,
|
|
475
489
|
maciAddress,
|
|
476
|
-
salt:
|
|
490
|
+
salt: args.salt,
|
|
477
491
|
privateKey,
|
|
478
492
|
signer,
|
|
479
493
|
});
|
|
@@ -488,23 +502,23 @@ program
|
|
|
488
502
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
489
503
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
490
504
|
.requiredOption("-p, --poll-id <pollId>", "the poll id", BigInt)
|
|
491
|
-
.action(async (
|
|
505
|
+
.action(async (args) => {
|
|
492
506
|
try {
|
|
493
507
|
const signer = await getSigner();
|
|
494
508
|
const network = await signer.provider?.getNetwork();
|
|
495
509
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
496
510
|
contractNames: [sdk_1.EContracts.MACI],
|
|
497
511
|
network: network?.name,
|
|
498
|
-
defaultAddresses: [
|
|
512
|
+
defaultAddresses: [args.maciAddress],
|
|
499
513
|
});
|
|
500
514
|
const receipt = await (0, sdk_1.mergeSignups)({
|
|
501
|
-
pollId:
|
|
515
|
+
pollId: args.pollId,
|
|
502
516
|
maciAddress,
|
|
503
517
|
signer,
|
|
504
518
|
});
|
|
505
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
519
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`Transaction hash: ${receipt.hash}`) });
|
|
506
520
|
(0, sdk_1.logGreen)({
|
|
507
|
-
quiet:
|
|
521
|
+
quiet: args.quiet,
|
|
508
522
|
text: (0, sdk_1.success)(`Executed mergeSignups(); gas used: ${receipt.gasUsed.toString()}`),
|
|
509
523
|
});
|
|
510
524
|
}
|
|
@@ -518,37 +532,39 @@ program
|
|
|
518
532
|
.requiredOption("-s, --seconds <seconds>", "the number of seconds to fast-forward", parseInt)
|
|
519
533
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
520
534
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
521
|
-
.action(async (
|
|
535
|
+
.action(async (args) => {
|
|
522
536
|
try {
|
|
523
|
-
(0, utils_1.banner)(
|
|
537
|
+
(0, utils_1.banner)(args.quiet);
|
|
524
538
|
const signer = await getSigner();
|
|
525
|
-
await (0, sdk_1.timeTravel)({ seconds:
|
|
526
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
539
|
+
await (0, sdk_1.timeTravel)({ seconds: args.seconds, signer });
|
|
540
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Fast-forwarded ${args.seconds} seconds`) });
|
|
527
541
|
}
|
|
528
542
|
catch (error) {
|
|
529
543
|
program.error(error.message, { exitCode: 1 });
|
|
530
544
|
}
|
|
531
545
|
});
|
|
532
546
|
program
|
|
533
|
-
.command("
|
|
547
|
+
.command("extractVerifyingKeyToFile")
|
|
534
548
|
.description("extract vkey to json file")
|
|
535
549
|
.requiredOption("--poll-joining-zkey <pollJoiningZkey>", "the poll joining zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
536
550
|
.requiredOption("--poll-joined-zkey <pollJoinedZkey>", "the poll joined zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
537
551
|
.requiredOption("--process-messages-zkey-qv <processMessagesZkeyPathQv>", "the process messages qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
538
552
|
.requiredOption("--tally-votes-zkey-qv <tallyVotesZkeyPathQv>", "the tally votes qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
539
553
|
.requiredOption("--process-messages-zkey-non-qv <processMessagesZkeyPathNonQv>", "the process messages non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
554
|
+
.requiredOption("--process-messages-zkey-full <processMessagesZkeyPathFull>", "the process messages full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
540
555
|
.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
556
|
.requiredOption("-o, --output-file <outputFile>", "the output file path of extracted vkeys")
|
|
542
|
-
.action(async (
|
|
557
|
+
.action(async (args) => {
|
|
543
558
|
try {
|
|
544
|
-
await (0, sdk_1.
|
|
545
|
-
processMessagesZkeyPathQv:
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
559
|
+
await (0, sdk_1.extractVerifyingKeyToFile)({
|
|
560
|
+
processMessagesZkeyPathQv: args.processMessagesZkeyQv,
|
|
561
|
+
processMessagesZkeyPathFull: args.processMessagesZkeyFull,
|
|
562
|
+
tallyVotesZkeyPathQv: args.tallyVotesZkeyQv,
|
|
563
|
+
processMessagesZkeyPathNonQv: args.processMessagesZkeyNonQv,
|
|
564
|
+
tallyVotesZkeyPathNonQv: args.tallyVotesZkeyNonQv,
|
|
565
|
+
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
566
|
+
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
567
|
+
outputFilePath: args.outputFile,
|
|
552
568
|
});
|
|
553
569
|
}
|
|
554
570
|
catch (error) {
|
|
@@ -563,23 +579,23 @@ program
|
|
|
563
579
|
.option("-s, --sg-data <sgData>", "the signup gateway data")
|
|
564
580
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
565
581
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
566
|
-
.action(async (
|
|
582
|
+
.action(async (args) => {
|
|
567
583
|
try {
|
|
568
584
|
const signer = await getSigner();
|
|
569
585
|
const network = await signer.provider?.getNetwork();
|
|
570
586
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
571
587
|
contractNames: [sdk_1.EContracts.MACI],
|
|
572
588
|
network: network?.name,
|
|
573
|
-
defaultAddresses: [
|
|
589
|
+
defaultAddresses: [args.maciAddress],
|
|
574
590
|
});
|
|
575
591
|
const data = await (0, sdk_1.signup)({
|
|
576
|
-
maciPublicKey:
|
|
592
|
+
maciPublicKey: args.publicKey,
|
|
577
593
|
maciAddress,
|
|
578
|
-
sgData:
|
|
594
|
+
sgData: args.sgData ?? utils_1.DEFAULT_SG_DATA,
|
|
579
595
|
signer,
|
|
580
596
|
});
|
|
581
597
|
(0, sdk_1.logGreen)({
|
|
582
|
-
quiet:
|
|
598
|
+
quiet: args.quiet,
|
|
583
599
|
text: (0, sdk_1.success)(`State index: ${data.stateIndex.toString()}\n Transaction hash: ${data.transactionHash}`),
|
|
584
600
|
});
|
|
585
601
|
}
|
|
@@ -593,25 +609,25 @@ program
|
|
|
593
609
|
.requiredOption("-p, --public-key <publicKey>", "the MACI public key")
|
|
594
610
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
595
611
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
596
|
-
.action(async (
|
|
612
|
+
.action(async (args) => {
|
|
597
613
|
try {
|
|
598
614
|
const signer = await getSigner();
|
|
599
615
|
const network = await signer.provider?.getNetwork();
|
|
600
616
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
601
617
|
contractNames: [sdk_1.EContracts.MACI],
|
|
602
618
|
network: network?.name,
|
|
603
|
-
defaultAddresses: [
|
|
619
|
+
defaultAddresses: [args.maciAddress],
|
|
604
620
|
});
|
|
605
621
|
const data = await (0, sdk_1.getSignedupUserData)({
|
|
606
|
-
maciPublicKey:
|
|
622
|
+
maciPublicKey: args.publicKey,
|
|
607
623
|
maciAddress,
|
|
608
624
|
signer,
|
|
609
625
|
});
|
|
610
626
|
if (data.isRegistered) {
|
|
611
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
627
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`State index: ${data.stateIndex?.toString()}`) });
|
|
612
628
|
}
|
|
613
629
|
else {
|
|
614
|
-
(0, sdk_1.logRed)({ quiet:
|
|
630
|
+
(0, sdk_1.logRed)({ quiet: args.quiet, text: "User is not registered" });
|
|
615
631
|
}
|
|
616
632
|
}
|
|
617
633
|
catch (error) {
|
|
@@ -628,25 +644,25 @@ program
|
|
|
628
644
|
.option("--start-block <startBlock>", "the block number to start looking for events from", parseInt)
|
|
629
645
|
.option("--end-block <endBlock>", "the block number to end looking for events from", parseInt)
|
|
630
646
|
.option("--blocks-per-batch <blockPerBatch>", "the number of blocks to process per batch", parseInt)
|
|
631
|
-
.action(async (
|
|
647
|
+
.action(async (args) => {
|
|
632
648
|
try {
|
|
633
649
|
const signer = await getSigner();
|
|
634
650
|
const network = await signer.provider?.getNetwork();
|
|
635
651
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
636
652
|
contractNames: [sdk_1.EContracts.MACI],
|
|
637
653
|
network: network?.name,
|
|
638
|
-
defaultAddresses: [
|
|
654
|
+
defaultAddresses: [args.maciAddress],
|
|
639
655
|
});
|
|
640
656
|
const data = await (0, sdk_1.getJoinedUserData)({
|
|
641
|
-
pollPublicKey:
|
|
642
|
-
startBlock:
|
|
657
|
+
pollPublicKey: args.publicKey,
|
|
658
|
+
startBlock: args.startBlock,
|
|
643
659
|
maciAddress,
|
|
644
|
-
pollId:
|
|
660
|
+
pollId: args.pollId,
|
|
645
661
|
signer,
|
|
646
662
|
});
|
|
647
663
|
if (data.isJoined) {
|
|
648
664
|
(0, sdk_1.logGreen)({
|
|
649
|
-
quiet:
|
|
665
|
+
quiet: args.quiet,
|
|
650
666
|
text: (0, sdk_1.success)([
|
|
651
667
|
`Poll state index: ${data.pollStateIndex?.toString()}, registered: ${data.isJoined}`,
|
|
652
668
|
`Voice credits: ${data.voiceCredits?.toString()}`,
|
|
@@ -654,7 +670,7 @@ program
|
|
|
654
670
|
});
|
|
655
671
|
}
|
|
656
672
|
else {
|
|
657
|
-
(0, sdk_1.logRed)({ quiet:
|
|
673
|
+
(0, sdk_1.logRed)({ quiet: args.quiet, text: "User has not joined the poll" });
|
|
658
674
|
}
|
|
659
675
|
}
|
|
660
676
|
catch (error) {
|
|
@@ -666,29 +682,34 @@ program
|
|
|
666
682
|
.description("Get deployed poll from MACI contract")
|
|
667
683
|
.option("-p, --poll <poll>", "the poll id")
|
|
668
684
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
669
|
-
.action(async (
|
|
685
|
+
.action(async (args) => {
|
|
670
686
|
try {
|
|
671
687
|
const signer = await getSigner();
|
|
672
688
|
const network = await signer.provider?.getNetwork();
|
|
673
689
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
674
690
|
contractNames: [sdk_1.EContracts.MACI],
|
|
675
691
|
network: network?.name,
|
|
676
|
-
defaultAddresses: [
|
|
692
|
+
defaultAddresses: [args.maciAddress],
|
|
677
693
|
});
|
|
678
694
|
const details = await (0, sdk_1.getPoll)({
|
|
679
|
-
pollId:
|
|
695
|
+
pollId: args.poll,
|
|
680
696
|
maciAddress,
|
|
681
697
|
signer,
|
|
682
698
|
});
|
|
699
|
+
const modeNames = {
|
|
700
|
+
[sdk_1.EMode.QV]: "Quadratic Voting",
|
|
701
|
+
[sdk_1.EMode.NON_QV]: "Non-Quadratic Voting",
|
|
702
|
+
[sdk_1.EMode.FULL]: "Full Credits Voting",
|
|
703
|
+
};
|
|
683
704
|
(0, sdk_1.logGreen)({
|
|
684
705
|
quiet: true,
|
|
685
706
|
text: (0, sdk_1.success)([
|
|
686
707
|
`ID: ${details.id}`,
|
|
687
708
|
`Start time: ${new Date(Number(details.startDate) * 1000).toString()}`,
|
|
688
709
|
`End time: ${new Date(Number(details.endDate) * 1000).toString()}`,
|
|
689
|
-
`Number of signups ${details.
|
|
710
|
+
`Number of signups ${details.totalSignups}`,
|
|
690
711
|
`State tree merged: ${details.isMerged}`,
|
|
691
|
-
`Mode: ${details.mode
|
|
712
|
+
`Mode: ${modeNames[details.mode]}`,
|
|
692
713
|
].join("\n")),
|
|
693
714
|
});
|
|
694
715
|
}
|
|
@@ -703,15 +724,15 @@ program
|
|
|
703
724
|
.requiredOption("-w, --address <address>", "the address to fund")
|
|
704
725
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
705
726
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
706
|
-
.action(async (
|
|
727
|
+
.action(async (args) => {
|
|
707
728
|
try {
|
|
708
|
-
(0, utils_1.banner)(
|
|
729
|
+
(0, utils_1.banner)(args.quiet);
|
|
709
730
|
const signer = await getSigner();
|
|
710
|
-
const hash = await (0, sdk_1.fundWallet)({ amount:
|
|
711
|
-
(0, sdk_1.logYellow)({ quiet:
|
|
731
|
+
const hash = await (0, sdk_1.fundWallet)({ amount: args.amount, address: args.address, signer });
|
|
732
|
+
(0, sdk_1.logYellow)({ quiet: args.quiet, text: (0, sdk_1.info)(`Transaction hash: ${hash}`) });
|
|
712
733
|
(0, sdk_1.logGreen)({
|
|
713
|
-
quiet:
|
|
714
|
-
text: (0, sdk_1.success)(`Successfully funded ${
|
|
734
|
+
quiet: args.quiet,
|
|
735
|
+
text: (0, sdk_1.success)(`Successfully funded ${args.address} with ${args.amount} wei`),
|
|
715
736
|
});
|
|
716
737
|
}
|
|
717
738
|
catch (error) {
|
|
@@ -726,34 +747,34 @@ program
|
|
|
726
747
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
727
748
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
728
749
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
729
|
-
.action(async (
|
|
750
|
+
.action(async (args) => {
|
|
730
751
|
try {
|
|
731
|
-
(0, utils_1.banner)(
|
|
752
|
+
(0, utils_1.banner)(args.quiet);
|
|
732
753
|
const signer = await getSigner();
|
|
733
754
|
const network = await signer.provider?.getNetwork();
|
|
734
755
|
// read the tally file
|
|
735
|
-
const isTallyFileExists = fs_1.default.existsSync(
|
|
736
|
-
if (!
|
|
737
|
-
throw new Error(`Unable to open ${
|
|
756
|
+
const isTallyFileExists = fs_1.default.existsSync(args.tallyFile);
|
|
757
|
+
if (!args.tallyFile || !isTallyFileExists) {
|
|
758
|
+
throw new Error(`Unable to open ${args.tallyFile}`);
|
|
738
759
|
}
|
|
739
|
-
const tallyData = await (0, utils_1.readJSONFile)(
|
|
760
|
+
const tallyData = await (0, utils_1.readJSONFile)(args.tallyFile);
|
|
740
761
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
741
762
|
contractNames: [sdk_1.EContracts.MACI],
|
|
742
763
|
network: network?.name,
|
|
743
|
-
defaultAddresses: [
|
|
764
|
+
defaultAddresses: [args.maciAddress],
|
|
744
765
|
});
|
|
745
|
-
const pollParams = await (0, sdk_1.getPollParams)({ pollId:
|
|
766
|
+
const pollParams = await (0, sdk_1.getPollParams)({ pollId: args.pollId, maciContractAddress: maciAddress, signer });
|
|
746
767
|
const tallyCommitments = (0, sdk_1.generateTallyCommitments)({
|
|
747
768
|
tallyData,
|
|
748
769
|
voteOptionTreeDepth: pollParams.voteOptionTreeDepth,
|
|
749
770
|
});
|
|
750
771
|
await (0, sdk_1.verify)({
|
|
751
772
|
tallyData,
|
|
752
|
-
pollId:
|
|
773
|
+
pollId: args.pollId,
|
|
753
774
|
maciAddress,
|
|
754
775
|
signer,
|
|
755
776
|
tallyCommitments,
|
|
756
|
-
|
|
777
|
+
totalVoteOptions: pollParams.totalVoteOptions,
|
|
757
778
|
voteOptionTreeDepth: pollParams.voteOptionTreeDepth,
|
|
758
779
|
});
|
|
759
780
|
}
|
|
@@ -762,7 +783,7 @@ program
|
|
|
762
783
|
}
|
|
763
784
|
});
|
|
764
785
|
program
|
|
765
|
-
.command("
|
|
786
|
+
.command("generateProofs")
|
|
766
787
|
.description("generate the proofs for a poll")
|
|
767
788
|
.option("-k, --private-key <privateKey>", "your serialized MACI private key")
|
|
768
789
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
@@ -787,9 +808,9 @@ program
|
|
|
787
808
|
.option("--start-block <startBlock>", "the block number to start looking for events from", parseInt)
|
|
788
809
|
.option("--end-block <endBlock>", "the block number to end looking for events from", parseInt)
|
|
789
810
|
.option("--blocks-per-batch <blockPerBatch>", "the number of blocks to process per batch", parseInt)
|
|
790
|
-
.option("-
|
|
811
|
+
.option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
|
|
791
812
|
.option("-b, --ipfs-message-backup-files <ipfsMessageBackupFiles>", "Backup files for ipfs messages (name format: ipfsHash1.json, ipfsHash2.json, ..., ipfsHashN.json)", (value) => value?.split(/\s*,\s*/))
|
|
792
|
-
.action(async ({ quiet, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, startBlock, endBlock, blocksPerBatch, privateKey, transactionHash, output, tallyFile, tallyZkey, tallyWitnessgen, tallyWasm, processZkey, processWitnessgen, processWasm,
|
|
813
|
+
.action(async ({ quiet, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, startBlock, endBlock, blocksPerBatch, privateKey, transactionHash, output, tallyFile, tallyZkey, tallyWitnessgen, tallyWasm, processZkey, processWitnessgen, processWasm, mode, tallyWitnessdat, processWitnessdat, wasm, rapidsnark, }) => {
|
|
793
814
|
try {
|
|
794
815
|
(0, utils_1.banner)(quiet);
|
|
795
816
|
const signer = await getSigner();
|
|
@@ -819,7 +840,7 @@ program
|
|
|
819
840
|
processZkey,
|
|
820
841
|
processWitgen: processWitnessgen,
|
|
821
842
|
processWasm,
|
|
822
|
-
|
|
843
|
+
mode,
|
|
823
844
|
tallyDatFile: tallyWitnessdat,
|
|
824
845
|
processDatFile: processWitnessdat,
|
|
825
846
|
useWasm: wasm,
|
|
@@ -831,7 +852,7 @@ program
|
|
|
831
852
|
}
|
|
832
853
|
});
|
|
833
854
|
program
|
|
834
|
-
.command("
|
|
855
|
+
.command("generateLocalState")
|
|
835
856
|
.description("generate a local MACI state from the smart contracts events")
|
|
836
857
|
.requiredOption("-o, --output <outputPath>", "the path where to write the state")
|
|
837
858
|
.requiredOption("-p, --poll-id <pollId>", "the id of the poll", BigInt)
|
|
@@ -846,30 +867,30 @@ program
|
|
|
846
867
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
847
868
|
.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
869
|
.option("-l, --logs-output <logsOutputPath>", "the path where to save the logs for debugging and auditing purposes")
|
|
849
|
-
.action(async (
|
|
870
|
+
.action(async (args) => {
|
|
850
871
|
try {
|
|
851
872
|
const signer = await getSigner();
|
|
852
873
|
const network = await signer.provider?.getNetwork();
|
|
853
874
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
854
875
|
contractNames: [sdk_1.EContracts.MACI],
|
|
855
876
|
network: network?.name,
|
|
856
|
-
defaultAddresses: [
|
|
877
|
+
defaultAddresses: [args.maciAddress],
|
|
857
878
|
});
|
|
858
|
-
const coordinatorPrivateKey =
|
|
879
|
+
const coordinatorPrivateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
|
|
859
880
|
await (0, sdk_1.generateMaciState)({
|
|
860
|
-
outputPath:
|
|
861
|
-
pollId:
|
|
881
|
+
outputPath: args.output.toString(),
|
|
882
|
+
pollId: args.pollId,
|
|
862
883
|
maciAddress,
|
|
863
884
|
coordinatorPrivateKey,
|
|
864
|
-
provider:
|
|
865
|
-
endBlock:
|
|
866
|
-
startBlock:
|
|
867
|
-
blockPerBatch:
|
|
868
|
-
transactionHash:
|
|
869
|
-
ipfsMessageBackupFiles:
|
|
870
|
-
sleep:
|
|
885
|
+
provider: args.rpcProvider,
|
|
886
|
+
endBlock: args.endBlock,
|
|
887
|
+
startBlock: args.startBlock,
|
|
888
|
+
blockPerBatch: args.blocksPerBatch,
|
|
889
|
+
transactionHash: args.transactionHash,
|
|
890
|
+
ipfsMessageBackupFiles: args.ipfsMessageBackupFiles,
|
|
891
|
+
sleep: args.sleep,
|
|
871
892
|
signer,
|
|
872
|
-
logsOutputPath:
|
|
893
|
+
logsOutputPath: args.logsOutput,
|
|
873
894
|
});
|
|
874
895
|
}
|
|
875
896
|
catch (error) {
|
|
@@ -884,20 +905,20 @@ program
|
|
|
884
905
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
885
906
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
886
907
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
887
|
-
.requiredOption("-f, --proof-dir <proofDir>", "the proof output directory from the
|
|
888
|
-
.action(async (
|
|
908
|
+
.requiredOption("-f, --proof-dir <proofDir>", "the proof output directory from the generateProofs subcommand")
|
|
909
|
+
.action(async (args) => {
|
|
889
910
|
try {
|
|
890
911
|
const signer = await getSigner();
|
|
891
912
|
const network = await signer.provider?.getNetwork();
|
|
892
913
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
893
914
|
contractNames: [sdk_1.EContracts.MACI],
|
|
894
915
|
network: network?.name,
|
|
895
|
-
defaultAddresses: [
|
|
916
|
+
defaultAddresses: [args.maciAddress],
|
|
896
917
|
});
|
|
897
918
|
await (0, sdk_1.proveOnChain)({
|
|
898
|
-
pollId:
|
|
899
|
-
tallyFile:
|
|
900
|
-
proofDir:
|
|
919
|
+
pollId: args.pollId,
|
|
920
|
+
tallyFile: args.tallyFile,
|
|
921
|
+
proofDir: args.proofDir,
|
|
901
922
|
maciAddress,
|
|
902
923
|
signer,
|
|
903
924
|
});
|