@maci-protocol/sdk 0.0.0-ci.9c4d683 → 0.0.0-ci.9d0431f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/package.json +9 -9
- package/build/ts/browser/index.d.ts +3 -1
- package/build/ts/browser/index.d.ts.map +1 -1
- package/build/ts/browser/index.js +2 -0
- package/build/ts/browser/index.js.map +1 -1
- package/build/ts/browser/joinPoll.d.ts +1 -1
- package/build/ts/browser/joinPoll.d.ts.map +1 -1
- package/build/ts/browser/joinPoll.js +2 -2
- package/build/ts/browser/joinPoll.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 +17 -7
- 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 +5 -7
- package/build/ts/deploy/poll.js.map +1 -1
- package/build/ts/deploy/types.d.ts +21 -13
- package/build/ts/deploy/types.d.ts.map +1 -1
- package/build/ts/index.d.ts +3 -2
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +7 -4
- package/build/ts/index.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/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 +10 -4
- package/build/ts/poll/poll.js.map +1 -1
- package/build/ts/poll/types.d.ts +4 -0
- package/build/ts/poll/types.d.ts.map +1 -1
- package/build/ts/proof/__tests__/download.test.js +1 -1
- package/build/ts/proof/__tests__/download.test.js.map +1 -1
- package/build/ts/proof/generate.d.ts +1 -1
- package/build/ts/proof/generate.d.ts.map +1 -1
- package/build/ts/proof/generate.js +24 -18
- 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 +16 -6
- package/build/ts/proof/prove.js.map +1 -1
- package/build/ts/proof/types.d.ts +14 -10
- package/build/ts/proof/types.d.ts.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/index.d.ts +2 -2
- package/build/ts/tally/index.d.ts.map +1 -1
- package/build/ts/tally/index.js +2 -1
- package/build/ts/tally/index.js.map +1 -1
- package/build/ts/tally/results.d.ts +9 -3
- package/build/ts/tally/results.d.ts.map +1 -1
- package/build/ts/tally/results.js +25 -20
- package/build/ts/tally/results.js.map +1 -1
- package/build/ts/tally/types.d.ts +15 -2
- package/build/ts/tally/types.d.ts.map +1 -1
- package/build/ts/trees/index.d.ts +1 -1
- package/build/ts/trees/index.d.ts.map +1 -1
- package/build/ts/trees/index.js +2 -1
- package/build/ts/trees/index.js.map +1 -1
- package/build/ts/trees/stateTree.d.ts +8 -0
- package/build/ts/trees/stateTree.d.ts.map +1 -1
- package/build/ts/trees/stateTree.js +14 -1
- package/build/ts/trees/stateTree.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 +2 -2
- 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 +19 -14
- package/build/ts/user/signup.js.map +1 -1
- package/build/ts/user/types.d.ts +8 -12
- package/build/ts/user/types.d.ts.map +1 -1
- package/build/ts/user/utils.d.ts +11 -3
- package/build/ts/user/utils.d.ts.map +1 -1
- package/build/ts/user/utils.js +26 -21
- 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/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.js +5 -5
- package/build/ts/verifyingKeys/checkVerifyingKeys.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 +51 -27
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/types.d.ts +19 -15
- package/build/ts/verifyingKeys/types.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.d.ts +2 -2
- package/build/ts/verifyingKeys/utils.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.js +13 -11
- package/build/ts/verifyingKeys/utils.js.map +1 -1
- package/build/ts/vote/index.d.ts +1 -0
- package/build/ts/vote/index.d.ts.map +1 -1
- package/build/ts/vote/index.js +3 -1
- package/build/ts/vote/index.js.map +1 -1
- package/build/ts/vote/invalidate.js +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.test.js","sourceRoot":"","sources":["../../../../ts/proof/__tests__/download.test.ts"],"names":[],"mappings":";;AAAA,wDAAgE;AAGhE,0CAAkE;AAElE;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,UAAU,EAAE,8EAA8E;IAC1F,aAAa,EAAE;QACb,8EAA8E;QAC9E,8EAA8E;KAC/E;IACD,QAAQ,EAAE;QACR,CAAC,8EAA8E,CAAC;QAChF,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;KACN;IACD,
|
|
1
|
+
{"version":3,"file":"download.test.js","sourceRoot":"","sources":["../../../../ts/proof/__tests__/download.test.ts"],"names":[],"mappings":";;AAAA,wDAAgE;AAGhE,0CAAkE;AAElE;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,UAAU,EAAE,8EAA8E;IAC1F,aAAa,EAAE;QACb,8EAA8E;QAC9E,8EAA8E;KAC/E;IACD,QAAQ,EAAE;QACR,CAAC,8EAA8E,CAAC;QAChF,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;KACN;IACD,KAAK,EAAE,CAAC;IACR,SAAS,EAAE,8EAA8E;IACzF,SAAS,EAAE,+EAA+E;IAC1F,oBAAoB,EAAE,GAAG;IACzB,MAAM,EAAE,GAAG;CACZ,CAAC;AAEF,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACnD,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;QAC/E,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,8CAAmC,EAAC;YAC/D,OAAO,EAAE,IAAI;YACb,cAAc,EAAE,EAAE;SACnB,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QAE3B,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,gCAAoB,EAAC;YAC3C,MAAM,EAAE,MAAmC;YAC3C,QAAQ,EAAE,IAAyB;YACnC,QAAQ,EAAE,IAAyB;SACpC,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -4,5 +4,5 @@ import type { IGenerateProofsArgs, IGenerateProofsData } from "./types";
|
|
|
4
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, mode,
|
|
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"}
|
|
@@ -14,18 +14,18 @@ const files_1 = require("../utils/files");
|
|
|
14
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, mode,
|
|
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
|
}
|
|
@@ -106,14 +112,14 @@ 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
119
|
messageProcessor: {
|
|
114
|
-
zkey:
|
|
115
|
-
|
|
116
|
-
wasm:
|
|
120
|
+
zkey: messageProcessorZkey,
|
|
121
|
+
witnessGenerator: messageProcessorWitnessGenerator,
|
|
122
|
+
wasm: useWasm ? messageProcessorWasm : undefined,
|
|
117
123
|
},
|
|
118
124
|
outputDir,
|
|
119
125
|
tallyOutputFile: tallyFile,
|
|
@@ -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,IAAI,EACJ,
|
|
1
|
+
{"version":3,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,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,10 +14,10 @@ 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:
|
|
20
|
+
const { maci: maciContract, poll: pollContract, messageProcessor: messageProcessorContract, tally: tallyContract, } = await (0, utils_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
21
21
|
const verifyingKeysRegistryContractAddress = await tallyContract.verifyingKeysRegistry();
|
|
22
22
|
const [isStateAqMerged, isVerifyingKeyRegistryExists] = await Promise.all([
|
|
23
23
|
pollContract.stateMerged(),
|
|
@@ -32,7 +32,7 @@ const proveOnChain = async ({ pollId, proofDir, maciAddress, tallyFile, signer,
|
|
|
32
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,7 +59,7 @@ 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,
|
|
@@ -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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E7F,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,iBAAiB,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;YAC1D,MAAM,KAAK,GAAG,gBAAgB,GAAG,KAAK,CAAC;YACvC,MAAM,GAAG,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;YAErG,IAAI,KAAK,GAAG,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"}
|
|
@@ -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
|
|
@@ -100,11 +104,11 @@ 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
|
*/
|
|
@@ -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
|
*/
|
|
@@ -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,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,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G;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 @@
|
|
|
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,GAAG,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;YAChC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,KAAK,EAAE,IAAI,CAAC,SAAS;aACtB,CAAC;YACF,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,MAAM,EAAE,kBAAkB;aAC3B;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAoB,CAAC;QAEnD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC5C,8DAA8D;YAC9D,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,OAAO,IAAI,sBAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,OAAO,CAAC,mBAAM,CAAC,CAAC;QACzB,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlED,oCAkEC"}
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
export { generateTallyCommitments } from "./commitments";
|
|
2
2
|
export { verify } from "./verification";
|
|
3
|
-
export type { ITallyData, IVerifyArgs, IGenerateTallyCommitmentsArgs, ITallyCommitments,
|
|
4
|
-
export { getResultPerOption, getResults } from "./results";
|
|
3
|
+
export type { ITallyData, IVerifyArgs, IGenerateTallyCommitmentsArgs, ITallyCommitments, IVoteTallyInputs, IGetResultPerOptionArgs, IGetResultsArgs, IResult, } from "./types";
|
|
4
|
+
export { getResultPerOption, getResults, isTallied } from "./results";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/tally/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,YAAY,EACV,UAAU,EACV,WAAW,EACX,6BAA6B,EAC7B,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/tally/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,YAAY,EACV,UAAU,EACV,WAAW,EACX,6BAA6B,EAC7B,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,OAAO,GACR,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC"}
|
package/build/ts/tally/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getResults = exports.getResultPerOption = exports.verify = exports.generateTallyCommitments = void 0;
|
|
3
|
+
exports.isTallied = exports.getResults = exports.getResultPerOption = exports.verify = exports.generateTallyCommitments = void 0;
|
|
4
4
|
var commitments_1 = require("./commitments");
|
|
5
5
|
Object.defineProperty(exports, "generateTallyCommitments", { enumerable: true, get: function () { return commitments_1.generateTallyCommitments; } });
|
|
6
6
|
var verification_1 = require("./verification");
|
|
@@ -8,4 +8,5 @@ Object.defineProperty(exports, "verify", { enumerable: true, get: function () {
|
|
|
8
8
|
var results_1 = require("./results");
|
|
9
9
|
Object.defineProperty(exports, "getResultPerOption", { enumerable: true, get: function () { return results_1.getResultPerOption; } });
|
|
10
10
|
Object.defineProperty(exports, "getResults", { enumerable: true, get: function () { return results_1.getResults; } });
|
|
11
|
+
Object.defineProperty(exports, "isTallied", { enumerable: true, get: function () { return results_1.isTallied; } });
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/tally/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyD;AAAhD,uHAAA,wBAAwB,OAAA;AACjC,+CAAwC;AAA/B,sGAAA,MAAM,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/tally/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyD;AAAhD,uHAAA,wBAAwB,OAAA;AACjC,+CAAwC;AAA/B,sGAAA,MAAM,OAAA;AAWf,qCAAsE;AAA7D,6GAAA,kBAAkB,OAAA;AAAE,qGAAA,UAAU,OAAA;AAAE,oGAAA,SAAS,OAAA"}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import type { IGetResultPerOptionArgs, IGetResultsArgs } from "./types";
|
|
1
|
+
import type { IGetResultPerOptionArgs, IGetResultsArgs, IResult } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Get result per option
|
|
4
4
|
* @param {IGetResultPerOptionsArgs} - The arguments to get result per option
|
|
5
5
|
* @returns The result per option
|
|
6
6
|
*/
|
|
7
|
-
export declare const getResultPerOption: ({ maciAddress, pollId, index, signer, }: IGetResultPerOptionArgs) => Promise<
|
|
7
|
+
export declare const getResultPerOption: ({ maciAddress, pollId, index, signer, }: IGetResultPerOptionArgs) => Promise<IResult>;
|
|
8
8
|
/**
|
|
9
9
|
* Get all results from the Tally contract
|
|
10
10
|
* @param {IGetResultsArgs} - The arguments to get all the results
|
|
11
11
|
* @returns The results array (The final result of vote option n is in index n-1)
|
|
12
12
|
*/
|
|
13
|
-
export declare const getResults: ({ maciAddress, pollId, signer }: IGetResultsArgs) => Promise<
|
|
13
|
+
export declare const getResults: ({ maciAddress, pollId, signer }: IGetResultsArgs) => Promise<IResult[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Check if the poll is tallied
|
|
16
|
+
* @param {IGetResultsArgs} - The arguments to check if the poll is tallied
|
|
17
|
+
* @returns {boolean} - True if the poll is tallied, false otherwise
|
|
18
|
+
*/
|
|
19
|
+
export declare const isTallied: ({ maciAddress, pollId, signer }: IGetResultsArgs) => Promise<boolean>;
|
|
14
20
|
//# sourceMappingURL=results.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../ts/tally/results.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../ts/tally/results.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIjF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAU,yCAKtC,uBAAuB,KAAG,OAAO,CAAC,OAAO,CAS3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAU,iCAAiC,eAAe,KAAG,OAAO,CAAC,OAAO,EAAE,CAkBpG,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAU,iCAAiC,eAAe,KAAG,OAAO,CAAC,OAAO,CAIjG,CAAC"}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getResults = exports.getResultPerOption = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.isTallied = exports.getResults = exports.getResultPerOption = void 0;
|
|
4
|
+
const poll_1 = require("../poll");
|
|
5
5
|
/**
|
|
6
6
|
* Get result per option
|
|
7
7
|
* @param {IGetResultPerOptionsArgs} - The arguments to get result per option
|
|
8
8
|
* @returns The result per option
|
|
9
9
|
*/
|
|
10
10
|
const getResultPerOption = async ({ maciAddress, pollId, index, signer, }) => {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return result.value;
|
|
11
|
+
const { tally } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
12
|
+
const { value, isSet } = await tally.getTallyResults(index);
|
|
13
|
+
return {
|
|
14
|
+
value,
|
|
15
|
+
isSet,
|
|
16
|
+
};
|
|
19
17
|
};
|
|
20
18
|
exports.getResultPerOption = getResultPerOption;
|
|
21
19
|
/**
|
|
@@ -24,21 +22,28 @@ exports.getResultPerOption = getResultPerOption;
|
|
|
24
22
|
* @returns The results array (The final result of vote option n is in index n-1)
|
|
25
23
|
*/
|
|
26
24
|
const getResults = async ({ maciAddress, pollId, signer }) => {
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const pollContract = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer);
|
|
30
|
-
const numberOfVoteOptions = await pollContract.voteOptions();
|
|
31
|
-
const tallyContract = typechain_types_1.Tally__factory.connect(pollContracts.tally, signer);
|
|
25
|
+
const { poll, tally } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
26
|
+
const numberOfVoteOptions = await poll.voteOptions();
|
|
32
27
|
const results = [];
|
|
33
28
|
for (let i = 0; i < numberOfVoteOptions; i += 1) {
|
|
34
29
|
// eslint-disable-next-line no-await-in-loop
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
const { value, isSet } = await tally.getTallyResults(i);
|
|
31
|
+
results.push({
|
|
32
|
+
value,
|
|
33
|
+
isSet,
|
|
34
|
+
});
|
|
40
35
|
}
|
|
41
36
|
return results;
|
|
42
37
|
};
|
|
43
38
|
exports.getResults = getResults;
|
|
39
|
+
/**
|
|
40
|
+
* Check if the poll is tallied
|
|
41
|
+
* @param {IGetResultsArgs} - The arguments to check if the poll is tallied
|
|
42
|
+
* @returns {boolean} - True if the poll is tallied, false otherwise
|
|
43
|
+
*/
|
|
44
|
+
const isTallied = async ({ maciAddress, pollId, signer }) => {
|
|
45
|
+
const { tally } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
46
|
+
return tally.isTallied();
|
|
47
|
+
};
|
|
48
|
+
exports.isTallied = isTallied;
|
|
44
49
|
//# sourceMappingURL=results.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.js","sourceRoot":"","sources":["../../../ts/tally/results.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"results.js","sourceRoot":"","sources":["../../../ts/tally/results.ts"],"names":[],"mappings":";;;AAEA,kCAA2C;AAE3C;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACvC,WAAW,EACX,MAAM,EACN,KAAK,EACL,MAAM,GACkB,EAAoB,EAAE;IAC9C,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,uBAAgB,EA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