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