@maci-protocol/sdk 0.0.0-ci.ce69388 → 0.0.0-ci.cf2cc5b
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 +16 -8
- package/build/ts/browser/index.d.ts +4 -2
- package/build/ts/browser/index.d.ts.map +1 -1
- package/build/ts/browser/index.js +7 -1
- package/build/ts/browser/index.js.map +1 -1
- package/build/ts/browser/joinPoll.d.ts +4 -2
- package/build/ts/browser/joinPoll.d.ts.map +1 -1
- package/build/ts/browser/joinPoll.js +21 -17
- package/build/ts/browser/joinPoll.js.map +1 -1
- package/build/ts/browser/utils.d.ts +2 -2
- package/build/ts/browser/utils.d.ts.map +1 -1
- package/build/ts/browser/utils.js +3 -3
- package/build/ts/browser/utils.js.map +1 -1
- package/build/ts/deploy/index.d.ts +2 -2
- package/build/ts/deploy/index.d.ts.map +1 -1
- package/build/ts/deploy/index.js +3 -3
- package/build/ts/deploy/index.js.map +1 -1
- package/build/ts/deploy/maci.d.ts +1 -1
- package/build/ts/deploy/maci.d.ts.map +1 -1
- package/build/ts/deploy/maci.js +18 -8
- package/build/ts/deploy/maci.js.map +1 -1
- package/build/ts/deploy/poll.d.ts +1 -1
- package/build/ts/deploy/poll.d.ts.map +1 -1
- package/build/ts/deploy/poll.js +8 -10
- package/build/ts/deploy/poll.js.map +1 -1
- package/build/ts/deploy/types.d.ts +24 -15
- package/build/ts/deploy/types.d.ts.map +1 -1
- package/build/ts/deploy/utils.js +1 -1
- package/build/ts/deploy/utils.js.map +1 -1
- package/build/ts/deploy/verifyingKeysRegistry.d.ts +7 -0
- package/build/ts/deploy/verifyingKeysRegistry.d.ts.map +1 -0
- package/build/ts/deploy/verifyingKeysRegistry.js +14 -0
- package/build/ts/deploy/verifyingKeysRegistry.js.map +1 -0
- package/build/ts/index.d.ts +3 -2
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +16 -9
- package/build/ts/index.js.map +1 -1
- package/build/ts/maci/state.d.ts +1 -1
- package/build/ts/maci/state.js +8 -8
- package/build/ts/maci/state.js.map +1 -1
- package/build/ts/maci/types.d.ts +1 -1
- package/build/ts/maciKeys/__tests__/keypair.test.js +3 -3
- package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -1
- package/build/ts/maciKeys/__tests__/publicKeys.test.js +5 -5
- package/build/ts/maciKeys/__tests__/publicKeys.test.js.map +1 -1
- package/build/ts/maciKeys/keypair.d.ts.map +1 -1
- package/build/ts/maciKeys/keypair.js +1 -0
- package/build/ts/maciKeys/keypair.js.map +1 -1
- package/build/ts/maciKeys/publicKeys.js +2 -2
- package/build/ts/maciKeys/publicKeys.js.map +1 -1
- package/build/ts/maciKeys/types.d.ts +5 -0
- package/build/ts/maciKeys/types.d.ts.map +1 -1
- package/build/ts/poll/poll.d.ts.map +1 -1
- package/build/ts/poll/poll.js +16 -10
- package/build/ts/poll/poll.js.map +1 -1
- package/build/ts/poll/types.d.ts +7 -3
- package/build/ts/poll/types.d.ts.map +1 -1
- package/build/ts/proof/__tests__/download.test.js +6 -3
- package/build/ts/proof/__tests__/download.test.js.map +1 -1
- package/build/ts/proof/download.d.ts +3 -3
- package/build/ts/proof/download.d.ts.map +1 -1
- package/build/ts/proof/download.js +5 -7
- package/build/ts/proof/download.js.map +1 -1
- package/build/ts/proof/generate.d.ts +2 -2
- package/build/ts/proof/generate.d.ts.map +1 -1
- package/build/ts/proof/generate.js +28 -22
- package/build/ts/proof/generate.js.map +1 -1
- package/build/ts/proof/prove.d.ts +1 -1
- package/build/ts/proof/prove.d.ts.map +1 -1
- package/build/ts/proof/prove.js +26 -16
- package/build/ts/proof/prove.js.map +1 -1
- package/build/ts/proof/types.d.ts +44 -14
- package/build/ts/proof/types.d.ts.map +1 -1
- package/build/ts/proof/utils.d.ts +10 -0
- package/build/ts/proof/utils.d.ts.map +1 -0
- package/build/ts/proof/utils.js +24 -0
- package/build/ts/proof/utils.js.map +1 -0
- package/build/ts/relayer/messages.js +1 -1
- package/build/ts/subgraph/index.d.ts +3 -0
- package/build/ts/subgraph/index.d.ts.map +1 -0
- package/build/ts/subgraph/index.js +18 -0
- package/build/ts/subgraph/index.js.map +1 -0
- package/build/ts/subgraph/maciSubgraph.d.ts +28 -0
- package/build/ts/subgraph/maciSubgraph.d.ts.map +1 -0
- package/build/ts/subgraph/maciSubgraph.js +64 -0
- package/build/ts/subgraph/maciSubgraph.js.map +1 -0
- package/build/ts/subgraph/types.d.ts +20 -0
- package/build/ts/subgraph/types.d.ts.map +1 -0
- package/build/ts/subgraph/types.js +3 -0
- package/build/ts/subgraph/types.js.map +1 -0
- package/build/ts/tally/commitments.d.ts.map +1 -1
- package/build/ts/tally/commitments.js +8 -7
- package/build/ts/tally/commitments.js.map +1 -1
- package/build/ts/tally/index.d.ts +2 -1
- package/build/ts/tally/index.d.ts.map +1 -1
- package/build/ts/tally/index.js +5 -1
- package/build/ts/tally/index.js.map +1 -1
- package/build/ts/tally/results.d.ts +20 -0
- package/build/ts/tally/results.d.ts.map +1 -0
- package/build/ts/tally/results.js +49 -0
- package/build/ts/tally/results.js.map +1 -0
- package/build/ts/tally/types.d.ts +55 -15
- package/build/ts/tally/types.d.ts.map +1 -1
- package/build/ts/tally/utils.d.ts +3 -3
- package/build/ts/tally/utils.d.ts.map +1 -1
- package/build/ts/tally/utils.js +10 -10
- package/build/ts/tally/utils.js.map +1 -1
- package/build/ts/tally/verification.d.ts +1 -1
- package/build/ts/tally/verification.d.ts.map +1 -1
- package/build/ts/tally/verification.js +10 -10
- package/build/ts/tally/verification.js.map +1 -1
- package/build/ts/trees/index.d.ts +2 -2
- package/build/ts/trees/index.d.ts.map +1 -1
- package/build/ts/trees/index.js +3 -1
- package/build/ts/trees/index.js.map +1 -1
- package/build/ts/trees/stateTree.d.ts +23 -1
- package/build/ts/trees/stateTree.d.ts.map +1 -1
- package/build/ts/trees/stateTree.js +74 -13
- package/build/ts/trees/stateTree.js.map +1 -1
- package/build/ts/trees/types.d.ts +10 -1
- package/build/ts/trees/types.d.ts.map +1 -1
- package/build/ts/user/index.d.ts +2 -2
- package/build/ts/user/index.d.ts.map +1 -1
- package/build/ts/user/index.js +5 -1
- package/build/ts/user/index.js.map +1 -1
- package/build/ts/user/joinPoll.d.ts +1 -1
- package/build/ts/user/joinPoll.d.ts.map +1 -1
- package/build/ts/user/joinPoll.js +11 -11
- package/build/ts/user/joinPoll.js.map +1 -1
- package/build/ts/user/signup.d.ts +1 -1
- package/build/ts/user/signup.d.ts.map +1 -1
- package/build/ts/user/signup.js +22 -17
- package/build/ts/user/signup.js.map +1 -1
- package/build/ts/user/types.d.ts +55 -11
- package/build/ts/user/types.d.ts.map +1 -1
- package/build/ts/user/utils.d.ts +32 -12
- package/build/ts/user/utils.d.ts.map +1 -1
- package/build/ts/user/utils.js +85 -51
- package/build/ts/user/utils.js.map +1 -1
- package/build/ts/utils/index.d.ts +1 -1
- package/build/ts/utils/index.d.ts.map +1 -1
- package/build/ts/utils/index.js +2 -1
- package/build/ts/utils/index.js.map +1 -1
- package/build/ts/utils/params.d.ts +1 -1
- package/build/ts/utils/params.d.ts.map +1 -1
- package/build/ts/utils/params.js +3 -3
- package/build/ts/utils/params.js.map +1 -1
- package/build/ts/utils/proofs.d.ts +2 -2
- package/build/ts/utils/proofs.d.ts.map +1 -1
- package/build/ts/utils/proofs.js +4 -4
- package/build/ts/utils/proofs.js.map +1 -1
- package/build/ts/utils/types.d.ts +2 -2
- package/build/ts/utils/types.d.ts.map +1 -1
- package/build/ts/utils/utils.d.ts +5 -0
- package/build/ts/utils/utils.d.ts.map +1 -1
- package/build/ts/utils/utils.js +13 -1
- package/build/ts/utils/utils.js.map +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.js +18 -19
- package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/index.d.ts +2 -2
- package/build/ts/verifyingKeys/index.d.ts.map +1 -1
- package/build/ts/verifyingKeys/index.js +5 -5
- package/build/ts/verifyingKeys/index.js.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.js +70 -47
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/types.d.ts +52 -48
- package/build/ts/verifyingKeys/types.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.d.ts +10 -10
- package/build/ts/verifyingKeys/utils.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.js +75 -60
- package/build/ts/verifyingKeys/utils.js.map +1 -1
- package/build/ts/vote/generate.d.ts.map +1 -1
- package/build/ts/vote/generate.js +3 -3
- package/build/ts/vote/generate.js.map +1 -1
- package/build/ts/vote/index.d.ts +2 -1
- package/build/ts/vote/index.d.ts.map +1 -1
- package/build/ts/vote/index.js +4 -2
- package/build/ts/vote/index.js.map +1 -1
- package/build/ts/vote/invalidate.js +2 -2
- package/build/ts/vote/invalidate.js.map +1 -1
- package/build/ts/vote/publish.js +12 -12
- package/build/ts/vote/publish.js.map +1 -1
- package/build/ts/vote/utils.d.ts +1 -1
- package/build/ts/vote/utils.d.ts.map +1 -1
- package/build/ts/vote/utils.js +3 -3
- package/build/ts/vote/utils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +22 -14
- package/build/ts/deploy/vkRegistry.d.ts +0 -7
- package/build/ts/deploy/vkRegistry.d.ts.map +0 -1
- package/build/ts/deploy/vkRegistry.js +0 -14
- package/build/ts/deploy/vkRegistry.js.map +0 -1
- package/build/ts/proof/constants.d.ts +0 -17
- package/build/ts/proof/constants.d.ts.map +0 -1
- package/build/ts/proof/constants.js +0 -20
- package/build/ts/proof/constants.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.downloadPollJoiningArtifactsBrowser = void 0;
|
|
4
|
-
const
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
5
|
/**
|
|
6
6
|
* Read the chunks of a response
|
|
7
7
|
*
|
|
@@ -29,14 +29,12 @@ const readChunks = async (reader) => {
|
|
|
29
29
|
/**
|
|
30
30
|
* Download the poll joining artifacts for the browser
|
|
31
31
|
*
|
|
32
|
-
* @param
|
|
32
|
+
* @param args - The arguments to download the poll joining artifacts for the browser
|
|
33
33
|
* @returns The poll joining artifacts
|
|
34
34
|
*/
|
|
35
|
-
const downloadPollJoiningArtifactsBrowser = async (testing = false) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
fetch(testing ? constants_1.pollJoiningWasmTestingUrl : constants_1.pollJoiningWasmProductionUrl),
|
|
39
|
-
]);
|
|
35
|
+
const downloadPollJoiningArtifactsBrowser = async ({ testing = false, stateTreeDepth, }) => {
|
|
36
|
+
const { zKeyUrl, wasmUrl } = (0, utils_1.getPollJoiningArtifactsUrl)(testing, stateTreeDepth);
|
|
37
|
+
const [zKeyResponse, wasmResponse] = await Promise.all([fetch(zKeyUrl), fetch(wasmUrl)]);
|
|
40
38
|
const zKeyReader = zKeyResponse.body?.getReader();
|
|
41
39
|
const wasmReader = wasmResponse.body?.getReader();
|
|
42
40
|
if (!zKeyReader || !wasmReader) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../../ts/proof/download.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../../ts/proof/download.ts"],"names":[],"mappings":";;;AAEA,mCAAqD;AAErD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,MAA+C,EAAuB,EAAE;IAChG,IAAI,MAAM,GAAG,MAAM,MAAM,CAAC,IAA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EAAE,CAAC;IAClD,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;IAElD,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAEzF,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC,CAAC;AAlBW,QAAA,mCAAmC,uCAkB9C"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IGenerateProofsArgs, IGenerateProofsData } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Generate proofs for the message processing and tally calculations
|
|
4
|
-
* @param args - The arguments for the
|
|
4
|
+
* @param args - The arguments for the generateProofs command
|
|
5
5
|
* @returns The tally data
|
|
6
6
|
*/
|
|
7
|
-
export declare const generateProofs: ({ outputDir, coordinatorPrivateKey, signer, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, transactionHash, startBlock, endBlock, blocksPerBatch, rapidsnark,
|
|
7
|
+
export declare const generateProofs: ({ outputDir, coordinatorPrivateKey, signer, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, transactionHash, startBlock, endBlock, blocksPerBatch, rapidsnark, mode, voteTallyZkey, voteTallyWitnessGenerator, voteTallyWasm, messageProcessorZkey, messageProcessorWitnessGenerator, messageProcessorWasm, messageProcessorWitnessDatFile, voteTallyWitnessDatFile, tallyFile, useWasm, }: IGenerateProofsArgs) => Promise<IGenerateProofsData>;
|
|
8
8
|
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../ts/proof/generate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAKxE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAU,
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../ts/proof/generate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAKxE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAU,oYAwBlC,mBAAmB,KAAG,OAAO,CAAC,mBAAmB,CAgJnD,CAAC"}
|
|
@@ -11,21 +11,21 @@ const utils_1 = require("../poll/utils");
|
|
|
11
11
|
const files_1 = require("../utils/files");
|
|
12
12
|
/**
|
|
13
13
|
* Generate proofs for the message processing and tally calculations
|
|
14
|
-
* @param args - The arguments for the
|
|
14
|
+
* @param args - The arguments for the generateProofs command
|
|
15
15
|
* @returns The tally data
|
|
16
16
|
*/
|
|
17
|
-
const generateProofs = async ({ outputDir, coordinatorPrivateKey, signer, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, transactionHash, startBlock, endBlock, blocksPerBatch, rapidsnark,
|
|
17
|
+
const generateProofs = async ({ outputDir, coordinatorPrivateKey, signer, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, transactionHash, startBlock, endBlock, blocksPerBatch, rapidsnark, mode, voteTallyZkey, voteTallyWitnessGenerator, voteTallyWasm, messageProcessorZkey, messageProcessorWitnessGenerator, messageProcessorWasm, messageProcessorWitnessDatFile, voteTallyWitnessDatFile, tallyFile, useWasm, }) => {
|
|
18
18
|
// differentiate whether we are using wasm or rapidsnark
|
|
19
19
|
if (useWasm) {
|
|
20
20
|
// if no rapidsnark then we assume we go with wasm
|
|
21
21
|
// so we expect those arguments
|
|
22
|
-
if (!
|
|
22
|
+
if (!messageProcessorWasm) {
|
|
23
23
|
throw new Error("Please specify the process wasm file location");
|
|
24
24
|
}
|
|
25
|
-
if (!
|
|
25
|
+
if (!voteTallyWasm) {
|
|
26
26
|
throw new Error("Please specify the tally wasm file location");
|
|
27
27
|
}
|
|
28
|
-
const wasmResult = (0, files_1.doesPathExist)([
|
|
28
|
+
const wasmResult = (0, files_1.doesPathExist)([messageProcessorWasm, voteTallyWasm]);
|
|
29
29
|
if (!wasmResult[0]) {
|
|
30
30
|
throw new Error(`Could not find ${wasmResult[1]}.`);
|
|
31
31
|
}
|
|
@@ -34,19 +34,25 @@ const generateProofs = async ({ outputDir, coordinatorPrivateKey, signer, maciAd
|
|
|
34
34
|
if (!rapidsnark) {
|
|
35
35
|
throw new Error("Please specify the rapidsnark file location");
|
|
36
36
|
}
|
|
37
|
-
if (!
|
|
38
|
-
throw new Error("Please specify the process
|
|
37
|
+
if (!messageProcessorWitnessGenerator) {
|
|
38
|
+
throw new Error("Please specify the process witnessGenerator file location");
|
|
39
39
|
}
|
|
40
|
-
if (!
|
|
41
|
-
throw new Error("Please specify the tally
|
|
40
|
+
if (!voteTallyWitnessGenerator) {
|
|
41
|
+
throw new Error("Please specify the tally witnessGenerator file location");
|
|
42
42
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const witnessGeneratorResult = (0, files_1.doesPathExist)([
|
|
44
|
+
rapidsnark,
|
|
45
|
+
messageProcessorWitnessGenerator,
|
|
46
|
+
voteTallyWitnessGenerator,
|
|
47
|
+
messageProcessorWitnessDatFile,
|
|
48
|
+
voteTallyWitnessDatFile,
|
|
49
|
+
]);
|
|
50
|
+
if (!witnessGeneratorResult[0]) {
|
|
51
|
+
throw new Error(`Could not find ${witnessGeneratorResult[1]}.`);
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
54
|
// check if zkeys were provided
|
|
49
|
-
const zkResult = (0, files_1.doesPathExist)([
|
|
55
|
+
const zkResult = (0, files_1.doesPathExist)([messageProcessorZkey, voteTallyZkey]);
|
|
50
56
|
if (!zkResult[0]) {
|
|
51
57
|
throw new Error(`Could not find ${zkResult[1]}.`);
|
|
52
58
|
}
|
|
@@ -55,7 +61,7 @@ const generateProofs = async ({ outputDir, coordinatorPrivateKey, signer, maciAd
|
|
|
55
61
|
throw new Error("Please provide a MACI contract address");
|
|
56
62
|
}
|
|
57
63
|
// the coordinator's MACI private key
|
|
58
|
-
if (!domainobjs_1.PrivateKey.
|
|
64
|
+
if (!domainobjs_1.PrivateKey.isValidSerialized(coordinatorPrivateKey)) {
|
|
59
65
|
throw new Error("Invalid MACI private key");
|
|
60
66
|
}
|
|
61
67
|
// if we do not have the output directory just create it
|
|
@@ -106,18 +112,18 @@ const generateProofs = async ({ outputDir, coordinatorPrivateKey, signer, maciAd
|
|
|
106
112
|
tallyContractAddress,
|
|
107
113
|
rapidsnark,
|
|
108
114
|
tally: {
|
|
109
|
-
zkey:
|
|
110
|
-
|
|
111
|
-
wasm:
|
|
115
|
+
zkey: voteTallyZkey,
|
|
116
|
+
witnessGenerator: voteTallyWitnessGenerator,
|
|
117
|
+
wasm: useWasm ? voteTallyWasm : undefined,
|
|
112
118
|
},
|
|
113
|
-
|
|
114
|
-
zkey:
|
|
115
|
-
|
|
116
|
-
wasm:
|
|
119
|
+
messageProcessor: {
|
|
120
|
+
zkey: messageProcessorZkey,
|
|
121
|
+
witnessGenerator: messageProcessorWitnessGenerator,
|
|
122
|
+
wasm: useWasm ? messageProcessorWasm : undefined,
|
|
117
123
|
},
|
|
118
124
|
outputDir,
|
|
119
125
|
tallyOutputFile: tallyFile,
|
|
120
|
-
|
|
126
|
+
mode,
|
|
121
127
|
});
|
|
122
128
|
const processProofs = await proofGenerator.generateMpProofs();
|
|
123
129
|
const { proofs: tallyProofs, tallyData } = await proofGenerator.generateTallyProofs(network?.name ?? "", network?.chainId.toString() ?? "0");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../ts/proof/generate.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0D;AAC1D,0DAAgE;AAEhE,4CAAoB;AAIpB,yCAAiD;AACjD,0CAA+C;AAE/C;;;;GAIG;AACI,MAAM,cAAc,GAAG,KAAK,EAAE,EACnC,SAAS,EACT,qBAAqB,EACrB,MAAM,EACN,WAAW,EACX,MAAM,EACN,sBAAsB,EACtB,SAAS,EACT,eAAe,EACf,UAAU,EACV,QAAQ,EACR,cAAc,EACd,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../ts/proof/generate.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0D;AAC1D,0DAAgE;AAEhE,4CAAoB;AAIpB,yCAAiD;AACjD,0CAA+C;AAE/C;;;;GAIG;AACI,MAAM,cAAc,GAAG,KAAK,EAAE,EACnC,SAAS,EACT,qBAAqB,EACrB,MAAM,EACN,WAAW,EACX,MAAM,EACN,sBAAsB,EACtB,SAAS,EACT,eAAe,EACf,UAAU,EACV,QAAQ,EACR,cAAc,EACd,UAAU,EACV,IAAI,EACJ,aAAa,EACb,yBAAyB,EACzB,aAAa,EACb,oBAAoB,EACpB,gCAAgC,EAChC,oBAAoB,EACpB,8BAA8B,EAC9B,uBAAuB,EACvB,SAAS,EACT,OAAO,GACa,EAAgC,EAAE;IACtD,wDAAwD;IACxD,IAAI,OAAO,EAAE,CAAC;QACZ,kDAAkD;QAClD,+BAA+B;QAC/B,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC,CAAC;QAExE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,kBAAkB,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;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,MAAM,cAAc,GAAG,IAAI,0BAAc,CAAC;QACxC,IAAI,EAAE,SAAS;QACf,mBAAmB,EAAE,WAAW;QAChC,oBAAoB;QACpB,UAAU;QACV,KAAK,EAAE;YACL,IAAI,EAAE,aAAa;YACnB,gBAAgB,EAAE,yBAAyB;YAC3C,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;SAC1C;QACD,gBAAgB,EAAE;YAChB,IAAI,EAAE,oBAAoB;YAC1B,gBAAgB,EAAE,gCAAgC;YAClD,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS;SACjD;QACD,SAAS;QACT,eAAe,EAAE,SAAS;QAC1B,IAAI;KACL,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,MAAM,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAC9D,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,MAAM,cAAc,CAAC,mBAAmB,CACjF,OAAO,EAAE,IAAI,IAAI,EAAE,EACnB,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,CACnC,CAAC;IAEF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AACnD,CAAC,CAAC;AAxKW,QAAA,cAAc,kBAwKzB"}
|
|
@@ -4,5 +4,5 @@ import type { IProveOnChainArgs } from "./types";
|
|
|
4
4
|
* Command to prove the result of a poll on-chain
|
|
5
5
|
* @param args - The arguments for the proveOnChain command
|
|
6
6
|
*/
|
|
7
|
-
export declare const proveOnChain: ({ pollId, proofDir, maciAddress, tallyFile, signer, }: IProveOnChainArgs) => Promise<ITallyData | undefined>;
|
|
7
|
+
export declare const proveOnChain: ({ pollId, proofDir, maciAddress, tallyFile, useBatchSubmission, signer, }: IProveOnChainArgs) => Promise<ITallyData | undefined>;
|
|
8
8
|
//# sourceMappingURL=prove.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prove.d.ts","sourceRoot":"","sources":["../../../ts/proof/prove.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAU,MAAM,SAAS,CAAC;AAKzD;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAU,
|
|
1
|
+
{"version":3,"file":"prove.d.ts","sourceRoot":"","sources":["../../../ts/proof/prove.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAU,MAAM,SAAS,CAAC;AAKzD;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAU,2EAOhC,iBAAiB,KAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAgGpD,CAAC"}
|
package/build/ts/proof/prove.js
CHANGED
|
@@ -14,25 +14,25 @@ const contracts_2 = require("../utils/contracts");
|
|
|
14
14
|
* Command to prove the result of a poll on-chain
|
|
15
15
|
* @param args - The arguments for the proveOnChain command
|
|
16
16
|
*/
|
|
17
|
-
const proveOnChain = async ({ pollId, proofDir, maciAddress, tallyFile, signer, }) => {
|
|
17
|
+
const proveOnChain = async ({ pollId, proofDir, maciAddress, tallyFile, useBatchSubmission, signer, }) => {
|
|
18
18
|
const deployment = contracts_1.Deployment.getInstance();
|
|
19
19
|
deployment.setContractNames(contracts_1.EContracts);
|
|
20
|
-
const { maci: maciContract, poll: pollContract, messageProcessor:
|
|
21
|
-
const
|
|
22
|
-
const [isStateAqMerged,
|
|
20
|
+
const { maci: maciContract, poll: pollContract, messageProcessor: messageProcessorContract, tally: tallyContract, } = await (0, utils_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
21
|
+
const verifyingKeysRegistryContractAddress = await tallyContract.verifyingKeysRegistry();
|
|
22
|
+
const [isStateAqMerged, isVerifyingKeyRegistryExists] = await Promise.all([
|
|
23
23
|
pollContract.stateMerged(),
|
|
24
|
-
(0, contracts_2.contractExists)(signer.provider,
|
|
24
|
+
(0, contracts_2.contractExists)(signer.provider, verifyingKeysRegistryContractAddress),
|
|
25
25
|
]);
|
|
26
|
-
if (!
|
|
27
|
-
throw new Error("There is no
|
|
26
|
+
if (!isVerifyingKeyRegistryExists) {
|
|
27
|
+
throw new Error("There is no VerifyingKeysRegistry contract linked to the specified MACI contract.");
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
name: contracts_1.EContracts.
|
|
31
|
-
address:
|
|
32
|
-
abi: typechain_types_1.
|
|
29
|
+
const verifyingKeysRegistryContract = await deployment.getContract({
|
|
30
|
+
name: contracts_1.EContracts.VerifyingKeysRegistry,
|
|
31
|
+
address: verifyingKeysRegistryContractAddress,
|
|
32
|
+
abi: typechain_types_1.VerifyingKeysRegistry__factory.abi,
|
|
33
33
|
signer,
|
|
34
34
|
});
|
|
35
|
-
const verifierContractAddress = await
|
|
35
|
+
const verifierContractAddress = await messageProcessorContract.verifier();
|
|
36
36
|
const isVerifierExists = await (0, contracts_2.contractExists)(signer.provider, verifierContractAddress);
|
|
37
37
|
if (!isVerifierExists) {
|
|
38
38
|
throw new Error("There is no Verifier contract linked to the specified MACI contract.");
|
|
@@ -59,9 +59,9 @@ const proveOnChain = async ({ pollId, proofDir, maciAddress, tallyFile, signer,
|
|
|
59
59
|
data.tallyProofs = await (0, contracts_1.readProofs)({ files, folder: proofDir, type: "tally" });
|
|
60
60
|
const prover = new contracts_1.Prover({
|
|
61
61
|
maciContract,
|
|
62
|
-
|
|
62
|
+
messageProcessorContract,
|
|
63
63
|
pollContract,
|
|
64
|
-
|
|
64
|
+
verifyingKeysRegistryContract,
|
|
65
65
|
verifierContract,
|
|
66
66
|
tallyContract,
|
|
67
67
|
});
|
|
@@ -71,8 +71,18 @@ const proveOnChain = async ({ pollId, proofDir, maciAddress, tallyFile, signer,
|
|
|
71
71
|
const tallyData = await fs_1.default.promises
|
|
72
72
|
.readFile(tallyFile, "utf8")
|
|
73
73
|
.then((result) => JSON.parse(result));
|
|
74
|
-
const voteOptions = await
|
|
75
|
-
|
|
74
|
+
const [voteOptions, messageBatchSize] = await Promise.all([
|
|
75
|
+
pollContract.voteOptions().then((number) => Number.parseInt(number.toString(), 10)),
|
|
76
|
+
pollContract.messageBatchSize().then((number) => Number.parseInt(number.toString(), 10)),
|
|
77
|
+
]);
|
|
78
|
+
const totalTallyBatches = useBatchSubmission ? Math.ceil(voteOptions / messageBatchSize) : 1;
|
|
79
|
+
for (let index = 0; index < totalTallyBatches; index += 1) {
|
|
80
|
+
const start = messageBatchSize * index;
|
|
81
|
+
const end = useBatchSubmission ? Math.min(messageBatchSize * (index + 1), voteOptions) : voteOptions;
|
|
82
|
+
if (start < end) {
|
|
83
|
+
await prover.submitResults(tallyData, { start, end });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
76
86
|
return tallyData;
|
|
77
87
|
}
|
|
78
88
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prove.js","sourceRoot":"","sources":["../../../ts/proof/prove.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAqC;AACrC,wDAAsF;AACtF,8EAKkD;AAElD,4CAAoB;AAKpB,yCAAiD;AACjD,kDAAoD;AAEpD;;;GAGG;AACI,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,MAAM,GACY,EAAmC,EAAE;IACvD,MAAM,UAAU,GAAG,sBAAU,CAAC,WAAW,EAAE,CAAC;IAC5C,UAAU,CAAC,gBAAgB,CAAC,sBAAU,CAAC,CAAC;IAExC,MAAM,EACJ,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,YAAY,EAClB,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"prove.js","sourceRoot":"","sources":["../../../ts/proof/prove.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAqC;AACrC,wDAAsF;AACtF,8EA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CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAvGW,QAAA,YAAY,gBAuGvB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ITallyData } from "../tally/types";
|
|
2
2
|
import type { Groth16Proof, SnarkProof } from "@maci-protocol/contracts";
|
|
3
|
-
import type {
|
|
3
|
+
import type { EMode, TCircuitInputs } from "@maci-protocol/core";
|
|
4
4
|
import type { BigNumberish, Signer } from "ethers";
|
|
5
5
|
import type { PublicSignals } from "snarkjs";
|
|
6
6
|
/**
|
|
@@ -27,6 +27,10 @@ export interface IProveOnChainArgs {
|
|
|
27
27
|
* The tally file with results, per vote option spent credits, spent voice credits total
|
|
28
28
|
*/
|
|
29
29
|
tallyFile?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to use batch submission
|
|
32
|
+
*/
|
|
33
|
+
useBatchSubmission?: boolean;
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
36
|
* Proof interface for sdk commands
|
|
@@ -39,14 +43,14 @@ export interface IProof {
|
|
|
39
43
|
/**
|
|
40
44
|
* Circuit inputs
|
|
41
45
|
*/
|
|
42
|
-
circuitInputs:
|
|
46
|
+
circuitInputs: TCircuitInputs;
|
|
43
47
|
/**
|
|
44
48
|
* Public signals
|
|
45
49
|
*/
|
|
46
50
|
publicInputs: PublicSignals;
|
|
47
51
|
}
|
|
48
52
|
/**
|
|
49
|
-
* Arguments for the
|
|
53
|
+
* Arguments for the generateProofs function
|
|
50
54
|
*/
|
|
51
55
|
export interface IGenerateProofsArgs {
|
|
52
56
|
/**
|
|
@@ -100,15 +104,15 @@ export interface IGenerateProofsArgs {
|
|
|
100
104
|
/**
|
|
101
105
|
* The path to the process dat file
|
|
102
106
|
*/
|
|
103
|
-
|
|
107
|
+
messageProcessorWitnessDatFile?: string;
|
|
104
108
|
/**
|
|
105
109
|
* The path to the tally dat file
|
|
106
110
|
*/
|
|
107
|
-
|
|
111
|
+
voteTallyWitnessDatFile?: string;
|
|
108
112
|
/**
|
|
109
113
|
* The use quadratic voting
|
|
110
114
|
*/
|
|
111
|
-
|
|
115
|
+
mode: EMode;
|
|
112
116
|
/**
|
|
113
117
|
* Whether to use wasm or rapidsnark
|
|
114
118
|
*/
|
|
@@ -116,27 +120,27 @@ export interface IGenerateProofsArgs {
|
|
|
116
120
|
/**
|
|
117
121
|
* The tally zkey
|
|
118
122
|
*/
|
|
119
|
-
|
|
123
|
+
voteTallyZkey: string;
|
|
120
124
|
/**
|
|
121
|
-
* The tally
|
|
125
|
+
* The tally witness generator
|
|
122
126
|
*/
|
|
123
|
-
|
|
127
|
+
voteTallyWitnessGenerator?: string;
|
|
124
128
|
/**
|
|
125
129
|
* The tally wasm
|
|
126
130
|
*/
|
|
127
|
-
|
|
131
|
+
voteTallyWasm?: string;
|
|
128
132
|
/**
|
|
129
133
|
* The process zkey
|
|
130
134
|
*/
|
|
131
|
-
|
|
135
|
+
messageProcessorZkey: string;
|
|
132
136
|
/**
|
|
133
|
-
* The process
|
|
137
|
+
* The process witness generator
|
|
134
138
|
*/
|
|
135
|
-
|
|
139
|
+
messageProcessorWitnessGenerator?: string;
|
|
136
140
|
/**
|
|
137
141
|
* The process wasm
|
|
138
142
|
*/
|
|
139
|
-
|
|
143
|
+
messageProcessorWasm?: string;
|
|
140
144
|
/**
|
|
141
145
|
* The tally file
|
|
142
146
|
*/
|
|
@@ -172,4 +176,30 @@ export interface IPollJoiningArtifacts {
|
|
|
172
176
|
*/
|
|
173
177
|
wasm: Uint8Array;
|
|
174
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* The url of the poll joining artifacts
|
|
181
|
+
*/
|
|
182
|
+
export interface IPollJoiningArtifactsUrl {
|
|
183
|
+
/**
|
|
184
|
+
* The url of the poll joining zkey
|
|
185
|
+
*/
|
|
186
|
+
zKeyUrl: string;
|
|
187
|
+
/**
|
|
188
|
+
* The url of the poll joining wasm
|
|
189
|
+
*/
|
|
190
|
+
wasmUrl: string;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The arguments to download the poll joining artifacts for the browser
|
|
194
|
+
*/
|
|
195
|
+
export interface IDownloadPollJoiningArtifactsBrowserArgs {
|
|
196
|
+
/**
|
|
197
|
+
* The depth of the state tree
|
|
198
|
+
*/
|
|
199
|
+
stateTreeDepth: number;
|
|
200
|
+
/**
|
|
201
|
+
* Whether to download the testing artifacts
|
|
202
|
+
*/
|
|
203
|
+
testing?: boolean;
|
|
204
|
+
}
|
|
175
205
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/proof/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/proof/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAA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AE7B;;OAEG;IACH,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAE1C;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IAExB;;OAEG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB;;OAEG;IACH,SAAS,EAAE,UAAU,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,IAAI,EAAE,UAAU,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,wCAAwC;IACvD;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IPollJoiningArtifactsUrl } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Get the url of the poll joining artifacts
|
|
4
|
+
*
|
|
5
|
+
* @param testing - Whether to get the testing artifacts
|
|
6
|
+
* @param stateTreeDepth - The depth of the state tree
|
|
7
|
+
* @returns The url of the poll joining artifacts
|
|
8
|
+
*/
|
|
9
|
+
export declare const getPollJoiningArtifactsUrl: (testing: boolean, stateTreeDepth: number) => IPollJoiningArtifactsUrl;
|
|
10
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/proof/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GAAI,SAAS,OAAO,EAAE,gBAAgB,MAAM,KAAG,wBAYrF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPollJoiningArtifactsUrl = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Get the url of the poll joining artifacts
|
|
6
|
+
*
|
|
7
|
+
* @param testing - Whether to get the testing artifacts
|
|
8
|
+
* @param stateTreeDepth - The depth of the state tree
|
|
9
|
+
* @returns The url of the poll joining artifacts
|
|
10
|
+
*/
|
|
11
|
+
const getPollJoiningArtifactsUrl = (testing, stateTreeDepth) => {
|
|
12
|
+
if (testing) {
|
|
13
|
+
return {
|
|
14
|
+
zKeyUrl: `https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/testing/PollJoining_${stateTreeDepth}_test.0.zkey`,
|
|
15
|
+
wasmUrl: `https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/testing/PollJoining_${stateTreeDepth}_test.wasm`,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
zKeyUrl: `https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/production/PollJoining_${stateTreeDepth}.0.zkey`,
|
|
20
|
+
wasmUrl: `https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/production/PollJoining_${stateTreeDepth}.wasm`,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
exports.getPollJoiningArtifactsUrl = getPollJoiningArtifactsUrl;
|
|
24
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/proof/utils.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACI,MAAM,0BAA0B,GAAG,CAAC,OAAgB,EAAE,cAAsB,EAA4B,EAAE;IAC/G,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO;YACL,OAAO,EAAE,uGAAuG,cAAc,cAAc;YAC5I,OAAO,EAAE,uGAAuG,cAAc,YAAY;SAC3I,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,0GAA0G,cAAc,SAAS;QAC1I,OAAO,EAAE,0GAA0G,cAAc,OAAO;KACzI,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,0BAA0B,8BAYrC"}
|
|
@@ -56,7 +56,7 @@ exports.getMessageBatches = getMessageBatches;
|
|
|
56
56
|
*/
|
|
57
57
|
const relayMessages = async ({ maciAddress, pollId, ipfsHash, messages, signer, provider, }) => {
|
|
58
58
|
const { poll: pollContract } = await (0, utils_1.getPollContracts)({ maciAddress, pollId, signer, provider });
|
|
59
|
-
const messageHashes = await Promise.all(messages.map(({ data, publicKey }) => pollContract.
|
|
59
|
+
const messageHashes = await Promise.all(messages.map(({ data, publicKey }) => pollContract.hashMessageAndPublicKey({ data }, { x: publicKey[0], y: publicKey[1] })));
|
|
60
60
|
const receipt = await pollContract.relayMessagesBatch(messageHashes, ipfsHash).then((tx) => tx.wait());
|
|
61
61
|
return {
|
|
62
62
|
hash: receipt?.hash,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/subgraph/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./maciSubgraph"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/subgraph/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PublicKey } from "@maci-protocol/domainobjs";
|
|
2
|
+
/**
|
|
3
|
+
* A class that can be used to interact with MACI's subgraph
|
|
4
|
+
* @dev refer to apps/subgraph for subgraph deployment and configuration
|
|
5
|
+
*/
|
|
6
|
+
export declare class MaciSubgraph {
|
|
7
|
+
/**
|
|
8
|
+
* The URL of the subgraph
|
|
9
|
+
*/
|
|
10
|
+
private url;
|
|
11
|
+
/**
|
|
12
|
+
* The query to get all MACIs public keys signed up
|
|
13
|
+
*/
|
|
14
|
+
private userQuery;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new instance of the MaciSubgraph class
|
|
17
|
+
*
|
|
18
|
+
* @param url - The URL of the subgraph
|
|
19
|
+
*/
|
|
20
|
+
constructor(url: string);
|
|
21
|
+
/**
|
|
22
|
+
* Get the public keys of all MACIs signed up
|
|
23
|
+
*
|
|
24
|
+
* @returns Array of public keys including pad key
|
|
25
|
+
*/
|
|
26
|
+
getKeys(): Promise<PublicKey[]>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=maciSubgraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maciSubgraph.d.ts","sourceRoot":"","sources":["../../../ts/subgraph/maciSubgraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,2BAA2B,CAAC;AAI9D;;;GAGG;AACH,qBAAa,YAAY;IACvB;;OAEG;IACH,OAAO,CAAC,GAAG,CAAS;IAEpB;;OAEG;IACH,OAAO,CAAC,SAAS,CAMb;IAEJ;;;;OAIG;gBACS,GAAG,EAAE,MAAM;IAIvB;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;CAmCtC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MaciSubgraph = void 0;
|
|
4
|
+
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
5
|
+
/**
|
|
6
|
+
* A class that can be used to interact with MACI's subgraph
|
|
7
|
+
* @dev refer to apps/subgraph for subgraph deployment and configuration
|
|
8
|
+
*/
|
|
9
|
+
class MaciSubgraph {
|
|
10
|
+
/**
|
|
11
|
+
* Create a new instance of the MaciSubgraph class
|
|
12
|
+
*
|
|
13
|
+
* @param url - The URL of the subgraph
|
|
14
|
+
*/
|
|
15
|
+
constructor(url) {
|
|
16
|
+
/**
|
|
17
|
+
* The query to get all MACIs public keys signed up
|
|
18
|
+
*/
|
|
19
|
+
this.userQuery = `
|
|
20
|
+
query {
|
|
21
|
+
users (orderBy: createdAt, orderDirection: asc) {
|
|
22
|
+
id
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
this.url = url;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get the public keys of all MACIs signed up
|
|
30
|
+
*
|
|
31
|
+
* @returns Array of public keys including pad key
|
|
32
|
+
*/
|
|
33
|
+
async getKeys() {
|
|
34
|
+
const res = await fetch(this.url, {
|
|
35
|
+
method: "POST",
|
|
36
|
+
body: JSON.stringify({
|
|
37
|
+
query: this.userQuery,
|
|
38
|
+
}),
|
|
39
|
+
headers: {
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
Accept: "application/json",
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
if (!res.ok) {
|
|
45
|
+
throw new Error(`GraphQL query failed: ${res.statusText}`);
|
|
46
|
+
}
|
|
47
|
+
const json = (await res.json());
|
|
48
|
+
if (json.errors) {
|
|
49
|
+
throw new Error(`GraphQL errors: ${JSON.stringify(json.errors)}`);
|
|
50
|
+
}
|
|
51
|
+
if (!json.data?.users) {
|
|
52
|
+
throw new Error("No users data in response");
|
|
53
|
+
}
|
|
54
|
+
const userKeys = json.data.users.map((user) => {
|
|
55
|
+
// Split the id into x and y coordinates and convert to BigInt
|
|
56
|
+
const [x, y] = user.id.split(" ");
|
|
57
|
+
return new domainobjs_1.PublicKey([BigInt(x), BigInt(y)]);
|
|
58
|
+
});
|
|
59
|
+
userKeys.unshift(domainobjs_1.padKey);
|
|
60
|
+
return userKeys;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.MaciSubgraph = MaciSubgraph;
|
|
64
|
+
//# sourceMappingURL=maciSubgraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maciSubgraph.js","sourceRoot":"","sources":["../../../ts/subgraph/maciSubgraph.ts"],"names":[],"mappings":";;;AAAA,0DAA8D;AAI9D;;;GAGG;AACH,MAAa,YAAY;IAiBvB;;;;OAIG;IACH,YAAY,GAAW;QAhBvB;;WAEG;QACK,cAAS,GAAG;;;;;;KAMjB,CAAC;QAQF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,GA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@@
|
|
|
1
|
+
/**
|
|
2
|
+
* The response from the GraphQL query
|
|
3
|
+
*/
|
|
4
|
+
export interface GraphQLResponse {
|
|
5
|
+
/**
|
|
6
|
+
* The data from the query
|
|
7
|
+
*/
|
|
8
|
+
data?: {
|
|
9
|
+
users: {
|
|
10
|
+
id: string;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The errors from the query
|
|
15
|
+
*/
|
|
16
|
+
errors?: {
|
|
17
|
+
message: string;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/subgraph/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,CAAC,EAAE;QACL,KAAK,EAAE;YACL,EAAE,EAAE,MAAM,CAAC;SACZ,EAAE,CAAC;KACL,CAAC;IACF;;OAEG;IACH,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;CACL"}
|