@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,53 @@
1
+ import { EPolicies } from "@maci-protocol/contracts";
2
+ import type { IGetPolicyTraitArgs, IGetPolicyDataArgs, ISemaphorePolicyData, IZupassPolicyData, IEASPolicyData, IMerkleProofPolicyData, IERC20PolicyData, IERC20VotesPolicyData } from "./types";
3
+ import { EPolicyTrait } from "./types";
4
+ /**
5
+ * Get the policy type of the MACI contract
6
+ * @param IGetPolicyTraitArgs - The arguments for the get policy type command
7
+ * @returns The policy type
8
+ */
9
+ export declare const getPolicyTrait: ({ maciAddress, signer }: IGetPolicyTraitArgs) => Promise<EPolicyTrait>;
10
+ /**
11
+ * Get policy contract names associated with the trait provided.
12
+ *
13
+ * @param trait the policy trait
14
+ * @returns the policy contract names
15
+ */
16
+ export declare const getPolicyContractNamesByTrait: (trait: EPolicyTrait) => EPolicies;
17
+ /**
18
+ * Get the semaphore policy data
19
+ * @param IGetSemaphorePolicyDataArgs - The arguments for the get semaphore policy data command
20
+ * @returns The semaphore policy data
21
+ */
22
+ export declare const getSemaphorePolicyData: ({ maciAddress, signer, }: IGetPolicyDataArgs) => Promise<ISemaphorePolicyData>;
23
+ /**
24
+ * Get the zupass policy data
25
+ * @param IGetPolicyDataArgs - The arguments for the get zupass policy data command
26
+ * @returns The zupass policy data
27
+ */
28
+ export declare const getZupassPolicyData: ({ maciAddress, signer }: IGetPolicyDataArgs) => Promise<IZupassPolicyData>;
29
+ /**
30
+ * Get the EAS policy data
31
+ * @param IGetPolicyDataArgs - The arguments for the get eas policy data command
32
+ * @returns The eas policy data
33
+ */
34
+ export declare const getEASPolicyData: ({ maciAddress, signer }: IGetPolicyDataArgs) => Promise<IEASPolicyData>;
35
+ /**
36
+ * Get the merkleproof policy data
37
+ * @param IGetPolicyDataArgs - The arguments for the get merkleproof policy data command
38
+ * @returns The merkleproof policy data
39
+ */
40
+ export declare const getMerkleProofPolicyData: ({ maciAddress, signer, }: IGetPolicyDataArgs) => Promise<IMerkleProofPolicyData>;
41
+ /**
42
+ * Get the ERC20 policy data
43
+ * @param IGetPolicyDataArgs - The arguments for the get erc20 policy data command
44
+ * @returns The erc20 policy data
45
+ */
46
+ export declare const getERC20PolicyData: ({ maciAddress, signer }: IGetPolicyDataArgs) => Promise<IERC20PolicyData>;
47
+ /**
48
+ * Get the ERC20 votes policy data
49
+ * @param IGetPolicyDataArgs - The arguments for the get erc20 votes policy data command
50
+ * @returns The erc20 votes policy data
51
+ */
52
+ export declare const getERC20VotesPolicyData: ({ maciAddress, signer, }: IGetPolicyDataArgs) => Promise<IERC20VotesPolicyData>;
53
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../ts/maci/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAgBrD,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAU,yBAAyB,mBAAmB,KAAG,OAAO,CAAC,YAAY,CAWvG,CAAC;AAeF;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GAAI,OAAO,YAAY,KAAG,SAAkD,CAAC;AAEvH;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAU,0BAG1C,kBAAkB,KAAG,OAAO,CAAC,oBAAoB,CAoBnD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAU,yBAAyB,kBAAkB,KAAG,OAAO,CAAC,iBAAiB,CAqBhH,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAU,yBAAyB,kBAAkB,KAAG,OAAO,CAAC,cAAc,CAoB1G,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAU,0BAG5C,kBAAkB,KAAG,OAAO,CAAC,sBAAsB,CAerD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAU,yBAAyB,kBAAkB,KAAG,OAAO,CAAC,gBAAgB,CAa9G,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAAU,0BAG3C,kBAAkB,KAAG,OAAO,CAAC,qBAAqB,CAkBpD,CAAC"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getERC20VotesPolicyData = exports.getERC20PolicyData = exports.getMerkleProofPolicyData = exports.getEASPolicyData = exports.getZupassPolicyData = exports.getSemaphorePolicyData = exports.getPolicyContractNamesByTrait = exports.getPolicyTrait = void 0;
4
+ const contracts_1 = require("@maci-protocol/contracts");
5
+ const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
6
+ const types_1 = require("./types");
7
+ /**
8
+ * Get the policy type of the MACI contract
9
+ * @param IGetPolicyTraitArgs - The arguments for the get policy type command
10
+ * @returns The policy type
11
+ */
12
+ const getPolicyTrait = async ({ maciAddress, signer }) => {
13
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
14
+ // get the address of the signup policy
15
+ const policyContractAddress = await maciContract.signUpPolicy();
16
+ const policyContract = typechain_types_1.IBasePolicy__factory.connect(policyContractAddress, signer);
17
+ const policyType = await policyContract.trait();
18
+ return policyType;
19
+ };
20
+ exports.getPolicyTrait = getPolicyTrait;
21
+ const POLICY_CONTRACT_NAMES_BY_TRAIT = {
22
+ [types_1.EPolicyTrait.EAS]: contracts_1.EPolicies.EAS,
23
+ [types_1.EPolicyTrait.FreeForAll]: contracts_1.EPolicies.FreeForAll,
24
+ [types_1.EPolicyTrait.GitcoinPassport]: contracts_1.EPolicies.GitcoinPassport,
25
+ [types_1.EPolicyTrait.Hats]: contracts_1.EPolicies.Hats,
26
+ [types_1.EPolicyTrait.Semaphore]: contracts_1.EPolicies.Semaphore,
27
+ [types_1.EPolicyTrait.Token]: contracts_1.EPolicies.Token,
28
+ [types_1.EPolicyTrait.Zupass]: contracts_1.EPolicies.Zupass,
29
+ [types_1.EPolicyTrait.MerkleProof]: contracts_1.EPolicies.MerkleProof,
30
+ [types_1.EPolicyTrait.ERC20]: contracts_1.EPolicies.ERC20,
31
+ [types_1.EPolicyTrait.ERC20Votes]: contracts_1.EPolicies.ERC20Votes,
32
+ };
33
+ /**
34
+ * Get policy contract names associated with the trait provided.
35
+ *
36
+ * @param trait the policy trait
37
+ * @returns the policy contract names
38
+ */
39
+ const getPolicyContractNamesByTrait = (trait) => POLICY_CONTRACT_NAMES_BY_TRAIT[trait];
40
+ exports.getPolicyContractNamesByTrait = getPolicyContractNamesByTrait;
41
+ /**
42
+ * Get the semaphore policy data
43
+ * @param IGetSemaphorePolicyDataArgs - The arguments for the get semaphore policy data command
44
+ * @returns The semaphore policy data
45
+ */
46
+ const getSemaphorePolicyData = async ({ maciAddress, signer, }) => {
47
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
48
+ // get the address of the signup policy
49
+ const policyContractAddress = await maciContract.signUpPolicy();
50
+ const policyContract = typechain_types_1.SemaphorePolicy__factory.connect(policyContractAddress, signer);
51
+ const checkerAddress = await policyContract.BASE_CHECKER();
52
+ const checkerContract = typechain_types_1.SemaphoreChecker__factory.connect(checkerAddress, signer);
53
+ // get the group ID and semaphore contract address
54
+ const [groupId, semaphoreContractAddress] = await Promise.all([
55
+ checkerContract.groupId(),
56
+ checkerContract.semaphore(),
57
+ ]);
58
+ return {
59
+ address: semaphoreContractAddress,
60
+ groupId: groupId.toString(),
61
+ };
62
+ };
63
+ exports.getSemaphorePolicyData = getSemaphorePolicyData;
64
+ /**
65
+ * Get the zupass policy data
66
+ * @param IGetPolicyDataArgs - The arguments for the get zupass policy data command
67
+ * @returns The zupass policy data
68
+ */
69
+ const getZupassPolicyData = async ({ maciAddress, signer }) => {
70
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
71
+ // get the address of the signup policy
72
+ const policyContractAddress = await maciContract.signUpPolicy();
73
+ const policyContract = typechain_types_1.ZupassPolicy__factory.connect(policyContractAddress, signer);
74
+ const checkerAddress = await policyContract.BASE_CHECKER();
75
+ const checkerContract = typechain_types_1.ZupassChecker__factory.connect(checkerAddress, signer);
76
+ const [validEventId, validSigner1, validSigner2] = await Promise.all([
77
+ checkerContract.validEventId(),
78
+ checkerContract.validSigner1(),
79
+ checkerContract.validSigner2(),
80
+ ]);
81
+ return {
82
+ eventId: validEventId.toString(),
83
+ signer1: validSigner1.toString(),
84
+ signer2: validSigner2.toString(),
85
+ };
86
+ };
87
+ exports.getZupassPolicyData = getZupassPolicyData;
88
+ /**
89
+ * Get the EAS policy data
90
+ * @param IGetPolicyDataArgs - The arguments for the get eas policy data command
91
+ * @returns The eas policy data
92
+ */
93
+ const getEASPolicyData = async ({ maciAddress, signer }) => {
94
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
95
+ const policyContractAddress = await maciContract.signUpPolicy();
96
+ const policyContract = typechain_types_1.EASPolicy__factory.connect(policyContractAddress, signer);
97
+ const checkerAddress = await policyContract.BASE_CHECKER();
98
+ const checkerContract = typechain_types_1.EASChecker__factory.connect(checkerAddress, signer);
99
+ const [eas, schema, attester] = await Promise.all([
100
+ checkerContract.eas(),
101
+ checkerContract.schema(),
102
+ checkerContract.attester(),
103
+ ]);
104
+ return {
105
+ eas: eas.toString(),
106
+ schema: schema.toString(),
107
+ attester: attester.toString(),
108
+ };
109
+ };
110
+ exports.getEASPolicyData = getEASPolicyData;
111
+ /**
112
+ * Get the merkleproof policy data
113
+ * @param IGetPolicyDataArgs - The arguments for the get merkleproof policy data command
114
+ * @returns The merkleproof policy data
115
+ */
116
+ const getMerkleProofPolicyData = async ({ maciAddress, signer, }) => {
117
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
118
+ // get the address of the signup policy
119
+ const policyContractAddress = await maciContract.signUpPolicy();
120
+ const policyContract = typechain_types_1.MerkleProofPolicy__factory.connect(policyContractAddress, signer);
121
+ const checkerAddress = await policyContract.BASE_CHECKER();
122
+ const checkerContract = typechain_types_1.MerkleProofChecker__factory.connect(checkerAddress, signer);
123
+ const [validRoot] = await Promise.all([checkerContract.root()]);
124
+ return {
125
+ root: validRoot.toString(),
126
+ };
127
+ };
128
+ exports.getMerkleProofPolicyData = getMerkleProofPolicyData;
129
+ /**
130
+ * Get the ERC20 policy data
131
+ * @param IGetPolicyDataArgs - The arguments for the get erc20 policy data command
132
+ * @returns The erc20 policy data
133
+ */
134
+ const getERC20PolicyData = async ({ maciAddress, signer }) => {
135
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
136
+ const policyContractAddress = await maciContract.signUpPolicy();
137
+ const policyContract = typechain_types_1.ERC20Checker__factory.connect(policyContractAddress, signer);
138
+ const [token, threshold] = await Promise.all([policyContract.token(), policyContract.threshold()]);
139
+ return {
140
+ token: token.toString(),
141
+ threshold: threshold.toString(),
142
+ };
143
+ };
144
+ exports.getERC20PolicyData = getERC20PolicyData;
145
+ /**
146
+ * Get the ERC20 votes policy data
147
+ * @param IGetPolicyDataArgs - The arguments for the get erc20 votes policy data command
148
+ * @returns The erc20 votes policy data
149
+ */
150
+ const getERC20VotesPolicyData = async ({ maciAddress, signer, }) => {
151
+ const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
152
+ const policyContractAddress = await maciContract.signUpPolicy();
153
+ const policyContract = typechain_types_1.ERC20VotesChecker__factory.connect(policyContractAddress, signer);
154
+ const [token, threshold, snapshotBlock] = await Promise.all([
155
+ policyContract.token(),
156
+ policyContract.threshold(),
157
+ policyContract.snapshotBlock(),
158
+ ]);
159
+ return {
160
+ token: token.toString(),
161
+ threshold: threshold.toString(),
162
+ snapshotBlock: snapshotBlock.toString(),
163
+ };
164
+ };
165
+ exports.getERC20VotesPolicyData = getERC20VotesPolicyData;
166
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../ts/maci/policy.ts"],"names":[],"mappings":";;;AAAA,wDAAqD;AACrD,8EAakD;AAalD,mCAAuC;AAEvC;;;;GAIG;AACI,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAuB,EAAyB,EAAE;IAC1G,MAAM,YAAY,GAAG,+BAAW,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE9D,uCAAuC;IACvC,MAAM,qBAAqB,GAAG,MAAM,YAAY,CAAC,YAAY,EAAE,CAAC;IAEhE,MAAM,cAAc,GAAG,sCAAmB,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAElF,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,KAAK,EAAE,CAAC;IAEhD,OAAO,UAA0B,CAAC;AACpC,CAAC,CAAC;AAXW,QAAA,cAAc,kBAWzB;AAEF,MAAM,8BAA8B,GAAG;IACrC,CAAC,oBAAY,CAAC,GAAG,CAAC,EAAE,qBAAS,CAAC,GAAG;IACjC,CAAC,oBAAY,CAAC,UAAU,CAAC,EAAE,qBAAS,CAAC,UAAU;IAC/C,CAAC,oBAAY,CAAC,eAAe,CAAC,EAAE,qBAAS,CAAC,eAAe;IACzD,CAAC,oBAAY,CAAC,IAAI,CAAC,EAAE,qBAAS,CAAC,IAAI;IACnC,CAAC,oBAAY,CAAC,SAAS,CAAC,EAAE,qBAAS,CAAC,SAAS;IAC7C,CAAC,oBAAY,CAAC,KAAK,CAAC,EAAE,qBAAS,CAAC,KAAK;IACrC,CAA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/B,aAAa,EAAE,aAAa,CAAC,QAAQ,EAAE;KACxC,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,uBAAuB,2BAqBlC"}
@@ -0,0 +1,8 @@
1
+ import type { IGenerateMaciStateArgs } from "./types";
2
+ import type { MaciState } from "@maci-protocol/core";
3
+ /**
4
+ * Generate a local MACI state from the smart contracts events
5
+ * @param args The arguments for the genLocalState command
6
+ */
7
+ export declare const generateMaciState: ({ outputPath, pollId, maciAddress, coordinatorPrivateKey, provider, endBlock, startBlock, blockPerBatch, transactionHash, sleep, signer, ipfsMessageBackupFiles, logsOutputPath, }: IGenerateMaciStateArgs) => Promise<MaciState>;
8
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../ts/maci/state.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAU,oLAcrC,sBAAsB,KAAG,OAAO,CAAC,SAAS,CAgF5C,CAAC"}
@@ -0,0 +1,82 @@
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.generateMaciState = void 0;
7
+ const contracts_1 = require("@maci-protocol/contracts");
8
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
9
+ const ethers_1 = require("ethers");
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const contracts_2 = require("../utils/contracts");
12
+ /**
13
+ * Generate a local MACI state from the smart contracts events
14
+ * @param args The arguments for the genLocalState command
15
+ */
16
+ const generateMaciState = async ({ outputPath, pollId, maciAddress, coordinatorPrivateKey, provider, endBlock, startBlock, blockPerBatch, transactionHash, sleep, signer, ipfsMessageBackupFiles, logsOutputPath, }) => {
17
+ if (!maciAddress) {
18
+ throw new Error("MACI contract address is empty");
19
+ }
20
+ const isMaciExists = await (0, contracts_2.contractExists)(signer.provider, maciAddress);
21
+ if (!isMaciExists) {
22
+ throw new Error("MACI contract does not exist");
23
+ }
24
+ // if no private key is passed we ask it securely
25
+ if (!domainobjs_1.PrivKey.isValidSerializedPrivKey(coordinatorPrivateKey)) {
26
+ throw new Error("Invalid MACI private key");
27
+ }
28
+ const coordinatorMaciPrivKey = domainobjs_1.PrivKey.deserialize(coordinatorPrivateKey);
29
+ const coordinatorKeypair = new domainobjs_1.Keypair(coordinatorMaciPrivKey);
30
+ const maciContract = contracts_1.MACI__factory.connect(maciAddress, signer);
31
+ const pollContracts = await maciContract.polls(pollId);
32
+ const isPollExists = await (0, contracts_2.contractExists)(signer.provider, pollContracts.poll);
33
+ if (!isPollExists) {
34
+ throw new Error("Poll contract does not exist");
35
+ }
36
+ const pollContract = contracts_1.Poll__factory.connect(pollContracts.poll, signer);
37
+ const [defaultStartBlockSignup, defaultStartBlockPoll, stateRoot, numSignups] = await Promise.all([
38
+ maciContract.queryFilter(maciContract.filters.SignUp(), startBlock).then((events) => events[0]?.blockNumber ?? 0),
39
+ maciContract
40
+ .queryFilter(maciContract.filters.DeployPoll(), startBlock)
41
+ .then((events) => events[0]?.blockNumber ?? 0),
42
+ maciContract.getStateTreeRoot(),
43
+ maciContract.numSignUps(),
44
+ ]);
45
+ const defaultStartBlock = Math.min(defaultStartBlockPoll, defaultStartBlockSignup);
46
+ let fromBlock = startBlock ? Number(startBlock) : defaultStartBlock;
47
+ const defaultEndBlock = await Promise.all([
48
+ pollContract
49
+ .queryFilter(pollContract.filters.MergeState(stateRoot, numSignups), fromBlock)
50
+ .then((events) => events[events.length - 1]?.blockNumber),
51
+ ]).then((blocks) => Math.max(...blocks));
52
+ if (transactionHash) {
53
+ const tx = await signer.provider.getTransaction(transactionHash);
54
+ fromBlock = tx?.blockNumber ?? defaultStartBlock;
55
+ }
56
+ // calculate the end block number
57
+ const endBlockNumber = endBlock || defaultEndBlock;
58
+ if (transactionHash) {
59
+ const tx = await signer.provider.getTransaction(transactionHash);
60
+ fromBlock = tx?.blockNumber ?? defaultStartBlock;
61
+ }
62
+ const maciState = await (0, contracts_1.genMaciStateFromContract)({
63
+ provider: provider ? new ethers_1.JsonRpcProvider(provider) : signer.provider,
64
+ address: maciAddress,
65
+ coordinatorKeypair,
66
+ pollId,
67
+ fromBlock,
68
+ blocksPerRequest: blockPerBatch || 50,
69
+ endBlock: endBlockNumber,
70
+ sleepAmount: sleep,
71
+ ipfsMessageBackupFiles,
72
+ logsOutputPath,
73
+ });
74
+ // write the state to a file
75
+ if (outputPath) {
76
+ const serializedState = maciState.toJSON();
77
+ await fs_1.default.promises.writeFile(outputPath, JSON.stringify(serializedState, null, 4));
78
+ }
79
+ return maciState;
80
+ };
81
+ exports.generateMaciState = generateMaciState;
82
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../ts/maci/state.ts"],"names":[],"mappings":";;;;;;AAAA,wDAIkC;AAClC,0DAA6D;AAC7D,mCAAyC;AAEzC,4CAAoB;AAKpB,kDAAoD;AAEpD;;;GAGG;AACI,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,UAAU,EACV,MAAM,EACN,WAAW,EACX,qBAAqB,EACrB,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,aAAa,EACb,eAAe,EACf,KAAK,EACL,MAAM,EACN,sBAAsB,EACtB,cAAc,GACS,EAAsB,EAAE;IAC/C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,0BAAc,EAAC,MAAM,CAAC,QAAS,EAAE,WAAW,CAAC,CAAC;IAEzE,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,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e,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAS;QACrE,OAAO,EAAE,WAAW;QACpB,kBAAkB;QAClB,MAAM;QACN,SAAS;QACT,gBAAgB,EAAE,aAAa,IAAI,EAAE;QACrC,QAAQ,EAAE,cAAc;QACxB,WAAW,EAAE,KAAK;QAClB,sBAAsB;QACtB,cAAc;KACf,CAAC,CAAC;IAEH,4BAA4B;IAC5B,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,eAAe,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QAC3C,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AA9FW,QAAA,iBAAiB,qBA8F5B"}
@@ -0,0 +1,208 @@
1
+ import type { Signer } from "ethers";
2
+ /**
3
+ * Enum for the policy type
4
+ */
5
+ export declare enum EPolicyTrait {
6
+ EAS = "EAS",
7
+ FreeForAll = "FreeForAll",
8
+ GitcoinPassport = "GitcoinPassport",
9
+ Hats = "Hats",
10
+ Semaphore = "Semaphore",
11
+ Token = "Token",
12
+ Zupass = "Zupass",
13
+ MerkleProof = "MerkleProof",
14
+ ERC20 = "ERC20",
15
+ ERC20Votes = "ERC20Votes"
16
+ }
17
+ /**
18
+ * Interface for the arguments to the getPolicyTrait command
19
+ */
20
+ export interface IGetPolicyTraitArgs {
21
+ /**
22
+ * The address of the MACI contract
23
+ */
24
+ maciAddress: string;
25
+ /**
26
+ * A signer object
27
+ */
28
+ signer: Signer;
29
+ }
30
+ /**
31
+ * Interface for the arguments to the get a policy data command
32
+ */
33
+ export interface IGetPolicyDataArgs {
34
+ /**
35
+ * The address of the MACI contract
36
+ */
37
+ maciAddress: string;
38
+ /**
39
+ * A signer object
40
+ */
41
+ signer: Signer;
42
+ }
43
+ /**
44
+ * Interface for the semaphore policy data
45
+ */
46
+ export interface ISemaphorePolicyData {
47
+ /**
48
+ * The address of the semaphore policy
49
+ */
50
+ address: string;
51
+ /**
52
+ * The group ID
53
+ */
54
+ groupId: string;
55
+ }
56
+ /**
57
+ * Interface for the zupass policy data
58
+ */
59
+ export interface IZupassPolicyData {
60
+ /**
61
+ * The event ID
62
+ */
63
+ eventId: string;
64
+ /**
65
+ * The first signer
66
+ */
67
+ signer1: string;
68
+ /**
69
+ * The second signer
70
+ */
71
+ signer2: string;
72
+ }
73
+ /**
74
+ * Interface for the EAS policy data
75
+ */
76
+ export interface IEASPolicyData {
77
+ /**
78
+ * The EAS
79
+ */
80
+ eas: string;
81
+ /**
82
+ * The schema
83
+ */
84
+ schema: string;
85
+ /**
86
+ * The attester
87
+ */
88
+ attester: string;
89
+ }
90
+ /**
91
+ * Interface for the MerkleProof policy data
92
+ */
93
+ export interface IMerkleProofPolicyData {
94
+ /**
95
+ * The merkle tree root
96
+ */
97
+ root: string;
98
+ }
99
+ /**
100
+ * Interface for the erc20 policy data
101
+ */
102
+ export interface IERC20PolicyData {
103
+ /**
104
+ * The token address
105
+ */
106
+ token: string;
107
+ /**
108
+ * The threshold
109
+ */
110
+ threshold: string;
111
+ }
112
+ /**
113
+ * Interface for the erc20 votes policy data
114
+ */
115
+ export interface IERC20VotesPolicyData {
116
+ /**
117
+ * The token address
118
+ */
119
+ token: string;
120
+ /**
121
+ * The threshold
122
+ */
123
+ threshold: string;
124
+ /**
125
+ * The snapshot block
126
+ */
127
+ snapshotBlock: string;
128
+ }
129
+ /**
130
+ * Interface for the arguments to the mergeSignups command
131
+ */
132
+ export interface IMergeSignupsArgs {
133
+ /**
134
+ * The id of the poll
135
+ */
136
+ pollId: bigint;
137
+ /**
138
+ * A signer object
139
+ */
140
+ signer: Signer;
141
+ /**
142
+ * The address of the MACI contract
143
+ */
144
+ maciAddress: string;
145
+ /**
146
+ * The number of queue operations to perform
147
+ */
148
+ numQueueOps?: string;
149
+ }
150
+ /**
151
+ * Interface for the arguments to the genLocalState command
152
+ * Generate a local MACI state from the smart contracts events
153
+ */
154
+ export interface IGenerateMaciStateArgs {
155
+ /**
156
+ * The id of the poll
157
+ */
158
+ pollId: bigint;
159
+ /**
160
+ * A signer object
161
+ */
162
+ signer: Signer;
163
+ /**
164
+ * The address of the MACI contract
165
+ */
166
+ maciAddress: string;
167
+ /**
168
+ * The private key of the MACI coordinator
169
+ */
170
+ coordinatorPrivateKey: string;
171
+ /**
172
+ * The ethereum provider
173
+ */
174
+ provider?: string;
175
+ /**
176
+ * The path where to write the state
177
+ */
178
+ outputPath?: string;
179
+ /**
180
+ * The start block number
181
+ */
182
+ startBlock?: number;
183
+ /**
184
+ * The end block number
185
+ */
186
+ endBlock?: number;
187
+ /**
188
+ * The number of blocks to fetch per batch
189
+ */
190
+ blockPerBatch?: number;
191
+ /**
192
+ * The transaction hash
193
+ */
194
+ transactionHash?: string;
195
+ /**
196
+ * The sleep time between batches
197
+ */
198
+ sleep?: number;
199
+ /**
200
+ * Backup files for ipfs messages (name format: ipfsHash.json)
201
+ */
202
+ ipfsMessageBackupFiles?: string[];
203
+ /**
204
+ * The file path where to save the logs for debugging and auditing purposes
205
+ */
206
+ logsOutputPath?: string;
207
+ }
208
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/maci/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,oBAAY,YAAY;IACtB,GAAG,QAAQ;IACX,UAAU,eAAe;IACzB,eAAe,oBAAoB;IACnC,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,WAAW,gBAAgB;IAC3B,KAAK,UAAU;IACf,UAAU,eAAe;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,WA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IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAElC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EPolicyTrait = void 0;
4
+ /**
5
+ * Enum for the policy type
6
+ */
7
+ var EPolicyTrait;
8
+ (function (EPolicyTrait) {
9
+ EPolicyTrait["EAS"] = "EAS";
10
+ EPolicyTrait["FreeForAll"] = "FreeForAll";
11
+ EPolicyTrait["GitcoinPassport"] = "GitcoinPassport";
12
+ EPolicyTrait["Hats"] = "Hats";
13
+ EPolicyTrait["Semaphore"] = "Semaphore";
14
+ EPolicyTrait["Token"] = "Token";
15
+ EPolicyTrait["Zupass"] = "Zupass";
16
+ EPolicyTrait["MerkleProof"] = "MerkleProof";
17
+ EPolicyTrait["ERC20"] = "ERC20";
18
+ EPolicyTrait["ERC20Votes"] = "ERC20Votes";
19
+ })(EPolicyTrait || (exports.EPolicyTrait = EPolicyTrait = {}));
20
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/maci/types.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,IAAY,YAWX;AAXD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,yCAAyB,CAAA;IACzB,mDAAmC,CAAA;IACnC,6BAAa,CAAA;IACb,uCAAuB,CAAA;IACvB,+BAAe,CAAA;IACf,iCAAiB,CAAA;IACjB,2CAA2B,CAAA;IAC3B,+BAAe,CAAA;IACf,yCAAyB,CAAA;AAC3B,CAAC,EAXW,YAAY,4BAAZ,YAAY,QAWvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=keypair.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.test.d.ts","sourceRoot":"","sources":["../../../../ts/maciKeys/__tests__/keypair.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const crypto_1 = require("@maci-protocol/crypto");
4
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
5
+ const keypair_1 = require("../keypair");
6
+ describe("generateKeypair", () => {
7
+ it("should output a random private key and public key", () => {
8
+ const keypair1 = (0, keypair_1.generateKeypair)();
9
+ const keypair2 = (0, keypair_1.generateKeypair)({
10
+ seed: 2801240355254658294358555831749515294960721159561923188361445519585440177746075496738285268291285781469276476510188450870897435498492786799730508035869388059n,
11
+ });
12
+ // Invoking the same command twice should result in different private keys
13
+ expect(keypair1.privateKey).not.toBe(keypair2.privateKey);
14
+ expect(keypair1.publicKey).not.toBe(keypair2.publicKey);
15
+ expect(domainobjs_1.PrivKey.deserialize(keypair1.privateKey)).toBeInstanceOf(domainobjs_1.PrivKey);
16
+ expect(domainobjs_1.PubKey.deserialize(keypair1.publicKey)).toBeInstanceOf(domainobjs_1.PubKey);
17
+ expect(domainobjs_1.PrivKey.deserialize(keypair2.privateKey)).toBeInstanceOf(domainobjs_1.PrivKey);
18
+ expect(domainobjs_1.PubKey.deserialize(keypair2.publicKey)).toBeInstanceOf(domainobjs_1.PubKey);
19
+ const publicKey2 = (0, crypto_1.genPubKey)(domainobjs_1.PrivKey.deserialize(keypair2.privateKey).rawPrivKey);
20
+ expect(domainobjs_1.PubKey.deserialize(keypair2.publicKey).rawPubKey[0].toString()).toBe(publicKey2[0].toString());
21
+ expect(domainobjs_1.PubKey.deserialize(keypair2.publicKey).rawPubKey[1].toString()).toBe(publicKey2[1].toString());
22
+ });
23
+ });
24
+ //# sourceMappingURL=keypair.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.test.js","sourceRoot":"","sources":["../../../../ts/maciKeys/__tests__/keypair.test.ts"],"names":[],"mappings":";;AAAA,kDAAkD;AAClD,0DAA4D;AAE5D,wCAA6C;AAE7C,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,QAAQ,GAAG,IAAA,yBAAe,GAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,IAAA,yBAAe,EAAC;YAC/B,IAAI,EAAE,8JAA8J;SACrK,CAAC,CAAC;QAEH,0EAA0E;QAC1E,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC1D,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACxD,MAAM,CAAC,oBAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,oBAAO,CAAC,CAAC;QACzE,MAAM,CAAC,mBAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,mBAAM,CAAC,CAAC;QACtE,MAAM,CAAC,oBAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,oBAAO,CAAC,CAAC;QACzE,MAAM,CAAC,mBAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,mBAAM,CAAC,CAAC;QAEtE,MAAM,UAAU,GAAG,IAAA,kBAAS,EAAC,oBAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC;QAClF,MAAM,CAAC,mBAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtG,MAAM,CAAC,mBAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=publicKeys.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicKeys.test.d.ts","sourceRoot":"","sources":["../../../../ts/maciKeys/__tests__/publicKeys.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const crypto_1 = require("@maci-protocol/crypto");
4
+ const domainobjs_1 = require("@maci-protocol/domainobjs");
5
+ const keypair_1 = require("../keypair");
6
+ const publicKeys_1 = require("../publicKeys");
7
+ describe("generateMaciPublicKey", () => {
8
+ test("should output a valid public key", () => {
9
+ const keypair = (0, keypair_1.generateKeypair)();
10
+ const pubKey = (0, publicKeys_1.generateMaciPublicKey)(keypair.privateKey);
11
+ expect(pubKey).toBe(keypair.publicKey);
12
+ const unserialisedPrivkey = domainobjs_1.PrivKey.deserialize(keypair.privateKey);
13
+ const pk2 = (0, crypto_1.genPubKey)(unserialisedPrivkey.rawPrivKey);
14
+ const unserializedPk = domainobjs_1.PubKey.deserialize(keypair.publicKey);
15
+ expect(unserializedPk.rawPubKey[0].toString()).toBe(pk2[0].toString());
16
+ expect(unserializedPk.rawPubKey[1].toString()).toBe(pk2[1].toString());
17
+ });
18
+ test("should throw when given an invalid private key", () => {
19
+ expect(() => (0, publicKeys_1.generateMaciPublicKey)("invalid")).toThrow("Invalid private key");
20
+ });
21
+ });
22
+ //# sourceMappingURL=publicKeys.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicKeys.test.js","sourceRoot":"","sources":["../../../../ts/maciKeys/__tests__/publicKeys.test.ts"],"names":[],"mappings":";;AAAA,kDAAkD;AAClD,0DAA4D;AAE5D,wCAA6C;AAC7C,8CAAsD;AAEtD,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC5C,MAAM,OAAO,GAAG,IAAA,yBAAe,GAAE,CAAC;QAClC,MAAM,MAAM,GAAG,IAAA,kCAAqB,EAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAEzD,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEvC,MAAM,mBAAmB,GAAG,oBAAO,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,IAAA,kBAAS,EAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACtD,MAAM,cAAc,GAAG,mBAAM,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7D,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvE,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,gDAAgD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,kCAAqB,EAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { generateKeypair } from "./keypair";
2
+ export { generateMaciPublicKey } from "./publicKeys";
3
+ export type { IGenerateKeypairArgs, IGenerateKeypairData } from "./types";
4
+ //# sourceMappingURL=index.d.ts.map