@zerodev/sdk 5.2.0-alpha-4 → 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 +42 -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 +4 -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 +43 -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 +5 -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 +7 -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 +57 -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 +20 -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,23 @@
|
|
|
1
|
+
import { getAction } from "permissionless"
|
|
2
|
+
import type { Address, Client } from "viem"
|
|
3
|
+
import { readContract } from "viem/actions"
|
|
4
|
+
import { KernelModuleIsInitializedAbi } from "../../../abi/kernel_v_3_0_0/KernelModuleAbi.js"
|
|
5
|
+
|
|
6
|
+
export const isPluginInitialized = async (
|
|
7
|
+
client: Client,
|
|
8
|
+
accountAddress: Address,
|
|
9
|
+
pluginAddress: Address
|
|
10
|
+
) => {
|
|
11
|
+
try {
|
|
12
|
+
return await getAction(
|
|
13
|
+
client,
|
|
14
|
+
readContract
|
|
15
|
+
)({
|
|
16
|
+
abi: KernelModuleIsInitializedAbi,
|
|
17
|
+
address: pluginAddress,
|
|
18
|
+
functionName: "isInitialized",
|
|
19
|
+
args: [accountAddress]
|
|
20
|
+
})
|
|
21
|
+
} catch (error) {}
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ENTRYPOINT_ADDRESS_V06,
|
|
3
3
|
getAccountNonce,
|
|
4
|
+
getEntryPointVersion,
|
|
4
5
|
getSenderAddress,
|
|
5
6
|
getUserOperationHash,
|
|
6
7
|
isSmartAccountDeployed
|
|
@@ -9,7 +10,10 @@ import {
|
|
|
9
10
|
SignTransactionNotSupportedBySmartAccount,
|
|
10
11
|
type SmartAccountSigner
|
|
11
12
|
} from "permissionless/accounts"
|
|
12
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
15
|
+
EntryPoint
|
|
16
|
+
} from "permissionless/types/entrypoint.js"
|
|
13
17
|
import {
|
|
14
18
|
type Address,
|
|
15
19
|
type Chain,
|
|
@@ -96,15 +100,20 @@ export async function createKernelV1Account<
|
|
|
96
100
|
client: Client<TTransport, TChain, undefined>,
|
|
97
101
|
{
|
|
98
102
|
signer,
|
|
99
|
-
entrypoint: entryPointAddress
|
|
103
|
+
entrypoint: entryPointAddress,
|
|
100
104
|
index = 0n
|
|
101
105
|
}: {
|
|
102
106
|
signer: SmartAccountSigner<TSource, TAddress>
|
|
103
|
-
entrypoint
|
|
107
|
+
entrypoint: entryPoint
|
|
104
108
|
index?: bigint
|
|
105
109
|
}
|
|
106
110
|
): Promise<KernelV1SmartAccount<entryPoint, TTransport, TChain>> {
|
|
107
|
-
|
|
111
|
+
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
112
|
+
|
|
113
|
+
if (
|
|
114
|
+
entryPointVersion !== "v0.6" ||
|
|
115
|
+
entryPointAddress !== ENTRYPOINT_ADDRESS_V06
|
|
116
|
+
) {
|
|
108
117
|
throw new Error("Only EntryPoint 0.6 is supported")
|
|
109
118
|
}
|
|
110
119
|
|
|
@@ -130,10 +139,13 @@ export async function createKernelV1Account<
|
|
|
130
139
|
}
|
|
131
140
|
|
|
132
141
|
const initCode = await generateInitCode()
|
|
133
|
-
const accountAddress = await getSenderAddress(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
const accountAddress = await getSenderAddress<ENTRYPOINT_ADDRESS_V06_TYPE>(
|
|
143
|
+
client,
|
|
144
|
+
{
|
|
145
|
+
initCode,
|
|
146
|
+
entryPoint: entryPointAddress
|
|
147
|
+
}
|
|
148
|
+
)
|
|
137
149
|
|
|
138
150
|
if (!accountAddress) throw new Error("Account address not found")
|
|
139
151
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ENTRYPOINT_ADDRESS_V06,
|
|
3
2
|
getAccountNonce,
|
|
3
|
+
getEntryPointVersion,
|
|
4
4
|
getSenderAddress,
|
|
5
5
|
isSmartAccountDeployed
|
|
6
6
|
} from "permissionless"
|
|
@@ -56,6 +56,8 @@ export type KernelSmartAccount<
|
|
|
56
56
|
chain extends Chain | undefined = Chain | undefined
|
|
57
57
|
> = SmartAccount<entryPoint, "kernelSmartAccount", transport, chain> & {
|
|
58
58
|
kernelPluginManager: KernelPluginManager<entryPoint>
|
|
59
|
+
getNonce: (customNonceKey?: bigint) => Promise<bigint>
|
|
60
|
+
generateInitCode: () => Promise<Hex>
|
|
59
61
|
encodeCallData: (args: KernelEncodeCallDataArgs) => Promise<Hex>
|
|
60
62
|
}
|
|
61
63
|
|
|
@@ -154,7 +156,7 @@ export async function createKernelV2Account<
|
|
|
154
156
|
client: Client<TTransport, TChain, undefined>,
|
|
155
157
|
{
|
|
156
158
|
plugins,
|
|
157
|
-
entryPoint: entryPointAddress
|
|
159
|
+
entryPoint: entryPointAddress,
|
|
158
160
|
index = 0n,
|
|
159
161
|
factoryAddress = KERNEL_ADDRESSES.FACTORY_ADDRESS,
|
|
160
162
|
deployedAccountAddress
|
|
@@ -162,18 +164,23 @@ export async function createKernelV2Account<
|
|
|
162
164
|
plugins:
|
|
163
165
|
| KernelPluginManagerParams<entryPoint>
|
|
164
166
|
| KernelPluginManager<entryPoint>
|
|
165
|
-
entryPoint
|
|
167
|
+
entryPoint: entryPoint
|
|
166
168
|
index?: bigint
|
|
167
169
|
factoryAddress?: Address
|
|
168
170
|
deployedAccountAddress?: Address
|
|
169
171
|
}
|
|
170
172
|
): Promise<KernelSmartAccount<entryPoint, TTransport, TChain>> {
|
|
173
|
+
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
174
|
+
|
|
175
|
+
if (entryPointVersion !== "v0.6") {
|
|
176
|
+
throw new Error("Only EntryPoint 0.6 is supported")
|
|
177
|
+
}
|
|
171
178
|
const kernelPluginManager = isKernelPluginManager<entryPoint>(plugins)
|
|
172
179
|
? plugins
|
|
173
180
|
: await toKernelPluginManager(client, {
|
|
174
181
|
sudo: plugins.sudo,
|
|
175
182
|
regular: plugins.regular,
|
|
176
|
-
|
|
183
|
+
action: plugins.action,
|
|
177
184
|
pluginEnableSignature: plugins.pluginEnableSignature,
|
|
178
185
|
kernelVersion: "0.0.2" ?? plugins.kernelVersion,
|
|
179
186
|
entryPoint: entryPointAddress
|
|
@@ -281,6 +288,7 @@ export async function createKernelV2Account<
|
|
|
281
288
|
entryPoint: entryPointAddress,
|
|
282
289
|
source: "kernelSmartAccount",
|
|
283
290
|
kernelPluginManager,
|
|
291
|
+
generateInitCode,
|
|
284
292
|
async getFactory() {
|
|
285
293
|
if (smartAccountDeployed) return undefined
|
|
286
294
|
|
|
@@ -310,8 +318,11 @@ export async function createKernelV2Account<
|
|
|
310
318
|
},
|
|
311
319
|
|
|
312
320
|
// Get the nonce of the smart account
|
|
313
|
-
async getNonce() {
|
|
314
|
-
const key = await kernelPluginManager.getNonceKey(
|
|
321
|
+
async getNonce(customNonceKey?: bigint) {
|
|
322
|
+
const key = await kernelPluginManager.getNonceKey(
|
|
323
|
+
accountAddress,
|
|
324
|
+
customNonceKey
|
|
325
|
+
)
|
|
315
326
|
return getAccountNonce(client, {
|
|
316
327
|
sender: accountAddress,
|
|
317
328
|
entryPoint: entryPointAddress,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getEntryPointVersion } from "permissionless"
|
|
2
|
+
import type { EntryPoint } from "permissionless/types"
|
|
3
|
+
import { keccak256, toHex } from "viem"
|
|
4
|
+
|
|
5
|
+
const hashAndTruncate = (input: string, byteSize: number): bigint => {
|
|
6
|
+
const hash = keccak256(toHex(input))
|
|
7
|
+
const truncatedHash = hash.substring(2, byteSize * 2 + 2) // 2 hex characters per byte
|
|
8
|
+
return BigInt(`0x${truncatedHash}`)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getCustomNonceKeyFromString = (
|
|
12
|
+
input: string,
|
|
13
|
+
entryPoint: EntryPoint
|
|
14
|
+
) => {
|
|
15
|
+
const entryPointVersion = getEntryPointVersion(entryPoint)
|
|
16
|
+
|
|
17
|
+
if (entryPointVersion === "v0.6") {
|
|
18
|
+
return hashAndTruncate(input, 24) // 24 bytes for v0.6
|
|
19
|
+
}
|
|
20
|
+
return hashAndTruncate(input, 2) // 2 bytes for v0.7
|
|
21
|
+
}
|
package/accounts/utils/index.ts
CHANGED