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