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