@zerodev/sdk 5.2.0-alpha-1 → 5.2.0-alpha-3
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 +124 -378
- 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 +19 -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 +135 -398
- 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 +19 -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 +2 -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 +176 -541
- 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 +21 -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 +2 -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
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
} from "permissionless"
|
|
7
7
|
import {
|
|
8
8
|
SignTransactionNotSupportedBySmartAccount,
|
|
9
|
-
type SmartAccount
|
|
9
|
+
type SmartAccount,
|
|
10
|
+
toSmartAccount
|
|
10
11
|
} from "permissionless/accounts"
|
|
11
12
|
import type {
|
|
12
13
|
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
@@ -17,55 +18,36 @@ import {
|
|
|
17
18
|
type Address,
|
|
18
19
|
type Chain,
|
|
19
20
|
type Client,
|
|
20
|
-
type EncodeDeployDataParameters,
|
|
21
|
-
type Hash,
|
|
22
21
|
type Hex,
|
|
23
22
|
type Transport,
|
|
24
23
|
type TypedDataDefinition,
|
|
25
24
|
concatHex,
|
|
26
|
-
decodeFunctionResult,
|
|
27
|
-
encodeAbiParameters,
|
|
28
|
-
encodeDeployData,
|
|
29
25
|
encodeFunctionData,
|
|
30
26
|
getTypesForEIP712Domain,
|
|
31
27
|
hashMessage,
|
|
32
28
|
hashTypedData,
|
|
33
|
-
keccak256,
|
|
34
|
-
pad,
|
|
35
|
-
parseAbi,
|
|
36
|
-
publicActions,
|
|
37
|
-
stringToHex,
|
|
38
|
-
toHex,
|
|
39
29
|
validateTypedData,
|
|
40
30
|
zeroAddress
|
|
41
31
|
} from "viem"
|
|
42
|
-
import { toAccount } from "viem/accounts"
|
|
43
|
-
import { CALL_TYPE, EXEC_TYPE, KERNEL_NAME } from "../../constants.js"
|
|
44
32
|
import type {
|
|
45
33
|
KernelEncodeCallDataArgs,
|
|
46
34
|
KernelPluginManager,
|
|
47
35
|
KernelPluginManagerParams
|
|
48
36
|
} from "../../types/kernel.js"
|
|
49
|
-
import {
|
|
50
|
-
KERNEL_FEATURES,
|
|
51
|
-
getExecMode,
|
|
52
|
-
getKernelVersion,
|
|
53
|
-
hasKernelFeature
|
|
54
|
-
} from "../../utils.js"
|
|
55
|
-
import {
|
|
56
|
-
getKernelImplementationAddress,
|
|
57
|
-
wrapSignatureWith6492
|
|
58
|
-
} from "../utils/6492.js"
|
|
37
|
+
import { KERNEL_FEATURES, hasKernelFeature } from "../../utils.js"
|
|
59
38
|
import { parseFactoryAddressAndCallDataFromAccountInitCode } from "../utils/index.js"
|
|
60
39
|
import {
|
|
61
40
|
isKernelPluginManager,
|
|
62
41
|
toKernelPluginManager
|
|
63
42
|
} from "../utils/toKernelPluginManager.js"
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
} from "./
|
|
43
|
+
import { KernelInitAbi } from "./abi/KernelAccountAbi.js"
|
|
44
|
+
import { KernelV3InitAbi } from "./abi/kernel_v_3_0_0/KernelAccountAbi.js"
|
|
45
|
+
import { encodeCallData as encodeCallDataEpV06 } from "./utils/account/ep0_6/encodeCallData.js"
|
|
46
|
+
import { encodeDeployCallData as encodeDeployCallDataV06 } from "./utils/account/ep0_6/encodeDeployCallData.js"
|
|
47
|
+
import { encodeCallData as encodeCallDataEpV07 } from "./utils/account/ep0_7/encodeCallData.js"
|
|
48
|
+
import { encodeDeployCallData as encodeDeployCallDataV07 } from "./utils/account/ep0_7/encodeDeployCallData.js"
|
|
49
|
+
import { accountMetadata } from "./utils/common/accountMetadata.js"
|
|
50
|
+
import { eip712WrapHash } from "./utils/common/eip712WrapHash.js"
|
|
69
51
|
|
|
70
52
|
export type KernelSmartAccount<
|
|
71
53
|
entryPoint extends EntryPoint,
|
|
@@ -73,7 +55,6 @@ export type KernelSmartAccount<
|
|
|
73
55
|
chain extends Chain | undefined = Chain | undefined
|
|
74
56
|
> = SmartAccount<entryPoint, "kernelSmartAccount", transport, chain> & {
|
|
75
57
|
kernelPluginManager: KernelPluginManager<entryPoint>
|
|
76
|
-
generateInitCode: () => Promise<Hex>
|
|
77
58
|
encodeCallData: (args: KernelEncodeCallDataArgs) => Promise<Hex>
|
|
78
59
|
}
|
|
79
60
|
|
|
@@ -123,48 +104,6 @@ const createAccountAbi = [
|
|
|
123
104
|
}
|
|
124
105
|
] as const
|
|
125
106
|
|
|
126
|
-
// Safe's library for create and create2: https://github.com/safe-global/safe-contracts/blob/0acdd35a203299585438f53885df630f9d486a86/contracts/libraries/CreateCall.sol
|
|
127
|
-
// Address was found here: https://github.com/safe-global/safe-deployments/blob/926ec6bbe2ebcac3aa2c2c6c0aff74aa590cbc6a/src/assets/v1.4.1/create_call.json
|
|
128
|
-
const createCallAddress = "0x9b35Af71d77eaf8d7e40252370304687390A1A52"
|
|
129
|
-
|
|
130
|
-
const createCallAbi = parseAbi([
|
|
131
|
-
"function performCreate(uint256 value, bytes memory deploymentData) public returns (address newContract)",
|
|
132
|
-
"function performCreate2(uint256 value, bytes memory deploymentData, bytes32 salt) public returns (address newContract)"
|
|
133
|
-
])
|
|
134
|
-
|
|
135
|
-
export const EIP1271ABI = [
|
|
136
|
-
{
|
|
137
|
-
type: "function",
|
|
138
|
-
name: "eip712Domain",
|
|
139
|
-
inputs: [],
|
|
140
|
-
outputs: [
|
|
141
|
-
{ name: "fields", type: "bytes1", internalType: "bytes1" },
|
|
142
|
-
{ name: "name", type: "string", internalType: "string" },
|
|
143
|
-
{ name: "version", type: "string", internalType: "string" },
|
|
144
|
-
{ name: "chainId", type: "uint256", internalType: "uint256" },
|
|
145
|
-
{
|
|
146
|
-
name: "verifyingContract",
|
|
147
|
-
type: "address",
|
|
148
|
-
internalType: "address"
|
|
149
|
-
},
|
|
150
|
-
{ name: "salt", type: "bytes32", internalType: "bytes32" },
|
|
151
|
-
{ name: "extensions", type: "uint256[]", internalType: "uint256[]" }
|
|
152
|
-
],
|
|
153
|
-
stateMutability: "view"
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
type: "function",
|
|
157
|
-
name: "isValidSignature",
|
|
158
|
-
inputs: [
|
|
159
|
-
{ name: "data", type: "bytes32", internalType: "bytes32" },
|
|
160
|
-
{ name: "signature", type: "bytes", internalType: "bytes" }
|
|
161
|
-
],
|
|
162
|
-
outputs: [
|
|
163
|
-
{ name: "magicValue", type: "bytes4", internalType: "bytes4" }
|
|
164
|
-
],
|
|
165
|
-
stateMutability: "view"
|
|
166
|
-
}
|
|
167
|
-
] as const
|
|
168
107
|
/**
|
|
169
108
|
* Default addresses for kernel smart account
|
|
170
109
|
*/
|
|
@@ -180,16 +119,16 @@ export const KERNEL_ADDRESSES: {
|
|
|
180
119
|
ENTRYPOINT_V0_6: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
|
|
181
120
|
}
|
|
182
121
|
|
|
183
|
-
const getKernelInitData = <entryPoint extends EntryPoint>({
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
entryPoint: entryPointAddress
|
|
122
|
+
const getKernelInitData = async <entryPoint extends EntryPoint>({
|
|
123
|
+
entryPoint: entryPointAddress,
|
|
124
|
+
kernelPluginManager
|
|
187
125
|
}: {
|
|
188
|
-
validatorAddress: Address
|
|
189
|
-
enableData: Hex
|
|
190
126
|
entryPoint: entryPoint
|
|
127
|
+
kernelPluginManager: KernelPluginManager<entryPoint>
|
|
191
128
|
}) => {
|
|
192
129
|
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
130
|
+
const { enableData, validatorAddress } =
|
|
131
|
+
await kernelPluginManager.getValidatorInitData()
|
|
193
132
|
|
|
194
133
|
if (entryPointVersion === "v0.6") {
|
|
195
134
|
return encodeFunctionData({
|
|
@@ -203,10 +142,7 @@ const getKernelInitData = <entryPoint extends EntryPoint>({
|
|
|
203
142
|
abi: KernelV3InitAbi,
|
|
204
143
|
functionName: "initialize",
|
|
205
144
|
args: [
|
|
206
|
-
|
|
207
|
-
size: 21,
|
|
208
|
-
dir: "left"
|
|
209
|
-
}),
|
|
145
|
+
kernelPluginManager.getValidationId(true),
|
|
210
146
|
zeroAddress,
|
|
211
147
|
enableData,
|
|
212
148
|
"0x"
|
|
@@ -225,22 +161,19 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
|
|
|
225
161
|
index,
|
|
226
162
|
factoryAddress,
|
|
227
163
|
accountLogicAddress,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
entryPoint: entryPointAddress
|
|
164
|
+
entryPoint: entryPointAddress,
|
|
165
|
+
kernelPluginManager
|
|
231
166
|
}: {
|
|
232
167
|
index: bigint
|
|
233
168
|
factoryAddress: Address
|
|
234
169
|
accountLogicAddress: Address
|
|
235
|
-
validatorAddress: Address
|
|
236
|
-
enableData: Hex
|
|
237
170
|
entryPoint: entryPoint
|
|
171
|
+
kernelPluginManager: KernelPluginManager<entryPoint>
|
|
238
172
|
}): Promise<Hex> => {
|
|
239
173
|
// Build the account initialization data
|
|
240
|
-
const initialisationData = getKernelInitData<entryPoint>({
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
entryPoint: entryPointAddress
|
|
174
|
+
const initialisationData = await getKernelInitData<entryPoint>({
|
|
175
|
+
entryPoint: entryPointAddress,
|
|
176
|
+
kernelPluginManager
|
|
244
177
|
})
|
|
245
178
|
|
|
246
179
|
// Build the account init code
|
|
@@ -336,15 +269,12 @@ export async function createKernelAccount<
|
|
|
336
269
|
})
|
|
337
270
|
// Helper to generate the init code for the smart account
|
|
338
271
|
const generateInitCode = async () => {
|
|
339
|
-
const validatorInitData =
|
|
340
|
-
await kernelPluginManager.getValidatorInitData()
|
|
341
272
|
return getAccountInitCode<entryPoint>({
|
|
342
273
|
index,
|
|
343
274
|
factoryAddress,
|
|
344
275
|
accountLogicAddress,
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
entryPoint: entryPointAddress
|
|
276
|
+
entryPoint: entryPointAddress,
|
|
277
|
+
kernelPluginManager
|
|
348
278
|
})
|
|
349
279
|
}
|
|
350
280
|
|
|
@@ -364,470 +294,175 @@ export async function createKernelAccount<
|
|
|
364
294
|
accountAddress
|
|
365
295
|
)
|
|
366
296
|
|
|
367
|
-
|
|
368
|
-
|
|
297
|
+
return {
|
|
298
|
+
kernelPluginManager,
|
|
299
|
+
...toSmartAccount({
|
|
300
|
+
address: accountAddress,
|
|
301
|
+
publicKey: accountAddress,
|
|
302
|
+
source: "kernelSmartAccount",
|
|
369
303
|
client,
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
)
|
|
376
|
-
if (
|
|
377
|
-
!hasKernelFeature(
|
|
378
|
-
KERNEL_FEATURES.ERC1271_SIG_WRAPPER,
|
|
379
|
-
kernelVersion
|
|
380
|
-
)
|
|
381
|
-
) {
|
|
382
|
-
return kernelPluginManager.signMessage({
|
|
383
|
-
message: {
|
|
384
|
-
raw: messageHash
|
|
304
|
+
entryPoint: entryPointAddress,
|
|
305
|
+
// Encode the deploy call data
|
|
306
|
+
async encodeDeployCallData(_tx) {
|
|
307
|
+
if (entryPointVersion === "v0.6") {
|
|
308
|
+
return encodeDeployCallDataV06(_tx)
|
|
385
309
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
to
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
let version: string
|
|
405
|
-
let chainId: bigint
|
|
406
|
-
|
|
407
|
-
if (domain !== "0x") {
|
|
408
|
-
const decoded = decodeFunctionResult({
|
|
409
|
-
abi: [...EIP1271ABI],
|
|
410
|
-
functionName: "eip712Domain",
|
|
411
|
-
data: domain
|
|
412
|
-
})
|
|
413
|
-
|
|
414
|
-
name = decoded[1]
|
|
415
|
-
version = decoded[2]
|
|
416
|
-
chainId = decoded[3]
|
|
417
|
-
} else {
|
|
418
|
-
name = KERNEL_NAME
|
|
419
|
-
version = kernelVersion
|
|
420
|
-
chainId = client.chain
|
|
421
|
-
? BigInt(client.chain.id)
|
|
422
|
-
: BigInt(await client.extend(publicActions).getChainId())
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
const encoded = encodeAbiParameters(
|
|
426
|
-
[
|
|
427
|
-
{ type: "bytes32" },
|
|
428
|
-
{ type: "bytes32" },
|
|
429
|
-
{ type: "bytes32" },
|
|
430
|
-
{ type: "uint256" },
|
|
431
|
-
{ type: "address" }
|
|
432
|
-
],
|
|
433
|
-
[
|
|
434
|
-
keccak256(
|
|
435
|
-
stringToHex(
|
|
436
|
-
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
|
|
437
|
-
)
|
|
438
|
-
),
|
|
439
|
-
keccak256(stringToHex(name)),
|
|
440
|
-
keccak256(stringToHex(version)),
|
|
441
|
-
BigInt(chainId),
|
|
442
|
-
accountAddress
|
|
443
|
-
]
|
|
444
|
-
)
|
|
445
|
-
|
|
446
|
-
const domainSeparator = keccak256(encoded)
|
|
447
|
-
|
|
448
|
-
let finalMessageHash = messageHash
|
|
449
|
-
if (
|
|
450
|
-
hasKernelFeature(
|
|
451
|
-
KERNEL_FEATURES.ERC1271_SIG_WRAPPER_WITH_WRAPPED_HASH,
|
|
452
|
-
kernelVersion
|
|
453
|
-
)
|
|
454
|
-
) {
|
|
455
|
-
finalMessageHash = keccak256(
|
|
456
|
-
encodeAbiParameters(
|
|
457
|
-
[{ type: "bytes32" }, { type: "bytes32" }],
|
|
458
|
-
[
|
|
459
|
-
keccak256(stringToHex("Kernel(bytes32 hash)")),
|
|
460
|
-
messageHash
|
|
461
|
-
]
|
|
462
|
-
)
|
|
463
|
-
)
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
const digest = keccak256(
|
|
467
|
-
concatHex(["0x1901", domainSeparator, finalMessageHash])
|
|
468
|
-
)
|
|
469
|
-
return kernelPluginManager.signMessage({
|
|
470
|
-
message: {
|
|
471
|
-
raw: digest
|
|
472
|
-
}
|
|
473
|
-
})
|
|
474
|
-
}
|
|
310
|
+
return encodeDeployCallDataV07(_tx)
|
|
311
|
+
},
|
|
312
|
+
async encodeCallData(_tx) {
|
|
313
|
+
const tx = _tx as KernelEncodeCallDataArgs
|
|
314
|
+
if (
|
|
315
|
+
!Array.isArray(tx) &&
|
|
316
|
+
tx.callType === "call" &&
|
|
317
|
+
tx.to.toLowerCase() === accountAddress.toLowerCase()
|
|
318
|
+
) {
|
|
319
|
+
return tx.data
|
|
320
|
+
}
|
|
321
|
+
if (entryPointVersion === "v0.6") {
|
|
322
|
+
return encodeCallDataEpV06(tx)
|
|
323
|
+
}
|
|
324
|
+
return encodeCallDataEpV07(tx)
|
|
325
|
+
},
|
|
326
|
+
async getFactory() {
|
|
327
|
+
if (smartAccountDeployed) return undefined
|
|
475
328
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
async signMessage({ message }) {
|
|
480
|
-
const messageHash = hashMessage(message)
|
|
481
|
-
const [isDeployed, signature] = await Promise.all([
|
|
482
|
-
isSmartAccountDeployed(client, accountAddress),
|
|
483
|
-
signHashedMessage(messageHash)
|
|
484
|
-
])
|
|
485
|
-
const kernelImplAddr = await getKernelImplementationAddress(
|
|
486
|
-
client,
|
|
487
|
-
accountAddress
|
|
488
|
-
)
|
|
489
|
-
const kernelVersion = getKernelVersion(
|
|
490
|
-
entryPointAddress,
|
|
491
|
-
kernelImplAddr
|
|
492
|
-
)
|
|
493
|
-
if (
|
|
494
|
-
!hasKernelFeature(
|
|
495
|
-
KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
|
|
496
|
-
kernelVersion
|
|
329
|
+
smartAccountDeployed = await isSmartAccountDeployed(
|
|
330
|
+
client,
|
|
331
|
+
accountAddress
|
|
497
332
|
)
|
|
498
|
-
) {
|
|
499
|
-
return create6492Signature(isDeployed, signature)
|
|
500
|
-
}
|
|
501
333
|
|
|
502
|
-
|
|
503
|
-
await kernelPluginManager.getValidatorInitData()
|
|
504
|
-
return create6492Signature(
|
|
505
|
-
isDeployed,
|
|
506
|
-
concatHex([
|
|
507
|
-
pad(
|
|
508
|
-
concatHex(["0x1", validatorInitData.validatorAddress]),
|
|
509
|
-
{
|
|
510
|
-
size: 21,
|
|
511
|
-
dir: "left"
|
|
512
|
-
}
|
|
513
|
-
),
|
|
514
|
-
signature
|
|
515
|
-
])
|
|
516
|
-
)
|
|
517
|
-
},
|
|
518
|
-
async signTransaction(_, __) {
|
|
519
|
-
throw new SignTransactionNotSupportedBySmartAccount()
|
|
520
|
-
},
|
|
521
|
-
async signTypedData(typedData) {
|
|
522
|
-
const kernelImplAddr = await getKernelImplementationAddress(
|
|
523
|
-
client,
|
|
524
|
-
accountAddress
|
|
525
|
-
)
|
|
526
|
-
const kernelVersion = getKernelVersion(
|
|
527
|
-
entryPointAddress,
|
|
528
|
-
kernelImplAddr
|
|
529
|
-
)
|
|
530
|
-
const types = {
|
|
531
|
-
EIP712Domain: getTypesForEIP712Domain({
|
|
532
|
-
domain: typedData.domain
|
|
533
|
-
}),
|
|
534
|
-
...typedData.types
|
|
535
|
-
}
|
|
334
|
+
if (smartAccountDeployed) return undefined
|
|
536
335
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
validateTypedData({
|
|
540
|
-
domain: typedData.domain,
|
|
541
|
-
message: typedData.message,
|
|
542
|
-
primaryType: typedData.primaryType,
|
|
543
|
-
types: types
|
|
544
|
-
} as TypedDataDefinition)
|
|
545
|
-
|
|
546
|
-
const typedHash = hashTypedData(typedData)
|
|
547
|
-
const [isDeployed, signature] = await Promise.all([
|
|
548
|
-
isSmartAccountDeployed(client, accountAddress),
|
|
549
|
-
signHashedMessage(typedHash)
|
|
550
|
-
])
|
|
551
|
-
if (
|
|
552
|
-
!hasKernelFeature(
|
|
553
|
-
KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
|
|
554
|
-
kernelVersion
|
|
555
|
-
)
|
|
556
|
-
) {
|
|
557
|
-
return create6492Signature(isDeployed, signature)
|
|
558
|
-
}
|
|
559
|
-
const validatorInitData =
|
|
560
|
-
await kernelPluginManager.getValidatorInitData()
|
|
561
|
-
return create6492Signature(
|
|
562
|
-
isDeployed,
|
|
563
|
-
concatHex([
|
|
564
|
-
pad(
|
|
565
|
-
// [TODO] - Make the Validator type dynamic to support permission validators
|
|
566
|
-
concatHex(["0x1", validatorInitData.validatorAddress]),
|
|
567
|
-
{
|
|
568
|
-
size: 21,
|
|
569
|
-
dir: "left"
|
|
570
|
-
}
|
|
571
|
-
),
|
|
572
|
-
signature
|
|
573
|
-
])
|
|
574
|
-
)
|
|
575
|
-
}
|
|
576
|
-
})
|
|
336
|
+
return factoryAddress
|
|
337
|
+
},
|
|
577
338
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
signature: Hash
|
|
581
|
-
): Promise<Hash> => {
|
|
582
|
-
if (isDeployed) {
|
|
583
|
-
return signature
|
|
584
|
-
}
|
|
339
|
+
async getFactoryData() {
|
|
340
|
+
if (smartAccountDeployed) return undefined
|
|
585
341
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
342
|
+
smartAccountDeployed = await isSmartAccountDeployed(
|
|
343
|
+
client,
|
|
344
|
+
accountAddress
|
|
345
|
+
)
|
|
590
346
|
|
|
591
|
-
|
|
592
|
-
factoryAddress,
|
|
593
|
-
factoryCalldata,
|
|
594
|
-
signature
|
|
595
|
-
})
|
|
596
|
-
}
|
|
347
|
+
if (smartAccountDeployed) return undefined
|
|
597
348
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
if (smartAccountDeployed) return undefined
|
|
616
|
-
|
|
617
|
-
return factoryAddress
|
|
618
|
-
},
|
|
619
|
-
|
|
620
|
-
async getFactoryData() {
|
|
621
|
-
if (smartAccountDeployed) return undefined
|
|
622
|
-
|
|
623
|
-
smartAccountDeployed = await isSmartAccountDeployed(
|
|
624
|
-
client,
|
|
625
|
-
accountAddress
|
|
626
|
-
)
|
|
627
|
-
|
|
628
|
-
if (smartAccountDeployed) return undefined
|
|
629
|
-
|
|
630
|
-
return parseFactoryAddressAndCallDataFromAccountInitCode(
|
|
631
|
-
await generateInitCode()
|
|
632
|
-
)[1]
|
|
633
|
-
},
|
|
634
|
-
|
|
635
|
-
// Get the nonce of the smart account
|
|
636
|
-
async getNonce() {
|
|
637
|
-
const key = await kernelPluginManager.getNonceKey(accountAddress)
|
|
638
|
-
return getAccountNonce(client, {
|
|
639
|
-
sender: accountAddress,
|
|
640
|
-
entryPoint: entryPointAddress,
|
|
641
|
-
key
|
|
642
|
-
})
|
|
643
|
-
},
|
|
644
|
-
|
|
645
|
-
// Sign a user operation
|
|
646
|
-
async signUserOperation(userOperation) {
|
|
647
|
-
return kernelPluginManager.signUserOperation(userOperation)
|
|
648
|
-
},
|
|
649
|
-
|
|
650
|
-
// Encode the init code
|
|
651
|
-
async getInitCode() {
|
|
652
|
-
if (smartAccountDeployed) return "0x"
|
|
653
|
-
|
|
654
|
-
smartAccountDeployed = await isSmartAccountDeployed(
|
|
655
|
-
client,
|
|
656
|
-
accountAddress
|
|
657
|
-
)
|
|
658
|
-
|
|
659
|
-
if (smartAccountDeployed) return "0x"
|
|
660
|
-
return generateInitCode()
|
|
661
|
-
},
|
|
662
|
-
|
|
663
|
-
// [TODO] - CLeanup the encoding functions
|
|
664
|
-
|
|
665
|
-
// Encode the deploy call data
|
|
666
|
-
async encodeDeployCallData(_tx) {
|
|
667
|
-
if (entryPointVersion === "v0.6") {
|
|
668
|
-
return encodeFunctionData({
|
|
669
|
-
abi: KernelExecuteAbi,
|
|
670
|
-
functionName: "executeDelegateCall",
|
|
671
|
-
args: [
|
|
672
|
-
createCallAddress,
|
|
673
|
-
encodeFunctionData({
|
|
674
|
-
abi: createCallAbi,
|
|
675
|
-
functionName: "performCreate",
|
|
676
|
-
args: [
|
|
677
|
-
0n,
|
|
678
|
-
encodeDeployData({
|
|
679
|
-
abi: _tx.abi,
|
|
680
|
-
bytecode: _tx.bytecode,
|
|
681
|
-
args: _tx.args
|
|
682
|
-
} as EncodeDeployDataParameters)
|
|
683
|
-
]
|
|
684
|
-
})
|
|
685
|
-
]
|
|
349
|
+
return parseFactoryAddressAndCallDataFromAccountInitCode(
|
|
350
|
+
await generateInitCode()
|
|
351
|
+
)[1]
|
|
352
|
+
},
|
|
353
|
+
async signMessage({ message }) {
|
|
354
|
+
const messageHash = hashMessage(message)
|
|
355
|
+
const { name, chainId, version } = await accountMetadata(
|
|
356
|
+
client,
|
|
357
|
+
accountAddress,
|
|
358
|
+
entryPointAddress
|
|
359
|
+
)
|
|
360
|
+
const wrappedMessageHash = await eip712WrapHash(messageHash, {
|
|
361
|
+
name,
|
|
362
|
+
chainId: Number(chainId),
|
|
363
|
+
version,
|
|
364
|
+
verifyingContract: accountAddress
|
|
686
365
|
})
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
return encodeFunctionData({
|
|
690
|
-
abi: KernelV3ExecuteAbi,
|
|
691
|
-
functionName: "execute",
|
|
692
|
-
args: [
|
|
693
|
-
getExecMode(CALL_TYPE.DELEGATE_CALL, EXEC_TYPE.DEFAULT),
|
|
694
|
-
concatHex([
|
|
695
|
-
createCallAddress,
|
|
696
|
-
encodeFunctionData({
|
|
697
|
-
abi: createCallAbi,
|
|
698
|
-
functionName: "performCreate",
|
|
699
|
-
args: [
|
|
700
|
-
0n,
|
|
701
|
-
encodeDeployData({
|
|
702
|
-
abi: _tx.abi,
|
|
703
|
-
bytecode: _tx.bytecode,
|
|
704
|
-
args: _tx.args
|
|
705
|
-
} as EncodeDeployDataParameters)
|
|
706
|
-
]
|
|
707
|
-
})
|
|
708
|
-
])
|
|
709
|
-
]
|
|
710
|
-
})
|
|
711
|
-
},
|
|
712
|
-
|
|
713
|
-
// Encode a call
|
|
714
|
-
async encodeCallData(_tx) {
|
|
715
|
-
const tx = _tx as KernelEncodeCallDataArgs
|
|
716
|
-
if (Array.isArray(tx)) {
|
|
717
|
-
// Encode a batched call
|
|
718
|
-
if (entryPointVersion === "v0.6") {
|
|
719
|
-
return encodeFunctionData({
|
|
720
|
-
abi: KernelExecuteAbi,
|
|
721
|
-
functionName: "executeBatch",
|
|
722
|
-
args: [
|
|
723
|
-
tx.map((txn) => {
|
|
724
|
-
if (txn.callType === "delegatecall") {
|
|
725
|
-
throw new Error("Cannot batch delegatecall")
|
|
726
|
-
}
|
|
727
|
-
return {
|
|
728
|
-
to: txn.to,
|
|
729
|
-
value: txn.value,
|
|
730
|
-
data: txn.data
|
|
731
|
-
}
|
|
732
|
-
})
|
|
733
|
-
]
|
|
734
|
-
})
|
|
735
|
-
}
|
|
736
|
-
return encodeFunctionData({
|
|
737
|
-
abi: KernelV3ExecuteAbi,
|
|
738
|
-
functionName: "execute",
|
|
739
|
-
args: [
|
|
740
|
-
getExecMode(CALL_TYPE.BATCH, EXEC_TYPE.DEFAULT),
|
|
741
|
-
encodeAbiParameters(
|
|
742
|
-
[
|
|
743
|
-
{
|
|
744
|
-
name: "executionBatch",
|
|
745
|
-
type: "tuple[]",
|
|
746
|
-
components: [
|
|
747
|
-
{
|
|
748
|
-
name: "target",
|
|
749
|
-
type: "address"
|
|
750
|
-
},
|
|
751
|
-
{
|
|
752
|
-
name: "value",
|
|
753
|
-
type: "uint256"
|
|
754
|
-
},
|
|
755
|
-
{
|
|
756
|
-
name: "callData",
|
|
757
|
-
type: "bytes"
|
|
758
|
-
}
|
|
759
|
-
]
|
|
760
|
-
}
|
|
761
|
-
],
|
|
762
|
-
[
|
|
763
|
-
tx.map((txn) => {
|
|
764
|
-
if (txn.callType === "delegatecall") {
|
|
765
|
-
throw new Error(
|
|
766
|
-
"Cannot batch delegatecall"
|
|
767
|
-
)
|
|
768
|
-
}
|
|
769
|
-
return {
|
|
770
|
-
target: txn.to,
|
|
771
|
-
value: txn.value,
|
|
772
|
-
callData: txn.data
|
|
773
|
-
}
|
|
774
|
-
})
|
|
775
|
-
]
|
|
776
|
-
)
|
|
777
|
-
]
|
|
366
|
+
const signature = await kernelPluginManager.signMessage({
|
|
367
|
+
message: { raw: wrappedMessageHash }
|
|
778
368
|
})
|
|
779
|
-
}
|
|
780
369
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
370
|
+
if (
|
|
371
|
+
!hasKernelFeature(
|
|
372
|
+
KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
|
|
373
|
+
version
|
|
374
|
+
)
|
|
375
|
+
) {
|
|
376
|
+
return signature
|
|
785
377
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
378
|
+
|
|
379
|
+
return concatHex([
|
|
380
|
+
kernelPluginManager.getValidationId(),
|
|
381
|
+
signature
|
|
382
|
+
])
|
|
383
|
+
},
|
|
384
|
+
async signTransaction(_, __) {
|
|
385
|
+
throw new SignTransactionNotSupportedBySmartAccount()
|
|
386
|
+
},
|
|
387
|
+
async signTypedData(typedData) {
|
|
388
|
+
const types = {
|
|
389
|
+
EIP712Domain: getTypesForEIP712Domain({
|
|
390
|
+
domain: typedData.domain
|
|
391
|
+
}),
|
|
392
|
+
...typedData.types
|
|
792
393
|
}
|
|
793
|
-
return encodeFunctionData({
|
|
794
|
-
abi: KernelV3ExecuteAbi,
|
|
795
|
-
functionName: "execute",
|
|
796
|
-
args: [
|
|
797
|
-
getExecMode(CALL_TYPE.SINGLE, EXEC_TYPE.DEFAULT),
|
|
798
|
-
concatHex([
|
|
799
|
-
tx.to,
|
|
800
|
-
pad(toHex(tx.value), { size: 32 }),
|
|
801
|
-
tx.data
|
|
802
|
-
])
|
|
803
|
-
]
|
|
804
|
-
})
|
|
805
|
-
}
|
|
806
394
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
395
|
+
// Need to do a runtime validation check on addresses, byte ranges, integer ranges, etc
|
|
396
|
+
// as we can't statically check this with TypeScript.
|
|
397
|
+
validateTypedData({
|
|
398
|
+
domain: typedData.domain,
|
|
399
|
+
message: typedData.message,
|
|
400
|
+
primaryType: typedData.primaryType,
|
|
401
|
+
types: types
|
|
402
|
+
} as TypedDataDefinition)
|
|
403
|
+
|
|
404
|
+
const typedHash = hashTypedData(typedData)
|
|
405
|
+
|
|
406
|
+
const { name, chainId, version } = await accountMetadata(
|
|
407
|
+
client,
|
|
408
|
+
accountAddress,
|
|
409
|
+
entryPointAddress
|
|
410
|
+
)
|
|
411
|
+
const wrappedMessageHash = await eip712WrapHash(typedHash, {
|
|
412
|
+
name,
|
|
413
|
+
chainId: Number(chainId),
|
|
414
|
+
version,
|
|
415
|
+
verifyingContract: accountAddress
|
|
416
|
+
})
|
|
417
|
+
const signature = await kernelPluginManager.signMessage({
|
|
418
|
+
message: { raw: wrappedMessageHash }
|
|
419
|
+
})
|
|
420
|
+
if (
|
|
421
|
+
!hasKernelFeature(
|
|
422
|
+
KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
|
|
423
|
+
version
|
|
424
|
+
)
|
|
425
|
+
) {
|
|
426
|
+
return signature
|
|
814
427
|
}
|
|
815
|
-
return
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
428
|
+
return concatHex([
|
|
429
|
+
kernelPluginManager.getValidationId(),
|
|
430
|
+
signature
|
|
431
|
+
])
|
|
432
|
+
},
|
|
433
|
+
// Get the nonce of the smart account
|
|
434
|
+
async getNonce() {
|
|
435
|
+
const key =
|
|
436
|
+
await kernelPluginManager.getNonceKey(accountAddress)
|
|
437
|
+
return getAccountNonce(client, {
|
|
438
|
+
sender: accountAddress,
|
|
439
|
+
entryPoint: entryPointAddress,
|
|
440
|
+
key
|
|
822
441
|
})
|
|
823
|
-
}
|
|
442
|
+
},
|
|
824
443
|
|
|
825
|
-
|
|
826
|
-
|
|
444
|
+
// Sign a user operation
|
|
445
|
+
async signUserOperation(userOperation) {
|
|
446
|
+
return kernelPluginManager.signUserOperation(userOperation)
|
|
447
|
+
},
|
|
448
|
+
|
|
449
|
+
// Get simple dummy signature
|
|
450
|
+
async getDummySignature(userOperation) {
|
|
451
|
+
return kernelPluginManager.getDummySignature(userOperation)
|
|
452
|
+
},
|
|
827
453
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
454
|
+
// Encode the init code
|
|
455
|
+
async getInitCode() {
|
|
456
|
+
if (smartAccountDeployed) return "0x"
|
|
457
|
+
|
|
458
|
+
smartAccountDeployed = await isSmartAccountDeployed(
|
|
459
|
+
client,
|
|
460
|
+
accountAddress
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
if (smartAccountDeployed) return "0x"
|
|
464
|
+
return generateInitCode()
|
|
465
|
+
}
|
|
466
|
+
})
|
|
832
467
|
}
|
|
833
468
|
}
|