@maci-protocol/coordinator 0.0.0-ci.a584b1a → 0.0.0-ci.aad6000
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 +2 -3
- package/build/hardhat.config.cjs.map +1 -1
- package/build/hardhat.config.d.cts +2 -4
- package/build/scripts/generateKeypair.js +2 -2
- package/build/scripts/generateKeypair.js.map +1 -1
- package/build/tests/e2e.deploy.test.js +58 -50
- 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 +119 -0
- package/build/tests/e2e.redis.test.js.map +1 -0
- package/build/tests/utils.d.ts.map +1 -1
- package/build/tests/utils.js +2 -2
- 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 +11 -21
- package/build/ts/common/__tests__/common.test.js.map +1 -1
- package/build/ts/common/accountAbstraction.d.ts +1 -1
- package/build/ts/common/accountAbstraction.d.ts.map +1 -1
- package/build/ts/common/accountAbstraction.js +5 -6
- package/build/ts/common/accountAbstraction.js.map +1 -1
- package/build/ts/common/chain.d.ts +4 -4
- package/build/ts/common/chain.d.ts.map +1 -1
- package/build/ts/common/chain.js +14 -16
- 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/deployer/__tests__/deployer.controller.test.js +17 -20
- package/build/ts/deployer/__tests__/deployer.controller.test.js.map +1 -1
- package/build/ts/deployer/__tests__/deployer.service.test.js +161 -79
- package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -1
- package/build/ts/deployer/__tests__/utils.d.ts +2 -6
- package/build/ts/deployer/__tests__/utils.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/utils.js +8 -12
- package/build/ts/deployer/__tests__/utils.js.map +1 -1
- package/build/ts/deployer/deployer.service.d.ts +17 -7
- package/build/ts/deployer/deployer.service.d.ts.map +1 -1
- package/build/ts/deployer/deployer.service.js +219 -62
- package/build/ts/deployer/deployer.service.js.map +1 -1
- package/build/ts/deployer/types.d.ts +22 -18
- 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/proof/__tests__/proof.controller.test.js +2 -2
- package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.gateway.test.js +2 -2
- package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.service.test.js +27 -73
- package/build/ts/proof/__tests__/proof.service.test.js.map +1 -1
- package/build/ts/proof/dto.d.ts +3 -6
- package/build/ts/proof/dto.d.ts.map +1 -1
- package/build/ts/proof/dto.js +9 -23
- 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.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 +3 -6
- package/build/ts/proof/types.d.ts.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 +149 -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 +52 -0
- package/build/ts/redis/redis.service.d.ts.map +1 -0
- package/build/ts/redis/redis.service.js +97 -0
- package/build/ts/redis/redis.service.js.map +1 -0
- package/build/ts/redis/types.d.ts +54 -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 +63 -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 +264 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.js.map +1 -0
- package/build/ts/scheduler/dto.d.ts +42 -0
- package/build/ts/scheduler/dto.d.ts.map +1 -0
- package/build/ts/scheduler/dto.js +116 -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 +23 -0
- package/build/ts/scheduler/scheduler.module.js.map +1 -0
- package/build/ts/scheduler/scheduler.service.d.ts +63 -0
- package/build/ts/scheduler/scheduler.service.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.service.js +239 -0
- package/build/ts/scheduler/scheduler.service.js.map +1 -0
- package/build/ts/scheduler/types.d.ts +61 -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 +30 -16
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js.map +1 -1
- package/build/ts/sessionKeys/__tests__/utils.d.ts.map +1 -1
- package/build/ts/sessionKeys/__tests__/utils.js +4 -5
- package/build/ts/sessionKeys/__tests__/utils.js.map +1 -1
- 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.service.test.js +2 -3
- package/build/ts/subgraph/__tests__/subgraph.service.test.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 +16 -5
- package/build/ts/subgraph/subgraph.service.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +41 -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,16 +1,16 @@
|
|
|
1
1
|
import { mainnet, sepolia, arbitrum, arbitrumSepolia, baseSepolia, lineaSepolia, scrollSepolia, scroll, base, holesky, linea, bsc, gnosis, polygon, optimism, optimismSepolia, } from "viem/chains";
|
|
2
2
|
import { getBundlerClient, getPublicClient, getZeroDevBundlerRPCUrl } from "../accountAbstraction";
|
|
3
|
-
import {
|
|
3
|
+
import { getRpcUrl } from "../chain";
|
|
4
4
|
import { ErrorCodes } from "../errors";
|
|
5
5
|
import { ESupportedNetworks, viemChain } from "../networks";
|
|
6
6
|
describe("common", () => {
|
|
7
7
|
describe("getPublicClient", () => {
|
|
8
|
-
test("should return a public client", () => {
|
|
9
|
-
const publicClient = getPublicClient(ESupportedNetworks.OPTIMISM_SEPOLIA);
|
|
8
|
+
test("should return a public client", async () => {
|
|
9
|
+
const publicClient = await getPublicClient(ESupportedNetworks.OPTIMISM_SEPOLIA);
|
|
10
10
|
expect(publicClient).toBeDefined();
|
|
11
11
|
});
|
|
12
|
-
test("should throw when given an unsupported network", () => {
|
|
13
|
-
expect(() => getPublicClient("Unsupported")).toThrow(ErrorCodes.UNSUPPORTED_NETWORK.toString());
|
|
12
|
+
test("should throw when given an unsupported network", async () => {
|
|
13
|
+
await expect(() => getPublicClient("Unsupported")).rejects.toThrow(ErrorCodes.UNSUPPORTED_NETWORK.toString());
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
describe("getZeroDevBundlerRPCUrl", () => {
|
|
@@ -29,23 +29,13 @@ describe("common", () => {
|
|
|
29
29
|
expect(() => getBundlerClient("Unsupported")).toThrow(ErrorCodes.UNSUPPORTED_NETWORK.toString());
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
-
describe("
|
|
33
|
-
test("should
|
|
34
|
-
|
|
35
|
-
expect(rpcUrl).toBeDefined();
|
|
36
|
-
expect(rpcUrl).toContain("https://opt-sepolia.g.alchemy.com/v2/");
|
|
32
|
+
describe("getRpcUrl", () => {
|
|
33
|
+
test("should throw when given an unsupported network", async () => {
|
|
34
|
+
await expect(() => getRpcUrl("Unsupported")).rejects.toThrow(ErrorCodes.UNSUPPORTED_NETWORK.toString());
|
|
37
35
|
});
|
|
38
|
-
test("should
|
|
39
|
-
|
|
40
|
-
expect(
|
|
41
|
-
expect(rpcUrl).toContain("https://eth-sepolia.g.alchemy.com/v2/");
|
|
42
|
-
});
|
|
43
|
-
test("should throw when given an unsupported network", () => {
|
|
44
|
-
expect(() => genAlchemyRPCUrl(ESupportedNetworks.GNOSIS_CHAIN)).toThrow(ErrorCodes.UNSUPPORTED_NETWORK.toString());
|
|
45
|
-
});
|
|
46
|
-
test("should throw when ALCHEMY_API_KEY is not set", () => {
|
|
47
|
-
delete process.env.RPC_API_KEY;
|
|
48
|
-
expect(() => genAlchemyRPCUrl(ESupportedNetworks.OPTIMISM_SEPOLIA)).toThrow(ErrorCodes.RPC_API_KEY_NOT_SET.toString());
|
|
36
|
+
test("should throw when COORDINATOR_RPC_URL is not set", async () => {
|
|
37
|
+
delete process.env.COORDINATOR_RPC_URL;
|
|
38
|
+
await expect(() => getRpcUrl(ESupportedNetworks.OPTIMISM_SEPOLIA)).rejects.toThrow(ErrorCodes.COORDINATOR_RPC_URL_NOT_SET.toString());
|
|
49
39
|
});
|
|
50
40
|
});
|
|
51
41
|
describe("viemChain", () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.test.js","sourceRoot":"","sources":["../../../../ts/common/__tests__/common.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,OAAO,EACP,QAAQ,EACR,eAAe,EACf,WAAW,EACX,YAAY,EACZ,aAAa,EACb,MAAM,EACN,IAAI,EACJ,OAAO,EACP,KAAK,EACL,GAAG,EACH,MAAM,EACN,OAAO,EACP,QAAQ,EACR,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"common.test.js","sourceRoot":"","sources":["../../../../ts/common/__tests__/common.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,OAAO,EACP,QAAQ,EACR,eAAe,EACf,WAAW,EACX,YAAY,EACZ,aAAa,EACb,MAAM,EACN,IAAI,EACJ,OAAO,EACP,KAAK,EACL,GAAG,EACH,MAAM,EACN,OAAO,EACP,QAAQ,EACR,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACnG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AC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9D,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC/E,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,4CAA4C,EAAE,GAAG,EAAE;YACtD,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,qBAA2C,CAAC,CAAC,CAAC,OAAO,CAC1E,UAAU,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAC1C,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { ESupportedNetworks } from "./networks";
|
|
|
7
7
|
* @param chainName - the name of the chain to use
|
|
8
8
|
* @returns the public client
|
|
9
9
|
*/
|
|
10
|
-
export declare const getPublicClient: (chainName: ESupportedNetworks) => PublicClientHTTPType
|
|
10
|
+
export declare const getPublicClient: (chainName: ESupportedNetworks) => Promise<PublicClientHTTPType>;
|
|
11
11
|
/**
|
|
12
12
|
* Get the ZeroDev bundler RPC URL based on the network
|
|
13
13
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountAbstraction.d.ts","sourceRoot":"","sources":["../../../ts/common/accountAbstraction.ts"],"names":[],"mappings":"AAKA,OAAO,EAA4B,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAI1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAIzF,OAAO,EAAE,kBAAkB,EAAa,MAAM,YAAY,CAAC;AAI3D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"accountAbstraction.d.ts","sourceRoot":"","sources":["../../../ts/common/accountAbstraction.ts"],"names":[],"mappings":"AAKA,OAAO,EAA4B,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAI1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAIzF,OAAO,EAAE,kBAAkB,EAAa,MAAM,YAAY,CAAC;AAI3D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAU,WAAW,kBAAkB,KAAG,OAAO,CAAC,oBAAoB,CAI9F,CAAC;AAEL;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,kBAAkB,KAAG,MASrE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,WAAW,kBAAkB,KAAG,iBAI7D,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,YAAY,GAAG,EACf,UAAU,MAAM,EAChB,OAAO,kBAAkB,KACxB,OAAO,CAAC,gBAAgB,CA0B1B,CAAC"}
|
|
@@ -6,7 +6,7 @@ import dotenv from "dotenv";
|
|
|
6
6
|
import { createPublicClient, http } from "viem";
|
|
7
7
|
import { createBundlerClient } from "viem/account-abstraction";
|
|
8
8
|
import { privateKeyToAccount } from "viem/accounts";
|
|
9
|
-
import {
|
|
9
|
+
import { getRpcUrl } from "./chain";
|
|
10
10
|
import { ErrorCodes } from "./errors";
|
|
11
11
|
import { ESupportedNetworks, viemChain } from "./networks";
|
|
12
12
|
dotenv.config();
|
|
@@ -16,8 +16,8 @@ dotenv.config();
|
|
|
16
16
|
* @param chainName - the name of the chain to use
|
|
17
17
|
* @returns the public client
|
|
18
18
|
*/
|
|
19
|
-
export const getPublicClient = (chainName) => createPublicClient({
|
|
20
|
-
transport: http(
|
|
19
|
+
export const getPublicClient = async (chainName) => createPublicClient({
|
|
20
|
+
transport: http(await getRpcUrl(chainName)),
|
|
21
21
|
chain: viemChain(chainName),
|
|
22
22
|
});
|
|
23
23
|
/**
|
|
@@ -60,19 +60,18 @@ export const addressOffset = 26;
|
|
|
60
60
|
*/
|
|
61
61
|
export const getKernelClient = async (sessionKey, approval, chain) => {
|
|
62
62
|
const bundlerUrl = getZeroDevBundlerRPCUrl(chain);
|
|
63
|
-
const publicClient = getPublicClient(chain);
|
|
63
|
+
const publicClient = await getPublicClient(chain);
|
|
64
64
|
// Using a stored private key
|
|
65
65
|
const sessionKeySigner = await toECDSASigner({
|
|
66
66
|
signer: privateKeyToAccount(sessionKey),
|
|
67
67
|
});
|
|
68
68
|
try {
|
|
69
69
|
const sessionKeyAccount = await deserializePermissionAccount(publicClient, getEntryPoint("0.7"), KERNEL_V3_1, approval, sessionKeySigner);
|
|
70
|
-
|
|
70
|
+
return createKernelAccountClient({
|
|
71
71
|
bundlerTransport: http(bundlerUrl),
|
|
72
72
|
account: sessionKeyAccount,
|
|
73
73
|
chain: viemChain(chain),
|
|
74
74
|
});
|
|
75
|
-
return kernelClient;
|
|
76
75
|
}
|
|
77
76
|
catch (error) {
|
|
78
77
|
throw new Error(ErrorCodes.INVALID_APPROVAL.toString());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountAbstraction.js","sourceRoot":"","sources":["../../../ts/common/accountAbstraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAY,MAAM,MAAM,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIpD,OAAO,EAAE,
|
|
1
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|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Signer } from "ethers";
|
|
2
2
|
import { ESupportedNetworks } from "./networks";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Get the RPC url for the chain we need to interact with
|
|
5
5
|
*
|
|
6
6
|
* @param network - the network we want to interact with
|
|
7
|
-
* @returns the
|
|
7
|
+
* @returns the RPC url for the network
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const getRpcUrl: (network: ESupportedNetworks) => Promise<string>;
|
|
10
10
|
/**
|
|
11
11
|
* Get a Ethers Signer given a chain and private key
|
|
12
12
|
* @param chain
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
|
-
export declare const getSigner: (chain: ESupportedNetworks) => Signer
|
|
15
|
+
export declare const getSigner: (chain: ESupportedNetworks) => Promise<Signer>;
|
|
16
16
|
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../ts/common/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAU,MAAM,QAAQ,CAAC;AAGzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../ts/common/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAU,MAAM,QAAQ,CAAC;AAGzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAU,SAAS,kBAAkB,KAAG,OAAO,CAAC,MAAM,CAY3E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAU,OAAO,kBAAkB,KAAG,OAAO,CAAC,MAAM,CASzE,CAAC"}
|
package/build/ts/common/chain.js
CHANGED
|
@@ -2,33 +2,31 @@ import { JsonRpcProvider, Wallet } from "ethers";
|
|
|
2
2
|
import { ErrorCodes } from "./errors";
|
|
3
3
|
import { ESupportedNetworks } from "./networks";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Get the RPC url for the chain we need to interact with
|
|
6
6
|
*
|
|
7
7
|
* @param network - the network we want to interact with
|
|
8
|
-
* @returns the
|
|
8
|
+
* @returns the RPC url for the network
|
|
9
9
|
*/
|
|
10
|
-
export const
|
|
11
|
-
const
|
|
12
|
-
if (!
|
|
13
|
-
|
|
10
|
+
export const getRpcUrl = async (network) => {
|
|
11
|
+
const rpcUrl = process.env.COORDINATOR_RPC_URL;
|
|
12
|
+
if (!rpcUrl) {
|
|
13
|
+
return Promise.reject(new Error(ErrorCodes.COORDINATOR_RPC_URL_NOT_SET.toString()));
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return `https://opt-sepolia.g.alchemy.com/v2/${rpcAPIKey}`;
|
|
18
|
-
case ESupportedNetworks.ETHEREUM_SEPOLIA:
|
|
19
|
-
return `https://eth-sepolia.g.alchemy.com/v2/${rpcAPIKey}`;
|
|
20
|
-
default:
|
|
21
|
-
throw new Error(ErrorCodes.UNSUPPORTED_NETWORK.toString());
|
|
15
|
+
if (!Object.values(ESupportedNetworks).includes(network)) {
|
|
16
|
+
return Promise.reject(new Error(ErrorCodes.UNSUPPORTED_NETWORK.toString()));
|
|
22
17
|
}
|
|
18
|
+
return Promise.resolve(rpcUrl);
|
|
23
19
|
};
|
|
24
20
|
/**
|
|
25
21
|
* Get a Ethers Signer given a chain and private key
|
|
26
22
|
* @param chain
|
|
27
23
|
* @returns
|
|
28
24
|
*/
|
|
29
|
-
export const getSigner = (chain) => {
|
|
30
|
-
const wallet =
|
|
31
|
-
|
|
25
|
+
export const getSigner = async (chain) => {
|
|
26
|
+
const wallet = process.env.PRIVATE_KEY
|
|
27
|
+
? new Wallet(process.env.PRIVATE_KEY)
|
|
28
|
+
: Wallet.fromPhrase(process.env.MNEMONIC);
|
|
29
|
+
const alchemyRpcUrl = await getRpcUrl(chain);
|
|
32
30
|
const provider = new JsonRpcProvider(alchemyRpcUrl);
|
|
33
31
|
return wallet.connect(provider);
|
|
34
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../ts/common/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../ts/common/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,OAA2B,EAAmB,EAAE;IAC9E,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAE/C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,2BAA2B,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,KAAyB,EAAmB,EAAE;IAC5E,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW;QACpC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;QACrC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,QAAS,CAAC,CAAC;IAE7C,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;IAEpD,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Keypair } from "@maci-protocol/domainobjs";
|
|
2
|
+
/**
|
|
3
|
+
* Instantiate the MACI Coordinator keypair.
|
|
4
|
+
* @returns {Keypair} - The MACI Coordinator keypair.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getCoordinatorKeypair: () => Keypair;
|
|
7
|
+
//# sourceMappingURL=coordinatorKeypair.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinatorKeypair.d.ts","sourceRoot":"","sources":["../../../ts/common/coordinatorKeypair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAc,MAAM,2BAA2B,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAO,OAUxC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Keypair, PrivateKey } from "@maci-protocol/domainobjs";
|
|
2
|
+
/**
|
|
3
|
+
* Instantiate the MACI Coordinator keypair.
|
|
4
|
+
* @returns {Keypair} - The MACI Coordinator keypair.
|
|
5
|
+
*/
|
|
6
|
+
export const getCoordinatorKeypair = () => {
|
|
7
|
+
const privateKey = String(process.env.COORDINATOR_MACI_PRIVATE_KEY);
|
|
8
|
+
if (!privateKey) {
|
|
9
|
+
throw new Error("COORDINATOR_MACI_PRIVATE_KEY environment variable is not set.");
|
|
10
|
+
}
|
|
11
|
+
const maciPrivateKey = PrivateKey.deserialize(privateKey);
|
|
12
|
+
return new Keypair(maciPrivateKey);
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=coordinatorKeypair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinatorKeypair.js","sourceRoot":"","sources":["../../../ts/common/coordinatorKeypair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAY,EAAE;IACjD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAEpE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IAED,MAAM,cAAc,GAAG,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE1D,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;AACrC,CAAC,CAAC"}
|
|
@@ -13,20 +13,24 @@ export declare enum ErrorCodes {
|
|
|
13
13
|
SESSION_KEY_NOT_FOUND = 8,
|
|
14
14
|
INVALID_APPROVAL = 9,
|
|
15
15
|
UNSUPPORTED_NETWORK = 10,
|
|
16
|
-
|
|
16
|
+
COORDINATOR_RPC_URL_NOT_SET = 11,
|
|
17
17
|
FAILED_TO_MERGE_STATE_TREE = 12,
|
|
18
18
|
FAILED_TO_MERGE_MESSAGE_SUBTREES = 13,
|
|
19
19
|
FAILED_TO_MERGE_MESSAGE_TREE = 14,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
UNSUPPORTED_VOICE_CREDIT_PROXY_FACTORY = 15,
|
|
21
|
+
UNSUPPORTED_VOICE_CREDIT_PROXY = 16,
|
|
22
|
+
UNSUPPORTED_POLICY = 17,
|
|
23
|
+
FAILED_TO_DEPLOY_CONTRACT = 18,
|
|
24
|
+
FAILED_TO_SET_MACI_INSTANCE_ON_POLICY = 19,
|
|
25
|
+
MACI_NOT_DEPLOYED = 20,
|
|
26
|
+
VERIFIER_NOT_DEPLOYED = 21,
|
|
27
|
+
VERIFYING_KEYS_REGISTRY_NOT_DEPLOYED = 22,
|
|
28
|
+
FAILED_TO_SET_VERIFYING_KEYS = 23,
|
|
29
|
+
FAILED_TO_DEPLOY_MACI = 24,
|
|
30
|
+
FAILED_TO_DEPLOY_POLL = 25,
|
|
31
|
+
NOT_MERGED_MESSAGE_TREE = 26,
|
|
32
|
+
FAILED_TO_UPDATE_SCHEDULED_POLL = 27,
|
|
33
|
+
POLL_ALREADY_SCHEDULED = 28,
|
|
34
|
+
POLL_ALREADY_TALLIED = 29
|
|
31
35
|
}
|
|
32
36
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../ts/common/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,UAAU;IACpB,qBAAqB,IAAA;IACrB,oBAAoB,IAAA;IACpB,cAAc,IAAA;IACd,UAAU,IAAA;IACV,UAAU,IAAA;IACV,cAAc,IAAA;IACd,eAAe,IAAA;IACf,6BAA6B,IAAA;IAC7B,qBAAqB,IAAA;IACrB,gBAAgB,IAAA;IAChB,mBAAmB,KAAA;IACnB,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../ts/common/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,UAAU;IACpB,qBAAqB,IAAA;IACrB,oBAAoB,IAAA;IACpB,cAAc,IAAA;IACd,UAAU,IAAA;IACV,UAAU,IAAA;IACV,cAAc,IAAA;IACd,eAAe,IAAA;IACf,6BAA6B,IAAA;IAC7B,qBAAqB,IAAA;IACrB,gBAAgB,IAAA;IAChB,mBAAmB,KAAA;IACnB,2BAA2B,KAAA;IAC3B,0BAA0B,KAAA;IAC1B,gCAAgC,KAAA;IAChC,4BAA4B,KAAA;IAC5B,sCAAsC,KAAA;IACtC,8BAA8B,KAAA;IAC9B,kBAAkB,KAAA;IAClB,yBAAyB,KAAA;IACzB,qCAAqC,KAAA;IACrC,iBAAiB,KAAA;IACjB,qBAAqB,KAAA;IACrB,oCAAoC,KAAA;IACpC,4BAA4B,KAAA;IAC5B,qBAAqB,KAAA;IACrB,qBAAqB,KAAA;IACrB,uBAAuB,KAAA;IACvB,+BAA+B,KAAA;IAC/B,sBAAsB,KAAA;IACtB,oBAAoB,KAAA;CACrB"}
|
|
@@ -14,20 +14,24 @@ export var ErrorCodes;
|
|
|
14
14
|
ErrorCodes[ErrorCodes["SESSION_KEY_NOT_FOUND"] = 8] = "SESSION_KEY_NOT_FOUND";
|
|
15
15
|
ErrorCodes[ErrorCodes["INVALID_APPROVAL"] = 9] = "INVALID_APPROVAL";
|
|
16
16
|
ErrorCodes[ErrorCodes["UNSUPPORTED_NETWORK"] = 10] = "UNSUPPORTED_NETWORK";
|
|
17
|
-
ErrorCodes[ErrorCodes["
|
|
17
|
+
ErrorCodes[ErrorCodes["COORDINATOR_RPC_URL_NOT_SET"] = 11] = "COORDINATOR_RPC_URL_NOT_SET";
|
|
18
18
|
ErrorCodes[ErrorCodes["FAILED_TO_MERGE_STATE_TREE"] = 12] = "FAILED_TO_MERGE_STATE_TREE";
|
|
19
19
|
ErrorCodes[ErrorCodes["FAILED_TO_MERGE_MESSAGE_SUBTREES"] = 13] = "FAILED_TO_MERGE_MESSAGE_SUBTREES";
|
|
20
20
|
ErrorCodes[ErrorCodes["FAILED_TO_MERGE_MESSAGE_TREE"] = 14] = "FAILED_TO_MERGE_MESSAGE_TREE";
|
|
21
|
-
ErrorCodes[ErrorCodes["
|
|
22
|
-
ErrorCodes[ErrorCodes["
|
|
23
|
-
ErrorCodes[ErrorCodes["
|
|
24
|
-
ErrorCodes[ErrorCodes["
|
|
25
|
-
ErrorCodes[ErrorCodes["
|
|
26
|
-
ErrorCodes[ErrorCodes["
|
|
27
|
-
ErrorCodes[ErrorCodes["
|
|
28
|
-
ErrorCodes[ErrorCodes["
|
|
29
|
-
ErrorCodes[ErrorCodes["
|
|
30
|
-
ErrorCodes[ErrorCodes["
|
|
31
|
-
ErrorCodes[ErrorCodes["
|
|
21
|
+
ErrorCodes[ErrorCodes["UNSUPPORTED_VOICE_CREDIT_PROXY_FACTORY"] = 15] = "UNSUPPORTED_VOICE_CREDIT_PROXY_FACTORY";
|
|
22
|
+
ErrorCodes[ErrorCodes["UNSUPPORTED_VOICE_CREDIT_PROXY"] = 16] = "UNSUPPORTED_VOICE_CREDIT_PROXY";
|
|
23
|
+
ErrorCodes[ErrorCodes["UNSUPPORTED_POLICY"] = 17] = "UNSUPPORTED_POLICY";
|
|
24
|
+
ErrorCodes[ErrorCodes["FAILED_TO_DEPLOY_CONTRACT"] = 18] = "FAILED_TO_DEPLOY_CONTRACT";
|
|
25
|
+
ErrorCodes[ErrorCodes["FAILED_TO_SET_MACI_INSTANCE_ON_POLICY"] = 19] = "FAILED_TO_SET_MACI_INSTANCE_ON_POLICY";
|
|
26
|
+
ErrorCodes[ErrorCodes["MACI_NOT_DEPLOYED"] = 20] = "MACI_NOT_DEPLOYED";
|
|
27
|
+
ErrorCodes[ErrorCodes["VERIFIER_NOT_DEPLOYED"] = 21] = "VERIFIER_NOT_DEPLOYED";
|
|
28
|
+
ErrorCodes[ErrorCodes["VERIFYING_KEYS_REGISTRY_NOT_DEPLOYED"] = 22] = "VERIFYING_KEYS_REGISTRY_NOT_DEPLOYED";
|
|
29
|
+
ErrorCodes[ErrorCodes["FAILED_TO_SET_VERIFYING_KEYS"] = 23] = "FAILED_TO_SET_VERIFYING_KEYS";
|
|
30
|
+
ErrorCodes[ErrorCodes["FAILED_TO_DEPLOY_MACI"] = 24] = "FAILED_TO_DEPLOY_MACI";
|
|
31
|
+
ErrorCodes[ErrorCodes["FAILED_TO_DEPLOY_POLL"] = 25] = "FAILED_TO_DEPLOY_POLL";
|
|
32
|
+
ErrorCodes[ErrorCodes["NOT_MERGED_MESSAGE_TREE"] = 26] = "NOT_MERGED_MESSAGE_TREE";
|
|
33
|
+
ErrorCodes[ErrorCodes["FAILED_TO_UPDATE_SCHEDULED_POLL"] = 27] = "FAILED_TO_UPDATE_SCHEDULED_POLL";
|
|
34
|
+
ErrorCodes[ErrorCodes["POLL_ALREADY_SCHEDULED"] = 28] = "POLL_ALREADY_SCHEDULED";
|
|
35
|
+
ErrorCodes[ErrorCodes["POLL_ALREADY_TALLIED"] = 29] = "POLL_ALREADY_TALLIED";
|
|
32
36
|
})(ErrorCodes || (ErrorCodes = {}));
|
|
33
37
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../ts/common/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../ts/common/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,UA+BX;AA/BD,WAAY,UAAU;IACpB,6EAAqB,CAAA;IACrB,2EAAoB,CAAA;IACpB,+DAAc,CAAA;IACd,uDAAU,CAAA;IACV,uDAAU,CAAA;IACV,+DAAc,CAAA;IACd,iEAAe,CAAA;IACf,6FAA6B,CAAA;IAC7B,6EAAqB,CAAA;IACrB,mEAAgB,CAAA;IAChB,0EAAmB,CAAA;IACnB,0FAA2B,CAAA;IAC3B,wFAA0B,CAAA;IAC1B,oGAAgC,CAAA;IAChC,4FAA4B,CAAA;IAC5B,gHAAsC,CAAA;IACtC,gGAA8B,CAAA;IAC9B,wEAAkB,CAAA;IAClB,sFAAyB,CAAA;IACzB,8GAAqC,CAAA;IACrC,sEAAiB,CAAA;IACjB,8EAAqB,CAAA;IACrB,4GAAoC,CAAA;IACpC,4FAA4B,CAAA;IAC5B,8EAAqB,CAAA;IACrB,8EAAqB,CAAA;IACrB,kFAAuB,CAAA;IACvB,kGAA+B,CAAA;IAC/B,gFAAsB,CAAA;IACtB,4EAAoB,CAAA;AACtB,CAAC,EA/BW,UAAU,KAAV,UAAU,QA+BrB"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Test } from "@nestjs/testing";
|
|
2
2
|
import { zeroAddress } from "viem";
|
|
3
3
|
import { ErrorCodes, ESupportedNetworks } from "../../common";
|
|
4
|
-
import { FileService } from "../../file/file.service";
|
|
5
|
-
import { generateApproval } from "../../sessionKeys/__tests__/utils";
|
|
6
|
-
import { SessionKeysService } from "../../sessionKeys/sessionKeys.service";
|
|
7
4
|
import { DeployerController } from "../deployer.controller";
|
|
8
5
|
import { DeployerService } from "../deployer.service";
|
|
9
6
|
import { testMaciDeploymentConfig, testPollDeploymentConfig } from "./utils";
|
|
@@ -18,15 +15,8 @@ describe("DeployerController", () => {
|
|
|
18
15
|
};
|
|
19
16
|
const defaultDeployMaciReturn = zeroAddress;
|
|
20
17
|
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
|
-
});
|
|
18
|
+
const approval = "approval";
|
|
19
|
+
const sessionKeyAddress = zeroAddress;
|
|
30
20
|
beforeEach(async () => {
|
|
31
21
|
const app = await Test.createTestingModule({
|
|
32
22
|
controllers: [DeployerController],
|
|
@@ -42,6 +32,9 @@ describe("DeployerController", () => {
|
|
|
42
32
|
.compile();
|
|
43
33
|
deployerController = app.get(DeployerController);
|
|
44
34
|
});
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
jest.clearAllMocks();
|
|
37
|
+
});
|
|
45
38
|
describe("v1/deploy/maci", () => {
|
|
46
39
|
test("should deploy all contracts", async () => {
|
|
47
40
|
const { address } = await deployerController.deployMACIContracts({
|
|
@@ -53,10 +46,12 @@ describe("DeployerController", () => {
|
|
|
53
46
|
expect(address).toEqual(defaultDeployMaciReturn);
|
|
54
47
|
});
|
|
55
48
|
test("should return 400 bad request when the service throws", async () => {
|
|
56
|
-
|
|
49
|
+
mockDeployerService.deployMaci.mockRejectedValue(new Error(ErrorCodes.SESSION_KEY_NOT_FOUND.toString()));
|
|
50
|
+
const controller = new DeployerController(mockDeployerService);
|
|
51
|
+
await expect(controller.deployMACIContracts({
|
|
57
52
|
chain: ESupportedNetworks.OPTIMISM_SEPOLIA,
|
|
58
|
-
approval: "",
|
|
59
|
-
sessionKeyAddress: "
|
|
53
|
+
approval: "0x123",
|
|
54
|
+
sessionKeyAddress: "0x123",
|
|
60
55
|
config: testMaciDeploymentConfig,
|
|
61
56
|
})).rejects.toThrow(ErrorCodes.SESSION_KEY_NOT_FOUND.toString());
|
|
62
57
|
});
|
|
@@ -65,17 +60,19 @@ describe("DeployerController", () => {
|
|
|
65
60
|
test("should deploy a new poll", async () => {
|
|
66
61
|
const { pollId } = await deployerController.deployPoll({
|
|
67
62
|
chain: ESupportedNetworks.OPTIMISM_SEPOLIA,
|
|
68
|
-
approval
|
|
69
|
-
sessionKeyAddress
|
|
63
|
+
approval,
|
|
64
|
+
sessionKeyAddress,
|
|
70
65
|
config: testPollDeploymentConfig,
|
|
71
66
|
});
|
|
72
67
|
expect(pollId).toEqual(defaultDeployPollReturn);
|
|
73
68
|
});
|
|
74
69
|
test("should return 400 bad request when the service throws", async () => {
|
|
75
|
-
|
|
70
|
+
mockDeployerService.deployPoll.mockRejectedValue(new Error(ErrorCodes.SESSION_KEY_NOT_FOUND.toString()));
|
|
71
|
+
const controller = new DeployerController(mockDeployerService);
|
|
72
|
+
await expect(controller.deployPoll({
|
|
76
73
|
chain: ESupportedNetworks.OPTIMISM_SEPOLIA,
|
|
77
|
-
approval: "",
|
|
78
|
-
sessionKeyAddress: "
|
|
74
|
+
approval: "0x123",
|
|
75
|
+
sessionKeyAddress: "0x123",
|
|
79
76
|
config: testPollDeploymentConfig,
|
|
80
77
|
})).rejects.toThrow(ErrorCodes.SESSION_KEY_NOT_FOUND.toString());
|
|
81
78
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployer.controller.test.js","sourceRoot":"","sources":["../../../../ts/deployer/__tests__/deployer.controller.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"deployer.controller.test.js","sourceRoot":"","sources":["../../../../ts/deployer/__tests__/deployer.controller.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC9D,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,CAA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