@maci-protocol/coordinator 0.0.0-ci.153b117 → 0.0.0-ci.16f78c8
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 +60 -24
- package/build/hardhat.config.cjs +14 -9
- package/build/hardhat.config.cjs.map +1 -1
- package/build/hardhat.config.d.cts +12 -12
- package/build/hardhat.config.d.cts.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 +14 -40
- package/build/tests/e2e.deploy.test.js.map +1 -1
- package/build/tests/e2e.redis.test.js +23 -19
- package/build/tests/e2e.redis.test.js.map +1 -1
- 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 +2 -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 -11
- 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 +173 -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 +10 -14
- 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 +14 -4
- package/build/ts/deployer/deployer.service.d.ts.map +1 -1
- package/build/ts/deployer/deployer.service.js +65 -29
- 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 +24 -20
- 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 +34 -10
- package/build/ts/health/__tests__/health.controller.test.js.map +1 -1
- package/build/ts/health/__tests__/health.service.test.js +34 -21
- package/build/ts/health/__tests__/health.service.test.js.map +1 -1
- package/build/ts/health/health.service.d.ts.map +1 -1
- package/build/ts/health/health.service.js +23 -29
- package/build/ts/health/health.service.js.map +1 -1
- package/build/ts/health/types.d.ts +9 -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/main.js +1 -1
- 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.js +34 -14
- package/build/ts/redis/__tests__/redis.service.test.js.map +1 -1
- package/build/ts/redis/redis.service.d.ts +2 -1
- package/build/ts/redis/redis.service.d.ts.map +1 -1
- package/build/ts/redis/redis.service.js +3 -1
- package/build/ts/redis/redis.service.js.map +1 -1
- package/build/ts/redis/types.d.ts +29 -20
- package/build/ts/redis/types.d.ts.map +1 -1
- package/build/ts/redis/utils.d.ts +2 -2
- package/build/ts/redis/utils.d.ts.map +1 -1
- package/build/ts/redis/utils.js +4 -1
- package/build/ts/redis/utils.js.map +1 -1
- 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 -26
|
@@ -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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;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":"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,IAAI,kBAAsC,CAAC;IAE3C,MAAM,mBAAmB,GAAG;QAC1B,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;KACtB,CAAC;IAEF,MAAM,uBA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AAK,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,114 +1,186 @@
|
|
|
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
|
+
verifierContractAddress: zeroAddress,
|
|
77
|
+
verifyingKeysRegistryContractAddress: zeroAddress,
|
|
78
|
+
});
|
|
79
|
+
getDeployedPolicyProxyFactories.mockResolvedValue({ checker: undefined, policy: undefined });
|
|
80
|
+
});
|
|
14
81
|
afterEach(() => {
|
|
15
82
|
jest.clearAllMocks();
|
|
16
83
|
});
|
|
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
84
|
describe("deployAndSavePolicy", () => {
|
|
35
|
-
// we cleanup after each test so we don't have leftover saved contracts
|
|
36
|
-
afterEach(() => {
|
|
37
|
-
storageInstance.cleanup(chain);
|
|
38
|
-
});
|
|
39
85
|
test("should throw when the policy is not existent", async () => {
|
|
40
|
-
|
|
86
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
87
|
+
await expect(deployerService.deployAndSavePolicy(signer, chain, {
|
|
88
|
+
policyType: "NonExistent",
|
|
89
|
+
checkerType: "NonExistent",
|
|
90
|
+
})).rejects.toThrow(ErrorCodes.UNSUPPORTED_POLICY.toString());
|
|
41
91
|
});
|
|
42
92
|
test("should deploy policy if none is stored", async () => {
|
|
43
|
-
const
|
|
93
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
94
|
+
const policy = await deployerService.deployAndSavePolicy(signer, chain, {
|
|
95
|
+
policyType: EPolicies.FreeForAll,
|
|
96
|
+
checkerType: ECheckers.FreeForAll,
|
|
97
|
+
});
|
|
44
98
|
expect(policy).toBeDefined();
|
|
45
99
|
expect(await policy.getAddress()).not.toBe(zeroAddress);
|
|
46
100
|
});
|
|
47
101
|
test("should save factories (policy and checker) after deploying policy", async () => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
102
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
103
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
104
|
+
policyType: EPolicies.FreeForAll,
|
|
105
|
+
checkerType: ECheckers.FreeForAll,
|
|
106
|
+
});
|
|
107
|
+
expect(mockStorage.register).toHaveBeenCalledTimes(4);
|
|
108
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(1, {
|
|
109
|
+
id: EPolicies.FreeForAll,
|
|
110
|
+
name: EPolicies.FreeForAll,
|
|
111
|
+
contract: mockContract,
|
|
112
|
+
args: [await mockContract.getAddress()],
|
|
113
|
+
network: chain,
|
|
114
|
+
});
|
|
115
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(2, {
|
|
116
|
+
id: ECheckers.FreeForAll,
|
|
117
|
+
name: ECheckers.FreeForAll,
|
|
118
|
+
contract: mockContract,
|
|
119
|
+
args: [],
|
|
51
120
|
network: chain,
|
|
52
|
-
signer,
|
|
53
121
|
});
|
|
54
|
-
expect(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
122
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(3, {
|
|
123
|
+
id: EPolicyFactories.FreeForAll,
|
|
124
|
+
name: EPolicyFactories.FreeForAll,
|
|
125
|
+
contract: mockContract,
|
|
126
|
+
network: chain,
|
|
127
|
+
});
|
|
128
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(4, {
|
|
129
|
+
id: ECheckerFactories.FreeForAll,
|
|
130
|
+
name: ECheckerFactories.FreeForAll,
|
|
131
|
+
contract: mockContract,
|
|
60
132
|
network: chain,
|
|
61
|
-
signer,
|
|
62
133
|
});
|
|
63
|
-
expect(checker).toBeDefined();
|
|
64
|
-
expect(policy).toBeDefined();
|
|
65
134
|
});
|
|
66
135
|
test("should reuse policy factories if already stored", async () => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
policy:
|
|
70
|
-
checker: ECheckerFactories.FreeForAll,
|
|
71
|
-
network: chain,
|
|
72
|
-
signer,
|
|
136
|
+
getDeployedPolicyProxyFactories.mockResolvedValue({
|
|
137
|
+
checker: mockContract,
|
|
138
|
+
policy: mockContract,
|
|
73
139
|
});
|
|
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,
|
|
140
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
141
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
142
|
+
policyType: EPolicies.FreeForAll,
|
|
143
|
+
checkerType: ECheckers.FreeForAll,
|
|
82
144
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
network: chain,
|
|
87
|
-
signer,
|
|
145
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
146
|
+
policyType: EPolicies.FreeForAll,
|
|
147
|
+
checkerType: ECheckers.FreeForAll,
|
|
88
148
|
});
|
|
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());
|
|
149
|
+
expect(mockStorage.register).toHaveBeenCalledTimes(4);
|
|
94
150
|
});
|
|
95
151
|
});
|
|
96
|
-
describe("
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
152
|
+
describe("deployAndSaveVoiceCreditProxyFactory", () => {
|
|
153
|
+
test("should throw when the voice credit proxy factory is not existent", async () => {
|
|
154
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
155
|
+
await expect(deployerService.deployAndSaveVoiceCreditProxyFactory(signer, "NonExistent", chain)).rejects.toThrow(ErrorCodes.UNSUPPORTED_VOICE_CREDIT_PROXY_FACTORY.toString());
|
|
156
|
+
});
|
|
157
|
+
test("should deploy voice credit proxy factory if none is stored", async () => {
|
|
158
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
159
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
160
|
+
expect(constantInitialVoiceCreditProxyFactory).toBeDefined();
|
|
161
|
+
expect(await constantInitialVoiceCreditProxyFactory.getAddress()).not.toBe(zeroAddress);
|
|
100
162
|
});
|
|
101
|
-
|
|
102
|
-
|
|
163
|
+
});
|
|
164
|
+
describe("deployAndSaveVoiceCreditProxy", () => {
|
|
165
|
+
test("should throw when the voice credit proxy is not existent", async () => {
|
|
166
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
167
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
168
|
+
await expect(deployerService.deployAndSaveVoiceCreditProxy(signer, "NonExistent", chain, constantInitialVoiceCreditProxyFactory)).rejects.toThrow(ErrorCodes.UNSUPPORTED_VOICE_CREDIT_PROXY.toString());
|
|
103
169
|
});
|
|
104
170
|
test("should deploy voice credit proxy if none is stored", async () => {
|
|
105
|
-
const
|
|
171
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
172
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
173
|
+
const voiceCreditProxy = await deployerService.deployAndSaveVoiceCreditProxy(signer, EInitialVoiceCreditProxies.Constant, chain, constantInitialVoiceCreditProxyFactory, { amount: 100 });
|
|
106
174
|
expect(voiceCreditProxy).toBeDefined();
|
|
107
175
|
expect(await voiceCreditProxy.getAddress()).not.toBe(zeroAddress);
|
|
108
176
|
});
|
|
109
177
|
});
|
|
110
178
|
describe("deployMaci", () => {
|
|
111
179
|
test("should throw when passing a non existent session key address", async () => {
|
|
180
|
+
sessionKeyService.getCoordinatorSigner = jest
|
|
181
|
+
.fn()
|
|
182
|
+
.mockRejectedValue(new Error(ErrorCodes.SESSION_KEY_NOT_FOUND.toString()));
|
|
183
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
112
184
|
await expect(deployerService.deployMaci({
|
|
113
185
|
config: testMaciDeploymentConfig,
|
|
114
186
|
chain,
|
|
@@ -117,6 +189,10 @@ describe("DeployerService", () => {
|
|
|
117
189
|
})).rejects.toThrow(ErrorCodes.SESSION_KEY_NOT_FOUND.toString());
|
|
118
190
|
});
|
|
119
191
|
test("should throw when the approval is not valid", async () => {
|
|
192
|
+
sessionKeyService.getCoordinatorSigner = jest
|
|
193
|
+
.fn()
|
|
194
|
+
.mockRejectedValue(new Error(ErrorCodes.INVALID_APPROVAL.toString()));
|
|
195
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
120
196
|
await expect(deployerService.deployMaci({
|
|
121
197
|
config: testMaciDeploymentConfig,
|
|
122
198
|
chain,
|
|
@@ -125,36 +201,25 @@ describe("DeployerService", () => {
|
|
|
125
201
|
})).rejects.toThrow(ErrorCodes.INVALID_APPROVAL.toString());
|
|
126
202
|
});
|
|
127
203
|
test("should deploy all new contracts", async () => {
|
|
128
|
-
const
|
|
129
|
-
jest.spyOn(DeployerService.prototype, "deployMaci").mockImplementation(mockDeployMaci);
|
|
204
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
130
205
|
const { address: maciAddress } = await deployerService.deployMaci({
|
|
131
206
|
config: testMaciDeploymentConfig,
|
|
132
207
|
chain,
|
|
133
208
|
approval,
|
|
134
209
|
sessionKeyAddress,
|
|
135
210
|
});
|
|
136
|
-
expect(maciAddress).toBe(zeroAddress);
|
|
211
|
+
expect(maciAddress).toBe(zeroAddress.replace("0x0", "0x1"));
|
|
137
212
|
});
|
|
138
213
|
});
|
|
139
214
|
describe("deployPoll", () => {
|
|
140
|
-
afterEach(() => {
|
|
141
|
-
storageInstance.cleanup(chain);
|
|
142
|
-
});
|
|
143
215
|
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: [],
|
|
216
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
217
|
+
...mockStorage,
|
|
218
|
+
getAddress: jest
|
|
219
|
+
.fn()
|
|
220
|
+
.mockImplementation((key) => (key !== EContracts.MACI ? zeroAddress : undefined)),
|
|
157
221
|
});
|
|
222
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
158
223
|
await expect(deployerService.deployPoll({
|
|
159
224
|
approval,
|
|
160
225
|
sessionKeyAddress,
|
|
@@ -162,13 +227,14 @@ describe("DeployerService", () => {
|
|
|
162
227
|
config: testPollDeploymentConfig,
|
|
163
228
|
})).rejects.toThrow(ErrorCodes.MACI_NOT_DEPLOYED.toString());
|
|
164
229
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
230
|
+
test("should throw when there is no verifier deployed", async () => {
|
|
231
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
232
|
+
...mockStorage,
|
|
233
|
+
getAddress: jest
|
|
234
|
+
.fn()
|
|
235
|
+
.mockImplementation((key) => (key !== EContracts.Verifier ? zeroAddress : undefined)),
|
|
171
236
|
});
|
|
237
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
172
238
|
await expect(deployerService.deployPoll({
|
|
173
239
|
approval,
|
|
174
240
|
sessionKeyAddress,
|
|
@@ -176,19 +242,14 @@ describe("DeployerService", () => {
|
|
|
176
242
|
config: testPollDeploymentConfig,
|
|
177
243
|
})).rejects.toThrow(ErrorCodes.VERIFIER_NOT_DEPLOYED.toString());
|
|
178
244
|
});
|
|
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: [],
|
|
245
|
+
test("should throw when there is no verifying keys registry deployed", async () => {
|
|
246
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
247
|
+
...mockStorage,
|
|
248
|
+
getAddress: jest
|
|
249
|
+
.fn()
|
|
250
|
+
.mockImplementation((key) => key !== EContracts.VerifyingKeysRegistry ? zeroAddress : undefined),
|
|
191
251
|
});
|
|
252
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
192
253
|
await expect(deployerService.deployPoll({
|
|
193
254
|
approval,
|
|
194
255
|
sessionKeyAddress,
|
|
@@ -197,8 +258,7 @@ describe("DeployerService", () => {
|
|
|
197
258
|
})).rejects.toThrow(ErrorCodes.VERIFYING_KEYS_REGISTRY_NOT_DEPLOYED.toString());
|
|
198
259
|
});
|
|
199
260
|
test("should deploy a poll", async () => {
|
|
200
|
-
const
|
|
201
|
-
jest.spyOn(DeployerService.prototype, "deployPoll").mockImplementation(mockDeployPoll);
|
|
261
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
202
262
|
const { pollId } = await deployerService.deployPoll({
|
|
203
263
|
config: testPollDeploymentConfig,
|
|
204
264
|
chain,
|