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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/LICENSE +21 -0
  3. package/README.md +49 -0
  4. package/build/hardhat.config.cjs +34 -0
  5. package/build/hardhat.config.cjs.map +1 -0
  6. package/build/hardhat.config.d.cts +27 -0
  7. package/build/hardhat.config.d.cts.map +1 -0
  8. package/build/scripts/generateKeypair.d.ts +2 -0
  9. package/build/scripts/generateKeypair.d.ts.map +1 -0
  10. package/build/scripts/generateKeypair.js +25 -0
  11. package/build/scripts/generateKeypair.js.map +1 -0
  12. package/build/scripts/generateMaciKeyPair.d.ts +2 -0
  13. package/build/scripts/generateMaciKeyPair.d.ts.map +1 -0
  14. package/build/scripts/generateMaciKeyPair.js +3 -0
  15. package/build/scripts/generateMaciKeyPair.js.map +1 -0
  16. package/build/scripts/getAuthHeader.d.ts +2 -0
  17. package/build/scripts/getAuthHeader.d.ts.map +1 -0
  18. package/build/scripts/getAuthHeader.js +31 -0
  19. package/build/scripts/getAuthHeader.js.map +1 -0
  20. package/build/tests/constants.d.ts +7 -0
  21. package/build/tests/constants.d.ts.map +1 -0
  22. package/build/tests/constants.js +9 -0
  23. package/build/tests/constants.js.map +1 -0
  24. package/build/tests/e2e.aa.test.d.ts +2 -0
  25. package/build/tests/e2e.aa.test.d.ts.map +1 -0
  26. package/build/tests/e2e.aa.test.js +106 -0
  27. package/build/tests/e2e.aa.test.js.map +1 -0
  28. package/build/tests/e2e.deploy.test.d.ts +2 -0
  29. package/build/tests/e2e.deploy.test.d.ts.map +1 -0
  30. package/build/tests/e2e.deploy.test.js +282 -0
  31. package/build/tests/e2e.deploy.test.js.map +1 -0
  32. package/build/tests/utils.d.ts +20 -0
  33. package/build/tests/utils.d.ts.map +1 -0
  34. package/build/tests/utils.js +53 -0
  35. package/build/tests/utils.js.map +1 -0
  36. package/build/ts/app.module.d.ts +3 -0
  37. package/build/ts/app.module.d.ts.map +1 -0
  38. package/build/ts/app.module.js +36 -0
  39. package/build/ts/app.module.js.map +1 -0
  40. package/build/ts/auth/AccountSignatureGuard.service.d.ts +44 -0
  41. package/build/ts/auth/AccountSignatureGuard.service.d.ts.map +1 -0
  42. package/build/ts/auth/AccountSignatureGuard.service.js +96 -0
  43. package/build/ts/auth/AccountSignatureGuard.service.js.map +1 -0
  44. package/build/ts/auth/__tests__/AccountSignatureGuard.test.d.ts +2 -0
  45. package/build/ts/auth/__tests__/AccountSignatureGuard.test.d.ts.map +1 -0
  46. package/build/ts/auth/__tests__/AccountSignatureGuard.test.js +113 -0
  47. package/build/ts/auth/__tests__/AccountSignatureGuard.test.js.map +1 -0
  48. package/build/ts/common/__tests__/common.test.d.ts +2 -0
  49. package/build/ts/common/__tests__/common.test.d.ts.map +1 -0
  50. package/build/ts/common/__tests__/common.test.js +75 -0
  51. package/build/ts/common/__tests__/common.test.js.map +1 -0
  52. package/build/ts/common/accountAbstraction.d.ts +38 -0
  53. package/build/ts/common/accountAbstraction.d.ts.map +1 -0
  54. package/build/ts/common/accountAbstraction.js +81 -0
  55. package/build/ts/common/accountAbstraction.js.map +1 -0
  56. package/build/ts/common/chain.d.ts +16 -0
  57. package/build/ts/common/chain.d.ts.map +1 -0
  58. package/build/ts/common/chain.js +35 -0
  59. package/build/ts/common/chain.js.map +1 -0
  60. package/build/ts/common/errors.d.ts +32 -0
  61. package/build/ts/common/errors.d.ts.map +1 -0
  62. package/build/ts/common/errors.js +33 -0
  63. package/build/ts/common/errors.js.map +1 -0
  64. package/build/ts/common/index.d.ts +6 -0
  65. package/build/ts/common/index.d.ts.map +1 -0
  66. package/build/ts/common/index.js +6 -0
  67. package/build/ts/common/index.js.map +1 -0
  68. package/build/ts/common/networks.d.ts +29 -0
  69. package/build/ts/common/networks.d.ts.map +1 -0
  70. package/build/ts/common/networks.js +70 -0
  71. package/build/ts/common/networks.js.map +1 -0
  72. package/build/ts/common/types.d.ts +8 -0
  73. package/build/ts/common/types.d.ts.map +1 -0
  74. package/build/ts/common/types.js +2 -0
  75. package/build/ts/common/types.js.map +1 -0
  76. package/build/ts/crypto/__tests__/crypto.service.test.d.ts +2 -0
  77. package/build/ts/crypto/__tests__/crypto.service.test.d.ts.map +1 -0
  78. package/build/ts/crypto/__tests__/crypto.service.test.js +26 -0
  79. package/build/ts/crypto/__tests__/crypto.service.test.js.map +1 -0
  80. package/build/ts/crypto/crypto.module.d.ts +3 -0
  81. package/build/ts/crypto/crypto.module.d.ts.map +1 -0
  82. package/build/ts/crypto/crypto.module.js +18 -0
  83. package/build/ts/crypto/crypto.module.js.map +1 -0
  84. package/build/ts/crypto/crypto.service.d.ts +31 -0
  85. package/build/ts/crypto/crypto.service.d.ts.map +1 -0
  86. package/build/ts/crypto/crypto.service.js +68 -0
  87. package/build/ts/crypto/crypto.service.js.map +1 -0
  88. package/build/ts/deployer/__tests__/deployer.controller.test.d.ts +2 -0
  89. package/build/ts/deployer/__tests__/deployer.controller.test.d.ts.map +1 -0
  90. package/build/ts/deployer/__tests__/deployer.controller.test.js +84 -0
  91. package/build/ts/deployer/__tests__/deployer.controller.test.js.map +1 -0
  92. package/build/ts/deployer/__tests__/deployer.service.test.d.ts +2 -0
  93. package/build/ts/deployer/__tests__/deployer.service.test.d.ts.map +1 -0
  94. package/build/ts/deployer/__tests__/deployer.service.test.js +166 -0
  95. package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -0
  96. package/build/ts/deployer/__tests__/utils.d.ts +65 -0
  97. package/build/ts/deployer/__tests__/utils.d.ts.map +1 -0
  98. package/build/ts/deployer/__tests__/utils.js +131 -0
  99. package/build/ts/deployer/__tests__/utils.js.map +1 -0
  100. package/build/ts/deployer/constants.d.ts +13 -0
  101. package/build/ts/deployer/constants.d.ts.map +1 -0
  102. package/build/ts/deployer/constants.js +13 -0
  103. package/build/ts/deployer/constants.js.map +1 -0
  104. package/build/ts/deployer/deployer.controller.d.ts +34 -0
  105. package/build/ts/deployer/deployer.controller.d.ts.map +1 -0
  106. package/build/ts/deployer/deployer.controller.js +89 -0
  107. package/build/ts/deployer/deployer.controller.js.map +1 -0
  108. package/build/ts/deployer/deployer.module.d.ts +3 -0
  109. package/build/ts/deployer/deployer.module.d.ts.map +1 -0
  110. package/build/ts/deployer/deployer.module.js +23 -0
  111. package/build/ts/deployer/deployer.module.js.map +1 -0
  112. package/build/ts/deployer/deployer.service.d.ts +76 -0
  113. package/build/ts/deployer/deployer.service.d.ts.map +1 -0
  114. package/build/ts/deployer/deployer.service.js +341 -0
  115. package/build/ts/deployer/deployer.service.js.map +1 -0
  116. package/build/ts/deployer/dto.d.ts +46 -0
  117. package/build/ts/deployer/dto.d.ts.map +1 -0
  118. package/build/ts/deployer/dto.js +125 -0
  119. package/build/ts/deployer/dto.js.map +1 -0
  120. package/build/ts/deployer/types.d.ts +344 -0
  121. package/build/ts/deployer/types.d.ts.map +1 -0
  122. package/build/ts/deployer/types.js +2 -0
  123. package/build/ts/deployer/types.js.map +1 -0
  124. package/build/ts/file/__tests__/file.service.test.d.ts +2 -0
  125. package/build/ts/file/__tests__/file.service.test.d.ts.map +1 -0
  126. package/build/ts/file/__tests__/file.service.test.js +77 -0
  127. package/build/ts/file/__tests__/file.service.test.js.map +1 -0
  128. package/build/ts/file/file.module.d.ts +3 -0
  129. package/build/ts/file/file.module.d.ts.map +1 -0
  130. package/build/ts/file/file.module.js +18 -0
  131. package/build/ts/file/file.module.js.map +1 -0
  132. package/build/ts/file/file.service.d.ts +63 -0
  133. package/build/ts/file/file.service.d.ts.map +1 -0
  134. package/build/ts/file/file.service.js +120 -0
  135. package/build/ts/file/file.service.js.map +1 -0
  136. package/build/ts/file/types.d.ts +36 -0
  137. package/build/ts/file/types.d.ts.map +1 -0
  138. package/build/ts/file/types.js +2 -0
  139. package/build/ts/file/types.js.map +1 -0
  140. package/build/ts/jest/setup.d.ts +8 -0
  141. package/build/ts/jest/setup.d.ts.map +1 -0
  142. package/build/ts/jest/setup.js +2 -0
  143. package/build/ts/jest/setup.js.map +1 -0
  144. package/build/ts/jest/transform.d.ts +8 -0
  145. package/build/ts/jest/transform.d.ts.map +1 -0
  146. package/build/ts/jest/transform.js +10 -0
  147. package/build/ts/jest/transform.js.map +1 -0
  148. package/build/ts/main.d.ts +2 -0
  149. package/build/ts/main.d.ts.map +1 -0
  150. package/build/ts/main.js +46 -0
  151. package/build/ts/main.js.map +1 -0
  152. package/build/ts/proof/__tests__/proof.controller.test.d.ts +2 -0
  153. package/build/ts/proof/__tests__/proof.controller.test.d.ts.map +1 -0
  154. package/build/ts/proof/__tests__/proof.controller.test.js +92 -0
  155. package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -0
  156. package/build/ts/proof/__tests__/proof.gateway.test.d.ts +2 -0
  157. package/build/ts/proof/__tests__/proof.gateway.test.d.ts.map +1 -0
  158. package/build/ts/proof/__tests__/proof.gateway.test.js +65 -0
  159. package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -0
  160. package/build/ts/proof/__tests__/proof.service.test.d.ts +2 -0
  161. package/build/ts/proof/__tests__/proof.service.test.d.ts.map +1 -0
  162. package/build/ts/proof/__tests__/proof.service.test.js +130 -0
  163. package/build/ts/proof/__tests__/proof.service.test.js.map +1 -0
  164. package/build/ts/proof/dto.d.ts +75 -0
  165. package/build/ts/proof/dto.d.ts.map +1 -0
  166. package/build/ts/proof/dto.js +277 -0
  167. package/build/ts/proof/dto.js.map +1 -0
  168. package/build/ts/proof/proof.controller.d.ts +47 -0
  169. package/build/ts/proof/proof.controller.d.ts.map +1 -0
  170. package/build/ts/proof/proof.controller.js +135 -0
  171. package/build/ts/proof/proof.controller.js.map +1 -0
  172. package/build/ts/proof/proof.gateway.d.ts +35 -0
  173. package/build/ts/proof/proof.gateway.d.ts.map +1 -0
  174. package/build/ts/proof/proof.gateway.js +93 -0
  175. package/build/ts/proof/proof.gateway.js.map +1 -0
  176. package/build/ts/proof/proof.module.d.ts +3 -0
  177. package/build/ts/proof/proof.module.d.ts.map +1 -0
  178. package/build/ts/proof/proof.module.js +24 -0
  179. package/build/ts/proof/proof.module.js.map +1 -0
  180. package/build/ts/proof/proof.service.d.ts +54 -0
  181. package/build/ts/proof/proof.service.d.ts.map +1 -0
  182. package/build/ts/proof/proof.service.js +166 -0
  183. package/build/ts/proof/proof.service.js.map +1 -0
  184. package/build/ts/proof/types.d.ts +148 -0
  185. package/build/ts/proof/types.d.ts.map +1 -0
  186. package/build/ts/proof/types.js +11 -0
  187. package/build/ts/proof/types.js.map +1 -0
  188. package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.d.ts +2 -0
  189. package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.d.ts.map +1 -0
  190. package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.js +44 -0
  191. package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.js.map +1 -0
  192. package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.d.ts +2 -0
  193. package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.d.ts.map +1 -0
  194. package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js +61 -0
  195. package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js.map +1 -0
  196. package/build/ts/sessionKeys/__tests__/utils.d.ts +25 -0
  197. package/build/ts/sessionKeys/__tests__/utils.d.ts.map +1 -0
  198. package/build/ts/sessionKeys/__tests__/utils.js +64 -0
  199. package/build/ts/sessionKeys/__tests__/utils.js.map +1 -0
  200. package/build/ts/sessionKeys/dto.d.ts +11 -0
  201. package/build/ts/sessionKeys/dto.d.ts.map +1 -0
  202. package/build/ts/sessionKeys/dto.js +29 -0
  203. package/build/ts/sessionKeys/dto.js.map +1 -0
  204. package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts +53 -0
  205. package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts.map +1 -0
  206. package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js +105 -0
  207. package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js.map +1 -0
  208. package/build/ts/sessionKeys/sessionKeys.controller.d.ts +26 -0
  209. package/build/ts/sessionKeys/sessionKeys.controller.d.ts.map +1 -0
  210. package/build/ts/sessionKeys/sessionKeys.controller.js +74 -0
  211. package/build/ts/sessionKeys/sessionKeys.controller.js.map +1 -0
  212. package/build/ts/sessionKeys/sessionKeys.module.d.ts +3 -0
  213. package/build/ts/sessionKeys/sessionKeys.module.d.ts.map +1 -0
  214. package/build/ts/sessionKeys/sessionKeys.module.js +23 -0
  215. package/build/ts/sessionKeys/sessionKeys.module.js.map +1 -0
  216. package/build/ts/sessionKeys/sessionKeys.service.d.ts +61 -0
  217. package/build/ts/sessionKeys/sessionKeys.service.d.ts.map +1 -0
  218. package/build/ts/sessionKeys/sessionKeys.service.js +122 -0
  219. package/build/ts/sessionKeys/sessionKeys.service.js.map +1 -0
  220. package/build/ts/sessionKeys/types.d.ts +11 -0
  221. package/build/ts/sessionKeys/types.d.ts.map +1 -0
  222. package/build/ts/sessionKeys/types.js +2 -0
  223. package/build/ts/sessionKeys/types.js.map +1 -0
  224. package/build/ts/subgraph/__tests__/subgraph.controller.test.d.ts +2 -0
  225. package/build/ts/subgraph/__tests__/subgraph.controller.test.d.ts.map +1 -0
  226. package/build/ts/subgraph/__tests__/subgraph.controller.test.js +50 -0
  227. package/build/ts/subgraph/__tests__/subgraph.controller.test.js.map +1 -0
  228. package/build/ts/subgraph/__tests__/subgraph.gateway.test.d.ts +2 -0
  229. package/build/ts/subgraph/__tests__/subgraph.gateway.test.d.ts.map +1 -0
  230. package/build/ts/subgraph/__tests__/subgraph.gateway.test.js +83 -0
  231. package/build/ts/subgraph/__tests__/subgraph.gateway.test.js.map +1 -0
  232. package/build/ts/subgraph/__tests__/subgraph.service.test.d.ts +2 -0
  233. package/build/ts/subgraph/__tests__/subgraph.service.test.d.ts.map +1 -0
  234. package/build/ts/subgraph/__tests__/subgraph.service.test.js +58 -0
  235. package/build/ts/subgraph/__tests__/subgraph.service.test.js.map +1 -0
  236. package/build/ts/subgraph/dto.d.ts +27 -0
  237. package/build/ts/subgraph/dto.d.ts.map +1 -0
  238. package/build/ts/subgraph/dto.js +83 -0
  239. package/build/ts/subgraph/dto.js.map +1 -0
  240. package/build/ts/subgraph/subgraph.controller.d.ts +24 -0
  241. package/build/ts/subgraph/subgraph.controller.d.ts.map +1 -0
  242. package/build/ts/subgraph/subgraph.controller.js +66 -0
  243. package/build/ts/subgraph/subgraph.controller.js.map +1 -0
  244. package/build/ts/subgraph/subgraph.gateway.d.ts +35 -0
  245. package/build/ts/subgraph/subgraph.gateway.d.ts.map +1 -0
  246. package/build/ts/subgraph/subgraph.gateway.js +93 -0
  247. package/build/ts/subgraph/subgraph.gateway.js.map +1 -0
  248. package/build/ts/subgraph/subgraph.module.d.ts +3 -0
  249. package/build/ts/subgraph/subgraph.module.d.ts.map +1 -0
  250. package/build/ts/subgraph/subgraph.module.js +23 -0
  251. package/build/ts/subgraph/subgraph.module.js.map +1 -0
  252. package/build/ts/subgraph/subgraph.service.d.ts +20 -0
  253. package/build/ts/subgraph/subgraph.service.d.ts.map +1 -0
  254. package/build/ts/subgraph/subgraph.service.js +106 -0
  255. package/build/ts/subgraph/subgraph.service.js.map +1 -0
  256. package/build/ts/subgraph/types.d.ts +93 -0
  257. package/build/ts/subgraph/types.d.ts.map +1 -0
  258. package/build/ts/subgraph/types.js +24 -0
  259. package/build/ts/subgraph/types.js.map +1 -0
  260. package/build/tsconfig.build.tsbuildinfo +1 -0
  261. package/package.json +125 -0
@@ -0,0 +1,344 @@
1
+ import { EPolicies, EInitialVoiceCreditProxies, EMode } from "@maci-protocol/sdk";
2
+ import { SendUserOperationParameters } from "viem/account-abstraction";
3
+ import type { Abi, Hex } from "viem";
4
+ import { ESupportedNetworks } from "../common";
5
+ /**
6
+ * IDeployMACIArgs represents the arguments for deploying MACI
7
+ */
8
+ export interface IDeployMaciArgs {
9
+ /**
10
+ * The address of the session key
11
+ */
12
+ sessionKeyAddress?: Hex;
13
+ /**
14
+ * The approval for the session key
15
+ */
16
+ approval?: string;
17
+ /**
18
+ * The chain name
19
+ */
20
+ chain: ESupportedNetworks;
21
+ /**
22
+ * The configuration for deploying MACI
23
+ */
24
+ config: IDeployMaciConfig;
25
+ }
26
+ /**
27
+ * IDeployPollArgs represents the arguments for deploying a poll
28
+ */
29
+ export interface IDeployPollArgs {
30
+ /**
31
+ * The address of the session key
32
+ */
33
+ sessionKeyAddress?: Hex;
34
+ /**
35
+ * The approval for the session key
36
+ */
37
+ approval?: string;
38
+ /**
39
+ * The chain name
40
+ */
41
+ chain: ESupportedNetworks;
42
+ /**
43
+ * The configuration for deploying a poll
44
+ */
45
+ config: IDeployPollConfig;
46
+ }
47
+ /**
48
+ * IConstantInitialVoiceCreditProxyArgs represents the arguments for deploying a constant initial voice credit proxy
49
+ */
50
+ export interface IConstantInitialVoiceCreditProxyArgs {
51
+ /**
52
+ * The amount of initial voice credits to deploy
53
+ */
54
+ amount: number;
55
+ }
56
+ /**
57
+ * IEASPolicyArgs represents the arguments for deploying an EAS policy
58
+ */
59
+ export interface IEASPolicyArgs {
60
+ /**
61
+ * The address of the EAS contract
62
+ */
63
+ easAddress: string;
64
+ /**
65
+ * The attestation schema to be used
66
+ */
67
+ schema: string;
68
+ /**
69
+ * The trusted attester
70
+ */
71
+ attester: string;
72
+ }
73
+ /**
74
+ * IZupassPolicyArgs represents the arguments for deploying a Zupass policy
75
+ */
76
+ export interface IZupassPolicyArgs {
77
+ /**
78
+ * The first signer
79
+ */
80
+ signer1: string;
81
+ /**
82
+ * The second signer
83
+ */
84
+ signer2: string;
85
+ /**
86
+ * The event ID
87
+ */
88
+ eventId: string;
89
+ /**
90
+ * The Zupass verifier address
91
+ */
92
+ zupassVerifier: string;
93
+ }
94
+ /**
95
+ * IHatsPolicyArgs represents the arguments for deploying a Hats policy
96
+ */
97
+ export interface IHatsPolicyArgs {
98
+ /**
99
+ * The hats protocol address
100
+ */
101
+ hatsProtocolAddress: string;
102
+ /**
103
+ * The criterion hats
104
+ */
105
+ critrionHats: string[];
106
+ }
107
+ /**
108
+ * ISemaphorePolicyArgs represents the arguments for deploying a semaphore policy
109
+ */
110
+ export interface ISemaphorePolicyArgs {
111
+ /**
112
+ * The semaphore contract address
113
+ */
114
+ semaphoreContract: string;
115
+ /**
116
+ * The group ID
117
+ */
118
+ groupId: string;
119
+ }
120
+ /**
121
+ * IMerkleProofPolicyArgs represents the arguments for deploying a merkle proof policy
122
+ */
123
+ export interface IMerkleProofPolicyArgs {
124
+ /**
125
+ * The merkle proof root
126
+ */
127
+ root: string;
128
+ }
129
+ /**
130
+ * ITokenPolicyArgs represents the arguments for deploying a sign up policy
131
+ */
132
+ export interface ITokenPolicyArgs {
133
+ /**
134
+ * The token address
135
+ */
136
+ token: string;
137
+ }
138
+ /**
139
+ * IAnonAadhaarPolicyArgs represents the arguments for deploying an Anon Aadhaar policy
140
+ */
141
+ export interface IAnonAadhaarPolicyArgs {
142
+ /**
143
+ * The Anon Aadhaar verifier address
144
+ */
145
+ verifier: string;
146
+ /**
147
+ * The nullifier seed
148
+ */
149
+ nullifierSeed: string;
150
+ }
151
+ /**
152
+ * IGitcoinPassportPolicyArgs represents the arguments for deploying a gitcoin passport policy
153
+ */
154
+ export interface IGitcoinPassportPolicyArgs {
155
+ /**
156
+ * The decoder address
157
+ */
158
+ decoderAddress: string;
159
+ /**
160
+ * The passing score
161
+ */
162
+ passingScore: string;
163
+ }
164
+ /**
165
+ * IERC20VotesPolicyArgs represents the arguments for deploying an ERC20 votes policy
166
+ */
167
+ export interface IERC20VotesPolicyArgs {
168
+ /**
169
+ * The token address
170
+ */
171
+ token: string;
172
+ /**
173
+ * The threshold
174
+ */
175
+ threshold: bigint | string;
176
+ /**
177
+ * The snapshot block
178
+ */
179
+ snapshotBlock: bigint | string;
180
+ }
181
+ /**
182
+ * IERC20PolicyArgs represents the arguments for deploying an ERC20 policy
183
+ */
184
+ export interface IERC20PolicyArgs {
185
+ /**
186
+ * The token address
187
+ */
188
+ token: string;
189
+ /**
190
+ * The threshold
191
+ */
192
+ threshold: string;
193
+ }
194
+ /**
195
+ * IVerifyingKeysRegistryArgs represents the arguments for deploying a VerifyingKeysRegistry
196
+ */
197
+ export interface IVerifyingKeysRegistryArgs {
198
+ /**
199
+ * The state tree depth
200
+ */
201
+ stateTreeDepth: bigint | string;
202
+ /**
203
+ * The poll state tree depth
204
+ */
205
+ pollStateTreeDepth: bigint | string;
206
+ /**
207
+ * The int state tree depth determines the tally batch size
208
+ */
209
+ tallyProcessingStateTreeDepth: bigint | string;
210
+ /**
211
+ * The vote option tree depth
212
+ */
213
+ voteOptionTreeDepth: bigint | string;
214
+ /**
215
+ * The message batch size
216
+ */
217
+ messageBatchSize: number;
218
+ }
219
+ /**
220
+ * IPolicyArgs represents the arguments for deploying a policy
221
+ */
222
+ export type IPolicyArgs = IEASPolicyArgs | IZupassPolicyArgs | IHatsPolicyArgs | ISemaphorePolicyArgs | IMerkleProofPolicyArgs | ITokenPolicyArgs | IAnonAadhaarPolicyArgs | IGitcoinPassportPolicyArgs | IERC20VotesPolicyArgs | IERC20PolicyArgs;
223
+ export type IInitialVoiceCreditProxyArgs = IConstantInitialVoiceCreditProxyArgs;
224
+ /**
225
+ * DeployMaciConfig is the configuration for deploying MACI
226
+ */
227
+ export interface IDeployMaciConfig {
228
+ /**
229
+ * The policy configuration
230
+ */
231
+ policy: {
232
+ type: EPolicies;
233
+ args?: IPolicyArgs;
234
+ };
235
+ /**
236
+ * The MACI configuration
237
+ */
238
+ MACI: {
239
+ stateTreeDepth: number;
240
+ policy: EPolicies;
241
+ };
242
+ /**
243
+ * The VerifyingKeysRegistry configuration
244
+ */
245
+ VerifyingKeysRegistry: {
246
+ args: IVerifyingKeysRegistryArgs;
247
+ };
248
+ /**
249
+ * Poseidon configuration
250
+ */
251
+ Poseidon?: {
252
+ poseidonT3: Hex;
253
+ poseidonT4: Hex;
254
+ poseidonT5: Hex;
255
+ poseidonT6: Hex;
256
+ };
257
+ }
258
+ /**
259
+ * DeployPollConfig is the configuration for deploying a poll
260
+ */
261
+ export interface IDeployPollConfig {
262
+ /**
263
+ * The poll's start date
264
+ */
265
+ startDate: number;
266
+ /**
267
+ * The poll's end date
268
+ */
269
+ endDate: number;
270
+ /**
271
+ * The coordinator publicKey
272
+ */
273
+ coordinatorPublicKey: string;
274
+ /**
275
+ * Voting mode
276
+ */
277
+ mode: EMode;
278
+ /**
279
+ * Determines the tally batch size
280
+ */
281
+ tallyProcessingStateTreeDepth: number;
282
+ /**
283
+ * Message batch size
284
+ */
285
+ messageBatchSize: number;
286
+ /**
287
+ * Poll state tree depth
288
+ */
289
+ pollStateTreeDepth: number;
290
+ /**
291
+ * Vote option tree depth
292
+ */
293
+ voteOptionTreeDepth: number;
294
+ /**
295
+ * The policy configuration
296
+ */
297
+ policy: {
298
+ type: EPolicies;
299
+ args?: IPolicyArgs;
300
+ address?: Hex;
301
+ };
302
+ /**
303
+ * The initial voice credits proxy configuration
304
+ */
305
+ initialVoiceCreditsProxy: {
306
+ type: EInitialVoiceCreditProxies;
307
+ args: IInitialVoiceCreditProxyArgs;
308
+ address?: Hex;
309
+ };
310
+ /**
311
+ * The relayer addresses
312
+ */
313
+ relayers?: string[];
314
+ /**
315
+ * Number of valid vote options
316
+ */
317
+ voteOptions: bigint | string;
318
+ }
319
+ /**
320
+ * IContractData represents the data for a contract
321
+ */
322
+ export interface IContractData {
323
+ /**
324
+ * The contract's address
325
+ */
326
+ address: string | undefined;
327
+ /**
328
+ * The ABI of the contract
329
+ */
330
+ abi: Abi;
331
+ /**
332
+ * The bytecode of the contract
333
+ */
334
+ bytecode: Hex;
335
+ /**
336
+ * Whether the contract is already deployed
337
+ */
338
+ alreadyDeployed: boolean;
339
+ }
340
+ /**
341
+ * IUserOperation represents the data send for a user operation
342
+ */
343
+ export type IUserOperation = SendUserOperationParameters;
344
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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C;IAE5B;;OAEG;IACH,MAAM,EAAE;QACN,IAAI,EAAE,SAAS,CAAC;QAChB,IAAI,CAAC,EAAE,WAAW,CAAC;QACnB,OAAO,CAAC,EAAE,GAAG,CAAC;KACf,CAAC;IAEF;;OAEG;IACH,wBAAwB,EAAE;QACxB,IAAI,EAAE,0BAA0B,CAAC;QACjC,IAAI,EAAE,4BAA4B,CAAC;QACnC,OAAO,CAAC,EAAE,GAAG,CAAC;KACf,CAAC;IAEF;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,GAAG,EAAE,GAAG,CAAC;IAET;;OAEG;IACH,QAAQ,EAAE,GAAG,CAAC;IAEd;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/deployer/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=file.service.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.service.test.d.ts","sourceRoot":"","sources":["../../../../ts/file/__tests__/file.service.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,77 @@
1
+ import { EMode } from "@maci-protocol/sdk";
2
+ import dotenv from "dotenv";
3
+ import fs from "fs";
4
+ import { ErrorCodes } from "../../common";
5
+ import { FileService } from "../file.service";
6
+ dotenv.config();
7
+ describe("FileService", () => {
8
+ afterEach(() => {
9
+ jest.clearAllMocks();
10
+ });
11
+ test("should save session key properly", () => {
12
+ const service = new FileService();
13
+ const sessionKeyAddress = "0x123";
14
+ const sessionKey = "0x456";
15
+ service.storeSessionKey(sessionKey, sessionKeyAddress);
16
+ const storedSessionKey = service.getSessionKey(sessionKeyAddress);
17
+ expect(storedSessionKey).toEqual(sessionKey);
18
+ });
19
+ test("should delete session key properly", () => {
20
+ const service = new FileService();
21
+ const sessionKeyAddress = "0x123";
22
+ const sessionKey = "0x456";
23
+ service.storeSessionKey(sessionKey, sessionKeyAddress);
24
+ service.deleteSessionKey(sessionKeyAddress);
25
+ const deletedSessionKey = service.getSessionKey(sessionKeyAddress);
26
+ expect(deletedSessionKey).toBeUndefined();
27
+ });
28
+ test("should return public key properly", async () => {
29
+ const service = new FileService();
30
+ const { publicKey } = await service.getPublicKey();
31
+ expect(publicKey).toBeDefined();
32
+ });
33
+ test("should return private key properly", async () => {
34
+ const service = new FileService();
35
+ const { privateKey } = await service.getPrivateKey();
36
+ expect(privateKey).toBeDefined();
37
+ });
38
+ test("should return zkey filepaths for tally qv properly", () => {
39
+ const service = new FileService();
40
+ const { zkey, wasm, witgen } = service.getZkeyFilePaths(process.env.COORDINATOR_TALLY_ZKEY_NAME, EMode.QV);
41
+ expect(zkey).toBeDefined();
42
+ expect(wasm).toBeDefined();
43
+ expect(witgen).toBeDefined();
44
+ });
45
+ test("should return zkey filepaths for tally non-qv properly", () => {
46
+ const service = new FileService();
47
+ const { zkey, wasm, witgen } = service.getZkeyFilePaths(process.env.COORDINATOR_TALLY_ZKEY_NAME, EMode.NON_QV);
48
+ expect(zkey).toBeDefined();
49
+ expect(wasm).toBeDefined();
50
+ expect(witgen).toBeDefined();
51
+ });
52
+ test("should return zkey filepaths for message process qv properly", () => {
53
+ const service = new FileService();
54
+ const { zkey, wasm, witgen } = service.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, EMode.QV);
55
+ expect(zkey).toBeDefined();
56
+ expect(wasm).toBeDefined();
57
+ expect(witgen).toBeDefined();
58
+ });
59
+ test("should return zkey filepaths for message process non-qv properly", () => {
60
+ const service = new FileService();
61
+ const { zkey, wasm, witgen } = service.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, EMode.NON_QV);
62
+ expect(zkey).toBeDefined();
63
+ expect(wasm).toBeDefined();
64
+ expect(witgen).toBeDefined();
65
+ });
66
+ test("should throw an error if there are no zkey filepaths", () => {
67
+ const service = new FileService();
68
+ expect(() => service.getZkeyFilePaths("unknown", EMode.NON_QV)).toThrow(ErrorCodes.FILE_NOT_FOUND.toString());
69
+ });
70
+ test("should throw an error if there are no wasm and witgen filepaths", () => {
71
+ const spyExistsSync = jest.spyOn(fs, "existsSync");
72
+ spyExistsSync.mockReturnValueOnce(true).mockReturnValue(false);
73
+ const service = new FileService();
74
+ expect(() => service.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, EMode.NON_QV)).toThrow(ErrorCodes.FILE_NOT_FOUND.toString());
75
+ });
76
+ });
77
+ //# sourceMappingURL=file.service.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.service.test.js","sourceRoot":"","sources":["../../../../ts/file/__tests__/file.service.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC5C,MAAM,OAAO,GAAG,IAAI,WAAW,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,CAC9G,UAAU,CAAC,cAAc,CAAC,QAAQ,EAAE,CACrC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare class FileModule {
2
+ }
3
+ //# sourceMappingURL=file.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.module.d.ts","sourceRoot":"","sources":["../../../ts/file/file.module.ts"],"names":[],"mappings":"AAIA,qBAIa,UAAU;CAAG"}
@@ -0,0 +1,18 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Module } from "@nestjs/common";
8
+ import { FileService } from "./file.service";
9
+ let FileModule = class FileModule {
10
+ };
11
+ FileModule = __decorate([
12
+ Module({
13
+ exports: [FileService],
14
+ providers: [FileService],
15
+ })
16
+ ], FileModule);
17
+ export { FileModule };
18
+ //# sourceMappingURL=file.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.module.js","sourceRoot":"","sources":["../../../ts/file/file.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMtC,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,UAAU;IAJtB,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,WAAW,CAAC;QACtB,SAAS,EAAE,CAAC,WAAW,CAAC;KACzB,CAAC;GACW,UAAU,CAAG"}
@@ -0,0 +1,63 @@
1
+ import { EMode } from "@maci-protocol/sdk";
2
+ import type { IGetPrivateKeyData, IGetPublicKeyData, IGetZkeyFilePathsData } from "./types";
3
+ import type { Hex } from "viem";
4
+ /**
5
+ * FileService is responsible for working with local files like:
6
+ * 1. RSA public/private keys
7
+ * 2. Zkey files
8
+ */
9
+ export declare class FileService {
10
+ /**
11
+ * Logger
12
+ */
13
+ private readonly logger;
14
+ /**
15
+ * Json file database instance
16
+ */
17
+ private db;
18
+ /**
19
+ * Initialize service
20
+ */
21
+ constructor();
22
+ /**
23
+ * Store session key
24
+ *
25
+ * @param sessionKey - session key
26
+ * @param address - key address
27
+ */
28
+ storeSessionKey(sessionKey: Hex, address: string): void;
29
+ /**
30
+ * Delete session key
31
+ *
32
+ * @param address - key address
33
+ */
34
+ deleteSessionKey(address: string): void;
35
+ /**
36
+ * Get session key
37
+ *
38
+ * @param address - key name
39
+ * @returns session key
40
+ */
41
+ getSessionKey(address: string): Hex | undefined;
42
+ /**
43
+ * Get RSA private key for coordinator service
44
+ *
45
+ * @returns serialized RSA public key
46
+ */
47
+ getPublicKey(): Promise<IGetPublicKeyData>;
48
+ /**
49
+ * Get RSA private key for coordinator service
50
+ *
51
+ * @returns serialized RSA private key
52
+ */
53
+ getPrivateKey(): Promise<IGetPrivateKeyData>;
54
+ /**
55
+ * Get zkey, wasm and witgen filepaths for zkey set
56
+ *
57
+ * @param name - zkey set name
58
+ * @param mode - voting mode
59
+ * @returns zkey and wasm filepaths
60
+ */
61
+ getZkeyFilePaths(name: string, mode: EMode): IGetZkeyFilePathsData;
62
+ }
63
+ //# sourceMappingURL=file.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.service.d.ts","sourceRoot":"","sources":["../../../ts/file/file.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAQ3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAUhC;;;;GAIG;AACH,qBACa,WAAW;IACtB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;OAEG;IACH,OAAO,CAAC,EAAE,CAA0B;IAEpC;;OAEG;;IAMH;;;;;OAKG;IACH,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAIvD;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIvC;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAI/C;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAMhD;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAMlD;;;;;;OAMG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,qBAAqB;CA4BnE"}
@@ -0,0 +1,120 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var FileService_1;
11
+ import { EMode } from "@maci-protocol/sdk";
12
+ import { Injectable, Logger } from "@nestjs/common";
13
+ import low from "lowdb";
14
+ import FileSync from "lowdb/adapters/FileSync";
15
+ import fs from "fs";
16
+ import path from "path";
17
+ import { ErrorCodes } from "../common";
18
+ /**
19
+ * FileService is responsible for working with local files like:
20
+ * 1. RSA public/private keys
21
+ * 2. Zkey files
22
+ */
23
+ let FileService = FileService_1 = class FileService {
24
+ /**
25
+ * Logger
26
+ */
27
+ logger;
28
+ /**
29
+ * Json file database instance
30
+ */
31
+ db;
32
+ /**
33
+ * Initialize service
34
+ */
35
+ constructor() {
36
+ this.logger = new Logger(FileService_1.name);
37
+ this.db = low(new FileSync(path.resolve(process.cwd(), "./session-keys.json")));
38
+ }
39
+ /**
40
+ * Store session key
41
+ *
42
+ * @param sessionKey - session key
43
+ * @param address - key address
44
+ */
45
+ storeSessionKey(sessionKey, address) {
46
+ this.db.set(address, sessionKey).write();
47
+ }
48
+ /**
49
+ * Delete session key
50
+ *
51
+ * @param address - key address
52
+ */
53
+ deleteSessionKey(address) {
54
+ this.db.unset(address).write();
55
+ }
56
+ /**
57
+ * Get session key
58
+ *
59
+ * @param address - key name
60
+ * @returns session key
61
+ */
62
+ getSessionKey(address) {
63
+ return this.db.get(address).value();
64
+ }
65
+ /**
66
+ * Get RSA private key for coordinator service
67
+ *
68
+ * @returns serialized RSA public key
69
+ */
70
+ async getPublicKey() {
71
+ const publicKey = await fs.promises.readFile(path.resolve(process.env.COORDINATOR_PUBLIC_KEY_PATH));
72
+ return { publicKey: publicKey.toString() };
73
+ }
74
+ /**
75
+ * Get RSA private key for coordinator service
76
+ *
77
+ * @returns serialized RSA private key
78
+ */
79
+ async getPrivateKey() {
80
+ const privateKey = await fs.promises.readFile(path.resolve(process.env.COORDINATOR_PRIVATE_KEY_PATH));
81
+ return { privateKey: privateKey.toString() };
82
+ }
83
+ /**
84
+ * Get zkey, wasm and witgen filepaths for zkey set
85
+ *
86
+ * @param name - zkey set name
87
+ * @param mode - voting mode
88
+ * @returns zkey and wasm filepaths
89
+ */
90
+ getZkeyFilePaths(name, mode) {
91
+ const root = path.resolve(process.env.COORDINATOR_ZKEY_PATH);
92
+ const index = name.indexOf("_");
93
+ const type = name.slice(0, index);
94
+ const params = name.slice(index + 1);
95
+ const modePrefixes = {
96
+ [EMode.QV]: "",
97
+ [EMode.NON_QV]: "NonQv",
98
+ [EMode.FULL]: "Full",
99
+ };
100
+ const filename = `${type}${modePrefixes[mode]}_${params}`;
101
+ const zkey = path.resolve(root, `${filename}/${filename}.0.zkey`);
102
+ const wasm = path.resolve(root, `${filename}/${filename}_js/${filename}.wasm`);
103
+ const witgen = path.resolve(root, `${filename}/${filename}_cpp/${filename}`);
104
+ if (!fs.existsSync(zkey) || (!fs.existsSync(wasm) && !fs.existsSync(witgen))) {
105
+ this.logger.error(`Error: ${ErrorCodes.FILE_NOT_FOUND}, zkey: ${zkey}, wasm: ${wasm}, witgen: ${witgen}`);
106
+ throw new Error(ErrorCodes.FILE_NOT_FOUND.toString());
107
+ }
108
+ return {
109
+ zkey,
110
+ wasm,
111
+ witgen,
112
+ };
113
+ }
114
+ };
115
+ FileService = FileService_1 = __decorate([
116
+ Injectable(),
117
+ __metadata("design:paramtypes", [])
118
+ ], FileService);
119
+ export { FileService };
120
+ //# sourceMappingURL=file.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.service.js","sourceRoot":"","sources":["../../../ts/file/file.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAE/C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAKxB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAQvC;;;;GAIG;AAEI,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACtB;;OAEG;IACc,MAAM,CAAS;IAEh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