@zerodev/sdk 5.2.0-alpha-3 → 5.2.0
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/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js +115 -58
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js.map +1 -1
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js +39 -0
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js.map +1 -0
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js +203 -0
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js.map +1 -0
- package/_cjs/accounts/kernel/createKernelAccount.js +43 -22
- package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_cjs/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js +22 -0
- package/_cjs/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js.map +1 -0
- package/_cjs/accounts/kernel/utils/common/getActionSelector.js +19 -0
- package/_cjs/accounts/kernel/utils/common/getActionSelector.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js +22 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js +39 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js +21 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js +41 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js +20 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js.map +1 -0
- package/_cjs/accounts/kernel/v1/createKernelV1Account.js +5 -2
- package/_cjs/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
- package/_cjs/accounts/kernel/v2/createKernelV2Account.js +9 -4
- package/_cjs/accounts/kernel/v2/createKernelV2Account.js.map +1 -1
- package/_cjs/accounts/utils/getCustomNonceKeyFromString.js +19 -0
- package/_cjs/accounts/utils/getCustomNonceKeyFromString.js.map +1 -0
- package/_cjs/accounts/utils/index.js +3 -1
- package/_cjs/accounts/utils/index.js.map +1 -1
- package/_cjs/accounts/utils/toKernelPluginManager.js +120 -184
- package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_cjs/actions/account-client/getUserOperationGasPrice.js +15 -0
- package/_cjs/actions/account-client/getUserOperationGasPrice.js.map +1 -0
- package/_cjs/actions/index.js +3 -1
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/paymaster/estimateGasInERC20.js +2 -2
- package/_cjs/actions/paymaster/estimateGasInERC20.js.map +1 -1
- package/_cjs/actions/paymaster/sponsorUserOperation.js +1 -2
- package/_cjs/actions/paymaster/sponsorUserOperation.js.map +1 -1
- package/_cjs/clients/decorators/kernel.js +3 -1
- package/_cjs/clients/decorators/kernel.js.map +1 -1
- package/_cjs/clients/kernelAccountClient.js +29 -3
- package/_cjs/clients/kernelAccountClient.js.map +1 -1
- package/_cjs/clients/paymasterClient.js +18 -1
- package/_cjs/clients/paymasterClient.js.map +1 -1
- package/_cjs/clients/utils.js +31 -0
- package/_cjs/clients/utils.js.map +1 -0
- package/_cjs/constants.js +5 -2
- package/_cjs/constants.js.map +1 -1
- package/_cjs/index.js +6 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/providers/KernelEIP1193Provider.js +37 -0
- package/_cjs/providers/KernelEIP1193Provider.js.map +1 -1
- package/_cjs/types/index.js.map +1 -1
- package/_cjs/types/kernel.js.map +1 -1
- package/_cjs/utils.js +1 -2
- package/_cjs/utils.js.map +1 -1
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js +115 -58
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js.map +1 -1
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js +36 -0
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js.map +1 -0
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js +200 -0
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js.map +1 -0
- package/_esm/accounts/kernel/createKernelAccount.js +44 -23
- package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_esm/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js +18 -0
- package/_esm/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js.map +1 -0
- package/_esm/accounts/kernel/utils/common/getActionSelector.js +15 -0
- package/_esm/accounts/kernel/utils/common/getActionSelector.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js +18 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js +35 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js +18 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js +42 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js +16 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js.map +1 -0
- package/_esm/accounts/kernel/v1/createKernelV1Account.js +6 -3
- package/_esm/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
- package/_esm/accounts/kernel/v2/createKernelV2Account.js +10 -5
- package/_esm/accounts/kernel/v2/createKernelV2Account.js.map +1 -1
- package/_esm/accounts/utils/getCustomNonceKeyFromString.js +15 -0
- package/_esm/accounts/utils/getCustomNonceKeyFromString.js.map +1 -0
- package/_esm/accounts/utils/index.js +1 -0
- package/_esm/accounts/utils/index.js.map +1 -1
- package/_esm/accounts/utils/toKernelPluginManager.js +124 -188
- package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_esm/actions/account-client/getUserOperationGasPrice.js +11 -0
- package/_esm/actions/account-client/getUserOperationGasPrice.js.map +1 -0
- package/_esm/actions/index.js +1 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/paymaster/estimateGasInERC20.js +2 -2
- package/_esm/actions/paymaster/estimateGasInERC20.js.map +1 -1
- package/_esm/actions/paymaster/sponsorUserOperation.js +1 -2
- package/_esm/actions/paymaster/sponsorUserOperation.js.map +1 -1
- package/_esm/clients/decorators/kernel.js +3 -1
- package/_esm/clients/decorators/kernel.js.map +1 -1
- package/_esm/clients/kernelAccountClient.js +30 -4
- package/_esm/clients/kernelAccountClient.js.map +1 -1
- package/_esm/clients/paymasterClient.js +19 -2
- package/_esm/clients/paymasterClient.js.map +1 -1
- package/_esm/clients/utils.js +26 -0
- package/_esm/clients/utils.js.map +1 -0
- package/_esm/constants.js +4 -1
- package/_esm/constants.js.map +1 -1
- package/_esm/index.js +3 -1
- package/_esm/index.js.map +1 -1
- package/_esm/providers/KernelEIP1193Provider.js +37 -0
- package/_esm/providers/KernelEIP1193Provider.js.map +1 -1
- package/_esm/types/index.js.map +1 -1
- package/_esm/types/kernel.js.map +1 -1
- package/_esm/utils.js +2 -3
- package/_esm/utils.js.map +1 -1
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.d.ts +110 -20
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.d.ts.map +1 -1
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.d.ts +60 -0
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.d.ts.map +1 -0
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.d.ts +215 -0
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.d.ts.map +1 -0
- package/_types/accounts/kernel/createKernelAccount.d.ts +8 -4
- package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.d.ts +3 -0
- package/_types/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/common/getActionSelector.d.ts +4 -0
- package/_types/accounts/kernel/utils/common/getActionSelector.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts +9 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts +13 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.d.ts +9 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts +10 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.d.ts +3 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.d.ts.map +1 -0
- package/_types/accounts/kernel/v1/createKernelV1Account.d.ts +1 -1
- package/_types/accounts/kernel/v1/createKernelV1Account.d.ts.map +1 -1
- package/_types/accounts/kernel/v2/createKernelV2Account.d.ts +3 -1
- package/_types/accounts/kernel/v2/createKernelV2Account.d.ts.map +1 -1
- package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts +3 -0
- package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts.map +1 -0
- package/_types/accounts/utils/index.d.ts +1 -0
- package/_types/accounts/utils/index.d.ts.map +1 -1
- package/_types/accounts/utils/toKernelPluginManager.d.ts +1 -1
- package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
- package/_types/actions/account-client/getUserOperationGasPrice.d.ts +9 -0
- package/_types/actions/account-client/getUserOperationGasPrice.d.ts.map +1 -0
- package/_types/actions/index.d.ts +1 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/paymaster/estimateGasInERC20.d.ts.map +1 -1
- package/_types/actions/paymaster/sponsorUserOperation.d.ts.map +1 -1
- package/_types/clients/decorators/kernel.d.ts +8 -1
- package/_types/clients/decorators/kernel.d.ts.map +1 -1
- package/_types/clients/kernelAccountClient.d.ts +12 -4
- package/_types/clients/kernelAccountClient.d.ts.map +1 -1
- package/_types/clients/paymasterClient.d.ts.map +1 -1
- package/_types/clients/utils.d.ts +3 -0
- package/_types/clients/utils.d.ts.map +1 -0
- package/_types/constants.d.ts +4 -1
- package/_types/constants.d.ts.map +1 -1
- package/_types/index.d.ts +3 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/providers/KernelEIP1193Provider.d.ts +2 -0
- package/_types/providers/KernelEIP1193Provider.d.ts.map +1 -1
- package/_types/types/index.d.ts +1 -1
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/kernel.d.ts +32 -17
- package/_types/types/kernel.d.ts.map +1 -1
- package/_types/utils.d.ts.map +1 -1
- package/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.ts +115 -58
- package/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.ts +35 -0
- package/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.ts +199 -0
- package/accounts/kernel/createKernelAccount.ts +59 -26
- package/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.ts +24 -0
- package/accounts/kernel/utils/common/getActionSelector.ts +20 -0
- package/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.ts +39 -0
- package/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.ts +76 -0
- package/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.ts +47 -0
- package/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.ts +63 -0
- package/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.ts +23 -0
- package/accounts/kernel/v1/createKernelV1Account.ts +21 -8
- package/accounts/kernel/v2/createKernelV2Account.ts +17 -6
- package/accounts/utils/getCustomNonceKeyFromString.ts +21 -0
- package/accounts/utils/index.ts +2 -0
- package/accounts/utils/toKernelPluginManager.ts +155 -224
- package/actions/account-client/getUserOperationGasPrice.ts +26 -0
- package/actions/index.ts +5 -0
- package/actions/paymaster/estimateGasInERC20.ts +2 -3
- package/actions/paymaster/sponsorUserOperation.ts +1 -3
- package/clients/decorators/kernel.ts +22 -6
- package/clients/kernelAccountClient.ts +36 -3
- package/clients/paymasterClient.ts +24 -1
- package/clients/utils.ts +28 -0
- package/constants.ts +6 -2
- package/index.ts +6 -1
- package/package.json +4 -4
- package/providers/KernelEIP1193Provider.ts +51 -0
- package/types/index.ts +4 -2
- package/types/kernel.ts +52 -38
- package/utils.ts +2 -3
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
export const KernelFactoryStakerAbi = [
|
|
2
|
+
{
|
|
3
|
+
type: "constructor",
|
|
4
|
+
inputs: [{ name: "_owner", type: "address", internalType: "address" }],
|
|
5
|
+
stateMutability: "nonpayable"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
type: "function",
|
|
9
|
+
name: "approveFactory",
|
|
10
|
+
inputs: [
|
|
11
|
+
{
|
|
12
|
+
name: "factory",
|
|
13
|
+
type: "address",
|
|
14
|
+
internalType: "contract KernelFactory"
|
|
15
|
+
},
|
|
16
|
+
{ name: "approval", type: "bool", internalType: "bool" }
|
|
17
|
+
],
|
|
18
|
+
outputs: [],
|
|
19
|
+
stateMutability: "payable"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: "function",
|
|
23
|
+
name: "approved",
|
|
24
|
+
inputs: [
|
|
25
|
+
{
|
|
26
|
+
name: "",
|
|
27
|
+
type: "address",
|
|
28
|
+
internalType: "contract KernelFactory"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
32
|
+
stateMutability: "view"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: "function",
|
|
36
|
+
name: "cancelOwnershipHandover",
|
|
37
|
+
inputs: [],
|
|
38
|
+
outputs: [],
|
|
39
|
+
stateMutability: "payable"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "function",
|
|
43
|
+
name: "completeOwnershipHandover",
|
|
44
|
+
inputs: [
|
|
45
|
+
{ name: "pendingOwner", type: "address", internalType: "address" }
|
|
46
|
+
],
|
|
47
|
+
outputs: [],
|
|
48
|
+
stateMutability: "payable"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "function",
|
|
52
|
+
name: "deployWithFactory",
|
|
53
|
+
inputs: [
|
|
54
|
+
{
|
|
55
|
+
name: "factory",
|
|
56
|
+
type: "address",
|
|
57
|
+
internalType: "contract KernelFactory"
|
|
58
|
+
},
|
|
59
|
+
{ name: "createData", type: "bytes", internalType: "bytes" },
|
|
60
|
+
{ name: "salt", type: "bytes32", internalType: "bytes32" }
|
|
61
|
+
],
|
|
62
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
63
|
+
stateMutability: "payable"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: "function",
|
|
67
|
+
name: "owner",
|
|
68
|
+
inputs: [],
|
|
69
|
+
outputs: [{ name: "result", type: "address", internalType: "address" }],
|
|
70
|
+
stateMutability: "view"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: "function",
|
|
74
|
+
name: "ownershipHandoverExpiresAt",
|
|
75
|
+
inputs: [
|
|
76
|
+
{ name: "pendingOwner", type: "address", internalType: "address" }
|
|
77
|
+
],
|
|
78
|
+
outputs: [{ name: "result", type: "uint256", internalType: "uint256" }],
|
|
79
|
+
stateMutability: "view"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: "function",
|
|
83
|
+
name: "renounceOwnership",
|
|
84
|
+
inputs: [],
|
|
85
|
+
outputs: [],
|
|
86
|
+
stateMutability: "payable"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: "function",
|
|
90
|
+
name: "requestOwnershipHandover",
|
|
91
|
+
inputs: [],
|
|
92
|
+
outputs: [],
|
|
93
|
+
stateMutability: "payable"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: "function",
|
|
97
|
+
name: "stake",
|
|
98
|
+
inputs: [
|
|
99
|
+
{
|
|
100
|
+
name: "entryPoint",
|
|
101
|
+
type: "address",
|
|
102
|
+
internalType: "contract IEntryPoint"
|
|
103
|
+
},
|
|
104
|
+
{ name: "unstakeDelay", type: "uint32", internalType: "uint32" }
|
|
105
|
+
],
|
|
106
|
+
outputs: [],
|
|
107
|
+
stateMutability: "payable"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
type: "function",
|
|
111
|
+
name: "transferOwnership",
|
|
112
|
+
inputs: [
|
|
113
|
+
{ name: "newOwner", type: "address", internalType: "address" }
|
|
114
|
+
],
|
|
115
|
+
outputs: [],
|
|
116
|
+
stateMutability: "payable"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: "function",
|
|
120
|
+
name: "unlockStake",
|
|
121
|
+
inputs: [
|
|
122
|
+
{
|
|
123
|
+
name: "entryPoint",
|
|
124
|
+
type: "address",
|
|
125
|
+
internalType: "contract IEntryPoint"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
outputs: [],
|
|
129
|
+
stateMutability: "payable"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
type: "function",
|
|
133
|
+
name: "withdrawStake",
|
|
134
|
+
inputs: [
|
|
135
|
+
{
|
|
136
|
+
name: "entryPoint",
|
|
137
|
+
type: "address",
|
|
138
|
+
internalType: "contract IEntryPoint"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "recipient",
|
|
142
|
+
type: "address",
|
|
143
|
+
internalType: "address payable"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
outputs: [],
|
|
147
|
+
stateMutability: "payable"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: "event",
|
|
151
|
+
name: "OwnershipHandoverCanceled",
|
|
152
|
+
inputs: [
|
|
153
|
+
{
|
|
154
|
+
name: "pendingOwner",
|
|
155
|
+
type: "address",
|
|
156
|
+
indexed: true,
|
|
157
|
+
internalType: "address"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
anonymous: false
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
type: "event",
|
|
164
|
+
name: "OwnershipHandoverRequested",
|
|
165
|
+
inputs: [
|
|
166
|
+
{
|
|
167
|
+
name: "pendingOwner",
|
|
168
|
+
type: "address",
|
|
169
|
+
indexed: true,
|
|
170
|
+
internalType: "address"
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
anonymous: false
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: "event",
|
|
177
|
+
name: "OwnershipTransferred",
|
|
178
|
+
inputs: [
|
|
179
|
+
{
|
|
180
|
+
name: "oldOwner",
|
|
181
|
+
type: "address",
|
|
182
|
+
indexed: true,
|
|
183
|
+
internalType: "address"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: "newOwner",
|
|
187
|
+
type: "address",
|
|
188
|
+
indexed: true,
|
|
189
|
+
internalType: "address"
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
anonymous: false
|
|
193
|
+
},
|
|
194
|
+
{ type: "error", name: "AlreadyInitialized", inputs: [] },
|
|
195
|
+
{ type: "error", name: "NewOwnerIsZeroAddress", inputs: [] },
|
|
196
|
+
{ type: "error", name: "NoHandoverRequest", inputs: [] },
|
|
197
|
+
{ type: "error", name: "NotApprovedFactory", inputs: [] },
|
|
198
|
+
{ type: "error", name: "Unauthorized", inputs: [] }
|
|
199
|
+
] as const
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
getTypesForEIP712Domain,
|
|
27
27
|
hashMessage,
|
|
28
28
|
hashTypedData,
|
|
29
|
+
toHex,
|
|
29
30
|
validateTypedData,
|
|
30
31
|
zeroAddress
|
|
31
32
|
} from "viem"
|
|
@@ -42,6 +43,7 @@ import {
|
|
|
42
43
|
} from "../utils/toKernelPluginManager.js"
|
|
43
44
|
import { KernelInitAbi } from "./abi/KernelAccountAbi.js"
|
|
44
45
|
import { KernelV3InitAbi } from "./abi/kernel_v_3_0_0/KernelAccountAbi.js"
|
|
46
|
+
import { KernelFactoryStakerAbi } from "./abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js"
|
|
45
47
|
import { encodeCallData as encodeCallDataEpV06 } from "./utils/account/ep0_6/encodeCallData.js"
|
|
46
48
|
import { encodeDeployCallData as encodeDeployCallDataV06 } from "./utils/account/ep0_6/encodeDeployCallData.js"
|
|
47
49
|
import { encodeCallData as encodeCallDataEpV07 } from "./utils/account/ep0_7/encodeCallData.js"
|
|
@@ -55,17 +57,20 @@ export type KernelSmartAccount<
|
|
|
55
57
|
chain extends Chain | undefined = Chain | undefined
|
|
56
58
|
> = SmartAccount<entryPoint, "kernelSmartAccount", transport, chain> & {
|
|
57
59
|
kernelPluginManager: KernelPluginManager<entryPoint>
|
|
60
|
+
getNonce: (customNonceKey?: bigint) => Promise<bigint>
|
|
61
|
+
generateInitCode: () => Promise<Hex>
|
|
58
62
|
encodeCallData: (args: KernelEncodeCallDataArgs) => Promise<Hex>
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
export type CreateKernelAccountParameters<entryPoint extends EntryPoint> = {
|
|
62
66
|
plugins:
|
|
63
|
-
| KernelPluginManagerParams<entryPoint>
|
|
67
|
+
| Omit<KernelPluginManagerParams<entryPoint>, "entryPoint">
|
|
64
68
|
| KernelPluginManager<entryPoint>
|
|
65
69
|
entryPoint: entryPoint
|
|
66
70
|
index?: bigint
|
|
67
71
|
factoryAddress?: Address
|
|
68
72
|
accountLogicAddress?: Address
|
|
73
|
+
factoryStakerAddress?: Address
|
|
69
74
|
deployedAccountAddress?: Address
|
|
70
75
|
}
|
|
71
76
|
|
|
@@ -110,13 +115,15 @@ const createAccountAbi = [
|
|
|
110
115
|
export const KERNEL_ADDRESSES: {
|
|
111
116
|
ACCOUNT_LOGIC_V0_6: Address
|
|
112
117
|
ACCOUNT_LOGIC_V0_7: Address
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
FACTORY_ADDRESS_V0_6: Address
|
|
119
|
+
FACTORY_ADDRESS_V0_7: Address
|
|
120
|
+
FACTORY_STAKER: Address
|
|
115
121
|
} = {
|
|
116
122
|
ACCOUNT_LOGIC_V0_6: "0xd3082872F8B06073A021b4602e022d5A070d7cfC",
|
|
117
|
-
ACCOUNT_LOGIC_V0_7: "
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
ACCOUNT_LOGIC_V0_7: "0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27",
|
|
124
|
+
FACTORY_ADDRESS_V0_6: "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3",
|
|
125
|
+
FACTORY_ADDRESS_V0_7: "0x6723b44Abeec4E71eBE3232BD5B455805baDD22f",
|
|
126
|
+
FACTORY_STAKER: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5"
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
const getKernelInitData = async <entryPoint extends EntryPoint>({
|
|
@@ -127,7 +134,7 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
|
|
|
127
134
|
kernelPluginManager: KernelPluginManager<entryPoint>
|
|
128
135
|
}) => {
|
|
129
136
|
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
130
|
-
const { enableData, validatorAddress } =
|
|
137
|
+
const { enableData, identifier, validatorAddress } =
|
|
131
138
|
await kernelPluginManager.getValidatorInitData()
|
|
132
139
|
|
|
133
140
|
if (entryPointVersion === "v0.6") {
|
|
@@ -141,12 +148,7 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
|
|
|
141
148
|
return encodeFunctionData({
|
|
142
149
|
abi: KernelV3InitAbi,
|
|
143
150
|
functionName: "initialize",
|
|
144
|
-
args: [
|
|
145
|
-
kernelPluginManager.getValidationId(true),
|
|
146
|
-
zeroAddress,
|
|
147
|
-
enableData,
|
|
148
|
-
"0x"
|
|
149
|
-
]
|
|
151
|
+
args: [identifier, zeroAddress, enableData, "0x"]
|
|
150
152
|
})
|
|
151
153
|
}
|
|
152
154
|
|
|
@@ -161,12 +163,14 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
|
|
|
161
163
|
index,
|
|
162
164
|
factoryAddress,
|
|
163
165
|
accountLogicAddress,
|
|
166
|
+
factoryStakerAddress,
|
|
164
167
|
entryPoint: entryPointAddress,
|
|
165
168
|
kernelPluginManager
|
|
166
169
|
}: {
|
|
167
170
|
index: bigint
|
|
168
171
|
factoryAddress: Address
|
|
169
172
|
accountLogicAddress: Address
|
|
173
|
+
factoryStakerAddress: Address
|
|
170
174
|
entryPoint: entryPoint
|
|
171
175
|
kernelPluginManager: KernelPluginManager<entryPoint>
|
|
172
176
|
}): Promise<Hex> => {
|
|
@@ -175,15 +179,31 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
|
|
|
175
179
|
entryPoint: entryPointAddress,
|
|
176
180
|
kernelPluginManager
|
|
177
181
|
})
|
|
182
|
+
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
178
183
|
|
|
179
184
|
// Build the account init code
|
|
185
|
+
if (entryPointVersion === "v0.6") {
|
|
186
|
+
return concatHex([
|
|
187
|
+
factoryAddress,
|
|
188
|
+
encodeFunctionData({
|
|
189
|
+
abi: createAccountAbi,
|
|
190
|
+
functionName: "createAccount",
|
|
191
|
+
args: [accountLogicAddress, initialisationData, index]
|
|
192
|
+
}) as Hex
|
|
193
|
+
])
|
|
194
|
+
}
|
|
195
|
+
|
|
180
196
|
return concatHex([
|
|
181
|
-
|
|
197
|
+
factoryStakerAddress,
|
|
182
198
|
encodeFunctionData({
|
|
183
|
-
abi:
|
|
184
|
-
functionName: "
|
|
185
|
-
args: [
|
|
186
|
-
|
|
199
|
+
abi: KernelFactoryStakerAbi,
|
|
200
|
+
functionName: "deployWithFactory",
|
|
201
|
+
args: [
|
|
202
|
+
factoryAddress,
|
|
203
|
+
initialisationData,
|
|
204
|
+
toHex(index, { size: 32 })
|
|
205
|
+
]
|
|
206
|
+
})
|
|
187
207
|
])
|
|
188
208
|
}
|
|
189
209
|
|
|
@@ -247,8 +267,9 @@ export async function createKernelAccount<
|
|
|
247
267
|
plugins,
|
|
248
268
|
entryPoint: entryPointAddress,
|
|
249
269
|
index = 0n,
|
|
250
|
-
factoryAddress = KERNEL_ADDRESSES.
|
|
270
|
+
factoryAddress = KERNEL_ADDRESSES.FACTORY_ADDRESS_V0_6,
|
|
251
271
|
accountLogicAddress = KERNEL_ADDRESSES.ACCOUNT_LOGIC_V0_6,
|
|
272
|
+
factoryStakerAddress = KERNEL_ADDRESSES.FACTORY_STAKER,
|
|
252
273
|
deployedAccountAddress
|
|
253
274
|
}: CreateKernelAccountParameters<entryPoint>
|
|
254
275
|
): Promise<KernelSmartAccount<entryPoint, TTransport, TChain>> {
|
|
@@ -257,13 +278,17 @@ export async function createKernelAccount<
|
|
|
257
278
|
entryPointVersion === "v0.6"
|
|
258
279
|
? KERNEL_ADDRESSES.ACCOUNT_LOGIC_V0_6
|
|
259
280
|
: KERNEL_ADDRESSES.ACCOUNT_LOGIC_V0_7
|
|
281
|
+
factoryAddress =
|
|
282
|
+
entryPointVersion === "v0.6"
|
|
283
|
+
? KERNEL_ADDRESSES.FACTORY_ADDRESS_V0_6
|
|
284
|
+
: KERNEL_ADDRESSES.FACTORY_ADDRESS_V0_7
|
|
260
285
|
|
|
261
286
|
const kernelPluginManager = isKernelPluginManager<entryPoint>(plugins)
|
|
262
287
|
? plugins
|
|
263
288
|
: await toKernelPluginManager<entryPoint>(client, {
|
|
264
289
|
sudo: plugins.sudo,
|
|
265
290
|
regular: plugins.regular,
|
|
266
|
-
|
|
291
|
+
action: plugins.action,
|
|
267
292
|
pluginEnableSignature: plugins.pluginEnableSignature,
|
|
268
293
|
entryPoint: entryPointAddress
|
|
269
294
|
})
|
|
@@ -273,6 +298,7 @@ export async function createKernelAccount<
|
|
|
273
298
|
index,
|
|
274
299
|
factoryAddress,
|
|
275
300
|
accountLogicAddress,
|
|
301
|
+
factoryStakerAddress,
|
|
276
302
|
entryPoint: entryPointAddress,
|
|
277
303
|
kernelPluginManager
|
|
278
304
|
})
|
|
@@ -296,6 +322,7 @@ export async function createKernelAccount<
|
|
|
296
322
|
|
|
297
323
|
return {
|
|
298
324
|
kernelPluginManager,
|
|
325
|
+
generateInitCode,
|
|
299
326
|
...toSmartAccount({
|
|
300
327
|
address: accountAddress,
|
|
301
328
|
publicKey: accountAddress,
|
|
@@ -333,7 +360,11 @@ export async function createKernelAccount<
|
|
|
333
360
|
|
|
334
361
|
if (smartAccountDeployed) return undefined
|
|
335
362
|
|
|
336
|
-
|
|
363
|
+
const entryPointVersion =
|
|
364
|
+
getEntryPointVersion(entryPointAddress)
|
|
365
|
+
return entryPointVersion === "v0.6"
|
|
366
|
+
? factoryAddress
|
|
367
|
+
: factoryStakerAddress
|
|
337
368
|
},
|
|
338
369
|
|
|
339
370
|
async getFactoryData() {
|
|
@@ -377,7 +408,7 @@ export async function createKernelAccount<
|
|
|
377
408
|
}
|
|
378
409
|
|
|
379
410
|
return concatHex([
|
|
380
|
-
kernelPluginManager.
|
|
411
|
+
kernelPluginManager.getIdentifier(),
|
|
381
412
|
signature
|
|
382
413
|
])
|
|
383
414
|
},
|
|
@@ -426,14 +457,16 @@ export async function createKernelAccount<
|
|
|
426
457
|
return signature
|
|
427
458
|
}
|
|
428
459
|
return concatHex([
|
|
429
|
-
kernelPluginManager.
|
|
460
|
+
kernelPluginManager.getIdentifier(),
|
|
430
461
|
signature
|
|
431
462
|
])
|
|
432
463
|
},
|
|
433
464
|
// Get the nonce of the smart account
|
|
434
|
-
async getNonce() {
|
|
435
|
-
const key =
|
|
436
|
-
|
|
465
|
+
async getNonce(customNonceKey?: bigint) {
|
|
466
|
+
const key = await kernelPluginManager.getNonceKey(
|
|
467
|
+
accountAddress,
|
|
468
|
+
customNonceKey
|
|
469
|
+
)
|
|
437
470
|
return getAccountNonce(client, {
|
|
438
471
|
sender: accountAddress,
|
|
439
472
|
entryPoint: entryPointAddress,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getAction } from "permissionless"
|
|
2
|
+
import type { Address, Client } from "viem"
|
|
3
|
+
import { readContract } from "viem/actions"
|
|
4
|
+
import { KernelV3AccountAbi } from "../../../abi/kernel_v_3_0_0/KernelAccountAbi.js"
|
|
5
|
+
|
|
6
|
+
export const getKernelV3Nonce = async (
|
|
7
|
+
client: Client,
|
|
8
|
+
accountAddress: Address
|
|
9
|
+
): Promise<number> => {
|
|
10
|
+
try {
|
|
11
|
+
const nonce = await getAction(
|
|
12
|
+
client,
|
|
13
|
+
readContract
|
|
14
|
+
)({
|
|
15
|
+
abi: KernelV3AccountAbi,
|
|
16
|
+
address: accountAddress,
|
|
17
|
+
functionName: "currentNonce",
|
|
18
|
+
args: []
|
|
19
|
+
})
|
|
20
|
+
return nonce
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return 1
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EntryPointVersion } from "permissionless/types/entrypoint"
|
|
2
|
+
import { type Hex, getAbiItem, toFunctionSelector } from "viem"
|
|
3
|
+
import { KernelAccountAbi } from "../../abi/KernelAccountAbi.js"
|
|
4
|
+
import { KernelV3AccountAbi } from "../../abi/kernel_v_3_0_0/KernelAccountAbi.js"
|
|
5
|
+
|
|
6
|
+
export const getActionSelector = (
|
|
7
|
+
entryPointVersion: EntryPointVersion
|
|
8
|
+
): Hex => {
|
|
9
|
+
if (entryPointVersion === "v0.6") {
|
|
10
|
+
return toFunctionSelector(
|
|
11
|
+
getAbiItem({ abi: KernelAccountAbi, name: "execute" })
|
|
12
|
+
)
|
|
13
|
+
} else if (entryPointVersion === "v0.7") {
|
|
14
|
+
return toFunctionSelector(
|
|
15
|
+
getAbiItem({ abi: KernelV3AccountAbi, name: "execute" })
|
|
16
|
+
)
|
|
17
|
+
} else {
|
|
18
|
+
throw new Error("Unsupported entry point version")
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
3
|
+
EntryPoint
|
|
4
|
+
} from "permissionless/types/entrypoint"
|
|
5
|
+
import { type Address, type Hex, concat, pad, toHex } from "viem"
|
|
6
|
+
import {
|
|
7
|
+
type PluginValidityData,
|
|
8
|
+
ValidatorMode
|
|
9
|
+
} from "../../../../../types/index.js"
|
|
10
|
+
import type { Kernel2_0_plugins } from "./getPluginsEnableTypedData.js"
|
|
11
|
+
|
|
12
|
+
export const getEncodedPluginsData = async <
|
|
13
|
+
entryPoint extends EntryPoint = ENTRYPOINT_ADDRESS_V06_TYPE
|
|
14
|
+
>({
|
|
15
|
+
accountAddress,
|
|
16
|
+
enableSignature,
|
|
17
|
+
action,
|
|
18
|
+
validator,
|
|
19
|
+
validUntil,
|
|
20
|
+
validAfter
|
|
21
|
+
}: {
|
|
22
|
+
accountAddress: Address
|
|
23
|
+
enableSignature: Hex
|
|
24
|
+
} & Kernel2_0_plugins<entryPoint> &
|
|
25
|
+
PluginValidityData) => {
|
|
26
|
+
const enableData = await validator.getEnableData(accountAddress)
|
|
27
|
+
const enableDataLength = enableData.length / 2 - 1
|
|
28
|
+
return concat([
|
|
29
|
+
ValidatorMode.enable,
|
|
30
|
+
pad(toHex(validUntil, { size: 6 }), { size: 6 }), // 6 bytes 4 - 10
|
|
31
|
+
pad(toHex(validAfter), { size: 6 }), // 6 bytes 10 - 16
|
|
32
|
+
pad(validator.address, { size: 20 }), // 20 bytes 16 - 36
|
|
33
|
+
pad(action.address, { size: 20 }), // 20 bytes 36 - 56
|
|
34
|
+
pad(toHex(enableDataLength), { size: 32 }), // 32 bytes 56 - 88
|
|
35
|
+
enableData, // 88 - 88 + enableData.length
|
|
36
|
+
pad(toHex(enableSignature.length / 2 - 1), { size: 32 }), // 32 bytes 88 + enableData.length - 120 + enableData.length
|
|
37
|
+
enableSignature // 120 + enableData.length - 120 + enableData.length + enableSignature.length
|
|
38
|
+
])
|
|
39
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
3
|
+
EntryPoint
|
|
4
|
+
} from "permissionless/types/entrypoint"
|
|
5
|
+
import {
|
|
6
|
+
type Address,
|
|
7
|
+
type CustomSource,
|
|
8
|
+
concatHex,
|
|
9
|
+
hexToBigInt,
|
|
10
|
+
pad,
|
|
11
|
+
toHex
|
|
12
|
+
} from "viem"
|
|
13
|
+
import type {
|
|
14
|
+
Action,
|
|
15
|
+
KernelValidator,
|
|
16
|
+
PluginValidityData
|
|
17
|
+
} from "../../../../../types/index.js"
|
|
18
|
+
|
|
19
|
+
export type Kernel2_0_plugins<entryPoint extends EntryPoint> = {
|
|
20
|
+
validator: KernelValidator<entryPoint>
|
|
21
|
+
action: Action
|
|
22
|
+
}
|
|
23
|
+
export const getPluginsEnableTypedData = async <
|
|
24
|
+
entryPoint extends EntryPoint = ENTRYPOINT_ADDRESS_V06_TYPE
|
|
25
|
+
>({
|
|
26
|
+
accountAddress,
|
|
27
|
+
chainId,
|
|
28
|
+
kernelVersion,
|
|
29
|
+
action,
|
|
30
|
+
validator,
|
|
31
|
+
validUntil,
|
|
32
|
+
validAfter
|
|
33
|
+
}: {
|
|
34
|
+
accountAddress: Address
|
|
35
|
+
chainId: number
|
|
36
|
+
kernelVersion: string
|
|
37
|
+
// { action, validator }: Kernel2_0_plugins
|
|
38
|
+
} & Kernel2_0_plugins<entryPoint> &
|
|
39
|
+
PluginValidityData): Promise<
|
|
40
|
+
Parameters<CustomSource["signTypedData"]>[0]
|
|
41
|
+
> => {
|
|
42
|
+
return {
|
|
43
|
+
domain: {
|
|
44
|
+
name: "Kernel",
|
|
45
|
+
version: kernelVersion,
|
|
46
|
+
chainId,
|
|
47
|
+
verifyingContract: accountAddress
|
|
48
|
+
},
|
|
49
|
+
types: {
|
|
50
|
+
ValidatorApproved: [
|
|
51
|
+
{ name: "sig", type: "bytes4" },
|
|
52
|
+
{ name: "validatorData", type: "uint256" },
|
|
53
|
+
{ name: "executor", type: "address" },
|
|
54
|
+
{ name: "enableData", type: "bytes" }
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
message: {
|
|
58
|
+
sig: action.selector,
|
|
59
|
+
validatorData: hexToBigInt(
|
|
60
|
+
concatHex([
|
|
61
|
+
pad(toHex(validUntil ?? 0), {
|
|
62
|
+
size: 6
|
|
63
|
+
}),
|
|
64
|
+
pad(toHex(validAfter ?? 0), {
|
|
65
|
+
size: 6
|
|
66
|
+
}),
|
|
67
|
+
validator.address
|
|
68
|
+
]),
|
|
69
|
+
{ size: 32 }
|
|
70
|
+
),
|
|
71
|
+
executor: action.address as Address,
|
|
72
|
+
enableData: await validator.getEnableData(accountAddress)
|
|
73
|
+
},
|
|
74
|
+
primaryType: "ValidatorApproved"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
3
|
+
EntryPoint
|
|
4
|
+
} from "permissionless/types/entrypoint"
|
|
5
|
+
import {
|
|
6
|
+
type Address,
|
|
7
|
+
type Hex,
|
|
8
|
+
concat,
|
|
9
|
+
encodeAbiParameters,
|
|
10
|
+
parseAbiParameters,
|
|
11
|
+
zeroAddress
|
|
12
|
+
} from "viem"
|
|
13
|
+
import type { Kernel2_0_plugins } from "../ep0_6/getPluginsEnableTypedData.js"
|
|
14
|
+
|
|
15
|
+
export const getEncodedPluginsData = async <
|
|
16
|
+
entryPoint extends EntryPoint = ENTRYPOINT_ADDRESS_V06_TYPE
|
|
17
|
+
>({
|
|
18
|
+
accountAddress,
|
|
19
|
+
enableSignature,
|
|
20
|
+
userOpSignature,
|
|
21
|
+
action,
|
|
22
|
+
validator
|
|
23
|
+
}: {
|
|
24
|
+
accountAddress: Address
|
|
25
|
+
enableSignature: Hex
|
|
26
|
+
userOpSignature: Hex
|
|
27
|
+
} & Kernel2_0_plugins<entryPoint>) => {
|
|
28
|
+
const enableData = await validator.getEnableData(accountAddress)
|
|
29
|
+
return concat([
|
|
30
|
+
zeroAddress, // hook address 20 bytes
|
|
31
|
+
encodeAbiParameters(
|
|
32
|
+
parseAbiParameters(
|
|
33
|
+
"bytes validatorData, bytes hookData, bytes selectorData, bytes enableSig, bytes userOpSig"
|
|
34
|
+
),
|
|
35
|
+
[
|
|
36
|
+
enableData,
|
|
37
|
+
"0x",
|
|
38
|
+
// [TODO]: Integrate custom target contract and hook
|
|
39
|
+
concat([
|
|
40
|
+
action.selector /*, action.address, zeroAddress, "0x"*/
|
|
41
|
+
]),
|
|
42
|
+
enableSignature,
|
|
43
|
+
userOpSignature
|
|
44
|
+
]
|
|
45
|
+
)
|
|
46
|
+
])
|
|
47
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ENTRYPOINT_ADDRESS_V07_TYPE,
|
|
3
|
+
EntryPoint
|
|
4
|
+
} from "permissionless/types/entrypoint"
|
|
5
|
+
import { type Address, type CustomSource, concat, pad, zeroAddress } from "viem"
|
|
6
|
+
import { VALIDATOR_TYPE } from "../../../../../constants.js"
|
|
7
|
+
import type { Kernel2_0_plugins } from "../ep0_6/getPluginsEnableTypedData.js"
|
|
8
|
+
|
|
9
|
+
export const getPluginsEnableTypedData = async <
|
|
10
|
+
entryPoint extends EntryPoint = ENTRYPOINT_ADDRESS_V07_TYPE
|
|
11
|
+
>({
|
|
12
|
+
accountAddress,
|
|
13
|
+
chainId,
|
|
14
|
+
kernelVersion,
|
|
15
|
+
action,
|
|
16
|
+
validator,
|
|
17
|
+
validatorNonce
|
|
18
|
+
}: {
|
|
19
|
+
accountAddress: Address
|
|
20
|
+
chainId: number
|
|
21
|
+
kernelVersion: string
|
|
22
|
+
validatorNonce: number
|
|
23
|
+
} & Kernel2_0_plugins<entryPoint>): Promise<
|
|
24
|
+
Parameters<CustomSource["signTypedData"]>[0]
|
|
25
|
+
> => {
|
|
26
|
+
return {
|
|
27
|
+
domain: {
|
|
28
|
+
name: "Kernel",
|
|
29
|
+
version: kernelVersion,
|
|
30
|
+
chainId,
|
|
31
|
+
verifyingContract: accountAddress
|
|
32
|
+
},
|
|
33
|
+
types: {
|
|
34
|
+
Enable: [
|
|
35
|
+
{ name: "validationId", type: "bytes21" },
|
|
36
|
+
{ name: "nonce", type: "uint32" },
|
|
37
|
+
{ name: "hook", type: "address" },
|
|
38
|
+
{ name: "validatorData", type: "bytes" },
|
|
39
|
+
{ name: "hookData", type: "bytes" },
|
|
40
|
+
{ name: "selectorData", type: "bytes" }
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
message: {
|
|
44
|
+
validationId: concat([
|
|
45
|
+
VALIDATOR_TYPE[validator.validatorType],
|
|
46
|
+
pad(validator.getIdentifier(), { size: 20, dir: "right" })
|
|
47
|
+
]),
|
|
48
|
+
nonce: validatorNonce,
|
|
49
|
+
hook: zeroAddress,
|
|
50
|
+
validatorData: await validator.getEnableData(accountAddress),
|
|
51
|
+
hookData: "0x",
|
|
52
|
+
selectorData: concat([
|
|
53
|
+
action.selector
|
|
54
|
+
/*
|
|
55
|
+
action.address,
|
|
56
|
+
zeroAddress,
|
|
57
|
+
"0x"
|
|
58
|
+
*/
|
|
59
|
+
])
|
|
60
|
+
},
|
|
61
|
+
primaryType: "Enable"
|
|
62
|
+
}
|
|
63
|
+
}
|