@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,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publishBatch = exports.publish = void 0;
|
|
4
|
+
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
5
|
+
const poll_1 = require("../poll");
|
|
6
|
+
const generate_1 = require("./generate");
|
|
7
|
+
const submit_1 = require("./submit");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
/**
|
|
10
|
+
* Publish a new message to a MACI Poll contract
|
|
11
|
+
* @param {IPublishArgs} args - The arguments for the publish command
|
|
12
|
+
* @returns {IPublishData} The ephemeral private key used to encrypt the message, transaction hash
|
|
13
|
+
*/
|
|
14
|
+
const publish = async ({ pubkey, stateIndex, voteOptionIndex, nonce, pollId, newVoteWeight, maciAddress, salt, privateKey, signer, }) => {
|
|
15
|
+
if (!domainobjs_1.PubKey.isValidSerializedPubKey(pubkey)) {
|
|
16
|
+
throw new Error("Invalid MACI public key");
|
|
17
|
+
}
|
|
18
|
+
if (!domainobjs_1.PrivKey.isValidSerializedPrivKey(privateKey)) {
|
|
19
|
+
throw new Error("Invalid MACI private key");
|
|
20
|
+
}
|
|
21
|
+
const { poll: pollContract } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
22
|
+
const votePubKey = domainobjs_1.PubKey.deserialize(pubkey);
|
|
23
|
+
const privKey = domainobjs_1.PrivKey.deserialize(privateKey);
|
|
24
|
+
const [maxVoteOption, pollAddress] = await Promise.all([pollContract.voteOptions(), pollContract.getAddress()]);
|
|
25
|
+
const coordinatorPubKey = await (0, utils_1.getCoordinatorPubKey)(pollAddress, signer);
|
|
26
|
+
const vote = (0, generate_1.generateVote)({
|
|
27
|
+
pollId,
|
|
28
|
+
voteOptionIndex,
|
|
29
|
+
salt,
|
|
30
|
+
nonce,
|
|
31
|
+
privateKey: privKey,
|
|
32
|
+
stateIndex,
|
|
33
|
+
voteWeight: newVoteWeight,
|
|
34
|
+
coordinatorPubKey,
|
|
35
|
+
maxVoteOption,
|
|
36
|
+
newPubKey: votePubKey,
|
|
37
|
+
});
|
|
38
|
+
const txHash = await (0, submit_1.submitVote)({ pollAddress, vote, signer });
|
|
39
|
+
return {
|
|
40
|
+
hash: txHash,
|
|
41
|
+
encryptedMessage: vote.message,
|
|
42
|
+
privateKey: vote.ephemeralKeypair.privKey.serialize(),
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
exports.publish = publish;
|
|
46
|
+
/**
|
|
47
|
+
* Batch publish new messages to a MACI Poll contract
|
|
48
|
+
* @param {IPublishBatchArgs} args - The arguments for the publish command
|
|
49
|
+
* @returns {IPublishBatchData} The ephemeral private key used to encrypt the message, transaction hash
|
|
50
|
+
*/
|
|
51
|
+
const publishBatch = async ({ messages, pollId, maciAddress, publicKey, privateKey, signer, }) => {
|
|
52
|
+
if (!domainobjs_1.PubKey.isValidSerializedPubKey(publicKey)) {
|
|
53
|
+
throw new Error("Invalid MACI public key");
|
|
54
|
+
}
|
|
55
|
+
if (!domainobjs_1.PrivKey.isValidSerializedPrivKey(privateKey)) {
|
|
56
|
+
throw new Error("Invalid MACI private key");
|
|
57
|
+
}
|
|
58
|
+
const { poll: pollContract } = await (0, poll_1.getPollContracts)({ maciAddress, pollId, signer });
|
|
59
|
+
const userMaciPubKey = domainobjs_1.PubKey.deserialize(publicKey);
|
|
60
|
+
const userMaciPrivKey = domainobjs_1.PrivKey.deserialize(privateKey);
|
|
61
|
+
const [maxVoteOption, pollAddress] = await Promise.all([pollContract.voteOptions(), pollContract.getAddress()]);
|
|
62
|
+
const coordinatorPubKey = await (0, utils_1.getCoordinatorPubKey)(pollAddress, signer);
|
|
63
|
+
// validate the vote options index against the max leaf index on-chain
|
|
64
|
+
const votes = messages.map(({ stateIndex, voteOptionIndex, salt, nonce, newVoteWeight }) => (0, generate_1.generateVote)({
|
|
65
|
+
pollId,
|
|
66
|
+
voteOptionIndex,
|
|
67
|
+
nonce,
|
|
68
|
+
privateKey: userMaciPrivKey,
|
|
69
|
+
stateIndex,
|
|
70
|
+
maxVoteOption: BigInt(maxVoteOption),
|
|
71
|
+
salt,
|
|
72
|
+
voteWeight: newVoteWeight,
|
|
73
|
+
coordinatorPubKey,
|
|
74
|
+
newPubKey: userMaciPubKey,
|
|
75
|
+
}));
|
|
76
|
+
const txHash = await (0, submit_1.submitVoteBatch)({
|
|
77
|
+
pollAddress,
|
|
78
|
+
votes: votes.reverse(),
|
|
79
|
+
signer,
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
hash: txHash,
|
|
83
|
+
encryptedMessages: votes.map((vote) => vote.message),
|
|
84
|
+
privateKeys: votes.map((vote) => vote.ephemeralKeypair.privKey.serialize()),
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
exports.publishBatch = publishBatch;
|
|
88
|
+
//# sourceMappingURL=publish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../ts/vote/publish.ts"],"names":[],"mappings":";;;AAAA,0DAA4D;AAI5D,kCAA2C;AAE3C,yCAA0C;AAC1C,qCAAuD;AACvD,mCAA+C;AAE/C;;;;GAIG;AACI,MAAM,OAAO,GAAG,KAAK,EAAE,EAC5B,MAAM,EACN,UAAU,EACV,eAAe,EACf,KAAK,EACL,MAAM,EACN,aAAa,EACb,WAAW,EACX,IAAI,EACJ,UAAU,EACV,MAAM,GACO,EAAyB,EAAE;IACxC,IAAI,CAAC,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QACpC,IAAI;QACJ,UAAU,EAAE,aAAa;QACzB,iBAAiB;QACjB,SAAS,EAAE,cAAc;KAC1B,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,OAAO,CAAC,SAAS,EAAE,CAAC;KAC5E,CAAC;AACJ,CAAC,CAAC;AAnDW,QAAA,YAAY,gBAmDvB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ISubmitVoteArgs, ISubmitVoteBatchArgs } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Submit a vote
|
|
4
|
+
* @param args - The arguments for the vote
|
|
5
|
+
*/
|
|
6
|
+
export declare const submitVote: ({ pollAddress, vote, signer }: ISubmitVoteArgs) => Promise<string | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Submit a batch of votes
|
|
9
|
+
* @param args - The arguments for the vote
|
|
10
|
+
* @dev Please ensure that the votes are in reverse order (by nonce) to be processed correctly
|
|
11
|
+
*/
|
|
12
|
+
export declare const submitVoteBatch: ({ pollAddress, votes, signer, }: ISubmitVoteBatchArgs) => Promise<string | undefined>;
|
|
13
|
+
//# sourceMappingURL=submit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../../../ts/vote/submit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAU,+BAA+B,eAAe,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAY3G,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAU,iCAInC,oBAAoB,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAenD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submitVoteBatch = exports.submitVote = void 0;
|
|
4
|
+
const contracts_1 = require("@maci-protocol/contracts");
|
|
5
|
+
/**
|
|
6
|
+
* Submit a vote
|
|
7
|
+
* @param args - The arguments for the vote
|
|
8
|
+
*/
|
|
9
|
+
const submitVote = async ({ pollAddress, vote, signer }) => {
|
|
10
|
+
const pollContract = contracts_1.Poll__factory.connect(pollAddress, signer);
|
|
11
|
+
const receipt = await pollContract
|
|
12
|
+
.publishMessage(vote.message, vote.ephemeralKeypair.pubKey.asContractParam())
|
|
13
|
+
.then((tx) => tx.wait());
|
|
14
|
+
if (receipt?.status === 0) {
|
|
15
|
+
throw new Error("Failed to submit the vote");
|
|
16
|
+
}
|
|
17
|
+
return receipt?.hash;
|
|
18
|
+
};
|
|
19
|
+
exports.submitVote = submitVote;
|
|
20
|
+
/**
|
|
21
|
+
* Submit a batch of votes
|
|
22
|
+
* @param args - The arguments for the vote
|
|
23
|
+
* @dev Please ensure that the votes are in reverse order (by nonce) to be processed correctly
|
|
24
|
+
*/
|
|
25
|
+
const submitVoteBatch = async ({ pollAddress, votes, signer, }) => {
|
|
26
|
+
const pollContract = contracts_1.Poll__factory.connect(pollAddress, signer);
|
|
27
|
+
const receipt = await pollContract
|
|
28
|
+
.publishMessageBatch(votes.map((vote) => vote.message), votes.map((vote) => vote.ephemeralKeypair.pubKey.asContractParam()))
|
|
29
|
+
.then((tx) => tx.wait());
|
|
30
|
+
if (receipt?.status === 0) {
|
|
31
|
+
throw new Error("Failed to submit the batch of votes");
|
|
32
|
+
}
|
|
33
|
+
return receipt?.hash;
|
|
34
|
+
};
|
|
35
|
+
exports.submitVoteBatch = submitVoteBatch;
|
|
36
|
+
//# sourceMappingURL=submit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submit.js","sourceRoot":"","sources":["../../../ts/vote/submit.ts"],"names":[],"mappings":";;;AAAA,wDAAwE;AAIxE;;;GAGG;AACI,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAmB,EAA+B,EAAE;IAC9G,MAAM,YAAY,GAAG,yBAAW,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE9D,MAAM,OAAO,GAAG,MAAM,YAAY;SAC/B,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;SAC5E,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;IAE3B,IAAI,OAAO,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,OAAO,EAAE,IAAI,CAAC;AACvB,CAAC,CAAC;AAZW,QAAA,UAAU,cAYrB;AAEF;;;;GAIG;AACI,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,WAAW,EACX,KAAK,EACL,MAAM,GACe,EAA+B,EAAE;IACtD,MAAM,YAAY,GAAG,yBAAW,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE9D,MAAM,OAAO,GAAG,MAAM,YAAY;SAC/B,mBAAmB,CAClB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EACjC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CACpE;SACA,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;IAE3B,IAAI,OAAO,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,OAAO,EAAE,IAAI,CAAC;AACvB,CAAC,CAAC;AAnBW,QAAA,eAAe,mBAmB1B"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import type { IMessageContractParams, Keypair, Message, PrivKey, PubKey } from "@maci-protocol/domainobjs";
|
|
2
|
+
import type { Signer } from "ethers";
|
|
3
|
+
/**
|
|
4
|
+
* Interface for the arguments for the generateVote function
|
|
5
|
+
*/
|
|
6
|
+
export interface IGenerateVoteArgs {
|
|
7
|
+
/**
|
|
8
|
+
* The poll id
|
|
9
|
+
*/
|
|
10
|
+
pollId: bigint;
|
|
11
|
+
/**
|
|
12
|
+
* The index of the vote option
|
|
13
|
+
*/
|
|
14
|
+
voteOptionIndex: bigint;
|
|
15
|
+
/**
|
|
16
|
+
* The salt for the vote
|
|
17
|
+
*/
|
|
18
|
+
salt?: bigint;
|
|
19
|
+
/**
|
|
20
|
+
* The nonce for the vote
|
|
21
|
+
*/
|
|
22
|
+
nonce: bigint;
|
|
23
|
+
/**
|
|
24
|
+
* The private key for the vote
|
|
25
|
+
*/
|
|
26
|
+
privateKey: PrivKey;
|
|
27
|
+
/**
|
|
28
|
+
* The state index for the vote
|
|
29
|
+
*/
|
|
30
|
+
stateIndex: bigint;
|
|
31
|
+
/**
|
|
32
|
+
* The weight of the vote
|
|
33
|
+
*/
|
|
34
|
+
voteWeight: bigint;
|
|
35
|
+
/**
|
|
36
|
+
* The coordinator public key
|
|
37
|
+
*/
|
|
38
|
+
coordinatorPubKey: PubKey;
|
|
39
|
+
/**
|
|
40
|
+
* The largest vote option index
|
|
41
|
+
*/
|
|
42
|
+
maxVoteOption: bigint;
|
|
43
|
+
/**
|
|
44
|
+
* Ephemeral keypair
|
|
45
|
+
*/
|
|
46
|
+
ephemeralKeypair?: Keypair;
|
|
47
|
+
/**
|
|
48
|
+
* New key in case of key change message
|
|
49
|
+
*/
|
|
50
|
+
newPubKey?: PubKey;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Interface for the vote object
|
|
54
|
+
*/
|
|
55
|
+
export interface IVote {
|
|
56
|
+
/**
|
|
57
|
+
* The message to be sent to the contract
|
|
58
|
+
*/
|
|
59
|
+
message: Message;
|
|
60
|
+
/**
|
|
61
|
+
* The ephemeral keypair used to generate the shared key for encrypting the message
|
|
62
|
+
*/
|
|
63
|
+
ephemeralKeypair: Keypair;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Interface for the submitVote function
|
|
67
|
+
*/
|
|
68
|
+
export interface ISubmitVoteArgs {
|
|
69
|
+
/**
|
|
70
|
+
* The address of the poll
|
|
71
|
+
*/
|
|
72
|
+
pollAddress: string;
|
|
73
|
+
/**
|
|
74
|
+
* The vote to submit
|
|
75
|
+
*/
|
|
76
|
+
vote: IVote;
|
|
77
|
+
/**
|
|
78
|
+
* The signer to use
|
|
79
|
+
*/
|
|
80
|
+
signer: Signer;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Interface for the submitVoteBatch function
|
|
84
|
+
*/
|
|
85
|
+
export interface ISubmitVoteBatchArgs {
|
|
86
|
+
/**
|
|
87
|
+
* The address of the poll
|
|
88
|
+
*/
|
|
89
|
+
pollAddress: string;
|
|
90
|
+
/**
|
|
91
|
+
* The votes to submit
|
|
92
|
+
* @note The messages must be in reverse order (by nonce) to be processed correctly
|
|
93
|
+
*/
|
|
94
|
+
votes: IVote[];
|
|
95
|
+
/**
|
|
96
|
+
* The signer to use
|
|
97
|
+
*/
|
|
98
|
+
signer: Signer;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Interface for the arguments to the batch publish command
|
|
102
|
+
*/
|
|
103
|
+
export interface IPublishBatchArgs {
|
|
104
|
+
/**
|
|
105
|
+
* User messages
|
|
106
|
+
*/
|
|
107
|
+
messages: IPublishMessage[];
|
|
108
|
+
/**
|
|
109
|
+
* The id of the poll
|
|
110
|
+
*/
|
|
111
|
+
pollId: bigint;
|
|
112
|
+
/**
|
|
113
|
+
* The address of the MACI contract
|
|
114
|
+
*/
|
|
115
|
+
maciAddress: string;
|
|
116
|
+
/**
|
|
117
|
+
* The public key of the user
|
|
118
|
+
*/
|
|
119
|
+
publicKey: string;
|
|
120
|
+
/**
|
|
121
|
+
* The private key of the user
|
|
122
|
+
*/
|
|
123
|
+
privateKey: string;
|
|
124
|
+
/**
|
|
125
|
+
* A signer object
|
|
126
|
+
*/
|
|
127
|
+
signer: Signer;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Interface that represents user publish message
|
|
131
|
+
*/
|
|
132
|
+
export interface IPublishMessage {
|
|
133
|
+
/**
|
|
134
|
+
* The index of the state leaf
|
|
135
|
+
*/
|
|
136
|
+
stateIndex: bigint;
|
|
137
|
+
/**
|
|
138
|
+
* The index of the vote option
|
|
139
|
+
*/
|
|
140
|
+
voteOptionIndex: bigint;
|
|
141
|
+
/**
|
|
142
|
+
* The nonce of the message
|
|
143
|
+
*/
|
|
144
|
+
nonce: bigint;
|
|
145
|
+
/**
|
|
146
|
+
* The new vote weight
|
|
147
|
+
*/
|
|
148
|
+
newVoteWeight: bigint;
|
|
149
|
+
/**
|
|
150
|
+
* The salt of the message
|
|
151
|
+
*/
|
|
152
|
+
salt?: bigint;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Interface that represents publish batch return data
|
|
156
|
+
*/
|
|
157
|
+
export interface IPublishBatchData {
|
|
158
|
+
/**
|
|
159
|
+
* Publish transaction hash
|
|
160
|
+
*/
|
|
161
|
+
hash: string;
|
|
162
|
+
/**
|
|
163
|
+
* Encrypted publish messages
|
|
164
|
+
*/
|
|
165
|
+
encryptedMessages: IMessageContractParams[];
|
|
166
|
+
/**
|
|
167
|
+
* Encryption private keys
|
|
168
|
+
*/
|
|
169
|
+
privateKeys: string[];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Interface for the arguments to the publish command
|
|
173
|
+
*/
|
|
174
|
+
export interface IPublishArgs extends IPublishMessage {
|
|
175
|
+
/**
|
|
176
|
+
* The poll public key
|
|
177
|
+
*/
|
|
178
|
+
pubkey: string;
|
|
179
|
+
/**
|
|
180
|
+
* The poll private key
|
|
181
|
+
*/
|
|
182
|
+
privateKey: string;
|
|
183
|
+
/**
|
|
184
|
+
* The address of the MACI contract
|
|
185
|
+
*/
|
|
186
|
+
maciAddress: string;
|
|
187
|
+
/**
|
|
188
|
+
* The id of the poll
|
|
189
|
+
*/
|
|
190
|
+
pollId: bigint;
|
|
191
|
+
/**
|
|
192
|
+
* A signer object
|
|
193
|
+
*/
|
|
194
|
+
signer: Signer;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Interface that represents return data type for publish message
|
|
198
|
+
*/
|
|
199
|
+
export interface IPublishData {
|
|
200
|
+
/**
|
|
201
|
+
* The ephemeral private key used to encrypt the message
|
|
202
|
+
*/
|
|
203
|
+
privateKey: string;
|
|
204
|
+
/**
|
|
205
|
+
* Encrypted publish message
|
|
206
|
+
*/
|
|
207
|
+
encryptedMessage: IMessageContractParams;
|
|
208
|
+
/**
|
|
209
|
+
* Publish transaction hash
|
|
210
|
+
*/
|
|
211
|
+
hash: string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Invalidate votes args
|
|
215
|
+
*/
|
|
216
|
+
export interface IInvalidateVotesArgs {
|
|
217
|
+
/**
|
|
218
|
+
* MACI contract address
|
|
219
|
+
*/
|
|
220
|
+
maciAddress: string;
|
|
221
|
+
/**
|
|
222
|
+
* Poll id
|
|
223
|
+
*/
|
|
224
|
+
pollId: bigint;
|
|
225
|
+
/**
|
|
226
|
+
* Signer
|
|
227
|
+
*/
|
|
228
|
+
signer: Signer;
|
|
229
|
+
/**
|
|
230
|
+
* MACI private key
|
|
231
|
+
*/
|
|
232
|
+
maciPrivateKey: PrivKey;
|
|
233
|
+
/**
|
|
234
|
+
* State index
|
|
235
|
+
*/
|
|
236
|
+
stateIndex: bigint;
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAC3G,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,OAAO,CAAC;IAEpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;CAC3B;A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C;IAEnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,UAAU,EAAE,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,OAAO,CAAC;IAExB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/vote/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PubKey } from "@maci-protocol/domainobjs";
|
|
2
|
+
import type { Signer } from "ethers";
|
|
3
|
+
/**
|
|
4
|
+
* Run both format check and size check on a salt value
|
|
5
|
+
* @param salt the salt to validate
|
|
6
|
+
* @returns whether it is valid or not
|
|
7
|
+
*/
|
|
8
|
+
export declare const validateSalt: (salt: bigint) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Get the coordinator public key for a poll
|
|
11
|
+
* @param pollAddress - the address of the poll
|
|
12
|
+
* @param signer - the signer to use
|
|
13
|
+
* @returns the coordinator public key
|
|
14
|
+
*/
|
|
15
|
+
export declare const getCoordinatorPubKey: (pollAddress: string, signer: Signer) => Promise<PubKey>;
|
|
16
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/vote/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD,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,oBAAoB,GAAU,aAAa,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,MAAM,CAM9F,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCoordinatorPubKey = exports.validateSalt = void 0;
|
|
4
|
+
const contracts_1 = require("@maci-protocol/contracts");
|
|
5
|
+
const crypto_1 = require("@maci-protocol/crypto");
|
|
6
|
+
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
7
|
+
/**
|
|
8
|
+
* Run both format check and size check on a salt value
|
|
9
|
+
* @param salt the salt to validate
|
|
10
|
+
* @returns whether it is valid or not
|
|
11
|
+
*/
|
|
12
|
+
const validateSalt = (salt) => salt < crypto_1.SNARK_FIELD_SIZE;
|
|
13
|
+
exports.validateSalt = validateSalt;
|
|
14
|
+
/**
|
|
15
|
+
* Get the coordinator public key for a poll
|
|
16
|
+
* @param pollAddress - the address of the poll
|
|
17
|
+
* @param signer - the signer to use
|
|
18
|
+
* @returns the coordinator public key
|
|
19
|
+
*/
|
|
20
|
+
const getCoordinatorPubKey = async (pollAddress, signer) => {
|
|
21
|
+
const pollContract = contracts_1.Poll__factory.connect(pollAddress, signer);
|
|
22
|
+
const coordinatorPubKey = await pollContract.coordinatorPubKey();
|
|
23
|
+
return new domainobjs_1.PubKey([coordinatorPubKey.x, coordinatorPubKey.y]);
|
|
24
|
+
};
|
|
25
|
+
exports.getCoordinatorPubKey = getCoordinatorPubKey;
|
|
26
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/vote/utils.ts"],"names":[],"mappings":";;;AAAA,wDAAwE;AACxE,kDAAyD;AACzD,0DAAmD;AAInD;;;;GAIG;AACI,MAAM,YAAY,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,GAAG,yBAAgB,CAAC;AAAlE,QAAA,YAAY,gBAAsD;AAE/E;;;;;GAKG;AACI,MAAM,oBAAoB,GAAG,KAAK,EAAE,WAAmB,EAAE,MAAc,EAAmB,EAAE;IACjG,MAAM,YAAY,GAAG,yBAAW,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE9D,MAAM,iBAAiB,GAAG,MAAM,YAAY,CAAC,iBAAiB,EAAE,CAAC;IAEjE,OAAO,IAAI,mBAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC;AANW,QAAA,oBAAoB,wBAM/B"}
|