@maci-protocol/coordinator 0.0.0-ci.85bba2d → 0.0.0-ci.86ec64f
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/README.md +18 -0
- 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 +46 -64
- 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 +6 -0
- package/build/ts/app.module.js.map +1 -1
- package/build/ts/common/__tests__/common.test.js +43 -41
- 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 +11 -9
- package/build/ts/common/accountAbstraction.js.map +1 -1
- package/build/ts/common/chain.d.ts +12 -6
- package/build/ts/common/chain.d.ts.map +1 -1
- package/build/ts/common/chain.js +19 -17
- package/build/ts/common/chain.js.map +1 -1
- package/build/ts/common/coordinatorKeypair.d.ts +7 -0
- package/build/ts/common/coordinatorKeypair.d.ts.map +1 -0
- package/build/ts/common/coordinatorKeypair.js +14 -0
- package/build/ts/common/coordinatorKeypair.js.map +1 -0
- package/build/ts/common/errors.d.ts +16 -12
- package/build/ts/common/errors.d.ts.map +1 -1
- package/build/ts/common/errors.js +16 -12
- package/build/ts/common/errors.js.map +1 -1
- package/build/ts/common/index.d.ts +0 -1
- package/build/ts/common/index.d.ts.map +1 -1
- package/build/ts/common/index.js +0 -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/deployer/__tests__/deployer.controller.test.js +23 -25
- package/build/ts/deployer/__tests__/deployer.controller.test.js.map +1 -1
- package/build/ts/deployer/__tests__/deployer.service.test.js +184 -80
- package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -1
- package/build/ts/deployer/__tests__/utils.d.ts +10 -14
- package/build/ts/deployer/__tests__/utils.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/utils.js +15 -17
- package/build/ts/deployer/__tests__/utils.js.map +1 -1
- package/build/ts/deployer/deployer.service.d.ts +17 -8
- package/build/ts/deployer/deployer.service.d.ts.map +1 -1
- package/build/ts/deployer/deployer.service.js +225 -60
- 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 +41 -34
- package/build/ts/deployer/types.d.ts.map +1 -1
- package/build/ts/file/__tests__/file.service.test.js +12 -11
- package/build/ts/file/__tests__/file.service.test.js.map +1 -1
- package/build/ts/file/file.service.d.ts +4 -3
- package/build/ts/file/file.service.d.ts.map +1 -1
- package/build/ts/file/file.service.js +16 -10
- package/build/ts/file/file.service.js.map +1 -1
- package/build/ts/file/types.d.ts +2 -2
- package/build/ts/file/types.d.ts.map +1 -1
- package/build/ts/health/__tests__/health.controller.test.d.ts +2 -0
- package/build/ts/health/__tests__/health.controller.test.d.ts.map +1 -0
- package/build/ts/health/__tests__/health.controller.test.js +52 -0
- package/build/ts/health/__tests__/health.controller.test.js.map +1 -0
- package/build/ts/health/__tests__/health.service.test.d.ts +2 -0
- package/build/ts/health/__tests__/health.service.test.d.ts.map +1 -0
- package/build/ts/health/__tests__/health.service.test.js +101 -0
- package/build/ts/health/__tests__/health.service.test.js.map +1 -0
- package/build/ts/health/health.controller.d.ts +16 -0
- package/build/ts/health/health.controller.d.ts.map +1 -0
- package/build/ts/health/health.controller.js +43 -0
- package/build/ts/health/health.controller.js.map +1 -0
- package/build/ts/health/health.module.d.ts +3 -0
- package/build/ts/health/health.module.d.ts.map +1 -0
- package/build/ts/health/health.module.js +22 -0
- package/build/ts/health/health.module.js.map +1 -0
- package/build/ts/health/health.service.d.ts +42 -0
- package/build/ts/health/health.service.d.ts.map +1 -0
- package/build/ts/health/health.service.js +176 -0
- package/build/ts/health/health.service.js.map +1 -0
- package/build/ts/health/types.d.ts +87 -0
- package/build/ts/health/types.d.ts.map +1 -0
- package/build/ts/health/types.js +2 -0
- package/build/ts/health/types.js.map +1 -0
- 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 +4 -5
- package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.gateway.test.js +3 -4
- package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.service.test.js +28 -74
- package/build/ts/proof/__tests__/proof.service.test.js.map +1 -1
- package/build/ts/proof/dto.d.ts +6 -10
- package/build/ts/proof/dto.d.ts.map +1 -1
- package/build/ts/proof/dto.js +15 -30
- 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 +1 -4
- 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 +2 -4
- package/build/ts/proof/proof.service.d.ts.map +1 -1
- package/build/ts/proof/proof.service.js +26 -27
- package/build/ts/proof/proof.service.js.map +1 -1
- package/build/ts/proof/types.d.ts +6 -10
- 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 +111 -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.controller.test.js +2 -2
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.js.map +1 -1
- 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/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 +2 -2
- 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 +5 -5
- 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.service.d.ts +4 -0
- package/build/ts/subgraph/subgraph.service.d.ts.map +1 -1
- package/build/ts/subgraph/subgraph.service.js +23 -10
- 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 +44 -38
- package/build/tests/e2e.aa.test.d.ts +0 -2
- package/build/tests/e2e.aa.test.d.ts.map +0 -1
- package/build/tests/e2e.aa.test.js +0 -106
- package/build/tests/e2e.aa.test.js.map +0 -1
|
@@ -1,29 +1,10 @@
|
|
|
1
|
+
import { ESupportedChains } from "@maci-protocol/sdk";
|
|
1
2
|
import { type Chain } from "viem/chains";
|
|
2
|
-
export declare enum ESupportedNetworks {
|
|
3
|
-
ETHEREUM = "mainnet",
|
|
4
|
-
OPTIMISM = "optimism",
|
|
5
|
-
OPTIMISM_SEPOLIA = "optimism-sepolia",
|
|
6
|
-
BSC = "bsc",
|
|
7
|
-
BSC_CHAPEL = "chapel",
|
|
8
|
-
GNOSIS_CHAIN = "gnosis",
|
|
9
|
-
POLYGON = "matic",
|
|
10
|
-
ARBITRUM_ONE = "arbitrum-one",
|
|
11
|
-
HOLESKY = "holesky",
|
|
12
|
-
LINEA_SEPOLIA = "linea-sepolia",
|
|
13
|
-
BASE_SEPOLIA = "base-sepolia",
|
|
14
|
-
ETHEREUM_SEPOLIA = "sepolia",
|
|
15
|
-
ARBITRUM_SEPOLIA = "arbitrum-sepolia",
|
|
16
|
-
LINEA = "linea",
|
|
17
|
-
BASE = "base",
|
|
18
|
-
SCROLL_SEPOLIA = "scroll-sepolia",
|
|
19
|
-
SCROLL = "scroll",
|
|
20
|
-
LOCALHOST = "localhost"
|
|
21
|
-
}
|
|
22
3
|
/**
|
|
23
4
|
* Get the Viem chain for a given network
|
|
24
5
|
*
|
|
25
6
|
* @param network - the network to get the chain for
|
|
26
7
|
* @returns the Viem chain
|
|
27
8
|
*/
|
|
28
|
-
export declare const viemChain: (network:
|
|
9
|
+
export declare const viemChain: (network: ESupportedChains) => Chain;
|
|
29
10
|
//# sourceMappingURL=networks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../../../ts/common/networks.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../../../ts/common/networks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAKL,KAAK,KAAK,EAmBX,MAAM,aAAa,CAAC;AAIrB;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,SAAS,gBAAgB,KAAG,KAkDrD,CAAC"}
|
|
@@ -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,S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AA2E;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,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
|
-
approval = await generateApproval(sessionKeyAddress);
|
|
28
|
-
sessionKeyAddress = (await sessionKeyService.generateSessionKey()).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,10 +47,12 @@ 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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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,
|
|
54
|
+
approval: "0x123",
|
|
55
|
+
sessionKeyAddress: "0x123",
|
|
60
56
|
config: testMaciDeploymentConfig,
|
|
61
57
|
})).rejects.toThrow(ErrorCodes.SESSION_KEY_NOT_FOUND.toString());
|
|
62
58
|
});
|
|
@@ -64,18 +60,20 @@ 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:
|
|
68
|
-
approval
|
|
69
|
-
sessionKeyAddress
|
|
63
|
+
chain: ESupportedChains.OptimismSepolia,
|
|
64
|
+
approval,
|
|
65
|
+
sessionKeyAddress,
|
|
70
66
|
config: testPollDeploymentConfig,
|
|
71
67
|
});
|
|
72
68
|
expect(pollId).toEqual(defaultDeployPollReturn);
|
|
73
69
|
});
|
|
74
70
|
test("should return 400 bad request when the service throws", async () => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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,
|
|
75
|
+
approval: "0x123",
|
|
76
|
+
sessionKeyAddress: "0x123",
|
|
79
77
|
config: testPollDeploymentConfig,
|
|
80
78
|
})).rejects.toThrow(ErrorCodes.SESSION_KEY_NOT_FOUND.toString());
|
|
81
79
|
});
|
|
@@ -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":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE7E,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,IAA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AC,QAAQ,EAAE,CAAC,CAAC,CAAC;YAEzG,MAAM,UAAU,GAAG,IAAI,kBAAkB,CAAC,mBAAiD,CAAC,CAAC;YAE7F,MAAM,MAAM,CACV,UAAU,CAAC,UAAU,CAAC;gBACpB,KAAK,EAAE,gBAAgB,CAAC,eAAe;gBACvC,QAAQ,EAAE,OAAO;gBACjB,iBAAiB,EAAE,OAAO;gBAC1B,MAAM,EAAE,wBAAwB;aACjC,CAAC,CACH,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,68 +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 kernelClient;
|
|
25
|
-
let signer;
|
|
26
|
-
beforeAll(async () => {
|
|
27
|
-
sessionKeyAddress = (await sessionKeyService.generateSessionKey()).sessionKeyAddress;
|
|
28
|
-
approval = await generateApproval(sessionKeyAddress);
|
|
29
|
-
kernelClient = await sessionKeyService.generateClientFromSessionKey(sessionKeyAddress, approval, chain);
|
|
30
|
-
signer = await sessionKeyService.getKernelClientSigner(kernelClient);
|
|
31
|
-
});
|
|
32
|
-
afterAll(() => {
|
|
33
|
-
storageInstance.cleanup(ESupportedNetworks.OPTIMISM_SEPOLIA);
|
|
34
|
-
storageInstance.cleanup(ESupportedNetworks.ARBITRUM_ONE);
|
|
35
|
-
});
|
|
36
82
|
describe("deployAndSavePolicy", () => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
83
|
+
test("should throw when the policy is not existent", async () => {
|
|
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());
|
|
43
89
|
});
|
|
44
90
|
test("should deploy policy if none is stored", async () => {
|
|
45
|
-
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
|
+
});
|
|
46
96
|
expect(policy).toBeDefined();
|
|
47
97
|
expect(await policy.getAddress()).not.toBe(zeroAddress);
|
|
48
98
|
});
|
|
99
|
+
test("should save factories (policy and checker) after deploying policy", async () => {
|
|
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: [],
|
|
118
|
+
network: chain,
|
|
119
|
+
});
|
|
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,
|
|
130
|
+
network: chain,
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
test("should reuse policy factories if already stored", async () => {
|
|
134
|
+
getDeployedPolicyProxyFactories.mockResolvedValue({
|
|
135
|
+
checker: mockContract,
|
|
136
|
+
policy: mockContract,
|
|
137
|
+
});
|
|
138
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
139
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
140
|
+
policyType: EPolicies.FreeForAll,
|
|
141
|
+
checkerType: ECheckers.FreeForAll,
|
|
142
|
+
});
|
|
143
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
144
|
+
policyType: EPolicies.FreeForAll,
|
|
145
|
+
checkerType: ECheckers.FreeForAll,
|
|
146
|
+
});
|
|
147
|
+
expect(mockStorage.register).toHaveBeenCalledTimes(4);
|
|
148
|
+
});
|
|
49
149
|
});
|
|
50
|
-
describe("
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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);
|
|
54
160
|
});
|
|
55
|
-
|
|
56
|
-
|
|
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());
|
|
57
167
|
});
|
|
58
168
|
test("should deploy voice credit proxy if none is stored", async () => {
|
|
59
|
-
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 });
|
|
60
172
|
expect(voiceCreditProxy).toBeDefined();
|
|
61
173
|
expect(await voiceCreditProxy.getAddress()).not.toBe(zeroAddress);
|
|
62
174
|
});
|
|
63
175
|
});
|
|
64
176
|
describe("deployMaci", () => {
|
|
65
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);
|
|
66
182
|
await expect(deployerService.deployMaci({
|
|
67
183
|
config: testMaciDeploymentConfig,
|
|
68
184
|
chain,
|
|
@@ -71,44 +187,37 @@ describe("DeployerService", () => {
|
|
|
71
187
|
})).rejects.toThrow(ErrorCodes.SESSION_KEY_NOT_FOUND.toString());
|
|
72
188
|
});
|
|
73
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);
|
|
74
194
|
await expect(deployerService.deployMaci({
|
|
75
195
|
config: testMaciDeploymentConfig,
|
|
76
196
|
chain,
|
|
77
|
-
approval: "
|
|
197
|
+
approval: "0x123",
|
|
78
198
|
sessionKeyAddress,
|
|
79
199
|
})).rejects.toThrow(ErrorCodes.INVALID_APPROVAL.toString());
|
|
80
200
|
});
|
|
81
201
|
test("should deploy all new contracts", async () => {
|
|
82
|
-
const
|
|
83
|
-
jest.spyOn(DeployerService.prototype, "deployMaci").mockImplementation(mockDeployMaci);
|
|
202
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
84
203
|
const { address: maciAddress } = await deployerService.deployMaci({
|
|
85
204
|
config: testMaciDeploymentConfig,
|
|
86
205
|
chain,
|
|
87
206
|
approval,
|
|
88
207
|
sessionKeyAddress,
|
|
89
208
|
});
|
|
90
|
-
expect(maciAddress).toBe(zeroAddress);
|
|
209
|
+
expect(maciAddress).toBe(zeroAddress.replace("0x0", "0x1"));
|
|
91
210
|
});
|
|
92
211
|
});
|
|
93
212
|
describe("deployPoll", () => {
|
|
94
|
-
afterEach(() => {
|
|
95
|
-
storageInstance.cleanup(chain);
|
|
96
|
-
});
|
|
97
213
|
test("should throw when there is no maci contract deployed", async () => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
})).rejects.toThrow(ErrorCodes.MACI_NOT_DEPLOYED.toString());
|
|
104
|
-
});
|
|
105
|
-
test("should throw when there is no maci contract deployed to this specific chain", async () => {
|
|
106
|
-
await storageInstance.register({
|
|
107
|
-
id: EContracts.MACI,
|
|
108
|
-
contract: new BaseContract("0x", MACIFactory.abi),
|
|
109
|
-
network: ESupportedNetworks.ARBITRUM_ONE,
|
|
110
|
-
args: [],
|
|
214
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
215
|
+
...mockStorage,
|
|
216
|
+
getAddress: jest
|
|
217
|
+
.fn()
|
|
218
|
+
.mockImplementation((key) => (key !== EContracts.MACI ? zeroAddress : undefined)),
|
|
111
219
|
});
|
|
220
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
112
221
|
await expect(deployerService.deployPoll({
|
|
113
222
|
approval,
|
|
114
223
|
sessionKeyAddress,
|
|
@@ -116,13 +225,14 @@ describe("DeployerService", () => {
|
|
|
116
225
|
config: testPollDeploymentConfig,
|
|
117
226
|
})).rejects.toThrow(ErrorCodes.MACI_NOT_DEPLOYED.toString());
|
|
118
227
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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)),
|
|
125
234
|
});
|
|
235
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
126
236
|
await expect(deployerService.deployPoll({
|
|
127
237
|
approval,
|
|
128
238
|
sessionKeyAddress,
|
|
@@ -130,19 +240,14 @@ describe("DeployerService", () => {
|
|
|
130
240
|
config: testPollDeploymentConfig,
|
|
131
241
|
})).rejects.toThrow(ErrorCodes.VERIFIER_NOT_DEPLOYED.toString());
|
|
132
242
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
140
|
-
await storageInstance.register({
|
|
141
|
-
id: EContracts.Verifier,
|
|
142
|
-
contract: new BaseContract("0x", VerifierFactory.abi),
|
|
143
|
-
network: chain,
|
|
144
|
-
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),
|
|
145
249
|
});
|
|
250
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
146
251
|
await expect(deployerService.deployPoll({
|
|
147
252
|
approval,
|
|
148
253
|
sessionKeyAddress,
|
|
@@ -151,8 +256,7 @@ describe("DeployerService", () => {
|
|
|
151
256
|
})).rejects.toThrow(ErrorCodes.VERIFYING_KEYS_REGISTRY_NOT_DEPLOYED.toString());
|
|
152
257
|
});
|
|
153
258
|
test("should deploy a poll", async () => {
|
|
154
|
-
const
|
|
155
|
-
jest.spyOn(DeployerService.prototype, "deployPoll").mockImplementation(mockDeployPoll);
|
|
259
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
156
260
|
const { pollId } = await deployerService.deployPoll({
|
|
157
261
|
config: testPollDeploymentConfig,
|
|
158
262
|
chain,
|