@maci-protocol/coordinator 0.0.0-ci.00107eb
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/CHANGELOG.md +51 -0
- package/LICENSE +21 -0
- package/README.md +103 -0
- package/build/hardhat.config.cjs +39 -0
- package/build/hardhat.config.cjs.map +1 -0
- package/build/hardhat.config.d.cts +27 -0
- package/build/hardhat.config.d.cts.map +1 -0
- package/build/scripts/generateKeypair.d.ts +2 -0
- package/build/scripts/generateKeypair.d.ts.map +1 -0
- package/build/scripts/generateKeypair.js +25 -0
- package/build/scripts/generateKeypair.js.map +1 -0
- package/build/scripts/generateMaciKeyPair.d.ts +2 -0
- package/build/scripts/generateMaciKeyPair.d.ts.map +1 -0
- package/build/scripts/generateMaciKeyPair.js +3 -0
- package/build/scripts/generateMaciKeyPair.js.map +1 -0
- package/build/scripts/getAuthHeader.d.ts +2 -0
- package/build/scripts/getAuthHeader.d.ts.map +1 -0
- package/build/scripts/getAuthHeader.js +31 -0
- package/build/scripts/getAuthHeader.js.map +1 -0
- package/build/tests/constants.d.ts +7 -0
- package/build/tests/constants.d.ts.map +1 -0
- package/build/tests/constants.js +11 -0
- package/build/tests/constants.js.map +1 -0
- package/build/tests/e2e.deploy.test.d.ts +2 -0
- package/build/tests/e2e.deploy.test.d.ts.map +1 -0
- package/build/tests/e2e.deploy.test.js +264 -0
- package/build/tests/e2e.deploy.test.js.map +1 -0
- 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 +20 -0
- package/build/tests/utils.d.ts.map +1 -0
- package/build/tests/utils.js +55 -0
- package/build/tests/utils.js.map +1 -0
- package/build/ts/app.module.d.ts +3 -0
- package/build/ts/app.module.d.ts.map +1 -0
- package/build/ts/app.module.js +42 -0
- package/build/ts/app.module.js.map +1 -0
- package/build/ts/auth/AccountSignatureGuard.service.d.ts +44 -0
- package/build/ts/auth/AccountSignatureGuard.service.d.ts.map +1 -0
- package/build/ts/auth/AccountSignatureGuard.service.js +96 -0
- package/build/ts/auth/AccountSignatureGuard.service.js.map +1 -0
- package/build/ts/auth/__tests__/AccountSignatureGuard.test.d.ts +2 -0
- package/build/ts/auth/__tests__/AccountSignatureGuard.test.d.ts.map +1 -0
- package/build/ts/auth/__tests__/AccountSignatureGuard.test.js +113 -0
- package/build/ts/auth/__tests__/AccountSignatureGuard.test.js.map +1 -0
- package/build/ts/common/__tests__/common.test.d.ts +2 -0
- package/build/ts/common/__tests__/common.test.d.ts.map +1 -0
- package/build/ts/common/__tests__/common.test.js +77 -0
- package/build/ts/common/__tests__/common.test.js.map +1 -0
- package/build/ts/common/accountAbstraction.d.ts +38 -0
- package/build/ts/common/accountAbstraction.d.ts.map +1 -0
- package/build/ts/common/accountAbstraction.js +83 -0
- package/build/ts/common/accountAbstraction.js.map +1 -0
- package/build/ts/common/chain.d.ts +22 -0
- package/build/ts/common/chain.d.ts.map +1 -0
- package/build/ts/common/chain.js +37 -0
- package/build/ts/common/chain.js.map +1 -0
- 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 +36 -0
- package/build/ts/common/errors.d.ts.map +1 -0
- package/build/ts/common/errors.js +37 -0
- package/build/ts/common/errors.js.map +1 -0
- 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 +6 -0
- package/build/ts/common/index.d.ts.map +1 -0
- package/build/ts/common/index.js +6 -0
- package/build/ts/common/index.js.map +1 -0
- package/build/ts/common/networks.d.ts +10 -0
- package/build/ts/common/networks.d.ts.map +1 -0
- package/build/ts/common/networks.js +61 -0
- package/build/ts/common/networks.js.map +1 -0
- package/build/ts/common/types.d.ts +8 -0
- package/build/ts/common/types.d.ts.map +1 -0
- package/build/ts/common/types.js +2 -0
- package/build/ts/common/types.js.map +1 -0
- package/build/ts/crypto/__tests__/crypto.service.test.d.ts +2 -0
- package/build/ts/crypto/__tests__/crypto.service.test.d.ts.map +1 -0
- package/build/ts/crypto/__tests__/crypto.service.test.js +26 -0
- package/build/ts/crypto/__tests__/crypto.service.test.js.map +1 -0
- package/build/ts/crypto/crypto.module.d.ts +3 -0
- package/build/ts/crypto/crypto.module.d.ts.map +1 -0
- package/build/ts/crypto/crypto.module.js +18 -0
- package/build/ts/crypto/crypto.module.js.map +1 -0
- package/build/ts/crypto/crypto.service.d.ts +31 -0
- package/build/ts/crypto/crypto.service.d.ts.map +1 -0
- package/build/ts/crypto/crypto.service.js +68 -0
- package/build/ts/crypto/crypto.service.js.map +1 -0
- package/build/ts/deployer/__tests__/deployer.controller.test.d.ts +2 -0
- package/build/ts/deployer/__tests__/deployer.controller.test.d.ts.map +1 -0
- package/build/ts/deployer/__tests__/deployer.controller.test.js +82 -0
- package/build/ts/deployer/__tests__/deployer.controller.test.js.map +1 -0
- package/build/ts/deployer/__tests__/deployer.service.test.d.ts +2 -0
- package/build/ts/deployer/__tests__/deployer.service.test.d.ts.map +1 -0
- package/build/ts/deployer/__tests__/deployer.service.test.js +272 -0
- package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -0
- package/build/ts/deployer/__tests__/utils.d.ts +61 -0
- package/build/ts/deployer/__tests__/utils.d.ts.map +1 -0
- package/build/ts/deployer/__tests__/utils.js +122 -0
- package/build/ts/deployer/__tests__/utils.js.map +1 -0
- package/build/ts/deployer/constants.d.ts +13 -0
- package/build/ts/deployer/constants.d.ts.map +1 -0
- package/build/ts/deployer/constants.js +13 -0
- package/build/ts/deployer/constants.js.map +1 -0
- package/build/ts/deployer/deployer.controller.d.ts +34 -0
- package/build/ts/deployer/deployer.controller.d.ts.map +1 -0
- package/build/ts/deployer/deployer.controller.js +102 -0
- package/build/ts/deployer/deployer.controller.js.map +1 -0
- package/build/ts/deployer/deployer.module.d.ts +3 -0
- package/build/ts/deployer/deployer.module.d.ts.map +1 -0
- package/build/ts/deployer/deployer.module.js +23 -0
- package/build/ts/deployer/deployer.module.js.map +1 -0
- package/build/ts/deployer/deployer.service.d.ts +85 -0
- package/build/ts/deployer/deployer.service.d.ts.map +1 -0
- package/build/ts/deployer/deployer.service.js +505 -0
- package/build/ts/deployer/deployer.service.js.map +1 -0
- package/build/ts/deployer/dto.d.ts +46 -0
- package/build/ts/deployer/dto.d.ts.map +1 -0
- package/build/ts/deployer/dto.js +125 -0
- package/build/ts/deployer/dto.js.map +1 -0
- package/build/ts/deployer/types.d.ts +351 -0
- package/build/ts/deployer/types.d.ts.map +1 -0
- package/build/ts/deployer/types.js +2 -0
- package/build/ts/deployer/types.js.map +1 -0
- package/build/ts/file/__tests__/file.service.test.d.ts +2 -0
- package/build/ts/file/__tests__/file.service.test.d.ts.map +1 -0
- package/build/ts/file/__tests__/file.service.test.js +77 -0
- package/build/ts/file/__tests__/file.service.test.js.map +1 -0
- package/build/ts/file/file.module.d.ts +3 -0
- package/build/ts/file/file.module.d.ts.map +1 -0
- package/build/ts/file/file.module.js +18 -0
- package/build/ts/file/file.module.js.map +1 -0
- package/build/ts/file/file.service.d.ts +63 -0
- package/build/ts/file/file.service.d.ts.map +1 -0
- package/build/ts/file/file.service.js +121 -0
- package/build/ts/file/file.service.js.map +1 -0
- package/build/ts/file/types.d.ts +36 -0
- package/build/ts/file/types.d.ts.map +1 -0
- package/build/ts/file/types.js +2 -0
- package/build/ts/file/types.js.map +1 -0
- 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/jest/setup.d.ts +8 -0
- package/build/ts/jest/setup.d.ts.map +1 -0
- package/build/ts/jest/setup.js +2 -0
- package/build/ts/jest/setup.js.map +1 -0
- package/build/ts/jest/transform.d.ts +8 -0
- package/build/ts/jest/transform.d.ts.map +1 -0
- package/build/ts/jest/transform.js +10 -0
- package/build/ts/jest/transform.js.map +1 -0
- package/build/ts/main.d.ts +2 -0
- package/build/ts/main.d.ts.map +1 -0
- package/build/ts/main.js +46 -0
- package/build/ts/main.js.map +1 -0
- package/build/ts/proof/__tests__/proof.controller.test.d.ts +2 -0
- package/build/ts/proof/__tests__/proof.controller.test.d.ts.map +1 -0
- package/build/ts/proof/__tests__/proof.controller.test.js +90 -0
- package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -0
- package/build/ts/proof/__tests__/proof.gateway.test.d.ts +2 -0
- package/build/ts/proof/__tests__/proof.gateway.test.d.ts.map +1 -0
- package/build/ts/proof/__tests__/proof.gateway.test.js +63 -0
- package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -0
- package/build/ts/proof/__tests__/proof.service.test.d.ts +2 -0
- package/build/ts/proof/__tests__/proof.service.test.d.ts.map +1 -0
- package/build/ts/proof/__tests__/proof.service.test.js +84 -0
- package/build/ts/proof/__tests__/proof.service.test.js.map +1 -0
- package/build/ts/proof/dto.d.ts +70 -0
- package/build/ts/proof/dto.d.ts.map +1 -0
- package/build/ts/proof/dto.js +261 -0
- package/build/ts/proof/dto.js.map +1 -0
- package/build/ts/proof/proof.controller.d.ts +47 -0
- package/build/ts/proof/proof.controller.d.ts.map +1 -0
- package/build/ts/proof/proof.controller.js +158 -0
- package/build/ts/proof/proof.controller.js.map +1 -0
- package/build/ts/proof/proof.gateway.d.ts +35 -0
- package/build/ts/proof/proof.gateway.d.ts.map +1 -0
- package/build/ts/proof/proof.gateway.js +93 -0
- package/build/ts/proof/proof.gateway.js.map +1 -0
- package/build/ts/proof/proof.module.d.ts +3 -0
- package/build/ts/proof/proof.module.d.ts.map +1 -0
- package/build/ts/proof/proof.module.js +25 -0
- package/build/ts/proof/proof.module.js.map +1 -0
- package/build/ts/proof/proof.service.d.ts +52 -0
- package/build/ts/proof/proof.service.d.ts.map +1 -0
- package/build/ts/proof/proof.service.js +164 -0
- package/build/ts/proof/proof.service.js.map +1 -0
- package/build/ts/proof/types.d.ts +144 -0
- package/build/ts/proof/types.d.ts.map +1 -0
- package/build/ts/proof/types.js +11 -0
- package/build/ts/proof/types.js.map +1 -0
- package/build/ts/redis/__tests__/redis.service.test.d.ts +2 -0
- package/build/ts/redis/__tests__/redis.service.test.d.ts.map +1 -0
- package/build/ts/redis/__tests__/redis.service.test.js +148 -0
- package/build/ts/redis/__tests__/redis.service.test.js.map +1 -0
- package/build/ts/redis/redis.module.d.ts +3 -0
- package/build/ts/redis/redis.module.d.ts.map +1 -0
- package/build/ts/redis/redis.module.js +18 -0
- package/build/ts/redis/redis.module.js.map +1 -0
- package/build/ts/redis/redis.service.d.ts +53 -0
- package/build/ts/redis/redis.service.d.ts.map +1 -0
- package/build/ts/redis/redis.service.js +99 -0
- package/build/ts/redis/redis.service.js.map +1 -0
- package/build/ts/redis/types.d.ts +66 -0
- package/build/ts/redis/types.d.ts.map +1 -0
- package/build/ts/redis/types.js +2 -0
- package/build/ts/redis/types.js.map +1 -0
- package/build/ts/redis/utils.d.ts +20 -0
- package/build/ts/redis/utils.d.ts.map +1 -0
- package/build/ts/redis/utils.js +27 -0
- package/build/ts/redis/utils.js.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.d.ts +2 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.d.ts.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.js +62 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.js.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.d.ts +2 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.d.ts.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.js +369 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.js.map +1 -0
- package/build/ts/scheduler/dto.d.ts +41 -0
- package/build/ts/scheduler/dto.d.ts.map +1 -0
- package/build/ts/scheduler/dto.js +115 -0
- package/build/ts/scheduler/dto.js.map +1 -0
- package/build/ts/scheduler/scheduler.controller.d.ts +32 -0
- package/build/ts/scheduler/scheduler.controller.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.controller.js +118 -0
- package/build/ts/scheduler/scheduler.controller.js.map +1 -0
- package/build/ts/scheduler/scheduler.module.d.ts +3 -0
- package/build/ts/scheduler/scheduler.module.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.module.js +24 -0
- package/build/ts/scheduler/scheduler.module.js.map +1 -0
- package/build/ts/scheduler/scheduler.service.d.ts +71 -0
- package/build/ts/scheduler/scheduler.service.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.service.js +297 -0
- package/build/ts/scheduler/scheduler.service.js.map +1 -0
- package/build/ts/scheduler/types.d.ts +65 -0
- package/build/ts/scheduler/types.d.ts.map +1 -0
- package/build/ts/scheduler/types.js +2 -0
- package/build/ts/scheduler/types.js.map +1 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.d.ts +2 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.d.ts.map +1 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.js +44 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.js.map +1 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.d.ts +2 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.d.ts.map +1 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js +76 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js.map +1 -0
- package/build/ts/sessionKeys/__tests__/utils.d.ts +25 -0
- package/build/ts/sessionKeys/__tests__/utils.d.ts.map +1 -0
- package/build/ts/sessionKeys/__tests__/utils.js +65 -0
- package/build/ts/sessionKeys/__tests__/utils.js.map +1 -0
- package/build/ts/sessionKeys/dto.d.ts +11 -0
- package/build/ts/sessionKeys/dto.d.ts.map +1 -0
- package/build/ts/sessionKeys/dto.js +29 -0
- package/build/ts/sessionKeys/dto.js.map +1 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts +53 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts.map +1 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js +105 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.controller.d.ts +26 -0
- package/build/ts/sessionKeys/sessionKeys.controller.d.ts.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.controller.js +74 -0
- package/build/ts/sessionKeys/sessionKeys.controller.js.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.module.d.ts +3 -0
- package/build/ts/sessionKeys/sessionKeys.module.d.ts.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.module.js +23 -0
- package/build/ts/sessionKeys/sessionKeys.module.js.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.service.d.ts +62 -0
- package/build/ts/sessionKeys/sessionKeys.service.d.ts.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.service.js +121 -0
- package/build/ts/sessionKeys/sessionKeys.service.js.map +1 -0
- package/build/ts/sessionKeys/types.d.ts +11 -0
- package/build/ts/sessionKeys/types.d.ts.map +1 -0
- package/build/ts/sessionKeys/types.js +2 -0
- package/build/ts/sessionKeys/types.js.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.controller.test.d.ts +2 -0
- package/build/ts/subgraph/__tests__/subgraph.controller.test.d.ts.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.controller.test.js +50 -0
- package/build/ts/subgraph/__tests__/subgraph.controller.test.js.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.d.ts +2 -0
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.d.ts.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.js +83 -0
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.js.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.service.test.d.ts +2 -0
- package/build/ts/subgraph/__tests__/subgraph.service.test.d.ts.map +1 -0
- package/build/ts/subgraph/__tests__/subgraph.service.test.js +58 -0
- package/build/ts/subgraph/__tests__/subgraph.service.test.js.map +1 -0
- package/build/ts/subgraph/dto.d.ts +27 -0
- package/build/ts/subgraph/dto.d.ts.map +1 -0
- package/build/ts/subgraph/dto.js +83 -0
- package/build/ts/subgraph/dto.js.map +1 -0
- package/build/ts/subgraph/subgraph.controller.d.ts +24 -0
- package/build/ts/subgraph/subgraph.controller.d.ts.map +1 -0
- package/build/ts/subgraph/subgraph.controller.js +71 -0
- package/build/ts/subgraph/subgraph.controller.js.map +1 -0
- package/build/ts/subgraph/subgraph.gateway.d.ts +35 -0
- package/build/ts/subgraph/subgraph.gateway.d.ts.map +1 -0
- package/build/ts/subgraph/subgraph.gateway.js +93 -0
- package/build/ts/subgraph/subgraph.gateway.js.map +1 -0
- package/build/ts/subgraph/subgraph.module.d.ts +3 -0
- package/build/ts/subgraph/subgraph.module.d.ts.map +1 -0
- package/build/ts/subgraph/subgraph.module.js +23 -0
- package/build/ts/subgraph/subgraph.module.js.map +1 -0
- package/build/ts/subgraph/subgraph.service.d.ts +24 -0
- package/build/ts/subgraph/subgraph.service.d.ts.map +1 -0
- package/build/ts/subgraph/subgraph.service.js +119 -0
- package/build/ts/subgraph/subgraph.service.js.map +1 -0
- package/build/ts/subgraph/types.d.ts +93 -0
- package/build/ts/subgraph/types.d.ts.map +1 -0
- package/build/ts/subgraph/types.js +24 -0
- package/build/ts/subgraph/types.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +131 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
|
+
import type { AASigner } from "@maci-protocol/contracts";
|
|
3
|
+
import type { ESupportedChains } from "@maci-protocol/sdk";
|
|
4
|
+
import type { Hex } from "viem";
|
|
5
|
+
import { KernelClientType } from "../common";
|
|
6
|
+
import { FileService } from "../file/file.service";
|
|
7
|
+
import { IGenerateSessionKeyReturn } from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* SessionKeysService is responsible for generating and managing session keys.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SessionKeysService {
|
|
12
|
+
private readonly fileService;
|
|
13
|
+
/**
|
|
14
|
+
* Logger
|
|
15
|
+
*/
|
|
16
|
+
private readonly logger;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new instance of SessionKeysService
|
|
19
|
+
*
|
|
20
|
+
* @param fileService - file service
|
|
21
|
+
*/
|
|
22
|
+
constructor(fileService: FileService);
|
|
23
|
+
/**
|
|
24
|
+
* Generate a session key
|
|
25
|
+
*
|
|
26
|
+
* @returns session key address
|
|
27
|
+
*/
|
|
28
|
+
generateSessionKey(): Promise<IGenerateSessionKeyReturn>;
|
|
29
|
+
/**
|
|
30
|
+
* Generate a KernelClient from a session key and an approval
|
|
31
|
+
*
|
|
32
|
+
* @param sessionKeyAddress - the address of the session key
|
|
33
|
+
* @param approval - the approval string
|
|
34
|
+
* @param chain - the chain to use
|
|
35
|
+
* @returns a KernelAccountClient
|
|
36
|
+
*/
|
|
37
|
+
generateClientFromSessionKey(sessionKeyAddress: Hex, approval: string, chain: ESupportedChains): Promise<KernelClientType>;
|
|
38
|
+
/**
|
|
39
|
+
* Get a signer from a kernel client (that could be generated from a session key)
|
|
40
|
+
*
|
|
41
|
+
* @param kernelClient - kernel client
|
|
42
|
+
* @returns signer
|
|
43
|
+
*/
|
|
44
|
+
getKernelClientSigner(kernelClient: KernelClientType): Promise<AASigner>;
|
|
45
|
+
/**
|
|
46
|
+
* Get a signer that would execute all the contract interactions in the coordinator service.
|
|
47
|
+
* There are particular cases where the AA signer does not work so we default to the normal signer.
|
|
48
|
+
* (e.g. `deployPoll`)
|
|
49
|
+
* @param chain - the chain to use
|
|
50
|
+
* @param sessionKeyAddress - the address of the session key. Defaults to normal signer if not provided
|
|
51
|
+
* @param approval - the approval string. Defaults to normal signer if not provided
|
|
52
|
+
* @returns a signer
|
|
53
|
+
*/
|
|
54
|
+
getCoordinatorSigner(chain: ESupportedChains, sessionKeyAddress?: Hex, approval?: string): Promise<AASigner | Signer>;
|
|
55
|
+
/**
|
|
56
|
+
* Deactivate a session key
|
|
57
|
+
*
|
|
58
|
+
* @param sessionKeyAddress - key address
|
|
59
|
+
*/
|
|
60
|
+
deactivateSessionKey(sessionKeyAddress: Hex): void;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=sessionKeys.service.d.ts.map
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0,0 +1,121 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var SessionKeysService_1;
|
|
11
|
+
import { Injectable, Logger } from "@nestjs/common";
|
|
12
|
+
import { toECDSASigner } from "@zerodev/permissions/signers";
|
|
13
|
+
import { BrowserProvider } from "ethers";
|
|
14
|
+
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
|
|
15
|
+
import { ErrorCodes, getSigner } from "../common";
|
|
16
|
+
import { getKernelClient } from "../common/accountAbstraction";
|
|
17
|
+
import { FileService } from "../file/file.service";
|
|
18
|
+
import { KernelEIP1193Provider } from "./provider/KernelEIP1193Provider";
|
|
19
|
+
/**
|
|
20
|
+
* SessionKeysService is responsible for generating and managing session keys.
|
|
21
|
+
*/
|
|
22
|
+
let SessionKeysService = SessionKeysService_1 = class SessionKeysService {
|
|
23
|
+
fileService;
|
|
24
|
+
/**
|
|
25
|
+
* Logger
|
|
26
|
+
*/
|
|
27
|
+
logger;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new instance of SessionKeysService
|
|
30
|
+
*
|
|
31
|
+
* @param fileService - file service
|
|
32
|
+
*/
|
|
33
|
+
constructor(fileService) {
|
|
34
|
+
this.fileService = fileService;
|
|
35
|
+
this.logger = new Logger(SessionKeysService_1.name);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generate a session key
|
|
39
|
+
*
|
|
40
|
+
* @returns session key address
|
|
41
|
+
*/
|
|
42
|
+
async generateSessionKey() {
|
|
43
|
+
const sessionPrivateKey = generatePrivateKey();
|
|
44
|
+
const sessionKeySigner = await toECDSASigner({
|
|
45
|
+
signer: privateKeyToAccount(sessionPrivateKey),
|
|
46
|
+
});
|
|
47
|
+
const sessionKeyAddress = sessionKeySigner.account.address;
|
|
48
|
+
// save the key
|
|
49
|
+
this.fileService.storeSessionKey(sessionPrivateKey, sessionKeyAddress);
|
|
50
|
+
return {
|
|
51
|
+
sessionKeyAddress,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Generate a KernelClient from a session key and an approval
|
|
56
|
+
*
|
|
57
|
+
* @param sessionKeyAddress - the address of the session key
|
|
58
|
+
* @param approval - the approval string
|
|
59
|
+
* @param chain - the chain to use
|
|
60
|
+
* @returns a KernelAccountClient
|
|
61
|
+
*/
|
|
62
|
+
async generateClientFromSessionKey(sessionKeyAddress, approval, chain) {
|
|
63
|
+
// retrieve the session key from the file service
|
|
64
|
+
const sessionKey = this.fileService.getSessionKey(sessionKeyAddress);
|
|
65
|
+
if (!sessionKey) {
|
|
66
|
+
this.logger.error(`Session key not found: ${sessionKeyAddress}`);
|
|
67
|
+
throw new Error(ErrorCodes.SESSION_KEY_NOT_FOUND.toString());
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
return await getKernelClient(sessionKey, approval, chain);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
this.logger.error("Error:", error);
|
|
74
|
+
throw new Error(ErrorCodes.INVALID_APPROVAL.toString());
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get a signer from a kernel client (that could be generated from a session key)
|
|
79
|
+
*
|
|
80
|
+
* @param kernelClient - kernel client
|
|
81
|
+
* @returns signer
|
|
82
|
+
*/
|
|
83
|
+
async getKernelClientSigner(kernelClient) {
|
|
84
|
+
const kernelProvider = new KernelEIP1193Provider(kernelClient);
|
|
85
|
+
const ethersProvider = new BrowserProvider(kernelProvider);
|
|
86
|
+
const signer = await ethersProvider.getSigner();
|
|
87
|
+
const aaSigner = signer;
|
|
88
|
+
aaSigner.isAA = true;
|
|
89
|
+
return aaSigner;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get a signer that would execute all the contract interactions in the coordinator service.
|
|
93
|
+
* There are particular cases where the AA signer does not work so we default to the normal signer.
|
|
94
|
+
* (e.g. `deployPoll`)
|
|
95
|
+
* @param chain - the chain to use
|
|
96
|
+
* @param sessionKeyAddress - the address of the session key. Defaults to normal signer if not provided
|
|
97
|
+
* @param approval - the approval string. Defaults to normal signer if not provided
|
|
98
|
+
* @returns a signer
|
|
99
|
+
*/
|
|
100
|
+
async getCoordinatorSigner(chain, sessionKeyAddress, approval) {
|
|
101
|
+
if (sessionKeyAddress && approval) {
|
|
102
|
+
const kernelClient = await this.generateClientFromSessionKey(sessionKeyAddress, approval, chain);
|
|
103
|
+
return this.getKernelClientSigner(kernelClient);
|
|
104
|
+
}
|
|
105
|
+
return getSigner(chain);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Deactivate a session key
|
|
109
|
+
*
|
|
110
|
+
* @param sessionKeyAddress - key address
|
|
111
|
+
*/
|
|
112
|
+
deactivateSessionKey(sessionKeyAddress) {
|
|
113
|
+
this.fileService.deleteSessionKey(sessionKeyAddress);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
SessionKeysService = SessionKeysService_1 = __decorate([
|
|
117
|
+
Injectable(),
|
|
118
|
+
__metadata("design:paramtypes", [FileService])
|
|
119
|
+
], SessionKeysService);
|
|
120
|
+
export { SessionKeysService };
|
|
121
|
+
//# sourceMappingURL=sessionKeys.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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,EAAE,KAAK,CAAC,CAAC;YACjG,OAAO,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,oBAAoB,CAAC,iBAAsB;QACzC,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACvD,CAAC;CACF,CAAA;AAhHY,kBAAkB;IAD9B,UAAU,EAAE;qCAY+B,WAAW;GAX1C,kBAAkB,CAgH9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/sessionKeys/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/sessionKeys/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph.controller.test.d.ts","sourceRoot":"","sources":["../../../../ts/subgraph/__tests__/subgraph.controller.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ESupportedChains } from "@maci-protocol/sdk";
|
|
2
|
+
import { HttpException, HttpStatus } from "@nestjs/common";
|
|
3
|
+
import { Test } from "@nestjs/testing";
|
|
4
|
+
import { SubgraphController } from "../subgraph.controller";
|
|
5
|
+
import { SubgraphService } from "../subgraph.service";
|
|
6
|
+
describe("SubgraphController", () => {
|
|
7
|
+
let subgraphController;
|
|
8
|
+
const defaultSubgraphDeployArgs = {
|
|
9
|
+
maciContractAddress: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
10
|
+
startBlock: 0,
|
|
11
|
+
network: ESupportedChains.OptimismSepolia,
|
|
12
|
+
name: "subgraph",
|
|
13
|
+
tag: "v0.0.1",
|
|
14
|
+
};
|
|
15
|
+
const defaultSubgraphDeployData = {
|
|
16
|
+
url: "url",
|
|
17
|
+
};
|
|
18
|
+
const mockSubgraphService = {
|
|
19
|
+
deploy: jest.fn(),
|
|
20
|
+
};
|
|
21
|
+
beforeEach(async () => {
|
|
22
|
+
const app = await Test.createTestingModule({
|
|
23
|
+
controllers: [SubgraphController],
|
|
24
|
+
})
|
|
25
|
+
.useMocker((token) => {
|
|
26
|
+
if (token === SubgraphService) {
|
|
27
|
+
mockSubgraphService.deploy.mockResolvedValue(defaultSubgraphDeployData);
|
|
28
|
+
return mockSubgraphService;
|
|
29
|
+
}
|
|
30
|
+
return jest.fn();
|
|
31
|
+
})
|
|
32
|
+
.compile();
|
|
33
|
+
subgraphController = app.get(SubgraphController);
|
|
34
|
+
});
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
jest.clearAllMocks();
|
|
37
|
+
});
|
|
38
|
+
describe("v1/subgraph/deploy", () => {
|
|
39
|
+
test("should return deployed subgraph url properly", async () => {
|
|
40
|
+
const data = await subgraphController.deploy(defaultSubgraphDeployArgs);
|
|
41
|
+
expect(data).toStrictEqual(defaultSubgraphDeployData);
|
|
42
|
+
});
|
|
43
|
+
test("should throw an error if proof generation is failed", async () => {
|
|
44
|
+
const error = new Error("error");
|
|
45
|
+
mockSubgraphService.deploy.mockRejectedValue(error);
|
|
46
|
+
await expect(subgraphController.deploy(defaultSubgraphDeployArgs)).rejects.toThrow(new HttpException(error.message, HttpStatus.INTERNAL_SERVER_ERROR));
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=subgraph.controller.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph.controller.test.js","sourceRoot":"","sources":["../../../../ts/subgraph/__tests__/subgraph.controller.test.ts"],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,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,IAAI,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;YAC9D,MAAM,IAAI,GAAG,MAAM,kBAAkB,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;YACxE,MAAM,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,qDAAqD,EAAE,KAAK,IAAI,EAAE;YACrE,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;YACjC,mBAAmB,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAEpD,MAAM,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAChF,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,qBAAqB,CAAC,CACnE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph.gateway.test.d.ts","sourceRoot":"","sources":["../../../../ts/subgraph/__tests__/subgraph.gateway.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ESupportedChains } from "@maci-protocol/sdk";
|
|
2
|
+
import { Test } from "@nestjs/testing";
|
|
3
|
+
import { SubgraphGateway } from "../subgraph.gateway";
|
|
4
|
+
import { SubgraphService } from "../subgraph.service";
|
|
5
|
+
import { EProgressStep, ESubgraphEvents, TOTAL_STEPS, } from "../types";
|
|
6
|
+
describe("SubgraphGateway", () => {
|
|
7
|
+
let gateway;
|
|
8
|
+
const defaultSubgraphDeployArgs = {
|
|
9
|
+
maciContractAddress: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
10
|
+
startBlock: 0,
|
|
11
|
+
network: ESupportedChains.OptimismSepolia,
|
|
12
|
+
name: "subgraph",
|
|
13
|
+
tag: "v0.0.1",
|
|
14
|
+
};
|
|
15
|
+
const defaultSubgraphDeployData = {
|
|
16
|
+
url: "https://localhost:3000",
|
|
17
|
+
};
|
|
18
|
+
const mockSubgraphService = {
|
|
19
|
+
deploy: jest.fn(),
|
|
20
|
+
};
|
|
21
|
+
const mockEmit = jest.fn();
|
|
22
|
+
beforeEach(async () => {
|
|
23
|
+
const testModule = await Test.createTestingModule({ providers: [SubgraphGateway] })
|
|
24
|
+
.useMocker((token) => {
|
|
25
|
+
if (token === SubgraphService) {
|
|
26
|
+
mockSubgraphService.deploy.mockImplementation((_, options) => {
|
|
27
|
+
options?.onProgress({ current: EProgressStep.SCHEMA, total: TOTAL_STEPS });
|
|
28
|
+
options?.onProgress({ current: EProgressStep.NETWORK, total: TOTAL_STEPS });
|
|
29
|
+
options?.onProgress({ current: EProgressStep.TEMPLATE, total: TOTAL_STEPS });
|
|
30
|
+
options?.onProgress({ current: EProgressStep.CODEGEN, total: TOTAL_STEPS });
|
|
31
|
+
options?.onProgress({ current: EProgressStep.BUILD, total: TOTAL_STEPS });
|
|
32
|
+
options?.onProgress({ current: EProgressStep.DEPLOY, total: TOTAL_STEPS });
|
|
33
|
+
options?.onSuccess(defaultSubgraphDeployData.url);
|
|
34
|
+
options?.onFail(new Error("error"));
|
|
35
|
+
});
|
|
36
|
+
return mockSubgraphService;
|
|
37
|
+
}
|
|
38
|
+
return jest.fn();
|
|
39
|
+
})
|
|
40
|
+
.compile();
|
|
41
|
+
gateway = testModule.get(SubgraphGateway);
|
|
42
|
+
gateway.server = { emit: mockEmit };
|
|
43
|
+
});
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
jest.clearAllMocks();
|
|
46
|
+
});
|
|
47
|
+
test("should be defined", () => {
|
|
48
|
+
expect(gateway).toBeDefined();
|
|
49
|
+
});
|
|
50
|
+
test("should start subgraph deployment properly", async () => {
|
|
51
|
+
await gateway.deploy(defaultSubgraphDeployArgs);
|
|
52
|
+
expect(mockEmit).toHaveBeenCalledTimes(8);
|
|
53
|
+
expect(mockEmit).toHaveBeenNthCalledWith(1, ESubgraphEvents.PROGRESS, {
|
|
54
|
+
current: EProgressStep.SCHEMA,
|
|
55
|
+
total: TOTAL_STEPS,
|
|
56
|
+
});
|
|
57
|
+
expect(mockEmit).toHaveBeenNthCalledWith(2, ESubgraphEvents.PROGRESS, {
|
|
58
|
+
current: EProgressStep.NETWORK,
|
|
59
|
+
total: TOTAL_STEPS,
|
|
60
|
+
});
|
|
61
|
+
expect(mockEmit).toHaveBeenNthCalledWith(3, ESubgraphEvents.PROGRESS, {
|
|
62
|
+
current: EProgressStep.TEMPLATE,
|
|
63
|
+
total: TOTAL_STEPS,
|
|
64
|
+
});
|
|
65
|
+
expect(mockEmit).toHaveBeenNthCalledWith(4, ESubgraphEvents.PROGRESS, {
|
|
66
|
+
current: EProgressStep.CODEGEN,
|
|
67
|
+
total: TOTAL_STEPS,
|
|
68
|
+
});
|
|
69
|
+
expect(mockEmit).toHaveBeenNthCalledWith(5, ESubgraphEvents.PROGRESS, {
|
|
70
|
+
current: EProgressStep.BUILD,
|
|
71
|
+
total: TOTAL_STEPS,
|
|
72
|
+
});
|
|
73
|
+
expect(mockEmit).toHaveBeenNthCalledWith(6, ESubgraphEvents.PROGRESS, {
|
|
74
|
+
current: EProgressStep.DEPLOY,
|
|
75
|
+
total: TOTAL_STEPS,
|
|
76
|
+
});
|
|
77
|
+
expect(mockEmit).toHaveBeenNthCalledWith(7, ESubgraphEvents.FINISH, {
|
|
78
|
+
url: defaultSubgraphDeployData.url,
|
|
79
|
+
});
|
|
80
|
+
expect(mockEmit).toHaveBeenNthCalledWith(8, ESubgraphEvents.ERROR, { message: "error" });
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=subgraph.gateway.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AAM,CAAC,QAAQ,CAAC,CAAC,uBAAuB,CAAC,CAAC,EAAE,eAAe,CAAC,MAAM,EAAE;YAClE,GAAG,EAAE,yBAAyB,CAAC,GAAG;SACnC,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,CAAC,uBAAuB,CAAC,CAAC,EAAE,eAAe,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph.service.test.d.ts","sourceRoot":"","sources":["../../../../ts/subgraph/__tests__/subgraph.service.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ESupportedChains } from "@maci-protocol/sdk";
|
|
2
|
+
import dotenv from "dotenv";
|
|
3
|
+
import childProcess from "child_process";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import { ErrorCodes } from "../../common";
|
|
6
|
+
import { SubgraphService } from "../subgraph.service";
|
|
7
|
+
dotenv.config();
|
|
8
|
+
jest.mock("child_process", () => ({
|
|
9
|
+
...jest.requireActual("child_process"),
|
|
10
|
+
execFile: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
jest.mock("fs", () => ({
|
|
13
|
+
...jest.requireActual("fs"),
|
|
14
|
+
promises: {
|
|
15
|
+
writeFile: jest.fn(),
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
jest.mock("util", () => ({
|
|
19
|
+
promisify: jest.fn((func) => func),
|
|
20
|
+
}));
|
|
21
|
+
describe("SubgraphService", () => {
|
|
22
|
+
const defaultArgs = {
|
|
23
|
+
maciContractAddress: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
24
|
+
startBlock: 0,
|
|
25
|
+
network: ESupportedChains.OptimismSepolia,
|
|
26
|
+
name: "subgraph",
|
|
27
|
+
tag: "v0.0.1",
|
|
28
|
+
};
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
childProcess.execFile.mockResolvedValue({
|
|
31
|
+
stdout: "https://subgraph.com https://test.com",
|
|
32
|
+
});
|
|
33
|
+
fs.promises.writeFile.mockResolvedValue(undefined);
|
|
34
|
+
});
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
jest.clearAllMocks();
|
|
37
|
+
});
|
|
38
|
+
test("should throw error if deploy is failed", async () => {
|
|
39
|
+
childProcess.execFile.mockRejectedValue(new Error());
|
|
40
|
+
const service = new SubgraphService();
|
|
41
|
+
await expect(service.deploy(defaultArgs)).rejects.toThrow(ErrorCodes.SUBGRAPH_DEPLOY.toString());
|
|
42
|
+
});
|
|
43
|
+
test("should throw error if network is invalid", async () => {
|
|
44
|
+
const service = new SubgraphService();
|
|
45
|
+
await expect(service.deploy({ ...defaultArgs, network: "unknown" })).rejects.toThrow(ErrorCodes.UNSUPPORTED_NETWORK.toString());
|
|
46
|
+
});
|
|
47
|
+
test("should throw error if there is no subgraph url", async () => {
|
|
48
|
+
childProcess.execFile.mockResolvedValue({ stdout: "", stderr: "" });
|
|
49
|
+
const service = new SubgraphService();
|
|
50
|
+
await expect(service.deploy(defaultArgs)).rejects.toThrow(ErrorCodes.SUBGRAPH_DEPLOY.toString());
|
|
51
|
+
});
|
|
52
|
+
test("should return deployed subgraph url properly", async () => {
|
|
53
|
+
const service = new SubgraphService();
|
|
54
|
+
const { url } = await service.deploy(defaultArgs);
|
|
55
|
+
expect(url).toBe("https://test.com");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=subgraph.service.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph.service.test.js","sourceRoot":"","sources":["../../../../ts/subgraph/__tests__/subgraph.service.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,YAAY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G,EAAE,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAElD,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ESupportedChains } from "@maci-protocol/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Data transfer object for deploying subgraph
|
|
4
|
+
*/
|
|
5
|
+
export declare class DeploySubgraphDto {
|
|
6
|
+
/**
|
|
7
|
+
* MACI contract address
|
|
8
|
+
*/
|
|
9
|
+
maciContractAddress: string;
|
|
10
|
+
/**
|
|
11
|
+
* Start block for event processing
|
|
12
|
+
*/
|
|
13
|
+
startBlock: number;
|
|
14
|
+
/**
|
|
15
|
+
* Network CLI name
|
|
16
|
+
*/
|
|
17
|
+
network: ESupportedChains;
|
|
18
|
+
/**
|
|
19
|
+
* Subgraph name
|
|
20
|
+
*/
|
|
21
|
+
name: string;
|
|
22
|
+
/**
|
|
23
|
+
* Version tag (ex: v0.0.1)
|
|
24
|
+
*/
|
|
25
|
+
tag: string;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../../../ts/subgraph/dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD;;GAEG;AACH,qBAAa,iBAAiB;IAC5B;;OAEG;IAMH,mBAAmB,EAAG,MAAM,CAAC;IAE7B;;OAEG;IAQH,UAAU,EAAG,MAAM,CAAC;IAEpB;;OAEG;IAMH,OAAO,EAAG,gBAAgB,CAAC;IAE3B;;OAEG;IAQH,IAAI,EAAG,MAAM,CAAC;IAEd;;OAEG;IAOH,GAAG,EAAG,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ESupportedChains } from "@maci-protocol/sdk";
|
|
11
|
+
import { ApiProperty } from "@nestjs/swagger";
|
|
12
|
+
import { IsEnum, IsEthereumAddress, IsInt, IsString, Matches, MaxLength, Min, MinLength } from "class-validator";
|
|
13
|
+
/**
|
|
14
|
+
* Data transfer object for deploying subgraph
|
|
15
|
+
*/
|
|
16
|
+
export class DeploySubgraphDto {
|
|
17
|
+
/**
|
|
18
|
+
* MACI contract address
|
|
19
|
+
*/
|
|
20
|
+
maciContractAddress;
|
|
21
|
+
/**
|
|
22
|
+
* Start block for event processing
|
|
23
|
+
*/
|
|
24
|
+
startBlock;
|
|
25
|
+
/**
|
|
26
|
+
* Network CLI name
|
|
27
|
+
*/
|
|
28
|
+
network;
|
|
29
|
+
/**
|
|
30
|
+
* Subgraph name
|
|
31
|
+
*/
|
|
32
|
+
name;
|
|
33
|
+
/**
|
|
34
|
+
* Version tag (ex: v0.0.1)
|
|
35
|
+
*/
|
|
36
|
+
tag;
|
|
37
|
+
}
|
|
38
|
+
__decorate([
|
|
39
|
+
ApiProperty({
|
|
40
|
+
description: "MACI contract address",
|
|
41
|
+
type: String,
|
|
42
|
+
}),
|
|
43
|
+
IsEthereumAddress(),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], DeploySubgraphDto.prototype, "maciContractAddress", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
ApiProperty({
|
|
48
|
+
description: "Start block for event parsing",
|
|
49
|
+
minimum: 0,
|
|
50
|
+
type: Number,
|
|
51
|
+
}),
|
|
52
|
+
IsInt(),
|
|
53
|
+
Min(0),
|
|
54
|
+
__metadata("design:type", Number)
|
|
55
|
+
], DeploySubgraphDto.prototype, "startBlock", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
ApiProperty({
|
|
58
|
+
description: "Network CLI name (https://thegraph.com/docs/en/developing/supported-networks/)",
|
|
59
|
+
enum: ESupportedChains,
|
|
60
|
+
}),
|
|
61
|
+
IsEnum(ESupportedChains),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], DeploySubgraphDto.prototype, "network", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
ApiProperty({
|
|
66
|
+
description: "Subgraph name",
|
|
67
|
+
type: String,
|
|
68
|
+
}),
|
|
69
|
+
IsString(),
|
|
70
|
+
MinLength(3),
|
|
71
|
+
MaxLength(50),
|
|
72
|
+
__metadata("design:type", String)
|
|
73
|
+
], DeploySubgraphDto.prototype, "name", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
ApiProperty({
|
|
76
|
+
description: "Version tag (ex: v0.0.1)",
|
|
77
|
+
type: String,
|
|
78
|
+
}),
|
|
79
|
+
IsString(),
|
|
80
|
+
Matches(/^v\d+\.\d+\.\d+$/),
|
|
81
|
+
__metadata("design:type", String)
|
|
82
|
+
], DeploySubgraphDto.prototype, "tag", void 0);
|
|
83
|
+
//# sourceMappingURL=dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.js","sourceRoot":"","sources":["../../../ts/subgraph/dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,C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ubgraphService } from "./subgraph.service";
|
|
4
|
+
export declare class SubgraphController {
|
|
5
|
+
private readonly subgraphService;
|
|
6
|
+
/**
|
|
7
|
+
* Logger
|
|
8
|
+
*/
|
|
9
|
+
private readonly logger;
|
|
10
|
+
/**
|
|
11
|
+
* Initialize SubgraphController
|
|
12
|
+
*
|
|
13
|
+
* @param subgraphService - subgraph service
|
|
14
|
+
*/
|
|
15
|
+
constructor(subgraphService: SubgraphService);
|
|
16
|
+
/**
|
|
17
|
+
* Generate proofs api method
|
|
18
|
+
*
|
|
19
|
+
* @param args - generate proof dto
|
|
20
|
+
* @returns generated proofs and tally data
|
|
21
|
+
*/
|
|
22
|
+
deploy(args: DeploySubgraphDto): Promise<IDeploySubgraphReturn>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=subgraph.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph.controller.d.ts","sourceRoot":"","sources":["../../../ts/subgraph/subgraph.controller.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAKrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,qBAIa,kBAAkB;IAWjB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAV5C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAE9D;;;;OAIG;gBAC0B,eAAe,EAAE,eAAe;IAE7D;;;;;OAKG;IAUG,MAAM,CAAS,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAM9E"}
|