@maci-protocol/sdk 0.0.0-ci.26f28d6
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 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/maciKeys/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/maciKeys/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/poll/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPollContracts = exports.getPollParams = exports.getPoll = void 0;
|
|
4
|
+
var poll_1 = require("./poll");
|
|
5
|
+
Object.defineProperty(exports, "getPoll", { enumerable: true, get: function () { return poll_1.getPoll; } });
|
|
6
|
+
Object.defineProperty(exports, "getPollParams", { enumerable: true, get: function () { return poll_1.getPollParams; } });
|
|
7
|
+
var utils_1 = require("./utils");
|
|
8
|
+
Object.defineProperty(exports, "getPollContracts", { enumerable: true, get: function () { return utils_1.getPollContracts; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/poll/index.ts"],"names":[],"mappings":";;;AAAA,+BAAgD;AAAvC,+FAAA,OAAO,OAAA;AAAE,qGAAA,aAAa,OAAA;AAC/B,iCAA2C;AAAlC,yGAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IGetPollArgs, IGetPollData, IGetPollParamsArgs, IPollParams } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Get deployed poll from MACI contract
|
|
4
|
+
* @param {IGetPollArgs} args - The arguments for the get poll command
|
|
5
|
+
* @returns {IGetPollData} poll data
|
|
6
|
+
*/
|
|
7
|
+
export declare const getPoll: ({ maciAddress, signer, provider, pollId }: IGetPollArgs) => Promise<IGetPollData>;
|
|
8
|
+
/**
|
|
9
|
+
* Get the parameters for the poll
|
|
10
|
+
* @param {IGetPollParamsArgs} args - The arguments for the get poll command
|
|
11
|
+
* @returns {IPollParams} poll parameters
|
|
12
|
+
*/
|
|
13
|
+
export declare const getPollParams: ({ pollId, signer, maciContractAddress, }: IGetPollParamsArgs) => Promise<IPollParams>;
|
|
14
|
+
//# sourceMappingURL=poll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poll.d.ts","sourceRoot":"","sources":["../../../ts/poll/poll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3F;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAU,2CAA2C,YAAY,KAAG,OAAO,CAAC,YAAY,CAgC3G,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,0CAIjC,kBAAkB,KAAG,OAAO,CAAC,WAAW,CAwB1C,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPollParams = exports.getPoll = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
/**
|
|
6
|
+
* Get deployed poll from MACI contract
|
|
7
|
+
* @param {IGetPollArgs} args - The arguments for the get poll command
|
|
8
|
+
* @returns {IGetPollData} poll data
|
|
9
|
+
*/
|
|
10
|
+
const getPoll = async ({ maciAddress, signer, provider, pollId }) => {
|
|
11
|
+
if (!signer && !provider) {
|
|
12
|
+
throw new Error("No signer and provider are provided");
|
|
13
|
+
}
|
|
14
|
+
const { id, poll: pollContract, maci: maciContract, tally: tallyContract, } = await (0, utils_1.getPollContracts)({ maciAddress, pollId, signer, provider });
|
|
15
|
+
const [[startDate, endDate], mergedStateRoot, pollAddress] = await Promise.all([
|
|
16
|
+
pollContract.getStartAndEndDate(),
|
|
17
|
+
pollContract.mergedStateRoot(),
|
|
18
|
+
pollContract.getAddress(),
|
|
19
|
+
]);
|
|
20
|
+
const isMerged = mergedStateRoot !== BigInt(0);
|
|
21
|
+
const numSignups = await (isMerged ? pollContract.numSignups() : maciContract.numSignUps());
|
|
22
|
+
// get the poll mode
|
|
23
|
+
const mode = await tallyContract.mode();
|
|
24
|
+
return {
|
|
25
|
+
id,
|
|
26
|
+
address: pollAddress,
|
|
27
|
+
startDate,
|
|
28
|
+
endDate,
|
|
29
|
+
numSignups,
|
|
30
|
+
isMerged,
|
|
31
|
+
mode,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
exports.getPoll = getPoll;
|
|
35
|
+
/**
|
|
36
|
+
* Get the parameters for the poll
|
|
37
|
+
* @param {IGetPollParamsArgs} args - The arguments for the get poll command
|
|
38
|
+
* @returns {IPollParams} poll parameters
|
|
39
|
+
*/
|
|
40
|
+
const getPollParams = async ({ pollId, signer, maciContractAddress, }) => {
|
|
41
|
+
// get the contract objects
|
|
42
|
+
const { poll: pollContract } = await (0, utils_1.getPollContracts)({
|
|
43
|
+
maciAddress: maciContractAddress,
|
|
44
|
+
pollId,
|
|
45
|
+
signer,
|
|
46
|
+
});
|
|
47
|
+
const treeDepths = await pollContract.treeDepths();
|
|
48
|
+
const voteOptionTreeDepth = Number(treeDepths.voteOptionTreeDepth);
|
|
49
|
+
const numVoteOptions = 5 ** voteOptionTreeDepth;
|
|
50
|
+
const messageBatchSize = Number.parseInt((await pollContract.messageBatchSize()).toString(), 10);
|
|
51
|
+
const intStateTreeDepth = Number(treeDepths.intStateTreeDepth);
|
|
52
|
+
const tallyBatchSize = 5 ** intStateTreeDepth;
|
|
53
|
+
return {
|
|
54
|
+
messageBatchSize,
|
|
55
|
+
numVoteOptions,
|
|
56
|
+
tallyBatchSize,
|
|
57
|
+
voteOptionTreeDepth,
|
|
58
|
+
intStateTreeDepth,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
exports.getPollParams = getPollParams;
|
|
62
|
+
//# sourceMappingURL=poll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poll.js","sourceRoot":"","sources":["../../../ts/poll/poll.ts"],"names":[],"mappings":";;;AAEA,mCAA2C;AAE3C;;;;GAIG;AACI,MAAM,OAAO,GAAG,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAgB,EAAyB,EAAE;IAC9G,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,EACJ,EAAE,EACF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AAC;IACnE,MAAM,cAAc,GAAG,CAAC,IAAI,mBAAmB,CAAC;IAEhD,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,YAAY,CAAC,gBAAgB,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IAEjG,MAAM,iBAAiB,GAAG,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC/D,MAAM,cAAc,GAAG,CAAC,IAAI,iBAAiB,CAAC;IAE9C,OAAO;QACL,gBAAgB;QAChB,cAAc;QACd,cAAc;QACd,mBAAmB;QACnB,iBAAiB;KAClB,CAAC;AACJ,CAAC,CAAC;AA5BW,QAAA,aAAa,iBA4BxB"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { Poll, MessageProcessor, Tally, MACI } from "@maci-protocol/contracts/typechain-types";
|
|
2
|
+
import type { BigNumberish, Provider, Signer } from "ethers";
|
|
3
|
+
/**
|
|
4
|
+
* Interface for the arguments to the get poll command
|
|
5
|
+
*/
|
|
6
|
+
export interface IGetPollArgs {
|
|
7
|
+
/**
|
|
8
|
+
* A signer object
|
|
9
|
+
*/
|
|
10
|
+
signer?: Signer;
|
|
11
|
+
/**
|
|
12
|
+
* A provider fallback object
|
|
13
|
+
*/
|
|
14
|
+
provider?: Provider;
|
|
15
|
+
/**
|
|
16
|
+
* The address of the MACI contract
|
|
17
|
+
*/
|
|
18
|
+
maciAddress: string;
|
|
19
|
+
/**
|
|
20
|
+
* The poll id. If not specified, latest poll id will be used
|
|
21
|
+
*/
|
|
22
|
+
pollId?: BigNumberish;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Interface that represents get poll contracts data
|
|
26
|
+
*/
|
|
27
|
+
export interface IGetPollContractsData {
|
|
28
|
+
/**
|
|
29
|
+
* Poll id
|
|
30
|
+
*/
|
|
31
|
+
id: bigint;
|
|
32
|
+
/**
|
|
33
|
+
* MACI contract
|
|
34
|
+
*/
|
|
35
|
+
maci: MACI;
|
|
36
|
+
/**
|
|
37
|
+
* Poll contract
|
|
38
|
+
*/
|
|
39
|
+
poll: Poll;
|
|
40
|
+
/**
|
|
41
|
+
* MessageProcessor contract
|
|
42
|
+
*/
|
|
43
|
+
messageProcessor: MessageProcessor;
|
|
44
|
+
/**
|
|
45
|
+
* Tally contract
|
|
46
|
+
*/
|
|
47
|
+
tally: Tally;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Interface for the return data to the get poll command
|
|
51
|
+
*/
|
|
52
|
+
export interface IGetPollData {
|
|
53
|
+
/**
|
|
54
|
+
* The poll id
|
|
55
|
+
*/
|
|
56
|
+
id: BigNumberish;
|
|
57
|
+
/**
|
|
58
|
+
* The poll address
|
|
59
|
+
*/
|
|
60
|
+
address: string;
|
|
61
|
+
/**
|
|
62
|
+
* The poll deployment timestamp
|
|
63
|
+
*/
|
|
64
|
+
startDate: BigNumberish;
|
|
65
|
+
/**
|
|
66
|
+
* The poll end timestamp
|
|
67
|
+
*/
|
|
68
|
+
endDate: BigNumberish;
|
|
69
|
+
/**
|
|
70
|
+
* The poll number of signups
|
|
71
|
+
*/
|
|
72
|
+
numSignups: BigNumberish;
|
|
73
|
+
/**
|
|
74
|
+
* Whether the MACI contract's state root has been merged
|
|
75
|
+
*/
|
|
76
|
+
isMerged: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Mode of the poll
|
|
79
|
+
*/
|
|
80
|
+
mode: BigNumberish;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Arguments for the get poll params command
|
|
84
|
+
*/
|
|
85
|
+
export interface IGetPollParamsArgs {
|
|
86
|
+
/**
|
|
87
|
+
* The poll id
|
|
88
|
+
*/
|
|
89
|
+
pollId: bigint;
|
|
90
|
+
/**
|
|
91
|
+
* The signer
|
|
92
|
+
*/
|
|
93
|
+
signer: Signer;
|
|
94
|
+
/**
|
|
95
|
+
* The MACI contract address
|
|
96
|
+
*/
|
|
97
|
+
maciContractAddress: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Poll parameters
|
|
101
|
+
*/
|
|
102
|
+
export interface IPollParams {
|
|
103
|
+
/**
|
|
104
|
+
* The message batch size
|
|
105
|
+
*/
|
|
106
|
+
messageBatchSize: number;
|
|
107
|
+
/**
|
|
108
|
+
* The number of vote options
|
|
109
|
+
*/
|
|
110
|
+
numVoteOptions: number;
|
|
111
|
+
/**
|
|
112
|
+
* Tally Batch Size
|
|
113
|
+
*/
|
|
114
|
+
tallyBatchSize: number;
|
|
115
|
+
/**
|
|
116
|
+
* The vote option tree depth
|
|
117
|
+
*/
|
|
118
|
+
voteOptionTreeDepth: number;
|
|
119
|
+
/**
|
|
120
|
+
* The depth of the tree holding the user ballots
|
|
121
|
+
*/
|
|
122
|
+
intStateTreeDepth: number;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Inputs for circuit PollJoining
|
|
126
|
+
*/
|
|
127
|
+
export interface IPollJoiningInputs {
|
|
128
|
+
privKey: bigint;
|
|
129
|
+
pollPubKey: bigint[][];
|
|
130
|
+
stateLeaf: bigint[];
|
|
131
|
+
siblings: bigint[][];
|
|
132
|
+
indices: bigint[];
|
|
133
|
+
nullifier: bigint;
|
|
134
|
+
credits: bigint;
|
|
135
|
+
stateRoot: bigint;
|
|
136
|
+
actualStateTreeDepth: bigint;
|
|
137
|
+
pollId: bigint;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Inputs for circuit PollJoined
|
|
141
|
+
*/
|
|
142
|
+
export interface IPollJoinedInputs {
|
|
143
|
+
privKey: bigint;
|
|
144
|
+
voiceCreditsBalance: bigint;
|
|
145
|
+
joinTimestamp: bigint;
|
|
146
|
+
stateLeaf: bigint[];
|
|
147
|
+
pathElements: bigint[][];
|
|
148
|
+
pathIndices: bigint[];
|
|
149
|
+
credits: bigint;
|
|
150
|
+
stateRoot: bigint;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL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EAAE,MAAM,CAAC;IACf;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/poll/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IGetPollArgs, IGetPollContractsData } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Get poll contracts
|
|
4
|
+
*
|
|
5
|
+
* @param args get poll contract args
|
|
6
|
+
* @returns poll contracts
|
|
7
|
+
*/
|
|
8
|
+
export declare const getPollContracts: ({ maciAddress, pollId, signer, provider, }: IGetPollArgs) => Promise<IGetPollContractsData>;
|
|
9
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/poll/utils.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAInE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAU,4CAKpC,YAAY,KAAG,OAAO,CAAC,qBAAqB,CAqC9C,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPollContracts = void 0;
|
|
4
|
+
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
5
|
+
const ethers_1 = require("ethers");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
/**
|
|
8
|
+
* Get poll contracts
|
|
9
|
+
*
|
|
10
|
+
* @param args get poll contract args
|
|
11
|
+
* @returns poll contracts
|
|
12
|
+
*/
|
|
13
|
+
const getPollContracts = async ({ maciAddress, pollId, signer, provider, }) => {
|
|
14
|
+
const maci = typechain_types_1.MACI__factory.connect(maciAddress, signer ?? provider);
|
|
15
|
+
const id = pollId === undefined ? await maci.nextPollId().then((nextPollId) => nextPollId - 1n) : BigInt(pollId);
|
|
16
|
+
if (id < 0n) {
|
|
17
|
+
throw new Error(`Invalid poll id ${id}`);
|
|
18
|
+
}
|
|
19
|
+
const isMaciExists = await (0, utils_1.contractExists)(signer?.provider || provider, maciAddress);
|
|
20
|
+
if (!isMaciExists) {
|
|
21
|
+
throw new Error("MACI contract does not exist");
|
|
22
|
+
}
|
|
23
|
+
const pollContracts = await maci.polls(id);
|
|
24
|
+
if (pollContracts.poll === ethers_1.ZeroAddress) {
|
|
25
|
+
throw new Error(`MACI contract doesn't have any deployed poll ${id}`);
|
|
26
|
+
}
|
|
27
|
+
const isPollExists = await (0, utils_1.contractExists)(signer?.provider || provider, pollContracts.poll);
|
|
28
|
+
if (!isPollExists) {
|
|
29
|
+
throw new Error("Poll contract does not exist");
|
|
30
|
+
}
|
|
31
|
+
const poll = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer ?? provider);
|
|
32
|
+
const messageProcessor = typechain_types_1.MessageProcessor__factory.connect(pollContracts.messageProcessor, signer ?? provider);
|
|
33
|
+
const tally = typechain_types_1.Tally__factory.connect(pollContracts.tally, signer ?? provider);
|
|
34
|
+
return {
|
|
35
|
+
id,
|
|
36
|
+
maci,
|
|
37
|
+
poll,
|
|
38
|
+
messageProcessor,
|
|
39
|
+
tally,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.getPollContracts = getPollContracts;
|
|
43
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/poll/utils.ts"],"names":[],"mappings":";;;AAAA,8EAKkD;AAClD,mCAAqC;AAIrC,oCAA0C;AAE1C;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,KAAK,EAAE,EACrC,WAAW,EACX,MAAM,EACN,MAAM,EACN,QAAQ,GACK,EAAkC,EAAE;IACjD,MAAM,IAAI,GAAG,+BAAW,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;IAClE,MAAM,EAAE,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CA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
+
{"version":3,"file":"download.test.d.ts","sourceRoot":"","sources":["../../../../ts/proof/__tests__/download.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const contracts_1 = require("@maci-protocol/contracts");
|
|
4
|
+
const download_1 = require("../download");
|
|
5
|
+
/**
|
|
6
|
+
* The inputs for the proof generation
|
|
7
|
+
*/
|
|
8
|
+
const inputs = {
|
|
9
|
+
privKey: "1259082279488355278660453796037744749156697484507442909424227073450806091599",
|
|
10
|
+
pollPubKey: [
|
|
11
|
+
"4604149953291977424931588219098726306922992659857425248363017596008978179462",
|
|
12
|
+
"1911350329545195833133079763781611226710101140694516439580176096139978229522",
|
|
13
|
+
],
|
|
14
|
+
siblings: [
|
|
15
|
+
["1309255631273308531193241901289907343161346846555918942743921933037802809814"],
|
|
16
|
+
["0"],
|
|
17
|
+
["0"],
|
|
18
|
+
["0"],
|
|
19
|
+
["0"],
|
|
20
|
+
["0"],
|
|
21
|
+
["0"],
|
|
22
|
+
["0"],
|
|
23
|
+
["0"],
|
|
24
|
+
["0"],
|
|
25
|
+
],
|
|
26
|
+
indices: ["1", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
|
|
27
|
+
nullifier: "5960968591926285526739882209300764345427591192846309606519433839944864771425",
|
|
28
|
+
stateRoot: "19853258600018552129206808764461795697997153860385513081821578400505176714352",
|
|
29
|
+
actualStateTreeDepth: "1",
|
|
30
|
+
pollId: "0",
|
|
31
|
+
};
|
|
32
|
+
describe("downloadPollJoiningArtifactsBrowser", () => {
|
|
33
|
+
it("should allow to generate a proof using the downloaded artifacts", async () => {
|
|
34
|
+
const { zKey, wasm } = await (0, download_1.downloadPollJoiningArtifactsBrowser)(true);
|
|
35
|
+
expect(zKey).toBeDefined();
|
|
36
|
+
expect(wasm).toBeDefined();
|
|
37
|
+
const { proof } = await (0, contracts_1.genProofSnarkjs)({
|
|
38
|
+
inputs: inputs,
|
|
39
|
+
zkeyPath: zKey,
|
|
40
|
+
wasmPath: wasm,
|
|
41
|
+
});
|
|
42
|
+
expect(proof).toBeDefined();
|
|
43
|
+
expect(proof.protocol).toBe("groth16");
|
|
44
|
+
expect(proof.pi_a.length).toBe(3);
|
|
45
|
+
expect(proof.pi_b.length).toBe(3);
|
|
46
|
+
expect(proof.pi_c.length).toBe(3);
|
|
47
|
+
expect(proof.curve).toBe("bn128");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=download.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.test.js","sourceRoot":"","sources":["../../../../ts/proof/__tests__/download.test.ts"],"names":[],"mappings":";;AAAA,wDAA2D;AAG3D,0CAAkE;AAElE;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,8EAA8E;IACvF,UAAU,EAAE;QACV,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,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAC3D,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,IAAI,CAAC,CAAC;QAEvE,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,2BAAe,EAAC;YACtC,MAAM,EAAE,MAAkC;YAC1C,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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The url of the poll joining zkey for testing
|
|
3
|
+
*/
|
|
4
|
+
export declare const pollJoiningZkeyTestingUrl = "https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/testing/PollJoining_10_test.0.zkey";
|
|
5
|
+
/**
|
|
6
|
+
* The url of the poll joining zkey for production
|
|
7
|
+
*/
|
|
8
|
+
export declare const pollJoiningWasmTestingUrl = "https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/testing/PollJoining_10_test.wasm";
|
|
9
|
+
/**
|
|
10
|
+
* The url of the poll joining zkey for production
|
|
11
|
+
*/
|
|
12
|
+
export declare const pollJoiningZkeyProductionUrl = "not-available";
|
|
13
|
+
/**
|
|
14
|
+
* The url of the poll joining wasm for production
|
|
15
|
+
*/
|
|
16
|
+
export declare const pollJoiningWasmProductionUrl = "not-available";
|
|
17
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../ts/proof/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,yBAAyB,uHACgF,CAAC;AAEvH;;GAEG;AACH,eAAO,MAAM,yBAAyB,qHAC8E,CAAC;AAErH;;GAEG;AACH,eAAO,MAAM,4BAA4B,kBAAkB,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,4BAA4B,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pollJoiningWasmProductionUrl = exports.pollJoiningZkeyProductionUrl = exports.pollJoiningWasmTestingUrl = exports.pollJoiningZkeyTestingUrl = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The url of the poll joining zkey for testing
|
|
6
|
+
*/
|
|
7
|
+
exports.pollJoiningZkeyTestingUrl = "https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/testing/PollJoining_10_test.0.zkey";
|
|
8
|
+
/**
|
|
9
|
+
* The url of the poll joining zkey for production
|
|
10
|
+
*/
|
|
11
|
+
exports.pollJoiningWasmTestingUrl = "https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/testing/PollJoining_10_test.wasm";
|
|
12
|
+
/**
|
|
13
|
+
* The url of the poll joining zkey for production
|
|
14
|
+
*/
|
|
15
|
+
exports.pollJoiningZkeyProductionUrl = "not-available";
|
|
16
|
+
/**
|
|
17
|
+
* The url of the poll joining wasm for production
|
|
18
|
+
*/
|
|
19
|
+
exports.pollJoiningWasmProductionUrl = "not-available";
|
|
20
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../ts/proof/constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,yBAAyB,GACpC,oHAAoH,CAAC;AAEvH;;GAEG;AACU,QAAA,yBAAyB,GACpC,kHAAkH,CAAC;AAErH;;GAEG;AACU,QAAA,4BAA4B,GAAG,eAAe,CAAC;AAE5D;;GAEG;AACU,QAAA,4BAA4B,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IPollJoiningArtifacts } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Download the poll joining artifacts for the browser
|
|
4
|
+
*
|
|
5
|
+
* @param testing - Whether to download the testing artifacts
|
|
6
|
+
* @returns The poll joining artifacts
|
|
7
|
+
*/
|
|
8
|
+
export declare const downloadPollJoiningArtifactsBrowser: (testing?: boolean) => Promise<IPollJoiningArtifacts>;
|
|
9
|
+
//# sourceMappingURL=download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../ts/proof/download.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA4CrD;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,GAAU,iBAAe,KAAG,OAAO,CAAC,qBAAqB,CAgBxG,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downloadPollJoiningArtifactsBrowser = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
/**
|
|
6
|
+
* Read the chunks of a response
|
|
7
|
+
*
|
|
8
|
+
* @param response - The response to read the chunks from
|
|
9
|
+
* @returns The chunks and the length
|
|
10
|
+
*/
|
|
11
|
+
const readChunks = async (reader) => {
|
|
12
|
+
let result = await reader.read();
|
|
13
|
+
const chunks = [];
|
|
14
|
+
let length = 0;
|
|
15
|
+
while (!result.done) {
|
|
16
|
+
const { value } = result;
|
|
17
|
+
length += value.length;
|
|
18
|
+
chunks.push(value);
|
|
19
|
+
// continue reading
|
|
20
|
+
// eslint-disable-next-line no-await-in-loop
|
|
21
|
+
result = await reader.read();
|
|
22
|
+
}
|
|
23
|
+
const { acc: obj } = chunks.reduce(({ acc, position }, chunk) => {
|
|
24
|
+
acc.set(chunk, position);
|
|
25
|
+
return { acc, position: position + chunk.length };
|
|
26
|
+
}, { acc: new Uint8Array(length), position: 0 });
|
|
27
|
+
return obj;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Download the poll joining artifacts for the browser
|
|
31
|
+
*
|
|
32
|
+
* @param testing - Whether to download the testing artifacts
|
|
33
|
+
* @returns The poll joining artifacts
|
|
34
|
+
*/
|
|
35
|
+
const downloadPollJoiningArtifactsBrowser = async (testing = false) => {
|
|
36
|
+
const [zKeyResponse, wasmResponse] = await Promise.all([
|
|
37
|
+
fetch(testing ? constants_1.pollJoiningZkeyTestingUrl : constants_1.pollJoiningZkeyProductionUrl),
|
|
38
|
+
fetch(testing ? constants_1.pollJoiningWasmTestingUrl : constants_1.pollJoiningWasmProductionUrl),
|
|
39
|
+
]);
|
|
40
|
+
const zKeyReader = zKeyResponse.body?.getReader();
|
|
41
|
+
const wasmReader = wasmResponse.body?.getReader();
|
|
42
|
+
if (!zKeyReader || !wasmReader) {
|
|
43
|
+
throw new Error("Failed to read zKey or wasm");
|
|
44
|
+
}
|
|
45
|
+
const [zKey, wasm] = await Promise.all([readChunks(zKeyReader), readChunks(wasmReader)]);
|
|
46
|
+
return { zKey, wasm };
|
|
47
|
+
};
|
|
48
|
+
exports.downloadPollJoiningArtifactsBrowser = downloadPollJoiningArtifactsBrowser;
|
|
49
|
+
//# sourceMappingURL=download.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../../ts/proof/download.ts"],"names":[],"mappings":";;;AAEA,2CAKqB;AAErB;;;;;GAKG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,MAA+C,EAAuB,EAAE;IAChG,IAAI,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAEjC,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAEzB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,KAA8B,CAAC,CAAC;QAE5C,mBAAmB;QACnB,4CAA4C;QAC5C,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,CAChC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE;QAC3B,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAEzB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;IACpD,CAAC,EACD,EAAE,GAAG,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAC7C,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF;;;;;GAKG;AACI,MAAM,mCAAmC,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK,EAAkC,EAAE;IAC3G,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,qCAAyB,CAAC,CAAC,CAAC,wCAA4B,CAAC;QACzE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,qCAAyB,CAAC,CAAC,CAAC,wCAA4B,CAAC;KAC1E,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;IAClD,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;IAElD,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAEzF,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC,CAAC;AAhBW,QAAA,mCAAmC,uCAgB9C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IGenerateProofsArgs, IGenerateProofsData } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Generate proofs for the message processing and tally calculations
|
|
4
|
+
* @param args - The arguments for the genProofs command
|
|
5
|
+
* @returns The tally data
|
|
6
|
+
*/
|
|
7
|
+
export declare const generateProofs: ({ outputDir, coordinatorPrivateKey, signer, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, transactionHash, startBlock, endBlock, blocksPerBatch, rapidsnark, useQuadraticVoting, tallyZkey, tallyWitgen, tallyWasm, processZkey, processWitgen, processWasm, processDatFile, tallyDatFile, tallyFile, useWasm, }: IGenerateProofsArgs) => Promise<IGenerateProofsData>;
|
|
8
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +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,4TAwBlC,mBAAmB,KAAG,OAAO,CAAC,mBAAmB,CA0InD,CAAC"}
|