@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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { EntryPoint } from "permissionless/types/entrypoint.js"
|
|
2
|
+
import type { KernelSmartAccount } from "../../../createKernelAccount.js"
|
|
3
|
+
import { encodeExecuteBatchCall } from "../../ep0_6/encodeExecuteBatchCall.js"
|
|
4
|
+
import { encodeExecuteDelegateCall } from "../../ep0_6/encodeExecuteDelegateCall.js"
|
|
5
|
+
import { encodeExecuteSingleCall } from "../../ep0_6/encodeExecuteSingleCall.js"
|
|
6
|
+
|
|
7
|
+
export const encodeCallData = async <
|
|
8
|
+
entryPoint extends EntryPoint = EntryPoint
|
|
9
|
+
>(
|
|
10
|
+
tx: Parameters<KernelSmartAccount<entryPoint>["encodeCallData"]>[0]
|
|
11
|
+
) => {
|
|
12
|
+
if (Array.isArray(tx)) {
|
|
13
|
+
if (tx.some((t) => t.callType === "delegatecall")) {
|
|
14
|
+
throw new Error("Cannot batch delegatecall")
|
|
15
|
+
}
|
|
16
|
+
return encodeExecuteBatchCall(tx)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Default to `call`
|
|
20
|
+
if (!tx.callType || tx.callType === "call") {
|
|
21
|
+
return encodeExecuteSingleCall(tx)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (tx.callType === "delegatecall") {
|
|
25
|
+
return encodeExecuteDelegateCall({
|
|
26
|
+
to: tx.to,
|
|
27
|
+
data: tx.data
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
throw new Error("Invalid call type")
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { toSmartAccount } from "permissionless/accounts"
|
|
2
|
+
import { encodeDeployData } from "viem"
|
|
3
|
+
import { safeCreateCallAddress } from "../../../../../constants.js"
|
|
4
|
+
import { encodeSafeCreateCall } from "../../common/encodeSafeCreateCall.js"
|
|
5
|
+
import { encodeExecuteDelegateCall } from "../../ep0_6/encodeExecuteDelegateCall.js"
|
|
6
|
+
import type { DelegateCallArgs } from "../../types.js"
|
|
7
|
+
|
|
8
|
+
export const encodeDeployCallData = (
|
|
9
|
+
tx: Parameters<
|
|
10
|
+
Parameters<typeof toSmartAccount>[0]["encodeDeployCallData"]
|
|
11
|
+
>[0]
|
|
12
|
+
) => {
|
|
13
|
+
const deployCalldataArgs: DelegateCallArgs = {
|
|
14
|
+
to: safeCreateCallAddress,
|
|
15
|
+
data: encodeSafeCreateCall([0n, encodeDeployData(tx)])
|
|
16
|
+
}
|
|
17
|
+
return encodeExecuteDelegateCall(deployCalldataArgs)
|
|
18
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { EntryPoint } from "permissionless/types/entrypoint.js"
|
|
2
|
+
import { EXEC_TYPE } from "../../../../../constants.js"
|
|
3
|
+
import type { KernelSmartAccount } from "../../../createKernelAccount.js"
|
|
4
|
+
import { encodeExecuteBatchCall } from "../../ep0_7/encodeExecuteBatchCall.js"
|
|
5
|
+
import { encodeExecuteDelegateCall } from "../../ep0_7/encodeExecuteDelegateCall.js"
|
|
6
|
+
import { encodeExecuteSingleCall } from "../../ep0_7/encodeExecuteSingleCall.js"
|
|
7
|
+
|
|
8
|
+
export const encodeCallData = async <
|
|
9
|
+
entryPoint extends EntryPoint = EntryPoint
|
|
10
|
+
>(
|
|
11
|
+
tx: Parameters<KernelSmartAccount<entryPoint>["encodeCallData"]>[0]
|
|
12
|
+
) => {
|
|
13
|
+
if (Array.isArray(tx)) {
|
|
14
|
+
if (tx.some((t) => t.callType === "delegatecall")) {
|
|
15
|
+
throw new Error("Cannot batch delegatecall")
|
|
16
|
+
}
|
|
17
|
+
// Encode a batched call
|
|
18
|
+
return encodeExecuteBatchCall(tx, {
|
|
19
|
+
execType: EXEC_TYPE.DEFAULT
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Default to `call`
|
|
24
|
+
if (!tx.callType || tx.callType === "call") {
|
|
25
|
+
return encodeExecuteSingleCall(tx, {
|
|
26
|
+
execType: EXEC_TYPE.DEFAULT
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (tx.callType === "delegatecall") {
|
|
31
|
+
return encodeExecuteDelegateCall(
|
|
32
|
+
{ to: tx.to, data: tx.data },
|
|
33
|
+
{
|
|
34
|
+
execType: EXEC_TYPE.DEFAULT
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
throw new Error("Invalid call type")
|
|
40
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { toSmartAccount } from "permissionless/accounts"
|
|
2
|
+
import { encodeDeployData } from "viem"
|
|
3
|
+
import { EXEC_TYPE, safeCreateCallAddress } from "../../../../../constants.js"
|
|
4
|
+
import { encodeSafeCreateCall } from "../../common/encodeSafeCreateCall.js"
|
|
5
|
+
import { encodeExecuteDelegateCall } from "../../ep0_7/encodeExecuteDelegateCall.js"
|
|
6
|
+
import type { DelegateCallArgs } from "../../types.js"
|
|
7
|
+
|
|
8
|
+
export const encodeDeployCallData = (
|
|
9
|
+
tx: Parameters<
|
|
10
|
+
Parameters<typeof toSmartAccount>[0]["encodeDeployCallData"]
|
|
11
|
+
>[0]
|
|
12
|
+
) => {
|
|
13
|
+
const deployCalldataArgs: DelegateCallArgs = {
|
|
14
|
+
to: safeCreateCallAddress,
|
|
15
|
+
data: encodeSafeCreateCall([0n, encodeDeployData(tx)])
|
|
16
|
+
}
|
|
17
|
+
return encodeExecuteDelegateCall(deployCalldataArgs, {
|
|
18
|
+
execType: EXEC_TYPE.DEFAULT
|
|
19
|
+
})
|
|
20
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { EntryPoint } from "permissionless/types/entrypoint.js"
|
|
2
|
+
import {
|
|
3
|
+
type Address,
|
|
4
|
+
type Chain,
|
|
5
|
+
type Client,
|
|
6
|
+
type Transport,
|
|
7
|
+
decodeFunctionResult,
|
|
8
|
+
encodeFunctionData,
|
|
9
|
+
publicActions
|
|
10
|
+
} from "viem"
|
|
11
|
+
import { KERNEL_NAME } from "../../../../constants.js"
|
|
12
|
+
import { getKernelVersion } from "../../../../utils.js"
|
|
13
|
+
import { EIP1271Abi } from "../../abi/EIP1271Abi.js"
|
|
14
|
+
|
|
15
|
+
type AccountMetadata = {
|
|
16
|
+
name: string
|
|
17
|
+
version: string
|
|
18
|
+
chainId: bigint
|
|
19
|
+
}
|
|
20
|
+
export const accountMetadata = async <
|
|
21
|
+
TTransport extends Transport = Transport,
|
|
22
|
+
TChain extends Chain | undefined = Chain | undefined
|
|
23
|
+
>(
|
|
24
|
+
client: Client<TTransport, TChain, undefined>,
|
|
25
|
+
accountAddress: Address,
|
|
26
|
+
entryPointAddress: EntryPoint
|
|
27
|
+
): Promise<AccountMetadata> => {
|
|
28
|
+
try {
|
|
29
|
+
const domain = await client.request({
|
|
30
|
+
method: "eth_call",
|
|
31
|
+
params: [
|
|
32
|
+
{
|
|
33
|
+
to: accountAddress,
|
|
34
|
+
data: encodeFunctionData({
|
|
35
|
+
abi: EIP1271Abi,
|
|
36
|
+
functionName: "eip712Domain"
|
|
37
|
+
})
|
|
38
|
+
},
|
|
39
|
+
"latest"
|
|
40
|
+
]
|
|
41
|
+
})
|
|
42
|
+
if (domain !== "0x") {
|
|
43
|
+
const decoded = decodeFunctionResult({
|
|
44
|
+
abi: [...EIP1271Abi],
|
|
45
|
+
functionName: "eip712Domain",
|
|
46
|
+
data: domain
|
|
47
|
+
})
|
|
48
|
+
return {
|
|
49
|
+
name: decoded[1],
|
|
50
|
+
version: decoded[2],
|
|
51
|
+
chainId: decoded[3]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {}
|
|
55
|
+
return {
|
|
56
|
+
name: KERNEL_NAME,
|
|
57
|
+
version: getKernelVersion(entryPointAddress),
|
|
58
|
+
chainId: client.chain
|
|
59
|
+
? BigInt(client.chain.id)
|
|
60
|
+
: BigInt(await client.extend(publicActions).getChainId())
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Hex,
|
|
3
|
+
type TypedDataDomain,
|
|
4
|
+
concatHex,
|
|
5
|
+
domainSeparator,
|
|
6
|
+
keccak256
|
|
7
|
+
} from "viem"
|
|
8
|
+
import type { WithRequired } from "../../../../types/index.js"
|
|
9
|
+
import { KERNEL_FEATURES, hasKernelFeature } from "../../../../utils.js"
|
|
10
|
+
import { hashKernelMessageHashWrapper } from "../ep0_7/hashKernelSignatureWrapper.js"
|
|
11
|
+
|
|
12
|
+
export const eip712WrapHash = async (
|
|
13
|
+
messageHash: Hex,
|
|
14
|
+
domain: WithRequired<
|
|
15
|
+
TypedDataDomain,
|
|
16
|
+
"name" | "chainId" | "verifyingContract" | "version"
|
|
17
|
+
>
|
|
18
|
+
): Promise<Hex> => {
|
|
19
|
+
const { name, version, chainId, verifyingContract } = domain
|
|
20
|
+
|
|
21
|
+
if (!hasKernelFeature(KERNEL_FEATURES.ERC1271_SIG_WRAPPER, version)) {
|
|
22
|
+
return messageHash
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const _domainSeparator = domainSeparator({
|
|
26
|
+
domain: {
|
|
27
|
+
name,
|
|
28
|
+
version,
|
|
29
|
+
chainId,
|
|
30
|
+
verifyingContract
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
let finalMessageHash = messageHash
|
|
35
|
+
if (
|
|
36
|
+
hasKernelFeature(
|
|
37
|
+
KERNEL_FEATURES.ERC1271_SIG_WRAPPER_WITH_WRAPPED_HASH,
|
|
38
|
+
version
|
|
39
|
+
)
|
|
40
|
+
) {
|
|
41
|
+
finalMessageHash = hashKernelMessageHashWrapper(finalMessageHash)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const digest = keccak256(
|
|
45
|
+
concatHex(["0x1901", _domainSeparator, finalMessageHash])
|
|
46
|
+
)
|
|
47
|
+
return digest
|
|
48
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { encodeFunctionData } from "viem"
|
|
2
|
+
import { SafeCreateCallAbi } from "../../abi/SafeCreateCallAbi.js"
|
|
3
|
+
|
|
4
|
+
type EncodeExecuteDelegateCallArgs = Parameters<
|
|
5
|
+
typeof encodeFunctionData<typeof SafeCreateCallAbi, "performCreate">
|
|
6
|
+
>[0]["args"]
|
|
7
|
+
|
|
8
|
+
export const encodeSafeCreateCall = (args: EncodeExecuteDelegateCallArgs) => {
|
|
9
|
+
return encodeFunctionData({
|
|
10
|
+
abi: SafeCreateCallAbi,
|
|
11
|
+
functionName: "performCreate",
|
|
12
|
+
args
|
|
13
|
+
})
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { encodeFunctionData } from "viem"
|
|
2
|
+
import { KernelExecuteAbi } from "../../abi/KernelAccountAbi.js"
|
|
3
|
+
import type { CallArgs } from "../types.js"
|
|
4
|
+
|
|
5
|
+
export const encodeExecuteBatchCall = (args: CallArgs[]) => {
|
|
6
|
+
return encodeFunctionData({
|
|
7
|
+
abi: KernelExecuteAbi,
|
|
8
|
+
functionName: "executeBatch",
|
|
9
|
+
args: [
|
|
10
|
+
args.map((arg) => {
|
|
11
|
+
return {
|
|
12
|
+
to: arg.to,
|
|
13
|
+
value: arg.value,
|
|
14
|
+
data: arg.data
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
]
|
|
18
|
+
})
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { encodeFunctionData } from "viem"
|
|
2
|
+
import { KernelExecuteAbi } from "../../abi/KernelAccountAbi.js"
|
|
3
|
+
import type { DelegateCallArgs } from "../types.js"
|
|
4
|
+
|
|
5
|
+
export const encodeExecuteDelegateCall = (args: DelegateCallArgs) => {
|
|
6
|
+
return encodeFunctionData({
|
|
7
|
+
abi: KernelExecuteAbi,
|
|
8
|
+
functionName: "executeDelegateCall",
|
|
9
|
+
args: [args.to, args.data]
|
|
10
|
+
})
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { encodeFunctionData } from "viem"
|
|
2
|
+
import { KernelExecuteAbi } from "../../abi/KernelAccountAbi.js"
|
|
3
|
+
import type { CallArgs } from "../types.js"
|
|
4
|
+
|
|
5
|
+
export const encodeExecuteSingleCall = (args: CallArgs) => {
|
|
6
|
+
return encodeFunctionData({
|
|
7
|
+
abi: KernelExecuteAbi,
|
|
8
|
+
functionName: "execute",
|
|
9
|
+
args: [args.to, args.value, args.data, 0]
|
|
10
|
+
})
|
|
11
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { encodeAbiParameters } from "viem"
|
|
2
|
+
import { CALL_TYPE } from "../../../../constants.js"
|
|
3
|
+
import type { CallArgs } from "../types.js"
|
|
4
|
+
import {
|
|
5
|
+
type EncodeExecuteOptions,
|
|
6
|
+
encodeExecuteCall
|
|
7
|
+
} from "./encodeExecuteCall.js"
|
|
8
|
+
|
|
9
|
+
export const encodeExecuteBatchCall = (
|
|
10
|
+
args: CallArgs[],
|
|
11
|
+
options: Omit<EncodeExecuteOptions, "callType">
|
|
12
|
+
) => {
|
|
13
|
+
const calldata = encodeAbiParameters(
|
|
14
|
+
[
|
|
15
|
+
{
|
|
16
|
+
name: "executionBatch",
|
|
17
|
+
type: "tuple[]",
|
|
18
|
+
components: [
|
|
19
|
+
{
|
|
20
|
+
name: "target",
|
|
21
|
+
type: "address"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "value",
|
|
25
|
+
type: "uint256"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "callData",
|
|
29
|
+
type: "bytes"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
args.map((arg) => {
|
|
36
|
+
return {
|
|
37
|
+
target: arg.to,
|
|
38
|
+
value: arg.value,
|
|
39
|
+
callData: arg.data
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
)
|
|
44
|
+
return encodeExecuteCall(
|
|
45
|
+
{ calldata },
|
|
46
|
+
{
|
|
47
|
+
callType: CALL_TYPE.BATCH,
|
|
48
|
+
execType: options.execType
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type Hex, concatHex, encodeFunctionData, toHex } from "viem"
|
|
2
|
+
import { CALL_TYPE } from "../../../../constants.js"
|
|
3
|
+
import { getExecMode } from "../../../../utils.js"
|
|
4
|
+
import { KernelV3ExecuteAbi } from "../../abi/kernel_v_3_0_0/KernelAccountAbi.js"
|
|
5
|
+
import type { CallArgs, DelegateCallArgs } from "../types.js"
|
|
6
|
+
|
|
7
|
+
export type EncodeExecuteOptions = Parameters<typeof getExecMode>[0]
|
|
8
|
+
|
|
9
|
+
type EncodeExecuteCallArgs<TOptions> =
|
|
10
|
+
| (TOptions extends {
|
|
11
|
+
callType: CALL_TYPE.DELEGATE_CALL
|
|
12
|
+
}
|
|
13
|
+
? DelegateCallArgs
|
|
14
|
+
: CallArgs)
|
|
15
|
+
| { calldata: Hex }
|
|
16
|
+
|
|
17
|
+
export const encodeExecuteCall = <TOptions extends EncodeExecuteOptions>(
|
|
18
|
+
args: EncodeExecuteCallArgs<TOptions>,
|
|
19
|
+
options: TOptions
|
|
20
|
+
) => {
|
|
21
|
+
let calldata: Hex
|
|
22
|
+
if ("calldata" in args) {
|
|
23
|
+
calldata = args.calldata
|
|
24
|
+
} else {
|
|
25
|
+
calldata = concatHex([
|
|
26
|
+
args.to,
|
|
27
|
+
options.callType !== CALL_TYPE.DELEGATE_CALL
|
|
28
|
+
? toHex(args.value, { size: 32 })
|
|
29
|
+
: "0x", // No value if delegate call
|
|
30
|
+
args.data
|
|
31
|
+
])
|
|
32
|
+
}
|
|
33
|
+
return encodeFunctionData({
|
|
34
|
+
abi: KernelV3ExecuteAbi,
|
|
35
|
+
functionName: "execute",
|
|
36
|
+
args: [getExecMode(options), calldata]
|
|
37
|
+
})
|
|
38
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CALL_TYPE } from "../../../../constants.js"
|
|
2
|
+
import type { DelegateCallArgs } from "../types.js"
|
|
3
|
+
import {
|
|
4
|
+
type EncodeExecuteOptions,
|
|
5
|
+
encodeExecuteCall
|
|
6
|
+
} from "./encodeExecuteCall.js"
|
|
7
|
+
|
|
8
|
+
export const encodeExecuteDelegateCall = (
|
|
9
|
+
args: DelegateCallArgs,
|
|
10
|
+
options: Omit<EncodeExecuteOptions, "callType">
|
|
11
|
+
) => {
|
|
12
|
+
return encodeExecuteCall(args, {
|
|
13
|
+
callType: CALL_TYPE.DELEGATE_CALL,
|
|
14
|
+
execType: options.execType
|
|
15
|
+
})
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CALL_TYPE } from "../../../../constants.js"
|
|
2
|
+
import type { CallArgs } from "../types.js"
|
|
3
|
+
import {
|
|
4
|
+
type EncodeExecuteOptions,
|
|
5
|
+
encodeExecuteCall
|
|
6
|
+
} from "./encodeExecuteCall.js"
|
|
7
|
+
|
|
8
|
+
export const encodeExecuteSingleCall = (
|
|
9
|
+
args: CallArgs,
|
|
10
|
+
options: Omit<EncodeExecuteOptions, "callType">
|
|
11
|
+
) => {
|
|
12
|
+
return encodeExecuteCall(args, {
|
|
13
|
+
callType: CALL_TYPE.SINGLE,
|
|
14
|
+
execType: options.execType
|
|
15
|
+
})
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Hex } from "viem"
|
|
2
|
+
import { encodeAbiParameters, keccak256, stringToHex } from "viem"
|
|
3
|
+
|
|
4
|
+
export const hashKernelMessageHashWrapper = (messageHash: Hex) => {
|
|
5
|
+
return keccak256(
|
|
6
|
+
encodeAbiParameters(
|
|
7
|
+
[{ type: "bytes32" }, { type: "bytes32" }],
|
|
8
|
+
[keccak256(stringToHex("Kernel(bytes32 hash)")), messageHash]
|
|
9
|
+
)
|
|
10
|
+
)
|
|
11
|
+
}
|
|
@@ -28,12 +28,12 @@ import { getChainId, signMessage, signTypedData } from "viem/actions"
|
|
|
28
28
|
import { type KernelEncodeCallDataArgs } from "../../../types/kernel.js"
|
|
29
29
|
import { wrapSignatureWith6492 } from "../../utils/6492.js"
|
|
30
30
|
import { parseFactoryAddressAndCallDataFromAccountInitCode } from "../../utils/index.js"
|
|
31
|
-
import { type KernelSmartAccount } from "../createKernelAccount.js"
|
|
32
31
|
import {
|
|
33
32
|
MULTISEND_ADDRESS,
|
|
34
33
|
encodeMultiSend,
|
|
35
34
|
multiSendAbi
|
|
36
|
-
} from "
|
|
35
|
+
} from "../../utils/multisend.js"
|
|
36
|
+
import { type KernelSmartAccount } from "../createKernelAccount.js"
|
|
37
37
|
|
|
38
38
|
export type KernelV1SmartAccount<
|
|
39
39
|
entryPoint extends EntryPoint,
|
|
@@ -204,7 +204,6 @@ export async function createKernelV1Account<
|
|
|
204
204
|
publicKey: accountAddress,
|
|
205
205
|
entryPoint: entryPointAddress,
|
|
206
206
|
source: "kernelSmartAccount",
|
|
207
|
-
generateInitCode,
|
|
208
207
|
async getFactory() {
|
|
209
208
|
if (smartAccountDeployed) return undefined
|
|
210
209
|
|