@maci-protocol/cli 0.0.0-ci.f433bba → 0.0.0-ci.f4e2c46
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 +6 -6
- package/build/ts/index.js +280 -251
- 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 +10 -10
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,81 @@ 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
|
-
.requiredOption("-b, --
|
|
151
|
-
.requiredOption("-p, --
|
|
152
|
-
.requiredOption("-t, --tally-
|
|
151
|
+
.requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
|
|
152
|
+
.requiredOption("-p, --message-processor-zkey <messageProcessorZkeyPath>", "the message processor zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
153
|
+
.requiredOption("-t, --vote-tally-zkey <voteTallyZkeyPath>", "the vote tally zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
pollJoiningZkeyPath:
|
|
173
|
-
pollJoinedZkeyPath:
|
|
174
|
-
|
|
175
|
-
|
|
167
|
+
stateTreeDepth: args.stateTreeDepth,
|
|
168
|
+
tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
|
|
169
|
+
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
170
|
+
messageBatchSize: args.messageBatchSize,
|
|
171
|
+
messageProcessorZkeyPath: args.messageProcessorZkey,
|
|
172
|
+
voteTallyZkeyPath: args.voteTallyZkey,
|
|
173
|
+
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
174
|
+
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
175
|
+
verifyingKeysRegistry: contractAddress,
|
|
176
|
+
mode: args.mode,
|
|
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
|
-
.requiredOption("-k, --
|
|
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, publicKeyAsContractParam } = (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}`) });
|
|
204
|
+
(0, sdk_1.logGreen)({
|
|
205
|
+
quiet: args.quiet,
|
|
206
|
+
text: (0, sdk_1.success)(`Public key as contract param:
|
|
207
|
+
X: ${publicKeyAsContractParam.x}
|
|
208
|
+
Y: ${publicKeyAsContractParam.y}`),
|
|
209
|
+
});
|
|
203
210
|
});
|
|
204
211
|
program
|
|
205
|
-
.command("
|
|
212
|
+
.command("deployVerifyingKeysRegistry")
|
|
206
213
|
.description("deploy a new verification key registry contract")
|
|
207
214
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
208
215
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
209
|
-
.action(async (
|
|
216
|
+
.action(async (args) => {
|
|
210
217
|
try {
|
|
211
|
-
(0, utils_1.banner)(
|
|
218
|
+
(0, utils_1.banner)(args.quiet);
|
|
212
219
|
const signer = await getSigner();
|
|
213
220
|
// assume that the vkRegistry contract is the first one to be deployed
|
|
214
221
|
const isContractAddressesStoreExists = fs_1.default.existsSync(utils_1.contractAddressesStorePath);
|
|
@@ -217,12 +224,15 @@ program
|
|
|
217
224
|
(0, utils_1.resetContractAddresses)(network?.name);
|
|
218
225
|
}
|
|
219
226
|
// deploy and store the address
|
|
220
|
-
const
|
|
227
|
+
const verifyingKeysRegistryAddress = await (0, sdk_1.deployVerifyingKeysRegistryContract)({ signer });
|
|
221
228
|
await (0, utils_1.storeContractAddresses)({
|
|
222
|
-
data: { [sdk_1.EContracts.
|
|
229
|
+
data: { [sdk_1.EContracts.VerifyingKeysRegistry]: { address: verifyingKeysRegistryAddress, args: [] } },
|
|
223
230
|
signer,
|
|
224
231
|
});
|
|
225
|
-
(0, sdk_1.logGreen)({
|
|
232
|
+
(0, sdk_1.logGreen)({
|
|
233
|
+
quiet: args.quiet,
|
|
234
|
+
text: (0, sdk_1.success)(`VerifyingKeysRegistry deployed at: ${verifyingKeysRegistryAddress}`),
|
|
235
|
+
});
|
|
226
236
|
}
|
|
227
237
|
catch (error) {
|
|
228
238
|
program.error(error.message, { exitCode: 1 });
|
|
@@ -249,36 +259,37 @@ program
|
|
|
249
259
|
program
|
|
250
260
|
.command("deployPoll")
|
|
251
261
|
.description("deploy a new poll")
|
|
252
|
-
.option("-k, --
|
|
253
|
-
.requiredOption("
|
|
254
|
-
.requiredOption("
|
|
255
|
-
.requiredOption("-i, --
|
|
256
|
-
.requiredOption("-b, --
|
|
262
|
+
.option("-k, --verifyingKeysRegistryAddress <verifyingKeysRegistryAddress>", "the vk registry contract address")
|
|
263
|
+
.requiredOption("--start <pollStartDate>", "the poll start date", parseInt)
|
|
264
|
+
.requiredOption("--end <pollEndDate>", "the poll end date", parseInt)
|
|
265
|
+
.requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the int state tree depth", parseInt)
|
|
266
|
+
.requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
|
|
267
|
+
.requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
257
268
|
.requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
|
|
258
|
-
.requiredOption("-p, --
|
|
259
|
-
.option("-
|
|
269
|
+
.requiredOption("-p, --public-key <publicKey>", "the coordinator public key")
|
|
270
|
+
.option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
|
|
260
271
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
261
|
-
.option("
|
|
272
|
+
.option("--relayers <relayers>", "the relayer addresses", (value) => value.split(",").map((item) => item.trim()))
|
|
262
273
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
263
274
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
264
275
|
.option("-o, --vote-options <voteOptions>", "the number of vote options", parseInt)
|
|
265
276
|
.option("--initial-voice-credits <initialVoiceCredits>", "the initial voice credits", parseInt)
|
|
266
277
|
.option("--initial-voice-credits-proxy <initialVoiceCreditsProxy>", "the initial voice credits proxy address")
|
|
267
278
|
.option("--signup-policy <signupPolicy>", "the signup policy contract address")
|
|
268
|
-
.action(async (
|
|
279
|
+
.action(async (args) => {
|
|
269
280
|
try {
|
|
270
|
-
(0, utils_1.banner)(
|
|
281
|
+
(0, utils_1.banner)(args.quiet);
|
|
271
282
|
const signer = await getSigner();
|
|
272
283
|
const network = await signer.provider?.getNetwork();
|
|
273
|
-
const [
|
|
284
|
+
const [verifyingKeysRegistryAddress, maciAddress, initialVoiceCreditProxyAddress, verifierContractAddress] = (0, utils_1.readContractAddresses)({
|
|
274
285
|
contractNames: [
|
|
275
|
-
sdk_1.EContracts.
|
|
286
|
+
sdk_1.EContracts.VerifyingKeysRegistry,
|
|
276
287
|
sdk_1.EContracts.MACI,
|
|
277
288
|
sdk_1.EContracts.ConstantInitialVoiceCreditProxy,
|
|
278
289
|
sdk_1.EContracts.Verifier,
|
|
279
290
|
],
|
|
280
291
|
network: network?.name,
|
|
281
|
-
defaultAddresses: [
|
|
292
|
+
defaultAddresses: [args.verifyingKeysRegistryAddress, args.maciAddress, args.initialVoiceCreditsProxy],
|
|
282
293
|
});
|
|
283
294
|
const maciContract = sdk_1.MACI__factory.connect(maciAddress, signer);
|
|
284
295
|
const nextPollId = await maciContract.nextPollId();
|
|
@@ -288,39 +299,40 @@ program
|
|
|
288
299
|
contractNames: [policyContractName.toString()],
|
|
289
300
|
keys: [nextPollId.toString()],
|
|
290
301
|
network: network?.name,
|
|
291
|
-
defaultAddresses: [
|
|
302
|
+
defaultAddresses: [args.signupPolicy],
|
|
292
303
|
});
|
|
293
304
|
const { pollId, pollContractAddress, tallyContractAddress, messageProcessorContractAddress, initialVoiceCreditProxyContractAddress, policyContractAddress, } = await (0, sdk_1.deployPoll)({
|
|
294
|
-
initialVoiceCredits:
|
|
295
|
-
pollStartTimestamp:
|
|
296
|
-
pollEndTimestamp:
|
|
297
|
-
|
|
298
|
-
messageBatchSize:
|
|
299
|
-
|
|
300
|
-
|
|
305
|
+
initialVoiceCredits: args.initialVoiceCredits || defaults_1.DEFAULT_INITIAL_VOICE_CREDITS,
|
|
306
|
+
pollStartTimestamp: args.start,
|
|
307
|
+
pollEndTimestamp: args.end,
|
|
308
|
+
tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
|
|
309
|
+
messageBatchSize: args.messageBatchSize,
|
|
310
|
+
stateTreeDepth: args.stateTreeDepth,
|
|
311
|
+
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
312
|
+
coordinatorPublicKey: domainobjs_1.PublicKey.deserialize(args.publicKey),
|
|
301
313
|
maciAddress,
|
|
302
|
-
|
|
303
|
-
relayers:
|
|
304
|
-
mode:
|
|
314
|
+
verifyingKeysRegistryContractAddress: verifyingKeysRegistryAddress,
|
|
315
|
+
relayers: args.relayers ?? [ethers_1.ZeroAddress],
|
|
316
|
+
mode: args.mode,
|
|
305
317
|
signer,
|
|
306
|
-
voteOptions:
|
|
318
|
+
voteOptions: args.voteOptions ?? defaults_1.DEFAULT_VOTE_OPTIONS,
|
|
307
319
|
verifierContractAddress,
|
|
308
320
|
policyContractAddress: signupPolicyContractAddress,
|
|
309
321
|
initialVoiceCreditProxyContractAddress: initialVoiceCreditProxyAddress,
|
|
310
322
|
});
|
|
311
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
312
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
313
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
323
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Poll ID: ${pollId}`) });
|
|
324
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Poll contract address: ${pollContractAddress}`) });
|
|
325
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Tally contract address: ${tallyContractAddress}`) });
|
|
314
326
|
(0, sdk_1.logGreen)({
|
|
315
|
-
quiet:
|
|
327
|
+
quiet: args.quiet,
|
|
316
328
|
text: (0, sdk_1.success)(`Message processor contract address: ${messageProcessorContractAddress}`),
|
|
317
329
|
});
|
|
318
330
|
(0, sdk_1.logGreen)({
|
|
319
|
-
quiet:
|
|
331
|
+
quiet: args.quiet,
|
|
320
332
|
text: (0, sdk_1.success)(`Initial voice credit proxy contract address: ${initialVoiceCreditProxyContractAddress}`),
|
|
321
333
|
});
|
|
322
334
|
(0, sdk_1.logGreen)({
|
|
323
|
-
quiet:
|
|
335
|
+
quiet: args.quiet,
|
|
324
336
|
text: (0, sdk_1.success)(`Signup policy contract address: ${policyContractAddress}`),
|
|
325
337
|
});
|
|
326
338
|
}
|
|
@@ -331,8 +343,7 @@ program
|
|
|
331
343
|
program
|
|
332
344
|
.command("joinPoll")
|
|
333
345
|
.description("join the poll")
|
|
334
|
-
.requiredOption("-k, --
|
|
335
|
-
.option("-i, --state-index <stateIndex>", "the user's state index", BigInt)
|
|
346
|
+
.requiredOption("-k, --private-key <privateKey>", "the private key")
|
|
336
347
|
.option("-s, --sg-data <sgData>", "the signup policy data")
|
|
337
348
|
.option("-v, --ivcp-data <ivcpData>", "the initial voice credit proxy data")
|
|
338
349
|
.option("-n, --new-voice-credit-balance <newVoiceCreditBalance>", "the voice credit balance of the user for the poll", BigInt)
|
|
@@ -348,38 +359,37 @@ program
|
|
|
348
359
|
.requiredOption("--poll-joining-zkey <pollZkeyPath>", "the poll join zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
349
360
|
.option("-w, --wasm", "whether to use the wasm binaries")
|
|
350
361
|
.option("-r, --rapidsnark <rapidsnark>", "the path to the rapidsnark binary")
|
|
351
|
-
.option("-g, --poll-
|
|
352
|
-
.action(async (
|
|
362
|
+
.option("-g, --poll-witness-generator <pollWitnessGenerator>", "the path to the poll witness generation binary")
|
|
363
|
+
.action(async (args) => {
|
|
353
364
|
try {
|
|
354
365
|
const signer = await getSigner();
|
|
355
366
|
const network = await signer.provider?.getNetwork();
|
|
356
367
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
357
368
|
contractNames: [sdk_1.EContracts.MACI],
|
|
358
369
|
network: network?.name,
|
|
359
|
-
defaultAddresses: [
|
|
370
|
+
defaultAddresses: [args.maciAddress],
|
|
360
371
|
});
|
|
361
|
-
const privateKey =
|
|
372
|
+
const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
|
|
362
373
|
const data = await (0, sdk_1.joinPoll)({
|
|
363
374
|
maciAddress,
|
|
364
375
|
privateKey,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
pollId: cmdObj.pollId,
|
|
376
|
+
stateFile: args.stateFile,
|
|
377
|
+
pollId: args.pollId,
|
|
368
378
|
signer,
|
|
369
|
-
startBlock:
|
|
370
|
-
endBlock:
|
|
371
|
-
blocksPerBatch:
|
|
372
|
-
pollJoiningZkey:
|
|
373
|
-
pollWasm:
|
|
374
|
-
useWasm:
|
|
375
|
-
rapidsnark:
|
|
376
|
-
|
|
377
|
-
sgDataArg:
|
|
378
|
-
ivcpDataArg:
|
|
379
|
-
});
|
|
380
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
381
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
382
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
379
|
+
startBlock: args.startBlock,
|
|
380
|
+
endBlock: args.endBlock,
|
|
381
|
+
blocksPerBatch: args.blocksPerBatch,
|
|
382
|
+
pollJoiningZkey: args.pollJoiningZkey,
|
|
383
|
+
pollWasm: args.pollWasm,
|
|
384
|
+
useWasm: args.wasm,
|
|
385
|
+
rapidsnark: args.rapidsnark,
|
|
386
|
+
pollWitnessGenerator: args.pollWitnessGenerator,
|
|
387
|
+
sgDataArg: args.sgData ?? utils_1.DEFAULT_SG_DATA,
|
|
388
|
+
ivcpDataArg: args.ivcpData ?? utils_1.DEFAULT_IVCP_DATA,
|
|
389
|
+
});
|
|
390
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with nullifier: ${data.nullifier}`) });
|
|
391
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with state index: ${data.pollStateIndex}`) });
|
|
392
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`User joined poll with ${data.voiceCredits} voice credits`) });
|
|
383
393
|
}
|
|
384
394
|
catch (error) {
|
|
385
395
|
program.error(error.message, { exitCode: 1 });
|
|
@@ -389,47 +399,59 @@ program
|
|
|
389
399
|
.command("setVerifyingKeys")
|
|
390
400
|
.description("set the verifying keys")
|
|
391
401
|
.requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
392
|
-
.requiredOption("-i, --
|
|
402
|
+
.requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the intermediate state tree depth", parseInt)
|
|
393
403
|
.requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
|
|
394
|
-
.requiredOption("-b, --
|
|
404
|
+
.requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
|
|
405
|
+
.option("--poll-state-tree-depth <pollStateTreeDepth>", "the poll state tree depth", parseInt)
|
|
395
406
|
.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)")
|
|
396
407
|
.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)")
|
|
397
|
-
.option("--
|
|
398
|
-
.option("--tally-
|
|
399
|
-
.option("--
|
|
400
|
-
.option("--tally-
|
|
401
|
-
.option("
|
|
408
|
+
.option("--message-processor-zkey-qv <messageProcessorZkeyPathQv>", "the message processor qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
409
|
+
.option("--vote-tally-zkey-qv <voteTallyZkeyPathQv>", "the vote tally qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
410
|
+
.option("--message-processor-zkey-non-qv <messageProcessorZkeyPathNonQv>", "the message processor non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
411
|
+
.option("--vote-tally-zkey-non-qv <voteTallyZkeyPathNonQv>", "the vote tally non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
412
|
+
.option("--message-processor-zkey-full <messageProcessorZkeyPathFull>", "the message processor full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
413
|
+
.option("--vote-tally-zkey-full <tallyVotesZkeyPathFull>", "the vote tally full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
414
|
+
.option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
|
|
402
415
|
.option("-k, --vk-registry <vkRegistry>", "the vk registry contract address")
|
|
403
416
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
404
417
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
405
|
-
.action(async (
|
|
418
|
+
.action(async (args) => {
|
|
406
419
|
try {
|
|
407
420
|
const signer = await getSigner();
|
|
408
421
|
const network = await signer.provider?.getNetwork();
|
|
409
|
-
const [
|
|
410
|
-
contractNames: [sdk_1.EContracts.
|
|
422
|
+
const [verifyingKeysRegistryAddress] = (0, utils_1.readContractAddresses)({
|
|
423
|
+
contractNames: [sdk_1.EContracts.VerifyingKeysRegistry],
|
|
411
424
|
network: network?.name,
|
|
412
|
-
defaultAddresses: [
|
|
425
|
+
defaultAddresses: [args.vkRegistry],
|
|
413
426
|
});
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
427
|
+
const processKeys = {
|
|
428
|
+
[sdk_1.EMode.QV]: args.messageProcessorZkeyQv,
|
|
429
|
+
[sdk_1.EMode.NON_QV]: args.messageProcessorZkeyNonQv,
|
|
430
|
+
[sdk_1.EMode.FULL]: args.messageProcessorZkeyFull,
|
|
431
|
+
};
|
|
432
|
+
const tallyKeys = {
|
|
433
|
+
[sdk_1.EMode.QV]: args.voteTallyZkeyQv,
|
|
434
|
+
[sdk_1.EMode.NON_QV]: args.voteTallyZkeyNonQv,
|
|
435
|
+
[sdk_1.EMode.FULL]: args.voteTallyZkeyFull,
|
|
436
|
+
};
|
|
437
|
+
const { pollJoiningVerifyingKey, pollJoinedVerifyingKey, processVerifyingKey, tallyVerifyingKey } = await (0, sdk_1.extractAllVerifyingKeys)({
|
|
438
|
+
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
439
|
+
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
440
|
+
messageProcessorZkeyPath: processKeys[args.mode],
|
|
441
|
+
voteTallyZkeyPath: tallyKeys[args.mode],
|
|
421
442
|
});
|
|
422
443
|
await (0, sdk_1.setVerifyingKeys)({
|
|
423
|
-
stateTreeDepth:
|
|
424
|
-
|
|
425
|
-
voteOptionTreeDepth:
|
|
426
|
-
messageBatchSize:
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
444
|
+
stateTreeDepth: args.stateTreeDepth,
|
|
445
|
+
tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
|
|
446
|
+
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
447
|
+
messageBatchSize: args.messageBatchSize,
|
|
448
|
+
pollStateTreeDepth: args.pollStateTreeDepth || args.stateTreeDepth,
|
|
449
|
+
pollJoiningVerifyingKey: pollJoiningVerifyingKey,
|
|
450
|
+
pollJoinedVerifyingKey: pollJoinedVerifyingKey,
|
|
451
|
+
processMessagesVerifyingKey: processVerifyingKey,
|
|
452
|
+
tallyVotesVerifyingKey: tallyVerifyingKey,
|
|
453
|
+
verifyingKeysRegistryAddress,
|
|
454
|
+
mode: args.mode,
|
|
433
455
|
signer,
|
|
434
456
|
});
|
|
435
457
|
}
|
|
@@ -440,9 +462,9 @@ program
|
|
|
440
462
|
program
|
|
441
463
|
.command("publish")
|
|
442
464
|
.description("publish a new message to a MACI Poll contract")
|
|
443
|
-
.requiredOption("-p, --
|
|
465
|
+
.requiredOption("-p, --public-key <publicKey>", "the MACI public key which should replace the user's public key in the state tree")
|
|
444
466
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
445
|
-
.option("-k, --
|
|
467
|
+
.option("-k, --private-key <privateKey>", "your serialized MACI private key")
|
|
446
468
|
.requiredOption("-i, --state-index <stateIndex>", "the user's state index", BigInt)
|
|
447
469
|
.requiredOption("-v, --vote-option-index <voteOptionIndex>", "the vote option index", BigInt)
|
|
448
470
|
.requiredOption("-n, --nonce <nonce>", "the message nonce", BigInt)
|
|
@@ -451,25 +473,25 @@ program
|
|
|
451
473
|
.requiredOption("-w, --new-vote-weight <newVoteWeight>", "the new vote weight", BigInt)
|
|
452
474
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
453
475
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
454
|
-
.action(async (
|
|
476
|
+
.action(async (args) => {
|
|
455
477
|
try {
|
|
456
478
|
const signer = await getSigner();
|
|
457
479
|
const network = await signer.provider?.getNetwork();
|
|
458
480
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
459
481
|
contractNames: [sdk_1.EContracts.MACI],
|
|
460
482
|
network: network?.name,
|
|
461
|
-
defaultAddresses: [
|
|
483
|
+
defaultAddresses: [args.maciAddress],
|
|
462
484
|
});
|
|
463
|
-
const privateKey =
|
|
485
|
+
const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
|
|
464
486
|
await (0, sdk_1.publish)({
|
|
465
|
-
|
|
466
|
-
stateIndex:
|
|
467
|
-
voteOptionIndex:
|
|
468
|
-
nonce:
|
|
469
|
-
pollId:
|
|
470
|
-
newVoteWeight:
|
|
487
|
+
publicKey: args.publicKey,
|
|
488
|
+
stateIndex: args.stateIndex,
|
|
489
|
+
voteOptionIndex: args.voteOptionIndex,
|
|
490
|
+
nonce: args.nonce,
|
|
491
|
+
pollId: args.pollId,
|
|
492
|
+
newVoteWeight: args.newVoteWeight,
|
|
471
493
|
maciAddress,
|
|
472
|
-
salt:
|
|
494
|
+
salt: args.salt,
|
|
473
495
|
privateKey,
|
|
474
496
|
signer,
|
|
475
497
|
});
|
|
@@ -484,23 +506,23 @@ program
|
|
|
484
506
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
485
507
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
486
508
|
.requiredOption("-p, --poll-id <pollId>", "the poll id", BigInt)
|
|
487
|
-
.action(async (
|
|
509
|
+
.action(async (args) => {
|
|
488
510
|
try {
|
|
489
511
|
const signer = await getSigner();
|
|
490
512
|
const network = await signer.provider?.getNetwork();
|
|
491
513
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
492
514
|
contractNames: [sdk_1.EContracts.MACI],
|
|
493
515
|
network: network?.name,
|
|
494
|
-
defaultAddresses: [
|
|
516
|
+
defaultAddresses: [args.maciAddress],
|
|
495
517
|
});
|
|
496
518
|
const receipt = await (0, sdk_1.mergeSignups)({
|
|
497
|
-
pollId:
|
|
519
|
+
pollId: args.pollId,
|
|
498
520
|
maciAddress,
|
|
499
521
|
signer,
|
|
500
522
|
});
|
|
501
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
523
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.info)(`Transaction hash: ${receipt.hash}`) });
|
|
502
524
|
(0, sdk_1.logGreen)({
|
|
503
|
-
quiet:
|
|
525
|
+
quiet: args.quiet,
|
|
504
526
|
text: (0, sdk_1.success)(`Executed mergeSignups(); gas used: ${receipt.gasUsed.toString()}`),
|
|
505
527
|
});
|
|
506
528
|
}
|
|
@@ -514,37 +536,39 @@ program
|
|
|
514
536
|
.requiredOption("-s, --seconds <seconds>", "the number of seconds to fast-forward", parseInt)
|
|
515
537
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
516
538
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
517
|
-
.action(async (
|
|
539
|
+
.action(async (args) => {
|
|
518
540
|
try {
|
|
519
|
-
(0, utils_1.banner)(
|
|
541
|
+
(0, utils_1.banner)(args.quiet);
|
|
520
542
|
const signer = await getSigner();
|
|
521
|
-
await (0, sdk_1.timeTravel)({ seconds:
|
|
522
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
543
|
+
await (0, sdk_1.timeTravel)({ seconds: args.seconds, signer });
|
|
544
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Fast-forwarded ${args.seconds} seconds`) });
|
|
523
545
|
}
|
|
524
546
|
catch (error) {
|
|
525
547
|
program.error(error.message, { exitCode: 1 });
|
|
526
548
|
}
|
|
527
549
|
});
|
|
528
550
|
program
|
|
529
|
-
.command("
|
|
551
|
+
.command("extractVerifyingKeyToFile")
|
|
530
552
|
.description("extract vkey to json file")
|
|
531
553
|
.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)")
|
|
532
554
|
.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)")
|
|
533
|
-
.requiredOption("--
|
|
534
|
-
.requiredOption("--tally-
|
|
535
|
-
.requiredOption("--
|
|
536
|
-
.requiredOption("--
|
|
555
|
+
.requiredOption("--message-processor-zkey-qv <messageProcessorZkeyPathQv>", "the message processor qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
556
|
+
.requiredOption("--vote-tally-zkey-qv <voteTallyZkeyPathQv>", "the vote tally qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
557
|
+
.requiredOption("--message-processor-zkey-non-qv <messageProcessorZkeyPathNonQv>", "the message processor non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
558
|
+
.requiredOption("--message-processor-zkey-full <messageProcessorZkeyPathFull>", "the message processor full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
559
|
+
.requiredOption("--vote-tally-zkey-non-qv <voteTallyZkeyPathNonQv>", "the vote tally non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
537
560
|
.requiredOption("-o, --output-file <outputFile>", "the output file path of extracted vkeys")
|
|
538
|
-
.action(async (
|
|
561
|
+
.action(async (args) => {
|
|
539
562
|
try {
|
|
540
|
-
await (0, sdk_1.
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
563
|
+
await (0, sdk_1.extractVerifyingKeyToFile)({
|
|
564
|
+
messageProcessorZkeyPathQv: args.messageProcessorZkeyQv,
|
|
565
|
+
messageProcessorZkeyPathFull: args.messageProcessorZkeyFull,
|
|
566
|
+
voteTallyZkeyPathQv: args.voteTallyZkeyQv,
|
|
567
|
+
messageProcessorZkeyPathNonQv: args.messageProcessorZkeyNonQv,
|
|
568
|
+
voteTallyZkeyPathNonQv: args.voteTallyZkeyNonQv,
|
|
569
|
+
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
570
|
+
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
571
|
+
outputFilePath: args.outputFile,
|
|
548
572
|
});
|
|
549
573
|
}
|
|
550
574
|
catch (error) {
|
|
@@ -554,28 +578,28 @@ program
|
|
|
554
578
|
program
|
|
555
579
|
.command("signup")
|
|
556
580
|
.description("Sign up to a MACI contract")
|
|
557
|
-
.requiredOption("-p, --
|
|
581
|
+
.requiredOption("-p, --public-key <publicKey>", "the MACI public key")
|
|
558
582
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
559
583
|
.option("-s, --sg-data <sgData>", "the signup gateway data")
|
|
560
584
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
561
585
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
562
|
-
.action(async (
|
|
586
|
+
.action(async (args) => {
|
|
563
587
|
try {
|
|
564
588
|
const signer = await getSigner();
|
|
565
589
|
const network = await signer.provider?.getNetwork();
|
|
566
590
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
567
591
|
contractNames: [sdk_1.EContracts.MACI],
|
|
568
592
|
network: network?.name,
|
|
569
|
-
defaultAddresses: [
|
|
593
|
+
defaultAddresses: [args.maciAddress],
|
|
570
594
|
});
|
|
571
595
|
const data = await (0, sdk_1.signup)({
|
|
572
|
-
|
|
596
|
+
maciPublicKey: args.publicKey,
|
|
573
597
|
maciAddress,
|
|
574
|
-
sgData:
|
|
598
|
+
sgData: args.sgData ?? utils_1.DEFAULT_SG_DATA,
|
|
575
599
|
signer,
|
|
576
600
|
});
|
|
577
601
|
(0, sdk_1.logGreen)({
|
|
578
|
-
quiet:
|
|
602
|
+
quiet: args.quiet,
|
|
579
603
|
text: (0, sdk_1.success)(`State index: ${data.stateIndex.toString()}\n Transaction hash: ${data.transactionHash}`),
|
|
580
604
|
});
|
|
581
605
|
}
|
|
@@ -586,28 +610,28 @@ program
|
|
|
586
610
|
program
|
|
587
611
|
.command("isRegisteredUser")
|
|
588
612
|
.description("Checks if user is registered with their public key and get their data")
|
|
589
|
-
.requiredOption("-p, --
|
|
613
|
+
.requiredOption("-p, --public-key <publicKey>", "the MACI public key")
|
|
590
614
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
591
615
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
592
|
-
.action(async (
|
|
616
|
+
.action(async (args) => {
|
|
593
617
|
try {
|
|
594
618
|
const signer = await getSigner();
|
|
595
619
|
const network = await signer.provider?.getNetwork();
|
|
596
620
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
597
621
|
contractNames: [sdk_1.EContracts.MACI],
|
|
598
622
|
network: network?.name,
|
|
599
|
-
defaultAddresses: [
|
|
623
|
+
defaultAddresses: [args.maciAddress],
|
|
600
624
|
});
|
|
601
625
|
const data = await (0, sdk_1.getSignedupUserData)({
|
|
602
|
-
|
|
626
|
+
maciPublicKey: args.publicKey,
|
|
603
627
|
maciAddress,
|
|
604
628
|
signer,
|
|
605
629
|
});
|
|
606
630
|
if (data.isRegistered) {
|
|
607
|
-
(0, sdk_1.logGreen)({ quiet:
|
|
631
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`State index: ${data.stateIndex?.toString()}`) });
|
|
608
632
|
}
|
|
609
633
|
else {
|
|
610
|
-
(0, sdk_1.logRed)({ quiet:
|
|
634
|
+
(0, sdk_1.logRed)({ quiet: args.quiet, text: "User is not registered" });
|
|
611
635
|
}
|
|
612
636
|
}
|
|
613
637
|
catch (error) {
|
|
@@ -617,32 +641,32 @@ program
|
|
|
617
641
|
program
|
|
618
642
|
.command("isJoinedUser")
|
|
619
643
|
.description("Checks if user is joined to the poll with public key")
|
|
620
|
-
.requiredOption("-p, --
|
|
644
|
+
.requiredOption("-p, --public-key <publicKey>", "the MACI public key")
|
|
621
645
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
622
646
|
.requiredOption("-o, --poll-id <pollId>", "the poll id", BigInt)
|
|
623
647
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
624
648
|
.option("--start-block <startBlock>", "the block number to start looking for events from", parseInt)
|
|
625
649
|
.option("--end-block <endBlock>", "the block number to end looking for events from", parseInt)
|
|
626
650
|
.option("--blocks-per-batch <blockPerBatch>", "the number of blocks to process per batch", parseInt)
|
|
627
|
-
.action(async (
|
|
651
|
+
.action(async (args) => {
|
|
628
652
|
try {
|
|
629
653
|
const signer = await getSigner();
|
|
630
654
|
const network = await signer.provider?.getNetwork();
|
|
631
655
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
632
656
|
contractNames: [sdk_1.EContracts.MACI],
|
|
633
657
|
network: network?.name,
|
|
634
|
-
defaultAddresses: [
|
|
658
|
+
defaultAddresses: [args.maciAddress],
|
|
635
659
|
});
|
|
636
660
|
const data = await (0, sdk_1.getJoinedUserData)({
|
|
637
|
-
|
|
638
|
-
startBlock:
|
|
661
|
+
pollPublicKey: args.publicKey,
|
|
662
|
+
startBlock: args.startBlock,
|
|
639
663
|
maciAddress,
|
|
640
|
-
pollId:
|
|
664
|
+
pollId: args.pollId,
|
|
641
665
|
signer,
|
|
642
666
|
});
|
|
643
667
|
if (data.isJoined) {
|
|
644
668
|
(0, sdk_1.logGreen)({
|
|
645
|
-
quiet:
|
|
669
|
+
quiet: args.quiet,
|
|
646
670
|
text: (0, sdk_1.success)([
|
|
647
671
|
`Poll state index: ${data.pollStateIndex?.toString()}, registered: ${data.isJoined}`,
|
|
648
672
|
`Voice credits: ${data.voiceCredits?.toString()}`,
|
|
@@ -650,7 +674,7 @@ program
|
|
|
650
674
|
});
|
|
651
675
|
}
|
|
652
676
|
else {
|
|
653
|
-
(0, sdk_1.logRed)({ quiet:
|
|
677
|
+
(0, sdk_1.logRed)({ quiet: args.quiet, text: "User has not joined the poll" });
|
|
654
678
|
}
|
|
655
679
|
}
|
|
656
680
|
catch (error) {
|
|
@@ -662,29 +686,34 @@ program
|
|
|
662
686
|
.description("Get deployed poll from MACI contract")
|
|
663
687
|
.option("-p, --poll <poll>", "the poll id")
|
|
664
688
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
665
|
-
.action(async (
|
|
689
|
+
.action(async (args) => {
|
|
666
690
|
try {
|
|
667
691
|
const signer = await getSigner();
|
|
668
692
|
const network = await signer.provider?.getNetwork();
|
|
669
693
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
670
694
|
contractNames: [sdk_1.EContracts.MACI],
|
|
671
695
|
network: network?.name,
|
|
672
|
-
defaultAddresses: [
|
|
696
|
+
defaultAddresses: [args.maciAddress],
|
|
673
697
|
});
|
|
674
698
|
const details = await (0, sdk_1.getPoll)({
|
|
675
|
-
pollId:
|
|
699
|
+
pollId: args.poll,
|
|
676
700
|
maciAddress,
|
|
677
701
|
signer,
|
|
678
702
|
});
|
|
703
|
+
const modeNames = {
|
|
704
|
+
[sdk_1.EMode.QV]: "Quadratic Voting",
|
|
705
|
+
[sdk_1.EMode.NON_QV]: "Non-Quadratic Voting",
|
|
706
|
+
[sdk_1.EMode.FULL]: "Full Credits Voting",
|
|
707
|
+
};
|
|
679
708
|
(0, sdk_1.logGreen)({
|
|
680
709
|
quiet: true,
|
|
681
710
|
text: (0, sdk_1.success)([
|
|
682
711
|
`ID: ${details.id}`,
|
|
683
712
|
`Start time: ${new Date(Number(details.startDate) * 1000).toString()}`,
|
|
684
713
|
`End time: ${new Date(Number(details.endDate) * 1000).toString()}`,
|
|
685
|
-
`Number of signups ${details.
|
|
714
|
+
`Number of signups ${details.totalSignups}`,
|
|
686
715
|
`State tree merged: ${details.isMerged}`,
|
|
687
|
-
`Mode: ${details.mode
|
|
716
|
+
`Mode: ${modeNames[details.mode]}`,
|
|
688
717
|
].join("\n")),
|
|
689
718
|
});
|
|
690
719
|
}
|
|
@@ -699,15 +728,15 @@ program
|
|
|
699
728
|
.requiredOption("-w, --address <address>", "the address to fund")
|
|
700
729
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
701
730
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
702
|
-
.action(async (
|
|
731
|
+
.action(async (args) => {
|
|
703
732
|
try {
|
|
704
|
-
(0, utils_1.banner)(
|
|
733
|
+
(0, utils_1.banner)(args.quiet);
|
|
705
734
|
const signer = await getSigner();
|
|
706
|
-
const hash = await (0, sdk_1.fundWallet)({ amount:
|
|
707
|
-
(0, sdk_1.logYellow)({ quiet:
|
|
735
|
+
const hash = await (0, sdk_1.fundWallet)({ amount: args.amount, address: args.address, signer });
|
|
736
|
+
(0, sdk_1.logYellow)({ quiet: args.quiet, text: (0, sdk_1.info)(`Transaction hash: ${hash}`) });
|
|
708
737
|
(0, sdk_1.logGreen)({
|
|
709
|
-
quiet:
|
|
710
|
-
text: (0, sdk_1.success)(`Successfully funded ${
|
|
738
|
+
quiet: args.quiet,
|
|
739
|
+
text: (0, sdk_1.success)(`Successfully funded ${args.address} with ${args.amount} wei`),
|
|
711
740
|
});
|
|
712
741
|
}
|
|
713
742
|
catch (error) {
|
|
@@ -722,34 +751,34 @@ program
|
|
|
722
751
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
723
752
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
724
753
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
725
|
-
.action(async (
|
|
754
|
+
.action(async (args) => {
|
|
726
755
|
try {
|
|
727
|
-
(0, utils_1.banner)(
|
|
756
|
+
(0, utils_1.banner)(args.quiet);
|
|
728
757
|
const signer = await getSigner();
|
|
729
758
|
const network = await signer.provider?.getNetwork();
|
|
730
759
|
// read the tally file
|
|
731
|
-
const isTallyFileExists = fs_1.default.existsSync(
|
|
732
|
-
if (!
|
|
733
|
-
throw new Error(`Unable to open ${
|
|
760
|
+
const isTallyFileExists = fs_1.default.existsSync(args.tallyFile);
|
|
761
|
+
if (!args.tallyFile || !isTallyFileExists) {
|
|
762
|
+
throw new Error(`Unable to open ${args.tallyFile}`);
|
|
734
763
|
}
|
|
735
|
-
const tallyData = await (0, utils_1.readJSONFile)(
|
|
764
|
+
const tallyData = await (0, utils_1.readJSONFile)(args.tallyFile);
|
|
736
765
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
737
766
|
contractNames: [sdk_1.EContracts.MACI],
|
|
738
767
|
network: network?.name,
|
|
739
|
-
defaultAddresses: [
|
|
768
|
+
defaultAddresses: [args.maciAddress],
|
|
740
769
|
});
|
|
741
|
-
const pollParams = await (0, sdk_1.getPollParams)({ pollId:
|
|
770
|
+
const pollParams = await (0, sdk_1.getPollParams)({ pollId: args.pollId, maciContractAddress: maciAddress, signer });
|
|
742
771
|
const tallyCommitments = (0, sdk_1.generateTallyCommitments)({
|
|
743
772
|
tallyData,
|
|
744
773
|
voteOptionTreeDepth: pollParams.voteOptionTreeDepth,
|
|
745
774
|
});
|
|
746
775
|
await (0, sdk_1.verify)({
|
|
747
776
|
tallyData,
|
|
748
|
-
pollId:
|
|
777
|
+
pollId: args.pollId,
|
|
749
778
|
maciAddress,
|
|
750
779
|
signer,
|
|
751
780
|
tallyCommitments,
|
|
752
|
-
|
|
781
|
+
totalVoteOptions: pollParams.totalVoteOptions,
|
|
753
782
|
voteOptionTreeDepth: pollParams.voteOptionTreeDepth,
|
|
754
783
|
});
|
|
755
784
|
}
|
|
@@ -758,34 +787,34 @@ program
|
|
|
758
787
|
}
|
|
759
788
|
});
|
|
760
789
|
program
|
|
761
|
-
.command("
|
|
790
|
+
.command("generateProofs")
|
|
762
791
|
.description("generate the proofs for a poll")
|
|
763
|
-
.option("-k, --
|
|
792
|
+
.option("-k, --private-key <privateKey>", "your serialized MACI private key")
|
|
764
793
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
765
794
|
.requiredOption("-o, --poll-id <pollId>", "the poll id", BigInt)
|
|
766
795
|
.requiredOption("-t, --tally-file <tallyFile>", "the tally file with results, per vote option spent credits, spent voice credits total")
|
|
767
796
|
.option("-r, --rapidsnark <rapidsnark>", "the path to the rapidsnark binary")
|
|
768
|
-
.option("-g, --
|
|
769
|
-
.option("--
|
|
770
|
-
.option("--tally-
|
|
771
|
-
.option("--tally-
|
|
797
|
+
.option("-g, --message-processor-witness-generator <messageProcessorWitnessGenerator>", "the path to the process witness generation binary")
|
|
798
|
+
.option("--message-processor-witnessDat <messageProcessorWitnessDat>", "the path to the process witness dat file")
|
|
799
|
+
.option("--vote-tally-witness-generator <voteTallyWitnessGenerator>", "the path to the tally witness generation binary")
|
|
800
|
+
.option("--vote-tally-witnessDat <voteTallyWitnessDat>", "the path to the tally witness dat file")
|
|
772
801
|
.requiredOption("--poll-joining-zkey <processJoinZkey>", "the path to the poll join zkey")
|
|
773
|
-
.requiredOption("--
|
|
774
|
-
.requiredOption("--tally-zkey <
|
|
802
|
+
.requiredOption("--message-processor-zkey <messageProcessorZkey>", "the path to the process zkey")
|
|
803
|
+
.requiredOption("--vote-tally-zkey <voteTallyZkey>", "the path to the tally zkey")
|
|
775
804
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
776
805
|
.option("-p, --rpc-provider <provider>", "the rpc provider URL")
|
|
777
806
|
.requiredOption("-f, --output <outputDir>", "the output directory for proofs")
|
|
778
807
|
.option("--transaction-hash <transactionHash>", "transaction hash of MACI contract creation")
|
|
779
808
|
.option("-w, --wasm", "whether to use the wasm binaries")
|
|
780
|
-
.option("--
|
|
781
|
-
.option("--tally-wasm <
|
|
809
|
+
.option("--message-processor-wasm <messageProcessorWasm>", "the path to the process witness generation wasm binary")
|
|
810
|
+
.option("--vote-tally-wasm <voteTallyWasm>", "the path to the tally witness generation wasm binary")
|
|
782
811
|
.option("--state-file <stateFile>", "the path to the state file containing the serialized maci state")
|
|
783
812
|
.option("--start-block <startBlock>", "the block number to start looking for events from", parseInt)
|
|
784
813
|
.option("--end-block <endBlock>", "the block number to end looking for events from", parseInt)
|
|
785
814
|
.option("--blocks-per-batch <blockPerBatch>", "the number of blocks to process per batch", parseInt)
|
|
786
|
-
.option("-
|
|
815
|
+
.option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
|
|
787
816
|
.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*/))
|
|
788
|
-
.action(async ({ quiet, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, startBlock, endBlock, blocksPerBatch,
|
|
817
|
+
.action(async ({ quiet, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, startBlock, endBlock, blocksPerBatch, privateKey, transactionHash, output, tallyFile, voteTallyZkey, voteTallyWitnessGenerator, voteTallyWasm, messageProcessorZkey, messageProcessorWitnessGenerator, messageProcessorWasm, mode, voteTallyWitnessDat, messageProcessorWitnessDat, wasm, rapidsnark, }) => {
|
|
789
818
|
try {
|
|
790
819
|
(0, utils_1.banner)(quiet);
|
|
791
820
|
const signer = await getSigner();
|
|
@@ -795,7 +824,7 @@ program
|
|
|
795
824
|
network: network?.name,
|
|
796
825
|
defaultAddresses: [maciAddress],
|
|
797
826
|
});
|
|
798
|
-
const coordinatorPrivateKey =
|
|
827
|
+
const coordinatorPrivateKey = privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
|
|
799
828
|
await (0, sdk_1.generateProofs)({
|
|
800
829
|
maciAddress: maciContractAddress,
|
|
801
830
|
coordinatorPrivateKey,
|
|
@@ -809,15 +838,15 @@ program
|
|
|
809
838
|
signer,
|
|
810
839
|
outputDir: output,
|
|
811
840
|
tallyFile,
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
841
|
+
voteTallyZkey,
|
|
842
|
+
voteTallyWitnessGenerator,
|
|
843
|
+
voteTallyWasm,
|
|
844
|
+
messageProcessorZkey,
|
|
845
|
+
messageProcessorWitnessGenerator,
|
|
846
|
+
messageProcessorWasm,
|
|
847
|
+
mode,
|
|
848
|
+
voteTallyWitnessDatFile: voteTallyWitnessDat,
|
|
849
|
+
messageProcessorWitnessDatFile: messageProcessorWitnessDat,
|
|
821
850
|
useWasm: wasm,
|
|
822
851
|
rapidsnark,
|
|
823
852
|
});
|
|
@@ -827,12 +856,12 @@ program
|
|
|
827
856
|
}
|
|
828
857
|
});
|
|
829
858
|
program
|
|
830
|
-
.command("
|
|
859
|
+
.command("generateLocalState")
|
|
831
860
|
.description("generate a local MACI state from the smart contracts events")
|
|
832
861
|
.requiredOption("-o, --output <outputPath>", "the path where to write the state")
|
|
833
862
|
.requiredOption("-p, --poll-id <pollId>", "the id of the poll", BigInt)
|
|
834
863
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
835
|
-
.option("-k, --
|
|
864
|
+
.option("-k, --private-key <privateKey>", "your serialized MACI private key")
|
|
836
865
|
.option("--start-block <startBlock>", "the start block number", parseInt)
|
|
837
866
|
.option("--end-block <endBlock>", "the end block number", parseInt)
|
|
838
867
|
.option("--blocks-per-batch <blockPerBatch>", "the blocks per batch", parseInt)
|
|
@@ -842,30 +871,30 @@ program
|
|
|
842
871
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
843
872
|
.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*/))
|
|
844
873
|
.option("-l, --logs-output <logsOutputPath>", "the path where to save the logs for debugging and auditing purposes")
|
|
845
|
-
.action(async (
|
|
874
|
+
.action(async (args) => {
|
|
846
875
|
try {
|
|
847
876
|
const signer = await getSigner();
|
|
848
877
|
const network = await signer.provider?.getNetwork();
|
|
849
878
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
850
879
|
contractNames: [sdk_1.EContracts.MACI],
|
|
851
880
|
network: network?.name,
|
|
852
|
-
defaultAddresses: [
|
|
881
|
+
defaultAddresses: [args.maciAddress],
|
|
853
882
|
});
|
|
854
|
-
const coordinatorPrivateKey =
|
|
883
|
+
const coordinatorPrivateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
|
|
855
884
|
await (0, sdk_1.generateMaciState)({
|
|
856
|
-
outputPath:
|
|
857
|
-
pollId:
|
|
885
|
+
outputPath: args.output.toString(),
|
|
886
|
+
pollId: args.pollId,
|
|
858
887
|
maciAddress,
|
|
859
888
|
coordinatorPrivateKey,
|
|
860
|
-
provider:
|
|
861
|
-
endBlock:
|
|
862
|
-
startBlock:
|
|
863
|
-
blockPerBatch:
|
|
864
|
-
transactionHash:
|
|
865
|
-
ipfsMessageBackupFiles:
|
|
866
|
-
sleep:
|
|
889
|
+
provider: args.rpcProvider,
|
|
890
|
+
endBlock: args.endBlock,
|
|
891
|
+
startBlock: args.startBlock,
|
|
892
|
+
blockPerBatch: args.blocksPerBatch,
|
|
893
|
+
transactionHash: args.transactionHash,
|
|
894
|
+
ipfsMessageBackupFiles: args.ipfsMessageBackupFiles,
|
|
895
|
+
sleep: args.sleep,
|
|
867
896
|
signer,
|
|
868
|
-
logsOutputPath:
|
|
897
|
+
logsOutputPath: args.logsOutput,
|
|
869
898
|
});
|
|
870
899
|
}
|
|
871
900
|
catch (error) {
|
|
@@ -880,20 +909,20 @@ program
|
|
|
880
909
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
881
910
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
882
911
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
883
|
-
.requiredOption("-f, --proof-dir <proofDir>", "the proof output directory from the
|
|
884
|
-
.action(async (
|
|
912
|
+
.requiredOption("-f, --proof-dir <proofDir>", "the proof output directory from the generateProofs subcommand")
|
|
913
|
+
.action(async (args) => {
|
|
885
914
|
try {
|
|
886
915
|
const signer = await getSigner();
|
|
887
916
|
const network = await signer.provider?.getNetwork();
|
|
888
917
|
const [maciAddress] = (0, utils_1.readContractAddresses)({
|
|
889
918
|
contractNames: [sdk_1.EContracts.MACI],
|
|
890
919
|
network: network?.name,
|
|
891
|
-
defaultAddresses: [
|
|
920
|
+
defaultAddresses: [args.maciAddress],
|
|
892
921
|
});
|
|
893
922
|
await (0, sdk_1.proveOnChain)({
|
|
894
|
-
pollId:
|
|
895
|
-
tallyFile:
|
|
896
|
-
proofDir:
|
|
923
|
+
pollId: args.pollId,
|
|
924
|
+
tallyFile: args.tallyFile,
|
|
925
|
+
proofDir: args.proofDir,
|
|
897
926
|
maciAddress,
|
|
898
927
|
signer,
|
|
899
928
|
});
|