@maci-protocol/sdk 0.0.0-ci.98aa65d → 0.0.0-ci.991fa14
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 +18 -9
- package/build/ts/browser/index.d.ts +8 -8
- package/build/ts/browser/index.d.ts.map +1 -1
- package/build/ts/browser/index.js +17 -20
- package/build/ts/browser/index.js.map +1 -1
- package/build/ts/browser/joinPoll.d.ts +10 -0
- package/build/ts/browser/joinPoll.d.ts.map +1 -0
- package/build/ts/browser/joinPoll.js +88 -0
- package/build/ts/browser/joinPoll.js.map +1 -0
- package/build/ts/browser/utils.d.ts +18 -0
- package/build/ts/browser/utils.d.ts.map +1 -0
- package/build/ts/browser/utils.js +37 -0
- package/build/ts/browser/utils.js.map +1 -0
- 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 +20 -15
- package/build/ts/deploy/poll.js.map +1 -1
- package/build/ts/deploy/types.d.ts +34 -13
- 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/policy.d.ts +13 -1
- package/build/ts/maci/policy.d.ts.map +1 -1
- package/build/ts/maci/policy.js +41 -2
- package/build/ts/maci/policy.js.map +1 -1
- package/build/ts/maci/state.d.ts +1 -1
- package/build/ts/maci/state.js +11 -11
- package/build/ts/maci/state.js.map +1 -1
- package/build/ts/maci/types.d.ts +34 -2
- package/build/ts/maci/types.d.ts.map +1 -1
- package/build/ts/maci/types.js +2 -0
- package/build/ts/maci/types.js.map +1 -1
- package/build/ts/maciKeys/__tests__/keypair.test.js +7 -7
- package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -1
- package/build/ts/maciKeys/__tests__/publicKeys.test.js +7 -7
- 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 +4 -3
- package/build/ts/maciKeys/keypair.js.map +1 -1
- package/build/ts/maciKeys/publicKeys.d.ts +2 -2
- package/build/ts/maciKeys/publicKeys.d.ts.map +1 -1
- package/build/ts/maciKeys/publicKeys.js +6 -6
- 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 +9 -9
- package/build/ts/poll/poll.js.map +1 -1
- package/build/ts/poll/types.d.ts +6 -7
- package/build/ts/poll/types.d.ts.map +1 -1
- package/build/ts/poll/utils.js +3 -3
- package/build/ts/poll/utils.js.map +1 -1
- package/build/ts/proof/__tests__/download.test.js +8 -5
- 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 +31 -25
- 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 +29 -19
- package/build/ts/proof/prove.js.map +1 -1
- package/build/ts/proof/types.d.ts +45 -15
- 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/__tests__/messages.test.js +1 -1
- package/build/ts/relayer/__tests__/messages.test.js.map +1 -1
- package/build/ts/relayer/__tests__/utils.test.js +3 -3
- package/build/ts/relayer/__tests__/utils.test.js.map +1 -1
- package/build/ts/relayer/messages.js +1 -1
- package/build/ts/relayer/utils.js +4 -4
- package/build/ts/relayer/utils.js.map +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 +76 -12
- package/build/ts/trees/stateTree.js.map +1 -1
- package/build/ts/trees/types.d.ts +11 -2
- package/build/ts/trees/types.d.ts.map +1 -1
- package/build/ts/user/index.d.ts +4 -2
- package/build/ts/user/index.d.ts.map +1 -1
- package/build/ts/user/index.js +14 -8
- package/build/ts/user/index.js.map +1 -1
- package/build/ts/user/joinPoll.d.ts +8 -0
- package/build/ts/user/joinPoll.d.ts.map +1 -0
- package/build/ts/user/joinPoll.js +84 -0
- package/build/ts/user/joinPoll.js.map +1 -0
- package/build/ts/user/signup.d.ts +20 -0
- package/build/ts/user/signup.d.ts.map +1 -0
- package/build/ts/user/signup.js +84 -0
- package/build/ts/user/signup.js.map +1 -0
- package/build/ts/user/types.d.ts +65 -29
- package/build/ts/user/types.d.ts.map +1 -1
- package/build/ts/user/utils.d.ts +50 -14
- package/build/ts/user/utils.d.ts.map +1 -1
- package/build/ts/user/utils.js +129 -57
- 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 +13 -0
- package/build/ts/utils/utils.d.ts.map +1 -1
- package/build/ts/utils/utils.js +26 -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 +76 -41
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/types.d.ts +56 -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 +76 -60
- package/build/ts/verifyingKeys/utils.js.map +1 -1
- package/build/ts/vote/generate.d.ts +1 -1
- package/build/ts/vote/generate.d.ts.map +1 -1
- package/build/ts/vote/generate.js +4 -4
- 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 +4 -4
- package/build/ts/vote/invalidate.js.map +1 -1
- package/build/ts/vote/publish.d.ts +1 -1
- package/build/ts/vote/publish.d.ts.map +1 -1
- package/build/ts/vote/publish.js +19 -19
- package/build/ts/vote/publish.js.map +1 -1
- package/build/ts/vote/submit.js +5 -5
- package/build/ts/vote/submit.js.map +1 -1
- package/build/ts/vote/types.d.ts +6 -6
- package/build/ts/vote/types.d.ts.map +1 -1
- package/build/ts/vote/utils.d.ts +2 -2
- package/build/ts/vote/utils.d.ts.map +1 -1
- package/build/ts/vote/utils.js +7 -7
- package/build/ts/vote/utils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +24 -15
- 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
- package/build/ts/user/user.d.ts +0 -42
- package/build/ts/user/user.d.ts.map +0 -1
- package/build/ts/user/user.js +0 -192
- package/build/ts/user/user.js.map +0 -1
package/build/ts/proof/prove.js
CHANGED
|
@@ -8,32 +8,32 @@ exports.proveOnChain = void 0;
|
|
|
8
8
|
const contracts_1 = require("@maci-protocol/contracts");
|
|
9
9
|
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
10
10
|
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const utils_1 = require("../poll/utils");
|
|
12
|
+
const contracts_2 = require("../utils/contracts");
|
|
13
13
|
/**
|
|
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,
|
|
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
|
|
36
|
-
const isVerifierExists = await (0,
|
|
35
|
+
const verifierContractAddress = await messageProcessorContract.verifier();
|
|
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.");
|
|
39
39
|
}
|
|
@@ -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,wDA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AG,GAAG,EAAE,CAAC;gBAChB,MAAM,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAvGW,QAAA,YAAY,gBAuGvB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { ITallyData } from "../tally/types";
|
|
1
2
|
import type { Groth16Proof, SnarkProof } from "@maci-protocol/contracts";
|
|
2
|
-
import type {
|
|
3
|
+
import type { EMode, TCircuitInputs } from "@maci-protocol/core";
|
|
3
4
|
import type { BigNumberish, Signer } from "ethers";
|
|
4
5
|
import type { PublicSignals } from "snarkjs";
|
|
5
|
-
import { ITallyData } from "../tally";
|
|
6
6
|
/**
|
|
7
7
|
* Interface for the arguments to the proveOnChain command
|
|
8
8
|
*/
|
|
@@ -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,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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AElB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;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"}
|
|
@@ -15,7 +15,7 @@ describe("messages", () => {
|
|
|
15
15
|
const keypair = new domainobjs_1.Keypair();
|
|
16
16
|
const defaultMessages = [
|
|
17
17
|
{
|
|
18
|
-
publicKey: keypair.
|
|
18
|
+
publicKey: keypair.publicKey.asArray().map(String),
|
|
19
19
|
data: new Array(10).fill("0"),
|
|
20
20
|
hash: "hash",
|
|
21
21
|
maciAddress: ethers_1.ZeroAddress,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.test.js","sourceRoot":"","sources":["../../../../ts/relayer/__tests__/messages.test.ts"],"names":[],"mappings":";;AAAA,0DAAoD;AACpD,mCAAiE;AAIjE,0BAMY;AACZ,4CAAoD;AACpD,oCAAoD;AAEpD,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,GAAY,EAAE,CAAC,CAAC;IAC5C,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;CAC5B,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAY,EAAE,CAAC,CAAC;IACpC,w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E,CAAC;YACrB,IAAI,CAAC,eAAe,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;YACrD,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,IAAA,qBAAiB,EAAC,WAAW,CAAC,CAAC;YAEhE,MAAM,CAAC,cAAc,CAAC,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -13,14 +13,14 @@ describe("utils", () => {
|
|
|
13
13
|
const keypair = new domainobjs_1.Keypair();
|
|
14
14
|
const defaultMessages = [
|
|
15
15
|
{
|
|
16
|
-
publicKey: keypair.
|
|
16
|
+
publicKey: keypair.publicKey.asArray().map(String),
|
|
17
17
|
data: new Array(10).fill("0"),
|
|
18
18
|
hash: "hash1",
|
|
19
19
|
maciAddress: ethers_1.ZeroAddress,
|
|
20
20
|
poll: 0,
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
publicKey: new domainobjs_1.Keypair().
|
|
23
|
+
publicKey: new domainobjs_1.Keypair().publicKey.asArray().map(String),
|
|
24
24
|
data: new Array(10).fill("0"),
|
|
25
25
|
hash: "hash2",
|
|
26
26
|
maciAddress: ethers_1.ZeroAddress,
|
|
@@ -47,7 +47,7 @@ describe("utils", () => {
|
|
|
47
47
|
startBlock: 0,
|
|
48
48
|
provider: mockProvider,
|
|
49
49
|
pollContract: mockPollContract,
|
|
50
|
-
publicKeys: [keypair.
|
|
50
|
+
publicKeys: [keypair.publicKey.serialize()],
|
|
51
51
|
messageHashes: ["hash1"],
|
|
52
52
|
});
|
|
53
53
|
expect(messages).toStrictEqual([defaultMessages[0]]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../../ts/relayer/__tests__/utils.test.ts"],"names":[],"mappings":";;AAAA,wDAA0E;A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ACb,QAAQ,EAAE,YAAY;YACtB,YAAY,EAAE,gBAAgB;SAC/B,CAAC,CAAC;QAEH,MAAM,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;QACzE,eAAe,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAEzD,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,gCAAwB,EAAC;YAClD,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,YAAY;YACtB,YAAY,EAAE,gBAAgB;SAC/B,CAAC,CAAC;QAEH,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -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,
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseIpfsHashAddedEvents = void 0;
|
|
4
4
|
const contracts_1 = require("@maci-protocol/contracts");
|
|
5
5
|
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
6
|
-
const
|
|
6
|
+
const constants_1 = require("../utils/constants");
|
|
7
7
|
/**
|
|
8
8
|
* Parse the ipfs hash events from the Poll contract
|
|
9
9
|
*
|
|
@@ -14,8 +14,8 @@ const parseIpfsHashAddedEvents = async ({ pollContract, startBlock, provider, pu
|
|
|
14
14
|
const ipfsService = contracts_1.IpfsService.getInstance();
|
|
15
15
|
const currentBlock = await provider.getBlockNumber();
|
|
16
16
|
const ipfsHashes = [];
|
|
17
|
-
for (let block = startBlock; block <= currentBlock; block +=
|
|
18
|
-
const toBlock = Math.min(block +
|
|
17
|
+
for (let block = startBlock; block <= currentBlock; block += constants_1.BLOCKS_STEP) {
|
|
18
|
+
const toBlock = Math.min(block + constants_1.BLOCKS_STEP - 1, currentBlock);
|
|
19
19
|
// eslint-disable-next-line no-await-in-loop
|
|
20
20
|
const events = await pollContract.queryFilter(pollContract.filters.IpfsHashAdded(), block, toBlock);
|
|
21
21
|
// eslint-disable-next-line no-underscore-dangle
|
|
@@ -24,7 +24,7 @@ const parseIpfsHashAddedEvents = async ({ pollContract, startBlock, provider, pu
|
|
|
24
24
|
const messages = await Promise.all(ipfsHashes.map((ipfsHash) => ipfsService.read(ipfsHash))).then((data) => data.reduce((acc, items) => {
|
|
25
25
|
acc?.push(...(items || [])
|
|
26
26
|
.filter((message) => publicKeys && publicKeys.length > 0
|
|
27
|
-
? publicKeys.some((publicKey) => domainobjs_1.
|
|
27
|
+
? publicKeys.some((publicKey) => domainobjs_1.PublicKey.deserialize(publicKey).equals(new domainobjs_1.PublicKey([BigInt(message.publicKey[0]), BigInt(message.publicKey[1])])))
|
|
28
28
|
: true)
|
|
29
29
|
.filter((message) => messageHashes && messageHashes.length > 0 ? messageHashes.some((hash) => message.hash === hash) : true));
|
|
30
30
|
return acc ?? [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/relayer/utils.ts"],"names":[],"mappings":";;;AAAA,wDAA0E;AAC1E,
|
|
1
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IAAI,EAAE,CAAC;aACb,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAClB,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;YACjC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAC5B,sBAAS,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,CACrC,IAAI,sBAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC5E,CACF;YACH,CAAC,CAAC,IAAI,CACT;aACA,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAClB,aAAa,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CACvG,CACJ,CAAC;QAEF,OAAO,GAAG,IAAI,EAAE,CAAC;IACnB,CAAC,EAAE,EAAE,CAAC,CACT,CAAC;IAEF,OAAO;QACL,QAAQ,EAAE,QAAQ,IAAI,EAAE;KACzB,CAAC;AACJ,CAAC,CAAC;AA9CW,QAAA,wBAAwB,4BA8CnC"}
|
|
@@ -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,O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|
@@ -0,0 +1,20 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/subgraph/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitments.d.ts","sourceRoot":"","sources":["../../../ts/tally/commitments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commitments.d.ts","sourceRoot":"","sources":["../../../ts/tally/commitments.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GAAI,qCAGtC,6BAA6B,KAAG,iBAyClC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateTallyCommitments = void 0;
|
|
4
|
+
const core_1 = require("@maci-protocol/core");
|
|
4
5
|
const crypto_1 = require("@maci-protocol/crypto");
|
|
5
6
|
/**
|
|
6
7
|
* Generate the tally commitments for this current batch of proving
|
|
@@ -10,22 +11,22 @@ const crypto_1 = require("@maci-protocol/crypto");
|
|
|
10
11
|
*/
|
|
11
12
|
const generateTallyCommitments = ({ tallyData, voteOptionTreeDepth, }) => {
|
|
12
13
|
// compute newResultsCommitment
|
|
13
|
-
const newResultsCommitment = (0, crypto_1.
|
|
14
|
+
const newResultsCommitment = (0, crypto_1.generateTreeCommitment)(tallyData.results.tally.map((x) => BigInt(x)), BigInt(tallyData.results.salt), voteOptionTreeDepth);
|
|
14
15
|
// compute newSpentVoiceCreditsCommitment
|
|
15
16
|
const newSpentVoiceCreditsCommitment = (0, crypto_1.hash2)([
|
|
16
17
|
BigInt(tallyData.totalSpentVoiceCredits.spent),
|
|
17
18
|
BigInt(tallyData.totalSpentVoiceCredits.salt),
|
|
18
19
|
]);
|
|
19
20
|
let newTallyCommitment;
|
|
20
|
-
let
|
|
21
|
-
if (tallyData.
|
|
22
|
-
// compute
|
|
23
|
-
|
|
21
|
+
let newPerVoteOptionSpentVoiceCreditsCommitment;
|
|
22
|
+
if (tallyData.mode === core_1.EMode.QV) {
|
|
23
|
+
// compute newPerVoteOptionSpentVoiceCreditsCommitment
|
|
24
|
+
newPerVoteOptionSpentVoiceCreditsCommitment = (0, crypto_1.generateTreeCommitment)(tallyData.perVoteOptionSpentVoiceCredits.tally.map((x) => BigInt(x)), BigInt(tallyData.perVoteOptionSpentVoiceCredits.salt), voteOptionTreeDepth);
|
|
24
25
|
// compute newTallyCommitment
|
|
25
26
|
newTallyCommitment = (0, crypto_1.hash3)([
|
|
26
27
|
newResultsCommitment,
|
|
27
28
|
newSpentVoiceCreditsCommitment,
|
|
28
|
-
|
|
29
|
+
newPerVoteOptionSpentVoiceCreditsCommitment,
|
|
29
30
|
]);
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
@@ -34,7 +35,7 @@ const generateTallyCommitments = ({ tallyData, voteOptionTreeDepth, }) => {
|
|
|
34
35
|
return {
|
|
35
36
|
newTallyCommitment,
|
|
36
37
|
newSpentVoiceCreditsCommitment,
|
|
37
|
-
|
|
38
|
+
newPerVoteOptionSpentVoiceCreditsCommitment,
|
|
38
39
|
newResultsCommitment,
|
|
39
40
|
};
|
|
40
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitments.js","sourceRoot":"","sources":["../../../ts/tally/commitments.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"commitments.js","sourceRoot":"","sources":["../../../ts/tally/commitments.ts"],"names":[],"mappings":";;;AAAA,8CAA4C;AAC5C,kDAA4F;AAI5F;;;;;GAKG;AACI,MAAM,wBAAwB,GAAG,CAAC,EACvC,SAAS,EACT,mBAAmB,GACW,EAAqB,EAAE;IACrD,+BAA+B;IAC/B,MAAM,oBAAoB,GAAG,IAAA,+BAAsB,EACjD,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAC7C,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAC9B,mBAAmB,CACpB,CAAC;IAEF,yCAAyC;IACzC,MAAM,8BAA8B,GAAG,IAAA,cAAK,EAAC;QAC3C,MAAM,CAAC,SAAS,CAAC,sBAAsB,CAAC,KAAK,CAAC;QAC9C,MAAM,CAAC,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC;KAC9C,CAAC,CAAC;IAEH,IAAI,kBAA0B,CAAC;IAC/B,IAAI,2CAA+D,CAAC;IAEpE,IAAI,SAAS,CAAC,IAAI,KAAK,YAAK,CAAC,EAAE,EAAE,CAAC;QAChC,sD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