@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,277 @@
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
+ import { EMode } from "@maci-protocol/sdk";
11
+ import { ApiProperty } from "@nestjs/swagger";
12
+ import { IsEnum, IsEthereumAddress, IsInt, IsOptional, IsString, Length, Max, Min } from "class-validator";
13
+ import { ESupportedNetworks } from "../common";
14
+ /**
15
+ * Data transfer object for generate proof
16
+ */
17
+ export class GenerateProofDto {
18
+ /**
19
+ * Poll id
20
+ */
21
+ poll;
22
+ /**
23
+ * Maci contract address
24
+ */
25
+ maciContractAddress;
26
+ /**
27
+ * Voting mode
28
+ */
29
+ mode;
30
+ /**
31
+ * Encrypted coordinator private key with RSA public key (see .env.example)
32
+ */
33
+ encryptedCoordinatorPrivateKey;
34
+ /**
35
+ * Start block for event processing
36
+ */
37
+ startBlock;
38
+ /**
39
+ * End block for event processing
40
+ */
41
+ endBlock;
42
+ /**
43
+ * Blocks per batch for event processing
44
+ */
45
+ blocksPerBatch;
46
+ sessionKeyAddress;
47
+ approval;
48
+ /**
49
+ * Chain Name
50
+ */
51
+ chain;
52
+ }
53
+ __decorate([
54
+ ApiProperty({
55
+ description: "Poll id",
56
+ minimum: 0,
57
+ type: Number,
58
+ }),
59
+ IsInt(),
60
+ Min(0),
61
+ __metadata("design:type", Number)
62
+ ], GenerateProofDto.prototype, "poll", void 0);
63
+ __decorate([
64
+ ApiProperty({
65
+ description: "MACI contract address",
66
+ type: String,
67
+ }),
68
+ IsEthereumAddress(),
69
+ __metadata("design:type", String)
70
+ ], GenerateProofDto.prototype, "maciContractAddress", void 0);
71
+ __decorate([
72
+ ApiProperty({
73
+ description: "Voting mode (qv: 0, non-qv: 1, full: 2)",
74
+ type: Number,
75
+ }),
76
+ IsEnum(EMode),
77
+ __metadata("design:type", Number)
78
+ ], GenerateProofDto.prototype, "mode", void 0);
79
+ __decorate([
80
+ ApiProperty({
81
+ description: "Encrypted coordinator private key with RSA public key (see README.md)",
82
+ minimum: 1,
83
+ maximum: 1024,
84
+ type: String,
85
+ }),
86
+ IsString(),
87
+ Length(1, 1024),
88
+ __metadata("design:type", String)
89
+ ], GenerateProofDto.prototype, "encryptedCoordinatorPrivateKey", void 0);
90
+ __decorate([
91
+ ApiProperty({
92
+ description: "Start block for event parsing",
93
+ minimum: 0,
94
+ type: Number,
95
+ }),
96
+ IsInt(),
97
+ Min(0),
98
+ IsOptional(),
99
+ __metadata("design:type", Number)
100
+ ], GenerateProofDto.prototype, "startBlock", void 0);
101
+ __decorate([
102
+ ApiProperty({
103
+ description: "End block for event parsing",
104
+ minimum: 0,
105
+ type: Number,
106
+ }),
107
+ IsInt(),
108
+ Min(0),
109
+ IsOptional(),
110
+ __metadata("design:type", Number)
111
+ ], GenerateProofDto.prototype, "endBlock", void 0);
112
+ __decorate([
113
+ ApiProperty({
114
+ description: "Blocks per batch for event parsing",
115
+ minimum: 1,
116
+ maximum: 1000,
117
+ type: Number,
118
+ }),
119
+ IsInt(),
120
+ Min(1),
121
+ Max(1000),
122
+ IsOptional(),
123
+ __metadata("design:type", Number)
124
+ ], GenerateProofDto.prototype, "blocksPerBatch", void 0);
125
+ __decorate([
126
+ ApiProperty({
127
+ description: "Session key address",
128
+ type: String,
129
+ required: false,
130
+ }),
131
+ IsOptional(),
132
+ IsEthereumAddress(),
133
+ __metadata("design:type", String)
134
+ ], GenerateProofDto.prototype, "sessionKeyAddress", void 0);
135
+ __decorate([
136
+ ApiProperty({
137
+ description: "Approval",
138
+ type: String,
139
+ required: false,
140
+ }),
141
+ IsOptional(),
142
+ IsString(),
143
+ __metadata("design:type", String)
144
+ ], GenerateProofDto.prototype, "approval", void 0);
145
+ __decorate([
146
+ ApiProperty({
147
+ description: "Chain to which to deploy the contract(s)",
148
+ enum: ESupportedNetworks,
149
+ }),
150
+ IsEnum(ESupportedNetworks),
151
+ __metadata("design:type", String)
152
+ ], GenerateProofDto.prototype, "chain", void 0);
153
+ /**
154
+ * Data transfer object for merge trees
155
+ */
156
+ export class MergeTreesDto {
157
+ /**
158
+ * Poll id
159
+ */
160
+ poll;
161
+ maciContractAddress;
162
+ sessionKeyAddress;
163
+ approval;
164
+ /**
165
+ * Chain Name
166
+ */
167
+ chain;
168
+ }
169
+ __decorate([
170
+ ApiProperty({
171
+ description: "Poll id",
172
+ minimum: 0,
173
+ type: Number,
174
+ }),
175
+ IsInt(),
176
+ Min(0),
177
+ __metadata("design:type", Number)
178
+ ], MergeTreesDto.prototype, "poll", void 0);
179
+ __decorate([
180
+ ApiProperty({
181
+ description: "MACI contract address",
182
+ type: String,
183
+ }),
184
+ IsEthereumAddress(),
185
+ __metadata("design:type", String)
186
+ ], MergeTreesDto.prototype, "maciContractAddress", void 0);
187
+ __decorate([
188
+ ApiProperty({
189
+ description: "Session key address",
190
+ type: String,
191
+ required: false,
192
+ }),
193
+ IsOptional(),
194
+ IsEthereumAddress(),
195
+ __metadata("design:type", String)
196
+ ], MergeTreesDto.prototype, "sessionKeyAddress", void 0);
197
+ __decorate([
198
+ ApiProperty({
199
+ description: "Approval",
200
+ type: String,
201
+ required: false,
202
+ }),
203
+ IsOptional(),
204
+ IsString(),
205
+ __metadata("design:type", String)
206
+ ], MergeTreesDto.prototype, "approval", void 0);
207
+ __decorate([
208
+ ApiProperty({
209
+ description: "Chain to which to deploy the contract(s)",
210
+ enum: ESupportedNetworks,
211
+ }),
212
+ IsEnum(ESupportedNetworks),
213
+ __metadata("design:type", String)
214
+ ], MergeTreesDto.prototype, "chain", void 0);
215
+ /**
216
+ * Data transfer object for submit proofs on-chain
217
+ */
218
+ export class SubmitProofsDto {
219
+ /**
220
+ * Poll id
221
+ */
222
+ pollId;
223
+ maciContractAddress;
224
+ sessionKeyAddress;
225
+ approval;
226
+ /**
227
+ * Chain Name
228
+ */
229
+ chain;
230
+ }
231
+ __decorate([
232
+ ApiProperty({
233
+ description: "Poll id",
234
+ minimum: 0,
235
+ type: Number,
236
+ }),
237
+ IsInt(),
238
+ Min(0),
239
+ __metadata("design:type", Number)
240
+ ], SubmitProofsDto.prototype, "pollId", void 0);
241
+ __decorate([
242
+ ApiProperty({
243
+ description: "MACI contract address",
244
+ type: String,
245
+ }),
246
+ IsEthereumAddress(),
247
+ __metadata("design:type", String)
248
+ ], SubmitProofsDto.prototype, "maciContractAddress", void 0);
249
+ __decorate([
250
+ ApiProperty({
251
+ description: "Session key address",
252
+ type: String,
253
+ required: false,
254
+ }),
255
+ IsOptional(),
256
+ IsEthereumAddress(),
257
+ __metadata("design:type", String)
258
+ ], SubmitProofsDto.prototype, "sessionKeyAddress", void 0);
259
+ __decorate([
260
+ ApiProperty({
261
+ description: "Approval",
262
+ type: String,
263
+ required: false,
264
+ }),
265
+ IsOptional(),
266
+ IsString(),
267
+ __metadata("design:type", String)
268
+ ], SubmitProofsDto.prototype, "approval", void 0);
269
+ __decorate([
270
+ ApiProperty({
271
+ description: "Chain to which to deploy the contract(s)",
272
+ enum: ESupportedNetworks,
273
+ }),
274
+ IsEnum(ESupportedNetworks),
275
+ __metadata("design:type", String)
276
+ ], SubmitProofsDto.prototype, "chain", void 0);
277
+ //# sourceMappingURL=dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto.js","sourceRoot":"","sources":["../../../ts/proof/dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAI3G,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;OAEG;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+ import type { ITallyData } from "@maci-protocol/sdk";
3
+ import { FileService } from "../file/file.service";
4
+ import { IGetPublicKeyData } from "../file/types";
5
+ import { GenerateProofDto, SubmitProofsDto } from "./dto";
6
+ import { ProofGeneratorService } from "./proof.service";
7
+ export declare class ProofController {
8
+ private readonly proofGeneratorService;
9
+ private readonly fileService;
10
+ /**
11
+ * Logger
12
+ */
13
+ private readonly logger;
14
+ /**
15
+ * Initialize ProofController
16
+ *
17
+ * @param proofGeneratorService - proof generator service
18
+ * @param fileService - file service
19
+ */
20
+ constructor(proofGeneratorService: ProofGeneratorService, fileService: FileService);
21
+ /**
22
+ * Generate proofs api method
23
+ *
24
+ * @param args - generate proof dto
25
+ * @returns generated proofs and tally data
26
+ */
27
+ generate(args: GenerateProofDto): Promise<IGenerateData>;
28
+ /**
29
+ * Merge trees api method
30
+ *
31
+ * @param args - merge args
32
+ * @returns whether the trees were successfully merged
33
+ */
34
+ merge(args: IMergeArgs): Promise<boolean>;
35
+ /**
36
+ * Submit proofs on-chain api method
37
+ * @param args - submit proofs on-chain args
38
+ */
39
+ submit(args: SubmitProofsDto): Promise<ITallyData>;
40
+ /**
41
+ * Get RSA public key for authorization setup
42
+ *
43
+ * @returns RSA public key
44
+ */
45
+ getPublicKey(): Promise<IGetPublicKeyData>;
46
+ }
47
+ //# sourceMappingURL=proof.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof.controller.d.ts","sourceRoot":"","sources":["../../../ts/proof/proof.controller.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAiB,eAAe,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,qBAIa,eAAe;IAaxB,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAb9B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAE3D;;;;;OAKG;gBAEgB,qBAAqB,EAAE,qBAAqB,EAC5C,WAAW,EAAE,WAAW;IAG3C;;;;;OAKG;IAMG,QAAQ,CAAS,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAOtE;;;;;OAKG;IAMG,KAAK,CAAS,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAOvD;;;OAGG;IAMG,MAAM,CAAS,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;IAOhE;;;;OAIG;IAKG,YAAY,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAMjD"}
@@ -0,0 +1,135 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ var ProofController_1;
14
+ /* eslint-disable @typescript-eslint/no-shadow */
15
+ import { Body, Controller, Get, HttpException, HttpStatus, Logger, Post, UseGuards } from "@nestjs/common";
16
+ import { ApiBearerAuth, ApiBody, ApiResponse, ApiTags } from "@nestjs/swagger";
17
+ import { AccountSignatureGuard, Public } from "../auth/AccountSignatureGuard.service";
18
+ import { FileService } from "../file/file.service";
19
+ import { GenerateProofDto, MergeTreesDto, SubmitProofsDto } from "./dto";
20
+ import { ProofGeneratorService } from "./proof.service";
21
+ let ProofController = ProofController_1 = class ProofController {
22
+ proofGeneratorService;
23
+ fileService;
24
+ /**
25
+ * Logger
26
+ */
27
+ logger = new Logger(ProofController_1.name);
28
+ /**
29
+ * Initialize ProofController
30
+ *
31
+ * @param proofGeneratorService - proof generator service
32
+ * @param fileService - file service
33
+ */
34
+ constructor(proofGeneratorService, fileService) {
35
+ this.proofGeneratorService = proofGeneratorService;
36
+ this.fileService = fileService;
37
+ }
38
+ /**
39
+ * Generate proofs api method
40
+ *
41
+ * @param args - generate proof dto
42
+ * @returns generated proofs and tally data
43
+ */
44
+ async generate(args) {
45
+ return this.proofGeneratorService.generate(args).catch((error) => {
46
+ this.logger.error(`Error:`, error);
47
+ throw new HttpException(error.message, HttpStatus.BAD_REQUEST);
48
+ });
49
+ }
50
+ /**
51
+ * Merge trees api method
52
+ *
53
+ * @param args - merge args
54
+ * @returns whether the trees were successfully merged
55
+ */
56
+ async merge(args) {
57
+ return this.proofGeneratorService.merge(args).catch((error) => {
58
+ this.logger.error(`Error:`, error);
59
+ throw new HttpException(error.message, HttpStatus.BAD_REQUEST);
60
+ });
61
+ }
62
+ /**
63
+ * Submit proofs on-chain api method
64
+ * @param args - submit proofs on-chain args
65
+ */
66
+ async submit(args) {
67
+ return this.proofGeneratorService.submit(args).catch((error) => {
68
+ this.logger.error(`Error:`, error);
69
+ throw new HttpException(error.message, HttpStatus.BAD_REQUEST);
70
+ });
71
+ }
72
+ /**
73
+ * Get RSA public key for authorization setup
74
+ *
75
+ * @returns RSA public key
76
+ */
77
+ async getPublicKey() {
78
+ return this.fileService.getPublicKey().catch((error) => {
79
+ this.logger.error(`Error:`, error);
80
+ throw new HttpException(error.message, HttpStatus.BAD_REQUEST);
81
+ });
82
+ }
83
+ };
84
+ __decorate([
85
+ ApiBody({ type: GenerateProofDto }),
86
+ ApiResponse({ status: HttpStatus.CREATED, description: "The proofs have been successfully generated" }),
87
+ ApiResponse({ status: HttpStatus.FORBIDDEN, description: "Forbidden" }),
88
+ ApiResponse({ status: HttpStatus.BAD_REQUEST, description: "BadRequest" }),
89
+ Post("generate"),
90
+ __param(0, Body()),
91
+ __metadata("design:type", Function),
92
+ __metadata("design:paramtypes", [GenerateProofDto]),
93
+ __metadata("design:returntype", Promise)
94
+ ], ProofController.prototype, "generate", null);
95
+ __decorate([
96
+ ApiBody({ type: MergeTreesDto }),
97
+ ApiResponse({ status: HttpStatus.CREATED, description: "The proofs have been successfully merged" }),
98
+ ApiResponse({ status: HttpStatus.FORBIDDEN, description: "Forbidden" }),
99
+ ApiResponse({ status: HttpStatus.BAD_REQUEST, description: "BadRequest" }),
100
+ Post("merge"),
101
+ __param(0, Body()),
102
+ __metadata("design:type", Function),
103
+ __metadata("design:paramtypes", [Object]),
104
+ __metadata("design:returntype", Promise)
105
+ ], ProofController.prototype, "merge", null);
106
+ __decorate([
107
+ ApiBody({ type: SubmitProofsDto }),
108
+ ApiResponse({ status: HttpStatus.CREATED, description: "The proofs have been successfully submitted" }),
109
+ ApiResponse({ status: HttpStatus.FORBIDDEN, description: "Forbidden" }),
110
+ ApiResponse({ status: HttpStatus.BAD_REQUEST, description: "BadRequest" }),
111
+ Post("submit"),
112
+ __param(0, Body()),
113
+ __metadata("design:type", Function),
114
+ __metadata("design:paramtypes", [SubmitProofsDto]),
115
+ __metadata("design:returntype", Promise)
116
+ ], ProofController.prototype, "submit", null);
117
+ __decorate([
118
+ ApiResponse({ status: HttpStatus.OK, description: "Public key was successfully returned" }),
119
+ ApiResponse({ status: HttpStatus.BAD_REQUEST, description: "BadRequest" }),
120
+ Public(),
121
+ Get("publicKey"),
122
+ __metadata("design:type", Function),
123
+ __metadata("design:paramtypes", []),
124
+ __metadata("design:returntype", Promise)
125
+ ], ProofController.prototype, "getPublicKey", null);
126
+ ProofController = ProofController_1 = __decorate([
127
+ ApiTags("v1/proof"),
128
+ ApiBearerAuth(),
129
+ Controller("v1/proof"),
130
+ UseGuards(AccountSignatureGuard),
131
+ __metadata("design:paramtypes", [ProofGeneratorService,
132
+ FileService])
133
+ ], ProofController);
134
+ export { ProofController };
135
+ //# sourceMappingURL=proof.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof.controller.js","sourceRoot":"","sources":["../../../ts/proof/proof.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iDAAiD;AACjD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3G,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAK/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAMjD,IAAM,eAAe,uBAArB,MAAM,eAAe;IAaP;IACA;IAbnB;;OAEG;IACc,MAAM,GAAG,IAAI,MAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;IAE3D;;;;;OAKG;IACH,YACmB,qBAA4C,EAC5C,WAAwB;QADxB,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,gBAAW,GAAX,WAAW,CAAa;IACxC,CAAC;IAEJ;;;;;OAKG;IAMG,AAAN,KAAK,CAAC,QAAQ,CAAS,IAAsB;QAC3C,OAAO,IAAI,CAAC,qB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AY,EAAE,CAAC;IAC1E,IAAI,CAAC,QAAQ,CAAC;IACD,WAAA,IAAI,EAAE,CAAA;;qCAAO,eAAe;;6CAKzC;AAWK;IAJL,WAAW,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;IAC3F,WAAW,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;IAC1E,MAAM,EAAE;IACR,GAAG,CAAC,WAAW,CAAC;;;;mDAMhB;AAnFU,eAAe;IAJ3B,OAAO,CAAC,UAAU,CAAC;IACnB,aAAa,EAAE;IACf,UAAU,CAAC,UAAU,CAAC;IACtB,SAAS,CAAC,qBAAqB,CAAC;qCAcW,qBAAqB;QAC/B,WAAW;GAdhC,eAAe,CAoF3B"}
@@ -0,0 +1,35 @@
1
+ import type { Server } from "socket.io";
2
+ import { GenerateProofDto } from "./dto";
3
+ import { ProofGeneratorService } from "./proof.service";
4
+ /**
5
+ * ProofGateway is responsible for websockets integration between client and ProofGeneratorService.
6
+ */
7
+ export declare class ProofGateway {
8
+ private readonly proofGeneratorService;
9
+ /**
10
+ * Logger
11
+ */
12
+ private readonly logger;
13
+ /**
14
+ * Websocket server
15
+ */
16
+ server: Server;
17
+ /**
18
+ * Initialize ProofGateway
19
+ *
20
+ * @param proofGeneratorService - proof generator service
21
+ */
22
+ constructor(proofGeneratorService: ProofGeneratorService);
23
+ /**
24
+ * Generate proofs api method.
25
+ * Events:
26
+ * 1. EProofGenerationEvents.START - trigger method call
27
+ * 2. EProofGenerationEvents.PROGRESS - returns generated proofs with batch info
28
+ * 3. EProofGenerationEvents.FINISH - returns generated proofs and tally data when available
29
+ * 4. EProofGenerationEvents.ERROR - triggered when exception is thrown
30
+ *
31
+ * @param args - generate proof dto
32
+ */
33
+ generate(data: GenerateProofDto): Promise<void>;
34
+ }
35
+ //# sourceMappingURL=proof.gateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof.gateway.d.ts","sourceRoot":"","sources":["../../../ts/proof/proof.gateway.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAIxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGxD;;GAEG;AACH,qBAMa,YAAY;IAiBX,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAhBlD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IAExD;;OAEG;IAEH,MAAM,EAAG,MAAM,CAAC;IAEhB;;;;OAIG;gBAC0B,qBAAqB,EAAE,qBAAqB;IAEzE;;;;;;;;;OASG;IAUG,QAAQ,CAEZ,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,IAAI,CAAC;CAcjB"}
@@ -0,0 +1,93 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ var ProofGateway_1;
14
+ import { Logger, UseGuards, UsePipes, ValidationPipe } from "@nestjs/common";
15
+ import { MessageBody, SubscribeMessage, WebSocketGateway, WebSocketServer, WsException } from "@nestjs/websockets";
16
+ import { AccountSignatureGuard } from "../auth/AccountSignatureGuard.service";
17
+ import { GenerateProofDto } from "./dto";
18
+ import { ProofGeneratorService } from "./proof.service";
19
+ import { EProofGenerationEvents } from "./types";
20
+ /**
21
+ * ProofGateway is responsible for websockets integration between client and ProofGeneratorService.
22
+ */
23
+ let ProofGateway = ProofGateway_1 = class ProofGateway {
24
+ proofGeneratorService;
25
+ /**
26
+ * Logger
27
+ */
28
+ logger = new Logger(ProofGateway_1.name);
29
+ /**
30
+ * Websocket server
31
+ */
32
+ server;
33
+ /**
34
+ * Initialize ProofGateway
35
+ *
36
+ * @param proofGeneratorService - proof generator service
37
+ */
38
+ constructor(proofGeneratorService) {
39
+ this.proofGeneratorService = proofGeneratorService;
40
+ }
41
+ /**
42
+ * Generate proofs api method.
43
+ * Events:
44
+ * 1. EProofGenerationEvents.START - trigger method call
45
+ * 2. EProofGenerationEvents.PROGRESS - returns generated proofs with batch info
46
+ * 3. EProofGenerationEvents.FINISH - returns generated proofs and tally data when available
47
+ * 4. EProofGenerationEvents.ERROR - triggered when exception is thrown
48
+ *
49
+ * @param args - generate proof dto
50
+ */
51
+ async generate(data) {
52
+ await this.proofGeneratorService.generate(data, {
53
+ onBatchComplete: (result) => {
54
+ this.server.emit(EProofGenerationEvents.PROGRESS, result);
55
+ },
56
+ onComplete: (proofs, tallyData) => {
57
+ this.server.emit(EProofGenerationEvents.FINISH, { proofs, tallyData });
58
+ },
59
+ onFail: (error) => {
60
+ this.logger.error(`Error:`, error);
61
+ this.server.emit(EProofGenerationEvents.ERROR, { message: error.message });
62
+ },
63
+ });
64
+ }
65
+ };
66
+ __decorate([
67
+ WebSocketServer(),
68
+ __metadata("design:type", Function)
69
+ ], ProofGateway.prototype, "server", void 0);
70
+ __decorate([
71
+ SubscribeMessage(EProofGenerationEvents.START),
72
+ UsePipes(new ValidationPipe({
73
+ transform: true,
74
+ exceptionFactory(validationErrors) {
75
+ return new WsException(validationErrors);
76
+ },
77
+ })),
78
+ __param(0, MessageBody()),
79
+ __metadata("design:type", Function),
80
+ __metadata("design:paramtypes", [GenerateProofDto]),
81
+ __metadata("design:returntype", Promise)
82
+ ], ProofGateway.prototype, "generate", null);
83
+ ProofGateway = ProofGateway_1 = __decorate([
84
+ WebSocketGateway({
85
+ cors: {
86
+ origin: process.env.COORDINATOR_ALLOWED_ORIGINS?.split(","),
87
+ },
88
+ }),
89
+ UseGuards(AccountSignatureGuard),
90
+ __metadata("design:paramtypes", [ProofGeneratorService])
91
+ ], ProofGateway);
92
+ export { ProofGateway };
93
+ //# sourceMappingURL=proof.gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof.gateway.js","sourceRoot":"","sources":["../../../ts/proof/proof.gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKnH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD;;GAEG;AAOI,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAiBM;IAhB7B;;OAEG;IACc,MAAM,GAAG,IAAI,MAAM,CAAC,cAAY,CAAC,IAAI,CAAC,CAAC;IAExD;;OAEG;IAEH,MAAM,CAAU;IAEhB;;;;OAIG;IACH,YAA6B,qBAA4C;QAA5C,0BAAqB,GAArB,qBAAqB,CAAuB;IAAG,CAAC;IAE7E;;;;;;;;;OASG;IAUG,AAAN,KAAK,CAAC,QAAQ,CAEZ,IAAsB;QAEtB,MAAM,IAAI,CAAC,qB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
3
+ //# sourceMappingURL=proof.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof.module.d.ts","sourceRoot":"","sources":["../../../ts/proof/proof.module.ts"],"names":[],"mappings":"AAUA,qBAKa,WAAW;CAAG"}
@@ -0,0 +1,24 @@
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 { CryptoModule } from "../crypto/crypto.module";
9
+ import { FileModule } from "../file/file.module";
10
+ import { SessionKeysModule } from "../sessionKeys/sessionKeys.module";
11
+ import { ProofController } from "./proof.controller";
12
+ import { ProofGateway } from "./proof.gateway";
13
+ import { ProofGeneratorService } from "./proof.service";
14
+ let ProofModule = class ProofModule {
15
+ };
16
+ ProofModule = __decorate([
17
+ Module({
18
+ imports: [FileModule, CryptoModule, SessionKeysModule],
19
+ controllers: [ProofController],
20
+ providers: [ProofGeneratorService, ProofGateway],
21
+ })
22
+ ], ProofModule);
23
+ export { ProofModule };
24
+ //# sourceMappingURL=proof.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof.module.js","sourceRoot":"","sources":["../../../ts/proof/proof.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAOjD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IALvB,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,iBAAiB,CAAC;QACtD,WAAW,EAAE,CAAC,eAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,qBAAqB,EAAE,YAAY,CAAC;KACjD,CAAC;GACW,WAAW,CAAG"}