@maci-protocol/coordinator 0.0.0-ci.7fb2610 → 0.0.0-ci.805eed1
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.
- package/build/hardhat.config.cjs +6 -3
- package/build/hardhat.config.cjs.map +1 -1
- package/build/hardhat.config.d.cts +6 -4
- package/build/scripts/generateKeypair.js +2 -2
- package/build/scripts/generateKeypair.js.map +1 -1
- package/build/tests/constants.d.ts +3 -3
- package/build/tests/constants.d.ts.map +1 -1
- package/build/tests/constants.js +5 -3
- package/build/tests/constants.js.map +1 -1
- package/build/tests/e2e.deploy.test.js +11 -37
- package/build/tests/e2e.deploy.test.js.map +1 -1
- package/build/tests/e2e.redis.test.d.ts +2 -0
- package/build/tests/e2e.redis.test.d.ts.map +1 -0
- package/build/tests/e2e.redis.test.js +118 -0
- package/build/tests/e2e.redis.test.js.map +1 -0
- package/build/tests/utils.d.ts +1 -1
- package/build/tests/utils.d.ts.map +1 -1
- package/build/tests/utils.js +5 -3
- package/build/tests/utils.js.map +1 -1
- package/build/ts/app.module.d.ts.map +1 -1
- package/build/ts/app.module.js +4 -0
- package/build/ts/app.module.js.map +1 -1
- package/build/ts/common/__tests__/common.test.js +40 -28
- package/build/ts/common/__tests__/common.test.js.map +1 -1
- package/build/ts/common/accountAbstraction.d.ts +5 -5
- package/build/ts/common/accountAbstraction.d.ts.map +1 -1
- package/build/ts/common/accountAbstraction.js +10 -8
- package/build/ts/common/accountAbstraction.js.map +1 -1
- package/build/ts/common/chain.d.ts +10 -4
- package/build/ts/common/chain.d.ts.map +1 -1
- package/build/ts/common/chain.js +15 -9
- package/build/ts/common/chain.js.map +1 -1
- package/build/ts/common/errors.d.ts +15 -11
- package/build/ts/common/errors.d.ts.map +1 -1
- package/build/ts/common/errors.js +15 -11
- package/build/ts/common/errors.js.map +1 -1
- package/build/ts/common/http.d.ts +6 -0
- package/build/ts/common/http.d.ts.map +1 -0
- package/build/ts/common/http.js +49 -0
- package/build/ts/common/http.js.map +1 -0
- package/build/ts/common/index.d.ts +1 -1
- package/build/ts/common/index.d.ts.map +1 -1
- package/build/ts/common/index.js +1 -1
- package/build/ts/common/index.js.map +1 -1
- package/build/ts/common/networks.d.ts +2 -21
- package/build/ts/common/networks.d.ts.map +1 -1
- package/build/ts/common/networks.js +39 -48
- package/build/ts/common/networks.js.map +1 -1
- package/build/ts/common/types.d.ts +2 -2
- package/build/ts/common/types.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/deployer.controller.test.js +17 -19
- package/build/ts/deployer/__tests__/deployer.controller.test.js.map +1 -1
- package/build/ts/deployer/__tests__/deployer.service.test.js +171 -113
- package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -1
- package/build/ts/deployer/__tests__/utils.d.ts +8 -8
- package/build/ts/deployer/__tests__/utils.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/utils.js +11 -8
- package/build/ts/deployer/__tests__/utils.js.map +1 -1
- package/build/ts/deployer/deployer.controller.d.ts.map +1 -1
- package/build/ts/deployer/deployer.controller.js +19 -6
- package/build/ts/deployer/deployer.controller.js.map +1 -1
- package/build/ts/deployer/deployer.service.d.ts +15 -5
- package/build/ts/deployer/deployer.service.d.ts.map +1 -1
- package/build/ts/deployer/deployer.service.js +78 -34
- package/build/ts/deployer/deployer.service.js.map +1 -1
- package/build/ts/deployer/dto.d.ts +3 -3
- package/build/ts/deployer/dto.d.ts.map +1 -1
- package/build/ts/deployer/dto.js +5 -5
- package/build/ts/deployer/dto.js.map +1 -1
- package/build/ts/deployer/types.d.ts +25 -21
- package/build/ts/deployer/types.d.ts.map +1 -1
- package/build/ts/file/file.service.d.ts.map +1 -1
- package/build/ts/file/file.service.js +2 -1
- package/build/ts/file/file.service.js.map +1 -1
- package/build/ts/health/__tests__/health.controller.test.js +37 -7
- package/build/ts/health/__tests__/health.controller.test.js.map +1 -1
- package/build/ts/health/__tests__/health.service.test.js +40 -16
- package/build/ts/health/__tests__/health.service.test.js.map +1 -1
- package/build/ts/health/health.module.d.ts.map +1 -1
- package/build/ts/health/health.module.js +2 -1
- package/build/ts/health/health.module.js.map +1 -1
- package/build/ts/health/health.service.d.ts +8 -1
- package/build/ts/health/health.service.d.ts.map +1 -1
- package/build/ts/health/health.service.js +38 -31
- package/build/ts/health/health.service.js.map +1 -1
- package/build/ts/health/types.d.ts +13 -5
- package/build/ts/health/types.d.ts.map +1 -1
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.d.ts +11 -0
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.d.ts.map +1 -0
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.js +12 -0
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.js.map +1 -0
- package/build/ts/proof/__tests__/proof.controller.test.js +5 -6
- package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.gateway.test.js +2 -3
- package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.service.test.js +4 -9
- package/build/ts/proof/__tests__/proof.service.test.js.map +1 -1
- package/build/ts/proof/dto.d.ts +4 -5
- package/build/ts/proof/dto.d.ts.map +1 -1
- package/build/ts/proof/dto.js +7 -8
- package/build/ts/proof/dto.js.map +1 -1
- package/build/ts/proof/proof.controller.d.ts.map +1 -1
- package/build/ts/proof/proof.controller.js +37 -11
- package/build/ts/proof/proof.controller.js.map +1 -1
- package/build/ts/proof/proof.module.d.ts.map +1 -1
- package/build/ts/proof/proof.module.js +1 -0
- package/build/ts/proof/proof.module.js.map +1 -1
- package/build/ts/proof/proof.service.d.ts.map +1 -1
- package/build/ts/proof/proof.service.js.map +1 -1
- package/build/ts/proof/types.d.ts +4 -5
- package/build/ts/proof/types.d.ts.map +1 -1
- package/build/ts/proof/types.js.map +1 -1
- package/build/ts/redis/__tests__/redis.service.test.d.ts +2 -0
- package/build/ts/redis/__tests__/redis.service.test.d.ts.map +1 -0
- package/build/ts/redis/__tests__/redis.service.test.js +148 -0
- package/build/ts/redis/__tests__/redis.service.test.js.map +1 -0
- package/build/ts/redis/redis.module.d.ts +3 -0
- package/build/ts/redis/redis.module.d.ts.map +1 -0
- package/build/ts/redis/redis.module.js +18 -0
- package/build/ts/redis/redis.module.js.map +1 -0
- package/build/ts/redis/redis.service.d.ts +53 -0
- package/build/ts/redis/redis.service.d.ts.map +1 -0
- package/build/ts/redis/redis.service.js +99 -0
- package/build/ts/redis/redis.service.js.map +1 -0
- package/build/ts/redis/types.d.ts +66 -0
- package/build/ts/redis/types.d.ts.map +1 -0
- package/build/ts/redis/types.js +2 -0
- package/build/ts/redis/types.js.map +1 -0
- package/build/ts/redis/utils.d.ts +20 -0
- package/build/ts/redis/utils.d.ts.map +1 -0
- package/build/ts/redis/utils.js +27 -0
- package/build/ts/redis/utils.js.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.d.ts +2 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.d.ts.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.js +62 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.js.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.d.ts +2 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.d.ts.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.js +369 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.js.map +1 -0
- package/build/ts/scheduler/dto.d.ts +41 -0
- package/build/ts/scheduler/dto.d.ts.map +1 -0
- package/build/ts/scheduler/dto.js +115 -0
- package/build/ts/scheduler/dto.js.map +1 -0
- package/build/ts/scheduler/scheduler.controller.d.ts +32 -0
- package/build/ts/scheduler/scheduler.controller.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.controller.js +118 -0
- package/build/ts/scheduler/scheduler.controller.js.map +1 -0
- package/build/ts/scheduler/scheduler.module.d.ts +3 -0
- package/build/ts/scheduler/scheduler.module.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.module.js +24 -0
- package/build/ts/scheduler/scheduler.module.js.map +1 -0
- package/build/ts/scheduler/scheduler.service.d.ts +71 -0
- package/build/ts/scheduler/scheduler.service.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.service.js +297 -0
- package/build/ts/scheduler/scheduler.service.js.map +1 -0
- package/build/ts/scheduler/types.d.ts +65 -0
- package/build/ts/scheduler/types.d.ts.map +1 -0
- package/build/ts/scheduler/types.js +2 -0
- package/build/ts/scheduler/types.js.map +1 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js +34 -19
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js.map +1 -1
- package/build/ts/sessionKeys/__tests__/utils.d.ts +1 -1
- package/build/ts/sessionKeys/__tests__/utils.d.ts.map +1 -1
- package/build/ts/sessionKeys/__tests__/utils.js +7 -6
- package/build/ts/sessionKeys/__tests__/utils.js.map +1 -1
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts +1 -1
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts.map +1 -1
- package/build/ts/sessionKeys/sessionKeys.service.d.ts +4 -3
- package/build/ts/sessionKeys/sessionKeys.service.d.ts.map +1 -1
- package/build/ts/sessionKeys/sessionKeys.service.js +1 -2
- package/build/ts/sessionKeys/sessionKeys.service.js.map +1 -1
- package/build/ts/subgraph/__tests__/subgraph.controller.test.js +3 -3
- package/build/ts/subgraph/__tests__/subgraph.controller.test.js.map +1 -1
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.js +2 -2
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.js.map +1 -1
- package/build/ts/subgraph/__tests__/subgraph.service.test.js +3 -2
- package/build/ts/subgraph/__tests__/subgraph.service.test.js.map +1 -1
- package/build/ts/subgraph/dto.d.ts +2 -2
- package/build/ts/subgraph/dto.d.ts.map +1 -1
- package/build/ts/subgraph/dto.js +3 -3
- package/build/ts/subgraph/dto.js.map +1 -1
- package/build/ts/subgraph/subgraph.controller.d.ts.map +1 -1
- package/build/ts/subgraph/subgraph.controller.js +8 -3
- package/build/ts/subgraph/subgraph.controller.js.map +1 -1
- package/build/ts/subgraph/subgraph.service.d.ts.map +1 -1
- package/build/ts/subgraph/subgraph.service.js +7 -5
- package/build/ts/subgraph/subgraph.service.js.map +1 -1
- package/build/ts/subgraph/types.d.ts +2 -2
- package/build/ts/subgraph/types.d.ts.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +32 -25
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ESupportedChains } from "@maci-protocol/sdk";
|
|
2
|
+
import { arbitrum, arbitrumSepolia, base, baseSepolia, gnosis, gnosisChiado, hardhat, linea, lineaSepolia, localhost, mainnet, optimism, optimismSepolia, polygon, polygonAmoy, polygonZkEvm, polygonZkEvmCardona, scroll, scrollSepolia, sepolia, zksync, zksyncSepoliaTestnet, } from "viem/chains";
|
|
2
3
|
import { ErrorCodes } from "./errors";
|
|
3
|
-
export var ESupportedNetworks;
|
|
4
|
-
(function (ESupportedNetworks) {
|
|
5
|
-
ESupportedNetworks["ETHEREUM"] = "mainnet";
|
|
6
|
-
ESupportedNetworks["OPTIMISM"] = "optimism";
|
|
7
|
-
ESupportedNetworks["OPTIMISM_SEPOLIA"] = "optimism-sepolia";
|
|
8
|
-
ESupportedNetworks["BSC"] = "bsc";
|
|
9
|
-
ESupportedNetworks["BSC_CHAPEL"] = "chapel";
|
|
10
|
-
ESupportedNetworks["GNOSIS_CHAIN"] = "gnosis";
|
|
11
|
-
ESupportedNetworks["POLYGON"] = "matic";
|
|
12
|
-
ESupportedNetworks["ARBITRUM_ONE"] = "arbitrum-one";
|
|
13
|
-
ESupportedNetworks["HOLESKY"] = "holesky";
|
|
14
|
-
ESupportedNetworks["LINEA_SEPOLIA"] = "linea-sepolia";
|
|
15
|
-
ESupportedNetworks["BASE_SEPOLIA"] = "base-sepolia";
|
|
16
|
-
ESupportedNetworks["ETHEREUM_SEPOLIA"] = "sepolia";
|
|
17
|
-
ESupportedNetworks["ARBITRUM_SEPOLIA"] = "arbitrum-sepolia";
|
|
18
|
-
ESupportedNetworks["LINEA"] = "linea";
|
|
19
|
-
ESupportedNetworks["BASE"] = "base";
|
|
20
|
-
ESupportedNetworks["SCROLL_SEPOLIA"] = "scroll-sepolia";
|
|
21
|
-
ESupportedNetworks["SCROLL"] = "scroll";
|
|
22
|
-
ESupportedNetworks["LOCALHOST"] = "localhost";
|
|
23
|
-
})(ESupportedNetworks || (ESupportedNetworks = {}));
|
|
24
4
|
/**
|
|
25
5
|
* Get the Viem chain for a given network
|
|
26
6
|
*
|
|
@@ -29,39 +9,50 @@ export var ESupportedNetworks;
|
|
|
29
9
|
*/
|
|
30
10
|
export const viemChain = (network) => {
|
|
31
11
|
switch (network) {
|
|
32
|
-
case
|
|
12
|
+
case ESupportedChains.Mainnet:
|
|
33
13
|
return mainnet;
|
|
34
|
-
case
|
|
14
|
+
case ESupportedChains.Sepolia:
|
|
35
15
|
return sepolia;
|
|
36
|
-
case
|
|
16
|
+
case ESupportedChains.Optimism:
|
|
17
|
+
return optimism;
|
|
18
|
+
case ESupportedChains.OptimismSepolia:
|
|
19
|
+
return optimismSepolia;
|
|
20
|
+
case ESupportedChains.Scroll:
|
|
21
|
+
return scroll;
|
|
22
|
+
case ESupportedChains.ScrollSepolia:
|
|
23
|
+
return scrollSepolia;
|
|
24
|
+
case ESupportedChains.Arbitrum:
|
|
37
25
|
return arbitrum;
|
|
38
|
-
case
|
|
26
|
+
case ESupportedChains.ArbitrumSepolia:
|
|
39
27
|
return arbitrumSepolia;
|
|
40
|
-
case
|
|
41
|
-
return baseSepolia;
|
|
42
|
-
case ESupportedNetworks.LINEA_SEPOLIA:
|
|
43
|
-
return lineaSepolia;
|
|
44
|
-
case ESupportedNetworks.SCROLL_SEPOLIA:
|
|
45
|
-
return scrollSepolia;
|
|
46
|
-
case ESupportedNetworks.SCROLL:
|
|
47
|
-
return scroll;
|
|
48
|
-
case ESupportedNetworks.BASE:
|
|
28
|
+
case ESupportedChains.Base:
|
|
49
29
|
return base;
|
|
50
|
-
case
|
|
51
|
-
return
|
|
52
|
-
case
|
|
53
|
-
return linea;
|
|
54
|
-
case ESupportedNetworks.BSC:
|
|
55
|
-
return bsc;
|
|
56
|
-
case ESupportedNetworks.GNOSIS_CHAIN:
|
|
30
|
+
case ESupportedChains.BaseSepolia:
|
|
31
|
+
return baseSepolia;
|
|
32
|
+
case ESupportedChains.Gnosis:
|
|
57
33
|
return gnosis;
|
|
58
|
-
case
|
|
34
|
+
case ESupportedChains.GnosisChiado:
|
|
35
|
+
return gnosisChiado;
|
|
36
|
+
case ESupportedChains.Polygon:
|
|
59
37
|
return polygon;
|
|
60
|
-
case
|
|
61
|
-
return
|
|
62
|
-
case
|
|
63
|
-
return
|
|
64
|
-
case
|
|
38
|
+
case ESupportedChains.PolygonAmoy:
|
|
39
|
+
return polygonAmoy;
|
|
40
|
+
case ESupportedChains.Linea:
|
|
41
|
+
return linea;
|
|
42
|
+
case ESupportedChains.LineaSepolia:
|
|
43
|
+
return lineaSepolia;
|
|
44
|
+
case ESupportedChains.ZkSyncEra:
|
|
45
|
+
return zksync;
|
|
46
|
+
case ESupportedChains.ZkSyncSepolia:
|
|
47
|
+
return zksyncSepoliaTestnet;
|
|
48
|
+
case ESupportedChains.PolygonZkEvm:
|
|
49
|
+
return polygonZkEvm;
|
|
50
|
+
case ESupportedChains.PolygonCardonaZkEvm:
|
|
51
|
+
return polygonZkEvmCardona;
|
|
52
|
+
// coverage is not supported by viem and it wont be used in the coordinator
|
|
53
|
+
case ESupportedChains.Hardhat:
|
|
54
|
+
return hardhat;
|
|
55
|
+
case ESupportedChains.Localhost:
|
|
65
56
|
return localhost;
|
|
66
57
|
default:
|
|
67
58
|
throw new Error(ErrorCodes.UNSUPPORTED_NETWORK.toString());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networks.js","sourceRoot":"","sources":["../../../ts/common/networks.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,IAAI,EACJ,WAAW,
|
|
1
|
+
{"version":3,"file":"networks.js","sourceRoot":"","sources":["../../../ts/common/networks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,QAAQ,EACR,eAAe,EACf,IAAI,EACJ,WAAW,EAEX,MAAM,EACN,YAAY,EACZ,OAAO,EACP,KAAK,EACL,YAAY,EACZ,SAAS,EACT,OAAO,EACP,QAAQ,EACR,eAAe,EACf,OAAO,EACP,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,OAAO,EACP,MAAM,EACN,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAyB,EAAS,EAAE;IAC5D,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,gBAAgB,CAAC,OAAO;YAC3B,OAAO,OAAO,CAAC;QACjB,KAAK,gBAAgB,CAAC,OAAO;YAC3B,OAAO,OAAO,CAAC;QACjB,KAAK,gBAAgB,CAAC,QAAQ;YAC5B,OAAO,QAAQ,CAAC;QAClB,KAAK,gBAAgB,CAAC,eAAe;YACnC,OAAO,eAAe,CAAC;QACzB,KAAK,gBAAgB,CAAC,MAAM;YAC1B,OAAO,MAAM,CAAC;QAChB,KAAK,gBAAgB,CAAC,aAAa;YACjC,OAAO,aAAa,CAAC;QACvB,KAAK,gBAAgB,CAAC,QAAQ;YAC5B,OAAO,QAAQ,CAAC;QAClB,KAAK,gBAAgB,CAAC,eAAe;YACnC,OAAO,eAAe,CAAC;QACzB,KAAK,gBAAgB,CAAC,IAAI;YACxB,OAAO,IAAI,CAAC;QACd,KAAK,gBAAgB,CAAC,WAAW;YAC/B,OAAO,WAAW,CAAC;QACrB,KAAK,gBAAgB,CAAC,MAAM;YAC1B,OAAO,MAAM,CAAC;QAChB,KAAK,gBAAgB,CAAC,YAAY;YAChC,OAAO,YAAY,CAAC;QACtB,KAAK,gBAAgB,CAAC,OAAO;YAC3B,OAAO,OAAO,CAAC;QACjB,KAAK,gBAAgB,CAAC,WAAW;YAC/B,OAAO,WAAW,CAAC;QACrB,KAAK,gBAAgB,CAAC,KAAK;YACzB,OAAO,KAAK,CAAC;QACf,KAAK,gBAAgB,CAAC,YAAY;YAChC,OAAO,YAAY,CAAC;QACtB,KAAK,gBAAgB,CAAC,SAAS;YAC7B,OAAO,MAAM,CAAC;QAChB,KAAK,gBAAgB,CAAC,aAAa;YACjC,OAAO,oBAAoB,CAAC;QAC9B,KAAK,gBAAgB,CAAC,YAAY;YAChC,OAAO,YAAY,CAAC;QACtB,KAAK,gBAAgB,CAAC,mBAAmB;YACvC,OAAO,mBAAmB,CAAC;QAC7B,2EAA2E;QAC3E,KAAK,gBAAgB,CAAC,OAAO;YAC3B,OAAO,OAAO,CAAC;QACjB,KAAK,gBAAgB,CAAC,SAAS;YAC7B,OAAO,SAAS,CAAC;QACnB;YACE,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CreateKernelAccountReturnType, KernelAccountClient } from "@zerodev/sdk";
|
|
2
|
-
import { BundlerClient } from "viem/account-abstraction";
|
|
1
|
+
import { type CreateKernelAccountReturnType, type KernelAccountClient } from "@zerodev/sdk";
|
|
2
|
+
import { type BundlerClient } from "viem/account-abstraction";
|
|
3
3
|
import type { Chain, HttpTransport, PublicClient, Transport } from "viem";
|
|
4
4
|
export type KernelClientType = KernelAccountClient<Transport, Chain, CreateKernelAccountReturnType>;
|
|
5
5
|
export type BundlerClientType = BundlerClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,6BAA6B,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1E,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,SAAS,EAAE,KAAK,EAAE,6BAA6B,CAAC,CAAC;AAEpG,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAE9C,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAE9D,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { ESupportedChains } from "@maci-protocol/sdk";
|
|
1
2
|
import { Test } from "@nestjs/testing";
|
|
2
3
|
import { zeroAddress } from "viem";
|
|
3
|
-
import { ErrorCodes
|
|
4
|
-
import { FileService } from "../../file/file.service";
|
|
5
|
-
import { generateApproval } from "../../sessionKeys/__tests__/utils";
|
|
6
|
-
import { SessionKeysService } from "../../sessionKeys/sessionKeys.service";
|
|
4
|
+
import { ErrorCodes } from "../../common";
|
|
7
5
|
import { DeployerController } from "../deployer.controller";
|
|
8
6
|
import { DeployerService } from "../deployer.service";
|
|
9
7
|
import { testMaciDeploymentConfig, testPollDeploymentConfig } from "./utils";
|
|
@@ -18,15 +16,8 @@ describe("DeployerController", () => {
|
|
|
18
16
|
};
|
|
19
17
|
const defaultDeployMaciReturn = zeroAddress;
|
|
20
18
|
const defaultDeployPollReturn = "0";
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const sessionKeyService = new SessionKeysService(fileService);
|
|
24
|
-
let approval;
|
|
25
|
-
let sessionKeyAddress;
|
|
26
|
-
beforeAll(async () => {
|
|
27
|
-
sessionKeyAddress = (await sessionKeyService.generateSessionKey()).sessionKeyAddress;
|
|
28
|
-
approval = await generateApproval(sessionKeyAddress);
|
|
29
|
-
});
|
|
19
|
+
const approval = "approval";
|
|
20
|
+
const sessionKeyAddress = zeroAddress;
|
|
30
21
|
beforeEach(async () => {
|
|
31
22
|
const app = await Test.createTestingModule({
|
|
32
23
|
controllers: [DeployerController],
|
|
@@ -42,10 +33,13 @@ describe("DeployerController", () => {
|
|
|
42
33
|
.compile();
|
|
43
34
|
deployerController = app.get(DeployerController);
|
|
44
35
|
});
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
jest.clearAllMocks();
|
|
38
|
+
});
|
|
45
39
|
describe("v1/deploy/maci", () => {
|
|
46
40
|
test("should deploy all contracts", async () => {
|
|
47
41
|
const { address } = await deployerController.deployMACIContracts({
|
|
48
|
-
chain:
|
|
42
|
+
chain: ESupportedChains.OptimismSepolia,
|
|
49
43
|
approval,
|
|
50
44
|
sessionKeyAddress,
|
|
51
45
|
config: testMaciDeploymentConfig,
|
|
@@ -53,8 +47,10 @@ describe("DeployerController", () => {
|
|
|
53
47
|
expect(address).toEqual(defaultDeployMaciReturn);
|
|
54
48
|
});
|
|
55
49
|
test("should return 400 bad request when the service throws", async () => {
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
mockDeployerService.deployMaci.mockRejectedValue(new Error(ErrorCodes.SESSION_KEY_NOT_FOUND.toString()));
|
|
51
|
+
const controller = new DeployerController(mockDeployerService);
|
|
52
|
+
await expect(controller.deployMACIContracts({
|
|
53
|
+
chain: ESupportedChains.OptimismSepolia,
|
|
58
54
|
approval: "0x123",
|
|
59
55
|
sessionKeyAddress: "0x123",
|
|
60
56
|
config: testMaciDeploymentConfig,
|
|
@@ -64,7 +60,7 @@ describe("DeployerController", () => {
|
|
|
64
60
|
describe("v1/deploy/poll", () => {
|
|
65
61
|
test("should deploy a new poll", async () => {
|
|
66
62
|
const { pollId } = await deployerController.deployPoll({
|
|
67
|
-
chain:
|
|
63
|
+
chain: ESupportedChains.OptimismSepolia,
|
|
68
64
|
approval,
|
|
69
65
|
sessionKeyAddress,
|
|
70
66
|
config: testPollDeploymentConfig,
|
|
@@ -72,8 +68,10 @@ describe("DeployerController", () => {
|
|
|
72
68
|
expect(pollId).toEqual(defaultDeployPollReturn);
|
|
73
69
|
});
|
|
74
70
|
test("should return 400 bad request when the service throws", async () => {
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
mockDeployerService.deployPoll.mockRejectedValue(new Error(ErrorCodes.SESSION_KEY_NOT_FOUND.toString()));
|
|
72
|
+
const controller = new DeployerController(mockDeployerService);
|
|
73
|
+
await expect(controller.deployPoll({
|
|
74
|
+
chain: ESupportedChains.OptimismSepolia,
|
|
77
75
|
approval: "0x123",
|
|
78
76
|
sessionKeyAddress: "0x123",
|
|
79
77
|
config: testPollDeploymentConfig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployer.controller.test.js","sourceRoot":"","sources":["../../../../ts/deployer/__tests__/deployer.controller.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"deployer.controller.test.js","sourceRoot":"","sources":["../../../../ts/deployer/__tests__/deployer.controller.test.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,114 +1,184 @@
|
|
|
1
|
-
import { ContractStorage,
|
|
1
|
+
import { ContractStorage, deployFreeForAllSignUpPolicy, deployPoll, deployVerifier, deployVerifyingKeysRegistryContract, deployMaci, deployConstantInitialVoiceCreditProxyFactory, deployConstantInitialVoiceCreditProxy, getDeployedPolicyProxyFactories, ECheckerFactories, EContracts, EInitialVoiceCreditProxies, EInitialVoiceCreditProxiesFactories, EPolicies, EPolicyFactories, ESupportedChains, ECheckers, } from "@maci-protocol/sdk";
|
|
2
2
|
import dotenv from "dotenv";
|
|
3
|
-
import { BaseContract } from "ethers";
|
|
4
3
|
import { zeroAddress } from "viem";
|
|
5
|
-
import
|
|
6
|
-
import { ErrorCodes, ESupportedNetworks } from "../../common";
|
|
7
|
-
import { FileService } from "../../file/file.service";
|
|
8
|
-
import { generateApproval } from "../../sessionKeys/__tests__/utils";
|
|
9
|
-
import { SessionKeysService } from "../../sessionKeys/sessionKeys.service";
|
|
4
|
+
import { ErrorCodes } from "../../common";
|
|
10
5
|
import { DeployerService } from "../deployer.service";
|
|
11
6
|
import { testMaciDeploymentConfig, testPollDeploymentConfig } from "./utils";
|
|
12
7
|
dotenv.config();
|
|
8
|
+
jest.mock("@maci-protocol/sdk", () => ({
|
|
9
|
+
...jest.requireActual("@maci-protocol/sdk"),
|
|
10
|
+
ContractStorage: {
|
|
11
|
+
getInstance: jest.fn(),
|
|
12
|
+
},
|
|
13
|
+
deployFreeForAllSignUpPolicy: jest.fn(),
|
|
14
|
+
deployPoll: jest.fn(),
|
|
15
|
+
deployVerifyingKeysRegistryContract: jest.fn(),
|
|
16
|
+
deployVerifier: jest.fn(),
|
|
17
|
+
getDeployedPolicyProxyFactories: jest.fn(),
|
|
18
|
+
setVerifyingKeys: jest.fn(),
|
|
19
|
+
deployMaci: jest.fn(),
|
|
20
|
+
deployConstantInitialVoiceCreditProxyFactory: jest.fn(),
|
|
21
|
+
deployConstantInitialVoiceCreditProxy: jest.fn(),
|
|
22
|
+
}));
|
|
13
23
|
describe("DeployerService", () => {
|
|
24
|
+
const chain = ESupportedChains.OptimismSepolia;
|
|
25
|
+
const signer = {
|
|
26
|
+
getAddress: jest.fn().mockResolvedValue(zeroAddress),
|
|
27
|
+
};
|
|
28
|
+
const approval = "approval";
|
|
29
|
+
const sessionKeyAddress = zeroAddress;
|
|
30
|
+
const mockStorage = {
|
|
31
|
+
register: jest.fn(),
|
|
32
|
+
getAddress: jest.fn(),
|
|
33
|
+
};
|
|
34
|
+
const mockContract = {
|
|
35
|
+
deploymentTransaction: jest.fn(),
|
|
36
|
+
getAddress: jest.fn().mockResolvedValue(zeroAddress.replace("0x0", "0x1")),
|
|
37
|
+
};
|
|
38
|
+
const fileService = {
|
|
39
|
+
getZkeyFilePaths: jest.fn(),
|
|
40
|
+
};
|
|
41
|
+
const sessionKeyService = {
|
|
42
|
+
getCoordinatorSigner: jest.fn().mockResolvedValue(signer),
|
|
43
|
+
};
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
mockStorage.getAddress = jest.fn().mockReturnValue(zeroAddress);
|
|
46
|
+
sessionKeyService.getCoordinatorSigner = jest.fn().mockResolvedValue(signer);
|
|
47
|
+
fileService.getZkeyFilePaths = jest.fn().mockReturnValue({ zkey: "" });
|
|
48
|
+
ContractStorage.getInstance.mockReturnValue(mockStorage);
|
|
49
|
+
deployFreeForAllSignUpPolicy.mockResolvedValue([
|
|
50
|
+
mockContract,
|
|
51
|
+
mockContract,
|
|
52
|
+
mockContract,
|
|
53
|
+
mockContract,
|
|
54
|
+
]);
|
|
55
|
+
deployVerifier.mockResolvedValue(mockContract);
|
|
56
|
+
deployVerifyingKeysRegistryContract.mockResolvedValue(mockContract);
|
|
57
|
+
deployConstantInitialVoiceCreditProxyFactory.mockResolvedValue(mockContract);
|
|
58
|
+
deployConstantInitialVoiceCreditProxy.mockResolvedValue(mockContract);
|
|
59
|
+
deployPoll.mockResolvedValue({
|
|
60
|
+
pollContractAddress: zeroAddress,
|
|
61
|
+
messageProcessorContractAddress: zeroAddress,
|
|
62
|
+
tallyContractAddress: zeroAddress,
|
|
63
|
+
pollId: 0n,
|
|
64
|
+
});
|
|
65
|
+
deployMaci.mockResolvedValue({
|
|
66
|
+
maciContractAddress: zeroAddress.replace("0x0", "0x1"),
|
|
67
|
+
pollFactoryContractAddress: zeroAddress,
|
|
68
|
+
messageProcessorFactoryContractAddress: zeroAddress,
|
|
69
|
+
tallyFactoryContractAddress: zeroAddress,
|
|
70
|
+
poseidonAddresses: {
|
|
71
|
+
poseidonT3: zeroAddress,
|
|
72
|
+
poseidonT4: zeroAddress,
|
|
73
|
+
poseidonT5: zeroAddress,
|
|
74
|
+
poseidonT6: zeroAddress,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
getDeployedPolicyProxyFactories.mockResolvedValue({ checker: undefined, policy: undefined });
|
|
78
|
+
});
|
|
14
79
|
afterEach(() => {
|
|
15
80
|
jest.clearAllMocks();
|
|
16
81
|
});
|
|
17
|
-
const chain = ESupportedNetworks.OPTIMISM_SEPOLIA;
|
|
18
|
-
const fileService = new FileService();
|
|
19
|
-
const storageInstance = ContractStorage.getInstance(path.join(process.cwd(), "deployed-contracts.json"));
|
|
20
|
-
const sessionKeyService = new SessionKeysService(fileService);
|
|
21
|
-
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
22
|
-
let approval;
|
|
23
|
-
let sessionKeyAddress;
|
|
24
|
-
let signer;
|
|
25
|
-
beforeAll(async () => {
|
|
26
|
-
sessionKeyAddress = (await sessionKeyService.generateSessionKey()).sessionKeyAddress;
|
|
27
|
-
approval = await generateApproval(sessionKeyAddress);
|
|
28
|
-
signer = await sessionKeyService.getCoordinatorSigner(chain);
|
|
29
|
-
});
|
|
30
|
-
afterAll(() => {
|
|
31
|
-
storageInstance.cleanup(ESupportedNetworks.OPTIMISM_SEPOLIA);
|
|
32
|
-
storageInstance.cleanup(ESupportedNetworks.ARBITRUM_ONE);
|
|
33
|
-
});
|
|
34
82
|
describe("deployAndSavePolicy", () => {
|
|
35
|
-
// we cleanup after each test so we don't have leftover saved contracts
|
|
36
|
-
afterEach(() => {
|
|
37
|
-
storageInstance.cleanup(chain);
|
|
38
|
-
});
|
|
39
83
|
test("should throw when the policy is not existent", async () => {
|
|
40
|
-
|
|
84
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
85
|
+
await expect(deployerService.deployAndSavePolicy(signer, chain, {
|
|
86
|
+
policyType: "NonExistent",
|
|
87
|
+
checkerType: "NonExistent",
|
|
88
|
+
})).rejects.toThrow(ErrorCodes.UNSUPPORTED_POLICY.toString());
|
|
41
89
|
});
|
|
42
90
|
test("should deploy policy if none is stored", async () => {
|
|
43
|
-
const
|
|
91
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
92
|
+
const policy = await deployerService.deployAndSavePolicy(signer, chain, {
|
|
93
|
+
policyType: EPolicies.FreeForAll,
|
|
94
|
+
checkerType: ECheckers.FreeForAll,
|
|
95
|
+
});
|
|
44
96
|
expect(policy).toBeDefined();
|
|
45
97
|
expect(await policy.getAddress()).not.toBe(zeroAddress);
|
|
46
98
|
});
|
|
47
99
|
test("should save factories (policy and checker) after deploying policy", async () => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
100
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
101
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
102
|
+
policyType: EPolicies.FreeForAll,
|
|
103
|
+
checkerType: ECheckers.FreeForAll,
|
|
104
|
+
});
|
|
105
|
+
expect(mockStorage.register).toHaveBeenCalledTimes(4);
|
|
106
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(1, {
|
|
107
|
+
id: EPolicies.FreeForAll,
|
|
108
|
+
name: EPolicies.FreeForAll,
|
|
109
|
+
contract: mockContract,
|
|
110
|
+
args: [await mockContract.getAddress()],
|
|
111
|
+
network: chain,
|
|
112
|
+
});
|
|
113
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(2, {
|
|
114
|
+
id: ECheckers.FreeForAll,
|
|
115
|
+
name: ECheckers.FreeForAll,
|
|
116
|
+
contract: mockContract,
|
|
117
|
+
args: [],
|
|
51
118
|
network: chain,
|
|
52
|
-
signer,
|
|
53
119
|
});
|
|
54
|
-
expect(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
120
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(3, {
|
|
121
|
+
id: EPolicyFactories.FreeForAll,
|
|
122
|
+
name: EPolicyFactories.FreeForAll,
|
|
123
|
+
contract: mockContract,
|
|
124
|
+
network: chain,
|
|
125
|
+
});
|
|
126
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(4, {
|
|
127
|
+
id: ECheckerFactories.FreeForAll,
|
|
128
|
+
name: ECheckerFactories.FreeForAll,
|
|
129
|
+
contract: mockContract,
|
|
60
130
|
network: chain,
|
|
61
|
-
signer,
|
|
62
131
|
});
|
|
63
|
-
expect(checker).toBeDefined();
|
|
64
|
-
expect(policy).toBeDefined();
|
|
65
132
|
});
|
|
66
133
|
test("should reuse policy factories if already stored", async () => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
policy:
|
|
70
|
-
checker: ECheckerFactories.FreeForAll,
|
|
71
|
-
network: chain,
|
|
72
|
-
signer,
|
|
134
|
+
getDeployedPolicyProxyFactories.mockResolvedValue({
|
|
135
|
+
checker: mockContract,
|
|
136
|
+
policy: mockContract,
|
|
73
137
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
expect(firstCheckerFactoryAddress).not.toBe(zeroAddress);
|
|
79
|
-
expect(firstPolicyFactoryAddress).not.toBe(zeroAddress);
|
|
80
|
-
const secondPolicy = await deployerService.deployAndSavePolicy(signer, chain, {
|
|
81
|
-
type: EPolicies.FreeForAll,
|
|
138
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
139
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
140
|
+
policyType: EPolicies.FreeForAll,
|
|
141
|
+
checkerType: ECheckers.FreeForAll,
|
|
82
142
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
network: chain,
|
|
87
|
-
signer,
|
|
143
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
144
|
+
policyType: EPolicies.FreeForAll,
|
|
145
|
+
checkerType: ECheckers.FreeForAll,
|
|
88
146
|
});
|
|
89
|
-
expect(
|
|
90
|
-
expect(secondPolicyFactory).toBeDefined();
|
|
91
|
-
expect(await secondCheckerFactory.getAddress()).toBe(firstCheckerFactoryAddress);
|
|
92
|
-
expect(await secondPolicyFactory.getAddress()).toBe(firstPolicyFactoryAddress);
|
|
93
|
-
expect(await firstPolicy.getAddress()).not.toBe(await secondPolicy.getAddress());
|
|
147
|
+
expect(mockStorage.register).toHaveBeenCalledTimes(4);
|
|
94
148
|
});
|
|
95
149
|
});
|
|
96
|
-
describe("
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
150
|
+
describe("deployAndSaveVoiceCreditProxyFactory", () => {
|
|
151
|
+
test("should throw when the voice credit proxy factory is not existent", async () => {
|
|
152
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
153
|
+
await expect(deployerService.deployAndSaveVoiceCreditProxyFactory(signer, "NonExistent", chain)).rejects.toThrow(ErrorCodes.UNSUPPORTED_VOICE_CREDIT_PROXY_FACTORY.toString());
|
|
154
|
+
});
|
|
155
|
+
test("should deploy voice credit proxy factory if none is stored", async () => {
|
|
156
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
157
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
158
|
+
expect(constantInitialVoiceCreditProxyFactory).toBeDefined();
|
|
159
|
+
expect(await constantInitialVoiceCreditProxyFactory.getAddress()).not.toBe(zeroAddress);
|
|
100
160
|
});
|
|
101
|
-
|
|
102
|
-
|
|
161
|
+
});
|
|
162
|
+
describe("deployAndSaveVoiceCreditProxy", () => {
|
|
163
|
+
test("should throw when the voice credit proxy is not existent", async () => {
|
|
164
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
165
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
166
|
+
await expect(deployerService.deployAndSaveVoiceCreditProxy(signer, "NonExistent", chain, constantInitialVoiceCreditProxyFactory)).rejects.toThrow(ErrorCodes.UNSUPPORTED_VOICE_CREDIT_PROXY.toString());
|
|
103
167
|
});
|
|
104
168
|
test("should deploy voice credit proxy if none is stored", async () => {
|
|
105
|
-
const
|
|
169
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
170
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
171
|
+
const voiceCreditProxy = await deployerService.deployAndSaveVoiceCreditProxy(signer, EInitialVoiceCreditProxies.Constant, chain, constantInitialVoiceCreditProxyFactory, { amount: 100 });
|
|
106
172
|
expect(voiceCreditProxy).toBeDefined();
|
|
107
173
|
expect(await voiceCreditProxy.getAddress()).not.toBe(zeroAddress);
|
|
108
174
|
});
|
|
109
175
|
});
|
|
110
176
|
describe("deployMaci", () => {
|
|
111
177
|
test("should throw when passing a non existent session key address", async () => {
|
|
178
|
+
sessionKeyService.getCoordinatorSigner = jest
|
|
179
|
+
.fn()
|
|
180
|
+
.mockRejectedValue(new Error(ErrorCodes.SESSION_KEY_NOT_FOUND.toString()));
|
|
181
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
112
182
|
await expect(deployerService.deployMaci({
|
|
113
183
|
config: testMaciDeploymentConfig,
|
|
114
184
|
chain,
|
|
@@ -117,6 +187,10 @@ describe("DeployerService", () => {
|
|
|
117
187
|
})).rejects.toThrow(ErrorCodes.SESSION_KEY_NOT_FOUND.toString());
|
|
118
188
|
});
|
|
119
189
|
test("should throw when the approval is not valid", async () => {
|
|
190
|
+
sessionKeyService.getCoordinatorSigner = jest
|
|
191
|
+
.fn()
|
|
192
|
+
.mockRejectedValue(new Error(ErrorCodes.INVALID_APPROVAL.toString()));
|
|
193
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
120
194
|
await expect(deployerService.deployMaci({
|
|
121
195
|
config: testMaciDeploymentConfig,
|
|
122
196
|
chain,
|
|
@@ -125,36 +199,25 @@ describe("DeployerService", () => {
|
|
|
125
199
|
})).rejects.toThrow(ErrorCodes.INVALID_APPROVAL.toString());
|
|
126
200
|
});
|
|
127
201
|
test("should deploy all new contracts", async () => {
|
|
128
|
-
const
|
|
129
|
-
jest.spyOn(DeployerService.prototype, "deployMaci").mockImplementation(mockDeployMaci);
|
|
202
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
130
203
|
const { address: maciAddress } = await deployerService.deployMaci({
|
|
131
204
|
config: testMaciDeploymentConfig,
|
|
132
205
|
chain,
|
|
133
206
|
approval,
|
|
134
207
|
sessionKeyAddress,
|
|
135
208
|
});
|
|
136
|
-
expect(maciAddress).toBe(zeroAddress);
|
|
209
|
+
expect(maciAddress).toBe(zeroAddress.replace("0x0", "0x1"));
|
|
137
210
|
});
|
|
138
211
|
});
|
|
139
212
|
describe("deployPoll", () => {
|
|
140
|
-
afterEach(() => {
|
|
141
|
-
storageInstance.cleanup(chain);
|
|
142
|
-
});
|
|
143
213
|
test("should throw when there is no maci contract deployed", async () => {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
})).rejects.toThrow(ErrorCodes.MACI_NOT_DEPLOYED.toString());
|
|
150
|
-
});
|
|
151
|
-
test("should throw when there is no maci contract deployed to this specific chain", async () => {
|
|
152
|
-
await storageInstance.register({
|
|
153
|
-
id: EContracts.MACI,
|
|
154
|
-
contract: new BaseContract("0x", MACIFactory.abi),
|
|
155
|
-
network: ESupportedNetworks.ARBITRUM_ONE,
|
|
156
|
-
args: [],
|
|
214
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
215
|
+
...mockStorage,
|
|
216
|
+
getAddress: jest
|
|
217
|
+
.fn()
|
|
218
|
+
.mockImplementation((key) => (key !== EContracts.MACI ? zeroAddress : undefined)),
|
|
157
219
|
});
|
|
220
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
158
221
|
await expect(deployerService.deployPoll({
|
|
159
222
|
approval,
|
|
160
223
|
sessionKeyAddress,
|
|
@@ -162,13 +225,14 @@ describe("DeployerService", () => {
|
|
|
162
225
|
config: testPollDeploymentConfig,
|
|
163
226
|
})).rejects.toThrow(ErrorCodes.MACI_NOT_DEPLOYED.toString());
|
|
164
227
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
228
|
+
test("should throw when there is no verifier deployed", async () => {
|
|
229
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
230
|
+
...mockStorage,
|
|
231
|
+
getAddress: jest
|
|
232
|
+
.fn()
|
|
233
|
+
.mockImplementation((key) => (key !== EContracts.Verifier ? zeroAddress : undefined)),
|
|
171
234
|
});
|
|
235
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
172
236
|
await expect(deployerService.deployPoll({
|
|
173
237
|
approval,
|
|
174
238
|
sessionKeyAddress,
|
|
@@ -176,19 +240,14 @@ describe("DeployerService", () => {
|
|
|
176
240
|
config: testPollDeploymentConfig,
|
|
177
241
|
})).rejects.toThrow(ErrorCodes.VERIFIER_NOT_DEPLOYED.toString());
|
|
178
242
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
});
|
|
186
|
-
await storageInstance.register({
|
|
187
|
-
id: EContracts.Verifier,
|
|
188
|
-
contract: new BaseContract("0x", VerifierFactory.abi),
|
|
189
|
-
network: chain,
|
|
190
|
-
args: [],
|
|
243
|
+
test("should throw when there is no verifying keys registry deployed", async () => {
|
|
244
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
245
|
+
...mockStorage,
|
|
246
|
+
getAddress: jest
|
|
247
|
+
.fn()
|
|
248
|
+
.mockImplementation((key) => key !== EContracts.VerifyingKeysRegistry ? zeroAddress : undefined),
|
|
191
249
|
});
|
|
250
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
192
251
|
await expect(deployerService.deployPoll({
|
|
193
252
|
approval,
|
|
194
253
|
sessionKeyAddress,
|
|
@@ -197,8 +256,7 @@ describe("DeployerService", () => {
|
|
|
197
256
|
})).rejects.toThrow(ErrorCodes.VERIFYING_KEYS_REGISTRY_NOT_DEPLOYED.toString());
|
|
198
257
|
});
|
|
199
258
|
test("should deploy a poll", async () => {
|
|
200
|
-
const
|
|
201
|
-
jest.spyOn(DeployerService.prototype, "deployPoll").mockImplementation(mockDeployPoll);
|
|
259
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
202
260
|
const { pollId } = await deployerService.deployPoll({
|
|
203
261
|
config: testPollDeploymentConfig,
|
|
204
262
|
chain,
|