@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 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/maciKeys/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateMaciPublicKey = exports.generateKeypair = void 0;
4
+ var keypair_1 = require("./keypair");
5
+ Object.defineProperty(exports, "generateKeypair", { enumerable: true, get: function () { return keypair_1.generateKeypair; } });
6
+ var publicKeys_1 = require("./publicKeys");
7
+ Object.defineProperty(exports, "generateMaciPublicKey", { enumerable: true, get: function () { return publicKeys_1.generateMaciPublicKey; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/maciKeys/index.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAAnC,0GAAA,eAAe,OAAA;AACxB,2CAAqD;AAA5C,mHAAA,qBAAqB,OAAA"}
@@ -0,0 +1,9 @@
1
+ import type { IGenerateKeypairArgs, IGenerateKeypairData } from "./types";
2
+ /**
3
+ * Generate a new Maci Key Pair
4
+ * and print it to the screen
5
+ * @param {IGenerateKeypairArgs} args keypair generation params
6
+ * @returns {IGenerateKeypairData} keypair
7
+ */
8
+ export declare const generateKeypair: ({ seed }?: IGenerateKeypairArgs) => IGenerateKeypairData;
9
+ //# sourceMappingURL=keypair.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.d.ts","sourceRoot":"","sources":["../../../ts/maciKeys/keypair.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE1E;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,WAAU,oBAAyB,KAAG,oBAQrE,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateKeypair = void 0;
4
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
5
+ /**
6
+ * Generate a new Maci Key Pair
7
+ * and print it to the screen
8
+ * @param {IGenerateKeypairArgs} args keypair generation params
9
+ * @returns {IGenerateKeypairData} keypair
10
+ */
11
+ const generateKeypair = ({ seed } = {}) => {
12
+ // create the new random keypair if there is no seed value
13
+ const keypair = new domainobjs_1.Keypair(seed ? new domainobjs_1.PrivKey(seed) : undefined);
14
+ return {
15
+ publicKey: keypair.pubKey.serialize(),
16
+ privateKey: keypair.privKey.serialize(),
17
+ };
18
+ };
19
+ exports.generateKeypair = generateKeypair;
20
+ //# sourceMappingURL=keypair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.js","sourceRoot":"","sources":["../../../ts/maciKeys/keypair.ts"],"names":[],"mappings":";;;AAAA,0DAA6D;AAI7D;;;;;GAKG;AACI,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,KAA2B,EAAE,EAAwB,EAAE;IAC3F,0DAA0D;IAC1D,MAAM,OAAO,GAAG,IAAI,oBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,oBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAElE,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE;QACrC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE;KACxC,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,eAAe,mBAQ1B"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generate a new Maci Public key from a private key
3
+ * @param privKey - the user private key
4
+ * @param quiet - whether to log the output
5
+ * @return the public key serialized
6
+ */
7
+ export declare const generateMaciPublicKey: (privkey: string) => string;
8
+ //# sourceMappingURL=publicKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicKeys.d.ts","sourceRoot":"","sources":["../../../ts/maciKeys/publicKeys.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,MAAM,KAAG,MAWvD,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateMaciPublicKey = void 0;
4
+ const crypto_1 = require("@maci-protocol/crypto");
5
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
6
+ /**
7
+ * Generate a new Maci Public key from a private key
8
+ * @param privKey - the user private key
9
+ * @param quiet - whether to log the output
10
+ * @return the public key serialized
11
+ */
12
+ const generateMaciPublicKey = (privkey) => {
13
+ // we check that the provided private key is valid
14
+ if (!domainobjs_1.PrivKey.isValidSerializedPrivKey(privkey)) {
15
+ throw new Error("Invalid private key");
16
+ }
17
+ const unserializedKey = domainobjs_1.PrivKey.deserialize(privkey);
18
+ const pubKey = new domainobjs_1.PubKey((0, crypto_1.genPubKey)(unserializedKey.rawPrivKey));
19
+ // we give back the serialized public key
20
+ return pubKey.serialize();
21
+ };
22
+ exports.generateMaciPublicKey = generateMaciPublicKey;
23
+ //# sourceMappingURL=publicKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicKeys.js","sourceRoot":"","sources":["../../../ts/maciKeys/publicKeys.ts"],"names":[],"mappings":";;;AAAA,kDAAkD;AAClD,0DAA4D;AAE5D;;;;;GAKG;AACI,MAAM,qBAAqB,GAAG,CAAC,OAAe,EAAU,EAAE;IAC/D,kDAAkD;IAClD,IAAI,CAAC,oBAAO,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,eAAe,GAAG,oBAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,IAAI,mBAAM,CAAC,IAAA,kBAAS,EAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjE,yCAAyC;IACzC,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC;AAC5B,CAAC,CAAC;AAXW,QAAA,qBAAqB,yBAWhC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Interface for the arguments for generate keypair command
3
+ */
4
+ export interface IGenerateKeypairArgs {
5
+ /**
6
+ * Seed value for keypair
7
+ */
8
+ seed?: bigint;
9
+ }
10
+ /**
11
+ * Interface for the return data type for generate keypair command
12
+ */
13
+ export interface IGenerateKeypairData {
14
+ /**
15
+ * Serialized public key
16
+ */
17
+ publicKey: string;
18
+ /**
19
+ * Serialized private key
20
+ */
21
+ privateKey: string;
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/maciKeys/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,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/maciKeys/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export { getPoll, getPollParams } from "./poll";
2
+ export { getPollContracts } from "./utils";
3
+ export type { IGetPollArgs, IGetPollData, IGetPollParamsArgs, IPollParams, IPollJoiningInputs, IPollJoinedInputs, } from "./types";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/poll/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPollContracts = exports.getPollParams = exports.getPoll = void 0;
4
+ var poll_1 = require("./poll");
5
+ Object.defineProperty(exports, "getPoll", { enumerable: true, get: function () { return poll_1.getPoll; } });
6
+ Object.defineProperty(exports, "getPollParams", { enumerable: true, get: function () { return poll_1.getPollParams; } });
7
+ var utils_1 = require("./utils");
8
+ Object.defineProperty(exports, "getPollContracts", { enumerable: true, get: function () { return utils_1.getPollContracts; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/poll/index.ts"],"names":[],"mappings":";;;AAAA,+BAAgD;AAAvC,+FAAA,OAAO,OAAA;AAAE,qGAAA,aAAa,OAAA;AAC/B,iCAA2C;AAAlC,yGAAA,gBAAgB,OAAA"}
@@ -0,0 +1,14 @@
1
+ import type { IGetPollArgs, IGetPollData, IGetPollParamsArgs, IPollParams } from "./types";
2
+ /**
3
+ * Get deployed poll from MACI contract
4
+ * @param {IGetPollArgs} args - The arguments for the get poll command
5
+ * @returns {IGetPollData} poll data
6
+ */
7
+ export declare const getPoll: ({ maciAddress, signer, provider, pollId }: IGetPollArgs) => Promise<IGetPollData>;
8
+ /**
9
+ * Get the parameters for the poll
10
+ * @param {IGetPollParamsArgs} args - The arguments for the get poll command
11
+ * @returns {IPollParams} poll parameters
12
+ */
13
+ export declare const getPollParams: ({ pollId, signer, maciContractAddress, }: IGetPollParamsArgs) => Promise<IPollParams>;
14
+ //# sourceMappingURL=poll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poll.d.ts","sourceRoot":"","sources":["../../../ts/poll/poll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3F;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAU,2CAA2C,YAAY,KAAG,OAAO,CAAC,YAAY,CAgC3G,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,0CAIjC,kBAAkB,KAAG,OAAO,CAAC,WAAW,CAwB1C,CAAC"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPollParams = exports.getPoll = void 0;
4
+ const utils_1 = require("./utils");
5
+ /**
6
+ * Get deployed poll from MACI contract
7
+ * @param {IGetPollArgs} args - The arguments for the get poll command
8
+ * @returns {IGetPollData} poll data
9
+ */
10
+ const getPoll = async ({ maciAddress, signer, provider, pollId }) => {
11
+ if (!signer && !provider) {
12
+ throw new Error("No signer and provider are provided");
13
+ }
14
+ const { id, poll: pollContract, maci: maciContract, tally: tallyContract, } = await (0, utils_1.getPollContracts)({ maciAddress, pollId, signer, provider });
15
+ const [[startDate, endDate], mergedStateRoot, pollAddress] = await Promise.all([
16
+ pollContract.getStartAndEndDate(),
17
+ pollContract.mergedStateRoot(),
18
+ pollContract.getAddress(),
19
+ ]);
20
+ const isMerged = mergedStateRoot !== BigInt(0);
21
+ const numSignups = await (isMerged ? pollContract.numSignups() : maciContract.numSignUps());
22
+ // get the poll mode
23
+ const mode = await tallyContract.mode();
24
+ return {
25
+ id,
26
+ address: pollAddress,
27
+ startDate,
28
+ endDate,
29
+ numSignups,
30
+ isMerged,
31
+ mode,
32
+ };
33
+ };
34
+ exports.getPoll = getPoll;
35
+ /**
36
+ * Get the parameters for the poll
37
+ * @param {IGetPollParamsArgs} args - The arguments for the get poll command
38
+ * @returns {IPollParams} poll parameters
39
+ */
40
+ const getPollParams = async ({ pollId, signer, maciContractAddress, }) => {
41
+ // get the contract objects
42
+ const { poll: pollContract } = await (0, utils_1.getPollContracts)({
43
+ maciAddress: maciContractAddress,
44
+ pollId,
45
+ signer,
46
+ });
47
+ const treeDepths = await pollContract.treeDepths();
48
+ const voteOptionTreeDepth = Number(treeDepths.voteOptionTreeDepth);
49
+ const numVoteOptions = 5 ** voteOptionTreeDepth;
50
+ const messageBatchSize = Number.parseInt((await pollContract.messageBatchSize()).toString(), 10);
51
+ const intStateTreeDepth = Number(treeDepths.intStateTreeDepth);
52
+ const tallyBatchSize = 5 ** intStateTreeDepth;
53
+ return {
54
+ messageBatchSize,
55
+ numVoteOptions,
56
+ tallyBatchSize,
57
+ voteOptionTreeDepth,
58
+ intStateTreeDepth,
59
+ };
60
+ };
61
+ exports.getPollParams = getPollParams;
62
+ //# sourceMappingURL=poll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poll.js","sourceRoot":"","sources":["../../../ts/poll/poll.ts"],"names":[],"mappings":";;;AAEA,mCAA2C;AAE3C;;;;GAIG;AACI,MAAM,OAAO,GAAG,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAgB,EAAyB,EAAE;IAC9G,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,EACJ,EAAE,EACF,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,aAAa,GACrB,GAAG,MAAM,IAAA,wBAAgB,EAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEtE,MAAM,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,eAAe,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC7E,YAAY,CAAC,kBAAkB,EAAE;QACjC,YAAY,CAAC,eAAe,EAAE;QAC9B,YAAY,CAAC,UAAU,EAAE;KAC1B,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,eAAe,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/C,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC;IAE5F,oBAAoB;IACpB,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC;IAExC,OAAO;QACL,EAAE;QACF,OAAO,EAAE,WAAW;QACpB,SAAS;QACT,OAAO;QACP,UAAU;QACV,QAAQ;QACR,IAAI;KACL,CAAC;AACJ,CAAC,CAAC;AAhCW,QAAA,OAAO,WAgClB;AAEF;;;;GAIG;AACI,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,MAAM,EACN,MAAM,EACN,mBAAmB,GACA,EAAwB,EAAE;IAC7C,2BAA2B;IAC3B,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,wBAAgB,EAAC;QACpD,WAAW,EAAE,mBAAmB;QAChC,MAAM;QACN,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,UAAU,EAAE,CAAC;IACnD,MAAM,mBAAmB,GAAG,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IACnE,MAAM,cAAc,GAAG,CAAC,IAAI,mBAAmB,CAAC;IAEhD,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,YAAY,CAAC,gBAAgB,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IAEjG,MAAM,iBAAiB,GAAG,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC/D,MAAM,cAAc,GAAG,CAAC,IAAI,iBAAiB,CAAC;IAE9C,OAAO;QACL,gBAAgB;QAChB,cAAc;QACd,cAAc;QACd,mBAAmB;QACnB,iBAAiB;KAClB,CAAC;AACJ,CAAC,CAAC;AA5BW,QAAA,aAAa,iBA4BxB"}
@@ -0,0 +1,151 @@
1
+ import type { Poll, MessageProcessor, Tally, MACI } from "@maci-protocol/contracts/typechain-types";
2
+ import type { BigNumberish, Provider, Signer } from "ethers";
3
+ /**
4
+ * Interface for the arguments to the get poll command
5
+ */
6
+ export interface IGetPollArgs {
7
+ /**
8
+ * A signer object
9
+ */
10
+ signer?: Signer;
11
+ /**
12
+ * A provider fallback object
13
+ */
14
+ provider?: Provider;
15
+ /**
16
+ * The address of the MACI contract
17
+ */
18
+ maciAddress: string;
19
+ /**
20
+ * The poll id. If not specified, latest poll id will be used
21
+ */
22
+ pollId?: BigNumberish;
23
+ }
24
+ /**
25
+ * Interface that represents get poll contracts data
26
+ */
27
+ export interface IGetPollContractsData {
28
+ /**
29
+ * Poll id
30
+ */
31
+ id: bigint;
32
+ /**
33
+ * MACI contract
34
+ */
35
+ maci: MACI;
36
+ /**
37
+ * Poll contract
38
+ */
39
+ poll: Poll;
40
+ /**
41
+ * MessageProcessor contract
42
+ */
43
+ messageProcessor: MessageProcessor;
44
+ /**
45
+ * Tally contract
46
+ */
47
+ tally: Tally;
48
+ }
49
+ /**
50
+ * Interface for the return data to the get poll command
51
+ */
52
+ export interface IGetPollData {
53
+ /**
54
+ * The poll id
55
+ */
56
+ id: BigNumberish;
57
+ /**
58
+ * The poll address
59
+ */
60
+ address: string;
61
+ /**
62
+ * The poll deployment timestamp
63
+ */
64
+ startDate: BigNumberish;
65
+ /**
66
+ * The poll end timestamp
67
+ */
68
+ endDate: BigNumberish;
69
+ /**
70
+ * The poll number of signups
71
+ */
72
+ numSignups: BigNumberish;
73
+ /**
74
+ * Whether the MACI contract's state root has been merged
75
+ */
76
+ isMerged: boolean;
77
+ /**
78
+ * Mode of the poll
79
+ */
80
+ mode: BigNumberish;
81
+ }
82
+ /**
83
+ * Arguments for the get poll params command
84
+ */
85
+ export interface IGetPollParamsArgs {
86
+ /**
87
+ * The poll id
88
+ */
89
+ pollId: bigint;
90
+ /**
91
+ * The signer
92
+ */
93
+ signer: Signer;
94
+ /**
95
+ * The MACI contract address
96
+ */
97
+ maciContractAddress: string;
98
+ }
99
+ /**
100
+ * Poll parameters
101
+ */
102
+ export interface IPollParams {
103
+ /**
104
+ * The message batch size
105
+ */
106
+ messageBatchSize: number;
107
+ /**
108
+ * The number of vote options
109
+ */
110
+ numVoteOptions: number;
111
+ /**
112
+ * Tally Batch Size
113
+ */
114
+ tallyBatchSize: number;
115
+ /**
116
+ * The vote option tree depth
117
+ */
118
+ voteOptionTreeDepth: number;
119
+ /**
120
+ * The depth of the tree holding the user ballots
121
+ */
122
+ intStateTreeDepth: number;
123
+ }
124
+ /**
125
+ * Inputs for circuit PollJoining
126
+ */
127
+ export interface IPollJoiningInputs {
128
+ privKey: bigint;
129
+ pollPubKey: bigint[][];
130
+ stateLeaf: bigint[];
131
+ siblings: bigint[][];
132
+ indices: bigint[];
133
+ nullifier: bigint;
134
+ credits: bigint;
135
+ stateRoot: bigint;
136
+ actualStateTreeDepth: bigint;
137
+ pollId: bigint;
138
+ }
139
+ /**
140
+ * Inputs for circuit PollJoined
141
+ */
142
+ export interface IPollJoinedInputs {
143
+ privKey: bigint;
144
+ voiceCreditsBalance: bigint;
145
+ stateLeaf: bigint[];
146
+ pathElements: bigint[][];
147
+ pathIndices: bigint[];
148
+ credits: bigint;
149
+ stateRoot: bigint;
150
+ }
151
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/poll/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IAEX;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,EAAE,EAAE,YAAY,CAAC;IAEjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,YAAY,CAAC;IAExB;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;IAEtB;;OAEG;IACH,UAAU,EAAE,YAAY,CAAC;IAEzB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,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/poll/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { IGetPollArgs, IGetPollContractsData } from "./types";
2
+ /**
3
+ * Get poll contracts
4
+ *
5
+ * @param args get poll contract args
6
+ * @returns poll contracts
7
+ */
8
+ export declare const getPollContracts: ({ maciAddress, pollId, signer, provider, }: IGetPollArgs) => Promise<IGetPollContractsData>;
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/poll/utils.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAInE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAU,4CAKpC,YAAY,KAAG,OAAO,CAAC,qBAAqB,CAqC9C,CAAC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPollContracts = void 0;
4
+ const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
5
+ const ethers_1 = require("ethers");
6
+ const contracts_1 = require("../utils/contracts");
7
+ /**
8
+ * Get poll contracts
9
+ *
10
+ * @param args get poll contract args
11
+ * @returns poll contracts
12
+ */
13
+ const getPollContracts = async ({ maciAddress, pollId, signer, provider, }) => {
14
+ const maci = typechain_types_1.MACI__factory.connect(maciAddress, signer ?? provider);
15
+ const id = pollId === undefined ? await maci.nextPollId().then((nextPollId) => nextPollId - 1n) : BigInt(pollId);
16
+ if (id < 0n) {
17
+ throw new Error(`Invalid poll id ${id}`);
18
+ }
19
+ const isMaciExists = await (0, contracts_1.contractExists)(signer?.provider || provider, maciAddress);
20
+ if (!isMaciExists) {
21
+ throw new Error("MACI contract does not exist");
22
+ }
23
+ const pollContracts = await maci.polls(id);
24
+ if (pollContracts.poll === ethers_1.ZeroAddress) {
25
+ throw new Error(`MACI contract doesn't have any deployed poll ${id}`);
26
+ }
27
+ const isPollExists = await (0, contracts_1.contractExists)(signer?.provider || provider, pollContracts.poll);
28
+ if (!isPollExists) {
29
+ throw new Error("Poll contract does not exist");
30
+ }
31
+ const poll = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer ?? provider);
32
+ const messageProcessor = typechain_types_1.MessageProcessor__factory.connect(pollContracts.messageProcessor, signer ?? provider);
33
+ const tally = typechain_types_1.Tally__factory.connect(pollContracts.tally, signer ?? provider);
34
+ return {
35
+ id,
36
+ maci,
37
+ poll,
38
+ messageProcessor,
39
+ tally,
40
+ };
41
+ };
42
+ exports.getPollContracts = getPollContracts;
43
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/poll/utils.ts"],"names":[],"mappings":";;;AAAA,8EAKkD;AAClD,mCAAqC;AAIrC,kDAAoD;AAEpD;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,KAAK,EAAE,EACrC,WAAW,EACX,MAAM,EACN,MAAM,EACN,QAAQ,GACK,EAAkC,EAAE;IACjD,MAAM,IAAI,GAAG,+BAAW,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;IAClE,MAAM,EAAE,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEjH,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,0BAAc,EAAC,MAAM,EAAE,QAAQ,IAAI,QAAS,EAAE,WAAW,CAAC,CAAC;IAEtF,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAE3C,IAAI,aAAa,CAAC,IAAI,KAAK,oBAAW,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,gDAAgD,EAAE,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,0BAAc,EAAC,MAAM,EAAE,QAAQ,IAAI,QAAS,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAE7F,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,IAAI,GAAG,+BAAW,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;IACzE,MAAM,gBAAgB,GAAG,2CAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,gBAAgB,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;IAC7G,MAAM,KAAK,GAAG,gCAAY,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;IAE5E,OAAO;QACL,EAAE;QACF,IAAI;QACJ,IAAI;QACJ,gBAAgB;QAChB,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AA1CW,QAAA,gBAAgB,oBA0C3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=download.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.test.d.ts","sourceRoot":"","sources":["../../../../ts/proof/__tests__/download.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const contracts_1 = require("@maci-protocol/contracts");
4
+ const download_1 = require("../download");
5
+ /**
6
+ * The inputs for the proof generation
7
+ */
8
+ const inputs = {
9
+ privKey: "1259082279488355278660453796037744749156697484507442909424227073450806091599",
10
+ pollPubKey: [
11
+ "4604149953291977424931588219098726306922992659857425248363017596008978179462",
12
+ "1911350329545195833133079763781611226710101140694516439580176096139978229522",
13
+ ],
14
+ siblings: [
15
+ ["1309255631273308531193241901289907343161346846555918942743921933037802809814"],
16
+ ["0"],
17
+ ["0"],
18
+ ["0"],
19
+ ["0"],
20
+ ["0"],
21
+ ["0"],
22
+ ["0"],
23
+ ["0"],
24
+ ["0"],
25
+ ],
26
+ indices: ["1", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
27
+ nullifier: "5960968591926285526739882209300764345427591192846309606519433839944864771425",
28
+ stateRoot: "19853258600018552129206808764461795697997153860385513081821578400505176714352",
29
+ actualStateTreeDepth: "1",
30
+ pollId: "0",
31
+ };
32
+ describe("downloadPollJoiningArtifactsBrowser", () => {
33
+ it("should allow to generate a proof using the downloaded artifacts", async () => {
34
+ const { zKey, wasm } = await (0, download_1.downloadPollJoiningArtifactsBrowser)(true);
35
+ expect(zKey).toBeDefined();
36
+ expect(wasm).toBeDefined();
37
+ const { proof } = await (0, contracts_1.genProofSnarkjs)({
38
+ inputs: inputs,
39
+ zkeyPath: zKey,
40
+ wasmPath: wasm,
41
+ });
42
+ expect(proof).toBeDefined();
43
+ expect(proof.protocol).toBe("groth16");
44
+ expect(proof.pi_a.length).toBe(3);
45
+ expect(proof.pi_b.length).toBe(3);
46
+ expect(proof.pi_c.length).toBe(3);
47
+ expect(proof.curve).toBe("bn128");
48
+ });
49
+ });
50
+ //# sourceMappingURL=download.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.test.js","sourceRoot":"","sources":["../../../../ts/proof/__tests__/download.test.ts"],"names":[],"mappings":";;AAAA,wDAA2D;AAG3D,0CAAkE;AAElE;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,8EAA8E;IACvF,UAAU,EAAE;QACV,8EAA8E;QAC9E,8EAA8E;KAC/E;IACD,QAAQ,EAAE;QACR,CAAC,8EAA8E,CAAC;QAChF,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;QACL,CAAC,GAAG,CAAC;KACN;IACD,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAC3D,SAAS,EAAE,8EAA8E;IACzF,SAAS,EAAE,+EAA+E;IAC1F,oBAAoB,EAAE,GAAG;IACzB,MAAM,EAAE,GAAG;CACZ,CAAC;AAEF,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACnD,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;QAC/E,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,8CAAmC,EAAC,IAAI,CAAC,CAAC;QAEvE,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QAE3B,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,2BAAe,EAAC;YACtC,MAAM,EAAE,MAAkC;YAC1C,QAAQ,EAAE,IAAyB;YACnC,QAAQ,EAAE,IAAyB;SACpC,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The url of the poll joining zkey for testing
3
+ */
4
+ export declare const pollJoiningZkeyTestingUrl = "https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/testing/PollJoining_10_test.0.zkey";
5
+ /**
6
+ * The url of the poll joining zkey for production
7
+ */
8
+ export declare const pollJoiningWasmTestingUrl = "https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/testing/PollJoining_10_test.wasm";
9
+ /**
10
+ * The url of the poll joining zkey for production
11
+ */
12
+ export declare const pollJoiningZkeyProductionUrl = "not-available";
13
+ /**
14
+ * The url of the poll joining wasm for production
15
+ */
16
+ export declare const pollJoiningWasmProductionUrl = "not-available";
17
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../ts/proof/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,yBAAyB,uHACgF,CAAC;AAEvH;;GAEG;AACH,eAAO,MAAM,yBAAyB,qHAC8E,CAAC;AAErH;;GAEG;AACH,eAAO,MAAM,4BAA4B,kBAAkB,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,4BAA4B,kBAAkB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pollJoiningWasmProductionUrl = exports.pollJoiningZkeyProductionUrl = exports.pollJoiningWasmTestingUrl = exports.pollJoiningZkeyTestingUrl = void 0;
4
+ /**
5
+ * The url of the poll joining zkey for testing
6
+ */
7
+ exports.pollJoiningZkeyTestingUrl = "https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/testing/PollJoining_10_test.0.zkey";
8
+ /**
9
+ * The url of the poll joining zkey for production
10
+ */
11
+ exports.pollJoiningWasmTestingUrl = "https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v3.0.0/browser-poll-join/testing/PollJoining_10_test.wasm";
12
+ /**
13
+ * The url of the poll joining zkey for production
14
+ */
15
+ exports.pollJoiningZkeyProductionUrl = "not-available";
16
+ /**
17
+ * The url of the poll joining wasm for production
18
+ */
19
+ exports.pollJoiningWasmProductionUrl = "not-available";
20
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../ts/proof/constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,yBAAyB,GACpC,oHAAoH,CAAC;AAEvH;;GAEG;AACU,QAAA,yBAAyB,GACpC,kHAAkH,CAAC;AAErH;;GAEG;AACU,QAAA,4BAA4B,GAAG,eAAe,CAAC;AAE5D;;GAEG;AACU,QAAA,4BAA4B,GAAG,eAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { IPollJoiningArtifacts } from "./types";
2
+ /**
3
+ * Download the poll joining artifacts for the browser
4
+ *
5
+ * @param testing - Whether to download the testing artifacts
6
+ * @returns The poll joining artifacts
7
+ */
8
+ export declare const downloadPollJoiningArtifactsBrowser: (testing?: boolean) => Promise<IPollJoiningArtifacts>;
9
+ //# sourceMappingURL=download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../ts/proof/download.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA4CrD;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,GAAU,iBAAe,KAAG,OAAO,CAAC,qBAAqB,CAgBxG,CAAC"}