@maci-protocol/sdk 0.0.0-ci.84b0e62 → 0.0.0-ci.85bba2d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -2
- package/build/package.json +4 -3
- package/build/ts/browser/index.d.ts +5 -7
- package/build/ts/browser/index.d.ts.map +1 -1
- package/build/ts/browser/index.js +11 -20
- package/build/ts/browser/index.js.map +1 -1
- package/build/ts/browser/joinPoll.d.ts +8 -0
- package/build/ts/browser/joinPoll.d.ts.map +1 -0
- package/build/ts/browser/joinPoll.js +88 -0
- package/build/ts/browser/joinPoll.js.map +1 -0
- package/build/ts/browser/utils.d.ts +18 -0
- package/build/ts/browser/utils.d.ts.map +1 -0
- package/build/ts/browser/utils.js +37 -0
- package/build/ts/browser/utils.js.map +1 -0
- package/build/ts/deploy/index.d.ts +2 -2
- package/build/ts/deploy/index.d.ts.map +1 -1
- package/build/ts/deploy/index.js +3 -3
- package/build/ts/deploy/index.js.map +1 -1
- package/build/ts/deploy/maci.js +1 -1
- 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 +18 -11
- package/build/ts/deploy/poll.js.map +1 -1
- package/build/ts/deploy/types.d.ts +18 -6
- package/build/ts/deploy/types.d.ts.map +1 -1
- package/build/ts/deploy/utils.js +1 -1
- package/build/ts/deploy/utils.js.map +1 -1
- package/build/ts/deploy/verifyingKeysRegistry.d.ts +7 -0
- package/build/ts/deploy/verifyingKeysRegistry.d.ts.map +1 -0
- package/build/ts/deploy/verifyingKeysRegistry.js +14 -0
- package/build/ts/deploy/verifyingKeysRegistry.js.map +1 -0
- package/build/ts/index.d.ts +1 -1
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +11 -7
- package/build/ts/index.js.map +1 -1
- package/build/ts/maci/policy.d.ts +13 -1
- package/build/ts/maci/policy.d.ts.map +1 -1
- package/build/ts/maci/policy.js +41 -2
- package/build/ts/maci/policy.js.map +1 -1
- package/build/ts/maci/state.d.ts +1 -1
- package/build/ts/maci/state.js +11 -11
- package/build/ts/maci/state.js.map +1 -1
- package/build/ts/maci/types.d.ts +34 -2
- package/build/ts/maci/types.d.ts.map +1 -1
- package/build/ts/maci/types.js +2 -0
- package/build/ts/maci/types.js.map +1 -1
- package/build/ts/maciKeys/__tests__/keypair.test.js +7 -7
- package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -1
- package/build/ts/maciKeys/__tests__/publicKeys.test.js +7 -7
- package/build/ts/maciKeys/__tests__/publicKeys.test.js.map +1 -1
- package/build/ts/maciKeys/keypair.js +3 -3
- package/build/ts/maciKeys/keypair.js.map +1 -1
- package/build/ts/maciKeys/publicKeys.d.ts +2 -2
- package/build/ts/maciKeys/publicKeys.d.ts.map +1 -1
- package/build/ts/maciKeys/publicKeys.js +6 -6
- package/build/ts/maciKeys/publicKeys.js.map +1 -1
- package/build/ts/poll/poll.js +4 -4
- package/build/ts/poll/poll.js.map +1 -1
- package/build/ts/poll/types.d.ts +5 -6
- package/build/ts/poll/types.d.ts.map +1 -1
- package/build/ts/poll/utils.js +3 -3
- package/build/ts/poll/utils.js.map +1 -1
- package/build/ts/proof/__tests__/download.test.js +3 -3
- 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.js +6 -6
- package/build/ts/proof/generate.js.map +1 -1
- package/build/ts/proof/prove.js +14 -14
- package/build/ts/proof/prove.js.map +1 -1
- package/build/ts/proof/types.d.ts +4 -4
- package/build/ts/proof/types.d.ts.map +1 -1
- package/build/ts/relayer/__tests__/messages.test.js +1 -1
- package/build/ts/relayer/__tests__/messages.test.js.map +1 -1
- package/build/ts/relayer/__tests__/utils.test.js +3 -3
- package/build/ts/relayer/__tests__/utils.test.js.map +1 -1
- package/build/ts/relayer/messages.js +1 -1
- package/build/ts/relayer/utils.js +4 -4
- package/build/ts/relayer/utils.js.map +1 -1
- package/build/ts/tally/commitments.js +2 -2
- package/build/ts/tally/commitments.js.map +1 -1
- package/build/ts/tally/types.d.ts +7 -7
- package/build/ts/tally/types.d.ts.map +1 -1
- package/build/ts/tally/utils.js +3 -3
- package/build/ts/tally/utils.js.map +1 -1
- package/build/ts/tally/verification.d.ts +1 -1
- package/build/ts/tally/verification.d.ts.map +1 -1
- package/build/ts/tally/verification.js +4 -4
- package/build/ts/tally/verification.js.map +1 -1
- package/build/ts/trees/stateTree.js +14 -11
- package/build/ts/trees/stateTree.js.map +1 -1
- package/build/ts/trees/types.d.ts +2 -2
- package/build/ts/trees/types.d.ts.map +1 -1
- package/build/ts/user/index.d.ts +3 -1
- package/build/ts/user/index.d.ts.map +1 -1
- package/build/ts/user/index.js +10 -8
- package/build/ts/user/index.js.map +1 -1
- package/build/ts/user/joinPoll.d.ts +8 -0
- package/build/ts/user/joinPoll.d.ts.map +1 -0
- package/build/ts/user/joinPoll.js +84 -0
- package/build/ts/user/joinPoll.js.map +1 -0
- package/build/ts/user/signup.d.ts +20 -0
- package/build/ts/user/signup.d.ts.map +1 -0
- package/build/ts/user/signup.js +79 -0
- package/build/ts/user/signup.js.map +1 -0
- package/build/ts/user/types.d.ts +12 -20
- package/build/ts/user/types.d.ts.map +1 -1
- package/build/ts/user/utils.d.ts +29 -13
- package/build/ts/user/utils.d.ts.map +1 -1
- package/build/ts/user/utils.js +66 -28
- package/build/ts/user/utils.js.map +1 -1
- package/build/ts/utils/proofs.d.ts +2 -2
- package/build/ts/utils/proofs.d.ts.map +1 -1
- package/build/ts/utils/proofs.js +4 -4
- package/build/ts/utils/proofs.js.map +1 -1
- package/build/ts/utils/types.d.ts +1 -1
- package/build/ts/utils/types.d.ts.map +1 -1
- package/build/ts/utils/utils.d.ts +8 -0
- package/build/ts/utils/utils.d.ts.map +1 -1
- package/build/ts/utils/utils.js +14 -1
- package/build/ts/utils/utils.js.map +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.js +13 -13
- package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/index.d.ts +2 -2
- package/build/ts/verifyingKeys/index.d.ts.map +1 -1
- package/build/ts/verifyingKeys/index.js +5 -5
- package/build/ts/verifyingKeys/index.js.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.js +44 -33
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/types.d.ts +36 -32
- package/build/ts/verifyingKeys/types.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.d.ts +10 -10
- package/build/ts/verifyingKeys/utils.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.js +74 -60
- package/build/ts/verifyingKeys/utils.js.map +1 -1
- package/build/ts/vote/generate.d.ts +1 -1
- package/build/ts/vote/generate.d.ts.map +1 -1
- package/build/ts/vote/generate.js +4 -4
- package/build/ts/vote/generate.js.map +1 -1
- package/build/ts/vote/index.d.ts +1 -1
- package/build/ts/vote/index.d.ts.map +1 -1
- package/build/ts/vote/index.js +2 -2
- package/build/ts/vote/index.js.map +1 -1
- package/build/ts/vote/invalidate.js +3 -3
- package/build/ts/vote/invalidate.js.map +1 -1
- package/build/ts/vote/publish.d.ts +1 -1
- package/build/ts/vote/publish.d.ts.map +1 -1
- package/build/ts/vote/publish.js +19 -19
- package/build/ts/vote/publish.js.map +1 -1
- package/build/ts/vote/submit.js +5 -5
- package/build/ts/vote/submit.js.map +1 -1
- package/build/ts/vote/types.d.ts +6 -6
- package/build/ts/vote/types.d.ts.map +1 -1
- package/build/ts/vote/utils.d.ts +2 -2
- package/build/ts/vote/utils.d.ts.map +1 -1
- package/build/ts/vote/utils.js +7 -7
- package/build/ts/vote/utils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +10 -9
- package/build/ts/deploy/vkRegistry.d.ts +0 -7
- package/build/ts/deploy/vkRegistry.d.ts.map +0 -1
- package/build/ts/deploy/vkRegistry.js +0 -14
- package/build/ts/deploy/vkRegistry.js.map +0 -1
- package/build/ts/user/user.d.ts +0 -42
- package/build/ts/user/user.d.ts.map +0 -1
- package/build/ts/user/user.js +0 -192
- package/build/ts/user/user.js.map +0 -1
|
@@ -9,7 +9,7 @@ const utils_1 = require("./utils");
|
|
|
9
9
|
* @param args - The arguments for the vote
|
|
10
10
|
* @returns The vote object
|
|
11
11
|
*/
|
|
12
|
-
const generateVote = ({ pollId, voteOptionIndex, salt, nonce, privateKey, stateIndex, voteWeight,
|
|
12
|
+
const generateVote = ({ pollId, voteOptionIndex, salt, nonce, privateKey, stateIndex, voteWeight, coordinatorPublicKey, maxVoteOption, ephemeralKeypair, newPublicKey, }) => {
|
|
13
13
|
const keypair = new domainobjs_1.Keypair(privateKey);
|
|
14
14
|
// validate args
|
|
15
15
|
if (voteOptionIndex < 0 || voteOptionIndex > maxVoteOption) {
|
|
@@ -25,18 +25,18 @@ const generateVote = ({ pollId, voteOptionIndex, salt, nonce, privateKey, stateI
|
|
|
25
25
|
if (salt && !(0, utils_1.validateSalt)(salt)) {
|
|
26
26
|
throw new Error("Invalid salt");
|
|
27
27
|
}
|
|
28
|
-
const userSalt = salt ? BigInt(salt) : (0, crypto_1.
|
|
28
|
+
const userSalt = salt ? BigInt(salt) : (0, crypto_1.generateRandomSalt)();
|
|
29
29
|
if (pollId < 0) {
|
|
30
30
|
throw new Error("Invalid poll id");
|
|
31
31
|
}
|
|
32
32
|
// if no ephemeral keypair is provided, generate a new one
|
|
33
33
|
const encKeypair = ephemeralKeypair ?? new domainobjs_1.Keypair();
|
|
34
34
|
// create the command object
|
|
35
|
-
const command = new domainobjs_1.PCommand(stateIndex,
|
|
35
|
+
const command = new domainobjs_1.PCommand(stateIndex, newPublicKey ?? keypair.publicKey, voteOptionIndex, voteWeight, nonce, pollId, userSalt);
|
|
36
36
|
// sign the command with the poll private key
|
|
37
37
|
const signature = command.sign(privateKey);
|
|
38
38
|
// encrypt the command using a shared key between the user and the coordinator
|
|
39
|
-
const message = command.encrypt(signature, domainobjs_1.Keypair.
|
|
39
|
+
const message = command.encrypt(signature, domainobjs_1.Keypair.generateEcdhSharedKey(encKeypair.privateKey, coordinatorPublicKey));
|
|
40
40
|
return {
|
|
41
41
|
message,
|
|
42
42
|
ephemeralKeypair: encKeypair,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../ts/vote/generate.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../ts/vote/generate.ts"],"names":[],"mappings":";;;AAAA,kDAA2D;AAC3D,0DAA8D;AAI9D,mCAAuC;AAEvC;;;;GAIG;AACI,MAAM,YAAY,GAAG,CAAC,EAC3B,MAAM,EACN,eAAe,EACf,IAAI,EACJ,KAAK,EACL,UAAU,EACV,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,YAAY,GACM,EAAS,EAAE;IAC7B,MAAM,OAAO,GAAG,IAAI,oBAAO,CAAC,UAAU,CAAC,CAAC;IAExC,gBAAgB;IAChB,IAAI,eAAe,GAAG,CAAC,IAAI,eAAe,GAAG,aAAa,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IAED,mDAAmD;IACnD,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,IAAI,IAAI,CAAC,IAAA,oBAAY,EAAC,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,2BAAkB,GAAE,CAAC;IAE5D,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,0DAA0D;IAC1D,MAAM,UAAU,GAAG,gBAAgB,IAAI,IAAI,oBAAO,EAAE,CAAC;IAErD,4BAA4B;IAC5B,MAAM,OAAO,GAAG,IAAI,qBAAQ,CAC1B,UAAU,EACV,YAAY,IAAI,OAAO,CAAC,SAAS,EACjC,eAAe,EACf,UAAU,EACV,KAAK,EACL,MAAM,EACN,QAAQ,CACT,CAAC;IAEF,6CAA6C;IAC7C,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAE3C,8EAA8E;IAC9E,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAC7B,SAAS,EACT,oBAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAC3E,CAAC;IAEF,OAAO;QACL,OAAO;QACP,gBAAgB,EAAE,UAAU;KAC7B,CAAC;AACJ,CAAC,CAAC;AAlEW,QAAA,YAAY,gBAkEvB"}
|
package/build/ts/vote/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export type { IVote, IGenerateVoteArgs, IPublishArgs, IPublishBatchArgs, IPublis
|
|
|
2
2
|
export { generateVote } from "./generate";
|
|
3
3
|
export { publish, publishBatch } from "./publish";
|
|
4
4
|
export { submitVote, submitVoteBatch } from "./submit";
|
|
5
|
-
export {
|
|
5
|
+
export { getCoordinatorPublicKey, validateSalt } from "./utils";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/vote/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,KAAK,EACL,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,oBAAoB,GACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/vote/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,KAAK,EACL,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,oBAAoB,GACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
package/build/ts/vote/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateSalt = exports.
|
|
3
|
+
exports.validateSalt = exports.getCoordinatorPublicKey = exports.submitVoteBatch = exports.submitVote = exports.publishBatch = exports.publish = exports.generateVote = void 0;
|
|
4
4
|
var generate_1 = require("./generate");
|
|
5
5
|
Object.defineProperty(exports, "generateVote", { enumerable: true, get: function () { return generate_1.generateVote; } });
|
|
6
6
|
var publish_1 = require("./publish");
|
|
@@ -10,6 +10,6 @@ var submit_1 = require("./submit");
|
|
|
10
10
|
Object.defineProperty(exports, "submitVote", { enumerable: true, get: function () { return submit_1.submitVote; } });
|
|
11
11
|
Object.defineProperty(exports, "submitVoteBatch", { enumerable: true, get: function () { return submit_1.submitVoteBatch; } });
|
|
12
12
|
var utils_1 = require("./utils");
|
|
13
|
-
Object.defineProperty(exports, "
|
|
13
|
+
Object.defineProperty(exports, "getCoordinatorPublicKey", { enumerable: true, get: function () { return utils_1.getCoordinatorPublicKey; } });
|
|
14
14
|
Object.defineProperty(exports, "validateSalt", { enumerable: true, get: function () { return utils_1.validateSalt; } });
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/vote/index.ts"],"names":[],"mappings":";;;AAWA,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,qCAAkD;AAAzC,kGAAA,OAAO,OAAA;AAAE,uGAAA,YAAY,OAAA;AAC9B,mCAAuD;AAA9C,oGAAA,UAAU,OAAA;AAAE,yGAAA,eAAe,OAAA;AACpC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/vote/index.ts"],"names":[],"mappings":";;;AAWA,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,qCAAkD;AAAzC,kGAAA,OAAO,OAAA;AAAE,uGAAA,YAAY,OAAA;AAC9B,mCAAuD;AAA9C,oGAAA,UAAU,OAAA;AAAE,yGAAA,eAAe,OAAA;AACpC,iCAAgE;AAAvD,gHAAA,uBAAuB,OAAA;AAAE,qGAAA,YAAY,OAAA"}
|
|
@@ -19,7 +19,7 @@ const utils_1 = require("./utils");
|
|
|
19
19
|
const invalidateVotes = async ({ maciAddress, pollId, signer, maciPrivateKey, stateIndex, }) => {
|
|
20
20
|
const { poll: pollContract } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
21
21
|
const [maxVoteOption, pollAddress] = await Promise.all([pollContract.voteOptions(), pollContract.getAddress()]);
|
|
22
|
-
const
|
|
22
|
+
const coordinatorPublicKey = await (0, utils_1.getCoordinatorPublicKey)(pollAddress, signer);
|
|
23
23
|
// generate the key change message
|
|
24
24
|
const message = (0, generate_1.generateVote)({
|
|
25
25
|
pollId,
|
|
@@ -28,9 +28,9 @@ const invalidateVotes = async ({ maciAddress, pollId, signer, maciPrivateKey, st
|
|
|
28
28
|
privateKey: maciPrivateKey,
|
|
29
29
|
stateIndex,
|
|
30
30
|
// use a random key to invalidate the previous votes
|
|
31
|
-
|
|
31
|
+
newPublicKey: new domainobjs_1.Keypair().publicKey,
|
|
32
32
|
voteWeight: 0n,
|
|
33
|
-
|
|
33
|
+
coordinatorPublicKey,
|
|
34
34
|
maxVoteOption,
|
|
35
35
|
});
|
|
36
36
|
const receipt = await (0, submit_1.submitVote)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalidate.js","sourceRoot":"","sources":["../../../ts/vote/invalidate.ts"],"names":[],"mappings":";;;AAAA,0DAAoD;AAIpD,kCAA2C;AAE3C,yCAA0C;AAC1C,qCAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"invalidate.js","sourceRoot":"","sources":["../../../ts/vote/invalidate.ts"],"names":[],"mappings":";;;AAAA,0DAAoD;AAIpD,kCAA2C;AAE3C,yCAA0C;AAC1C,qCAAsC;AACtC,mCAAkD;AAElD;;;;;;;;;GASG;AACI,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,WAAW,EACX,MAAM,EACN,MAAM,EACN,cAAc,EACd,UAAU,GACW,EAA+B,EAAE;IACtD,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,uBAAgB,EAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAEvF,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAChH,MAAM,oBAAoB,GAAG,MAAM,IAAA,+BAAuB,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAEhF,kCAAkC;IAClC,MAAM,OAAO,GAAG,IAAA,uBAAY,EAAC;QAC3B,MAAM;QACN,eAAe,EAAE,EAAE;QACnB,KAAK,EAAE,EAAE;QACT,UAAU,EAAE,cAAc;QAC1B,UAAU;QACV,oDAAoD;QACpD,YAAY,EAAE,IAAI,oBAAO,EAAE,CAAC,SAAS;QACrC,UAAU,EAAE,EAAE;QACd,oBAAoB;QACpB,aAAa;KACd,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAU,EAAC;QAC/B,WAAW;QACX,IAAI,EAAE,OAAO;QACb,MAAM;KACP,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAjCW,QAAA,eAAe,mBAiC1B"}
|
|
@@ -4,7 +4,7 @@ import type { IPublishBatchArgs, IPublishBatchData, IPublishArgs, IPublishData }
|
|
|
4
4
|
* @param {IPublishArgs} args - The arguments for the publish command
|
|
5
5
|
* @returns {IPublishData} The ephemeral private key used to encrypt the message, transaction hash
|
|
6
6
|
*/
|
|
7
|
-
export declare const publish: ({
|
|
7
|
+
export declare const publish: ({ stateIndex, voteOptionIndex, nonce, pollId, newVoteWeight, maciAddress, salt, publicKey: serializedPublicKey, privateKey: serializedPrivateKey, signer, }: IPublishArgs) => Promise<IPublishData>;
|
|
8
8
|
/**
|
|
9
9
|
* Batch publish new messages to a MACI Poll contract
|
|
10
10
|
* @param {IPublishBatchArgs} args - The arguments for the publish command
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../ts/vote/publish.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQhG;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAU
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../ts/vote/publish.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQhG;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAU,6JAW3B,YAAY,KAAG,OAAO,CAAC,YAAY,CAqCrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAU,mEAOhC,iBAAiB,KAAG,OAAO,CAAC,iBAAiB,CA4C/C,CAAC"}
|
package/build/ts/vote/publish.js
CHANGED
|
@@ -11,35 +11,35 @@ const utils_1 = require("./utils");
|
|
|
11
11
|
* @param {IPublishArgs} args - The arguments for the publish command
|
|
12
12
|
* @returns {IPublishData} The ephemeral private key used to encrypt the message, transaction hash
|
|
13
13
|
*/
|
|
14
|
-
const publish = async ({
|
|
15
|
-
if (!domainobjs_1.
|
|
14
|
+
const publish = async ({ stateIndex, voteOptionIndex, nonce, pollId, newVoteWeight, maciAddress, salt, publicKey: serializedPublicKey, privateKey: serializedPrivateKey, signer, }) => {
|
|
15
|
+
if (!domainobjs_1.PublicKey.isValidSerialized(serializedPublicKey)) {
|
|
16
16
|
throw new Error("Invalid MACI public key");
|
|
17
17
|
}
|
|
18
|
-
if (!domainobjs_1.
|
|
18
|
+
if (!domainobjs_1.PrivateKey.isValidSerialized(serializedPrivateKey)) {
|
|
19
19
|
throw new Error("Invalid MACI private key");
|
|
20
20
|
}
|
|
21
21
|
const { poll: pollContract } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
22
|
-
const
|
|
23
|
-
const
|
|
22
|
+
const votePublicKey = domainobjs_1.PublicKey.deserialize(serializedPublicKey);
|
|
23
|
+
const privateKey = domainobjs_1.PrivateKey.deserialize(serializedPrivateKey);
|
|
24
24
|
const [maxVoteOption, pollAddress] = await Promise.all([pollContract.voteOptions(), pollContract.getAddress()]);
|
|
25
|
-
const
|
|
25
|
+
const coordinatorPublicKey = await (0, utils_1.getCoordinatorPublicKey)(pollAddress, signer);
|
|
26
26
|
const vote = (0, generate_1.generateVote)({
|
|
27
27
|
pollId,
|
|
28
28
|
voteOptionIndex,
|
|
29
29
|
salt,
|
|
30
30
|
nonce,
|
|
31
|
-
privateKey
|
|
31
|
+
privateKey,
|
|
32
32
|
stateIndex,
|
|
33
33
|
voteWeight: newVoteWeight,
|
|
34
|
-
|
|
34
|
+
coordinatorPublicKey,
|
|
35
35
|
maxVoteOption,
|
|
36
|
-
|
|
36
|
+
newPublicKey: votePublicKey,
|
|
37
37
|
});
|
|
38
38
|
const txHash = await (0, submit_1.submitVote)({ pollAddress, vote, signer });
|
|
39
39
|
return {
|
|
40
40
|
hash: txHash,
|
|
41
41
|
encryptedMessage: vote.message,
|
|
42
|
-
privateKey: vote.ephemeralKeypair.
|
|
42
|
+
privateKey: vote.ephemeralKeypair.privateKey.serialize(),
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
45
|
exports.publish = publish;
|
|
@@ -49,29 +49,29 @@ exports.publish = publish;
|
|
|
49
49
|
* @returns {IPublishBatchData} The ephemeral private key used to encrypt the message, transaction hash
|
|
50
50
|
*/
|
|
51
51
|
const publishBatch = async ({ messages, pollId, maciAddress, publicKey, privateKey, signer, }) => {
|
|
52
|
-
if (!domainobjs_1.
|
|
52
|
+
if (!domainobjs_1.PublicKey.isValidSerialized(publicKey)) {
|
|
53
53
|
throw new Error("Invalid MACI public key");
|
|
54
54
|
}
|
|
55
|
-
if (!domainobjs_1.
|
|
55
|
+
if (!domainobjs_1.PrivateKey.isValidSerialized(privateKey)) {
|
|
56
56
|
throw new Error("Invalid MACI private key");
|
|
57
57
|
}
|
|
58
58
|
const { poll: pollContract } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
59
|
-
const
|
|
60
|
-
const
|
|
59
|
+
const userMaciPublicKey = domainobjs_1.PublicKey.deserialize(publicKey);
|
|
60
|
+
const userMaciPrivateKey = domainobjs_1.PrivateKey.deserialize(privateKey);
|
|
61
61
|
const [maxVoteOption, pollAddress] = await Promise.all([pollContract.voteOptions(), pollContract.getAddress()]);
|
|
62
|
-
const
|
|
62
|
+
const coordinatorPublicKey = await (0, utils_1.getCoordinatorPublicKey)(pollAddress, signer);
|
|
63
63
|
// validate the vote options index against the max leaf index on-chain
|
|
64
64
|
const votes = messages.map(({ stateIndex, voteOptionIndex, salt, nonce, newVoteWeight }) => (0, generate_1.generateVote)({
|
|
65
65
|
pollId,
|
|
66
66
|
voteOptionIndex,
|
|
67
67
|
nonce,
|
|
68
|
-
privateKey:
|
|
68
|
+
privateKey: userMaciPrivateKey,
|
|
69
69
|
stateIndex,
|
|
70
70
|
maxVoteOption: BigInt(maxVoteOption),
|
|
71
71
|
salt,
|
|
72
72
|
voteWeight: newVoteWeight,
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
coordinatorPublicKey,
|
|
74
|
+
newPublicKey: userMaciPublicKey,
|
|
75
75
|
}));
|
|
76
76
|
const txHash = await (0, submit_1.submitVoteBatch)({
|
|
77
77
|
pollAddress,
|
|
@@ -81,7 +81,7 @@ const publishBatch = async ({ messages, pollId, maciAddress, publicKey, privateK
|
|
|
81
81
|
return {
|
|
82
82
|
hash: txHash,
|
|
83
83
|
encryptedMessages: votes.map((vote) => vote.message),
|
|
84
|
-
privateKeys: votes.map((vote) => vote.ephemeralKeypair.
|
|
84
|
+
privateKeys: votes.map((vote) => vote.ephemeralKeypair.privateKey.serialize()),
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
87
|
exports.publishBatch = publishBatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../ts/vote/publish.ts"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EAAE,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAChH,MAAM,oBAAoB,GAAG,MAAM,IAAA,+BAAuB,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAEhF,sEAAsE;IACtE,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,CACzF,IAAA,uBAAY,EAAC;QACX,MAAM;QACN,eAAe;QACf,KAAK;QACL,UAAU,EAAE,kBAAkB;QAC9B,UAAU;QACV,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC;QACpC,IAAI;QACJ,UAAU,EAAE,aAAa;QACzB,oBAAoB;QACpB,YAAY,EAAE,iBAAiB;KAChC,CAAC,CACH,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAe,EAAC;QACnC,WAAW;QACX,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE;QACtB,MAAM;KACP,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,MAAO;QACb,iBAAiB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;QACpD,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;KAC/E,CAAC;AACJ,CAAC,CAAC;AAnDW,QAAA,YAAY,gBAmDvB"}
|
package/build/ts/vote/submit.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.submitVoteBatch = exports.submitVote = void 0;
|
|
4
|
-
const
|
|
4
|
+
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
5
5
|
/**
|
|
6
6
|
* Submit a vote
|
|
7
7
|
* @param args - The arguments for the vote
|
|
8
8
|
*/
|
|
9
9
|
const submitVote = async ({ pollAddress, vote, signer }) => {
|
|
10
|
-
const pollContract =
|
|
10
|
+
const pollContract = typechain_types_1.Poll__factory.connect(pollAddress, signer);
|
|
11
11
|
const receipt = await pollContract
|
|
12
|
-
.publishMessage(vote.message, vote.ephemeralKeypair.
|
|
12
|
+
.publishMessage(vote.message, vote.ephemeralKeypair.publicKey.asContractParam())
|
|
13
13
|
.then((tx) => tx.wait());
|
|
14
14
|
if (receipt?.status === 0) {
|
|
15
15
|
throw new Error("Failed to submit the vote");
|
|
@@ -23,9 +23,9 @@ exports.submitVote = submitVote;
|
|
|
23
23
|
* @dev Please ensure that the votes are in reverse order (by nonce) to be processed correctly
|
|
24
24
|
*/
|
|
25
25
|
const submitVoteBatch = async ({ pollAddress, votes, signer, }) => {
|
|
26
|
-
const pollContract =
|
|
26
|
+
const pollContract = typechain_types_1.Poll__factory.connect(pollAddress, signer);
|
|
27
27
|
const receipt = await pollContract
|
|
28
|
-
.publishMessageBatch(votes.map((vote) => vote.message), votes.map((vote) => vote.ephemeralKeypair.
|
|
28
|
+
.publishMessageBatch(votes.map((vote) => vote.message), votes.map((vote) => vote.ephemeralKeypair.publicKey.asContractParam()))
|
|
29
29
|
.then((tx) => tx.wait());
|
|
30
30
|
if (receipt?.status === 0) {
|
|
31
31
|
throw new Error("Failed to submit the batch of votes");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit.js","sourceRoot":"","sources":["../../../ts/vote/submit.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"submit.js","sourceRoot":"","sources":["../../../ts/vote/submit.ts"],"names":[],"mappings":";;;AAAA,8EAAwF;AAIxF;;;GAGG;AACI,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAmB,EAA+B,EAAE;IAC9G,MAAM,YAAY,GAAG,+BAAW,CAAC,OAAO,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 @@
|
|
|
1
|
-
import type { IMessageContractParams, Keypair, Message,
|
|
1
|
+
import type { IMessageContractParams, Keypair, Message, PrivateKey, PublicKey } from "@maci-protocol/domainobjs";
|
|
2
2
|
import type { Signer } from "ethers";
|
|
3
3
|
/**
|
|
4
4
|
* Interface for the arguments for the generateVote function
|
|
@@ -23,7 +23,7 @@ export interface IGenerateVoteArgs {
|
|
|
23
23
|
/**
|
|
24
24
|
* The private key for the vote
|
|
25
25
|
*/
|
|
26
|
-
privateKey:
|
|
26
|
+
privateKey: PrivateKey;
|
|
27
27
|
/**
|
|
28
28
|
* The state index for the vote
|
|
29
29
|
*/
|
|
@@ -35,7 +35,7 @@ export interface IGenerateVoteArgs {
|
|
|
35
35
|
/**
|
|
36
36
|
* The coordinator public key
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
coordinatorPublicKey: PublicKey;
|
|
39
39
|
/**
|
|
40
40
|
* The largest vote option index
|
|
41
41
|
*/
|
|
@@ -47,7 +47,7 @@ export interface IGenerateVoteArgs {
|
|
|
47
47
|
/**
|
|
48
48
|
* New key in case of key change message
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
newPublicKey?: PublicKey;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Interface for the vote object
|
|
@@ -175,7 +175,7 @@ export interface IPublishArgs extends IPublishMessage {
|
|
|
175
175
|
/**
|
|
176
176
|
* The poll public key
|
|
177
177
|
*/
|
|
178
|
-
|
|
178
|
+
publicKey: string;
|
|
179
179
|
/**
|
|
180
180
|
* The poll private key
|
|
181
181
|
*/
|
|
@@ -229,7 +229,7 @@ export interface IInvalidateVotesArgs {
|
|
|
229
229
|
/**
|
|
230
230
|
* MACI private key
|
|
231
231
|
*/
|
|
232
|
-
maciPrivateKey:
|
|
232
|
+
maciPrivateKey: PrivateKey;
|
|
233
233
|
/**
|
|
234
234
|
* State index
|
|
235
235
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/vote/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/vote/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACjH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,oBAAoB,EAAE,SAAS,CAAC;IAEhC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,oBAA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MAAM,CAAC;IAEnB;;OAEG;IACH,gBAAgB,EAAE,sBAAsB,CAAC;IAEzC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,cAAc,EAAE,UAAU,CAAC;IAE3B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
package/build/ts/vote/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PublicKey } from "@maci-protocol/domainobjs";
|
|
2
2
|
import type { Signer } from "ethers";
|
|
3
3
|
/**
|
|
4
4
|
* Run both format check and size check on a salt value
|
|
@@ -12,5 +12,5 @@ export declare const validateSalt: (salt: bigint) => boolean;
|
|
|
12
12
|
* @param signer - the signer to use
|
|
13
13
|
* @returns the coordinator public key
|
|
14
14
|
*/
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const getCoordinatorPublicKey: (pollAddress: string, signer: Signer) => Promise<PublicKey>;
|
|
16
16
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/vote/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/vote/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAAkC,CAAC;AAE/E;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAU,aAAa,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,SAAS,CAMpG,CAAC"}
|
package/build/ts/vote/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
3
|
+
exports.getCoordinatorPublicKey = exports.validateSalt = void 0;
|
|
4
|
+
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
5
5
|
const crypto_1 = require("@maci-protocol/crypto");
|
|
6
6
|
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
7
7
|
/**
|
|
@@ -17,10 +17,10 @@ exports.validateSalt = validateSalt;
|
|
|
17
17
|
* @param signer - the signer to use
|
|
18
18
|
* @returns the coordinator public key
|
|
19
19
|
*/
|
|
20
|
-
const
|
|
21
|
-
const pollContract =
|
|
22
|
-
const
|
|
23
|
-
return new domainobjs_1.
|
|
20
|
+
const getCoordinatorPublicKey = async (pollAddress, signer) => {
|
|
21
|
+
const pollContract = typechain_types_1.Poll__factory.connect(pollAddress, signer);
|
|
22
|
+
const coordinatorPublicKey = await pollContract.coordinatorPublicKey();
|
|
23
|
+
return new domainobjs_1.PublicKey([coordinatorPublicKey.x, coordinatorPublicKey.y]);
|
|
24
24
|
};
|
|
25
|
-
exports.
|
|
25
|
+
exports.getCoordinatorPublicKey = getCoordinatorPublicKey;
|
|
26
26
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/vote/utils.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/vote/utils.ts"],"names":[],"mappings":";;;AAAA,8EAAwF;AACxF,kDAAyD;AACzD,0DAAsD;AAItD;;;;GAIG;AACI,MAAM,YAAY,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,GAAG,yBAAgB,CAAC;AAAlE,QAAA,YAAY,gBAAsD;AAE/E;;;;;GAKG;AACI,MAAM,uBAAuB,GAAG,KAAK,EAAE,WAAmB,EAAE,MAAc,EAAsB,EAAE;IACvG,MAAM,YAAY,GAAG,+BAAW,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE9D,MAAM,oBAAoB,GAAG,MAAM,YAAY,CAAC,oBAAoB,EAAE,CAAC;IAEvE,OAAO,IAAI,sBAAS,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC,CAAC;AANW,QAAA,uBAAuB,2BAMlC"}
|