@maci-protocol/sdk 0.0.0-ci.2653bc0
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/CHANGELOG.md +80 -0
- package/LICENSE +22 -0
- package/README.md +12 -0
- package/build/package.json +56 -0
- package/build/ts/browser/index.d.ts +15 -0
- package/build/ts/browser/index.d.ts.map +1 -0
- package/build/ts/browser/index.js +43 -0
- package/build/ts/browser/index.js.map +1 -0
- package/build/ts/deploy/index.d.ts +5 -0
- package/build/ts/deploy/index.d.ts.map +1 -0
- package/build/ts/deploy/index.js +10 -0
- package/build/ts/deploy/index.js.map +1 -0
- package/build/ts/deploy/maci.d.ts +8 -0
- package/build/ts/deploy/maci.d.ts.map +1 -0
- package/build/ts/deploy/maci.js +87 -0
- package/build/ts/deploy/maci.js.map +1 -0
- package/build/ts/deploy/poll.d.ts +8 -0
- package/build/ts/deploy/poll.d.ts.map +1 -0
- package/build/ts/deploy/poll.js +107 -0
- package/build/ts/deploy/poll.js.map +1 -0
- package/build/ts/deploy/types.d.ts +204 -0
- package/build/ts/deploy/types.d.ts.map +1 -0
- package/build/ts/deploy/types.js +3 -0
- package/build/ts/deploy/types.js.map +1 -0
- package/build/ts/deploy/utils.d.ts +11 -0
- package/build/ts/deploy/utils.d.ts.map +1 -0
- package/build/ts/deploy/utils.js +22 -0
- package/build/ts/deploy/utils.js.map +1 -0
- package/build/ts/deploy/vkRegistry.d.ts +7 -0
- package/build/ts/deploy/vkRegistry.d.ts.map +1 -0
- package/build/ts/deploy/vkRegistry.js +14 -0
- package/build/ts/deploy/vkRegistry.js.map +1 -0
- package/build/ts/index.d.ts +16 -0
- package/build/ts/index.d.ts.map +1 -0
- package/build/ts/index.js +69 -0
- package/build/ts/index.js.map +1 -0
- package/build/ts/maci/index.d.ts +6 -0
- package/build/ts/maci/index.d.ts.map +1 -0
- package/build/ts/maci/index.js +17 -0
- package/build/ts/maci/index.js.map +1 -0
- package/build/ts/maci/merge.d.ts +9 -0
- package/build/ts/maci/merge.d.ts.map +1 -0
- package/build/ts/maci/merge.js +29 -0
- package/build/ts/maci/merge.js.map +1 -0
- package/build/ts/maci/policy.d.ts +41 -0
- package/build/ts/maci/policy.d.ts.map +1 -0
- package/build/ts/maci/policy.js +127 -0
- package/build/ts/maci/policy.js.map +1 -0
- package/build/ts/maci/state.d.ts +8 -0
- package/build/ts/maci/state.d.ts.map +1 -0
- package/build/ts/maci/state.js +82 -0
- package/build/ts/maci/state.js.map +1 -0
- package/build/ts/maci/types.d.ts +176 -0
- package/build/ts/maci/types.d.ts.map +1 -0
- package/build/ts/maci/types.js +18 -0
- package/build/ts/maci/types.js.map +1 -0
- package/build/ts/maciKeys/__tests__/keypair.test.d.ts +2 -0
- package/build/ts/maciKeys/__tests__/keypair.test.d.ts.map +1 -0
- package/build/ts/maciKeys/__tests__/keypair.test.js +24 -0
- package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts +2 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts.map +1 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.js +22 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.js.map +1 -0
- package/build/ts/maciKeys/index.d.ts +4 -0
- package/build/ts/maciKeys/index.d.ts.map +1 -0
- package/build/ts/maciKeys/index.js +8 -0
- package/build/ts/maciKeys/index.js.map +1 -0
- package/build/ts/maciKeys/keypair.d.ts +9 -0
- package/build/ts/maciKeys/keypair.d.ts.map +1 -0
- package/build/ts/maciKeys/keypair.js +20 -0
- package/build/ts/maciKeys/keypair.js.map +1 -0
- package/build/ts/maciKeys/publicKeys.d.ts +8 -0
- package/build/ts/maciKeys/publicKeys.d.ts.map +1 -0
- package/build/ts/maciKeys/publicKeys.js +23 -0
- package/build/ts/maciKeys/publicKeys.js.map +1 -0
- package/build/ts/maciKeys/types.d.ts +23 -0
- package/build/ts/maciKeys/types.d.ts.map +1 -0
- package/build/ts/maciKeys/types.js +3 -0
- package/build/ts/maciKeys/types.js.map +1 -0
- package/build/ts/poll/index.d.ts +4 -0
- package/build/ts/poll/index.d.ts.map +1 -0
- package/build/ts/poll/index.js +9 -0
- package/build/ts/poll/index.js.map +1 -0
- package/build/ts/poll/poll.d.ts +14 -0
- package/build/ts/poll/poll.d.ts.map +1 -0
- package/build/ts/poll/poll.js +62 -0
- package/build/ts/poll/poll.js.map +1 -0
- package/build/ts/poll/types.d.ts +152 -0
- package/build/ts/poll/types.d.ts.map +1 -0
- package/build/ts/poll/types.js +3 -0
- package/build/ts/poll/types.js.map +1 -0
- package/build/ts/poll/utils.d.ts +9 -0
- package/build/ts/poll/utils.d.ts.map +1 -0
- package/build/ts/poll/utils.js +43 -0
- package/build/ts/poll/utils.js.map +1 -0
- package/build/ts/proof/__tests__/download.test.d.ts +2 -0
- package/build/ts/proof/__tests__/download.test.d.ts.map +1 -0
- package/build/ts/proof/__tests__/download.test.js +50 -0
- package/build/ts/proof/__tests__/download.test.js.map +1 -0
- package/build/ts/proof/constants.d.ts +17 -0
- package/build/ts/proof/constants.d.ts.map +1 -0
- package/build/ts/proof/constants.js +20 -0
- package/build/ts/proof/constants.js.map +1 -0
- package/build/ts/proof/download.d.ts +9 -0
- package/build/ts/proof/download.d.ts.map +1 -0
- package/build/ts/proof/download.js +49 -0
- package/build/ts/proof/download.js.map +1 -0
- package/build/ts/proof/generate.d.ts +8 -0
- package/build/ts/proof/generate.d.ts.map +1 -0
- package/build/ts/proof/generate.js +127 -0
- package/build/ts/proof/generate.js.map +1 -0
- package/build/ts/proof/index.d.ts +4 -0
- package/build/ts/proof/index.d.ts.map +1 -0
- package/build/ts/proof/index.js +8 -0
- package/build/ts/proof/index.js.map +1 -0
- package/build/ts/proof/prove.d.ts +8 -0
- package/build/ts/proof/prove.d.ts.map +1 -0
- package/build/ts/proof/prove.js +81 -0
- package/build/ts/proof/prove.js.map +1 -0
- package/build/ts/proof/types.d.ts +175 -0
- package/build/ts/proof/types.d.ts.map +1 -0
- package/build/ts/proof/types.js +3 -0
- package/build/ts/proof/types.js.map +1 -0
- package/build/ts/relayer/__tests__/messages.test.d.ts +2 -0
- package/build/ts/relayer/__tests__/messages.test.d.ts.map +1 -0
- package/build/ts/relayer/__tests__/messages.test.js +76 -0
- package/build/ts/relayer/__tests__/messages.test.js.map +1 -0
- package/build/ts/relayer/__tests__/utils.test.d.ts +2 -0
- package/build/ts/relayer/__tests__/utils.test.d.ts.map +1 -0
- package/build/ts/relayer/__tests__/utils.test.js +73 -0
- package/build/ts/relayer/__tests__/utils.test.js.map +1 -0
- package/build/ts/relayer/index.d.ts +3 -0
- package/build/ts/relayer/index.d.ts.map +1 -0
- package/build/ts/relayer/index.js +8 -0
- package/build/ts/relayer/index.js.map +1 -0
- package/build/ts/relayer/messages.d.ts +23 -0
- package/build/ts/relayer/messages.d.ts.map +1 -0
- package/build/ts/relayer/messages.js +66 -0
- package/build/ts/relayer/messages.js.map +1 -0
- package/build/ts/relayer/types.d.ts +168 -0
- package/build/ts/relayer/types.d.ts.map +1 -0
- package/build/ts/relayer/types.js +3 -0
- package/build/ts/relayer/types.js.map +1 -0
- package/build/ts/relayer/utils.d.ts +12 -0
- package/build/ts/relayer/utils.d.ts.map +1 -0
- package/build/ts/relayer/utils.js +37 -0
- package/build/ts/relayer/utils.js.map +1 -0
- package/build/ts/tally/commitments.d.ts +9 -0
- package/build/ts/tally/commitments.d.ts.map +1 -0
- package/build/ts/tally/commitments.js +42 -0
- package/build/ts/tally/commitments.js.map +1 -0
- package/build/ts/tally/index.d.ts +4 -0
- package/build/ts/tally/index.d.ts.map +1 -0
- package/build/ts/tally/index.js +8 -0
- package/build/ts/tally/index.js.map +1 -0
- package/build/ts/tally/types.d.ts +179 -0
- package/build/ts/tally/types.d.ts.map +1 -0
- package/build/ts/tally/types.js +3 -0
- package/build/ts/tally/types.js.map +1 -0
- package/build/ts/tally/utils.d.ts +24 -0
- package/build/ts/tally/utils.d.ts.map +1 -0
- package/build/ts/tally/utils.js +50 -0
- package/build/ts/tally/utils.js.map +1 -0
- package/build/ts/tally/verification.d.ts +7 -0
- package/build/ts/tally/verification.d.ts.map +1 -0
- package/build/ts/tally/verification.js +62 -0
- package/build/ts/tally/verification.js.map +1 -0
- package/build/ts/trees/index.d.ts +3 -0
- package/build/ts/trees/index.d.ts.map +1 -0
- package/build/ts/trees/index.js +6 -0
- package/build/ts/trees/index.js.map +1 -0
- package/build/ts/trees/stateTree.d.ts +13 -0
- package/build/ts/trees/stateTree.d.ts.map +1 -0
- package/build/ts/trees/stateTree.js +53 -0
- package/build/ts/trees/stateTree.js.map +1 -0
- package/build/ts/trees/types.d.ts +46 -0
- package/build/ts/trees/types.d.ts.map +1 -0
- package/build/ts/trees/types.js +3 -0
- package/build/ts/trees/types.js.map +1 -0
- package/build/ts/user/index.d.ts +3 -0
- package/build/ts/user/index.d.ts.map +1 -0
- package/build/ts/user/index.js +11 -0
- package/build/ts/user/index.js.map +1 -0
- package/build/ts/user/types.d.ts +424 -0
- package/build/ts/user/types.d.ts.map +1 -0
- package/build/ts/user/types.js +3 -0
- package/build/ts/user/types.js.map +1 -0
- package/build/ts/user/user.d.ts +42 -0
- package/build/ts/user/user.d.ts.map +1 -0
- package/build/ts/user/user.js +192 -0
- package/build/ts/user/user.js.map +1 -0
- package/build/ts/user/utils.d.ts +52 -0
- package/build/ts/user/utils.d.ts.map +1 -0
- package/build/ts/user/utils.js +186 -0
- package/build/ts/user/utils.js.map +1 -0
- package/build/ts/utils/cid.d.ts +23 -0
- package/build/ts/utils/cid.d.ts.map +1 -0
- package/build/ts/utils/cid.js +72 -0
- package/build/ts/utils/cid.js.map +1 -0
- package/build/ts/utils/constants.d.ts +2 -0
- package/build/ts/utils/constants.d.ts.map +1 -0
- package/build/ts/utils/constants.js +5 -0
- package/build/ts/utils/constants.js.map +1 -0
- package/build/ts/utils/contracts.d.ts +15 -0
- package/build/ts/utils/contracts.d.ts.map +1 -0
- package/build/ts/utils/contracts.js +26 -0
- package/build/ts/utils/contracts.js.map +1 -0
- package/build/ts/utils/files.d.ts +9 -0
- package/build/ts/utils/files.d.ts.map +1 -0
- package/build/ts/utils/files.js +20 -0
- package/build/ts/utils/files.js.map +1 -0
- package/build/ts/utils/formatting.d.ts +8 -0
- package/build/ts/utils/formatting.d.ts.map +1 -0
- package/build/ts/utils/formatting.js +11 -0
- package/build/ts/utils/formatting.js.map +1 -0
- package/build/ts/utils/fundWallet.d.ts +7 -0
- package/build/ts/utils/fundWallet.d.ts.map +1 -0
- package/build/ts/utils/fundWallet.js +20 -0
- package/build/ts/utils/fundWallet.js.map +1 -0
- package/build/ts/utils/index.d.ts +12 -0
- package/build/ts/utils/index.d.ts.map +1 -0
- package/build/ts/utils/index.js +28 -0
- package/build/ts/utils/index.js.map +1 -0
- package/build/ts/utils/params.d.ts +7 -0
- package/build/ts/utils/params.d.ts.map +1 -0
- package/build/ts/utils/params.js +19 -0
- package/build/ts/utils/params.js.map +1 -0
- package/build/ts/utils/proofs.d.ts +13 -0
- package/build/ts/utils/proofs.d.ts.map +1 -0
- package/build/ts/utils/proofs.js +41 -0
- package/build/ts/utils/proofs.js.map +1 -0
- package/build/ts/utils/timeTravel.d.ts +7 -0
- package/build/ts/utils/timeTravel.d.ts.map +1 -0
- package/build/ts/utils/timeTravel.js +14 -0
- package/build/ts/utils/timeTravel.js.map +1 -0
- package/build/ts/utils/trees.d.ts +13 -0
- package/build/ts/utils/trees.d.ts.map +1 -0
- package/build/ts/utils/trees.js +30 -0
- package/build/ts/utils/trees.js.map +1 -0
- package/build/ts/utils/types.d.ts +71 -0
- package/build/ts/utils/types.d.ts.map +1 -0
- package/build/ts/utils/types.js +3 -0
- package/build/ts/utils/types.js.map +1 -0
- package/build/ts/utils/utils.d.ts +16 -0
- package/build/ts/utils/utils.d.ts.map +1 -0
- package/build/ts/utils/utils.js +36 -0
- package/build/ts/utils/utils.js.map +1 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +10 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.js +67 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -0
- package/build/ts/verifyingKeys/index.d.ts +5 -0
- package/build/ts/verifyingKeys/index.d.ts.map +1 -0
- package/build/ts/verifyingKeys/index.js +13 -0
- package/build/ts/verifyingKeys/index.js.map +1 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +7 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.js +73 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -0
- package/build/ts/verifyingKeys/types.d.ts +231 -0
- package/build/ts/verifyingKeys/types.d.ts.map +1 -0
- package/build/ts/verifyingKeys/types.js +3 -0
- package/build/ts/verifyingKeys/types.js.map +1 -0
- package/build/ts/verifyingKeys/utils.d.ts +29 -0
- package/build/ts/verifyingKeys/utils.d.ts.map +1 -0
- package/build/ts/verifyingKeys/utils.js +102 -0
- package/build/ts/verifyingKeys/utils.js.map +1 -0
- package/build/ts/vote/generate.d.ts +8 -0
- package/build/ts/vote/generate.d.ts.map +1 -0
- package/build/ts/vote/generate.js +46 -0
- package/build/ts/vote/generate.js.map +1 -0
- package/build/ts/vote/index.d.ts +6 -0
- package/build/ts/vote/index.d.ts.map +1 -0
- package/build/ts/vote/index.js +15 -0
- package/build/ts/vote/index.js.map +1 -0
- package/build/ts/vote/invalidate.d.ts +13 -0
- package/build/ts/vote/invalidate.d.ts.map +1 -0
- package/build/ts/vote/invalidate.js +44 -0
- package/build/ts/vote/invalidate.js.map +1 -0
- package/build/ts/vote/publish.d.ts +14 -0
- package/build/ts/vote/publish.d.ts.map +1 -0
- package/build/ts/vote/publish.js +88 -0
- package/build/ts/vote/publish.js.map +1 -0
- package/build/ts/vote/submit.d.ts +13 -0
- package/build/ts/vote/submit.d.ts.map +1 -0
- package/build/ts/vote/submit.js +36 -0
- package/build/ts/vote/submit.js.map +1 -0
- package/build/ts/vote/types.d.ts +238 -0
- package/build/ts/vote/types.d.ts.map +1 -0
- package/build/ts/vote/types.js +3 -0
- package/build/ts/vote/types.js.map +1 -0
- package/build/ts/vote/utils.d.ts +16 -0
- package/build/ts/vote/utils.d.ts.map +1 -0
- package/build/ts/vote/utils.js +26 -0
- package/build/ts/vote/utils.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateProofs = void 0;
|
|
7
|
+
const contracts_1 = require("@maci-protocol/contracts");
|
|
8
|
+
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const poll_1 = require("../poll");
|
|
11
|
+
const files_1 = require("../utils/files");
|
|
12
|
+
/**
|
|
13
|
+
* Generate proofs for the message processing and tally calculations
|
|
14
|
+
* @param args - The arguments for the genProofs command
|
|
15
|
+
* @returns The tally data
|
|
16
|
+
*/
|
|
17
|
+
const generateProofs = async ({ outputDir, coordinatorPrivateKey, signer, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, transactionHash, startBlock, endBlock, blocksPerBatch, rapidsnark, useQuadraticVoting, tallyZkey, tallyWitgen, tallyWasm, processZkey, processWitgen, processWasm, processDatFile, tallyDatFile, tallyFile, useWasm, }) => {
|
|
18
|
+
// differentiate whether we are using wasm or rapidsnark
|
|
19
|
+
if (useWasm) {
|
|
20
|
+
// if no rapidsnark then we assume we go with wasm
|
|
21
|
+
// so we expect those arguments
|
|
22
|
+
if (!processWasm) {
|
|
23
|
+
throw new Error("Please specify the process wasm file location");
|
|
24
|
+
}
|
|
25
|
+
if (!tallyWasm) {
|
|
26
|
+
throw new Error("Please specify the tally wasm file location");
|
|
27
|
+
}
|
|
28
|
+
const wasmResult = (0, files_1.doesPathExist)([processWasm, tallyWasm]);
|
|
29
|
+
if (!wasmResult[0]) {
|
|
30
|
+
throw new Error(`Could not find ${wasmResult[1]}.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (!rapidsnark) {
|
|
35
|
+
throw new Error("Please specify the rapidsnark file location");
|
|
36
|
+
}
|
|
37
|
+
if (!processWitgen) {
|
|
38
|
+
throw new Error("Please specify the process witgen file location");
|
|
39
|
+
}
|
|
40
|
+
if (!tallyWitgen) {
|
|
41
|
+
throw new Error("Please specify the tally witgen file location");
|
|
42
|
+
}
|
|
43
|
+
const witgenResult = (0, files_1.doesPathExist)([rapidsnark, processWitgen, tallyWitgen, processDatFile, tallyDatFile]);
|
|
44
|
+
if (!witgenResult[0]) {
|
|
45
|
+
throw new Error(`Could not find ${witgenResult[1]}.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// check if zkeys were provided
|
|
49
|
+
const zkResult = (0, files_1.doesPathExist)([processZkey, tallyZkey]);
|
|
50
|
+
if (!zkResult[0]) {
|
|
51
|
+
throw new Error(`Could not find ${zkResult[1]}.`);
|
|
52
|
+
}
|
|
53
|
+
const network = await signer.provider?.getNetwork();
|
|
54
|
+
if (!maciAddress) {
|
|
55
|
+
throw new Error("Please provide a MACI contract address");
|
|
56
|
+
}
|
|
57
|
+
// the coordinator's MACI private key
|
|
58
|
+
if (!domainobjs_1.PrivKey.isValidSerializedPrivKey(coordinatorPrivateKey)) {
|
|
59
|
+
throw new Error("Invalid MACI private key");
|
|
60
|
+
}
|
|
61
|
+
// if we do not have the output directory just create it
|
|
62
|
+
const isOutputDirExists = fs_1.default.existsSync(outputDir);
|
|
63
|
+
if (!isOutputDirExists) {
|
|
64
|
+
// Create the directory
|
|
65
|
+
await fs_1.default.promises.mkdir(outputDir);
|
|
66
|
+
}
|
|
67
|
+
const maciPrivateKey = domainobjs_1.PrivKey.deserialize(coordinatorPrivateKey);
|
|
68
|
+
const coordinatorKeypair = new domainobjs_1.Keypair(maciPrivateKey);
|
|
69
|
+
const { poll: pollContract, maci: maciContract, tally: tallyContract, } = await (0, poll_1.getPollContracts)({
|
|
70
|
+
maciAddress,
|
|
71
|
+
pollId,
|
|
72
|
+
signer,
|
|
73
|
+
});
|
|
74
|
+
const [isStateAqMerged, tallyContractAddress] = await Promise.all([
|
|
75
|
+
pollContract.stateMerged(),
|
|
76
|
+
tallyContract.getAddress(),
|
|
77
|
+
]);
|
|
78
|
+
// Check that the state and message trees have been merged
|
|
79
|
+
if (!isStateAqMerged) {
|
|
80
|
+
throw new Error("The state tree has not been merged yet. Please use the mergeSignups subcommand to do so.");
|
|
81
|
+
}
|
|
82
|
+
const maciState = await contracts_1.ProofGenerator.prepareState({
|
|
83
|
+
maciContract,
|
|
84
|
+
pollContract,
|
|
85
|
+
maciPrivateKey,
|
|
86
|
+
coordinatorKeypair,
|
|
87
|
+
pollId,
|
|
88
|
+
signer,
|
|
89
|
+
outputDir,
|
|
90
|
+
ipfsMessageBackupFiles,
|
|
91
|
+
options: {
|
|
92
|
+
stateFile,
|
|
93
|
+
transactionHash,
|
|
94
|
+
startBlock,
|
|
95
|
+
endBlock,
|
|
96
|
+
blocksPerBatch,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
const foundPoll = maciState.polls.get(BigInt(pollId));
|
|
100
|
+
if (!foundPoll) {
|
|
101
|
+
throw new Error(`Poll ${pollId} not found`);
|
|
102
|
+
}
|
|
103
|
+
const proofGenerator = new contracts_1.ProofGenerator({
|
|
104
|
+
poll: foundPoll,
|
|
105
|
+
maciContractAddress: maciAddress,
|
|
106
|
+
tallyContractAddress,
|
|
107
|
+
rapidsnark,
|
|
108
|
+
tally: {
|
|
109
|
+
zkey: tallyZkey,
|
|
110
|
+
witgen: tallyWitgen,
|
|
111
|
+
wasm: tallyWasm,
|
|
112
|
+
},
|
|
113
|
+
mp: {
|
|
114
|
+
zkey: processZkey,
|
|
115
|
+
witgen: processWitgen,
|
|
116
|
+
wasm: processWasm,
|
|
117
|
+
},
|
|
118
|
+
outputDir,
|
|
119
|
+
tallyOutputFile: tallyFile,
|
|
120
|
+
useQuadraticVoting,
|
|
121
|
+
});
|
|
122
|
+
const processProofs = await proofGenerator.generateMpProofs();
|
|
123
|
+
const { proofs: tallyProofs, tallyData } = await proofGenerator.generateTallyProofs(network?.name ?? "", network?.chainId.toString() ?? "0");
|
|
124
|
+
return { processProofs, tallyProofs, tallyData };
|
|
125
|
+
};
|
|
126
|
+
exports.generateProofs = generateProofs;
|
|
127
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../ts/proof/generate.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0D;AAC1D,0DAA6D;AAE7D,4CAAoB;AAIpB,kCAA2C;AAC3C,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,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,aAAa,EACb,WAAW,EACX,cAAc,EACd,YAAY,EACZ,SAAS,EACT,OAAO,GACa,EAAgC,EAAE;IACtD,wDAAwD;IACxD,IAAI,OAAO,EAAE,CAAC;QACZ,kDAAkD;QAClD,+BAA+B;QAC/B,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,6CAA6C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AS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.proveOnChain = exports.generateProofs = void 0;
|
|
4
|
+
var generate_1 = require("./generate");
|
|
5
|
+
Object.defineProperty(exports, "generateProofs", { enumerable: true, get: function () { return generate_1.generateProofs; } });
|
|
6
|
+
var prove_1 = require("./prove");
|
|
7
|
+
Object.defineProperty(exports, "proveOnChain", { enumerable: true, get: function () { return prove_1.proveOnChain; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/proof/index.ts"],"names":[],"mappings":";;;AACA,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,iCAAuC;AAA9B,qGAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ITallyData } from "../tally";
|
|
2
|
+
import type { IProveOnChainArgs } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Command to prove the result of a poll on-chain
|
|
5
|
+
* @param args - The arguments for the proveOnChain command
|
|
6
|
+
*/
|
|
7
|
+
export declare const proveOnChain: ({ pollId, proofDir, maciAddress, tallyFile, signer, }: IProveOnChainArgs) => Promise<ITallyData | undefined>;
|
|
8
|
+
//# sourceMappingURL=prove.d.ts.map
|
|
@@ -0,0 +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,uDAMhC,iBAAiB,KAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAmFpD,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.proveOnChain = void 0;
|
|
7
|
+
/* eslint-disable no-await-in-loop */
|
|
8
|
+
const contracts_1 = require("@maci-protocol/contracts");
|
|
9
|
+
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const poll_1 = require("../poll");
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
/**
|
|
14
|
+
* Command to prove the result of a poll on-chain
|
|
15
|
+
* @param args - The arguments for the proveOnChain command
|
|
16
|
+
*/
|
|
17
|
+
const proveOnChain = async ({ pollId, proofDir, maciAddress, tallyFile, signer, }) => {
|
|
18
|
+
const deployment = contracts_1.Deployment.getInstance();
|
|
19
|
+
deployment.setContractNames(contracts_1.EContracts);
|
|
20
|
+
const { maci: maciContract, poll: pollContract, messageProcessor: mpContract, tally: tallyContract, } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
21
|
+
const vkRegistryContractAddress = await tallyContract.vkRegistry();
|
|
22
|
+
const [isStateAqMerged, isVkRegistryExists] = await Promise.all([
|
|
23
|
+
pollContract.stateMerged(),
|
|
24
|
+
(0, utils_1.contractExists)(signer.provider, vkRegistryContractAddress),
|
|
25
|
+
]);
|
|
26
|
+
if (!isVkRegistryExists) {
|
|
27
|
+
throw new Error("There is no VkRegistry contract linked to the specified MACI contract.");
|
|
28
|
+
}
|
|
29
|
+
const vkRegistryContract = await deployment.getContract({
|
|
30
|
+
name: contracts_1.EContracts.VkRegistry,
|
|
31
|
+
address: vkRegistryContractAddress,
|
|
32
|
+
abi: typechain_types_1.VkRegistry__factory.abi,
|
|
33
|
+
signer,
|
|
34
|
+
});
|
|
35
|
+
const verifierContractAddress = await mpContract.verifier();
|
|
36
|
+
const isVerifierExists = await (0, utils_1.contractExists)(signer.provider, verifierContractAddress);
|
|
37
|
+
if (!isVerifierExists) {
|
|
38
|
+
throw new Error("There is no Verifier contract linked to the specified MACI contract.");
|
|
39
|
+
}
|
|
40
|
+
const verifierContract = await deployment.getContract({
|
|
41
|
+
name: contracts_1.EContracts.Verifier,
|
|
42
|
+
address: verifierContractAddress,
|
|
43
|
+
abi: typechain_types_1.Verifier__factory.abi,
|
|
44
|
+
signer,
|
|
45
|
+
});
|
|
46
|
+
// Check that the state and message trees have been merged for at least the first poll
|
|
47
|
+
if (!isStateAqMerged && pollId.toString() === "0") {
|
|
48
|
+
throw new Error("The state tree has not been merged yet. Please use the mergeSignups subcommand to do so.");
|
|
49
|
+
}
|
|
50
|
+
const data = {
|
|
51
|
+
processProofs: [],
|
|
52
|
+
tallyProofs: [],
|
|
53
|
+
};
|
|
54
|
+
// read the proofs from the output directory
|
|
55
|
+
const files = await fs_1.default.promises.readdir(proofDir);
|
|
56
|
+
// Read process proofs
|
|
57
|
+
data.processProofs = await (0, contracts_1.readProofs)({ files, folder: proofDir, type: "process" });
|
|
58
|
+
// Read tally proofs
|
|
59
|
+
data.tallyProofs = await (0, contracts_1.readProofs)({ files, folder: proofDir, type: "tally" });
|
|
60
|
+
const prover = new contracts_1.Prover({
|
|
61
|
+
maciContract,
|
|
62
|
+
mpContract,
|
|
63
|
+
pollContract,
|
|
64
|
+
vkRegistryContract,
|
|
65
|
+
verifierContract,
|
|
66
|
+
tallyContract,
|
|
67
|
+
});
|
|
68
|
+
await prover.proveMessageProcessing(data.processProofs);
|
|
69
|
+
await prover.proveTally(data.tallyProofs);
|
|
70
|
+
if (tallyFile) {
|
|
71
|
+
const tallyData = await fs_1.default.promises
|
|
72
|
+
.readFile(tallyFile, "utf8")
|
|
73
|
+
.then((result) => JSON.parse(result));
|
|
74
|
+
const voteOptions = await pollContract.voteOptions();
|
|
75
|
+
await prover.submitResults(tallyData, Number.parseInt(voteOptions.toString(), 10));
|
|
76
|
+
return tallyData;
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
};
|
|
80
|
+
exports.proveOnChain = proveOnChain;
|
|
81
|
+
//# sourceMappingURL=prove.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prove.js","sourceRoot":"","sources":["../../../ts/proof/prove.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAqC;AACrC,wDAAsF;AACtF,8EAKkD;AAElD,4CAAoB;AAKpB,kCAA2C;AAC3C,oCAA0C;AAE1C;;;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,UAAU,EAC5B,KAAK,EAAE,aAAa,GACrB,GAAG,MAAM,IAAA,uBAAgB,EAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAE5D,MAAM,yBAAyB,GAAG,MAAM,aAAa,CAAC,UAAU,EAAE,CAAC;IACnE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC9D,YAAY,CAAC,WAAW,EAAE;QAC1B,IAAA,sBAAc,EAAC,MAAM,CAAC,QAAS,EAAE,yBAAyB,CAAC;KAC5D,CAAC,CAAC;IAEH,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,kBAAkB,GAAG,MAAM,UAAU,CAAC,WAAW,CAAa;QAClE,IAAI,EAAE,sBAAU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I,kBAAM,CAAC;QACxB,YAAY;QACZ,UAAU;QACV,YAAY;QACZ,kBAAkB;QAClB,gBAAgB;QAChB,aAAa;KACd,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACxD,MAAM,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAE1C,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,SAAS,GAAG,MAAM,YAAE,CAAC,QAAQ;aAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;aAC3B,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAA0B,CAAC,CAAC;QACjE,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,WAAW,EAAE,CAAC;QAErD,MAAM,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAEnF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAzFW,QAAA,YAAY,gBAyFvB"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { Groth16Proof, SnarkProof } from "@maci-protocol/contracts";
|
|
2
|
+
import type { CircuitInputs } from "@maci-protocol/core";
|
|
3
|
+
import type { BigNumberish, Signer } from "ethers";
|
|
4
|
+
import type { PublicSignals } from "snarkjs";
|
|
5
|
+
import { ITallyData } from "../tally";
|
|
6
|
+
/**
|
|
7
|
+
* Interface for the arguments to the proveOnChain command
|
|
8
|
+
*/
|
|
9
|
+
export interface IProveOnChainArgs {
|
|
10
|
+
/**
|
|
11
|
+
* The id of the poll
|
|
12
|
+
*/
|
|
13
|
+
pollId: bigint;
|
|
14
|
+
/**
|
|
15
|
+
* The directory containing the proofs
|
|
16
|
+
*/
|
|
17
|
+
proofDir: string;
|
|
18
|
+
/**
|
|
19
|
+
* A signer object
|
|
20
|
+
*/
|
|
21
|
+
signer: Signer;
|
|
22
|
+
/**
|
|
23
|
+
* The address of the MACI contract
|
|
24
|
+
*/
|
|
25
|
+
maciAddress: string;
|
|
26
|
+
/**
|
|
27
|
+
* The tally file with results, per vote option spent credits, spent voice credits total
|
|
28
|
+
*/
|
|
29
|
+
tallyFile?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Proof interface for sdk commands
|
|
33
|
+
*/
|
|
34
|
+
export interface IProof {
|
|
35
|
+
/**
|
|
36
|
+
* Proof
|
|
37
|
+
*/
|
|
38
|
+
proof: SnarkProof | Groth16Proof;
|
|
39
|
+
/**
|
|
40
|
+
* Circuit inputs
|
|
41
|
+
*/
|
|
42
|
+
circuitInputs: CircuitInputs;
|
|
43
|
+
/**
|
|
44
|
+
* Public signals
|
|
45
|
+
*/
|
|
46
|
+
publicInputs: PublicSignals;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Arguments for the genProofs function
|
|
50
|
+
*/
|
|
51
|
+
export interface IGenerateProofsArgs {
|
|
52
|
+
/**
|
|
53
|
+
* The output directory
|
|
54
|
+
*/
|
|
55
|
+
outputDir: string;
|
|
56
|
+
/**
|
|
57
|
+
* The coordinator private key
|
|
58
|
+
*/
|
|
59
|
+
coordinatorPrivateKey: string;
|
|
60
|
+
/**
|
|
61
|
+
* The signer
|
|
62
|
+
*/
|
|
63
|
+
signer: Signer;
|
|
64
|
+
/**
|
|
65
|
+
* The maci contract address
|
|
66
|
+
*/
|
|
67
|
+
maciAddress: string;
|
|
68
|
+
/**
|
|
69
|
+
* The poll id
|
|
70
|
+
*/
|
|
71
|
+
pollId: BigNumberish;
|
|
72
|
+
/**
|
|
73
|
+
* The ipfs message backup files
|
|
74
|
+
*/
|
|
75
|
+
ipfsMessageBackupFiles?: string[];
|
|
76
|
+
/**
|
|
77
|
+
* The state file
|
|
78
|
+
*/
|
|
79
|
+
stateFile?: string;
|
|
80
|
+
/**
|
|
81
|
+
* The transaction hash
|
|
82
|
+
*/
|
|
83
|
+
transactionHash?: string;
|
|
84
|
+
/**
|
|
85
|
+
* The start block
|
|
86
|
+
*/
|
|
87
|
+
startBlock?: number;
|
|
88
|
+
/**
|
|
89
|
+
* The end block
|
|
90
|
+
*/
|
|
91
|
+
endBlock?: number;
|
|
92
|
+
/**
|
|
93
|
+
* The blocks per batch
|
|
94
|
+
*/
|
|
95
|
+
blocksPerBatch?: number;
|
|
96
|
+
/**
|
|
97
|
+
* The rapidsnark path
|
|
98
|
+
*/
|
|
99
|
+
rapidsnark?: string;
|
|
100
|
+
/**
|
|
101
|
+
* The path to the process dat file
|
|
102
|
+
*/
|
|
103
|
+
processDatFile?: string;
|
|
104
|
+
/**
|
|
105
|
+
* The path to the tally dat file
|
|
106
|
+
*/
|
|
107
|
+
tallyDatFile?: string;
|
|
108
|
+
/**
|
|
109
|
+
* The use quadratic voting
|
|
110
|
+
*/
|
|
111
|
+
useQuadraticVoting: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Whether to use wasm or rapidsnark
|
|
114
|
+
*/
|
|
115
|
+
useWasm?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* The tally zkey
|
|
118
|
+
*/
|
|
119
|
+
tallyZkey: string;
|
|
120
|
+
/**
|
|
121
|
+
* The tally witgen
|
|
122
|
+
*/
|
|
123
|
+
tallyWitgen?: string;
|
|
124
|
+
/**
|
|
125
|
+
* The tally wasm
|
|
126
|
+
*/
|
|
127
|
+
tallyWasm?: string;
|
|
128
|
+
/**
|
|
129
|
+
* The process zkey
|
|
130
|
+
*/
|
|
131
|
+
processZkey: string;
|
|
132
|
+
/**
|
|
133
|
+
* The process witgen
|
|
134
|
+
*/
|
|
135
|
+
processWitgen?: string;
|
|
136
|
+
/**
|
|
137
|
+
* The process wasm
|
|
138
|
+
*/
|
|
139
|
+
processWasm?: string;
|
|
140
|
+
/**
|
|
141
|
+
* The tally file
|
|
142
|
+
*/
|
|
143
|
+
tallyFile: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Interface for the data returned by the generateProofs function
|
|
147
|
+
*/
|
|
148
|
+
export interface IGenerateProofsData {
|
|
149
|
+
/**
|
|
150
|
+
* Process proofs
|
|
151
|
+
*/
|
|
152
|
+
processProofs: IProof[];
|
|
153
|
+
/**
|
|
154
|
+
* Tally proofs
|
|
155
|
+
*/
|
|
156
|
+
tallyProofs: IProof[];
|
|
157
|
+
/**
|
|
158
|
+
* Tally data
|
|
159
|
+
*/
|
|
160
|
+
tallyData: ITallyData;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Interface for the poll joining artifacts
|
|
164
|
+
*/
|
|
165
|
+
export interface IPollJoiningArtifacts {
|
|
166
|
+
/**
|
|
167
|
+
* The zkey
|
|
168
|
+
*/
|
|
169
|
+
zKey: Uint8Array;
|
|
170
|
+
/**
|
|
171
|
+
* The wasm
|
|
172
|
+
*/
|
|
173
|
+
wasm: Uint8Array;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,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CAAC;IAEnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/proof/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.test.d.ts","sourceRoot":"","sources":["../../../../ts/relayer/__tests__/messages.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const __1 = require("..");
|
|
6
|
+
const utils_1 = require("../../poll/utils");
|
|
7
|
+
const utils_2 = require("../utils");
|
|
8
|
+
jest.mock("../../poll/utils", () => ({
|
|
9
|
+
getPollContracts: jest.fn(),
|
|
10
|
+
}));
|
|
11
|
+
jest.mock("../utils", () => ({
|
|
12
|
+
parseIpfsHashAddedEvents: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
describe("messages", () => {
|
|
15
|
+
const keypair = new domainobjs_1.Keypair();
|
|
16
|
+
const defaultMessages = [
|
|
17
|
+
{
|
|
18
|
+
publicKey: keypair.pubKey.asArray().map(String),
|
|
19
|
+
data: new Array(10).fill("0"),
|
|
20
|
+
hash: "hash",
|
|
21
|
+
maciAddress: ethers_1.ZeroAddress,
|
|
22
|
+
poll: 0,
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
describe("getRelayedMessages", () => {
|
|
26
|
+
const defaultArgs = {
|
|
27
|
+
maciAddress: ethers_1.ZeroAddress,
|
|
28
|
+
pollId: 0,
|
|
29
|
+
signer: {},
|
|
30
|
+
provider: {},
|
|
31
|
+
};
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
utils_1.getPollContracts.mockResolvedValue({ poll: {} });
|
|
34
|
+
utils_2.parseIpfsHashAddedEvents.mockResolvedValue({ messages: defaultMessages });
|
|
35
|
+
});
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
jest.clearAllMocks();
|
|
38
|
+
});
|
|
39
|
+
test("should get relayed messages properly", async () => {
|
|
40
|
+
const { messages } = await (0, __1.getRelayedMessages)(defaultArgs);
|
|
41
|
+
expect(messages).toStrictEqual(defaultMessages);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe("getMessageBatches", () => {
|
|
45
|
+
const defaultArgs = {
|
|
46
|
+
maciContractAddress: ethers_1.ZeroAddress,
|
|
47
|
+
poll: 0,
|
|
48
|
+
url: "url",
|
|
49
|
+
limit: 10,
|
|
50
|
+
skip: 0,
|
|
51
|
+
ipfsHashes: ["hash"],
|
|
52
|
+
publicKeys: ["key"],
|
|
53
|
+
messageHashes: ["hash"],
|
|
54
|
+
};
|
|
55
|
+
const defaultMessageBatches = [
|
|
56
|
+
{
|
|
57
|
+
messages: defaultMessages,
|
|
58
|
+
ipfsHash: "hash",
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
beforeEach(() => {
|
|
62
|
+
jest.spyOn(global, "fetch").mockResolvedValue({
|
|
63
|
+
json: jest.fn().mockResolvedValue(defaultMessageBatches),
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
afterEach(() => {
|
|
67
|
+
jest.clearAllMocks();
|
|
68
|
+
jest.restoreAllMocks();
|
|
69
|
+
});
|
|
70
|
+
test("should get message batches properly", async () => {
|
|
71
|
+
const { messageBatches } = await (0, __1.getMessageBatches)(defaultArgs);
|
|
72
|
+
expect(messageBatches).toStrictEqual(defaultMessageBatches);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=messages.test.js.map
|
|
@@ -0,0 +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,wBAAwB,EAAE,IAAI,CAAC,EAAE,EAAE;CACpC,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,MAAM,OAAO,GAAG,IAAI,oBAAO,EAAE,CAAC;IAE9B,MAAM,eAAe,GAAmB;QACtC;YACE,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,MAAM,CAAqB;YACnE,IAAI,EAAE,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAa;YACzC,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,oBAAW;YACxB,IAAI,EAAE,CAAC;SACR;KACF,CAAC;IAEF,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,MAAM,WAAW,GA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iBAAiB,CAAC,qBAAqB,CAAC;aAClC,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,SAAS,CAAC,GAAG,EAAE;YACb,IAAI,CAAC,aAAa,EAAE,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../../ts/relayer/__tests__/utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const contracts_1 = require("@maci-protocol/contracts");
|
|
4
|
+
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
5
|
+
const ethers_1 = require("ethers");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
describe("utils", () => {
|
|
8
|
+
let mockPollContract;
|
|
9
|
+
let mockIpfsService;
|
|
10
|
+
const mockProvider = {
|
|
11
|
+
getBlockNumber: () => Promise.resolve(0),
|
|
12
|
+
};
|
|
13
|
+
const keypair = new domainobjs_1.Keypair();
|
|
14
|
+
const defaultMessages = [
|
|
15
|
+
{
|
|
16
|
+
publicKey: keypair.pubKey.asArray().map(String),
|
|
17
|
+
data: new Array(10).fill("0"),
|
|
18
|
+
hash: "hash1",
|
|
19
|
+
maciAddress: ethers_1.ZeroAddress,
|
|
20
|
+
poll: 0,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
publicKey: new domainobjs_1.Keypair().pubKey.asArray().map(String),
|
|
24
|
+
data: new Array(10).fill("0"),
|
|
25
|
+
hash: "hash2",
|
|
26
|
+
maciAddress: ethers_1.ZeroAddress,
|
|
27
|
+
poll: 0,
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
mockIpfsService = {
|
|
32
|
+
read: jest.fn().mockResolvedValue(defaultMessages),
|
|
33
|
+
};
|
|
34
|
+
jest.spyOn(contracts_1.IpfsService, "getInstance").mockReturnValue(mockIpfsService);
|
|
35
|
+
mockPollContract = {
|
|
36
|
+
queryFilter: jest.fn().mockResolvedValue([{ args: { _ipfsHash: "hash" } }]),
|
|
37
|
+
filters: {
|
|
38
|
+
IpfsHashAdded: jest.fn(),
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
jest.clearAllMocks();
|
|
44
|
+
});
|
|
45
|
+
test("should parse IpfsHashAdded events properly", async () => {
|
|
46
|
+
const { messages } = await (0, utils_1.parseIpfsHashAddedEvents)({
|
|
47
|
+
startBlock: 0,
|
|
48
|
+
provider: mockProvider,
|
|
49
|
+
pollContract: mockPollContract,
|
|
50
|
+
publicKeys: [keypair.pubKey.serialize()],
|
|
51
|
+
messageHashes: ["hash1"],
|
|
52
|
+
});
|
|
53
|
+
expect(messages).toStrictEqual([defaultMessages[0]]);
|
|
54
|
+
});
|
|
55
|
+
it("should parse IpfsHashAdded events properly without public keys and message hashes", async () => {
|
|
56
|
+
const { messages } = await (0, utils_1.parseIpfsHashAddedEvents)({
|
|
57
|
+
startBlock: 0,
|
|
58
|
+
provider: mockProvider,
|
|
59
|
+
pollContract: mockPollContract,
|
|
60
|
+
});
|
|
61
|
+
expect(messages).toStrictEqual(defaultMessages);
|
|
62
|
+
});
|
|
63
|
+
it("should return empty array if can't get messages from ipfs", async () => {
|
|
64
|
+
mockIpfsService.read = jest.fn().mockResolvedValue(null);
|
|
65
|
+
const { messages } = await (0, utils_1.parseIpfsHashAddedEvents)({
|
|
66
|
+
startBlock: 0,
|
|
67
|
+
provider: mockProvider,
|
|
68
|
+
pollContract: mockPollContract,
|
|
69
|
+
});
|
|
70
|
+
expect(messages).toHaveLength(0);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../../ts/relayer/__tests__/utils.test.ts"],"names":[],"mappings":";;AAAA,wDAA0E;AAC1E,0DAAoD;AACpD,mCAAoD;AAIpD,oCAAoD;AAEpD,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,IAAI,gBAAsB,CAAC;IAC3B,IAAI,eAA4B,CAAC;IAEjC,MAAM,YAAY,GAAG;QACnB,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC7B,CAAC;IAEd,MAAM,OAAO,GAAG,IAAI,oBAAO,EAAE,CAAC;IAE9B,MAAM,eAAe,GAAmB;QACtC;YACE,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,MAAM,CAAqB;YACnE,IAAI,EAAE,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAa;YACzC,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,oBAAW;YACxB,IAAI,EAAE,CAAC;SACR;QACD;YACE,SAAS,EAAE,IAAI,oBAAO,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,MAAM,CAAqB;YACzE,IAAI,EAAE,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAa;YACzC,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,oBAAW;YACxB,IAAI,EAAE,CAAC;SACR;KACF,CAAC;IAEF,UAAU,CAAC,GAAG,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a,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"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { getRelayedMessages, getMessageBatches, relayMessages } from "./messages";
|
|
2
|
+
export type { IGetRelayedMessagesArgs, IGetRelayedMessagesData, IMessageBatch, IGetMessageBatchesArgs, IGetMessageBatchesData, IRelayMessagesArgs, IRelayMessagesData, } from "./types";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/relayer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAClF,YAAY,EACV,uBAAuB,EACvB,uBAAuB,EACvB,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.relayMessages = exports.getMessageBatches = exports.getRelayedMessages = void 0;
|
|
4
|
+
var messages_1 = require("./messages");
|
|
5
|
+
Object.defineProperty(exports, "getRelayedMessages", { enumerable: true, get: function () { return messages_1.getRelayedMessages; } });
|
|
6
|
+
Object.defineProperty(exports, "getMessageBatches", { enumerable: true, get: function () { return messages_1.getMessageBatches; } });
|
|
7
|
+
Object.defineProperty(exports, "relayMessages", { enumerable: true, get: function () { return messages_1.relayMessages; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/relayer/index.ts"],"names":[],"mappings":";;;AAAA,uCAAkF;AAAzE,8GAAA,kBAAkB,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,yGAAA,aAAa,OAAA"}
|