@zerodev/sdk 5.2.0-alpha-0 → 5.2.0-alpha-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/_cjs/accounts/index.js +9 -2
- package/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/kernel/abi/EIP1271Abi.js +37 -0
- package/_cjs/accounts/kernel/abi/EIP1271Abi.js.map +1 -0
- package/_cjs/accounts/kernel/abi/SafeCreateCallAbi.js +9 -0
- package/_cjs/accounts/kernel/abi/SafeCreateCallAbi.js.map +1 -0
- package/_cjs/accounts/kernel/createKernelAccount.js +123 -360
- package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_cjs/accounts/kernel/utils/account/ep0_6/encodeCallData.js +26 -0
- package/_cjs/accounts/kernel/utils/account/ep0_6/encodeCallData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.js +16 -0
- package/_cjs/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/account/ep0_7/encodeCallData.js +30 -0
- package/_cjs/accounts/kernel/utils/account/ep0_7/encodeCallData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.js +18 -0
- package/_cjs/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/common/accountMetadata.js +46 -0
- package/_cjs/accounts/kernel/utils/common/accountMetadata.js.map +1 -0
- package/_cjs/accounts/kernel/utils/common/eip712WrapHash.js +28 -0
- package/_cjs/accounts/kernel/utils/common/eip712WrapHash.js.map +1 -0
- package/_cjs/accounts/kernel/utils/common/encodeSafeCreateCall.js +14 -0
- package/_cjs/accounts/kernel/utils/common/encodeSafeCreateCall.js.map +1 -0
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js +22 -0
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js.map +1 -0
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js +14 -0
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js.map +1 -0
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js +14 -0
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js.map +1 -0
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js +42 -0
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js.map +1 -0
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteCall.js +29 -0
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteCall.js.map +1 -0
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteDelegateCall.js +13 -0
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteDelegateCall.js.map +1 -0
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteSingleCall.js +13 -0
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteSingleCall.js.map +1 -0
- package/_cjs/accounts/kernel/utils/ep0_7/hashKernelSignatureWrapper.js +9 -0
- package/_cjs/accounts/kernel/utils/ep0_7/hashKernelSignatureWrapper.js.map +1 -0
- package/_cjs/accounts/kernel/utils/types.js +3 -0
- package/_cjs/accounts/kernel/utils/types.js.map +1 -0
- package/_cjs/accounts/kernel/v1/createKernelV1Account.js +1 -2
- package/_cjs/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
- package/_cjs/accounts/kernel/v2/abi/KernelAccountV2Abi.js +377 -0
- package/_cjs/accounts/kernel/v2/abi/KernelAccountV2Abi.js.map +1 -0
- package/_cjs/accounts/kernel/v2/abi/KernelFactoryV2Abi.js +115 -0
- package/_cjs/accounts/kernel/v2/abi/KernelFactoryV2Abi.js.map +1 -0
- package/_cjs/accounts/kernel/v2/createKernelV2Account.js +226 -0
- package/_cjs/accounts/kernel/v2/createKernelV2Account.js.map +1 -0
- package/_cjs/accounts/utils/multisend.js.map +1 -0
- package/_cjs/accounts/utils/toKernelPluginManager.js +4 -4
- package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_cjs/constants.js +2 -1
- package/_cjs/constants.js.map +1 -1
- package/_cjs/index.js +3 -2
- package/_cjs/index.js.map +1 -1
- package/_cjs/types/kernel.js.map +1 -1
- package/_cjs/utils.js +1 -1
- package/_cjs/utils.js.map +1 -1
- package/_esm/accounts/index.js +5 -1
- package/_esm/accounts/index.js.map +1 -1
- package/_esm/accounts/kernel/abi/EIP1271Abi.js +34 -0
- package/_esm/accounts/kernel/abi/EIP1271Abi.js.map +1 -0
- package/_esm/accounts/kernel/abi/SafeCreateCallAbi.js +6 -0
- package/_esm/accounts/kernel/abi/SafeCreateCallAbi.js.map +1 -0
- package/_esm/accounts/kernel/createKernelAccount.js +136 -380
- package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_esm/accounts/kernel/utils/account/ep0_6/encodeCallData.js +23 -0
- package/_esm/accounts/kernel/utils/account/ep0_6/encodeCallData.js.map +1 -0
- package/_esm/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.js +13 -0
- package/_esm/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.js.map +1 -0
- package/_esm/accounts/kernel/utils/account/ep0_7/encodeCallData.js +28 -0
- package/_esm/accounts/kernel/utils/account/ep0_7/encodeCallData.js.map +1 -0
- package/_esm/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.js +15 -0
- package/_esm/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.js.map +1 -0
- package/_esm/accounts/kernel/utils/common/accountMetadata.js +42 -0
- package/_esm/accounts/kernel/utils/common/accountMetadata.js.map +1 -0
- package/_esm/accounts/kernel/utils/common/eip712WrapHash.js +24 -0
- package/_esm/accounts/kernel/utils/common/eip712WrapHash.js.map +1 -0
- package/_esm/accounts/kernel/utils/common/encodeSafeCreateCall.js +10 -0
- package/_esm/accounts/kernel/utils/common/encodeSafeCreateCall.js.map +1 -0
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js +18 -0
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js.map +1 -0
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js +10 -0
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js.map +1 -0
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js +10 -0
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js.map +1 -0
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js +38 -0
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js.map +1 -0
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteCall.js +25 -0
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteCall.js.map +1 -0
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteDelegateCall.js +9 -0
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteDelegateCall.js.map +1 -0
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteSingleCall.js +9 -0
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteSingleCall.js.map +1 -0
- package/_esm/accounts/kernel/utils/ep0_7/hashKernelSignatureWrapper.js +5 -0
- package/_esm/accounts/kernel/utils/ep0_7/hashKernelSignatureWrapper.js.map +1 -0
- package/_esm/accounts/kernel/utils/types.js +2 -0
- package/_esm/accounts/kernel/utils/types.js.map +1 -0
- package/_esm/accounts/kernel/v1/createKernelV1Account.js +1 -2
- package/_esm/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
- package/_esm/accounts/kernel/v2/abi/KernelAccountV2Abi.js +374 -0
- package/_esm/accounts/kernel/v2/abi/KernelAccountV2Abi.js.map +1 -0
- package/_esm/accounts/kernel/v2/abi/KernelFactoryV2Abi.js +112 -0
- package/_esm/accounts/kernel/v2/abi/KernelFactoryV2Abi.js.map +1 -0
- package/_esm/accounts/kernel/v2/createKernelV2Account.js +264 -0
- package/_esm/accounts/kernel/v2/createKernelV2Account.js.map +1 -0
- package/_esm/accounts/{kernel/v1 → utils}/multisend.js +1 -1
- package/_esm/accounts/utils/multisend.js.map +1 -0
- package/_esm/accounts/utils/toKernelPluginManager.js +4 -4
- package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_esm/constants.js +3 -0
- package/_esm/constants.js.map +1 -1
- package/_esm/index.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/types/kernel.js.map +1 -1
- package/_esm/utils.js +1 -1
- package/_esm/utils.js.map +1 -1
- package/_types/accounts/index.d.ts +5 -1
- package/_types/accounts/index.d.ts.map +1 -1
- package/_types/accounts/kernel/abi/EIP1271Abi.d.ts +54 -0
- package/_types/accounts/kernel/abi/EIP1271Abi.d.ts.map +1 -0
- package/_types/accounts/kernel/abi/SafeCreateCallAbi.d.ts +35 -0
- package/_types/accounts/kernel/abi/SafeCreateCallAbi.d.ts.map +1 -0
- package/_types/accounts/kernel/createKernelAccount.d.ts +0 -54
- package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/account/ep0_6/encodeCallData.d.ts +4 -0
- package/_types/accounts/kernel/utils/account/ep0_6/encodeCallData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.d.ts +3 -0
- package/_types/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/account/ep0_7/encodeCallData.d.ts +4 -0
- package/_types/accounts/kernel/utils/account/ep0_7/encodeCallData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.d.ts +3 -0
- package/_types/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/common/accountMetadata.d.ts +10 -0
- package/_types/accounts/kernel/utils/common/accountMetadata.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/common/eip712WrapHash.d.ts +4 -0
- package/_types/accounts/kernel/utils/common/eip712WrapHash.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/common/encodeSafeCreateCall.d.ts +2 -0
- package/_types/accounts/kernel/utils/common/encodeSafeCreateCall.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.d.ts +3 -0
- package/_types/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.d.ts +3 -0
- package/_types/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.d.ts +3 -0
- package/_types/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.d.ts +4 -0
- package/_types/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/ep0_7/encodeExecuteCall.d.ts +16 -0
- package/_types/accounts/kernel/utils/ep0_7/encodeExecuteCall.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/ep0_7/encodeExecuteDelegateCall.d.ts +4 -0
- package/_types/accounts/kernel/utils/ep0_7/encodeExecuteDelegateCall.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/ep0_7/encodeExecuteSingleCall.d.ts +4 -0
- package/_types/accounts/kernel/utils/ep0_7/encodeExecuteSingleCall.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/ep0_7/hashKernelSignatureWrapper.d.ts +3 -0
- package/_types/accounts/kernel/utils/ep0_7/hashKernelSignatureWrapper.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/types.d.ts +8 -0
- package/_types/accounts/kernel/utils/types.d.ts.map +1 -0
- package/_types/accounts/kernel/v1/createKernelV1Account.d.ts.map +1 -1
- package/_types/accounts/kernel/v2/abi/KernelAccountV2Abi.d.ts +447 -0
- package/_types/accounts/kernel/v2/abi/KernelAccountV2Abi.d.ts.map +1 -0
- package/_types/accounts/kernel/v2/abi/KernelFactoryV2Abi.d.ts +109 -0
- package/_types/accounts/kernel/v2/abi/KernelFactoryV2Abi.d.ts.map +1 -0
- package/_types/accounts/kernel/v2/createKernelV2Account.d.ts +33 -0
- package/_types/accounts/kernel/v2/createKernelV2Account.d.ts.map +1 -0
- package/_types/accounts/{kernel/v1 → utils}/multisend.d.ts +1 -1
- package/_types/accounts/utils/multisend.d.ts.map +1 -0
- package/_types/accounts/utils/toKernelPluginManager.d.ts +1 -1
- package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
- package/_types/constants.d.ts +1 -0
- package/_types/constants.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/types/index.d.ts +1 -0
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/kernel.d.ts +1 -0
- package/_types/types/kernel.d.ts.map +1 -1
- package/_types/utils.d.ts +4 -1
- package/_types/utils.d.ts.map +1 -1
- package/accounts/index.ts +5 -2
- package/accounts/kernel/abi/EIP1271Abi.ts +33 -0
- package/accounts/kernel/abi/SafeCreateCallAbi.ts +6 -0
- package/accounts/kernel/createKernelAccount.ts +164 -511
- package/accounts/kernel/utils/account/ep0_6/encodeCallData.ts +32 -0
- package/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.ts +18 -0
- package/accounts/kernel/utils/account/ep0_7/encodeCallData.ts +40 -0
- package/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.ts +20 -0
- package/accounts/kernel/utils/common/accountMetadata.ts +62 -0
- package/accounts/kernel/utils/common/eip712WrapHash.ts +48 -0
- package/accounts/kernel/utils/common/encodeSafeCreateCall.ts +14 -0
- package/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.ts +19 -0
- package/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.ts +11 -0
- package/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.ts +11 -0
- package/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.ts +51 -0
- package/accounts/kernel/utils/ep0_7/encodeExecuteCall.ts +38 -0
- package/accounts/kernel/utils/ep0_7/encodeExecuteDelegateCall.ts +16 -0
- package/accounts/kernel/utils/ep0_7/encodeExecuteSingleCall.ts +16 -0
- package/accounts/kernel/utils/ep0_7/hashKernelSignatureWrapper.ts +11 -0
- package/accounts/kernel/utils/types.ts +8 -0
- package/accounts/kernel/v1/createKernelV1Account.ts +2 -3
- package/accounts/kernel/v2/abi/KernelAccountV2Abi.ts +373 -0
- package/accounts/kernel/v2/abi/KernelFactoryV2Abi.ts +111 -0
- package/accounts/kernel/v2/createKernelV2Account.ts +409 -0
- package/accounts/{kernel/v1 → utils}/multisend.ts +1 -1
- package/accounts/utils/toKernelPluginManager.ts +6 -7
- package/constants.ts +5 -0
- package/index.ts +2 -1
- package/package.json +1 -1
- package/types/index.ts +2 -0
- package/types/kernel.ts +1 -0
- package/utils.ts +7 -1
- package/_cjs/accounts/kernel/v1/multisend.js.map +0 -1
- package/_esm/accounts/kernel/v1/multisend.js.map +0 -1
- package/_types/accounts/kernel/v1/multisend.d.ts.map +0 -1
- /package/_cjs/accounts/{kernel/v1 → utils}/multisend.js +0 -0
package/README.md
ADDED
package/_cjs/accounts/index.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addressToEmptyAccount = exports.
|
|
3
|
+
exports.addressToEmptyAccount = exports.EIP1271Abi = exports.KernelFactoryV2Abi = exports.KernelAccountV2Abi = exports.createKernelV2Account = exports.createKernelV1Account = exports.KERNEL_ADDRESSES = exports.createKernelAccount = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var createKernelAccount_js_1 = require("./kernel/createKernelAccount.js");
|
|
6
6
|
Object.defineProperty(exports, "createKernelAccount", { enumerable: true, get: function () { return createKernelAccount_js_1.createKernelAccount; } });
|
|
7
7
|
Object.defineProperty(exports, "KERNEL_ADDRESSES", { enumerable: true, get: function () { return createKernelAccount_js_1.KERNEL_ADDRESSES; } });
|
|
8
|
-
Object.defineProperty(exports, "EIP1271ABI", { enumerable: true, get: function () { return createKernelAccount_js_1.EIP1271ABI; } });
|
|
9
8
|
var createKernelV1Account_js_1 = require("./kernel/v1/createKernelV1Account.js");
|
|
10
9
|
Object.defineProperty(exports, "createKernelV1Account", { enumerable: true, get: function () { return createKernelV1Account_js_1.createKernelV1Account; } });
|
|
10
|
+
var createKernelV2Account_js_1 = require("./kernel/v2/createKernelV2Account.js");
|
|
11
|
+
Object.defineProperty(exports, "createKernelV2Account", { enumerable: true, get: function () { return createKernelV2Account_js_1.createKernelV2Account; } });
|
|
12
|
+
var KernelAccountV2Abi_js_1 = require("./kernel/v2/abi/KernelAccountV2Abi.js");
|
|
13
|
+
Object.defineProperty(exports, "KernelAccountV2Abi", { enumerable: true, get: function () { return KernelAccountV2Abi_js_1.KernelAccountV2Abi; } });
|
|
14
|
+
var KernelFactoryV2Abi_js_1 = require("./kernel/v2/abi/KernelFactoryV2Abi.js");
|
|
15
|
+
Object.defineProperty(exports, "KernelFactoryV2Abi", { enumerable: true, get: function () { return KernelFactoryV2Abi_js_1.KernelFactoryV2Abi; } });
|
|
16
|
+
var EIP1271Abi_js_1 = require("./kernel/abi/EIP1271Abi.js");
|
|
17
|
+
Object.defineProperty(exports, "EIP1271Abi", { enumerable: true, get: function () { return EIP1271Abi_js_1.EIP1271Abi; } });
|
|
11
18
|
var addressToEmptyAccount_js_1 = require("./addressToEmptyAccount.js");
|
|
12
19
|
Object.defineProperty(exports, "addressToEmptyAccount", { enumerable: true, get: function () { return addressToEmptyAccount_js_1.addressToEmptyAccount; } });
|
|
13
20
|
tslib_1.__exportStar(require("./utils/index.js"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":";;;;AAAA,0EAIwC;AAHpC,6HAAA,mBAAmB,OAAA;AAEnB,0HAAA,gBAAgB,OAAA;AAEpB,iFAA4E;AAAnE,iIAAA,qBAAqB,OAAA;AAC9B,iFAA4E;AAAnE,iIAAA,qBAAqB,OAAA;AAC9B,+EAA0E;AAAjE,2HAAA,kBAAkB,OAAA;AAC3B,+EAA0E;AAAjE,2HAAA,kBAAkB,OAAA;AAC3B,4DAAuD;AAA9C,2GAAA,UAAU,OAAA;AACnB,uEAAkE;AAAzD,iIAAA,qBAAqB,OAAA;AAC9B,2DAAgC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EIP1271Abi = void 0;
|
|
4
|
+
exports.EIP1271Abi = [
|
|
5
|
+
{
|
|
6
|
+
type: "function",
|
|
7
|
+
name: "eip712Domain",
|
|
8
|
+
inputs: [],
|
|
9
|
+
outputs: [
|
|
10
|
+
{ name: "fields", type: "bytes1", internalType: "bytes1" },
|
|
11
|
+
{ name: "name", type: "string", internalType: "string" },
|
|
12
|
+
{ name: "version", type: "string", internalType: "string" },
|
|
13
|
+
{ name: "chainId", type: "uint256", internalType: "uint256" },
|
|
14
|
+
{
|
|
15
|
+
name: "verifyingContract",
|
|
16
|
+
type: "address",
|
|
17
|
+
internalType: "address"
|
|
18
|
+
},
|
|
19
|
+
{ name: "salt", type: "bytes32", internalType: "bytes32" },
|
|
20
|
+
{ name: "extensions", type: "uint256[]", internalType: "uint256[]" }
|
|
21
|
+
],
|
|
22
|
+
stateMutability: "view"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: "function",
|
|
26
|
+
name: "isValidSignature",
|
|
27
|
+
inputs: [
|
|
28
|
+
{ name: "data", type: "bytes32", internalType: "bytes32" },
|
|
29
|
+
{ name: "signature", type: "bytes", internalType: "bytes" }
|
|
30
|
+
],
|
|
31
|
+
outputs: [
|
|
32
|
+
{ name: "magicValue", type: "bytes4", internalType: "bytes4" }
|
|
33
|
+
],
|
|
34
|
+
stateMutability: "view"
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
//# sourceMappingURL=EIP1271Abi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EIP1271Abi.js","sourceRoot":"","sources":["../../../../accounts/kernel/abi/EIP1271Abi.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IACtB;QACI,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,EAAE;QACV,OAAO,EAAE;YACL,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE;YAC1D,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE;YACxD,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE;YAC3D,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;YAC7D;gBACI,IAAI,EAAE,mBAAmB;gBACzB,IAAI,EAAE,SAAS;gBACf,YAAY,EAAE,SAAS;aAC1B;YACD,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;YAC1D,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE;SACvE;QACD,eAAe,EAAE,MAAM;KAC1B;IACD;QACI,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE;YACJ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;YAC1D,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE;SAC9D;QACD,OAAO,EAAE;YACL,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE;SACjE;QACD,eAAe,EAAE,MAAM;KAC1B;CACK,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SafeCreateCallAbi = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
exports.SafeCreateCallAbi = (0, viem_1.parseAbi)([
|
|
6
|
+
"function performCreate(uint256 value, bytes memory deploymentData) public returns (address newContract)",
|
|
7
|
+
"function performCreate2(uint256 value, bytes memory deploymentData, bytes32 salt) public returns (address newContract)"
|
|
8
|
+
]);
|
|
9
|
+
//# sourceMappingURL=SafeCreateCallAbi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SafeCreateCallAbi.js","sourceRoot":"","sources":["../../../../accounts/kernel/abi/SafeCreateCallAbi.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAElB,QAAA,iBAAiB,GAAG,IAAA,eAAQ,EAAC;IACtC,yGAAyG;IACzG,wHAAwH;CAC3H,CAAC,CAAA"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createKernelAccount = exports.KERNEL_ADDRESSES =
|
|
3
|
+
exports.createKernelAccount = exports.KERNEL_ADDRESSES = void 0;
|
|
4
4
|
const permissionless_1 = require("permissionless");
|
|
5
5
|
const accounts_1 = require("permissionless/accounts");
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
|
-
const accounts_2 = require("viem/accounts");
|
|
8
|
-
const constants_js_1 = require("../../constants.js");
|
|
9
7
|
const utils_js_1 = require("../../utils.js");
|
|
10
|
-
const _6492_js_1 = require("../utils/6492.js");
|
|
11
8
|
const index_js_1 = require("../utils/index.js");
|
|
12
9
|
const toKernelPluginManager_js_1 = require("../utils/toKernelPluginManager.js");
|
|
13
10
|
const KernelAccountAbi_js_1 = require("./abi/KernelAccountAbi.js");
|
|
14
11
|
const KernelAccountAbi_js_2 = require("./abi/kernel_v_3_0_0/KernelAccountAbi.js");
|
|
12
|
+
const encodeCallData_js_1 = require("./utils/account/ep0_6/encodeCallData.js");
|
|
13
|
+
const encodeDeployCallData_js_1 = require("./utils/account/ep0_6/encodeDeployCallData.js");
|
|
14
|
+
const encodeCallData_js_2 = require("./utils/account/ep0_7/encodeCallData.js");
|
|
15
|
+
const encodeDeployCallData_js_2 = require("./utils/account/ep0_7/encodeDeployCallData.js");
|
|
16
|
+
const accountMetadata_js_1 = require("./utils/common/accountMetadata.js");
|
|
17
|
+
const eip712WrapHash_js_1 = require("./utils/common/eip712WrapHash.js");
|
|
15
18
|
const createAccountAbi = [
|
|
16
19
|
{
|
|
17
20
|
inputs: [
|
|
@@ -43,44 +46,6 @@ const createAccountAbi = [
|
|
|
43
46
|
type: "function"
|
|
44
47
|
}
|
|
45
48
|
];
|
|
46
|
-
const createCallAddress = "0x9b35Af71d77eaf8d7e40252370304687390A1A52";
|
|
47
|
-
const createCallAbi = (0, viem_1.parseAbi)([
|
|
48
|
-
"function performCreate(uint256 value, bytes memory deploymentData) public returns (address newContract)",
|
|
49
|
-
"function performCreate2(uint256 value, bytes memory deploymentData, bytes32 salt) public returns (address newContract)"
|
|
50
|
-
]);
|
|
51
|
-
exports.EIP1271ABI = [
|
|
52
|
-
{
|
|
53
|
-
type: "function",
|
|
54
|
-
name: "eip712Domain",
|
|
55
|
-
inputs: [],
|
|
56
|
-
outputs: [
|
|
57
|
-
{ name: "fields", type: "bytes1", internalType: "bytes1" },
|
|
58
|
-
{ name: "name", type: "string", internalType: "string" },
|
|
59
|
-
{ name: "version", type: "string", internalType: "string" },
|
|
60
|
-
{ name: "chainId", type: "uint256", internalType: "uint256" },
|
|
61
|
-
{
|
|
62
|
-
name: "verifyingContract",
|
|
63
|
-
type: "address",
|
|
64
|
-
internalType: "address"
|
|
65
|
-
},
|
|
66
|
-
{ name: "salt", type: "bytes32", internalType: "bytes32" },
|
|
67
|
-
{ name: "extensions", type: "uint256[]", internalType: "uint256[]" }
|
|
68
|
-
],
|
|
69
|
-
stateMutability: "view"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
type: "function",
|
|
73
|
-
name: "isValidSignature",
|
|
74
|
-
inputs: [
|
|
75
|
-
{ name: "data", type: "bytes32", internalType: "bytes32" },
|
|
76
|
-
{ name: "signature", type: "bytes", internalType: "bytes" }
|
|
77
|
-
],
|
|
78
|
-
outputs: [
|
|
79
|
-
{ name: "magicValue", type: "bytes4", internalType: "bytes4" }
|
|
80
|
-
],
|
|
81
|
-
stateMutability: "view"
|
|
82
|
-
}
|
|
83
|
-
];
|
|
84
49
|
exports.KERNEL_ADDRESSES = {
|
|
85
50
|
ACCOUNT_LOGIC_V0_6: "0xd3082872F8B06073A021b4602e022d5A070d7cfC",
|
|
86
51
|
ACCOUNT_LOGIC_V0_7: "0x079D5D8A3275A230AF743cB59c341Ff74B82488D",
|
|
@@ -175,336 +140,134 @@ async function createKernelAccount(client, { plugins, entryPoint: entryPointAddr
|
|
|
175
140
|
if (!accountAddress)
|
|
176
141
|
throw new Error("Account address not found");
|
|
177
142
|
let smartAccountDeployed = await (0, permissionless_1.isSmartAccountDeployed)(client, accountAddress);
|
|
178
|
-
const signHashedMessage = async (messageHash) => {
|
|
179
|
-
const kernelImplAddr = await (0, _6492_js_1.getKernelImplementationAddress)(client, accountAddress);
|
|
180
|
-
const kernelVersion = (0, utils_js_1.getKernelVersion)(entryPointAddress, kernelImplAddr);
|
|
181
|
-
if (!(0, utils_js_1.hasKernelFeature)(utils_js_1.KERNEL_FEATURES.ERC1271_SIG_WRAPPER, kernelVersion)) {
|
|
182
|
-
return kernelPluginManager.signMessage({
|
|
183
|
-
message: {
|
|
184
|
-
raw: messageHash
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
const domain = await client.request({
|
|
189
|
-
method: "eth_call",
|
|
190
|
-
params: [
|
|
191
|
-
{
|
|
192
|
-
to: accountAddress,
|
|
193
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
194
|
-
abi: exports.EIP1271ABI,
|
|
195
|
-
functionName: "eip712Domain"
|
|
196
|
-
})
|
|
197
|
-
},
|
|
198
|
-
"latest"
|
|
199
|
-
]
|
|
200
|
-
});
|
|
201
|
-
let name;
|
|
202
|
-
let version;
|
|
203
|
-
let chainId;
|
|
204
|
-
if (domain !== "0x") {
|
|
205
|
-
const decoded = (0, viem_1.decodeFunctionResult)({
|
|
206
|
-
abi: [...exports.EIP1271ABI],
|
|
207
|
-
functionName: "eip712Domain",
|
|
208
|
-
data: domain
|
|
209
|
-
});
|
|
210
|
-
name = decoded[1];
|
|
211
|
-
version = decoded[2];
|
|
212
|
-
chainId = decoded[3];
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
name = constants_js_1.KERNEL_NAME;
|
|
216
|
-
version = kernelVersion;
|
|
217
|
-
chainId = client.chain
|
|
218
|
-
? BigInt(client.chain.id)
|
|
219
|
-
: BigInt(await client.extend(viem_1.publicActions).getChainId());
|
|
220
|
-
}
|
|
221
|
-
const encoded = (0, viem_1.encodeAbiParameters)([
|
|
222
|
-
{ type: "bytes32" },
|
|
223
|
-
{ type: "bytes32" },
|
|
224
|
-
{ type: "bytes32" },
|
|
225
|
-
{ type: "uint256" },
|
|
226
|
-
{ type: "address" }
|
|
227
|
-
], [
|
|
228
|
-
(0, viem_1.keccak256)((0, viem_1.stringToHex)("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")),
|
|
229
|
-
(0, viem_1.keccak256)((0, viem_1.stringToHex)(name)),
|
|
230
|
-
(0, viem_1.keccak256)((0, viem_1.stringToHex)(version)),
|
|
231
|
-
BigInt(chainId),
|
|
232
|
-
accountAddress
|
|
233
|
-
]);
|
|
234
|
-
const domainSeparator = (0, viem_1.keccak256)(encoded);
|
|
235
|
-
let finalMessageHash = messageHash;
|
|
236
|
-
if ((0, utils_js_1.hasKernelFeature)(utils_js_1.KERNEL_FEATURES.ERC1271_SIG_WRAPPER_WITH_WRAPPED_HASH, kernelVersion)) {
|
|
237
|
-
finalMessageHash = (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "bytes32" }, { type: "bytes32" }], [
|
|
238
|
-
(0, viem_1.keccak256)((0, viem_1.stringToHex)("Kernel(bytes32 hash)")),
|
|
239
|
-
messageHash
|
|
240
|
-
]));
|
|
241
|
-
}
|
|
242
|
-
const digest = (0, viem_1.keccak256)((0, viem_1.concatHex)(["0x1901", domainSeparator, finalMessageHash]));
|
|
243
|
-
return kernelPluginManager.signMessage({
|
|
244
|
-
message: {
|
|
245
|
-
raw: digest
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
};
|
|
249
|
-
const account = (0, accounts_2.toAccount)({
|
|
250
|
-
address: accountAddress,
|
|
251
|
-
async signMessage({ message }) {
|
|
252
|
-
const messageHash = (0, viem_1.hashMessage)(message);
|
|
253
|
-
const [isDeployed, signature] = await Promise.all([
|
|
254
|
-
(0, permissionless_1.isSmartAccountDeployed)(client, accountAddress),
|
|
255
|
-
signHashedMessage(messageHash)
|
|
256
|
-
]);
|
|
257
|
-
const kernelImplAddr = await (0, _6492_js_1.getKernelImplementationAddress)(client, accountAddress);
|
|
258
|
-
const kernelVersion = (0, utils_js_1.getKernelVersion)(entryPointAddress, kernelImplAddr);
|
|
259
|
-
if (!(0, utils_js_1.hasKernelFeature)(utils_js_1.KERNEL_FEATURES.ERC1271_WITH_VALIDATOR, kernelVersion)) {
|
|
260
|
-
return create6492Signature(isDeployed, signature);
|
|
261
|
-
}
|
|
262
|
-
const validatorInitData = await kernelPluginManager.getValidatorInitData();
|
|
263
|
-
return create6492Signature(isDeployed, (0, viem_1.concatHex)([
|
|
264
|
-
(0, viem_1.pad)((0, viem_1.concatHex)(["0x1", validatorInitData.validatorAddress]), {
|
|
265
|
-
size: 21,
|
|
266
|
-
dir: "left"
|
|
267
|
-
}),
|
|
268
|
-
signature
|
|
269
|
-
]));
|
|
270
|
-
},
|
|
271
|
-
async signTransaction(_, __) {
|
|
272
|
-
throw new accounts_1.SignTransactionNotSupportedBySmartAccount();
|
|
273
|
-
},
|
|
274
|
-
async signTypedData(typedData) {
|
|
275
|
-
const kernelImplAddr = await (0, _6492_js_1.getKernelImplementationAddress)(client, accountAddress);
|
|
276
|
-
const kernelVersion = (0, utils_js_1.getKernelVersion)(entryPointAddress, kernelImplAddr);
|
|
277
|
-
const types = {
|
|
278
|
-
EIP712Domain: (0, viem_1.getTypesForEIP712Domain)({
|
|
279
|
-
domain: typedData.domain
|
|
280
|
-
}),
|
|
281
|
-
...typedData.types
|
|
282
|
-
};
|
|
283
|
-
(0, viem_1.validateTypedData)({
|
|
284
|
-
domain: typedData.domain,
|
|
285
|
-
message: typedData.message,
|
|
286
|
-
primaryType: typedData.primaryType,
|
|
287
|
-
types: types
|
|
288
|
-
});
|
|
289
|
-
const typedHash = (0, viem_1.hashTypedData)(typedData);
|
|
290
|
-
const [isDeployed, signature] = await Promise.all([
|
|
291
|
-
(0, permissionless_1.isSmartAccountDeployed)(client, accountAddress),
|
|
292
|
-
signHashedMessage(typedHash)
|
|
293
|
-
]);
|
|
294
|
-
if (!(0, utils_js_1.hasKernelFeature)(utils_js_1.KERNEL_FEATURES.ERC1271_WITH_VALIDATOR, kernelVersion)) {
|
|
295
|
-
return create6492Signature(isDeployed, signature);
|
|
296
|
-
}
|
|
297
|
-
const validatorInitData = await kernelPluginManager.getValidatorInitData();
|
|
298
|
-
return create6492Signature(isDeployed, (0, viem_1.concatHex)([
|
|
299
|
-
(0, viem_1.pad)((0, viem_1.concatHex)(["0x1", validatorInitData.validatorAddress]), {
|
|
300
|
-
size: 21,
|
|
301
|
-
dir: "left"
|
|
302
|
-
}),
|
|
303
|
-
signature
|
|
304
|
-
]));
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
const create6492Signature = async (isDeployed, signature) => {
|
|
308
|
-
if (isDeployed) {
|
|
309
|
-
return signature;
|
|
310
|
-
}
|
|
311
|
-
const [factoryAddress, factoryCalldata] = (0, index_js_1.parseFactoryAddressAndCallDataFromAccountInitCode)(await generateInitCode());
|
|
312
|
-
return (0, _6492_js_1.wrapSignatureWith6492)({
|
|
313
|
-
factoryAddress,
|
|
314
|
-
factoryCalldata,
|
|
315
|
-
signature
|
|
316
|
-
});
|
|
317
|
-
};
|
|
318
143
|
return {
|
|
319
|
-
...account,
|
|
320
|
-
client: client,
|
|
321
|
-
publicKey: accountAddress,
|
|
322
|
-
entryPoint: entryPointAddress,
|
|
323
|
-
source: "kernelSmartAccount",
|
|
324
144
|
kernelPluginManager,
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return factoryAddress;
|
|
333
|
-
},
|
|
334
|
-
async getFactoryData() {
|
|
335
|
-
if (smartAccountDeployed)
|
|
336
|
-
return undefined;
|
|
337
|
-
smartAccountDeployed = await (0, permissionless_1.isSmartAccountDeployed)(client, accountAddress);
|
|
338
|
-
if (smartAccountDeployed)
|
|
339
|
-
return undefined;
|
|
340
|
-
return (0, index_js_1.parseFactoryAddressAndCallDataFromAccountInitCode)(await generateInitCode())[1];
|
|
341
|
-
},
|
|
342
|
-
async getNonce() {
|
|
343
|
-
const key = await kernelPluginManager.getNonceKey(accountAddress);
|
|
344
|
-
return (0, permissionless_1.getAccountNonce)(client, {
|
|
345
|
-
sender: accountAddress,
|
|
346
|
-
entryPoint: entryPointAddress,
|
|
347
|
-
key
|
|
348
|
-
});
|
|
349
|
-
},
|
|
350
|
-
async signUserOperation(userOperation) {
|
|
351
|
-
return kernelPluginManager.signUserOperation(userOperation);
|
|
352
|
-
},
|
|
353
|
-
async getInitCode() {
|
|
354
|
-
if (smartAccountDeployed)
|
|
355
|
-
return "0x";
|
|
356
|
-
smartAccountDeployed = await (0, permissionless_1.isSmartAccountDeployed)(client, accountAddress);
|
|
357
|
-
if (smartAccountDeployed)
|
|
358
|
-
return "0x";
|
|
359
|
-
return generateInitCode();
|
|
360
|
-
},
|
|
361
|
-
async encodeDeployCallData(_tx) {
|
|
362
|
-
if (entryPointVersion === "v0.6") {
|
|
363
|
-
return (0, viem_1.encodeFunctionData)({
|
|
364
|
-
abi: KernelAccountAbi_js_1.KernelExecuteAbi,
|
|
365
|
-
functionName: "executeDelegateCall",
|
|
366
|
-
args: [
|
|
367
|
-
createCallAddress,
|
|
368
|
-
(0, viem_1.encodeFunctionData)({
|
|
369
|
-
abi: createCallAbi,
|
|
370
|
-
functionName: "performCreate",
|
|
371
|
-
args: [
|
|
372
|
-
0n,
|
|
373
|
-
(0, viem_1.encodeDeployData)({
|
|
374
|
-
abi: _tx.abi,
|
|
375
|
-
bytecode: _tx.bytecode,
|
|
376
|
-
args: _tx.args
|
|
377
|
-
})
|
|
378
|
-
]
|
|
379
|
-
})
|
|
380
|
-
]
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
return (0, viem_1.encodeFunctionData)({
|
|
384
|
-
abi: KernelAccountAbi_js_2.KernelV3ExecuteAbi,
|
|
385
|
-
functionName: "execute",
|
|
386
|
-
args: [
|
|
387
|
-
(0, utils_js_1.getExecMode)(constants_js_1.CALL_TYPE.DELEGATE_CALL, constants_js_1.EXEC_TYPE.DEFAULT),
|
|
388
|
-
(0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)("address to, bytes data"), [
|
|
389
|
-
createCallAddress,
|
|
390
|
-
(0, viem_1.encodeFunctionData)({
|
|
391
|
-
abi: createCallAbi,
|
|
392
|
-
functionName: "performCreate",
|
|
393
|
-
args: [
|
|
394
|
-
0n,
|
|
395
|
-
(0, viem_1.encodeDeployData)({
|
|
396
|
-
abi: _tx.abi,
|
|
397
|
-
bytecode: _tx.bytecode,
|
|
398
|
-
args: _tx.args
|
|
399
|
-
})
|
|
400
|
-
]
|
|
401
|
-
})
|
|
402
|
-
])
|
|
403
|
-
]
|
|
404
|
-
});
|
|
405
|
-
},
|
|
406
|
-
async encodeCallData(_tx) {
|
|
407
|
-
const tx = _tx;
|
|
408
|
-
if (Array.isArray(tx)) {
|
|
145
|
+
...(0, accounts_1.toSmartAccount)({
|
|
146
|
+
address: accountAddress,
|
|
147
|
+
publicKey: accountAddress,
|
|
148
|
+
source: "kernelSmartAccount",
|
|
149
|
+
client,
|
|
150
|
+
entryPoint: entryPointAddress,
|
|
151
|
+
async encodeDeployCallData(_tx) {
|
|
409
152
|
if (entryPointVersion === "v0.6") {
|
|
410
|
-
return (0,
|
|
411
|
-
abi: KernelAccountAbi_js_1.KernelExecuteAbi,
|
|
412
|
-
functionName: "executeBatch",
|
|
413
|
-
args: [
|
|
414
|
-
tx.map((txn) => {
|
|
415
|
-
if (txn.callType === "delegatecall") {
|
|
416
|
-
throw new Error("Cannot batch delegatecall");
|
|
417
|
-
}
|
|
418
|
-
return {
|
|
419
|
-
to: txn.to,
|
|
420
|
-
value: txn.value,
|
|
421
|
-
data: txn.data
|
|
422
|
-
};
|
|
423
|
-
})
|
|
424
|
-
]
|
|
425
|
-
});
|
|
153
|
+
return (0, encodeDeployCallData_js_1.encodeDeployCallData)(_tx);
|
|
426
154
|
}
|
|
427
|
-
return (0,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
name: "executionBatch",
|
|
435
|
-
type: "tuple[]",
|
|
436
|
-
components: [
|
|
437
|
-
{
|
|
438
|
-
name: "target",
|
|
439
|
-
type: "address"
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
name: "value",
|
|
443
|
-
type: "uint256"
|
|
444
|
-
},
|
|
445
|
-
{
|
|
446
|
-
name: "callData",
|
|
447
|
-
type: "bytes"
|
|
448
|
-
}
|
|
449
|
-
]
|
|
450
|
-
}
|
|
451
|
-
], [
|
|
452
|
-
tx.map((txn) => {
|
|
453
|
-
if (txn.callType === "delegatecall") {
|
|
454
|
-
throw new Error("Cannot batch delegatecall");
|
|
455
|
-
}
|
|
456
|
-
return {
|
|
457
|
-
target: txn.to,
|
|
458
|
-
value: txn.value,
|
|
459
|
-
callData: txn.data
|
|
460
|
-
};
|
|
461
|
-
})
|
|
462
|
-
])
|
|
463
|
-
]
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
if (!tx.callType || tx.callType === "call") {
|
|
467
|
-
if (tx.to.toLowerCase() === accountAddress.toLowerCase()) {
|
|
155
|
+
return (0, encodeDeployCallData_js_2.encodeDeployCallData)(_tx);
|
|
156
|
+
},
|
|
157
|
+
async encodeCallData(_tx) {
|
|
158
|
+
const tx = _tx;
|
|
159
|
+
if (!Array.isArray(tx) &&
|
|
160
|
+
tx.callType === "call" &&
|
|
161
|
+
tx.to.toLowerCase() === accountAddress.toLowerCase()) {
|
|
468
162
|
return tx.data;
|
|
469
163
|
}
|
|
470
164
|
if (entryPointVersion === "v0.6") {
|
|
471
|
-
return (0,
|
|
472
|
-
abi: KernelAccountAbi_js_1.KernelExecuteAbi,
|
|
473
|
-
functionName: "execute",
|
|
474
|
-
args: [tx.to, tx.value, tx.data, 0]
|
|
475
|
-
});
|
|
165
|
+
return (0, encodeCallData_js_1.encodeCallData)(tx);
|
|
476
166
|
}
|
|
477
|
-
return (0,
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
167
|
+
return (0, encodeCallData_js_2.encodeCallData)(tx);
|
|
168
|
+
},
|
|
169
|
+
async getFactory() {
|
|
170
|
+
if (smartAccountDeployed)
|
|
171
|
+
return undefined;
|
|
172
|
+
smartAccountDeployed = await (0, permissionless_1.isSmartAccountDeployed)(client, accountAddress);
|
|
173
|
+
if (smartAccountDeployed)
|
|
174
|
+
return undefined;
|
|
175
|
+
return factoryAddress;
|
|
176
|
+
},
|
|
177
|
+
async getFactoryData() {
|
|
178
|
+
if (smartAccountDeployed)
|
|
179
|
+
return undefined;
|
|
180
|
+
smartAccountDeployed = await (0, permissionless_1.isSmartAccountDeployed)(client, accountAddress);
|
|
181
|
+
if (smartAccountDeployed)
|
|
182
|
+
return undefined;
|
|
183
|
+
return (0, index_js_1.parseFactoryAddressAndCallDataFromAccountInitCode)(await generateInitCode())[1];
|
|
184
|
+
},
|
|
185
|
+
async signMessage({ message }) {
|
|
186
|
+
const messageHash = (0, viem_1.hashMessage)(message);
|
|
187
|
+
const { name, chainId, version } = await (0, accountMetadata_js_1.accountMetadata)(client, accountAddress, entryPointAddress);
|
|
188
|
+
const wrappedMessageHash = await (0, eip712WrapHash_js_1.eip712WrapHash)(messageHash, {
|
|
189
|
+
name,
|
|
190
|
+
chainId: Number(chainId),
|
|
191
|
+
version,
|
|
192
|
+
verifyingContract: accountAddress
|
|
484
193
|
});
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
functionName: "executeDelegateCall",
|
|
491
|
-
args: [tx.to, tx.data]
|
|
492
|
-
});
|
|
194
|
+
const signature = await kernelPluginManager.signMessage({
|
|
195
|
+
message: { raw: wrappedMessageHash }
|
|
196
|
+
});
|
|
197
|
+
if (!(0, utils_js_1.hasKernelFeature)(utils_js_1.KERNEL_FEATURES.ERC1271_WITH_VALIDATOR, version)) {
|
|
198
|
+
return signature;
|
|
493
199
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
200
|
+
const validatorInitData = await kernelPluginManager.getValidatorInitData();
|
|
201
|
+
return (0, viem_1.concatHex)([
|
|
202
|
+
(0, viem_1.pad)((0, viem_1.concatHex)(["0x1", validatorInitData.validatorAddress]), {
|
|
203
|
+
size: 21,
|
|
204
|
+
dir: "left"
|
|
205
|
+
}),
|
|
206
|
+
signature
|
|
207
|
+
]);
|
|
208
|
+
},
|
|
209
|
+
async signTransaction(_, __) {
|
|
210
|
+
throw new accounts_1.SignTransactionNotSupportedBySmartAccount();
|
|
211
|
+
},
|
|
212
|
+
async signTypedData(typedData) {
|
|
213
|
+
const types = {
|
|
214
|
+
EIP712Domain: (0, viem_1.getTypesForEIP712Domain)({
|
|
215
|
+
domain: typedData.domain
|
|
216
|
+
}),
|
|
217
|
+
...typedData.types
|
|
218
|
+
};
|
|
219
|
+
(0, viem_1.validateTypedData)({
|
|
220
|
+
domain: typedData.domain,
|
|
221
|
+
message: typedData.message,
|
|
222
|
+
primaryType: typedData.primaryType,
|
|
223
|
+
types: types
|
|
224
|
+
});
|
|
225
|
+
const typedHash = (0, viem_1.hashTypedData)(typedData);
|
|
226
|
+
const { name, chainId, version } = await (0, accountMetadata_js_1.accountMetadata)(client, accountAddress, entryPointAddress);
|
|
227
|
+
const wrappedMessageHash = await (0, eip712WrapHash_js_1.eip712WrapHash)(typedHash, {
|
|
228
|
+
name,
|
|
229
|
+
chainId: Number(chainId),
|
|
230
|
+
version,
|
|
231
|
+
verifyingContract: accountAddress
|
|
501
232
|
});
|
|
233
|
+
const signature = await kernelPluginManager.signMessage({
|
|
234
|
+
message: { raw: wrappedMessageHash }
|
|
235
|
+
});
|
|
236
|
+
if (!(0, utils_js_1.hasKernelFeature)(utils_js_1.KERNEL_FEATURES.ERC1271_WITH_VALIDATOR, version)) {
|
|
237
|
+
return signature;
|
|
238
|
+
}
|
|
239
|
+
const validatorInitData = await kernelPluginManager.getValidatorInitData();
|
|
240
|
+
return (0, viem_1.concatHex)([
|
|
241
|
+
(0, viem_1.pad)((0, viem_1.concatHex)(["0x1", validatorInitData.validatorAddress]), {
|
|
242
|
+
size: 21,
|
|
243
|
+
dir: "left"
|
|
244
|
+
}),
|
|
245
|
+
signature
|
|
246
|
+
]);
|
|
247
|
+
},
|
|
248
|
+
async getNonce() {
|
|
249
|
+
const key = await kernelPluginManager.getNonceKey(accountAddress);
|
|
250
|
+
return (0, permissionless_1.getAccountNonce)(client, {
|
|
251
|
+
sender: accountAddress,
|
|
252
|
+
entryPoint: entryPointAddress,
|
|
253
|
+
key
|
|
254
|
+
});
|
|
255
|
+
},
|
|
256
|
+
async signUserOperation(userOperation) {
|
|
257
|
+
return kernelPluginManager.signUserOperation(userOperation);
|
|
258
|
+
},
|
|
259
|
+
async getDummySignature(userOperation) {
|
|
260
|
+
return kernelPluginManager.getDummySignature(userOperation);
|
|
261
|
+
},
|
|
262
|
+
async getInitCode() {
|
|
263
|
+
if (smartAccountDeployed)
|
|
264
|
+
return "0x";
|
|
265
|
+
smartAccountDeployed = await (0, permissionless_1.isSmartAccountDeployed)(client, accountAddress);
|
|
266
|
+
if (smartAccountDeployed)
|
|
267
|
+
return "0x";
|
|
268
|
+
return generateInitCode();
|
|
502
269
|
}
|
|
503
|
-
|
|
504
|
-
},
|
|
505
|
-
async getDummySignature(userOperation) {
|
|
506
|
-
return kernelPluginManager.getDummySignature(userOperation);
|
|
507
|
-
}
|
|
270
|
+
})
|
|
508
271
|
};
|
|
509
272
|
}
|
|
510
273
|
exports.createKernelAccount = createKernelAccount;
|