@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,68 @@
1
+ import { PrivKey, PubKey } from "@maci-protocol/domainobjs";
2
+ import type { IGetPollJoiningCircuitEventsArgs, IGetPollJoiningCircuitInputsFromStateFileArgs, IParsePollJoinEventsArgs, IParseSignupEventsArgs, IPollJoiningCircuitInputs, IJoinedUserArgs, IIsNullifierOnChainArgs } from "./types";
3
+ import type { IGenerateSignUpTree } from "../trees/types";
4
+ import type { CircuitInputs } from "../utils/types";
5
+ /**
6
+ * Parse the poll joining events from the Poll contract
7
+ */
8
+ export declare const parsePollJoinEvents: ({ pollContract, startBlock, currentBlock, pollPublicKey, }: IParsePollJoinEventsArgs) => Promise<{
9
+ pollStateIndex?: string;
10
+ voiceCredits?: string;
11
+ }>;
12
+ /**
13
+ * Checks if user is joined to a poll with their public key and get its data
14
+ * @param {IJoinedUserArgs} - The arguments for the join check command
15
+ * @returns user joined or not and poll state index, voice credit balance
16
+ */
17
+ export declare const getJoinedUserData: ({ maciAddress, pollId, pollPubKey, signer, startBlock, }: IJoinedUserArgs) => Promise<{
18
+ isJoined: boolean;
19
+ pollStateIndex?: string;
20
+ voiceCredits?: string;
21
+ }>;
22
+ /**
23
+ * Checks if a user joined a poll with a given nullifier
24
+ * @param {IIsNullifierOnChainArgs} args - The arguments for the is nullifier on chain command
25
+ * @returns whether the nullifier is on chain or not
26
+ */
27
+ export declare const hasUserJoinedPoll: ({ maciAddress, pollId, nullifier, signer, }: IIsNullifierOnChainArgs) => Promise<boolean>;
28
+ /**
29
+ * Parse the signup events from the MACI contract
30
+ */
31
+ export declare const parseSignupEvents: ({ maciContract, startBlock, currentBlock, publicKey, }: IParseSignupEventsArgs) => Promise<{
32
+ stateIndex?: string;
33
+ }>;
34
+ /**
35
+ * Get state index from maci state leaves or from sign up leaves
36
+ * @param pubKeys Public keys from maci state or sign up tree
37
+ * @param userMaciPubKey Public key of the maci user
38
+ * @param stateIndex State index from the command
39
+ * @returns State index
40
+ */
41
+ export declare const getStateIndex: (pubKeys: PubKey[], userMaciPubKey: PubKey, stateIndex?: bigint) => bigint | undefined;
42
+ /**
43
+ * Create circuit input for pollJoining
44
+ * @param signUpData Sign up tree and state leaves
45
+ * @param stateTreeDepth Maci state tree depth
46
+ * @param maciPrivKey User's private key for signing up
47
+ * @param stateLeafIndex Index where the user is stored in the state leaves
48
+ * @param pollPrivKey Poll's private key for the poll joining
49
+ * @param pollPubKey Poll's public key for the poll joining
50
+ * @param pollId Poll's id
51
+ * @returns stringified circuit inputs
52
+ */
53
+ export declare const joiningCircuitInputs: (signUpData: IGenerateSignUpTree, stateTreeDepth: bigint, maciPrivKey: PrivKey, stateLeafIndex: bigint, pollPubKey: PubKey, pollId: bigint) => IPollJoiningCircuitInputs;
54
+ /**
55
+ * Get the poll joining circuit inputs from a state file
56
+ * @param stateFile - The path to the state file
57
+ * @returns The poll joining circuit inputs
58
+ */
59
+ export declare const getPollJoiningCircuitInputsFromStateFile: ({ stateFile, pollId, stateIndex, userMaciPrivKey, }: IGetPollJoiningCircuitInputsFromStateFileArgs) => Promise<CircuitInputs>;
60
+ /**
61
+ * Get the poll joining circuit events from a state file
62
+ * @param maciContract - The MACI contract
63
+ * @param startBlock - The start block
64
+ * @param signer - The signer
65
+ * @returns The poll joining circuit events
66
+ */
67
+ export declare const getPollJoiningCircuitEvents: ({ maciContract, stateIndex, pollId, userMaciPrivKey, signer, startBlock, endBlock, blocksPerBatch, }: IGetPollJoiningCircuitEventsArgs) => Promise<CircuitInputs>;
68
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":"AAGA,OAAO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iDF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wCAAwC,GAAU,qDAK5D,6CAA6C,KAAG,OAAO,CAAC,aAAa,CAwBvE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GAAU,sGAS/C,gCAAgC,KAAG,OAAO,CAAC,aAAa,CAsC1D,CAAC"}
@@ -0,0 +1,224 @@
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.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 pubKey = pollPublicKey.asArray();
21
+ // eslint-disable-next-line no-await-in-loop
22
+ const newEvents = await pollContract.queryFilter(pollContract.filters.PollJoined(pubKey[0], pubKey[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, pollPubKey, 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.PubKey.deserialize(pollPubKey);
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.rawPubKey[0], publicKey.rawPubKey[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 pubKeys Public keys from maci state or sign up tree
97
+ * @param userMaciPubKey Public key of the maci user
98
+ * @param stateIndex State index from the command
99
+ * @returns State index
100
+ */
101
+ const getStateIndex = (pubKeys, userMaciPubKey, stateIndex) => {
102
+ if (!stateIndex) {
103
+ const index = pubKeys.findIndex((key) => key.equals(userMaciPubKey));
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 maciPrivKey User's private key for signing up
117
+ * @param stateLeafIndex Index where the user is stored in the state leaves
118
+ * @param pollPrivKey Poll's private key for the poll joining
119
+ * @param pollPubKey Poll's public key for the poll joining
120
+ * @param pollId Poll's id
121
+ * @returns stringified circuit inputs
122
+ */
123
+ const joiningCircuitInputs = (signUpData, stateTreeDepth, maciPrivKey, stateLeafIndex, pollPubKey, pollId) => {
124
+ // Get the state leaf on the index position
125
+ const { signUpTree: stateTree } = signUpData;
126
+ // calculate the path elements for the state tree given the original state tree
127
+ const { siblings, index } = stateTree.generateProof(Number(stateLeafIndex));
128
+ const siblingsLength = siblings.length;
129
+ // The index must be converted to a list of indices, 1 for each tree level.
130
+ // The circuit tree depth is this.stateTreeDepth, so the number of siblings must be this.stateTreeDepth,
131
+ // even if the tree depth is actually 3. The missing siblings can be set to 0, as they
132
+ // won't be used to calculate the root in the circuit.
133
+ const indices = [];
134
+ for (let i = 0; i < stateTreeDepth; i += 1) {
135
+ // eslint-disable-next-line no-bitwise
136
+ indices.push(BigInt((index >> i) & 1));
137
+ if (i >= siblingsLength) {
138
+ siblings[i] = BigInt(0);
139
+ }
140
+ }
141
+ const siblingsArray = siblings.map((sibling) => [sibling]);
142
+ // Create nullifier from private key
143
+ const inputNullifier = BigInt(maciPrivKey.asCircuitInputs());
144
+ const nullifier = (0, crypto_1.poseidon)([inputNullifier, pollId]);
145
+ // Get pll state tree's root
146
+ const stateRoot = stateTree.root;
147
+ // Set actualStateTreeDepth as number of initial siblings length
148
+ const actualStateTreeDepth = BigInt(siblingsLength);
149
+ // Calculate public input hash from nullifier, credits and current root
150
+ const circuitInputs = {
151
+ privKey: maciPrivKey.asCircuitInputs(),
152
+ pollPubKey: pollPubKey.asCircuitInputs(),
153
+ siblings: siblingsArray,
154
+ indices,
155
+ nullifier,
156
+ stateRoot,
157
+ actualStateTreeDepth,
158
+ pollId,
159
+ };
160
+ return (0, crypto_1.stringifyBigInts)(circuitInputs);
161
+ };
162
+ exports.joiningCircuitInputs = joiningCircuitInputs;
163
+ /**
164
+ * Get the poll joining circuit inputs from a state file
165
+ * @param stateFile - The path to the state file
166
+ * @returns The poll joining circuit inputs
167
+ */
168
+ const getPollJoiningCircuitInputsFromStateFile = async ({ stateFile, pollId, stateIndex, userMaciPrivKey, }) => {
169
+ const file = await fs_1.default.promises.readFile(stateFile);
170
+ const content = JSON.parse(file.toString());
171
+ const maciState = core_1.MaciState.fromJSON(content);
172
+ const poll = maciState.polls.get(pollId);
173
+ const { pubKey: userPubKey } = new domainobjs_1.Keypair(userMaciPrivKey);
174
+ const loadedStateIndex = (0, exports.getStateIndex)(maciState.pubKeys, userPubKey, stateIndex);
175
+ // check < 1 cause index zero is a blank state leaf
176
+ if (loadedStateIndex < 1) {
177
+ throw new Error("Invalid state index");
178
+ }
179
+ poll.updatePoll(BigInt(maciState.pubKeys.length));
180
+ const circuitInputs = poll.joiningCircuitInputs({
181
+ maciPrivKey: userMaciPrivKey,
182
+ stateLeafIndex: stateIndex,
183
+ pollPubKey: userPubKey,
184
+ });
185
+ return circuitInputs;
186
+ };
187
+ exports.getPollJoiningCircuitInputsFromStateFile = getPollJoiningCircuitInputsFromStateFile;
188
+ /**
189
+ * Get the poll joining circuit events from a state file
190
+ * @param maciContract - The MACI contract
191
+ * @param startBlock - The start block
192
+ * @param signer - The signer
193
+ * @returns The poll joining circuit events
194
+ */
195
+ const getPollJoiningCircuitEvents = async ({ maciContract, stateIndex, pollId, userMaciPrivKey, signer, startBlock, endBlock, blocksPerBatch, }) => {
196
+ // build an off-chain representation of the MACI contract using data in the contract storage
197
+ const [defaultStartBlockSignup, defaultStartBlockPoll, stateTreeDepth] = await Promise.all([
198
+ maciContract
199
+ .queryFilter(maciContract.filters.SignUp(), startBlock ?? 0)
200
+ .then((events) => events[0]?.blockNumber ?? 0),
201
+ maciContract
202
+ .queryFilter(maciContract.filters.DeployPoll(), startBlock ?? 0)
203
+ .then((events) => events[0]?.blockNumber ?? 0),
204
+ maciContract.stateTreeDepth(),
205
+ ]);
206
+ const defaultStartBlock = Math.min(defaultStartBlockPoll, defaultStartBlockSignup);
207
+ const fromBlock = startBlock ? Number(startBlock) : defaultStartBlock;
208
+ const signUpData = await (0, stateTree_1.generateSignUpTree)({
209
+ provider: signer.provider,
210
+ address: await maciContract.getAddress(),
211
+ blocksPerRequest: blocksPerBatch || 50,
212
+ fromBlock,
213
+ endBlock,
214
+ sleepAmount: 0,
215
+ });
216
+ const { pubKey: userPubKey } = new domainobjs_1.Keypair(userMaciPrivKey);
217
+ const loadedStateIndex = (0, exports.getStateIndex)(signUpData.pubKeys, userPubKey, stateIndex);
218
+ if (loadedStateIndex < 1) {
219
+ throw new Error("Invalid state index");
220
+ }
221
+ return (0, exports.joiningCircuitInputs)(signUpData, stateTreeDepth, userMaciPrivKey, stateIndex, userPubKey, pollId);
222
+ };
223
+ exports.getPollJoiningCircuitEvents = getPollJoiningCircuitEvents;
224
+ //# 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,0DAAqE;AAErE,4CAAoB;AAcpB,kDAAwD;AACxD,kDAAiD;AAEjD;;GAEG;AACI,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,aAAa,GACY,EAGxB,EAAE;IACH,KAAK,IAAI,KAAK,GAAG,UAAU,EAAE,KAAK,IAAI,YAAY,EAAE,KAAK,IAAI,uBAAW,EAAE,CAAC;QACzE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,uBAAW,GAAG,CAAC,EAAE,YAAY,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC;QACvC,4CAA4C;QAC5C,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,WAAW,CAC9C,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EACtF,KAAK,EACL,OAAO,CACR,CAAC;QAEF,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;YAE1B,OAAO;gBACL,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;gBACxC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;aACvC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,cAAc,EAAE;KAC9B,CAAC,CAAC;IACH,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC;IACnF,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAEtE,MAAM,UAAU,GAAG,MAAM,IAAA,8BAAkB,EAAC;QAC1C,QAAQ,EAAE,MAAM,CAAC,QAAS;QAC1B,OAAO,EAAE,MAAM,YAAY,CAAC,UAAU,EAAE;QACxC,gBAAgB,EAAE,cAAc,IAAI,EAAE;QACtC,SAAS;QACT,QAAQ;QACR,WAAW,EAAE,CAAC;KACf,CAAC,CAAC;IAEH,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,oBAAO,CAAC,eAAe,CAAC,CAAC;IAC5D,MAAM,gBAAgB,GAAG,IAAA,qBAAa,EAAC,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAEnF,IAAI,gBAAiB,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,IAAA,4BAAoB,EACzB,UAAU,EACV,cAAc,EACd,eAAe,EACf,UAAU,EACV,UAAU,EACV,MAAM,CACqB,CAAC;AAChC,CAAC,CAAC;AA/CW,QAAA,2BAA2B,+BA+CtC"}
@@ -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"}