@maci-protocol/sdk 0.0.0-ci.01622be

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 (314) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/LICENSE +21 -0
  3. package/README.md +12 -0
  4. package/build/package.json +65 -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 +38 -0
  8. package/build/ts/browser/index.js.map +1 -0
  9. package/build/ts/browser/joinPoll.d.ts +10 -0
  10. package/build/ts/browser/joinPoll.d.ts.map +1 -0
  11. package/build/ts/browser/joinPoll.js +88 -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 +217 -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/verifyingKeysRegistry.d.ts +7 -0
  38. package/build/ts/deploy/verifyingKeysRegistry.d.ts.map +1 -0
  39. package/build/ts/deploy/verifyingKeysRegistry.js +14 -0
  40. package/build/ts/deploy/verifyingKeysRegistry.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 +86 -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 +53 -0
  108. package/build/ts/proof/__tests__/download.test.js.map +1 -0
  109. package/build/ts/proof/download.d.ts +9 -0
  110. package/build/ts/proof/download.d.ts.map +1 -0
  111. package/build/ts/proof/download.js +47 -0
  112. package/build/ts/proof/download.js.map +1 -0
  113. package/build/ts/proof/generate.d.ts +8 -0
  114. package/build/ts/proof/generate.d.ts.map +1 -0
  115. package/build/ts/proof/generate.js +127 -0
  116. package/build/ts/proof/generate.js.map +1 -0
  117. package/build/ts/proof/index.d.ts +4 -0
  118. package/build/ts/proof/index.d.ts.map +1 -0
  119. package/build/ts/proof/index.js +8 -0
  120. package/build/ts/proof/index.js.map +1 -0
  121. package/build/ts/proof/prove.d.ts +8 -0
  122. package/build/ts/proof/prove.d.ts.map +1 -0
  123. package/build/ts/proof/prove.js +81 -0
  124. package/build/ts/proof/prove.js.map +1 -0
  125. package/build/ts/proof/types.d.ts +201 -0
  126. package/build/ts/proof/types.d.ts.map +1 -0
  127. package/build/ts/proof/types.js +3 -0
  128. package/build/ts/proof/types.js.map +1 -0
  129. package/build/ts/proof/utils.d.ts +10 -0
  130. package/build/ts/proof/utils.d.ts.map +1 -0
  131. package/build/ts/proof/utils.js +24 -0
  132. package/build/ts/proof/utils.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 +43 -0
  160. package/build/ts/tally/commitments.js.map +1 -0
  161. package/build/ts/tally/index.d.ts +5 -0
  162. package/build/ts/tally/index.d.ts.map +1 -0
  163. package/build/ts/tally/index.js +11 -0
  164. package/build/ts/tally/index.js.map +1 -0
  165. package/build/ts/tally/results.d.ts +14 -0
  166. package/build/ts/tally/results.d.ts.map +1 -0
  167. package/build/ts/tally/results.js +44 -0
  168. package/build/ts/tally/results.js.map +1 -0
  169. package/build/ts/tally/types.d.ts +206 -0
  170. package/build/ts/tally/types.d.ts.map +1 -0
  171. package/build/ts/tally/types.js +3 -0
  172. package/build/ts/tally/types.js.map +1 -0
  173. package/build/ts/tally/utils.d.ts +24 -0
  174. package/build/ts/tally/utils.d.ts.map +1 -0
  175. package/build/ts/tally/utils.js +50 -0
  176. package/build/ts/tally/utils.js.map +1 -0
  177. package/build/ts/tally/verification.d.ts +7 -0
  178. package/build/ts/tally/verification.d.ts.map +1 -0
  179. package/build/ts/tally/verification.js +62 -0
  180. package/build/ts/tally/verification.js.map +1 -0
  181. package/build/ts/trees/index.d.ts +3 -0
  182. package/build/ts/trees/index.d.ts.map +1 -0
  183. package/build/ts/trees/index.js +7 -0
  184. package/build/ts/trees/index.js.map +1 -0
  185. package/build/ts/trees/stateTree.d.ts +27 -0
  186. package/build/ts/trees/stateTree.d.ts.map +1 -0
  187. package/build/ts/trees/stateTree.js +104 -0
  188. package/build/ts/trees/stateTree.js.map +1 -0
  189. package/build/ts/trees/types.d.ts +55 -0
  190. package/build/ts/trees/types.d.ts.map +1 -0
  191. package/build/ts/trees/types.js +3 -0
  192. package/build/ts/trees/types.js.map +1 -0
  193. package/build/ts/user/index.d.ts +5 -0
  194. package/build/ts/user/index.d.ts.map +1 -0
  195. package/build/ts/user/index.js +17 -0
  196. package/build/ts/user/index.js.map +1 -0
  197. package/build/ts/user/joinPoll.d.ts +8 -0
  198. package/build/ts/user/joinPoll.d.ts.map +1 -0
  199. package/build/ts/user/joinPoll.js +84 -0
  200. package/build/ts/user/joinPoll.js.map +1 -0
  201. package/build/ts/user/signup.d.ts +20 -0
  202. package/build/ts/user/signup.d.ts.map +1 -0
  203. package/build/ts/user/signup.js +79 -0
  204. package/build/ts/user/signup.js.map +1 -0
  205. package/build/ts/user/types.d.ts +464 -0
  206. package/build/ts/user/types.d.ts.map +1 -0
  207. package/build/ts/user/types.js +3 -0
  208. package/build/ts/user/types.js.map +1 -0
  209. package/build/ts/user/utils.d.ts +80 -0
  210. package/build/ts/user/utils.d.ts.map +1 -0
  211. package/build/ts/user/utils.js +253 -0
  212. package/build/ts/user/utils.js.map +1 -0
  213. package/build/ts/utils/cid.d.ts +23 -0
  214. package/build/ts/utils/cid.d.ts.map +1 -0
  215. package/build/ts/utils/cid.js +72 -0
  216. package/build/ts/utils/cid.js.map +1 -0
  217. package/build/ts/utils/constants.d.ts +2 -0
  218. package/build/ts/utils/constants.d.ts.map +1 -0
  219. package/build/ts/utils/constants.js +5 -0
  220. package/build/ts/utils/constants.js.map +1 -0
  221. package/build/ts/utils/contracts.d.ts +15 -0
  222. package/build/ts/utils/contracts.d.ts.map +1 -0
  223. package/build/ts/utils/contracts.js +26 -0
  224. package/build/ts/utils/contracts.js.map +1 -0
  225. package/build/ts/utils/files.d.ts +9 -0
  226. package/build/ts/utils/files.d.ts.map +1 -0
  227. package/build/ts/utils/files.js +20 -0
  228. package/build/ts/utils/files.js.map +1 -0
  229. package/build/ts/utils/formatting.d.ts +8 -0
  230. package/build/ts/utils/formatting.d.ts.map +1 -0
  231. package/build/ts/utils/formatting.js +11 -0
  232. package/build/ts/utils/formatting.js.map +1 -0
  233. package/build/ts/utils/fundWallet.d.ts +7 -0
  234. package/build/ts/utils/fundWallet.d.ts.map +1 -0
  235. package/build/ts/utils/fundWallet.js +20 -0
  236. package/build/ts/utils/fundWallet.js.map +1 -0
  237. package/build/ts/utils/index.d.ts +12 -0
  238. package/build/ts/utils/index.d.ts.map +1 -0
  239. package/build/ts/utils/index.js +28 -0
  240. package/build/ts/utils/index.js.map +1 -0
  241. package/build/ts/utils/params.d.ts +7 -0
  242. package/build/ts/utils/params.d.ts.map +1 -0
  243. package/build/ts/utils/params.js +19 -0
  244. package/build/ts/utils/params.js.map +1 -0
  245. package/build/ts/utils/proofs.d.ts +13 -0
  246. package/build/ts/utils/proofs.d.ts.map +1 -0
  247. package/build/ts/utils/proofs.js +41 -0
  248. package/build/ts/utils/proofs.js.map +1 -0
  249. package/build/ts/utils/timeTravel.d.ts +7 -0
  250. package/build/ts/utils/timeTravel.d.ts.map +1 -0
  251. package/build/ts/utils/timeTravel.js +14 -0
  252. package/build/ts/utils/timeTravel.js.map +1 -0
  253. package/build/ts/utils/trees.d.ts +13 -0
  254. package/build/ts/utils/trees.d.ts.map +1 -0
  255. package/build/ts/utils/trees.js +30 -0
  256. package/build/ts/utils/trees.js.map +1 -0
  257. package/build/ts/utils/types.d.ts +71 -0
  258. package/build/ts/utils/types.d.ts.map +1 -0
  259. package/build/ts/utils/types.js +3 -0
  260. package/build/ts/utils/types.js.map +1 -0
  261. package/build/ts/utils/utils.d.ts +24 -0
  262. package/build/ts/utils/utils.d.ts.map +1 -0
  263. package/build/ts/utils/utils.js +49 -0
  264. package/build/ts/utils/utils.js.map +1 -0
  265. package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +10 -0
  266. package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -0
  267. package/build/ts/verifyingKeys/checkVerifyingKeys.js +66 -0
  268. package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -0
  269. package/build/ts/verifyingKeys/index.d.ts +5 -0
  270. package/build/ts/verifyingKeys/index.d.ts.map +1 -0
  271. package/build/ts/verifyingKeys/index.js +13 -0
  272. package/build/ts/verifyingKeys/index.js.map +1 -0
  273. package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +7 -0
  274. package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -0
  275. package/build/ts/verifyingKeys/setVerifyingKeys.js +84 -0
  276. package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -0
  277. package/build/ts/verifyingKeys/types.d.ts +235 -0
  278. package/build/ts/verifyingKeys/types.d.ts.map +1 -0
  279. package/build/ts/verifyingKeys/types.js +3 -0
  280. package/build/ts/verifyingKeys/types.js.map +1 -0
  281. package/build/ts/verifyingKeys/utils.d.ts +29 -0
  282. package/build/ts/verifyingKeys/utils.d.ts.map +1 -0
  283. package/build/ts/verifyingKeys/utils.js +116 -0
  284. package/build/ts/verifyingKeys/utils.js.map +1 -0
  285. package/build/ts/vote/generate.d.ts +8 -0
  286. package/build/ts/vote/generate.d.ts.map +1 -0
  287. package/build/ts/vote/generate.js +46 -0
  288. package/build/ts/vote/generate.js.map +1 -0
  289. package/build/ts/vote/index.d.ts +6 -0
  290. package/build/ts/vote/index.d.ts.map +1 -0
  291. package/build/ts/vote/index.js +15 -0
  292. package/build/ts/vote/index.js.map +1 -0
  293. package/build/ts/vote/invalidate.d.ts +13 -0
  294. package/build/ts/vote/invalidate.d.ts.map +1 -0
  295. package/build/ts/vote/invalidate.js +44 -0
  296. package/build/ts/vote/invalidate.js.map +1 -0
  297. package/build/ts/vote/publish.d.ts +14 -0
  298. package/build/ts/vote/publish.d.ts.map +1 -0
  299. package/build/ts/vote/publish.js +88 -0
  300. package/build/ts/vote/publish.js.map +1 -0
  301. package/build/ts/vote/submit.d.ts +13 -0
  302. package/build/ts/vote/submit.d.ts.map +1 -0
  303. package/build/ts/vote/submit.js +36 -0
  304. package/build/ts/vote/submit.js.map +1 -0
  305. package/build/ts/vote/types.d.ts +238 -0
  306. package/build/ts/vote/types.d.ts.map +1 -0
  307. package/build/ts/vote/types.js +3 -0
  308. package/build/ts/vote/types.js.map +1 -0
  309. package/build/ts/vote/utils.d.ts +16 -0
  310. package/build/ts/vote/utils.d.ts.map +1 -0
  311. package/build/ts/vote/utils.js +26 -0
  312. package/build/ts/vote/utils.js.map +1 -0
  313. package/build/tsconfig.build.tsbuildinfo +1 -0
  314. package/package.json +66 -0
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPollJoiningCircuitEvents = exports.generateMaciStateTreeWithEndKey = exports.generateMaciStateTree = exports.getPollJoiningCircuitInputsFromStateFile = exports.joiningCircuitInputs = exports.getStateIndex = exports.parseSignupEvents = exports.hasUserJoinedPoll = exports.getJoinedUserData = exports.parsePollJoinEvents = void 0;
7
+ const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
8
+ const core_1 = require("@maci-protocol/core");
9
+ const crypto_1 = require("@maci-protocol/crypto");
10
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const stateTree_1 = require("../trees/stateTree");
13
+ const constants_1 = require("../utils/constants");
14
+ /**
15
+ * Parse the poll joining events from the Poll contract
16
+ */
17
+ const parsePollJoinEvents = async ({ pollContract, startBlock, currentBlock, pollPublicKey, }) => {
18
+ for (let block = startBlock; block <= currentBlock; block += constants_1.BLOCKS_STEP) {
19
+ const toBlock = Math.min(block + constants_1.BLOCKS_STEP - 1, currentBlock);
20
+ const publicKey = pollPublicKey.asArray();
21
+ // eslint-disable-next-line no-await-in-loop
22
+ const newEvents = await pollContract.queryFilter(pollContract.filters.PollJoined(publicKey[0], publicKey[1], undefined, undefined, undefined), block, toBlock);
23
+ if (newEvents.length > 0) {
24
+ const [event] = newEvents;
25
+ return {
26
+ pollStateIndex: event.args[4].toString(),
27
+ voiceCredits: event.args[2].toString(),
28
+ };
29
+ }
30
+ }
31
+ return {
32
+ pollStateIndex: undefined,
33
+ voiceCredits: undefined,
34
+ };
35
+ };
36
+ exports.parsePollJoinEvents = parsePollJoinEvents;
37
+ /**
38
+ * Checks if user is joined to a poll with their public key and get its data
39
+ * @param {IJoinedUserArgs} - The arguments for the join check command
40
+ * @returns user joined or not and poll state index, voice credit balance
41
+ */
42
+ const getJoinedUserData = async ({ maciAddress, pollId, pollPublicKey: serializedPollPublicKey, signer, startBlock, }) => {
43
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
44
+ const pollContracts = await maciContract.getPoll(pollId);
45
+ const pollContract = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer);
46
+ const pollPublicKey = domainobjs_1.PublicKey.deserialize(serializedPollPublicKey);
47
+ const startBlockNumber = startBlock || 0;
48
+ const currentBlock = await signer.provider.getBlockNumber();
49
+ const { pollStateIndex, voiceCredits } = await (0, exports.parsePollJoinEvents)({
50
+ pollContract,
51
+ startBlock: startBlockNumber,
52
+ currentBlock,
53
+ pollPublicKey,
54
+ });
55
+ return {
56
+ isJoined: pollStateIndex !== undefined,
57
+ pollStateIndex,
58
+ voiceCredits,
59
+ };
60
+ };
61
+ exports.getJoinedUserData = getJoinedUserData;
62
+ /**
63
+ * Checks if a user joined a poll with a given nullifier
64
+ * @param {IIsNullifierOnChainArgs} args - The arguments for the is nullifier on chain command
65
+ * @returns whether the nullifier is on chain or not
66
+ */
67
+ const hasUserJoinedPoll = async ({ maciAddress, pollId, nullifier, signer, }) => {
68
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
69
+ const pollContracts = await maciContract.getPoll(pollId);
70
+ const pollContract = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer);
71
+ return pollContract.pollNullifiers(nullifier);
72
+ };
73
+ exports.hasUserJoinedPoll = hasUserJoinedPoll;
74
+ /**
75
+ * Parse the signup events from the MACI contract
76
+ */
77
+ const parseSignupEvents = async ({ maciContract, startBlock, currentBlock, publicKey, }) => {
78
+ for (let block = startBlock; block <= currentBlock; block += constants_1.BLOCKS_STEP) {
79
+ const toBlock = Math.min(block + constants_1.BLOCKS_STEP - 1, currentBlock);
80
+ // eslint-disable-next-line no-await-in-loop
81
+ const newEvents = await maciContract.queryFilter(maciContract.filters.SignUp(undefined, undefined, publicKey.raw[0], publicKey.raw[1]), block, toBlock);
82
+ if (newEvents.length > 0) {
83
+ const [event] = newEvents;
84
+ return {
85
+ stateIndex: event.args[0].toString(),
86
+ };
87
+ }
88
+ }
89
+ return {
90
+ stateIndex: undefined,
91
+ };
92
+ };
93
+ exports.parseSignupEvents = parseSignupEvents;
94
+ /**
95
+ * Get state index from maci state leaves or from sign up leaves
96
+ * @param publicKeys Public keys from maci state or sign up tree
97
+ * @param userMaciPublicKey Public key of the maci user
98
+ * @param stateIndex State index from the command
99
+ * @returns State index
100
+ */
101
+ const getStateIndex = (publicKeys, userMaciPublicKey, stateIndex) => {
102
+ if (!stateIndex) {
103
+ const index = publicKeys.findIndex((key) => key.equals(userMaciPublicKey));
104
+ if (index > 0) {
105
+ return BigInt(index);
106
+ }
107
+ throw new Error("MACI Public key not found");
108
+ }
109
+ return stateIndex;
110
+ };
111
+ exports.getStateIndex = getStateIndex;
112
+ /**
113
+ * Create circuit input for pollJoining
114
+ * @param signUpData Sign up tree and state leaves
115
+ * @param stateTreeDepth Maci state tree depth
116
+ * @param maciPrivateKey User's private key for signing up
117
+ * @param pollPrivateKey Poll's private key for the poll joining
118
+ * @param pollPublicKey Poll's public key for the poll joining
119
+ * @param pollId Poll's id
120
+ * @returns stringified circuit inputs
121
+ */
122
+ const joiningCircuitInputs = (inclusionProof, stateTreeDepth, maciPrivateKey, pollPublicKey, pollId) => {
123
+ // calculate the path elements for the state tree given the original state tree
124
+ const { siblings, index, root: stateRoot } = inclusionProof;
125
+ const siblingsLength = siblings.length;
126
+ // The index must be converted to a list of indices, 1 for each tree level.
127
+ // The circuit tree depth is this.stateTreeDepth, so the number of siblings must be this.stateTreeDepth,
128
+ // even if the tree depth is actually 3. The missing siblings can be set to 0, as they
129
+ // won't be used to calculate the root in the circuit.
130
+ const indices = [];
131
+ for (let i = 0; i < stateTreeDepth; i += 1) {
132
+ // eslint-disable-next-line no-bitwise
133
+ indices.push(BigInt((index >> i) & 1));
134
+ if (i >= siblingsLength) {
135
+ siblings[i] = BigInt(0);
136
+ }
137
+ }
138
+ const siblingsArray = siblings.map((sibling) => [sibling]);
139
+ // Create nullifier from private key
140
+ const inputNullifier = BigInt(maciPrivateKey.asCircuitInputs());
141
+ const nullifier = (0, crypto_1.poseidon)([inputNullifier, pollId]);
142
+ // Set actualStateTreeDepth as number of initial siblings length
143
+ const actualStateTreeDepth = BigInt(siblingsLength);
144
+ // Calculate public input hash from nullifier, credits and current root
145
+ const circuitInputs = {
146
+ privateKey: maciPrivateKey.asCircuitInputs(),
147
+ pollPublicKey: pollPublicKey.asCircuitInputs(),
148
+ siblings: siblingsArray,
149
+ indices,
150
+ nullifier,
151
+ stateRoot,
152
+ actualStateTreeDepth,
153
+ pollId,
154
+ };
155
+ return (0, crypto_1.stringifyBigInts)(circuitInputs);
156
+ };
157
+ exports.joiningCircuitInputs = joiningCircuitInputs;
158
+ /**
159
+ * Get the poll joining circuit inputs from a state file
160
+ * @param stateFile - The path to the state file
161
+ * @returns The poll joining circuit inputs
162
+ */
163
+ const getPollJoiningCircuitInputsFromStateFile = async ({ stateFile, pollId, stateIndex, userMaciPrivateKey, }) => {
164
+ const file = await fs_1.default.promises.readFile(stateFile);
165
+ const content = JSON.parse(file.toString());
166
+ const maciState = core_1.MaciState.fromJSON(content);
167
+ const poll = maciState.polls.get(pollId);
168
+ const { publicKey: userPublicKey } = new domainobjs_1.Keypair(userMaciPrivateKey);
169
+ const loadedStateIndex = (0, exports.getStateIndex)(maciState.publicKeys, userPublicKey, stateIndex);
170
+ // check < 1 cause index zero is a blank state leaf
171
+ if (loadedStateIndex < 1) {
172
+ throw new Error("Invalid state index");
173
+ }
174
+ poll.updatePoll(BigInt(maciState.publicKeys.length));
175
+ const circuitInputs = poll.joiningCircuitInputs({
176
+ maciPrivateKey: userMaciPrivateKey,
177
+ stateLeafIndex: stateIndex,
178
+ pollPublicKey: userPublicKey,
179
+ });
180
+ return circuitInputs;
181
+ };
182
+ exports.getPollJoiningCircuitInputsFromStateFile = getPollJoiningCircuitInputsFromStateFile;
183
+ /**
184
+ * Generate MACI's state tree from the MACI contract
185
+ * @param {IGenerateMaciStateTreeArgs} args - The arguments for the generate maci state tree command
186
+ * @returns The MACI's state tree
187
+ */
188
+ const generateMaciStateTree = async ({ maciContract, signer, startBlock, endBlock, blocksPerBatch, }) => {
189
+ // build an off-chain representation of the MACI contract using data in the contract storage
190
+ const defaultStartBlock = await maciContract
191
+ .queryFilter(maciContract.filters.SignUp(), startBlock ?? 0)
192
+ .then((events) => events[0]?.blockNumber ?? 0);
193
+ const fromBlock = startBlock ? Number(startBlock) : defaultStartBlock;
194
+ return (0, stateTree_1.generateSignUpTree)({
195
+ provider: signer.provider,
196
+ address: await maciContract.getAddress(),
197
+ blocksPerRequest: blocksPerBatch || 50,
198
+ fromBlock,
199
+ endBlock,
200
+ sleepAmount: 0,
201
+ });
202
+ };
203
+ exports.generateMaciStateTree = generateMaciStateTree;
204
+ /**
205
+ * Generate MACI's state tree from the MACI contract with a given end key
206
+ * @param {IGenerateMaciStateTreeWithEndKeyArgs} args - The arguments for the generate maci state tree command
207
+ * @returns The MACI's state tree
208
+ */
209
+ const generateMaciStateTreeWithEndKey = async ({ maciContract, signer, startBlock, endBlock, blocksPerBatch, userPublicKey, }) => {
210
+ // build an off-chain representation of the MACI contract using data in the contract storage
211
+ const defaultStartBlock = await maciContract
212
+ .queryFilter(maciContract.filters.SignUp(), startBlock ?? 0)
213
+ .then((events) => events[0]?.blockNumber ?? 0);
214
+ const fromBlock = startBlock ? Number(startBlock) : defaultStartBlock;
215
+ return (0, stateTree_1.generateSignUpTreeWithEndKey)({
216
+ provider: signer.provider,
217
+ address: await maciContract.getAddress(),
218
+ blocksPerRequest: blocksPerBatch || 50,
219
+ fromBlock,
220
+ endBlock,
221
+ userPublicKey,
222
+ });
223
+ };
224
+ exports.generateMaciStateTreeWithEndKey = generateMaciStateTreeWithEndKey;
225
+ /**
226
+ * Get the poll joining circuit events from a state file
227
+ * @param maciContract - The MACI contract
228
+ * @param startBlock - The start block
229
+ * @param signer - The signer
230
+ * @returns The poll joining circuit events
231
+ */
232
+ const getPollJoiningCircuitEvents = async ({ maciContract, stateIndex, pollId, userMaciPrivateKey, signer, startBlock, endBlock, blocksPerBatch, }) => {
233
+ const stateTreeDepth = await maciContract.stateTreeDepth();
234
+ const signUpData = await (0, exports.generateMaciStateTree)({
235
+ maciContract,
236
+ signer,
237
+ startBlock,
238
+ endBlock,
239
+ blocksPerBatch,
240
+ });
241
+ const { publicKey: userPublicKey } = new domainobjs_1.Keypair(userMaciPrivateKey);
242
+ const loadedStateIndex = (0, exports.getStateIndex)(signUpData.publicKeys, userPublicKey, stateIndex);
243
+ if (loadedStateIndex < 1) {
244
+ throw new Error("Invalid state index");
245
+ }
246
+ // Get the state leaf on the index position
247
+ const { signUpTree: stateTree } = signUpData;
248
+ // calculate the path elements for the state tree given the original state tree
249
+ const inclusionProof = stateTree.generateProof(Number(loadedStateIndex));
250
+ return (0, exports.joiningCircuitInputs)(inclusionProof, stateTreeDepth, userMaciPrivateKey, userPublicKey, pollId);
251
+ };
252
+ exports.getPollJoiningCircuitEvents = getPollJoiningCircuitEvents;
253
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":";;;;;;AAAA,8EAAsH;AACtH,8CAAgE;AAChE,kDAAmE;AACnE,0DAA2E;AAE3E,4CAAo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d,kBAAkB,EAClB,aAAa,EACb,MAAM,CACsB,CAAC;AACjC,CAAC,CAAC;AAxCW,QAAA,2BAA2B,+BAwCtC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Converts an IPFS CIDv1 to a bytes32-compatible hex string.
3
+ *
4
+ * This function:
5
+ * - Decodes the Base32-encoded CIDv1
6
+ * - Extracts the SHA-256 digest from the multihash
7
+ * - Converts it to a Solidity-compatible `bytes32` format
8
+ *
9
+ * @param hash - The CIDv1 string
10
+ * @returns A `bytes32`-compatible hex string (e.g., `0x...`)
11
+ */
12
+ export declare const cidToBytes32: (hash: string) => Promise<string>;
13
+ /**
14
+ * Creates a CID (Content Identifier) from an object by encoding the object into JSON and
15
+ * hashing it using the SHA-256 algorithm, and then creating a CID using the Multiformats CID library.
16
+ *
17
+ * @template T
18
+ * @param {T} data The input object to be encoded and hashed to generate the CID.
19
+ * @returns A CID generated from the hashed JSON-encoded object.
20
+ *
21
+ */
22
+ export declare const createCidFromObject: <T>(data: T) => Promise<string>;
23
+ //# sourceMappingURL=cid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../../../ts/utils/cid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,MAAM,CAI/D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAU,CAAC,EAAE,MAAM,CAAC,KAAG,OAAO,CAAC,MAAM,CAUpE,CAAC"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createCidFromObject = exports.cidToBytes32 = void 0;
37
+ /**
38
+ * Converts an IPFS CIDv1 to a bytes32-compatible hex string.
39
+ *
40
+ * This function:
41
+ * - Decodes the Base32-encoded CIDv1
42
+ * - Extracts the SHA-256 digest from the multihash
43
+ * - Converts it to a Solidity-compatible `bytes32` format
44
+ *
45
+ * @param hash - The CIDv1 string
46
+ * @returns A `bytes32`-compatible hex string (e.g., `0x...`)
47
+ */
48
+ const cidToBytes32 = async (hash) => {
49
+ const [{ CID }, { ethers }] = await Promise.all([Promise.resolve().then(() => __importStar(require("multiformats/cid"))), Promise.resolve().then(() => __importStar(require("ethers")))]);
50
+ return ethers.hexlify(CID.parse(hash).multihash.digest);
51
+ };
52
+ exports.cidToBytes32 = cidToBytes32;
53
+ /**
54
+ * Creates a CID (Content Identifier) from an object by encoding the object into JSON and
55
+ * hashing it using the SHA-256 algorithm, and then creating a CID using the Multiformats CID library.
56
+ *
57
+ * @template T
58
+ * @param {T} data The input object to be encoded and hashed to generate the CID.
59
+ * @returns A CID generated from the hashed JSON-encoded object.
60
+ *
61
+ */
62
+ const createCidFromObject = async (data) => {
63
+ const [{ CID }, json, { sha256 }] = await Promise.all([
64
+ Promise.resolve().then(() => __importStar(require("multiformats/cid"))),
65
+ Promise.resolve().then(() => __importStar(require("multiformats/codecs/json"))),
66
+ Promise.resolve().then(() => __importStar(require("multiformats/hashes/sha2"))),
67
+ ]);
68
+ const hash = await sha256.digest(json.encode(data));
69
+ return CID.create(1, json.code, hash).toString();
70
+ };
71
+ exports.createCidFromObject = createCidFromObject;
72
+ //# sourceMappingURL=cid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cid.js","sourceRoot":"","sources":["../../../ts/utils/cid.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACI,MAAM,YAAY,GAAG,KAAK,EAAE,IAAY,EAAmB,EAAE;IAClE,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,mDAAQ,kBAAkB,uDAAU,QAAQ,IAAE,CAAC,CAAC;IAEhG,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC1D,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB;AAEF;;;;;;;;GAQG;AACI,MAAM,mBAAmB,GAAG,KAAK,EAAK,IAAO,EAAmB,EAAE;IACvE,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;0DAC7C,kBAAkB;0DAClB,0BAA0B;0DAC1B,0BAA0B;KAClC,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAEpD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;AACnD,CAAC,CAAC;AAVW,QAAA,mBAAmB,uBAU9B"}
@@ -0,0 +1,2 @@
1
+ export declare const BLOCKS_STEP = 1000;
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../ts/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,OAAO,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BLOCKS_STEP = void 0;
4
+ exports.BLOCKS_STEP = 1000;
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../ts/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,IAAI,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Provider } from "ethers";
2
+ /**
3
+ * Small utility function to check whether a contract exists at a given address
4
+ * @param provider - the provider to use to interact with the chain
5
+ * @param address - the address of the contract to check
6
+ * @returns a boolean indicating whether the contract exists
7
+ */
8
+ export declare const contractExists: (provider: Provider, address: string) => Promise<boolean>;
9
+ /**
10
+ * Small utility to retrieve the current block timestamp from the blockchain
11
+ * @param provider the provider to use to interact with the chain
12
+ * @returns the current block timestamp
13
+ */
14
+ export declare const currentBlockTimestamp: (provider: Provider) => Promise<number>;
15
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../ts/utils/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAU,UAAU,QAAQ,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,OAAO,CAGzF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAU,UAAU,QAAQ,KAAG,OAAO,CAAC,MAAM,CAK9E,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.currentBlockTimestamp = exports.contractExists = void 0;
4
+ /**
5
+ * Small utility function to check whether a contract exists at a given address
6
+ * @param provider - the provider to use to interact with the chain
7
+ * @param address - the address of the contract to check
8
+ * @returns a boolean indicating whether the contract exists
9
+ */
10
+ const contractExists = async (provider, address) => {
11
+ const code = await provider.getCode(address);
12
+ return code.length > 2;
13
+ };
14
+ exports.contractExists = contractExists;
15
+ /**
16
+ * Small utility to retrieve the current block timestamp from the blockchain
17
+ * @param provider the provider to use to interact with the chain
18
+ * @returns the current block timestamp
19
+ */
20
+ const currentBlockTimestamp = async (provider) => {
21
+ const blockNum = await provider.getBlockNumber();
22
+ const block = await provider.getBlock(blockNum);
23
+ return Number(block?.timestamp);
24
+ };
25
+ exports.currentBlockTimestamp = currentBlockTimestamp;
26
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../ts/utils/contracts.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACI,MAAM,cAAc,GAAG,KAAK,EAAE,QAAkB,EAAE,OAAe,EAAoB,EAAE;IAC5F,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB;AAEF;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,KAAK,EAAE,QAAkB,EAAmB,EAAE;IACjF,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,cAAc,EAAE,CAAC;IACjD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAClC,CAAC,CAAC;AALW,QAAA,qBAAqB,yBAKhC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Check if an array of paths exist on the local file system
3
+ * @param paths - the array of paths to check
4
+ * @returns an array of boolean and string,
5
+ * where the boolean indicates whether all paths exist, and the string
6
+ * is the path that does not exist
7
+ */
8
+ export declare const doesPathExist: (paths: string[]) => [boolean, string | null];
9
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../ts/utils/files.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,KAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAItE,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.doesPathExist = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ /**
9
+ * Check if an array of paths exist on the local file system
10
+ * @param paths - the array of paths to check
11
+ * @returns an array of boolean and string,
12
+ * where the boolean indicates whether all paths exist, and the string
13
+ * is the path that does not exist
14
+ */
15
+ const doesPathExist = (paths) => {
16
+ const notFoundPath = paths.find((path) => !fs_1.default.existsSync(path));
17
+ return notFoundPath ? [false, notFoundPath] : [true, null];
18
+ };
19
+ exports.doesPathExist = doesPathExist;
20
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../../ts/utils/files.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEpB;;;;;;GAMG;AACI,MAAM,aAAa,GAAG,CAAC,KAAe,EAA4B,EAAE;IACzE,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhE,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC,CAAC;AAJW,QAAA,aAAa,iBAIxB"}
@@ -0,0 +1,8 @@
1
+ import type { BigNumberish } from "ethers";
2
+ /**
3
+ * Convert a value to its hex representation
4
+ * @param val - the value to convert
5
+ * @returns the value converted as a hex string
6
+ */
7
+ export declare const asHex: (val: BigNumberish) => string;
8
+ //# sourceMappingURL=formatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../ts/utils/formatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,YAAY,KAAG,MAAyC,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asHex = void 0;
4
+ /**
5
+ * Convert a value to its hex representation
6
+ * @param val - the value to convert
7
+ * @returns the value converted as a hex string
8
+ */
9
+ const asHex = (val) => `0x${BigInt(val).toString(16)}`;
10
+ exports.asHex = asHex;
11
+ //# sourceMappingURL=formatting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.js","sourceRoot":"","sources":["../../../ts/utils/formatting.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACI,MAAM,KAAK,GAAG,CAAC,GAAiB,EAAU,EAAE,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAAvE,QAAA,KAAK,SAAkE"}
@@ -0,0 +1,7 @@
1
+ import type { IFundWalletArgs } from "./types";
2
+ /**
3
+ * Fund a new wallet with Ether
4
+ * @param args Fund wallet arguments
5
+ */
6
+ export declare const fundWallet: ({ amount, address, signer }: IFundWalletArgs) => Promise<string>;
7
+ //# sourceMappingURL=fundWallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fundWallet.d.ts","sourceRoot":"","sources":["../../../ts/utils/fundWallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAU,6BAA6B,eAAe,KAAG,OAAO,CAAC,MAAM,CAY7F,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fundWallet = void 0;
4
+ /**
5
+ * Fund a new wallet with Ether
6
+ * @param args Fund wallet arguments
7
+ */
8
+ const fundWallet = async ({ amount, address, signer }) => {
9
+ const tx = await signer.sendTransaction({
10
+ to: address,
11
+ value: amount.toString(),
12
+ });
13
+ const receipt = await tx.wait();
14
+ if (receipt?.status !== 1) {
15
+ throw new Error("Transaction failed");
16
+ }
17
+ return receipt.hash;
18
+ };
19
+ exports.fundWallet = fundWallet;
20
+ //# sourceMappingURL=fundWallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fundWallet.js","sourceRoot":"","sources":["../../../ts/utils/fundWallet.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAmB,EAAmB,EAAE;IAChG,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC;QACtC,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE;KACzB,CAAC,CAAC;IACH,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,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC,CAAC;AAZW,QAAA,UAAU,cAYrB"}
@@ -0,0 +1,12 @@
1
+ export { cidToBytes32, createCidFromObject } from "./cid";
2
+ export { BLOCKS_STEP } from "./constants";
3
+ export { contractExists, currentBlockTimestamp } from "./contracts";
4
+ export { asHex } from "./formatting";
5
+ export { fundWallet } from "./fundWallet";
6
+ export { validateParams } from "./params";
7
+ export { timeTravel } from "./timeTravel";
8
+ export { calculateBinaryTreeDepthFromMaxLeaves, calculateQuinTreeDepthFromMaxLeaves } from "./trees";
9
+ export { isArm, sleep } from "./utils";
10
+ export { generateAndVerifyProof } from "./proofs";
11
+ export type { ICircuitParams, ISnarkJSVerificationKey, ITimeTravelArgs, IFundWalletArgs } from "./types";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,qCAAqC,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AACrG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,YAAY,EAAE,cAAc,EAAE,uBAAuB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateAndVerifyProof = exports.sleep = exports.isArm = exports.calculateQuinTreeDepthFromMaxLeaves = exports.calculateBinaryTreeDepthFromMaxLeaves = exports.timeTravel = exports.validateParams = exports.fundWallet = exports.asHex = exports.currentBlockTimestamp = exports.contractExists = exports.BLOCKS_STEP = exports.createCidFromObject = exports.cidToBytes32 = void 0;
4
+ var cid_1 = require("./cid");
5
+ Object.defineProperty(exports, "cidToBytes32", { enumerable: true, get: function () { return cid_1.cidToBytes32; } });
6
+ Object.defineProperty(exports, "createCidFromObject", { enumerable: true, get: function () { return cid_1.createCidFromObject; } });
7
+ var constants_1 = require("./constants");
8
+ Object.defineProperty(exports, "BLOCKS_STEP", { enumerable: true, get: function () { return constants_1.BLOCKS_STEP; } });
9
+ var contracts_1 = require("./contracts");
10
+ Object.defineProperty(exports, "contractExists", { enumerable: true, get: function () { return contracts_1.contractExists; } });
11
+ Object.defineProperty(exports, "currentBlockTimestamp", { enumerable: true, get: function () { return contracts_1.currentBlockTimestamp; } });
12
+ var formatting_1 = require("./formatting");
13
+ Object.defineProperty(exports, "asHex", { enumerable: true, get: function () { return formatting_1.asHex; } });
14
+ var fundWallet_1 = require("./fundWallet");
15
+ Object.defineProperty(exports, "fundWallet", { enumerable: true, get: function () { return fundWallet_1.fundWallet; } });
16
+ var params_1 = require("./params");
17
+ Object.defineProperty(exports, "validateParams", { enumerable: true, get: function () { return params_1.validateParams; } });
18
+ var timeTravel_1 = require("./timeTravel");
19
+ Object.defineProperty(exports, "timeTravel", { enumerable: true, get: function () { return timeTravel_1.timeTravel; } });
20
+ var trees_1 = require("./trees");
21
+ Object.defineProperty(exports, "calculateBinaryTreeDepthFromMaxLeaves", { enumerable: true, get: function () { return trees_1.calculateBinaryTreeDepthFromMaxLeaves; } });
22
+ Object.defineProperty(exports, "calculateQuinTreeDepthFromMaxLeaves", { enumerable: true, get: function () { return trees_1.calculateQuinTreeDepthFromMaxLeaves; } });
23
+ var utils_1 = require("./utils");
24
+ Object.defineProperty(exports, "isArm", { enumerable: true, get: function () { return utils_1.isArm; } });
25
+ Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return utils_1.sleep; } });
26
+ var proofs_1 = require("./proofs");
27
+ Object.defineProperty(exports, "generateAndVerifyProof", { enumerable: true, get: function () { return proofs_1.generateAndVerifyProof; } });
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/utils/index.ts"],"names":[],"mappings":";;;AAAA,6BAA0D;AAAjD,mGAAA,YAAY,OAAA;AAAE,0GAAA,mBAAmB,OAAA;AAC1C,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AACpB,yCAAoE;AAA3D,2GAAA,cAAc,OAAA;AAAE,kHAAA,qBAAqB,OAAA;AAC9C,2CAAqC;AAA5B,mGAAA,KAAK,OAAA;AACd,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AACvB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,iCAAqG;AAA5F,8HAAA,qCAAqC,OAAA;AAAE,4HAAA,mCAAmC,OAAA;AACnF,iCAAuC;AAA9B,8FAAA,KAAK,OAAA;AAAE,8FAAA,KAAK,OAAA;AACrB,mCAAkD;AAAzC,gHAAA,sBAAsB,OAAA"}
@@ -0,0 +1,7 @@
1
+ import type { ICircuitParams } from "./types";
2
+ /**
3
+ * Validate the circuit parameters
4
+ * @param params - The circuit parameters
5
+ */
6
+ export declare const validateParams: ({ stateTreeDepth, tallyProcessingStateTreeDepth, voteOptionTreeDepth, messageBatchSize, }: ICircuitParams) => boolean;
7
+ //# sourceMappingURL=params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../ts/utils/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,2FAK5B,cAAc,KAAG,OAWnB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateParams = void 0;
4
+ /**
5
+ * Validate the circuit parameters
6
+ * @param params - The circuit parameters
7
+ */
8
+ const validateParams = ({ stateTreeDepth, tallyProcessingStateTreeDepth, voteOptionTreeDepth, messageBatchSize, }) => {
9
+ // validate args
10
+ if (stateTreeDepth < 1 || tallyProcessingStateTreeDepth < 1 || voteOptionTreeDepth < 1 || messageBatchSize < 1) {
11
+ throw new Error("Invalid depth or batch size parameters");
12
+ }
13
+ if (stateTreeDepth < tallyProcessingStateTreeDepth) {
14
+ throw new Error("Invalid state tree depth or intermediate state tree depth");
15
+ }
16
+ return true;
17
+ };
18
+ exports.validateParams = validateParams;
19
+ //# sourceMappingURL=params.js.map