@maci-protocol/coordinator 0.0.0-ci.01622be
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 +49 -0
- package/build/hardhat.config.cjs +34 -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 +9 -0
- package/build/tests/constants.js.map +1 -0
- package/build/tests/e2e.aa.test.d.ts +2 -0
- package/build/tests/e2e.aa.test.d.ts.map +1 -0
- package/build/tests/e2e.aa.test.js +106 -0
- package/build/tests/e2e.aa.test.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 +282 -0
- package/build/tests/e2e.deploy.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 +53 -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 +36 -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 +75 -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 +81 -0
- package/build/ts/common/accountAbstraction.js.map +1 -0
- package/build/ts/common/chain.d.ts +16 -0
- package/build/ts/common/chain.d.ts.map +1 -0
- package/build/ts/common/chain.js +35 -0
- package/build/ts/common/chain.js.map +1 -0
- package/build/ts/common/errors.d.ts +32 -0
- package/build/ts/common/errors.d.ts.map +1 -0
- package/build/ts/common/errors.js +33 -0
- package/build/ts/common/errors.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 +29 -0
- package/build/ts/common/networks.d.ts.map +1 -0
- package/build/ts/common/networks.js +70 -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 +84 -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 +166 -0
- package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -0
- package/build/ts/deployer/__tests__/utils.d.ts +65 -0
- package/build/ts/deployer/__tests__/utils.d.ts.map +1 -0
- package/build/ts/deployer/__tests__/utils.js +131 -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 +89 -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 +76 -0
- package/build/ts/deployer/deployer.service.d.ts.map +1 -0
- package/build/ts/deployer/deployer.service.js +341 -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 +344 -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 +120 -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/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 +92 -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 +65 -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 +130 -0
- package/build/ts/proof/__tests__/proof.service.test.js.map +1 -0
- package/build/ts/proof/dto.d.ts +75 -0
- package/build/ts/proof/dto.d.ts.map +1 -0
- package/build/ts/proof/dto.js +277 -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 +135 -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 +24 -0
- package/build/ts/proof/proof.module.js.map +1 -0
- package/build/ts/proof/proof.service.d.ts +54 -0
- package/build/ts/proof/proof.service.d.ts.map +1 -0
- package/build/ts/proof/proof.service.js +166 -0
- package/build/ts/proof/proof.service.js.map +1 -0
- package/build/ts/proof/types.d.ts +148 -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/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 +61 -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 +64 -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 +61 -0
- package/build/ts/sessionKeys/sessionKeys.service.d.ts.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.service.js +122 -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 +66 -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 +20 -0
- package/build/ts/subgraph/subgraph.service.d.ts.map +1 -0
- package/build/ts/subgraph/subgraph.service.js +106 -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 +125 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../../../ts/sessionKeys/dto.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;GAEG;AACH,qBAAa,uBAAuB;IAClC;;OAEG;IAMH,iBAAiB,EAAG,GAAG,CAAC;CACzB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { ApiProperty } from "@nestjs/swagger";
|
|
11
|
+
import { IsEthereumAddress } from "class-validator";
|
|
12
|
+
/**
|
|
13
|
+
* Data transfer object for Deactivate session key
|
|
14
|
+
*/
|
|
15
|
+
export class DeactivateSessionKeyDto {
|
|
16
|
+
/**
|
|
17
|
+
* Session key address
|
|
18
|
+
*/
|
|
19
|
+
sessionKeyAddress;
|
|
20
|
+
}
|
|
21
|
+
__decorate([
|
|
22
|
+
ApiProperty({
|
|
23
|
+
description: "Session key address",
|
|
24
|
+
type: String,
|
|
25
|
+
}),
|
|
26
|
+
IsEthereumAddress(),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], DeactivateSessionKeyDto.prototype, "sessionKeyAddress", void 0);
|
|
29
|
+
//# sourceMappingURL=dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.js","sourceRoot":"","sources":["../../../ts/sessionKeys/dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIpD;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAClC;;OAEG;IAMH,iBAAiB,CAAO;CACzB;AADC;IALC,WAAW,CAAC;QACX,WAAW,EAAE,qBAAqB;QAClC,IAAI,EAAE,MAAM;KACb,CAAC;IACD,iBAAiB,EAAE;;kEACI"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { KernelAccountClient } from "@zerodev/sdk";
|
|
2
|
+
import { encodeFunctionData } from "viem";
|
|
3
|
+
import { EventEmitter } from "events";
|
|
4
|
+
import type { EIP1193Parameters, EIP1193RequestFn, Hex } from "viem";
|
|
5
|
+
export declare const SafeCreateCallAbi: readonly [{
|
|
6
|
+
readonly name: "performCreate";
|
|
7
|
+
readonly type: "function";
|
|
8
|
+
readonly stateMutability: "nonpayable";
|
|
9
|
+
readonly inputs: readonly [{
|
|
10
|
+
readonly type: "uint256";
|
|
11
|
+
readonly name: "value";
|
|
12
|
+
}, {
|
|
13
|
+
readonly type: "bytes";
|
|
14
|
+
readonly name: "deploymentData";
|
|
15
|
+
}];
|
|
16
|
+
readonly outputs: readonly [{
|
|
17
|
+
readonly type: "address";
|
|
18
|
+
readonly name: "newContract";
|
|
19
|
+
}];
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: "performCreate2";
|
|
22
|
+
readonly type: "function";
|
|
23
|
+
readonly stateMutability: "nonpayable";
|
|
24
|
+
readonly inputs: readonly [{
|
|
25
|
+
readonly type: "uint256";
|
|
26
|
+
readonly name: "value";
|
|
27
|
+
}, {
|
|
28
|
+
readonly type: "bytes";
|
|
29
|
+
readonly name: "deploymentData";
|
|
30
|
+
}, {
|
|
31
|
+
readonly type: "bytes32";
|
|
32
|
+
readonly name: "salt";
|
|
33
|
+
}];
|
|
34
|
+
readonly outputs: readonly [{
|
|
35
|
+
readonly type: "address";
|
|
36
|
+
readonly name: "newContract";
|
|
37
|
+
}];
|
|
38
|
+
}];
|
|
39
|
+
type EncodeExecuteDelegateCallArgs = Parameters<typeof encodeFunctionData<typeof SafeCreateCallAbi, "performCreate">>[0]["args"];
|
|
40
|
+
export declare const encodeSafeCreateCall: (args: EncodeExecuteDelegateCallArgs) => Hex;
|
|
41
|
+
export declare class KernelEIP1193Provider extends EventEmitter {
|
|
42
|
+
private kernelClient;
|
|
43
|
+
constructor(kernelClient: KernelAccountClient);
|
|
44
|
+
request({ method, params }: EIP1193Parameters): ReturnType<EIP1193RequestFn>;
|
|
45
|
+
private handleEthRequestAccounts;
|
|
46
|
+
private handleEthAccounts;
|
|
47
|
+
private handleEthSendTransaction;
|
|
48
|
+
private handleEthSign;
|
|
49
|
+
private handlePersonalSign;
|
|
50
|
+
private handleEthSignTypedDataV4;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=KernelEIP1193Provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KernelEIP1193Provider.d.ts","sourceRoot":"","sources":["../../../../ts/sessionKeys/provider/KernelEIP1193Provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAY,MAAM,MAAM,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAQ,GAAG,EAA8C,MAAM,MAAM,CAAC;AAEvH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG5B,CAAC;AAEH,KAAK,6BAA6B,GAAG,UAAU,CAC7C,OAAO,kBAAkB,CAAC,OAAO,iBAAiB,EAAE,eAAe,CAAC,CACrE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEb,eAAO,MAAM,oBAAoB,GAAI,MAAM,6BAA6B,KAAG,GAKvE,CAAC;AAEL,qBAAa,qBAAsB,SAAQ,YAAY;IACrD,OAAO,CAAC,YAAY,CAAsB;gBAE9B,YAAY,EAAE,mBAAmB;IAKvC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAW,EAAE,EAAE,iBAAiB,GAAG,UAAU,CAAC,gBAAgB,CAAC;IAoBvF,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,iBAAiB;YAQX,wBAAwB;YAexB,aAAa;YAiBb,kBAAkB;YAiBlB,wBAAwB;CA0BvC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { safeCreateCallAddress } from "@zerodev/sdk/constants";
|
|
2
|
+
import { encodeFunctionData, parseAbi } from "viem";
|
|
3
|
+
import { EventEmitter } from "events";
|
|
4
|
+
export const SafeCreateCallAbi = parseAbi([
|
|
5
|
+
"function performCreate(uint256 value, bytes memory deploymentData) public returns (address newContract)",
|
|
6
|
+
"function performCreate2(uint256 value, bytes memory deploymentData, bytes32 salt) public returns (address newContract)",
|
|
7
|
+
]);
|
|
8
|
+
export const encodeSafeCreateCall = (args) => encodeFunctionData({
|
|
9
|
+
abi: SafeCreateCallAbi,
|
|
10
|
+
functionName: "performCreate",
|
|
11
|
+
args,
|
|
12
|
+
});
|
|
13
|
+
export class KernelEIP1193Provider extends EventEmitter {
|
|
14
|
+
kernelClient;
|
|
15
|
+
constructor(kernelClient) {
|
|
16
|
+
super();
|
|
17
|
+
this.kernelClient = kernelClient;
|
|
18
|
+
}
|
|
19
|
+
async request({ method, params = [] }) {
|
|
20
|
+
switch (method) {
|
|
21
|
+
case "eth_requestAccounts":
|
|
22
|
+
return this.handleEthRequestAccounts();
|
|
23
|
+
case "eth_accounts":
|
|
24
|
+
return this.handleEthAccounts();
|
|
25
|
+
case "eth_sendTransaction":
|
|
26
|
+
return this.handleEthSendTransaction(params);
|
|
27
|
+
case "eth_sign":
|
|
28
|
+
return this.handleEthSign(params);
|
|
29
|
+
case "personal_sign":
|
|
30
|
+
return this.handlePersonalSign(params);
|
|
31
|
+
case "eth_signTypedData":
|
|
32
|
+
case "eth_signTypedData_v4":
|
|
33
|
+
return this.handleEthSignTypedDataV4(params);
|
|
34
|
+
default:
|
|
35
|
+
return this.kernelClient.transport.request({ method, params });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
handleEthRequestAccounts() {
|
|
39
|
+
if (!this.kernelClient.account) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
return [this.kernelClient.account.address];
|
|
43
|
+
}
|
|
44
|
+
handleEthAccounts() {
|
|
45
|
+
if (!this.kernelClient.account) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return [this.kernelClient.account.address];
|
|
49
|
+
}
|
|
50
|
+
async handleEthSendTransaction(params) {
|
|
51
|
+
const [tx] = params;
|
|
52
|
+
if (!("to" in tx) && tx.data) {
|
|
53
|
+
// contract deployment
|
|
54
|
+
tx.data = encodeSafeCreateCall([0n, tx.data]);
|
|
55
|
+
tx.to = safeCreateCallAddress;
|
|
56
|
+
return this.kernelClient.sendTransaction(tx);
|
|
57
|
+
}
|
|
58
|
+
// eth transaction (function call or eth transfer)
|
|
59
|
+
return this.kernelClient.sendTransaction(tx);
|
|
60
|
+
}
|
|
61
|
+
async handleEthSign(params) {
|
|
62
|
+
if (!this.kernelClient.account) {
|
|
63
|
+
throw new Error("account not connected!");
|
|
64
|
+
}
|
|
65
|
+
const [address, message] = params;
|
|
66
|
+
if (address.toLowerCase() !== this.kernelClient.account.address.toLowerCase()) {
|
|
67
|
+
throw new Error("cannot sign for address that is not the current account");
|
|
68
|
+
}
|
|
69
|
+
return this.kernelClient.signMessage({
|
|
70
|
+
message,
|
|
71
|
+
account: this.kernelClient.account,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async handlePersonalSign(params) {
|
|
75
|
+
if (!this.kernelClient.account) {
|
|
76
|
+
throw new Error("account not connected!");
|
|
77
|
+
}
|
|
78
|
+
const [message, address] = params;
|
|
79
|
+
if (address.toLowerCase() !== this.kernelClient.account.address.toLowerCase()) {
|
|
80
|
+
throw new Error("cannot sign for address that is not the current account");
|
|
81
|
+
}
|
|
82
|
+
return this.kernelClient.signMessage({
|
|
83
|
+
message,
|
|
84
|
+
account: this.kernelClient.account,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async handleEthSignTypedDataV4(params) {
|
|
88
|
+
if (!this.kernelClient.account) {
|
|
89
|
+
throw new Error("account not connected!");
|
|
90
|
+
}
|
|
91
|
+
const [address, typedDataJSON] = params;
|
|
92
|
+
const typedData = JSON.parse(typedDataJSON);
|
|
93
|
+
if (address.toLowerCase() !== this.kernelClient.account.address.toLowerCase()) {
|
|
94
|
+
throw new Error("cannot sign for address that is not the current account");
|
|
95
|
+
}
|
|
96
|
+
return this.kernelClient.signTypedData({
|
|
97
|
+
account: this.kernelClient.account,
|
|
98
|
+
domain: typedData.domain,
|
|
99
|
+
types: typedData.types,
|
|
100
|
+
message: typedData.message,
|
|
101
|
+
primaryType: typedData.primaryType,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=KernelEIP1193Provider.js.map
|
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AI,OAAO,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC;YACrC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO;YAClC,MAAM,EAAE,SAAS,CAAC,MAAM;YACxB,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,WAAW,EAAE,SAAS,CAAC,WAAW;SACnC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IGenerateSessionKeyReturn } from "./types";
|
|
2
|
+
import { DeactivateSessionKeyDto } from "./dto";
|
|
3
|
+
import { SessionKeysService } from "./sessionKeys.service";
|
|
4
|
+
export declare class SessionKeysController {
|
|
5
|
+
private readonly sessionKeysService;
|
|
6
|
+
/**
|
|
7
|
+
* Initialize SessionKeysController
|
|
8
|
+
*
|
|
9
|
+
* @param sessionKeysService - session keys service
|
|
10
|
+
*/
|
|
11
|
+
constructor(sessionKeysService: SessionKeysService);
|
|
12
|
+
/**
|
|
13
|
+
* Generate a session key api method
|
|
14
|
+
*
|
|
15
|
+
* @returns generated session key address
|
|
16
|
+
*/
|
|
17
|
+
generateSessionKey(): Promise<IGenerateSessionKeyReturn>;
|
|
18
|
+
/**
|
|
19
|
+
* Delete a session key api method
|
|
20
|
+
*
|
|
21
|
+
* @param args - delete session key dto
|
|
22
|
+
* @returns deleted session key address
|
|
23
|
+
*/
|
|
24
|
+
deactivateSessionKey(args: DeactivateSessionKeyDto): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=sessionKeys.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionKeys.controller.d.ts","sourceRoot":"","sources":["../../../ts/sessionKeys/sessionKeys.controller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAIzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,qBAIa,qBAAqB;IAMpB,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAL/C;;;;OAIG;gBAC0B,kBAAkB,EAAE,kBAAkB;IAEnE;;;;OAIG;IAKG,kBAAkB,IAAI,OAAO,CAAC,yBAAyB,CAAC;IAI9D;;;;;OAKG;IAMH,oBAAoB,CAAS,IAAI,EAAE,uBAAuB,GAAG,IAAI;CAGlE"}
|
|
@@ -0,0 +1,74 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Body, Controller, Delete, Get, HttpStatus, UseGuards } from "@nestjs/common";
|
|
14
|
+
import { ApiBearerAuth, ApiBody, ApiResponse, ApiTags } from "@nestjs/swagger";
|
|
15
|
+
import { AccountSignatureGuard } from "../auth/AccountSignatureGuard.service";
|
|
16
|
+
import { DeactivateSessionKeyDto } from "./dto";
|
|
17
|
+
import { SessionKeysService } from "./sessionKeys.service";
|
|
18
|
+
let SessionKeysController = class SessionKeysController {
|
|
19
|
+
sessionKeysService;
|
|
20
|
+
/**
|
|
21
|
+
* Initialize SessionKeysController
|
|
22
|
+
*
|
|
23
|
+
* @param sessionKeysService - session keys service
|
|
24
|
+
*/
|
|
25
|
+
constructor(sessionKeysService) {
|
|
26
|
+
this.sessionKeysService = sessionKeysService;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate a session key api method
|
|
30
|
+
*
|
|
31
|
+
* @returns generated session key address
|
|
32
|
+
*/
|
|
33
|
+
async generateSessionKey() {
|
|
34
|
+
return this.sessionKeysService.generateSessionKey();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Delete a session key api method
|
|
38
|
+
*
|
|
39
|
+
* @param args - delete session key dto
|
|
40
|
+
* @returns deleted session key address
|
|
41
|
+
*/
|
|
42
|
+
deactivateSessionKey(args) {
|
|
43
|
+
this.sessionKeysService.deactivateSessionKey(args.sessionKeyAddress);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
__decorate([
|
|
47
|
+
ApiResponse({ status: HttpStatus.OK, description: "The session key was successfully generated" }),
|
|
48
|
+
ApiResponse({ status: HttpStatus.FORBIDDEN, description: "Forbidden" }),
|
|
49
|
+
ApiResponse({ status: HttpStatus.BAD_REQUEST, description: "BadRequest" }),
|
|
50
|
+
Get("generate"),
|
|
51
|
+
__metadata("design:type", Function),
|
|
52
|
+
__metadata("design:paramtypes", []),
|
|
53
|
+
__metadata("design:returntype", Promise)
|
|
54
|
+
], SessionKeysController.prototype, "generateSessionKey", null);
|
|
55
|
+
__decorate([
|
|
56
|
+
ApiBody({ type: DeactivateSessionKeyDto }),
|
|
57
|
+
ApiResponse({ status: HttpStatus.CREATED, description: "The session key was successfully deactivated" }),
|
|
58
|
+
ApiResponse({ status: HttpStatus.FORBIDDEN, description: "Forbidden" }),
|
|
59
|
+
ApiResponse({ status: HttpStatus.BAD_REQUEST, description: "BadRequest" }),
|
|
60
|
+
Delete("delete"),
|
|
61
|
+
__param(0, Body()),
|
|
62
|
+
__metadata("design:type", Function),
|
|
63
|
+
__metadata("design:paramtypes", [DeactivateSessionKeyDto]),
|
|
64
|
+
__metadata("design:returntype", void 0)
|
|
65
|
+
], SessionKeysController.prototype, "deactivateSessionKey", null);
|
|
66
|
+
SessionKeysController = __decorate([
|
|
67
|
+
ApiTags("v1/session-keys"),
|
|
68
|
+
ApiBearerAuth(),
|
|
69
|
+
Controller("v1/session-keys"),
|
|
70
|
+
UseGuards(AccountSignatureGuard),
|
|
71
|
+
__metadata("design:paramtypes", [SessionKeysService])
|
|
72
|
+
], SessionKeysController);
|
|
73
|
+
export { SessionKeysController };
|
|
74
|
+
//# sourceMappingURL=sessionKeys.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionKeys.controller.js","sourceRoot":"","sources":["../../../ts/sessionKeys/sessionKeys.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAMpD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAMH;IAL7B;;;;OAIG;IACH,YAA6B,kBAAsC;QAAtC,uBAAkB,GAAlB,kBAAkB,CAAoB;IAAG,CAAC;IAEvE;;;;OA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.d.ts","sourceRoot":"","sources":["../../../ts/sessionKeys/sessionKeys.module.ts"],"names":[],"mappings":"AAQA,qBAMa,iBAAiB;CAAG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
import { Module } from "@nestjs/common";
|
|
8
|
+
import { CryptoService } from "../crypto/crypto.service";
|
|
9
|
+
import { FileModule } from "../file/file.module";
|
|
10
|
+
import { SessionKeysController } from "./sessionKeys.controller";
|
|
11
|
+
import { SessionKeysService } from "./sessionKeys.service";
|
|
12
|
+
let SessionKeysModule = class SessionKeysModule {
|
|
13
|
+
};
|
|
14
|
+
SessionKeysModule = __decorate([
|
|
15
|
+
Module({
|
|
16
|
+
imports: [FileModule],
|
|
17
|
+
controllers: [SessionKeysController],
|
|
18
|
+
providers: [SessionKeysService, CryptoService],
|
|
19
|
+
exports: [SessionKeysService],
|
|
20
|
+
})
|
|
21
|
+
], SessionKeysModule);
|
|
22
|
+
export { SessionKeysModule };
|
|
23
|
+
//# sourceMappingURL=sessionKeys.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionKeys.module.js","sourceRoot":"","sources":["../../../ts/sessionKeys/sessionKeys.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAQpD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,iBAAiB;IAN7B,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,UAAU,CAAC;QACrB,WAAW,EAAE,CAAC,qBAAqB,CAAC;QACpC,SAAS,EAAE,CAAC,kBAAkB,EAAE,aAAa,CAAC;QAC9C,OAAO,EAAE,CAAC,kBAAkB,CAAC;KAC9B,CAAC;GACW,iBAAiB,CAAG"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
|
+
import type { AASigner } from "@maci-protocol/contracts";
|
|
3
|
+
import type { Hex } from "viem";
|
|
4
|
+
import { ESupportedNetworks, KernelClientType } from "../common";
|
|
5
|
+
import { FileService } from "../file/file.service";
|
|
6
|
+
import { IGenerateSessionKeyReturn } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* SessionKeysService is responsible for generating and managing session keys.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SessionKeysService {
|
|
11
|
+
private readonly fileService;
|
|
12
|
+
/**
|
|
13
|
+
* Logger
|
|
14
|
+
*/
|
|
15
|
+
private readonly logger;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new instance of SessionKeysService
|
|
18
|
+
*
|
|
19
|
+
* @param fileService - file service
|
|
20
|
+
*/
|
|
21
|
+
constructor(fileService: FileService);
|
|
22
|
+
/**
|
|
23
|
+
* Generate a session key
|
|
24
|
+
*
|
|
25
|
+
* @returns session key address
|
|
26
|
+
*/
|
|
27
|
+
generateSessionKey(): Promise<IGenerateSessionKeyReturn>;
|
|
28
|
+
/**
|
|
29
|
+
* Generate a KernelClient from a session key and an approval
|
|
30
|
+
*
|
|
31
|
+
* @param sessionKeyAddress - the address of the session key
|
|
32
|
+
* @param approval - the approval string
|
|
33
|
+
* @param chain - the chain to use
|
|
34
|
+
* @returns a KernelAccountClient
|
|
35
|
+
*/
|
|
36
|
+
generateClientFromSessionKey(sessionKeyAddress: Hex, approval: string, chain: ESupportedNetworks): Promise<KernelClientType>;
|
|
37
|
+
/**
|
|
38
|
+
* Get a signer from a kernel client (that could be generated from a session key)
|
|
39
|
+
*
|
|
40
|
+
* @param kernelClient - kernel client
|
|
41
|
+
* @returns signer
|
|
42
|
+
*/
|
|
43
|
+
getKernelClientSigner(kernelClient: KernelClientType): Promise<AASigner>;
|
|
44
|
+
/**
|
|
45
|
+
* Get a signer that would execute all the contract interactions in the coordinator service.
|
|
46
|
+
* There are particular cases where the AA signer does not work so we default to the normal signer.
|
|
47
|
+
* (e.g. `deployPoll`)
|
|
48
|
+
* @param chain - the chain to use
|
|
49
|
+
* @param sessionKeyAddress - the address of the session key. Defaults to normal signer if not provided
|
|
50
|
+
* @param approval - the approval string. Defaults to normal signer if not provided
|
|
51
|
+
* @returns a signer
|
|
52
|
+
*/
|
|
53
|
+
getCoordinatorSigner(chain: ESupportedNetworks, sessionKeyAddress?: Hex, approval?: string): Promise<AASigner | Signer>;
|
|
54
|
+
/**
|
|
55
|
+
* Deactivate a session key
|
|
56
|
+
*
|
|
57
|
+
* @param sessionKeyAddress - key address
|
|
58
|
+
*/
|
|
59
|
+
deactivateSessionKey(sessionKeyAddress: Hex): void;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=sessionKeys.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionKeys.service.d.ts","sourceRoot":"","sources":["../../../ts/sessionKeys/sessionKeys.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAc,kBAAkB,EAAa,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEpD;;GAEG;AACH,qBACa,kBAAkB;IAWjB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAVxC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;OAIG;gBAC0B,WAAW,EAAE,WAAW;IAIrD;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,yBAAyB,CAAC;IAiB9D;;;;;;;OAOG;IACG,4BAA4B,CAChC,iBAAiB,EAAE,GAAG,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,gBAAgB,CAAC;IAkB5B;;;;;OAKG;IACG,qBAAqB,CAAC,YAAY,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAU9E;;;;;;;;OAQG;IACG,oBAAoB,CACxB,KAAK,EAAE,kBAAkB,EACzB,iBAAiB,CAAC,EAAE,GAAG,EACvB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC;IAS7B;;;;OAIG;IACH,oBAAoB,CAAC,iBAAiB,EAAE,GAAG,GAAG,IAAI;CAGnD"}
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
const kernelClient = getKernelClient(sessionKey, approval, chain);
|
|
71
|
+
return kernelClient;
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
this.logger.error("Error:", error);
|
|
75
|
+
throw new Error(ErrorCodes.INVALID_APPROVAL.toString());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get a signer from a kernel client (that could be generated from a session key)
|
|
80
|
+
*
|
|
81
|
+
* @param kernelClient - kernel client
|
|
82
|
+
* @returns signer
|
|
83
|
+
*/
|
|
84
|
+
async getKernelClientSigner(kernelClient) {
|
|
85
|
+
const kernelProvider = new KernelEIP1193Provider(kernelClient);
|
|
86
|
+
const ethersProvider = new BrowserProvider(kernelProvider);
|
|
87
|
+
const signer = await ethersProvider.getSigner();
|
|
88
|
+
const aaSigner = signer;
|
|
89
|
+
aaSigner.isAA = true;
|
|
90
|
+
return aaSigner;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get a signer that would execute all the contract interactions in the coordinator service.
|
|
94
|
+
* There are particular cases where the AA signer does not work so we default to the normal signer.
|
|
95
|
+
* (e.g. `deployPoll`)
|
|
96
|
+
* @param chain - the chain to use
|
|
97
|
+
* @param sessionKeyAddress - the address of the session key. Defaults to normal signer if not provided
|
|
98
|
+
* @param approval - the approval string. Defaults to normal signer if not provided
|
|
99
|
+
* @returns a signer
|
|
100
|
+
*/
|
|
101
|
+
async getCoordinatorSigner(chain, sessionKeyAddress, approval) {
|
|
102
|
+
if (sessionKeyAddress && approval) {
|
|
103
|
+
const kernelClient = await this.generateClientFromSessionKey(sessionKeyAddress, approval, chain);
|
|
104
|
+
return this.getKernelClientSigner(kernelClient);
|
|
105
|
+
}
|
|
106
|
+
return getSigner(chain);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Deactivate a session key
|
|
110
|
+
*
|
|
111
|
+
* @param sessionKeyAddress - key address
|
|
112
|
+
*/
|
|
113
|
+
deactivateSessionKey(sessionKeyAddress) {
|
|
114
|
+
this.fileService.deleteSessionKey(sessionKeyAddress);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
SessionKeysService = SessionKeysService_1 = __decorate([
|
|
118
|
+
Injectable(),
|
|
119
|
+
__metadata("design:paramtypes", [FileService])
|
|
120
|
+
], SessionKeysService);
|
|
121
|
+
export { SessionKeysService };
|
|
122
|
+
//# sourceMappingURL=sessionKeys.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionKeys.service.js","sourceRoot":"","sources":["../../../ts/sessionKeys/sessionKeys.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAU,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MA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CAAA;AAjHY,kBAAkB;IAD9B,UAAU,EAAE;qCAY+B,WAAW;GAX1C,kBAAkB,CAiH9B"}
|
|
@@ -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 { HttpException, HttpStatus } from "@nestjs/common";
|
|
2
|
+
import { Test } from "@nestjs/testing";
|
|
3
|
+
import { ESupportedNetworks } from "../../common";
|
|
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: ESupportedNetworks.OPTIMISM_SEPOLIA,
|
|
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.BAD_REQUEST));
|
|
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"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAIvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,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