@maci-protocol/sdk 0.0.0-ci.185b643

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.
Files changed (310) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/LICENSE +22 -0
  3. package/README.md +12 -0
  4. package/build/package.json +57 -0
  5. package/build/ts/browser/index.d.ts +13 -0
  6. package/build/ts/browser/index.d.ts.map +1 -0
  7. package/build/ts/browser/index.js +34 -0
  8. package/build/ts/browser/index.js.map +1 -0
  9. package/build/ts/browser/joinPoll.d.ts +8 -0
  10. package/build/ts/browser/joinPoll.d.ts.map +1 -0
  11. package/build/ts/browser/joinPoll.js +84 -0
  12. package/build/ts/browser/joinPoll.js.map +1 -0
  13. package/build/ts/browser/utils.d.ts +18 -0
  14. package/build/ts/browser/utils.d.ts.map +1 -0
  15. package/build/ts/browser/utils.js +37 -0
  16. package/build/ts/browser/utils.js.map +1 -0
  17. package/build/ts/deploy/index.d.ts +6 -0
  18. package/build/ts/deploy/index.d.ts.map +1 -0
  19. package/build/ts/deploy/index.js +12 -0
  20. package/build/ts/deploy/index.js.map +1 -0
  21. package/build/ts/deploy/maci.d.ts +8 -0
  22. package/build/ts/deploy/maci.d.ts.map +1 -0
  23. package/build/ts/deploy/maci.js +87 -0
  24. package/build/ts/deploy/maci.js.map +1 -0
  25. package/build/ts/deploy/poll.d.ts +8 -0
  26. package/build/ts/deploy/poll.d.ts.map +1 -0
  27. package/build/ts/deploy/poll.js +114 -0
  28. package/build/ts/deploy/poll.js.map +1 -0
  29. package/build/ts/deploy/types.d.ts +216 -0
  30. package/build/ts/deploy/types.d.ts.map +1 -0
  31. package/build/ts/deploy/types.js +3 -0
  32. package/build/ts/deploy/types.js.map +1 -0
  33. package/build/ts/deploy/utils.d.ts +11 -0
  34. package/build/ts/deploy/utils.d.ts.map +1 -0
  35. package/build/ts/deploy/utils.js +22 -0
  36. package/build/ts/deploy/utils.js.map +1 -0
  37. package/build/ts/deploy/vkRegistry.d.ts +7 -0
  38. package/build/ts/deploy/vkRegistry.d.ts.map +1 -0
  39. package/build/ts/deploy/vkRegistry.js +14 -0
  40. package/build/ts/deploy/vkRegistry.js.map +1 -0
  41. package/build/ts/index.d.ts +16 -0
  42. package/build/ts/index.d.ts.map +1 -0
  43. package/build/ts/index.js +82 -0
  44. package/build/ts/index.js.map +1 -0
  45. package/build/ts/maci/index.d.ts +6 -0
  46. package/build/ts/maci/index.d.ts.map +1 -0
  47. package/build/ts/maci/index.js +17 -0
  48. package/build/ts/maci/index.js.map +1 -0
  49. package/build/ts/maci/merge.d.ts +9 -0
  50. package/build/ts/maci/merge.d.ts.map +1 -0
  51. package/build/ts/maci/merge.js +29 -0
  52. package/build/ts/maci/merge.js.map +1 -0
  53. package/build/ts/maci/policy.d.ts +53 -0
  54. package/build/ts/maci/policy.d.ts.map +1 -0
  55. package/build/ts/maci/policy.js +166 -0
  56. package/build/ts/maci/policy.js.map +1 -0
  57. package/build/ts/maci/state.d.ts +8 -0
  58. package/build/ts/maci/state.d.ts.map +1 -0
  59. package/build/ts/maci/state.js +82 -0
  60. package/build/ts/maci/state.js.map +1 -0
  61. package/build/ts/maci/types.d.ts +208 -0
  62. package/build/ts/maci/types.d.ts.map +1 -0
  63. package/build/ts/maci/types.js +20 -0
  64. package/build/ts/maci/types.js.map +1 -0
  65. package/build/ts/maciKeys/__tests__/keypair.test.d.ts +2 -0
  66. package/build/ts/maciKeys/__tests__/keypair.test.d.ts.map +1 -0
  67. package/build/ts/maciKeys/__tests__/keypair.test.js +24 -0
  68. package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -0
  69. package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts +2 -0
  70. package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts.map +1 -0
  71. package/build/ts/maciKeys/__tests__/publicKeys.test.js +22 -0
  72. package/build/ts/maciKeys/__tests__/publicKeys.test.js.map +1 -0
  73. package/build/ts/maciKeys/index.d.ts +4 -0
  74. package/build/ts/maciKeys/index.d.ts.map +1 -0
  75. package/build/ts/maciKeys/index.js +8 -0
  76. package/build/ts/maciKeys/index.js.map +1 -0
  77. package/build/ts/maciKeys/keypair.d.ts +9 -0
  78. package/build/ts/maciKeys/keypair.d.ts.map +1 -0
  79. package/build/ts/maciKeys/keypair.js +20 -0
  80. package/build/ts/maciKeys/keypair.js.map +1 -0
  81. package/build/ts/maciKeys/publicKeys.d.ts +8 -0
  82. package/build/ts/maciKeys/publicKeys.d.ts.map +1 -0
  83. package/build/ts/maciKeys/publicKeys.js +23 -0
  84. package/build/ts/maciKeys/publicKeys.js.map +1 -0
  85. package/build/ts/maciKeys/types.d.ts +23 -0
  86. package/build/ts/maciKeys/types.d.ts.map +1 -0
  87. package/build/ts/maciKeys/types.js +3 -0
  88. package/build/ts/maciKeys/types.js.map +1 -0
  89. package/build/ts/poll/index.d.ts +4 -0
  90. package/build/ts/poll/index.d.ts.map +1 -0
  91. package/build/ts/poll/index.js +9 -0
  92. package/build/ts/poll/index.js.map +1 -0
  93. package/build/ts/poll/poll.d.ts +14 -0
  94. package/build/ts/poll/poll.d.ts.map +1 -0
  95. package/build/ts/poll/poll.js +62 -0
  96. package/build/ts/poll/poll.js.map +1 -0
  97. package/build/ts/poll/types.d.ts +151 -0
  98. package/build/ts/poll/types.d.ts.map +1 -0
  99. package/build/ts/poll/types.js +3 -0
  100. package/build/ts/poll/types.js.map +1 -0
  101. package/build/ts/poll/utils.d.ts +9 -0
  102. package/build/ts/poll/utils.d.ts.map +1 -0
  103. package/build/ts/poll/utils.js +43 -0
  104. package/build/ts/poll/utils.js.map +1 -0
  105. package/build/ts/proof/__tests__/download.test.d.ts +2 -0
  106. package/build/ts/proof/__tests__/download.test.d.ts.map +1 -0
  107. package/build/ts/proof/__tests__/download.test.js +50 -0
  108. package/build/ts/proof/__tests__/download.test.js.map +1 -0
  109. package/build/ts/proof/constants.d.ts +17 -0
  110. package/build/ts/proof/constants.d.ts.map +1 -0
  111. package/build/ts/proof/constants.js +20 -0
  112. package/build/ts/proof/constants.js.map +1 -0
  113. package/build/ts/proof/download.d.ts +9 -0
  114. package/build/ts/proof/download.d.ts.map +1 -0
  115. package/build/ts/proof/download.js +49 -0
  116. package/build/ts/proof/download.js.map +1 -0
  117. package/build/ts/proof/generate.d.ts +8 -0
  118. package/build/ts/proof/generate.d.ts.map +1 -0
  119. package/build/ts/proof/generate.js +127 -0
  120. package/build/ts/proof/generate.js.map +1 -0
  121. package/build/ts/proof/index.d.ts +4 -0
  122. package/build/ts/proof/index.d.ts.map +1 -0
  123. package/build/ts/proof/index.js +8 -0
  124. package/build/ts/proof/index.js.map +1 -0
  125. package/build/ts/proof/prove.d.ts +8 -0
  126. package/build/ts/proof/prove.d.ts.map +1 -0
  127. package/build/ts/proof/prove.js +81 -0
  128. package/build/ts/proof/prove.js.map +1 -0
  129. package/build/ts/proof/types.d.ts +175 -0
  130. package/build/ts/proof/types.d.ts.map +1 -0
  131. package/build/ts/proof/types.js +3 -0
  132. package/build/ts/proof/types.js.map +1 -0
  133. package/build/ts/relayer/__tests__/messages.test.d.ts +2 -0
  134. package/build/ts/relayer/__tests__/messages.test.d.ts.map +1 -0
  135. package/build/ts/relayer/__tests__/messages.test.js +76 -0
  136. package/build/ts/relayer/__tests__/messages.test.js.map +1 -0
  137. package/build/ts/relayer/__tests__/utils.test.d.ts +2 -0
  138. package/build/ts/relayer/__tests__/utils.test.d.ts.map +1 -0
  139. package/build/ts/relayer/__tests__/utils.test.js +73 -0
  140. package/build/ts/relayer/__tests__/utils.test.js.map +1 -0
  141. package/build/ts/relayer/index.d.ts +3 -0
  142. package/build/ts/relayer/index.d.ts.map +1 -0
  143. package/build/ts/relayer/index.js +8 -0
  144. package/build/ts/relayer/index.js.map +1 -0
  145. package/build/ts/relayer/messages.d.ts +23 -0
  146. package/build/ts/relayer/messages.d.ts.map +1 -0
  147. package/build/ts/relayer/messages.js +66 -0
  148. package/build/ts/relayer/messages.js.map +1 -0
  149. package/build/ts/relayer/types.d.ts +168 -0
  150. package/build/ts/relayer/types.d.ts.map +1 -0
  151. package/build/ts/relayer/types.js +3 -0
  152. package/build/ts/relayer/types.js.map +1 -0
  153. package/build/ts/relayer/utils.d.ts +12 -0
  154. package/build/ts/relayer/utils.d.ts.map +1 -0
  155. package/build/ts/relayer/utils.js +37 -0
  156. package/build/ts/relayer/utils.js.map +1 -0
  157. package/build/ts/tally/commitments.d.ts +9 -0
  158. package/build/ts/tally/commitments.d.ts.map +1 -0
  159. package/build/ts/tally/commitments.js +42 -0
  160. package/build/ts/tally/commitments.js.map +1 -0
  161. package/build/ts/tally/index.d.ts +4 -0
  162. package/build/ts/tally/index.d.ts.map +1 -0
  163. package/build/ts/tally/index.js +8 -0
  164. package/build/ts/tally/index.js.map +1 -0
  165. package/build/ts/tally/types.d.ts +179 -0
  166. package/build/ts/tally/types.d.ts.map +1 -0
  167. package/build/ts/tally/types.js +3 -0
  168. package/build/ts/tally/types.js.map +1 -0
  169. package/build/ts/tally/utils.d.ts +24 -0
  170. package/build/ts/tally/utils.d.ts.map +1 -0
  171. package/build/ts/tally/utils.js +50 -0
  172. package/build/ts/tally/utils.js.map +1 -0
  173. package/build/ts/tally/verification.d.ts +7 -0
  174. package/build/ts/tally/verification.d.ts.map +1 -0
  175. package/build/ts/tally/verification.js +62 -0
  176. package/build/ts/tally/verification.js.map +1 -0
  177. package/build/ts/trees/index.d.ts +3 -0
  178. package/build/ts/trees/index.d.ts.map +1 -0
  179. package/build/ts/trees/index.js +6 -0
  180. package/build/ts/trees/index.js.map +1 -0
  181. package/build/ts/trees/stateTree.d.ts +13 -0
  182. package/build/ts/trees/stateTree.d.ts.map +1 -0
  183. package/build/ts/trees/stateTree.js +56 -0
  184. package/build/ts/trees/stateTree.js.map +1 -0
  185. package/build/ts/trees/types.d.ts +46 -0
  186. package/build/ts/trees/types.d.ts.map +1 -0
  187. package/build/ts/trees/types.js +3 -0
  188. package/build/ts/trees/types.js.map +1 -0
  189. package/build/ts/user/index.d.ts +5 -0
  190. package/build/ts/user/index.d.ts.map +1 -0
  191. package/build/ts/user/index.js +13 -0
  192. package/build/ts/user/index.js.map +1 -0
  193. package/build/ts/user/joinPoll.d.ts +8 -0
  194. package/build/ts/user/joinPoll.d.ts.map +1 -0
  195. package/build/ts/user/joinPoll.js +84 -0
  196. package/build/ts/user/joinPoll.js.map +1 -0
  197. package/build/ts/user/signup.d.ts +20 -0
  198. package/build/ts/user/signup.d.ts.map +1 -0
  199. package/build/ts/user/signup.js +79 -0
  200. package/build/ts/user/signup.js.map +1 -0
  201. package/build/ts/user/types.d.ts +416 -0
  202. package/build/ts/user/types.d.ts.map +1 -0
  203. package/build/ts/user/types.js +3 -0
  204. package/build/ts/user/types.js.map +1 -0
  205. package/build/ts/user/utils.d.ts +68 -0
  206. package/build/ts/user/utils.d.ts.map +1 -0
  207. package/build/ts/user/utils.js +224 -0
  208. package/build/ts/user/utils.js.map +1 -0
  209. package/build/ts/utils/cid.d.ts +23 -0
  210. package/build/ts/utils/cid.d.ts.map +1 -0
  211. package/build/ts/utils/cid.js +72 -0
  212. package/build/ts/utils/cid.js.map +1 -0
  213. package/build/ts/utils/constants.d.ts +2 -0
  214. package/build/ts/utils/constants.d.ts.map +1 -0
  215. package/build/ts/utils/constants.js +5 -0
  216. package/build/ts/utils/constants.js.map +1 -0
  217. package/build/ts/utils/contracts.d.ts +15 -0
  218. package/build/ts/utils/contracts.d.ts.map +1 -0
  219. package/build/ts/utils/contracts.js +26 -0
  220. package/build/ts/utils/contracts.js.map +1 -0
  221. package/build/ts/utils/files.d.ts +9 -0
  222. package/build/ts/utils/files.d.ts.map +1 -0
  223. package/build/ts/utils/files.js +20 -0
  224. package/build/ts/utils/files.js.map +1 -0
  225. package/build/ts/utils/formatting.d.ts +8 -0
  226. package/build/ts/utils/formatting.d.ts.map +1 -0
  227. package/build/ts/utils/formatting.js +11 -0
  228. package/build/ts/utils/formatting.js.map +1 -0
  229. package/build/ts/utils/fundWallet.d.ts +7 -0
  230. package/build/ts/utils/fundWallet.d.ts.map +1 -0
  231. package/build/ts/utils/fundWallet.js +20 -0
  232. package/build/ts/utils/fundWallet.js.map +1 -0
  233. package/build/ts/utils/index.d.ts +12 -0
  234. package/build/ts/utils/index.d.ts.map +1 -0
  235. package/build/ts/utils/index.js +28 -0
  236. package/build/ts/utils/index.js.map +1 -0
  237. package/build/ts/utils/params.d.ts +7 -0
  238. package/build/ts/utils/params.d.ts.map +1 -0
  239. package/build/ts/utils/params.js +19 -0
  240. package/build/ts/utils/params.js.map +1 -0
  241. package/build/ts/utils/proofs.d.ts +13 -0
  242. package/build/ts/utils/proofs.d.ts.map +1 -0
  243. package/build/ts/utils/proofs.js +41 -0
  244. package/build/ts/utils/proofs.js.map +1 -0
  245. package/build/ts/utils/timeTravel.d.ts +7 -0
  246. package/build/ts/utils/timeTravel.d.ts.map +1 -0
  247. package/build/ts/utils/timeTravel.js +14 -0
  248. package/build/ts/utils/timeTravel.js.map +1 -0
  249. package/build/ts/utils/trees.d.ts +13 -0
  250. package/build/ts/utils/trees.d.ts.map +1 -0
  251. package/build/ts/utils/trees.js +30 -0
  252. package/build/ts/utils/trees.js.map +1 -0
  253. package/build/ts/utils/types.d.ts +71 -0
  254. package/build/ts/utils/types.d.ts.map +1 -0
  255. package/build/ts/utils/types.js +3 -0
  256. package/build/ts/utils/types.js.map +1 -0
  257. package/build/ts/utils/utils.d.ts +24 -0
  258. package/build/ts/utils/utils.d.ts.map +1 -0
  259. package/build/ts/utils/utils.js +49 -0
  260. package/build/ts/utils/utils.js.map +1 -0
  261. package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +10 -0
  262. package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -0
  263. package/build/ts/verifyingKeys/checkVerifyingKeys.js +67 -0
  264. package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -0
  265. package/build/ts/verifyingKeys/index.d.ts +5 -0
  266. package/build/ts/verifyingKeys/index.d.ts.map +1 -0
  267. package/build/ts/verifyingKeys/index.js +13 -0
  268. package/build/ts/verifyingKeys/index.js.map +1 -0
  269. package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +7 -0
  270. package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -0
  271. package/build/ts/verifyingKeys/setVerifyingKeys.js +85 -0
  272. package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -0
  273. package/build/ts/verifyingKeys/types.d.ts +235 -0
  274. package/build/ts/verifyingKeys/types.d.ts.map +1 -0
  275. package/build/ts/verifyingKeys/types.js +3 -0
  276. package/build/ts/verifyingKeys/types.js.map +1 -0
  277. package/build/ts/verifyingKeys/utils.d.ts +29 -0
  278. package/build/ts/verifyingKeys/utils.d.ts.map +1 -0
  279. package/build/ts/verifyingKeys/utils.js +103 -0
  280. package/build/ts/verifyingKeys/utils.js.map +1 -0
  281. package/build/ts/vote/generate.d.ts +8 -0
  282. package/build/ts/vote/generate.d.ts.map +1 -0
  283. package/build/ts/vote/generate.js +46 -0
  284. package/build/ts/vote/generate.js.map +1 -0
  285. package/build/ts/vote/index.d.ts +6 -0
  286. package/build/ts/vote/index.d.ts.map +1 -0
  287. package/build/ts/vote/index.js +15 -0
  288. package/build/ts/vote/index.js.map +1 -0
  289. package/build/ts/vote/invalidate.d.ts +13 -0
  290. package/build/ts/vote/invalidate.d.ts.map +1 -0
  291. package/build/ts/vote/invalidate.js +44 -0
  292. package/build/ts/vote/invalidate.js.map +1 -0
  293. package/build/ts/vote/publish.d.ts +14 -0
  294. package/build/ts/vote/publish.d.ts.map +1 -0
  295. package/build/ts/vote/publish.js +88 -0
  296. package/build/ts/vote/publish.js.map +1 -0
  297. package/build/ts/vote/submit.d.ts +13 -0
  298. package/build/ts/vote/submit.d.ts.map +1 -0
  299. package/build/ts/vote/submit.js +36 -0
  300. package/build/ts/vote/submit.js.map +1 -0
  301. package/build/ts/vote/types.d.ts +238 -0
  302. package/build/ts/vote/types.d.ts.map +1 -0
  303. package/build/ts/vote/types.js +3 -0
  304. package/build/ts/vote/types.js.map +1 -0
  305. package/build/ts/vote/utils.d.ts +16 -0
  306. package/build/ts/vote/utils.d.ts.map +1 -0
  307. package/build/ts/vote/utils.js +26 -0
  308. package/build/ts/vote/utils.js.map +1 -0
  309. package/build/tsconfig.build.tsbuildinfo +1 -0
  310. package/package.json +58 -0
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.joinPoll = void 0;
4
+ /* eslint-disable no-underscore-dangle */
5
+ const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
6
+ const crypto_1 = require("@maci-protocol/crypto");
7
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
8
+ const contracts_1 = require("../utils/contracts");
9
+ const proofs_1 = require("../utils/proofs");
10
+ const utils_1 = require("./utils");
11
+ /**
12
+ * Join Poll user to the Poll contract
13
+ * @param {IJoinPollArgs} args - The arguments for the join poll command
14
+ * @returns {IJoinPollData} The poll state index of the joined user and transaction hash
15
+ */
16
+ const joinPoll = async ({ maciAddress, privateKey, stateFile, pollId, signer, startBlock, endBlock, blocksPerBatch, pollJoiningZkey, useWasm, rapidsnark, pollWitgen, pollWasm, sgDataArg, ivcpDataArg, }) => {
17
+ const validContract = await (0, contracts_1.contractExists)(signer.provider, maciAddress);
18
+ if (!validContract) {
19
+ throw new Error("MACI contract does not exist");
20
+ }
21
+ if (!domainobjs_1.PrivKey.isValidSerializedPrivKey(privateKey)) {
22
+ throw new Error("Invalid MACI private key");
23
+ }
24
+ if (pollId < 0) {
25
+ throw new Error("Invalid poll id");
26
+ }
27
+ const userMaciPrivKey = domainobjs_1.PrivKey.deserialize(privateKey);
28
+ const userMaciPubKey = new domainobjs_1.Keypair(userMaciPrivKey).pubKey;
29
+ const nullifier = (0, crypto_1.poseidon)([BigInt(userMaciPrivKey.asCircuitInputs()), pollId]);
30
+ // check if the user has already joined the poll based on the nullifier
31
+ const hasUserJoinedAlready = await (0, utils_1.hasUserJoinedPoll)({
32
+ maciAddress,
33
+ pollId,
34
+ nullifier,
35
+ signer,
36
+ });
37
+ if (hasUserJoinedAlready) {
38
+ throw new Error("User has already joined");
39
+ }
40
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
41
+ const pollContracts = await maciContract.getPoll(pollId);
42
+ const pollContract = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer);
43
+ // get the state index from the MACI contract
44
+ const stateIndex = await maciContract.getStateIndex(userMaciPubKey.hash()).catch(() => -1n);
45
+ let circuitInputs;
46
+ if (stateFile) {
47
+ circuitInputs = await (0, utils_1.getPollJoiningCircuitInputsFromStateFile)({
48
+ stateFile,
49
+ pollId,
50
+ stateIndex,
51
+ userMaciPrivKey,
52
+ });
53
+ }
54
+ else {
55
+ circuitInputs = await (0, utils_1.getPollJoiningCircuitEvents)({
56
+ maciContract,
57
+ stateIndex,
58
+ pollId,
59
+ userMaciPrivKey,
60
+ signer,
61
+ startBlock,
62
+ endBlock,
63
+ blocksPerBatch,
64
+ });
65
+ }
66
+ const currentStateRootIndex = Number.parseInt((await maciContract.numSignUps()).toString(), 10) - 1;
67
+ // generate the proof for this batch
68
+ const proof = await (0, proofs_1.generateAndVerifyProof)(circuitInputs, pollJoiningZkey, useWasm, rapidsnark, pollWitgen, pollWasm);
69
+ // submit the message onchain as well as the encryption public key
70
+ const tx = await pollContract.joinPoll(nullifier, userMaciPubKey.asContractParam(), currentStateRootIndex, proof, sgDataArg, ivcpDataArg);
71
+ const receipt = await tx.wait();
72
+ if (receipt?.status !== 1) {
73
+ throw new Error("Transaction failed");
74
+ }
75
+ const [{ args }] = await pollContract.queryFilter(pollContract.filters.PollJoined, receipt.blockNumber, receipt.blockNumber);
76
+ return {
77
+ pollStateIndex: args._pollStateIndex.toString(),
78
+ voiceCredits: args._voiceCreditBalance.toString(),
79
+ nullifier: nullifier.toString(),
80
+ hash: receipt.hash,
81
+ };
82
+ };
83
+ exports.joinPoll = joinPoll;
84
+ //# sourceMappingURL=joinPoll.js.map
@@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ACpC,SAAS,EACT,cAAc,CAAC,eAAe,EAAE,EAChC,qBAAqB,EACrB,KAAK,EACL,SAAS,EACT,WAAW,CACZ,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;IAEhC,IAAI,OAAO,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,YAAY,CAAC,WAAW,CAC/C,YAAY,CAAC,OAAO,CAAC,UAAU,EAC/B,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,WAAW,CACpB,CAAC;IAEF,OAAO;QACL,cAAc,EAAE,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;QAC/C,YAAY,EAAE,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE;QACjD,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE;QAC/B,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC;AACJ,CAAC,CAAC;AA5GW,QAAA,QAAQ,YA4GnB"}
@@ -0,0 +1,20 @@
1
+ import type { IIsRegisteredUser, ISignupArgs, ISignupData, IRegisteredUserArgs, IHasUserSignedUpArgs } from "./types";
2
+ /**
3
+ * Checks if user is registered with a given public key and get its data
4
+ * @param IRegisteredArgs - The arguments for the check register command
5
+ * @returns whether the user is registered or not and their state index
6
+ */
7
+ export declare const getSignedupUserData: ({ maciAddress, maciPubKey, signer, startBlock, }: IRegisteredUserArgs) => Promise<IIsRegisteredUser>;
8
+ /**
9
+ * Signup a user to the MACI contract
10
+ * @param {SignupArgs} args - The arguments for the signup command
11
+ * @returns {ISignupData} The state index of the user and transaction hash
12
+ */
13
+ export declare const signup: ({ maciPubKey, maciAddress, sgData, signer }: ISignupArgs) => Promise<ISignupData>;
14
+ /**
15
+ * Checks if a user is signed up with a given public key
16
+ * @param {IIsSignedUpArgs} args - The arguments for the is signed up command
17
+ * @returns {boolean} Whether the user is signed up or not
18
+ */
19
+ export declare const hasUserSignedUp: ({ maciAddress, maciPubKey, signer }: IHasUserSignedUpArgs) => Promise<boolean>;
20
+ //# sourceMappingURL=signup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signup.d.ts","sourceRoot":"","sources":["../../../ts/user/signup.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAMtH;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAU,kDAKvC,mBAAmB,KAAG,OAAO,CAAC,iBAAiB,CAiBjD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,MAAM,GAAU,6CAA6C,WAAW,KAAG,OAAO,CAAC,WAAW,CA6C1G,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAU,qCAAqC,oBAAoB,KAAG,OAAO,CAAC,OAAO,CAMhH,CAAC"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasUserSignedUp = exports.signup = exports.getSignedupUserData = void 0;
4
+ const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
5
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
6
+ const ethers_1 = require("ethers");
7
+ const contracts_1 = require("../utils/contracts");
8
+ const utils_1 = require("./utils");
9
+ /**
10
+ * Checks if user is registered with a given public key and get its data
11
+ * @param IRegisteredArgs - The arguments for the check register command
12
+ * @returns whether the user is registered or not and their state index
13
+ */
14
+ const getSignedupUserData = async ({ maciAddress, maciPubKey, signer, startBlock, }) => {
15
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
16
+ const publicKey = domainobjs_1.PubKey.deserialize(maciPubKey);
17
+ const startBlockNumber = startBlock || 0;
18
+ const currentBlock = await signer.provider.getBlockNumber();
19
+ const { stateIndex } = await (0, utils_1.parseSignupEvents)({
20
+ maciContract,
21
+ startBlock: startBlockNumber,
22
+ currentBlock,
23
+ publicKey,
24
+ });
25
+ return {
26
+ isRegistered: stateIndex !== undefined,
27
+ stateIndex,
28
+ };
29
+ };
30
+ exports.getSignedupUserData = getSignedupUserData;
31
+ /**
32
+ * Signup a user to the MACI contract
33
+ * @param {SignupArgs} args - The arguments for the signup command
34
+ * @returns {ISignupData} The state index of the user and transaction hash
35
+ */
36
+ const signup = async ({ maciPubKey, maciAddress, sgData, signer }) => {
37
+ // validate user key
38
+ if (!domainobjs_1.PubKey.isValidSerializedPubKey(maciPubKey)) {
39
+ throw new Error("Invalid MACI public key");
40
+ }
41
+ const userMaciPubKey = domainobjs_1.PubKey.deserialize(maciPubKey);
42
+ const validContract = await (0, contracts_1.contractExists)(signer.provider, maciAddress);
43
+ if (!validContract) {
44
+ throw new Error("There is no contract deployed at the specified address");
45
+ }
46
+ // we validate that the signup data and voice credit data is valid
47
+ if (!(0, ethers_1.isBytesLike)(sgData)) {
48
+ throw new Error("invalid signup gateway data");
49
+ }
50
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
51
+ let stateIndex = "";
52
+ let receipt = null;
53
+ // sign up to the MACI contract
54
+ const tx = await maciContract.signUp(userMaciPubKey.asContractParam(), sgData);
55
+ receipt = await tx.wait();
56
+ if (receipt?.status !== 1) {
57
+ throw new Error("The transaction failed");
58
+ }
59
+ // get state index from the event
60
+ const [{ args = [] } = { args: [] }] = await maciContract.queryFilter(maciContract.filters.SignUp, receipt.blockNumber, receipt.blockNumber);
61
+ stateIndex = args[0].toString();
62
+ return {
63
+ stateIndex: stateIndex ? stateIndex.toString() : "",
64
+ transactionHash: receipt.hash,
65
+ };
66
+ };
67
+ exports.signup = signup;
68
+ /**
69
+ * Checks if a user is signed up with a given public key
70
+ * @param {IIsSignedUpArgs} args - The arguments for the is signed up command
71
+ * @returns {boolean} Whether the user is signed up or not
72
+ */
73
+ const hasUserSignedUp = async ({ maciAddress, maciPubKey, signer }) => {
74
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
75
+ const stateIndex = await maciContract.getStateIndex(domainobjs_1.PubKey.deserialize(maciPubKey).hash());
76
+ return stateIndex !== 0n;
77
+ };
78
+ exports.hasUserSignedUp = hasUserSignedUp;
79
+ //# sourceMappingURL=signup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signup.js","sourceRoot":"","sources":["../../../ts/user/signup.ts"],"names":[],"mappings":";;;AAAA,8EAAwF;AACxF,0DAAmD;AACnD,mCAAiE;AAIjE,kDAAoD;AAEpD,mCAA4C;AAE5C;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,WAAW,EACX,UAAU,EACV,MAAM,EACN,UAAU,GACU,EAA8B,EAAE;IACpD,MAAM,YAAY,GAAG,+BAAW,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC9D,MAAM,SAAS,GAAG,mBAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACjD,MAAM,gBAAgB,GAAG,UAAU,IAAI,CAAC,CAAC;IACzC,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,QAAS,CAAC,cAAc,EAAE,CAAC;IAE7D,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,IAAA,yBAAiB,EAAC;QAC7C,YAAY;QACZ,UAAU,EAAE,gBAAgB;QAC5B,YAAY;QACZ,SAAS;KACV,CAAC,CAAC;IAEH,OAAO;QACL,YAAY,EAAE,UAAU,KAAK,SAAS;QACtC,UAAU;KACX,CAAC;AACJ,CAAC,CAAC;AAtBW,QAAA,mBAAmB,uBAsB9B;AAEF;;;;GAIG;AACI,MAAM,MAAM,GAAG,KAAK,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAe,EAAwB,EAAE;IAC7G,oBAAoB;IACpB,IAAI,CAAC,mBAAM,CAAC,uBAAuB,CAAC,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AEhC,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE;QACnD,eAAe,EAAE,OAAO,CAAC,IAAI;KAC9B,CAAC;AACJ,CAAC,CAAC;AA7CW,QAAA,MAAM,UA6CjB;AAEF;;;;GAIG;AACI,MAAM,eAAe,GAAG,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAwB,EAAoB,EAAE;IACnH,MAAM,YAAY,GAAG,+BAAW,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE9D,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,mBAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAE3F,OAAO,UAAU,KAAK,EAAE,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,eAAe,mBAM1B"}
@@ -0,0 +1,416 @@
1
+ import type { MACI, Poll } from "@maci-protocol/contracts/typechain-types";
2
+ import type { PrivKey, PubKey } from "@maci-protocol/domainobjs";
3
+ import type { Signer } from "ethers";
4
+ /**
5
+ * Interface for the arguments to the isJoinedUser command
6
+ */
7
+ export interface IJoinedUserArgs {
8
+ /**
9
+ * The address of the MACI contract
10
+ */
11
+ maciAddress: string;
12
+ /**
13
+ * The id of the poll
14
+ */
15
+ pollId: bigint;
16
+ /**
17
+ * Poll public key for the poll
18
+ */
19
+ pollPubKey: string;
20
+ /**
21
+ * A signer object
22
+ */
23
+ signer: Signer;
24
+ /**
25
+ * The start block number
26
+ */
27
+ startBlock: number;
28
+ }
29
+ /**
30
+ * Interface for the return data to the isRegisteredUser function
31
+ */
32
+ export interface IIsRegisteredUser {
33
+ /**
34
+ * Whether the user is registered
35
+ */
36
+ isRegistered: boolean;
37
+ /**
38
+ * The state index of the user
39
+ */
40
+ stateIndex?: string;
41
+ }
42
+ /**
43
+ * Interface for the return data to the isJoinedUser function
44
+ */
45
+ export interface IIsJoinedUser {
46
+ /**
47
+ * Whether the user joined the poll
48
+ */
49
+ isJoined: boolean;
50
+ /**
51
+ * The state index of the user
52
+ */
53
+ pollStateIndex?: string;
54
+ /**
55
+ * The voice credits of the user
56
+ */
57
+ voiceCredits?: string;
58
+ }
59
+ /**
60
+ * Interface for the arguments to the signup command
61
+ */
62
+ export interface ISignupArgs {
63
+ /**
64
+ * The public key of the user
65
+ */
66
+ maciPubKey: string;
67
+ /**
68
+ * A signer object
69
+ */
70
+ signer: Signer;
71
+ /**
72
+ * The address of the MACI contract
73
+ */
74
+ maciAddress: string;
75
+ /**
76
+ * The signup policy data
77
+ */
78
+ sgData: string;
79
+ }
80
+ /**
81
+ * Interface for the return data to the signup command
82
+ */
83
+ export interface ISignupData {
84
+ /**
85
+ * The state index of the user
86
+ */
87
+ stateIndex: string;
88
+ /**
89
+ * The signup transaction hash
90
+ */
91
+ transactionHash: string;
92
+ }
93
+ /**
94
+ * Interface for the arguments to the register check command
95
+ */
96
+ export interface IRegisteredUserArgs {
97
+ /**
98
+ * A signer object
99
+ */
100
+ signer: Signer;
101
+ /**
102
+ * The public key of the user
103
+ */
104
+ maciPubKey: string;
105
+ /**
106
+ * The address of the MACI contract
107
+ */
108
+ maciAddress: string;
109
+ /**
110
+ * Start block for event parsing
111
+ */
112
+ startBlock?: number;
113
+ }
114
+ /**
115
+ * Interface for the arguments to the parsePollJoinEvents function
116
+ */
117
+ export interface IParsePollJoinEventsArgs {
118
+ /**
119
+ * The MACI contract
120
+ */
121
+ pollContract: Poll;
122
+ /**
123
+ * The start block
124
+ */
125
+ startBlock: number;
126
+ /**
127
+ * The current block
128
+ */
129
+ currentBlock: number;
130
+ /**
131
+ * The public key
132
+ */
133
+ pollPublicKey: PubKey;
134
+ }
135
+ /**
136
+ * Interface for the arguments to the parseSignupEvents function
137
+ */
138
+ export interface IParseSignupEventsArgs {
139
+ /**
140
+ * The MACI contract
141
+ */
142
+ maciContract: MACI;
143
+ /**
144
+ * The start block
145
+ */
146
+ startBlock: number;
147
+ /**
148
+ * The current block
149
+ */
150
+ currentBlock: number;
151
+ /**
152
+ * The public key
153
+ */
154
+ publicKey: PubKey;
155
+ }
156
+ /**
157
+ * An interface describing the circuit inputs to the PollJoining circuit
158
+ */
159
+ export interface IPollJoiningCircuitInputs {
160
+ /**
161
+ * The private key
162
+ */
163
+ privKey: string;
164
+ /**
165
+ * The poll public key
166
+ */
167
+ pollPubKey: string[];
168
+ /**
169
+ * The state leaf
170
+ */
171
+ stateLeaf: string[];
172
+ /**
173
+ * The siblings for the merkle proof
174
+ */
175
+ siblings: string[][];
176
+ /**
177
+ * The path indices
178
+ */
179
+ indices: string[];
180
+ /**
181
+ * The nullifier
182
+ */
183
+ nullifier: string;
184
+ /**
185
+ * The state root
186
+ */
187
+ stateRoot: string;
188
+ /**
189
+ * The actual state tree depth
190
+ */
191
+ actualStateTreeDepth: string;
192
+ /**
193
+ * The poll id
194
+ */
195
+ pollId: string;
196
+ }
197
+ /**
198
+ * An interface describing the circuit inputs to the PollJoined circuit
199
+ */
200
+ export interface IPollJoinedCircuitInputs {
201
+ /**
202
+ * The private key
203
+ */
204
+ privKey: string;
205
+ /**
206
+ * The voice credits balance
207
+ */
208
+ voiceCreditsBalance: string;
209
+ /**
210
+ * The state leaf
211
+ */
212
+ stateLeaf: string[];
213
+ /**
214
+ * The path elements
215
+ */
216
+ pathElements: string[][];
217
+ /**
218
+ * The path indices
219
+ */
220
+ pathIndices: string[];
221
+ /**
222
+ * The state root
223
+ */
224
+ stateRoot: string;
225
+ /**
226
+ * The actual state tree depth
227
+ */
228
+ actualStateTreeDepth: string;
229
+ }
230
+ /**
231
+ * Interface for the arguments to the joinPoll command
232
+ */
233
+ export interface IJoinPollArgs {
234
+ /**
235
+ * A signer object
236
+ */
237
+ signer: Signer;
238
+ /**
239
+ * The private key of the user
240
+ */
241
+ privateKey: string;
242
+ /**
243
+ * The id of the poll
244
+ */
245
+ pollId: bigint;
246
+ /**
247
+ * The index of the public key in the state tree
248
+ */
249
+ stateIndex?: bigint;
250
+ /**
251
+ * Path to the state file with MACI state
252
+ */
253
+ stateFile?: string;
254
+ /**
255
+ * The address of the MACI contract
256
+ */
257
+ maciAddress: string;
258
+ /**
259
+ * The end block number
260
+ */
261
+ endBlock?: number;
262
+ /**
263
+ * The start block number
264
+ */
265
+ startBlock?: number;
266
+ /**
267
+ * The number of blocks to fetch per batch
268
+ */
269
+ blocksPerBatch?: number;
270
+ /**
271
+ * The path to the poll zkey file
272
+ */
273
+ pollJoiningZkey: string;
274
+ /**
275
+ * Whether to use wasm or rapidsnark
276
+ */
277
+ useWasm?: boolean;
278
+ /**
279
+ * The path to the rapidsnark binary
280
+ */
281
+ rapidsnark?: string;
282
+ /**
283
+ * The path to the poll witnessgen binary
284
+ */
285
+ pollWitgen?: string;
286
+ /**
287
+ * The path to the poll wasm file
288
+ */
289
+ pollWasm?: string;
290
+ /**
291
+ * The signup policy data
292
+ */
293
+ sgDataArg: string;
294
+ /**
295
+ * The initial voice credit proxy data
296
+ */
297
+ ivcpDataArg: string;
298
+ }
299
+ /**
300
+ * Interface for the return data to the joinPoll command
301
+ */
302
+ export interface IJoinPollData {
303
+ /**
304
+ * The poll state index of the joined user
305
+ */
306
+ pollStateIndex: string;
307
+ /**
308
+ * Voice credits balance
309
+ */
310
+ voiceCredits: string;
311
+ /**
312
+ * Private key nullifier
313
+ */
314
+ nullifier: string;
315
+ /**
316
+ * The join poll transaction hash
317
+ */
318
+ hash: string;
319
+ }
320
+ /**
321
+ * The arguments to check if a nullifier is on chain
322
+ */
323
+ export interface IIsNullifierOnChainArgs {
324
+ /**
325
+ * The address of the MACI contract
326
+ */
327
+ maciAddress: string;
328
+ /**
329
+ * The id of the poll
330
+ */
331
+ pollId: bigint;
332
+ /**
333
+ * The nullifier to check
334
+ */
335
+ nullifier: bigint;
336
+ /**
337
+ * The signer to use
338
+ */
339
+ signer: Signer;
340
+ }
341
+ /**
342
+ * Arguments for getPollJoiningCircuitEvents
343
+ */
344
+ export interface IGetPollJoiningCircuitEventsArgs {
345
+ /**
346
+ * The MACI contract
347
+ */
348
+ maciContract: MACI;
349
+ /**
350
+ * The state index
351
+ */
352
+ stateIndex: bigint;
353
+ /**
354
+ * The poll id
355
+ */
356
+ pollId: bigint;
357
+ /**
358
+ * The user's maci private key
359
+ */
360
+ userMaciPrivKey: PrivKey;
361
+ /**
362
+ * The signer
363
+ */
364
+ signer: Signer;
365
+ /**
366
+ * The start block
367
+ */
368
+ startBlock?: number;
369
+ /**
370
+ * The end block
371
+ */
372
+ endBlock?: number;
373
+ /**
374
+ * The blocks per batch
375
+ */
376
+ blocksPerBatch?: number;
377
+ }
378
+ /**
379
+ * Arguments for getPollJoiningCircuitInputsFromStateFile
380
+ */
381
+ export interface IGetPollJoiningCircuitInputsFromStateFileArgs {
382
+ /**
383
+ * The path to the file containing the serialized MACI state
384
+ */
385
+ stateFile: string;
386
+ /**
387
+ * The poll id
388
+ */
389
+ pollId: bigint;
390
+ /**
391
+ * The state index
392
+ */
393
+ stateIndex: bigint;
394
+ /**
395
+ * The user's maci private key
396
+ */
397
+ userMaciPrivKey: PrivKey;
398
+ }
399
+ /**
400
+ * Interface for the arguments for the is signed up command
401
+ */
402
+ export interface IHasUserSignedUpArgs {
403
+ /**
404
+ * The address of the MACI contract
405
+ */
406
+ maciAddress: string;
407
+ /**
408
+ * The public key of the user
409
+ */
410
+ maciPubKey: string;
411
+ /**
412
+ * The signer to use for the transaction
413
+ */
414
+ signer: Signer;
415
+ }
416
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/user/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,E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AAC;IAEnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,6CAA6C;IAC5D;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/user/types.ts"],"names":[],"mappings":""}