@dynamic-labs-sdk/zerodev 1.29.0 → 1.30.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/dist/addZerodevExtension/addZerodevExtension.d.ts.map +1 -1
- package/dist/constants.d.ts +14 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.esm.js +1 -1
- package/dist/createKernelClientForWalletAccount/createKernelClientForWalletAccount.d.ts +1 -1
- package/dist/createKernelClientForWalletAccount/createKernelClientForWalletAccount.d.ts.map +1 -1
- package/dist/exports/index.d.ts +1 -0
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/{getZerodevRpc-CQfWJYcA.cjs → getZerodevRpc-Dek-gVrN.cjs} +21 -3
- package/dist/getZerodevRpc-Dek-gVrN.cjs.map +1 -0
- package/dist/{getZerodevRpc-CZ6WsXo_.esm.js → getZerodevRpc-DvZw2j1r.esm.js} +16 -4
- package/dist/getZerodevRpc-DvZw2j1r.esm.js.map +1 -0
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/getEcdsaValidator/getEcdsaValidator.d.ts +3 -1
- package/dist/utils/getEcdsaValidator/getEcdsaValidator.d.ts.map +1 -1
- package/dist/utils/getEntryPoint/getEntryPoint.d.ts +4 -1
- package/dist/utils/getEntryPoint/getEntryPoint.d.ts.map +1 -1
- package/dist/utils/getKernelVersion/getKernelVersion.d.ts +2 -2
- package/dist/utils/getKernelVersion/getKernelVersion.d.ts.map +1 -1
- package/dist/utils/getPaymasterConfig/getPaymasterConfig.d.ts +5 -3
- package/dist/utils/getPaymasterConfig/getPaymasterConfig.d.ts.map +1 -1
- package/dist/utils/getZerodevChainProviderForNetworkId/getZerodevChainProviderForNetworkId.d.ts +2 -1
- package/dist/utils/getZerodevChainProviderForNetworkId/getZerodevChainProviderForNetworkId.d.ts.map +1 -1
- package/dist/utils/getZerodevProviderFromSettings/getZerodevProviderFromSettings.d.ts +2 -1
- package/dist/utils/getZerodevProviderFromSettings/getZerodevProviderFromSettings.d.ts.map +1 -1
- package/dist/utils/getZerodevRpc/getZerodevRpc.d.ts +1 -1
- package/dist/utils/getZerodevRpc/getZerodevRpc.d.ts.map +1 -1
- package/dist/utils/prepareUserOperationFromCalls/prepareUserOperationFromCalls.d.ts +6 -457
- package/dist/utils/prepareUserOperationFromCalls/prepareUserOperationFromCalls.d.ts.map +1 -1
- package/dist/utils/shouldSignWithEoa/shouldSignWithEoa.d.ts.map +1 -1
- package/dist/utils/shouldUseEIP7702/shouldUseEIP7702.d.ts.map +1 -1
- package/dist/utils/signMessage/signMessage.d.ts +4 -3
- package/dist/utils/signMessage/signMessage.d.ts.map +1 -1
- package/dist/utils/zerodevTransferAmount/zerodevTransferAmount.d.ts +5 -3
- package/dist/utils/zerodevTransferAmount/zerodevTransferAmount.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/getZerodevRpc-CQfWJYcA.cjs.map +0 -1
- package/dist/getZerodevRpc-CZ6WsXo_.esm.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addZerodevExtension.d.ts","sourceRoot":"","sources":["../../src/addZerodevExtension/addZerodevExtension.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,GAAI,yDAA2B,
|
|
1
|
+
{"version":3,"file":"addZerodevExtension.d.ts","sourceRoot":"","sources":["../../src/addZerodevExtension/addZerodevExtension.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,GAAI,yDAA2B,KAAG,IAejE,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ZerodevBundlerProvider as SdkApiZerodevBundlerProvider } from '@dynamic-labs/sdk-api-core';
|
|
1
2
|
import type { KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';
|
|
2
3
|
import type { EntryPointVersion } from 'viem/account-abstraction';
|
|
3
4
|
export declare const ZERODEV_METADATA: {
|
|
@@ -6,6 +7,19 @@ export declare const ZERODEV_METADATA: {
|
|
|
6
7
|
normalizedWalletName: string;
|
|
7
8
|
};
|
|
8
9
|
export declare const ZERODEV_RPC_BASE_URL = "https://rpc.zerodev.app/api/v2";
|
|
10
|
+
/**
|
|
11
|
+
* Identifies the provider used for ZeroDev bundler and paymaster requests.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const provider: ZerodevBundlerProvider = ZerodevBundlerProvider.Pimlico;
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @see createKernelClientForWalletAccount
|
|
19
|
+
* @see getZerodevRpc
|
|
20
|
+
*/
|
|
21
|
+
export declare const ZerodevBundlerProvider: typeof SdkApiZerodevBundlerProvider;
|
|
22
|
+
export type ZerodevBundlerProvider = SdkApiZerodevBundlerProvider;
|
|
9
23
|
export declare const KERNEL_VERSION_MAP: {
|
|
10
24
|
readonly v3_3: import("@zerodev/sdk/types").KERNEL_V3_VERSION_TYPE;
|
|
11
25
|
readonly v3_2: import("@zerodev/sdk/types").KERNEL_V3_VERSION_TYPE;
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,sBAAsB,IAAI,4BAA4B,EACvD,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC;AAEF,eAAO,MAAM,oBAAoB,mCAAmC,CAAC;AAErE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,qCAA+B,CAAC;AACnE,MAAM,MAAM,sBAAsB,GAAG,4BAA4B,CAAC;AAElE,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAC;AAEX,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,iBAAiB,EACjB,mBAAmB,CAKX,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAWrB,CAAC"}
|
package/dist/core.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_getZerodevRpc = require('./getZerodevRpc-
|
|
1
|
+
const require_getZerodevRpc = require('./getZerodevRpc-Dek-gVrN.cjs');
|
|
2
2
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
3
3
|
|
|
4
4
|
//#region src/exports/core.ts
|
package/dist/core.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getKernelVersion, i as shouldUseEIP7702, l as getZerodevChainProviderForNetworkId, m as
|
|
1
|
+
import { a as getKernelVersion, h as version, i as shouldUseEIP7702, l as getZerodevChainProviderForNetworkId, m as name, n as getPaymasterConfig, o as getEntryPoint, r as createKernelAccount, s as getEcdsaValidator, t as getZerodevRpc, u as getZerodevProviderFromSettings } from "./getZerodevRpc-DvZw2j1r.esm.js";
|
|
2
2
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
3
3
|
|
|
4
4
|
//#region src/exports/core.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';
|
|
2
|
-
import type { ZerodevBundlerProvider } from '@dynamic-labs/sdk-api-core';
|
|
3
2
|
import type { Hex } from 'viem';
|
|
4
3
|
import type { SignAuthorizationReturnType } from 'viem/accounts';
|
|
5
4
|
import type { KernelClient } from '../KernelClient.types';
|
|
5
|
+
import type { ZerodevBundlerProvider } from '../constants';
|
|
6
6
|
export type Eip7702Authorization = SignAuthorizationReturnType;
|
|
7
7
|
type CreateKernelClientForWalletAccountParams = {
|
|
8
8
|
bundlerProvider?: ZerodevBundlerProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createKernelClientForWalletAccount.d.ts","sourceRoot":"","sources":["../../src/createKernelClientForWalletAccount/createKernelClientForWalletAccount.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"createKernelClientForWalletAccount.d.ts","sourceRoot":"","sources":["../../src/createKernelClientForWalletAccount/createKernelClientForWalletAccount.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAM9D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAK3D,MAAM,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAE/D,KAAK,wCAAwC,GAAG;IAC9C,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,2BAA2B,CAAC;IAC1C,eAAe,CAAC,EAAE,GAAG,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,gBAAgB,CAAC;IACrC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,kCAAkC,GAC7C,wKASG,wCAAwC,EAC3C,yDAA2B,KAC1B,OAAO,CAAC,YAAY,CAsFtB,CAAC"}
|
package/dist/exports/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { addZerodevExtension } from '../addZerodevExtension';
|
|
|
2
2
|
export type { BatchCall } from '../BatchCall.types';
|
|
3
3
|
export { canSponsorUserOperation } from '../canSponsorUserOperation';
|
|
4
4
|
export type { CanSponsorUserOperationParams } from '../canSponsorUserOperation';
|
|
5
|
+
export { ZerodevBundlerProvider } from '../constants';
|
|
5
6
|
export { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';
|
|
6
7
|
export type { Eip7702Authorization } from '../createKernelClientForWalletAccount';
|
|
7
8
|
export { estimateUserOperationGas } from '../estimateUserOperationGas';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,YAAY,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,kCAAkC,EAAE,MAAM,uCAAuC,CAAC;AAC3F,YAAY,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,YAAY,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,YAAY,EAA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4BAA4B,EAAE,MAAM,uCAAuC,CAAC"}
|
|
@@ -10,7 +10,7 @@ let _zerodev_multi_chain_ecdsa_validator = require("@zerodev/multi-chain-ecdsa-v
|
|
|
10
10
|
|
|
11
11
|
//#region package.json
|
|
12
12
|
var name = "@dynamic-labs-sdk/zerodev";
|
|
13
|
-
var version = "1.
|
|
13
|
+
var version = "1.30.3";
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/constants.ts
|
|
@@ -20,6 +20,18 @@ const ZERODEV_METADATA = {
|
|
|
20
20
|
normalizedWalletName: "zerodev"
|
|
21
21
|
};
|
|
22
22
|
const ZERODEV_RPC_BASE_URL = "https://rpc.zerodev.app/api/v2";
|
|
23
|
+
/**
|
|
24
|
+
* Identifies the provider used for ZeroDev bundler and paymaster requests.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const provider: ZerodevBundlerProvider = ZerodevBundlerProvider.Pimlico;
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @see createKernelClientForWalletAccount
|
|
32
|
+
* @see getZerodevRpc
|
|
33
|
+
*/
|
|
34
|
+
const ZerodevBundlerProvider = _dynamic_labs_sdk_api_core.ZerodevBundlerProvider;
|
|
23
35
|
const KERNEL_VERSION_MAP = {
|
|
24
36
|
[_dynamic_labs_sdk_api_core.ProviderKernelVersionEnum.V33]: _zerodev_sdk.constants.KERNEL_V3_3,
|
|
25
37
|
[_dynamic_labs_sdk_api_core.ProviderKernelVersionEnum.V32]: _zerodev_sdk.constants.KERNEL_V3_2,
|
|
@@ -214,7 +226,7 @@ const getZerodevRpc = ({ networkId, bundlerProvider, rpcType }, client) => {
|
|
|
214
226
|
if (zerodevProvider?.zerodevPaymasterRpcUrl) return zerodevProvider.zerodevPaymasterRpcUrl;
|
|
215
227
|
const zerodevChainProvider = getZerodevChainProviderForNetworkId({ networkId }, client);
|
|
216
228
|
(0, _dynamic_labs_sdk_client_core.assertDefined)(zerodevChainProvider, `No zerodev provider found for network id ${networkId}`);
|
|
217
|
-
const paymasterProvider = bundlerProvider ?? zerodevProvider.zerodevBundlerProvider ??
|
|
229
|
+
const paymasterProvider = bundlerProvider ?? zerodevProvider.zerodevBundlerProvider ?? ZerodevBundlerProvider.Pimlico;
|
|
218
230
|
const paramName = rpcType === "bundler" ? "bundlerProvider" : "paymasterProvider";
|
|
219
231
|
return `${ZERODEV_RPC_BASE_URL}/${rpcType}/${zerodevChainProvider.clientId}?${paramName}=${paymasterProvider}`;
|
|
220
232
|
};
|
|
@@ -232,6 +244,12 @@ Object.defineProperty(exports, 'ZERODEV_METADATA', {
|
|
|
232
244
|
return ZERODEV_METADATA;
|
|
233
245
|
}
|
|
234
246
|
});
|
|
247
|
+
Object.defineProperty(exports, 'ZerodevBundlerProvider', {
|
|
248
|
+
enumerable: true,
|
|
249
|
+
get: function () {
|
|
250
|
+
return ZerodevBundlerProvider;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
235
253
|
Object.defineProperty(exports, 'createKernelAccount', {
|
|
236
254
|
enumerable: true,
|
|
237
255
|
get: function () {
|
|
@@ -304,4 +322,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
304
322
|
return version;
|
|
305
323
|
}
|
|
306
324
|
});
|
|
307
|
-
//# sourceMappingURL=getZerodevRpc-
|
|
325
|
+
//# sourceMappingURL=getZerodevRpc-Dek-gVrN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getZerodevRpc-Dek-gVrN.cjs","names":["DYNAMIC_ICONIC_SPRITE_URL","SdkApiZerodevBundlerProvider","ProviderKernelVersionEnum","constants","ENTRY_POINT_VERSION_MAP: Record<\n EntryPointVersion,\n KERNEL_VERSION_TYPE\n>","ProviderEnum","NoSmartWalletAccountSignerFoundError","ProviderEntryPointVersionEnum","constants","entryPointVersion: keyof typeof ENTRY_POINT_VERSION_MAP","constants","constants"],"sources":["../package.json","../src/constants.ts","../src/utils/getZerodevProviderFromSettings/getZerodevProviderFromSettings.ts","../src/utils/getZerodevChainProviderForNetworkId/getZerodevChainProviderForNetworkId.ts","../src/getSignerForSmartWalletAccount/getSignerForSmartWalletAccount.ts","../src/utils/getEcdsaValidator/getEcdsaValidator.ts","../src/utils/getEntryPoint/getEntryPoint.ts","../src/utils/getKernelVersion/getKernelVersion.ts","../src/utils/shouldUseEIP7702/shouldUseEIP7702.ts","../src/utils/createKernelAccount/createKernelAccount.ts","../src/utils/getPaymasterConfig/getPaymasterConfig.ts","../src/utils/getZerodevRpc/getZerodevRpc.ts"],"sourcesContent":["","import { DYNAMIC_ICONIC_SPRITE_URL } from '@dynamic-labs-sdk/client/core';\nimport {\n ProviderKernelVersionEnum,\n ZerodevBundlerProvider as SdkApiZerodevBundlerProvider,\n} from '@dynamic-labs/sdk-api-core';\nimport { constants } from '@zerodev/sdk';\nimport type { KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\n\nexport const ZERODEV_METADATA = {\n displayName: 'ZeroDev',\n icon: `${DYNAMIC_ICONIC_SPRITE_URL}#smartwallet`,\n normalizedWalletName: 'zerodev',\n};\n\nexport const ZERODEV_RPC_BASE_URL = 'https://rpc.zerodev.app/api/v2';\n\n/**\n * Identifies the provider used for ZeroDev bundler and paymaster requests.\n *\n * @example\n * ```ts\n * const provider: ZerodevBundlerProvider = ZerodevBundlerProvider.Pimlico;\n * ```\n *\n * @see createKernelClientForWalletAccount\n * @see getZerodevRpc\n */\nexport const ZerodevBundlerProvider = SdkApiZerodevBundlerProvider;\nexport type ZerodevBundlerProvider = SdkApiZerodevBundlerProvider;\n\nexport const KERNEL_VERSION_MAP = {\n [ProviderKernelVersionEnum.V33]: constants.KERNEL_V3_3,\n [ProviderKernelVersionEnum.V32]: constants.KERNEL_V3_2,\n [ProviderKernelVersionEnum.V31]: constants.KERNEL_V3_1,\n [ProviderKernelVersionEnum.V30]: constants.KERNEL_V3_0,\n [ProviderKernelVersionEnum.V24]: constants.KERNEL_V2_4,\n} as const;\n\nexport const ENTRY_POINT_VERSION_MAP: Record<\n EntryPointVersion,\n KERNEL_VERSION_TYPE\n> = {\n 0.6: constants.KERNEL_V2_4,\n 0.7: constants.KERNEL_V3_1,\n 0.8: constants.KERNEL_V3_3,\n} as const;\n\nexport const ERC20_TRANSFER_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const;\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport { type Provider, ProviderEnum } from '@dynamic-labs/sdk-api-core';\n\n/** @notInstrumented */\nexport const getZerodevProviderFromSettings = (\n client: DynamicClient\n): Provider => {\n const projectSettings = client.projectSettings;\n\n assertDefined(projectSettings, 'Project settings are not available');\n\n const zerodevProvider = projectSettings.providers?.find(\n (provider) => provider.provider === ProviderEnum.Zerodev\n );\n\n assertDefined(\n zerodevProvider,\n 'Zerodev is not configured in project settings'\n );\n\n return zerodevProvider;\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport type { ProviderMultichainAccountAbstractionProviders } from '@dynamic-labs/sdk-api-core';\n\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\n\ntype GetZerodevChainProviderForNetworkIdProps = {\n networkId: string;\n};\n\n/** @notInstrumented */\nexport const getZerodevChainProviderForNetworkId = (\n { networkId }: GetZerodevChainProviderForNetworkIdProps,\n client: DynamicClient\n): ProviderMultichainAccountAbstractionProviders | undefined => {\n const zerodevProvider = getZerodevProviderFromSettings(client);\n\n return zerodevProvider.multichainAccountAbstractionProviders?.find(\n (provider) => provider.chain === networkId\n );\n};\n","import {\n NoSmartWalletAccountSignerFoundError,\n getOwnerWalletAccountForSmartWalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport { getDefaultClient } from '@dynamic-labs-sdk/client/core';\nimport {\n type EvmWalletAccount,\n isEvmWalletAccount,\n} from '@dynamic-labs-sdk/evm';\nimport { createWalletClientForWalletAccount } from '@dynamic-labs-sdk/evm/viem';\nimport type { Account, Chain, Transport, WalletClient } from 'viem';\n\ntype GetSignerForSmartWalletAccountParams = {\n smartWalletAccount: EvmWalletAccount;\n};\n\n/**\n * Gets a WalletClient instance for the EOA of the smart wallet account.\n * You can use this signer to sign EVM transactions.\n *\n * @example\n * ```ts\n * const signer = await getSignerForSmartWalletAccount({\n * smartWalletAccount: evmSmartWallet,\n * });\n * ```\n *\n * @param params.smartWalletAccount - The EVM smart wallet account to get the signer for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to a WalletClient instance.\n * @throws {NoSmartWalletAccountSignerFoundError} When the signer wallet account is not found for the given smart wallet account.\n * @see createKernelClientForWalletAccount\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const getSignerForSmartWalletAccount = (\n { smartWalletAccount }: GetSignerForSmartWalletAccountParams,\n client = getDefaultClient()\n): Promise<WalletClient<Transport, Chain, Account>> => {\n const signerWalletAccount = getOwnerWalletAccountForSmartWalletAccount(\n { smartWalletAccount },\n client\n );\n\n if (!signerWalletAccount || !isEvmWalletAccount(signerWalletAccount)) {\n throw new NoSmartWalletAccountSignerFoundError(smartWalletAccount.address);\n }\n\n return createWalletClientForWalletAccount(\n {\n walletAccount: signerWalletAccount,\n },\n client\n );\n};\n","import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator';\nimport { toMultiChainECDSAValidator } from '@zerodev/multi-chain-ecdsa-validator';\nimport type {\n EntryPointType,\n GetKernelVersion,\n Signer,\n} from '@zerodev/sdk/types';\nimport type { Client } from 'viem';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\nimport type { KernelValidator } from '@zerodev/sdk';\n\ntype GetEcdsaValidatorParams = {\n ecdsaProviderType?: string;\n entryPoint: EntryPointType<EntryPointVersion>;\n kernelVersion: GetKernelVersion<EntryPointVersion>;\n publicClient: Client;\n signer: Signer;\n};\n\ntype EcdsaValidator =\n | KernelValidator<'MultiChainECDSAValidator'>\n | KernelValidator<'ECDSAValidator'>;\n\n/** @notInstrumented */\nexport const getEcdsaValidator = ({\n ecdsaProviderType,\n publicClient,\n signer,\n entryPoint,\n kernelVersion,\n}: GetEcdsaValidatorParams): Promise<EcdsaValidator> => {\n const params = {\n entryPoint,\n kernelVersion,\n signer,\n };\n\n if (ecdsaProviderType === 'zerodev_multi_chain') {\n return toMultiChainECDSAValidator(publicClient, params);\n }\n\n return signerToEcdsaValidator(publicClient, params);\n};\n","import { ProviderEntryPointVersionEnum } from '@dynamic-labs/sdk-api-core';\nimport { constants } from '@zerodev/sdk';\n\ntype EntryPoint =\n | ReturnType<typeof constants.getEntryPoint<'0.6'>>\n | ReturnType<typeof constants.getEntryPoint<'0.7'>>;\n\n/** @notInstrumented */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const getEntryPoint = (entryPoint?: string): EntryPoint => {\n if (entryPoint === ProviderEntryPointVersionEnum.V6) {\n return constants.getEntryPoint('0.6');\n }\n\n // default to v7\n return constants.getEntryPoint('0.7');\n};\n","import type { ProviderKernelVersionEnum } from '@dynamic-labs/sdk-api-core';\nimport { constants } from '@zerodev/sdk';\nimport type { EntryPointType, KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\n\nimport { ENTRY_POINT_VERSION_MAP, KERNEL_VERSION_MAP } from '../../constants';\n\ntype GetKernelVersionParams = {\n entryPoint: EntryPointType<EntryPointVersion>;\n kernelVersion: ProviderKernelVersionEnum | undefined;\n};\n\n/** @notInstrumented */\nexport const getKernelVersion = ({\n kernelVersion,\n entryPoint,\n}: GetKernelVersionParams): KERNEL_VERSION_TYPE => {\n // If kernel version is explicitly provided, use it\n if (kernelVersion && kernelVersion in KERNEL_VERSION_MAP) {\n return KERNEL_VERSION_MAP[kernelVersion];\n }\n\n // If no kernel version provided, determine based on entry point version\n const entryPointVersion: keyof typeof ENTRY_POINT_VERSION_MAP =\n entryPoint.version;\n if (entryPointVersion in ENTRY_POINT_VERSION_MAP) {\n return ENTRY_POINT_VERSION_MAP[entryPointVersion];\n }\n\n // Fallback to latest version\n return constants.KERNEL_V3_3;\n};\n","import {\n type DynamicClient,\n type WalletAccount,\n getOwnerWalletAccountForSmartWalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\n\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\n\ntype ShouldUseEIP7702Params = {\n smartWalletAccount: WalletAccount;\n};\n\n/** @notInstrumented */\nexport const shouldUseEIP7702 = (\n { smartWalletAccount }: ShouldUseEIP7702Params,\n client: DynamicClient\n): boolean | undefined => {\n const zerodevProvider = getZerodevProviderFromSettings(client);\n\n assertDefined(\n zerodevProvider,\n 'Zerodev provider is not enabled in project settings'\n );\n\n const eoaWalletAccount = getOwnerWalletAccountForSmartWalletAccount(\n { smartWalletAccount },\n client\n );\n\n assertDefined(eoaWalletAccount, 'EOA wallet account is not found');\n\n return (\n zerodevProvider.enableEIP7702 &&\n // with EIP7702, the EOA wallet account address is the same as the smart wallet account address\n smartWalletAccount.address === eoaWalletAccount.address\n );\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getVerifiedCredentialForWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport { createEcdsaKernelMigrationAccount } from '@zerodev/ecdsa-validator';\nimport {\n type CreateKernelAccountReturnType,\n constants,\n createKernelAccount as createZerodevKernelAccount,\n} from '@zerodev/sdk';\nimport type { PublicClient } from 'viem';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\n\nimport { getSignerForSmartWalletAccount } from '../../getSignerForSmartWalletAccount';\nimport { getEcdsaValidator } from '../getEcdsaValidator';\nimport { getEntryPoint } from '../getEntryPoint';\nimport { getKernelVersion } from '../getKernelVersion';\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\nimport { shouldUseEIP7702 } from '../shouldUseEIP7702';\n\ntype CreateKernelAccountParams = {\n eip7702Auth?: SignAuthorizationReturnType;\n publicClient: PublicClient;\n smartWalletAccount: EvmWalletAccount;\n};\n\n/**\n * Creates a ZeroDev kernel account for a given smart wallet account.\n * This is a lower-level function used internally by createKernelClientForWalletAccount.\n *\n * @param params - The parameters for creating the kernel account.\n * @param params.publicClient - The viem public client to use for blockchain interactions.\n * @param params.smartWalletAccount - The EVM smart wallet account to create the kernel account for.\n * @param [params.eip7702Auth] - A pre-signed EIP-7702 authorization. When provided, this authorization is passed to the ZeroDev SDK instead of signing a new one internally. Useful for singleUse MFA flows.\n * @param client - The Dynamic client instance.\n * @returns A promise that resolves to a ZeroDev kernel account.\n * @notInstrumented\n */\nexport const createKernelAccount = async (\n { publicClient, smartWalletAccount, eip7702Auth }: CreateKernelAccountParams,\n client: DynamicClient\n): Promise<CreateKernelAccountReturnType<EntryPointVersion>> => {\n const zerodevProvider = getZerodevProviderFromSettings(client);\n\n assertDefined(\n zerodevProvider,\n 'Zerodev provider is not enabled in project settings'\n );\n\n const signer = await getSignerForSmartWalletAccount(\n {\n smartWalletAccount,\n },\n client\n );\n\n const walletProperties = getVerifiedCredentialForWalletAccount(\n { walletAccount: smartWalletAccount },\n client\n )?.walletProperties;\n\n const entryPointVersion =\n walletProperties?.entryPointVersion ?? zerodevProvider.entryPointVersion;\n const entryPoint = getEntryPoint(entryPointVersion);\n\n const useEIP7702 = shouldUseEIP7702({ smartWalletAccount }, client);\n\n if (useEIP7702) {\n return createZerodevKernelAccount(publicClient, {\n eip7702Account: signer,\n eip7702Auth,\n entryPoint,\n kernelVersion: constants.KERNEL_V3_3,\n });\n }\n\n const kernelVersionValue =\n walletProperties?.kernelVersion ?? zerodevProvider.kernelVersion;\n\n const kernelVersion = getKernelVersion({\n entryPoint,\n kernelVersion: kernelVersionValue,\n });\n\n const kernelV3MigrationEnabled =\n zerodevProvider.enableKernelV3Migration ?? false;\n\n if (kernelV3MigrationEnabled) {\n const apiKernelVersion = getKernelVersion({\n entryPoint,\n kernelVersion: zerodevProvider.kernelVersion,\n });\n\n return createEcdsaKernelMigrationAccount(publicClient, {\n entryPoint,\n migrationVersion: {\n from: kernelVersion,\n to: apiKernelVersion,\n },\n signer,\n });\n }\n\n const validator = await getEcdsaValidator({\n ecdsaProviderType:\n walletProperties?.ecdsaProviderType ?? zerodevProvider.ecdsaProviderType,\n entryPoint,\n kernelVersion,\n publicClient,\n signer,\n });\n\n return createZerodevKernelAccount(publicClient, {\n entryPoint,\n kernelVersion,\n plugins: {\n sudo: validator,\n },\n });\n};\n","import {\n type SponsorUserOperationReturnType,\n createZeroDevPaymasterClient,\n} from '@zerodev/sdk';\nimport type { Hex, Chain as ViemChain } from 'viem';\nimport { http } from 'viem';\nimport type { GetPaymasterDataParameters } from 'viem/account-abstraction';\n\ntype GetPaymasterConfigProps = {\n chain: ViemChain;\n /**\n * The address the ERC20 token to use for the paymaster.\n * If not provided, the paymaster will use the default gas token for the chain.\n */\n gasTokenAddress?: Hex;\n paymasterRpc: string;\n};\n\ntype PaymasterConfig = {\n paymaster: {\n getPaymasterData: (\n params: GetPaymasterDataParameters\n ) => Promise<SponsorUserOperationReturnType>;\n };\n};\n\n/** @notInstrumented */\nexport const getPaymasterConfig = ({\n chain,\n gasTokenAddress,\n paymasterRpc,\n}: GetPaymasterConfigProps): PaymasterConfig => {\n const getPaymasterData = (params: GetPaymasterDataParameters) => {\n const zerodevPaymaster = createZeroDevPaymasterClient({\n chain,\n transport: http(paymasterRpc),\n });\n\n return zerodevPaymaster.sponsorUserOperation({\n gasToken: gasTokenAddress,\n userOperation: params,\n });\n };\n\n return {\n paymaster: {\n getPaymasterData,\n },\n };\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\n\nimport {\n ZERODEV_RPC_BASE_URL,\n ZerodevBundlerProvider,\n} from '../../constants';\nimport { getZerodevChainProviderForNetworkId } from '../getZerodevChainProviderForNetworkId';\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\n\ntype GetZerodevRpcParams = {\n bundlerProvider?: ZerodevBundlerProvider;\n networkId: string;\n rpcType: 'paymaster' | 'bundler';\n};\n\n/** @notInstrumented */\nexport const getZerodevRpc = (\n { networkId, bundlerProvider, rpcType }: GetZerodevRpcParams,\n client: DynamicClient\n): string => {\n const zerodevProvider = getZerodevProviderFromSettings(client);\n\n if (zerodevProvider?.zerodevPaymasterRpcUrl) {\n return zerodevProvider.zerodevPaymasterRpcUrl;\n }\n\n const zerodevChainProvider = getZerodevChainProviderForNetworkId(\n { networkId },\n client\n );\n\n assertDefined(\n zerodevChainProvider,\n `No zerodev provider found for network id ${networkId}`\n );\n\n const paymasterProvider =\n bundlerProvider ??\n zerodevProvider.zerodevBundlerProvider ??\n ZerodevBundlerProvider.Pimlico;\n\n const paramName =\n rpcType === 'bundler' ? 'bundlerProvider' : 'paymasterProvider';\n\n return `${ZERODEV_RPC_BASE_URL}/${rpcType}/${zerodevChainProvider.clientId}?${paramName}=${paymasterProvider}`;\n};\n"],"mappings":";;;;;;;;;;;;;;;;ACSA,MAAa,mBAAmB;CAC9B,aAAa;CACb,MAAM,GAAGA,wDAA0B;CACnC,sBAAsB;CACvB;AAED,MAAa,uBAAuB;;;;;;;;;;;;AAapC,MAAa,yBAAyBC;AAGtC,MAAa,qBAAqB;EAC/BC,qDAA0B,MAAMC,uBAAU;EAC1CD,qDAA0B,MAAMC,uBAAU;EAC1CD,qDAA0B,MAAMC,uBAAU;EAC1CD,qDAA0B,MAAMC,uBAAU;EAC1CD,qDAA0B,MAAMC,uBAAU;CAC5C;AAED,MAAaC,0BAGT;CACF,IAAKD,uBAAU;CACf,IAAKA,uBAAU;CACf,IAAKA,uBAAU;CAChB;AAED,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qBAAqB;GAC3C,UAAU;GACV,eAAe;GAChB,CAAC;;AAGJ,QAAO,EACL,WAAW,EACT,kBACD,EACF;;;;;;AC/BH,MAAa,iBACX,EAAE,WAAW,iBAAiB,WAC9B,WACW;CACX,MAAM,kBAAkB,+BAA+B,OAAO;AAE9D,KAAI,iBAAiB,uBACnB,QAAO,gBAAgB;CAGzB,MAAM,uBAAuB,oCAC3B,EAAE,WAAW,EACb,OACD;AAED,kDACE,sBACA,4CAA4C,YAC7C;CAED,MAAM,oBACJ,mBACA,gBAAgB,0BAChB,uBAAuB;CAEzB,MAAM,YACJ,YAAY,YAAY,oBAAoB;AAE9C,QAAO,GAAG,qBAAqB,GAAG,QAAQ,GAAG,qBAAqB,SAAS,GAAG,UAAU,GAAG"}
|
|
@@ -10,7 +10,7 @@ import { toMultiChainECDSAValidator } from "@zerodev/multi-chain-ecdsa-validator
|
|
|
10
10
|
|
|
11
11
|
//#region package.json
|
|
12
12
|
var name = "@dynamic-labs-sdk/zerodev";
|
|
13
|
-
var version = "1.
|
|
13
|
+
var version = "1.30.3";
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/constants.ts
|
|
@@ -20,6 +20,18 @@ const ZERODEV_METADATA = {
|
|
|
20
20
|
normalizedWalletName: "zerodev"
|
|
21
21
|
};
|
|
22
22
|
const ZERODEV_RPC_BASE_URL = "https://rpc.zerodev.app/api/v2";
|
|
23
|
+
/**
|
|
24
|
+
* Identifies the provider used for ZeroDev bundler and paymaster requests.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const provider: ZerodevBundlerProvider = ZerodevBundlerProvider.Pimlico;
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @see createKernelClientForWalletAccount
|
|
32
|
+
* @see getZerodevRpc
|
|
33
|
+
*/
|
|
34
|
+
const ZerodevBundlerProvider$1 = ZerodevBundlerProvider;
|
|
23
35
|
const KERNEL_VERSION_MAP = {
|
|
24
36
|
[ProviderKernelVersionEnum.V33]: constants.KERNEL_V3_3,
|
|
25
37
|
[ProviderKernelVersionEnum.V32]: constants.KERNEL_V3_2,
|
|
@@ -214,11 +226,11 @@ const getZerodevRpc = ({ networkId, bundlerProvider, rpcType }, client) => {
|
|
|
214
226
|
if (zerodevProvider?.zerodevPaymasterRpcUrl) return zerodevProvider.zerodevPaymasterRpcUrl;
|
|
215
227
|
const zerodevChainProvider = getZerodevChainProviderForNetworkId({ networkId }, client);
|
|
216
228
|
assertDefined(zerodevChainProvider, `No zerodev provider found for network id ${networkId}`);
|
|
217
|
-
const paymasterProvider = bundlerProvider ?? zerodevProvider.zerodevBundlerProvider ?? ZerodevBundlerProvider.Pimlico;
|
|
229
|
+
const paymasterProvider = bundlerProvider ?? zerodevProvider.zerodevBundlerProvider ?? ZerodevBundlerProvider$1.Pimlico;
|
|
218
230
|
const paramName = rpcType === "bundler" ? "bundlerProvider" : "paymasterProvider";
|
|
219
231
|
return `${ZERODEV_RPC_BASE_URL}/${rpcType}/${zerodevChainProvider.clientId}?${paramName}=${paymasterProvider}`;
|
|
220
232
|
};
|
|
221
233
|
|
|
222
234
|
//#endregion
|
|
223
|
-
export { getKernelVersion as a, getSignerForSmartWalletAccount as c, ERC20_TRANSFER_ABI as d, ZERODEV_METADATA as f, shouldUseEIP7702 as i, getZerodevChainProviderForNetworkId as l,
|
|
224
|
-
//# sourceMappingURL=getZerodevRpc-
|
|
235
|
+
export { getKernelVersion as a, getSignerForSmartWalletAccount as c, ERC20_TRANSFER_ABI as d, ZERODEV_METADATA as f, version as h, shouldUseEIP7702 as i, getZerodevChainProviderForNetworkId as l, name as m, getPaymasterConfig as n, getEntryPoint as o, ZerodevBundlerProvider$1 as p, createKernelAccount$1 as r, getEcdsaValidator as s, getZerodevRpc as t, getZerodevProviderFromSettings as u };
|
|
236
|
+
//# sourceMappingURL=getZerodevRpc-DvZw2j1r.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getZerodevRpc-DvZw2j1r.esm.js","names":["ZerodevBundlerProvider","SdkApiZerodevBundlerProvider","ENTRY_POINT_VERSION_MAP: Record<\n EntryPointVersion,\n KERNEL_VERSION_TYPE\n>","entryPointVersion: keyof typeof ENTRY_POINT_VERSION_MAP","createKernelAccount","createZerodevKernelAccount","ZerodevBundlerProvider"],"sources":["../package.json","../src/constants.ts","../src/utils/getZerodevProviderFromSettings/getZerodevProviderFromSettings.ts","../src/utils/getZerodevChainProviderForNetworkId/getZerodevChainProviderForNetworkId.ts","../src/getSignerForSmartWalletAccount/getSignerForSmartWalletAccount.ts","../src/utils/getEcdsaValidator/getEcdsaValidator.ts","../src/utils/getEntryPoint/getEntryPoint.ts","../src/utils/getKernelVersion/getKernelVersion.ts","../src/utils/shouldUseEIP7702/shouldUseEIP7702.ts","../src/utils/createKernelAccount/createKernelAccount.ts","../src/utils/getPaymasterConfig/getPaymasterConfig.ts","../src/utils/getZerodevRpc/getZerodevRpc.ts"],"sourcesContent":["","import { DYNAMIC_ICONIC_SPRITE_URL } from '@dynamic-labs-sdk/client/core';\nimport {\n ProviderKernelVersionEnum,\n ZerodevBundlerProvider as SdkApiZerodevBundlerProvider,\n} from '@dynamic-labs/sdk-api-core';\nimport { constants } from '@zerodev/sdk';\nimport type { KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\n\nexport const ZERODEV_METADATA = {\n displayName: 'ZeroDev',\n icon: `${DYNAMIC_ICONIC_SPRITE_URL}#smartwallet`,\n normalizedWalletName: 'zerodev',\n};\n\nexport const ZERODEV_RPC_BASE_URL = 'https://rpc.zerodev.app/api/v2';\n\n/**\n * Identifies the provider used for ZeroDev bundler and paymaster requests.\n *\n * @example\n * ```ts\n * const provider: ZerodevBundlerProvider = ZerodevBundlerProvider.Pimlico;\n * ```\n *\n * @see createKernelClientForWalletAccount\n * @see getZerodevRpc\n */\nexport const ZerodevBundlerProvider = SdkApiZerodevBundlerProvider;\nexport type ZerodevBundlerProvider = SdkApiZerodevBundlerProvider;\n\nexport const KERNEL_VERSION_MAP = {\n [ProviderKernelVersionEnum.V33]: constants.KERNEL_V3_3,\n [ProviderKernelVersionEnum.V32]: constants.KERNEL_V3_2,\n [ProviderKernelVersionEnum.V31]: constants.KERNEL_V3_1,\n [ProviderKernelVersionEnum.V30]: constants.KERNEL_V3_0,\n [ProviderKernelVersionEnum.V24]: constants.KERNEL_V2_4,\n} as const;\n\nexport const ENTRY_POINT_VERSION_MAP: Record<\n EntryPointVersion,\n KERNEL_VERSION_TYPE\n> = {\n 0.6: constants.KERNEL_V2_4,\n 0.7: constants.KERNEL_V3_1,\n 0.8: constants.KERNEL_V3_3,\n} as const;\n\nexport const ERC20_TRANSFER_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const;\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport { type Provider, ProviderEnum } from '@dynamic-labs/sdk-api-core';\n\n/** @notInstrumented */\nexport const getZerodevProviderFromSettings = (\n client: DynamicClient\n): Provider => {\n const projectSettings = client.projectSettings;\n\n assertDefined(projectSettings, 'Project settings are not available');\n\n const zerodevProvider = projectSettings.providers?.find(\n (provider) => provider.provider === ProviderEnum.Zerodev\n );\n\n assertDefined(\n zerodevProvider,\n 'Zerodev is not configured in project settings'\n );\n\n return zerodevProvider;\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport type { ProviderMultichainAccountAbstractionProviders } from '@dynamic-labs/sdk-api-core';\n\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\n\ntype GetZerodevChainProviderForNetworkIdProps = {\n networkId: string;\n};\n\n/** @notInstrumented */\nexport const getZerodevChainProviderForNetworkId = (\n { networkId }: GetZerodevChainProviderForNetworkIdProps,\n client: DynamicClient\n): ProviderMultichainAccountAbstractionProviders | undefined => {\n const zerodevProvider = getZerodevProviderFromSettings(client);\n\n return zerodevProvider.multichainAccountAbstractionProviders?.find(\n (provider) => provider.chain === networkId\n );\n};\n","import {\n NoSmartWalletAccountSignerFoundError,\n getOwnerWalletAccountForSmartWalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport { getDefaultClient } from '@dynamic-labs-sdk/client/core';\nimport {\n type EvmWalletAccount,\n isEvmWalletAccount,\n} from '@dynamic-labs-sdk/evm';\nimport { createWalletClientForWalletAccount } from '@dynamic-labs-sdk/evm/viem';\nimport type { Account, Chain, Transport, WalletClient } from 'viem';\n\ntype GetSignerForSmartWalletAccountParams = {\n smartWalletAccount: EvmWalletAccount;\n};\n\n/**\n * Gets a WalletClient instance for the EOA of the smart wallet account.\n * You can use this signer to sign EVM transactions.\n *\n * @example\n * ```ts\n * const signer = await getSignerForSmartWalletAccount({\n * smartWalletAccount: evmSmartWallet,\n * });\n * ```\n *\n * @param params.smartWalletAccount - The EVM smart wallet account to get the signer for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to a WalletClient instance.\n * @throws {NoSmartWalletAccountSignerFoundError} When the signer wallet account is not found for the given smart wallet account.\n * @see createKernelClientForWalletAccount\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const getSignerForSmartWalletAccount = (\n { smartWalletAccount }: GetSignerForSmartWalletAccountParams,\n client = getDefaultClient()\n): Promise<WalletClient<Transport, Chain, Account>> => {\n const signerWalletAccount = getOwnerWalletAccountForSmartWalletAccount(\n { smartWalletAccount },\n client\n );\n\n if (!signerWalletAccount || !isEvmWalletAccount(signerWalletAccount)) {\n throw new NoSmartWalletAccountSignerFoundError(smartWalletAccount.address);\n }\n\n return createWalletClientForWalletAccount(\n {\n walletAccount: signerWalletAccount,\n },\n client\n );\n};\n","import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator';\nimport { toMultiChainECDSAValidator } from '@zerodev/multi-chain-ecdsa-validator';\nimport type {\n EntryPointType,\n GetKernelVersion,\n Signer,\n} from '@zerodev/sdk/types';\nimport type { Client } from 'viem';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\nimport type { KernelValidator } from '@zerodev/sdk';\n\ntype GetEcdsaValidatorParams = {\n ecdsaProviderType?: string;\n entryPoint: EntryPointType<EntryPointVersion>;\n kernelVersion: GetKernelVersion<EntryPointVersion>;\n publicClient: Client;\n signer: Signer;\n};\n\ntype EcdsaValidator =\n | KernelValidator<'MultiChainECDSAValidator'>\n | KernelValidator<'ECDSAValidator'>;\n\n/** @notInstrumented */\nexport const getEcdsaValidator = ({\n ecdsaProviderType,\n publicClient,\n signer,\n entryPoint,\n kernelVersion,\n}: GetEcdsaValidatorParams): Promise<EcdsaValidator> => {\n const params = {\n entryPoint,\n kernelVersion,\n signer,\n };\n\n if (ecdsaProviderType === 'zerodev_multi_chain') {\n return toMultiChainECDSAValidator(publicClient, params);\n }\n\n return signerToEcdsaValidator(publicClient, params);\n};\n","import { ProviderEntryPointVersionEnum } from '@dynamic-labs/sdk-api-core';\nimport { constants } from '@zerodev/sdk';\n\ntype EntryPoint =\n | ReturnType<typeof constants.getEntryPoint<'0.6'>>\n | ReturnType<typeof constants.getEntryPoint<'0.7'>>;\n\n/** @notInstrumented */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const getEntryPoint = (entryPoint?: string): EntryPoint => {\n if (entryPoint === ProviderEntryPointVersionEnum.V6) {\n return constants.getEntryPoint('0.6');\n }\n\n // default to v7\n return constants.getEntryPoint('0.7');\n};\n","import type { ProviderKernelVersionEnum } from '@dynamic-labs/sdk-api-core';\nimport { constants } from '@zerodev/sdk';\nimport type { EntryPointType, KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\n\nimport { ENTRY_POINT_VERSION_MAP, KERNEL_VERSION_MAP } from '../../constants';\n\ntype GetKernelVersionParams = {\n entryPoint: EntryPointType<EntryPointVersion>;\n kernelVersion: ProviderKernelVersionEnum | undefined;\n};\n\n/** @notInstrumented */\nexport const getKernelVersion = ({\n kernelVersion,\n entryPoint,\n}: GetKernelVersionParams): KERNEL_VERSION_TYPE => {\n // If kernel version is explicitly provided, use it\n if (kernelVersion && kernelVersion in KERNEL_VERSION_MAP) {\n return KERNEL_VERSION_MAP[kernelVersion];\n }\n\n // If no kernel version provided, determine based on entry point version\n const entryPointVersion: keyof typeof ENTRY_POINT_VERSION_MAP =\n entryPoint.version;\n if (entryPointVersion in ENTRY_POINT_VERSION_MAP) {\n return ENTRY_POINT_VERSION_MAP[entryPointVersion];\n }\n\n // Fallback to latest version\n return constants.KERNEL_V3_3;\n};\n","import {\n type DynamicClient,\n type WalletAccount,\n getOwnerWalletAccountForSmartWalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\n\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\n\ntype ShouldUseEIP7702Params = {\n smartWalletAccount: WalletAccount;\n};\n\n/** @notInstrumented */\nexport const shouldUseEIP7702 = (\n { smartWalletAccount }: ShouldUseEIP7702Params,\n client: DynamicClient\n): boolean | undefined => {\n const zerodevProvider = getZerodevProviderFromSettings(client);\n\n assertDefined(\n zerodevProvider,\n 'Zerodev provider is not enabled in project settings'\n );\n\n const eoaWalletAccount = getOwnerWalletAccountForSmartWalletAccount(\n { smartWalletAccount },\n client\n );\n\n assertDefined(eoaWalletAccount, 'EOA wallet account is not found');\n\n return (\n zerodevProvider.enableEIP7702 &&\n // with EIP7702, the EOA wallet account address is the same as the smart wallet account address\n smartWalletAccount.address === eoaWalletAccount.address\n );\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getVerifiedCredentialForWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport { createEcdsaKernelMigrationAccount } from '@zerodev/ecdsa-validator';\nimport {\n type CreateKernelAccountReturnType,\n constants,\n createKernelAccount as createZerodevKernelAccount,\n} from '@zerodev/sdk';\nimport type { PublicClient } from 'viem';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\n\nimport { getSignerForSmartWalletAccount } from '../../getSignerForSmartWalletAccount';\nimport { getEcdsaValidator } from '../getEcdsaValidator';\nimport { getEntryPoint } from '../getEntryPoint';\nimport { getKernelVersion } from '../getKernelVersion';\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\nimport { shouldUseEIP7702 } from '../shouldUseEIP7702';\n\ntype CreateKernelAccountParams = {\n eip7702Auth?: SignAuthorizationReturnType;\n publicClient: PublicClient;\n smartWalletAccount: EvmWalletAccount;\n};\n\n/**\n * Creates a ZeroDev kernel account for a given smart wallet account.\n * This is a lower-level function used internally by createKernelClientForWalletAccount.\n *\n * @param params - The parameters for creating the kernel account.\n * @param params.publicClient - The viem public client to use for blockchain interactions.\n * @param params.smartWalletAccount - The EVM smart wallet account to create the kernel account for.\n * @param [params.eip7702Auth] - A pre-signed EIP-7702 authorization. When provided, this authorization is passed to the ZeroDev SDK instead of signing a new one internally. Useful for singleUse MFA flows.\n * @param client - The Dynamic client instance.\n * @returns A promise that resolves to a ZeroDev kernel account.\n * @notInstrumented\n */\nexport const createKernelAccount = async (\n { publicClient, smartWalletAccount, eip7702Auth }: CreateKernelAccountParams,\n client: DynamicClient\n): Promise<CreateKernelAccountReturnType<EntryPointVersion>> => {\n const zerodevProvider = getZerodevProviderFromSettings(client);\n\n assertDefined(\n zerodevProvider,\n 'Zerodev provider is not enabled in project settings'\n );\n\n const signer = await getSignerForSmartWalletAccount(\n {\n smartWalletAccount,\n },\n client\n );\n\n const walletProperties = getVerifiedCredentialForWalletAccount(\n { walletAccount: smartWalletAccount },\n client\n )?.walletProperties;\n\n const entryPointVersion =\n walletProperties?.entryPointVersion ?? zerodevProvider.entryPointVersion;\n const entryPoint = getEntryPoint(entryPointVersion);\n\n const useEIP7702 = shouldUseEIP7702({ smartWalletAccount }, client);\n\n if (useEIP7702) {\n return createZerodevKernelAccount(publicClient, {\n eip7702Account: signer,\n eip7702Auth,\n entryPoint,\n kernelVersion: constants.KERNEL_V3_3,\n });\n }\n\n const kernelVersionValue =\n walletProperties?.kernelVersion ?? zerodevProvider.kernelVersion;\n\n const kernelVersion = getKernelVersion({\n entryPoint,\n kernelVersion: kernelVersionValue,\n });\n\n const kernelV3MigrationEnabled =\n zerodevProvider.enableKernelV3Migration ?? false;\n\n if (kernelV3MigrationEnabled) {\n const apiKernelVersion = getKernelVersion({\n entryPoint,\n kernelVersion: zerodevProvider.kernelVersion,\n });\n\n return createEcdsaKernelMigrationAccount(publicClient, {\n entryPoint,\n migrationVersion: {\n from: kernelVersion,\n to: apiKernelVersion,\n },\n signer,\n });\n }\n\n const validator = await getEcdsaValidator({\n ecdsaProviderType:\n walletProperties?.ecdsaProviderType ?? zerodevProvider.ecdsaProviderType,\n entryPoint,\n kernelVersion,\n publicClient,\n signer,\n });\n\n return createZerodevKernelAccount(publicClient, {\n entryPoint,\n kernelVersion,\n plugins: {\n sudo: validator,\n },\n });\n};\n","import {\n type SponsorUserOperationReturnType,\n createZeroDevPaymasterClient,\n} from '@zerodev/sdk';\nimport type { Hex, Chain as ViemChain } from 'viem';\nimport { http } from 'viem';\nimport type { GetPaymasterDataParameters } from 'viem/account-abstraction';\n\ntype GetPaymasterConfigProps = {\n chain: ViemChain;\n /**\n * The address the ERC20 token to use for the paymaster.\n * If not provided, the paymaster will use the default gas token for the chain.\n */\n gasTokenAddress?: Hex;\n paymasterRpc: string;\n};\n\ntype PaymasterConfig = {\n paymaster: {\n getPaymasterData: (\n params: GetPaymasterDataParameters\n ) => Promise<SponsorUserOperationReturnType>;\n };\n};\n\n/** @notInstrumented */\nexport const getPaymasterConfig = ({\n chain,\n gasTokenAddress,\n paymasterRpc,\n}: GetPaymasterConfigProps): PaymasterConfig => {\n const getPaymasterData = (params: GetPaymasterDataParameters) => {\n const zerodevPaymaster = createZeroDevPaymasterClient({\n chain,\n transport: http(paymasterRpc),\n });\n\n return zerodevPaymaster.sponsorUserOperation({\n gasToken: gasTokenAddress,\n userOperation: params,\n });\n };\n\n return {\n paymaster: {\n getPaymasterData,\n },\n };\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\n\nimport {\n ZERODEV_RPC_BASE_URL,\n ZerodevBundlerProvider,\n} from '../../constants';\nimport { getZerodevChainProviderForNetworkId } from '../getZerodevChainProviderForNetworkId';\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\n\ntype GetZerodevRpcParams = {\n bundlerProvider?: ZerodevBundlerProvider;\n networkId: string;\n rpcType: 'paymaster' | 'bundler';\n};\n\n/** @notInstrumented */\nexport const getZerodevRpc = (\n { networkId, bundlerProvider, rpcType }: GetZerodevRpcParams,\n client: DynamicClient\n): string => {\n const zerodevProvider = getZerodevProviderFromSettings(client);\n\n if (zerodevProvider?.zerodevPaymasterRpcUrl) {\n return zerodevProvider.zerodevPaymasterRpcUrl;\n }\n\n const zerodevChainProvider = getZerodevChainProviderForNetworkId(\n { networkId },\n client\n );\n\n assertDefined(\n zerodevChainProvider,\n `No zerodev provider found for network id ${networkId}`\n );\n\n const paymasterProvider =\n bundlerProvider ??\n zerodevProvider.zerodevBundlerProvider ??\n ZerodevBundlerProvider.Pimlico;\n\n const paramName =\n rpcType === 'bundler' ? 'bundlerProvider' : 'paymasterProvider';\n\n return `${ZERODEV_RPC_BASE_URL}/${rpcType}/${zerodevChainProvider.clientId}?${paramName}=${paymasterProvider}`;\n};\n"],"mappings":";;;;;;;;;;;;;;;;ACSA,MAAa,mBAAmB;CAC9B,aAAa;CACb,MAAM,GAAG,0BAA0B;CACnC,sBAAsB;CACvB;AAED,MAAa,uBAAuB;;;;;;;;;;;;AAapC,MAAaA,2BAAyBC;AAGtC,MAAa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A,oBAA2B,cAAc;EAC9C;EACA;EACA,SAAS,EACP,MAbc,MAAM,kBAAkB;GACxC,mBACE,kBAAkB,qBAAqB,gBAAgB;GACzD;GACA;GACA;GACA;GACD,CAAC,EAOC;EACF,CAAC;;;;;;AC9FJ,MAAa,sBAAsB,EACjC,OACA,iBACA,mBAC8C;CAC9C,MAAM,oBAAoB,WAAuC;AAM/D,SALyB,6BAA6B;GACpD;GACA,WAAW,KAAK,aAAa;GAC9B,CAAC,CAEsB,qBAAqB;GAC3C,UAAU;GACV,eAAe;GAChB,CAAC;;AAGJ,QAAO,EACL,WAAW,EACT,kBACD,EACF;;;;;;AC/BH,MAAa,iBACX,EAAE,WAAW,iBAAiB,WAC9B,WACW;CACX,MAAM,kBAAkB,+BAA+B,OAAO;AAE9D,KAAI,iBAAiB,uBACnB,QAAO,gBAAgB;CAGzB,MAAM,uBAAuB,oCAC3B,EAAE,WAAW,EACb,OACD;AAED,eACE,sBACA,4CAA4C,YAC7C;CAED,MAAM,oBACJ,mBACA,gBAAgB,0BAChBC,yBAAuB;CAEzB,MAAM,YACJ,YAAY,YAAY,oBAAoB;AAE9C,QAAO,GAAG,qBAAqB,GAAG,QAAQ,GAAG,qBAAqB,SAAS,GAAG,UAAU,GAAG"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_getZerodevRpc = require('./getZerodevRpc-
|
|
1
|
+
const require_getZerodevRpc = require('./getZerodevRpc-Dek-gVrN.cjs');
|
|
2
2
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
3
3
|
let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
|
|
4
4
|
let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
@@ -280,8 +280,8 @@ const addZerodevExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefau
|
|
|
280
280
|
//#endregion
|
|
281
281
|
//#region src/utils/prepareUserOperationFromCalls/prepareUserOperationFromCalls.ts
|
|
282
282
|
/**
|
|
283
|
-
* Prepares a user operation from an array of calls
|
|
284
|
-
*
|
|
283
|
+
* Prepares a user operation from an array of calls, handling both single and
|
|
284
|
+
* batch transactions
|
|
285
285
|
*
|
|
286
286
|
* @param params.kernelClient - The kernel client to use for preparing the user operation
|
|
287
287
|
* @param params.calls - Array of calls (can be single call or multiple calls)
|
|
@@ -674,6 +674,7 @@ const simulateZerodevUserOperation = async ({ walletAccount, userOperation, netw
|
|
|
674
674
|
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(require_getZerodevRpc.name, require_getZerodevRpc.version);
|
|
675
675
|
|
|
676
676
|
//#endregion
|
|
677
|
+
exports.ZerodevBundlerProvider = require_getZerodevRpc.ZerodevBundlerProvider;
|
|
677
678
|
exports.addZerodevExtension = addZerodevExtension;
|
|
678
679
|
exports.calculateFeeForUserOperation = calculateFeeForUserOperation;
|
|
679
680
|
exports.canSponsorUserOperation = canSponsorUserOperation;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["WalletProviderEnum","ZERODEV_METADATA","networkData: NetworkData | undefined","getZerodevRpc","createKernelAccount","getPaymasterConfig","shouldUseEIP7702","InvalidParamError","ERC20_TRANSFER_ABI","chain: Chain","WalletProviderEnum","ZERODEV_METADATA","signMessage","InvalidParamError","signMessageUtils","getZerodevChainProviderForNetworkId","UnrecognizedNetworkError","WalletProviderPriority","getSignerForSmartWalletAccount","networkData: NetworkData | undefined","constants","ZERODEV_METADATA","FeeEstimationFailedError","InvalidParamError","feeData: EvmSimulationResult['feeData']","FeeEstimationFailedError","SimulationFailedError","name","version"],"sources":["../src/utils/getAllUserZerodevAddresses/getAllUserZerodevAddresses.ts","../src/createKernelClientForWalletAccount/createKernelClientForWalletAccount.ts","../src/utils/shouldSignWithEoa/shouldSignWithEoa.ts","../src/utils/signMessage/signMessage.ts","../src/isGasSponsorshipError/isGasSponsorshipError.ts","../src/utils/zerodevTransferAmount/zerodevTransferAmount.ts","../src/utils/createZerodevWalletProvider/createZerodevWalletProvider.ts","../src/addZerodevExtension/addZerodevExtension.ts","../src/utils/prepareUserOperationFromCalls/prepareUserOperationFromCalls.ts","../src/canSponsorUserOperation/canSponsorUserOperation.ts","../src/utils/calculateGasForUserOperation/calculateGasForUserOperation.ts","../src/estimateUserOperationGas/estimateUserOperationGas.ts","../src/sendUserOperation/sendUserOperation.ts","../src/signEip7702Authorization/signEip7702Authorization.ts","../src/isZerodevWalletAccount/isZerodevWalletAccount.ts","../src/utils/calculateFeeForUserOperation/calculateFeeForUserOperation.ts","../src/utils/hasRequiredGasFields/hasRequiredGasFields.ts","../src/simulateZerodevUserOperation/simulateZerodevUserOperation.ts","../src/exports/index.ts"],"sourcesContent":["import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getChainFromVerifiedCredentialChain } from '@dynamic-labs-sdk/client/core';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { ZERODEV_METADATA } from '../../constants';\n\n/** @notInstrumented */\nexport const getAllUserZerodevAddresses = (client: DynamicClient): string[] => {\n const zerodevWalletCredentials =\n client.user?.verifiedCredentials.filter(\n (credential) =>\n credential.walletProvider === WalletProviderEnum.SmartContractWallet &&\n credential.walletName\n ?.toLowerCase()\n .startsWith(ZERODEV_METADATA.normalizedWalletName) &&\n credential.address &&\n credential.chain &&\n getChainFromVerifiedCredentialChain(credential.chain) === 'EVM'\n ) ?? [];\n\n const zerodevAddresses: string[] = zerodevWalletCredentials.map(\n // casting because we're already filtering out credentials without an address\n (credential) => credential.address as string\n );\n\n return zerodevAddresses;\n};\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { getActiveNetworkData } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getDefaultClient,\n getNetworkDataForNetworkId,\n} from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport { mapNetworkDataToViemChain } from '@dynamic-labs-sdk/evm/viem';\nimport type { ZerodevBundlerProvider } from '@dynamic-labs/sdk-api-core';\nimport {\n createKernelAccountClient,\n getUserOperationGasPrice,\n} from '@zerodev/sdk';\nimport type { Hex } from 'viem';\nimport { createPublicClient, http } from 'viem';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\n\nimport type { KernelClient } from '../KernelClient.types';\nimport { createKernelAccount } from '../utils/createKernelAccount';\nimport { getPaymasterConfig } from '../utils/getPaymasterConfig';\nimport { getZerodevRpc } from '../utils/getZerodevRpc';\n\nexport type Eip7702Authorization = SignAuthorizationReturnType;\n\ntype CreateKernelClientForWalletAccountParams = {\n bundlerProvider?: ZerodevBundlerProvider;\n bundlerRpc?: string;\n eip7702Auth?: SignAuthorizationReturnType;\n gasTokenAddress?: Hex;\n networkId?: string;\n paymasterRpc?: string;\n smartWalletAccount: EvmWalletAccount;\n withSponsorship?: boolean;\n};\n\n/**\n * Creates a KernelClient instance for a given smart wallet account.\n *\n * @example\n * ```ts\n * const kernelClient = await createKernelClientForWalletAccount({\n * smartWalletAccount: evmSmartWallet,\n * });\n * ```\n *\n * @param params.smartWalletAccount - The smart wallet account to create the KernelClient for.\n * @param [params.bundlerProvider] - A custom bundler provider to use.\n * @param [params.bundlerRpc] - A custom bundler RPC to use.\n * @param [params.networkId] - The network ID to use for the KernelClient.\n * @param [params.paymasterRpc] - A custom paymaster RPC to use.\n * @param [params.gasTokenAddress] - The address of a custom ERC20 token to use as a gas token.\n * @param [params.withSponsorship] - Whether to use sponsorship for the KernelClient or not (default is true).\n * @param [params.eip7702Auth] - A pre-signed EIP-7702 authorization for singleUse MFA flows.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to a KernelClient instance.\n * @throws {ValueMustBeDefinedError} If network data or a required wallet value is unavailable.\n * @see sendUserOperation\n * @see getSignerForSmartWalletAccount\n * @notInstrumented\n */\nexport const createKernelClientForWalletAccount = async (\n {\n smartWalletAccount,\n withSponsorship = true,\n bundlerProvider,\n networkId,\n bundlerRpc: bundlerRpcOverride,\n paymasterRpc: paymasterRpcOverride,\n gasTokenAddress,\n eip7702Auth,\n }: CreateKernelClientForWalletAccountParams,\n client = getDefaultClient()\n): Promise<KernelClient> => {\n let networkData: NetworkData | undefined;\n\n if (networkId) {\n networkData = getNetworkDataForNetworkId(\n { chain: 'EVM', networkId },\n client\n );\n\n assertDefined(\n networkData,\n `No network data found for specified network ID: ${networkId}. Make sure the network is enabled for your project.`\n );\n } else {\n const activeNetworkData = await getActiveNetworkData(\n { walletAccount: smartWalletAccount },\n client\n );\n\n networkData = activeNetworkData.networkData;\n\n assertDefined(\n networkData,\n `No active network data found for this wallet account.`\n );\n }\n\n const viemChain = mapNetworkDataToViemChain(networkData);\n\n const bundlerRpc =\n bundlerRpcOverride ??\n getZerodevRpc(\n {\n bundlerProvider,\n networkId: networkData.networkId,\n rpcType: 'bundler',\n },\n client\n );\n\n const bundlerTransport = http(bundlerRpc);\n\n const publicClient = createPublicClient({\n chain: viemChain,\n transport: bundlerTransport,\n });\n\n const account = await createKernelAccount(\n {\n eip7702Auth,\n publicClient,\n smartWalletAccount,\n },\n client\n );\n\n const paymasterRpc =\n paymasterRpcOverride ??\n getZerodevRpc(\n {\n bundlerProvider,\n networkId: networkData.networkId,\n rpcType: 'paymaster',\n },\n client\n );\n\n const paymasterConfig = withSponsorship\n ? getPaymasterConfig({\n chain: viemChain,\n gasTokenAddress,\n paymasterRpc,\n })\n : {};\n\n return createKernelAccountClient({\n account,\n bundlerTransport,\n chain: viemChain,\n client: publicClient,\n userOperation: {\n estimateFeesPerGas: async ({ bundlerClient }) =>\n getUserOperationGasPrice(bundlerClient),\n },\n ...paymasterConfig,\n });\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\n\nimport type { KernelClient } from '../../KernelClient.types';\nimport { shouldUseEIP7702 } from '../shouldUseEIP7702';\n\ntype ShouldSignWithEoaParams = {\n kernelClient: KernelClient;\n smartWalletAccount: EvmWalletAccount;\n};\n\n/** @notInstrumented */\nexport const shouldSignWithEoa = async (\n { kernelClient, smartWalletAccount }: ShouldSignWithEoaParams,\n client: DynamicClient\n) => {\n const useEIP7702 = shouldUseEIP7702({ smartWalletAccount }, client);\n\n if (!useEIP7702) {\n return false;\n }\n\n const isDeployed = await kernelClient.account.isDeployed();\n\n return !isDeployed;\n};\n","import {\n type DynamicClient,\n getOwnerWalletAccountForSmartWalletAccount,\n signMessage as signMessageWithWalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\n\nimport { createKernelClientForWalletAccount } from '../../createKernelClientForWalletAccount';\nimport { shouldSignWithEoa } from '../shouldSignWithEoa';\n\ntype SignMessageParams = {\n message: string;\n walletAccount: EvmWalletAccount;\n};\n\n/** @notInstrumented */\nexport const signMessage = async (\n { walletAccount, message }: SignMessageParams,\n client: DynamicClient\n): Promise<{ signature: string }> => {\n const kernelClient = await createKernelClientForWalletAccount(\n { smartWalletAccount: walletAccount },\n client\n );\n\n const shouldUseEoa = await shouldSignWithEoa(\n {\n kernelClient,\n smartWalletAccount: walletAccount,\n },\n client\n );\n\n if (shouldUseEoa) {\n const eoaWalletAccount = getOwnerWalletAccountForSmartWalletAccount(\n { smartWalletAccount: walletAccount },\n client\n );\n\n assertDefined(eoaWalletAccount, 'Eoa wallet account not found');\n\n const { signature } = await signMessageWithWalletAccount({\n message,\n walletAccount: eoaWalletAccount,\n });\n\n return { signature };\n }\n\n const signature = await kernelClient.signMessage({ message });\n return { signature };\n};\n","/**\n * Checks if an error is a ZeroDev gas sponsorship error, indicating the\n * user operation did not match any gas sponsoring policies.\n *\n * @example\n * ```ts\n * try {\n * await sendUserOperation({ walletAccount, calls });\n * } catch (err) {\n * if (isGasSponsorshipError(err)) {\n * // Handle missing sponsorship\n * }\n * }\n * ```\n *\n * @param err - The error to check.\n * @returns True if the error is a gas sponsorship policy mismatch, false otherwise.\n * @see canSponsorUserOperation\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const isGasSponsorshipError = (err: unknown): boolean => {\n const errorWithMessage = err as { message?: string } | undefined;\n\n return (\n errorWithMessage?.message?.includes(\n 'userOp did not match any gas sponsoring policies'\n ) || false\n );\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { InvalidParamError } from '@dynamic-labs-sdk/client';\nimport {\n type TransferAmountParams,\n parseAmountToSmallestUnit,\n} from '@dynamic-labs-sdk/client/core';\nimport { isEvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport type { Hex } from 'viem';\nimport { encodeFunctionData } from 'viem';\n\nimport { ERC20_TRANSFER_ABI } from '../../constants';\nimport { createKernelClientForWalletAccount } from '../../createKernelClientForWalletAccount';\nimport { isGasSponsorshipError } from '../../isGasSponsorshipError';\n\nconst EVM_NATIVE_DECIMALS = 18;\n\n/**\n * Transfers native ETH or an ERC-20 token via a ZeroDev smart wallet.\n *\n * Attempts with gas sponsorship first, then falls back to unsponsored\n * if the paymaster rejects.\n * @notInstrumented\n */\nexport const zerodevTransferAmount = async (\n { amount, recipient, token, walletAccount }: TransferAmountParams,\n client: DynamicClient\n): Promise<{ transactionHash: string }> => {\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account is not an EVM wallet account');\n }\n\n // eslint-disable-next-line custom-rules/require-single-object-param\n const sendTransaction = async (withSponsorship: boolean) => {\n const kernelClient = await createKernelClientForWalletAccount(\n { smartWalletAccount: walletAccount, withSponsorship },\n client\n );\n\n if (token?.address) {\n const smallestUnit = parseAmountToSmallestUnit({\n amount,\n decimals: token.decimals,\n });\n\n const data = encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n args: [recipient as Hex, smallestUnit],\n functionName: 'transfer',\n });\n\n return kernelClient.sendTransaction({\n data,\n to: token.address as Hex,\n });\n }\n\n const value = parseAmountToSmallestUnit({\n amount,\n decimals: EVM_NATIVE_DECIMALS,\n });\n\n return kernelClient.sendTransaction({\n to: recipient as Hex,\n value,\n });\n };\n\n try {\n const hash = await sendTransaction(true);\n\n return { transactionHash: hash };\n } catch (error) {\n if (!isGasSponsorshipError(error)) {\n throw error;\n }\n\n const hash = await sendTransaction(false);\n\n return { transactionHash: hash };\n }\n};\n","import {\n type Chain,\n type DynamicClient,\n InvalidParamError,\n UnrecognizedNetworkError,\n type WalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n formatWalletProviderGroupKey,\n formatWalletProviderKey,\n getActiveNetworkIdFromLastKnownRegistry,\n switchActiveNetworkInLastKnownRegistry,\n} from '@dynamic-labs-sdk/client/core';\nimport {\n type EvmWalletProvider,\n isEvmWalletAccount,\n} from '@dynamic-labs-sdk/evm';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { ZERODEV_METADATA } from '../../constants';\nimport { getAllUserZerodevAddresses } from '../getAllUserZerodevAddresses';\nimport { getZerodevChainProviderForNetworkId } from '../getZerodevChainProviderForNetworkId';\nimport { signMessage as signMessageUtils } from '../signMessage';\nimport { zerodevTransferAmount } from '../zerodevTransferAmount';\n\n/** @notInstrumented */\nexport const createZerodevWalletProvider = (\n client: DynamicClient\n): EvmWalletProvider => {\n const chain: Chain = 'EVM';\n const walletProviderType = WalletProviderEnum.SmartContractWallet;\n const key = formatWalletProviderKey({\n chain,\n displayName: ZERODEV_METADATA.displayName,\n walletProviderType,\n });\n\n const getActiveNetworkId = async () =>\n getActiveNetworkIdFromLastKnownRegistry({\n client,\n walletProviderKey: key,\n });\n\n const getConnectedAddresses = async () => {\n const zerodevAddresses = getAllUserZerodevAddresses(client);\n\n return {\n addresses: zerodevAddresses,\n };\n };\n\n const signMessage = async ({\n walletAccount,\n message,\n }: {\n message: string;\n walletAccount?: WalletAccount;\n }) => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError(`walletAccount is not an EVM wallet account`);\n }\n\n return signMessageUtils({ message, walletAccount }, client);\n };\n\n const switchActiveNetwork = async ({ networkId }: { networkId: string }) => {\n const isNetworkEnabled = getZerodevChainProviderForNetworkId(\n { networkId },\n client\n );\n\n if (!isNetworkEnabled) {\n throw new UnrecognizedNetworkError({\n networkId,\n originalError: null,\n walletProviderKey: key,\n });\n }\n\n return switchActiveNetworkInLastKnownRegistry({\n client,\n networkId,\n walletProviderKey: key,\n });\n };\n\n return {\n chain,\n getActiveNetworkId,\n getConnectedAddresses,\n groupKey: formatWalletProviderGroupKey(ZERODEV_METADATA.displayName),\n key,\n metadata: {\n displayName: ZERODEV_METADATA.displayName,\n icon: ZERODEV_METADATA.icon,\n },\n signMessage,\n switchActiveNetwork,\n transferAmount: (args) => zerodevTransferAmount(args, client),\n walletProviderType,\n };\n};\n","import {\n WalletProviderPriority,\n getDefaultClient,\n getWalletProviderRegistry,\n hasExtension,\n registerExtension,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { createZerodevWalletProvider } from '../utils/createZerodevWalletProvider';\n\nexport const ZERODEV_EXTENSION_KEY = 'zerodev';\n\n/**\n * Adds the ZeroDev extension to the Dynamic client.\n *\n * This extension enables Account Abstraction integration with ZeroDev.\n *\n * @example\n * ```ts\n * const client = createDynamicClient({ environmentId: 'env-123' });\n * addZerodevExtension(client);\n * ```\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns void\n * @see createKernelClientForWalletAccount\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const addZerodevExtension = (client = getDefaultClient()) => {\n if (hasExtension({ extensionKey: ZERODEV_EXTENSION_KEY }, client)) {\n return;\n }\n\n registerExtension({ extensionKey: ZERODEV_EXTENSION_KEY }, client);\n\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n const walletProvider = createZerodevWalletProvider(client);\n\n walletProviderRegistry.register({\n priority: WalletProviderPriority.WALLET_SDK,\n walletProvider,\n });\n};\n","import type { BatchCall } from '../../BatchCall.types';\nimport type { KernelClient } from '../../KernelClient.types';\n\nexport type PrepareUserOperationFromCallsParams = {\n calls: BatchCall[];\n kernelClient: KernelClient;\n};\n\n/**\n * Prepares a user operation from an array of calls\n * Replaces prepareUserOperationWithKernelClient to handle both single and batch transactions\n *\n * @param params.kernelClient - The kernel client to use for preparing the user operation\n * @param params.calls - Array of calls (can be single call or multiple calls)\n * @returns Promise resolving to the prepared user operation\n * @notInstrumented\n */\nexport const prepareUserOperationFromCalls = async ({\n kernelClient,\n calls,\n}: PrepareUserOperationFromCallsParams) => {\n // Normalize calls to ensure data field exists\n const normalizedCalls = calls.map((call) => ({\n data: call.data ?? '0x',\n to: call.to,\n value: call.value,\n }));\n\n const callData = await kernelClient.account.encodeCalls(normalizedCalls);\n\n return kernelClient.prepareUserOperation({\n callData,\n });\n};\n","import { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\n\nimport type { BatchCall } from '../BatchCall.types';\nimport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nimport type { KernelClient } from '../KernelClient.types';\nimport { prepareUserOperationFromCalls } from '../utils/prepareUserOperationFromCalls';\n\ntype CanSponsorUserOperationBaseParams = {\n calls: BatchCall[];\n};\n\ntype CanSponsorUserOperationWithWalletParams =\n CanSponsorUserOperationBaseParams & {\n kernelClient?: never;\n walletAccount: EvmWalletAccount;\n };\n\ntype CanSponsorUserOperationWithClientParams =\n CanSponsorUserOperationBaseParams & {\n kernelClient: KernelClient;\n walletAccount?: never;\n };\n\nexport type CanSponsorUserOperationParams =\n | CanSponsorUserOperationWithWalletParams\n | CanSponsorUserOperationWithClientParams;\n\n/**\n * Checks if a user operation can be sponsored by the paymaster.\n * Handles both single transactions and batch transactions.\n *\n * @example\n * ```ts\n * const canSponsor = await canSponsorUserOperation({\n * walletAccount: smartWallet,\n * calls: [{ to: '0x...', value: 0n, data: '0x' }],\n * });\n * ```\n *\n * @param params.calls - Array of calls (single call or multiple calls).\n * @param params.kernelClient - Optional kernel client with sponsorship configured.\n * @param params.walletAccount - The wallet account to use (required if kernelClient not provided).\n * @returns True if the user operation can be sponsored, false otherwise.\n * @throws {ValueMustBeDefinedError} If neither a wallet account nor kernel client is provided.\n * @see sendUserOperation\n * @see estimateUserOperationGas\n * @notInstrumented\n */\nexport const canSponsorUserOperation = async ({\n walletAccount,\n calls,\n kernelClient,\n}: CanSponsorUserOperationParams): Promise<boolean> => {\n let kernelClientToUse = kernelClient;\n\n if (!kernelClientToUse) {\n assertDefined(\n walletAccount,\n 'Please provide either a wallet account or a kernel client in the parameters'\n );\n\n kernelClientToUse = await createKernelClientForWalletAccount({\n smartWalletAccount: walletAccount,\n });\n }\n\n try {\n const sponsorResult = await prepareUserOperationFromCalls({\n calls,\n kernelClient: kernelClientToUse,\n });\n\n const hasPaymaster = sponsorResult.paymasterAndData !== '0x';\n\n return hasPaymaster;\n } catch {\n return false;\n }\n};\n","import type { UserOperation } from 'viem/account-abstraction';\n\ntype CalculateGasForUserOperationParams = {\n userOperationData: Pick<\n UserOperation,\n | 'callGasLimit'\n | 'verificationGasLimit'\n | 'preVerificationGas'\n | 'maxFeePerGas'\n >;\n};\n\n/** @notInstrumented */\nexport const calculateGasForUserOperation = ({\n userOperationData,\n}: CalculateGasForUserOperationParams): bigint => {\n // Sum all gas units\n const totalGasUnits =\n userOperationData.callGasLimit +\n userOperationData.verificationGasLimit +\n userOperationData.preVerificationGas;\n\n // Multiply by maxFeePerGas to get the total gas cost in wei\n const gasCost = totalGasUnits * userOperationData.maxFeePerGas;\n\n return gasCost;\n};\n","import type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\n\nimport type { BatchCall } from '../BatchCall.types';\nimport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nimport { calculateGasForUserOperation } from '../utils/calculateGasForUserOperation';\nimport { prepareUserOperationFromCalls } from '../utils/prepareUserOperationFromCalls';\n\nexport type EstimateUserOperationGasParams = {\n calls: BatchCall[];\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Estimates the total gas cost for a user operation with one or more calls.\n * Handles both single transactions and batch transactions.\n *\n * @example\n * ```ts\n * const gasEstimate = await estimateUserOperationGas({\n * walletAccount: smartWallet,\n * calls: [{ to: '0x...', value: 0n, data: '0x' }],\n * });\n * ```\n *\n * @param params.calls - Array of calls (single call or multiple calls).\n * @param params.walletAccount - The wallet account that will execute the user operation.\n * @returns The estimated gas cost in wei, or null if estimation fails.\n * @see sendUserOperation\n * @see canSponsorUserOperation\n * @notInstrumented\n */\nexport const estimateUserOperationGas = async ({\n walletAccount,\n calls,\n}: EstimateUserOperationGasParams): Promise<bigint | null> => {\n try {\n const kernelClientWithoutSponsorship =\n await createKernelClientForWalletAccount({\n smartWalletAccount: walletAccount,\n withSponsorship: false,\n });\n\n const unsponsoredUserOperation = await prepareUserOperationFromCalls({\n calls,\n kernelClient: kernelClientWithoutSponsorship,\n });\n\n return calculateGasForUserOperation({\n userOperationData: unsponsoredUserOperation,\n });\n } catch {\n return null;\n }\n};\n","import { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport type { UserOperationReceipt } from 'viem/account-abstraction';\n\nimport type { BatchCall } from '../BatchCall.types';\nimport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nimport type { KernelClient } from '../KernelClient.types';\nimport { prepareUserOperationFromCalls } from '../utils/prepareUserOperationFromCalls';\n\ntype SendUserOperationBaseParams = {\n calls: BatchCall[];\n};\n\ntype SendUserOperationWithWalletParams = SendUserOperationBaseParams & {\n kernelClient?: never;\n walletAccount: EvmWalletAccount;\n withSponsorship?: boolean;\n};\n\ntype SendUserOperationWithClientParams = SendUserOperationBaseParams & {\n kernelClient: KernelClient;\n walletAccount?: never;\n withSponsorship?: never;\n};\n\nexport type SendUserOperationParams =\n | SendUserOperationWithWalletParams\n | SendUserOperationWithClientParams;\n\n/**\n * Sends a user operation with one or more calls.\n * Handles both single transactions and batch transactions.\n *\n * @example\n * ```ts\n * const receipt = await sendUserOperation({\n * walletAccount: smartWallet,\n * calls: [{ to: '0x...', value: 0n, data: '0x' }],\n * });\n * ```\n *\n * @param params.calls - Array of calls (single call or multiple calls).\n * @param params.kernelClient - Optional pre-configured kernel client.\n * @param params.walletAccount - The wallet account to use (required if kernelClient not provided).\n * @param params.withSponsorship - Whether to use sponsorship (default: true, only used with walletAccount).\n * @returns Promise resolving to the UserOperation receipt.\n * @throws {ValueMustBeDefinedError} If neither a wallet account nor kernel client is provided.\n * @see createKernelClientForWalletAccount\n * @see canSponsorUserOperation\n * @notInstrumented\n */\nexport const sendUserOperation = async ({\n walletAccount,\n calls,\n kernelClient,\n withSponsorship = true,\n}: SendUserOperationParams): Promise<UserOperationReceipt> => {\n let kernelClientToUse = kernelClient;\n\n if (!kernelClientToUse) {\n assertDefined(\n walletAccount,\n 'Please provide either a wallet account or a kernel client in the parameters'\n );\n\n kernelClientToUse = await createKernelClientForWalletAccount({\n smartWalletAccount: walletAccount,\n withSponsorship,\n });\n }\n\n const userOperation = await prepareUserOperationFromCalls({\n calls,\n kernelClient: kernelClientToUse,\n });\n\n // Type cast needed: prepareUserOperation returns a fully prepared UserOperation with all fields,\n // but sendUserOperation's discriminated union types expect specific field combinations.\n // This is safe as the prepared operation is compatible at runtime.\n const userOperationHash = await kernelClientToUse.sendUserOperation(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n userOperation as any\n );\n\n return kernelClientToUse.waitForUserOperationReceipt({\n hash: userOperationHash,\n });\n};\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { getActiveNetworkData } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getDefaultClient,\n getNetworkDataForNetworkId,\n} from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport { mapNetworkDataToViemChain } from '@dynamic-labs-sdk/evm/viem';\nimport { constants } from '@zerodev/sdk';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\nimport { signAuthorization } from 'viem/actions';\n\nimport { getSignerForSmartWalletAccount } from '../getSignerForSmartWalletAccount';\n\nexport type SignEip7702AuthorizationParams = {\n networkId?: string;\n smartWalletAccount: EvmWalletAccount;\n};\n\n/**\n * Signs an EIP-7702 authorization for ZeroDev kernel delegation.\n *\n * This function creates a signed authorization that allows a wallet to delegate\n * its execution to the ZeroDev kernel contract. The signed authorization can then\n * be passed to `createKernelClientForWalletAccount` via the `eip7702Auth` parameter.\n *\n * @example\n * ```ts\n * const auth = await signEip7702Authorization({\n * smartWalletAccount: evmSmartWallet,\n * });\n * const kernelClient = await createKernelClientForWalletAccount({\n * smartWalletAccount: evmSmartWallet,\n * eip7702Auth: auth,\n * });\n * ```\n *\n * @param params.smartWalletAccount - The EVM smart wallet account to sign the authorization for.\n * @param [params.networkId] - The network ID to use for signing. If not provided, uses the wallet's active network.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the signed EIP-7702 authorization.\n * @throws {ValueMustBeDefinedError} If network data is unavailable for the smart wallet account.\n * @see createKernelClientForWalletAccount\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const signEip7702Authorization = async (\n { smartWalletAccount, networkId }: SignEip7702AuthorizationParams,\n client = getDefaultClient()\n): Promise<SignAuthorizationReturnType> => {\n const walletClient = await getSignerForSmartWalletAccount(\n { smartWalletAccount },\n client\n );\n\n let networkData: NetworkData | undefined;\n\n if (networkId) {\n networkData = getNetworkDataForNetworkId(\n { chain: 'EVM', networkId },\n client\n );\n\n assertDefined(\n networkData,\n `No network data found for specified network ID: ${networkId}. Make sure the network is enabled for your project.`\n );\n } else {\n const activeNetworkData = await getActiveNetworkData(\n { walletAccount: smartWalletAccount },\n client\n );\n\n networkData = activeNetworkData.networkData;\n\n assertDefined(\n networkData,\n 'No active network data found for this wallet account.'\n );\n }\n\n const viemChain = mapNetworkDataToViemChain(networkData);\n\n return signAuthorization(walletClient, {\n chainId: viemChain.id,\n contractAddress: constants.KERNEL_7702_DELEGATION_ADDRESS,\n });\n};\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport { ZERODEV_METADATA } from '../constants';\n\n/**\n * Type guard function to check if a wallet account is a Zerodev wallet account.\n *\n * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is a Zerodev wallet account, false otherwise.\n * @notInstrumented\n */\nexport const isZerodevWalletAccount = (\n walletAccount: WalletAccount\n): boolean => {\n return walletAccount.walletProviderKey.startsWith(\n ZERODEV_METADATA.normalizedWalletName\n );\n};\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { FeeEstimationFailedError } from '@dynamic-labs-sdk/client';\nimport type { EvmTransactionFeeData } from '@dynamic-labs-sdk/evm';\nimport { formatEther } from 'viem';\nimport type { UserOperation } from 'viem/account-abstraction';\n\nimport { calculateGasForUserOperation } from '../calculateGasForUserOperation';\n\ntype CalculateFeeForUserOperationParams = {\n nativeTokenPriceUsd?: number;\n networkData: NetworkData;\n userOperationData: Pick<\n UserOperation,\n | 'callGasLimit'\n | 'verificationGasLimit'\n | 'preVerificationGas'\n | 'maxFeePerGas'\n >;\n};\n\n/**\n * Calculates the estimated fee for a ZeroDev user operation.\n *\n * This function estimates the total gas cost for a user operation by summing\n * all gas components (call, verification, pre-verification) and multiplying\n * by the maximum fee per gas unit.\n *\n * @example\n * ```ts\n * const fee = calculateFeeForUserOperation({\n * userOperationData: userOp,\n * networkData,\n * nativeTokenPriceUsd: 2500,\n * });\n * ```\n *\n * @param params.userOperationData - The user operation data containing gas limits and fees.\n * @param params.networkData - Network configuration (not currently used but kept for consistency).\n * @param params.nativeTokenPriceUsd - Optional USD price of the native token for fee conversion.\n * @returns Fee data including gas estimates and human-readable amounts.\n * @throws {FeeEstimationFailedError} If fee calculation fails.\n * @see estimateUserOperationGas\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const calculateFeeForUserOperation = ({\n userOperationData,\n networkData: _networkData,\n nativeTokenPriceUsd,\n}: CalculateFeeForUserOperationParams): EvmTransactionFeeData => {\n try {\n // Calculate total gas cost in wei\n const nativeAmount = calculateGasForUserOperation({ userOperationData });\n\n // Calculate total gas units\n const gasEstimate =\n userOperationData.callGasLimit +\n userOperationData.verificationGasLimit +\n userOperationData.preVerificationGas;\n\n // Format to human-readable ETH\n const humanReadableAmount = formatEther(nativeAmount);\n\n // Calculate USD amount if price data available\n const usdAmount = nativeTokenPriceUsd\n ? (Number(humanReadableAmount) * nativeTokenPriceUsd).toFixed(2)\n : undefined;\n\n return {\n gasEstimate,\n humanReadableAmount,\n maxFeePerGas: userOperationData.maxFeePerGas,\n nativeAmount,\n usdAmount,\n };\n } catch (error) {\n throw new FeeEstimationFailedError({\n cause: error instanceof Error ? error : undefined,\n message: 'Failed to calculate user operation fee',\n });\n }\n};\n","import type { UserOperation } from 'viem/account-abstraction';\n\ntype UserOperationWithGasFields = Pick<\n UserOperation,\n | 'callGasLimit'\n | 'verificationGasLimit'\n | 'preVerificationGas'\n | 'maxFeePerGas'\n>;\n\n/**\n * Type guard to check if a partial user operation has all required gas fields.\n *\n * This function narrows the type of a Partial<UserOperation> to ensure it has\n * the required gas fields needed for fee calculation. Use this when you need to\n * validate that gas fields are present before performing fee calculations.\n *\n * @param userOperation - The partial user operation to check.\n * @returns True if all required gas fields are present, false otherwise.\n *\n * @example\n * ```typescript\n * if (hasRequiredGasFields(userOperation)) {\n * // TypeScript now knows these fields are defined\n * const fee = calculateFee({\n * callGasLimit: userOperation.callGasLimit,\n * maxFeePerGas: userOperation.maxFeePerGas,\n * preVerificationGas: userOperation.preVerificationGas,\n * verificationGasLimit: userOperation.verificationGasLimit,\n * });\n * }\n * ```\n * @notInstrumented\n */\nexport const hasRequiredGasFields = (\n userOperation: Partial<UserOperation>\n): userOperation is Partial<UserOperation> & UserOperationWithGasFields =>\n Boolean(\n userOperation.callGasLimit &&\n userOperation.verificationGasLimit &&\n userOperation.preVerificationGas &&\n userOperation.maxFeePerGas\n );\n","import {\n FeeEstimationFailedError,\n InvalidParamError,\n SimulationFailedError,\n getDefaultClient,\n getNetworksData,\n} from '@dynamic-labs-sdk/client';\nimport { createApiClient, getCore } from '@dynamic-labs-sdk/client/core';\nimport type {\n EvmSimulationResult,\n EvmWalletAccount,\n} from '@dynamic-labs-sdk/evm';\nimport { isEvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport type { UserOperation } from 'viem/account-abstraction';\n\nimport { canSponsorUserOperation } from '../canSponsorUserOperation';\nimport { isZerodevWalletAccount } from '../isZerodevWalletAccount';\nimport { calculateFeeForUserOperation } from '../utils/calculateFeeForUserOperation';\nimport { hasRequiredGasFields } from '../utils/hasRequiredGasFields';\n\ntype SimulateZerodevUserOperationParams = {\n entryPoint: string;\n includeFees?: boolean;\n networkId: string;\n userOperation: Partial<UserOperation>;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Simulates a ZeroDev user operation to preview its effects before execution.\n *\n * This function uses the Blockaid API to analyze the user operation and returns\n * information about asset transfers, security validation, and optionally fee estimates.\n * For account abstraction wallets, it also checks if gas sponsorship is available.\n *\n * **Important**: A successful simulation does not guarantee the user operation will succeed.\n * The simulation may succeed but indicate the operation would fail (e.g., due to\n * insufficient balance, reverted contract call). Check the `validation` field in the\n * result for potential issues.\n *\n * @example\n * ```ts\n * const result = await simulateZerodevUserOperation({\n * walletAccount: smartWallet,\n * userOperation,\n * networkId: '137',\n * entryPoint: '0x5FF1...A000',\n * });\n * ```\n *\n * @param params.walletAccount - The EVM smart wallet account that will execute the operation.\n * @param params.userOperation - The user operation to simulate.\n * @param params.networkId - The network ID where the operation will be executed (e.g., '137' for Polygon).\n * @param params.entryPoint - The entry point contract address for the user operation.\n * @param params.includeFees - Whether to calculate transaction fees (default: false).\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns Simulation result with asset diffs, security validation, and optional fee data.\n * @throws {InvalidParamError} If wallet account is not an EVM ZeroDev account or network ID is not configured.\n * @throws {SimulationFailedError} If the simulation API call fails.\n * @throws {FeeEstimationFailedError} If includeFees is true and fee calculation fails.\n * @see sendUserOperation\n * @see canSponsorUserOperation\n * @notInstrumented\n */\nexport const simulateZerodevUserOperation = async (\n {\n walletAccount,\n userOperation,\n networkId,\n entryPoint,\n includeFees = false,\n }: SimulateZerodevUserOperationParams,\n client = getDefaultClient()\n): Promise<EvmSimulationResult> => {\n // Validate wallet account type\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account must be an EVM wallet account');\n }\n\n if (!isZerodevWalletAccount(walletAccount)) {\n throw new InvalidParamError(\n 'Wallet account must be a ZeroDev wallet account'\n );\n }\n\n // Get network data for the specified network\n const networksData = getNetworksData(client);\n const networkData = networksData.find(\n (data) => data.networkId === networkId && data.chain === 'EVM'\n );\n\n if (!networkData) {\n throw new InvalidParamError(\n `Network with ID ${networkId} is not configured in project settings`\n );\n }\n\n try {\n // Create API client and call simulation endpoint\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n // Note: The API endpoint for user operations might be different\n // This implementation assumes simulateUserOp exists on the API client\n // If it doesn't exist, we may need to use simulateEVMTransaction instead\n const response = await apiClient.simulateUserOp({\n environmentId: core.environmentId,\n simulateUserOpRequest: {\n chainId: networkId,\n entryPoint,\n operation: {\n callData: userOperation.callData || '0x',\n callGasLimit: userOperation.callGasLimit?.toString() || '0',\n maxFeePerGas: userOperation.maxFeePerGas?.toString() || '0',\n maxPriorityFeePerGas:\n userOperation.maxPriorityFeePerGas?.toString() || '0',\n nonce: userOperation.nonce?.toString() || '0',\n preVerificationGas:\n userOperation.preVerificationGas?.toString() || '0',\n sender: userOperation.sender || '',\n signature: userOperation.signature || '0x',\n verificationGasLimit:\n userOperation.verificationGasLimit?.toString() || '0',\n },\n value: '0',\n },\n });\n\n // Calculate fees if requested\n let feeData: EvmSimulationResult['feeData'];\n\n if (includeFees) {\n // Check if the transaction can be sponsored\n const isSponsored =\n userOperation.callData &&\n userOperation.sender &&\n (await canSponsorUserOperation({\n calls: [\n {\n data: userOperation.callData,\n to: userOperation.sender as `0x${string}`,\n value: 0n,\n },\n ],\n walletAccount,\n }));\n\n if (isSponsored) {\n // Sponsored transaction - no fee for user\n feeData = {\n gasEstimate: 0n,\n humanReadableAmount: '0',\n nativeAmount: 0n,\n usdAmount: '0.00',\n };\n } else if (hasRequiredGasFields(userOperation)) {\n // User pays fee - calculate it\n feeData = calculateFeeForUserOperation({\n nativeTokenPriceUsd: response.priceData?.nativeTokenUsdPrice,\n networkData,\n userOperationData: {\n callGasLimit: userOperation.callGasLimit,\n maxFeePerGas: userOperation.maxFeePerGas,\n preVerificationGas: userOperation.preVerificationGas,\n verificationGasLimit: userOperation.verificationGasLimit,\n },\n });\n }\n }\n\n // Map API response to simulation result\n return {\n counterparties: response.counterparties,\n feeData,\n inAssets: response.inAssets || [],\n outAssets: response.outAssets || [],\n priceData: response.priceData,\n showTotalFiat: response.showTotalFiat,\n validation: response.validation\n ? {\n description: response.validation.description,\n reason: response.validation.reason,\n result: response.validation.result as\n | 'benign'\n | 'warning'\n | 'malicious',\n }\n : undefined,\n };\n } catch (error) {\n // Re-throw FeeEstimationFailedError as-is\n if (error instanceof FeeEstimationFailedError) {\n throw error;\n }\n\n throw new SimulationFailedError({\n cause: error instanceof Error ? error : undefined,\n message: 'Failed to simulate ZeroDev user operation',\n });\n }\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport { name, version } from '../../package.json';\n\nassertPackageVersion(name, version);\n\nexport { addZerodevExtension } from '../addZerodevExtension';\nexport type { BatchCall } from '../BatchCall.types';\nexport { canSponsorUserOperation } from '../canSponsorUserOperation';\nexport type { CanSponsorUserOperationParams } from '../canSponsorUserOperation';\nexport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nexport type { Eip7702Authorization } from '../createKernelClientForWalletAccount';\nexport { estimateUserOperationGas } from '../estimateUserOperationGas';\nexport type { EstimateUserOperationGasParams } from '../estimateUserOperationGas';\nexport { getSignerForSmartWalletAccount } from '../getSignerForSmartWalletAccount';\nexport { isGasSponsorshipError } from '../isGasSponsorshipError';\nexport type { KernelClient } from '../KernelClient.types';\nexport { sendUserOperation } from '../sendUserOperation';\nexport type { SendUserOperationParams } from '../sendUserOperation';\nexport { signEip7702Authorization } from '../signEip7702Authorization';\nexport { simulateZerodevUserOperation } from '../simulateZerodevUserOperation';\nexport { calculateFeeForUserOperation } from '../utils/calculateFeeForUserOperation';\n"],"mappings":";;;;;;;;;;;;;AAOA,MAAa,8BAA8B,WAAoC;AAkB7E,SAhBE,OAAO,MAAM,oBAAoB,QAC9B,eACC,WAAW,mBAAmBA,8CAAmB,uBACjD,WAAW,YACP,aAAa,CACd,WAAWC,uCAAiB,qBAAqB,IACpD,WAAW,WACX,WAAW,gFACyB,WAAW,MAAM,KAAK,MAC7D,IAAI,EAAE,EAEmD,KAEzD,eAAe,WAAW,QAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACsCH,MAAa,qCAAqC,OAChD,EACE,oBACA,kBAAkB,MAClB,iBACA,WACA,YAAY,oBACZ,cAAc,sBACd,iBACA,eAEF,8DAA2B,KACD;CAC1B,IAAIC;AAEJ,KAAI,WAAW;AACb,8EACE;GAAE,OAAO;GAAO;GAAW,EAC3B,OACD;AAED,mDACE,aACA,mDAAmD,UAAU,sDAC9D;QACI;AAML,iBAL0B,yDACxB,EAAE,eAAe,oBAAoB,EACrC,OACD,EAE+B;AAEhC,mDACE,aACA,wDACD;;CAGH,MAAM,sEAAsC,YAAY;CAaxD,MAAM,kCAVJ,sBACAC,oCACE;EACE;EACA,WAAW,YAAY;EACvB,SAAS;EACV,EACD,OACD,CAEsC;CAEzC,MAAM,4CAAkC;EACtC,OAAO;EACP,WAAW;EACZ,CAAC;CAEF,MAAM,UAAU,MAAMC,0CACpB;EACE;EACA;EACA;EACD,EACD,OACD;CAED,MAAM,eACJ,wBACAD,oCACE;EACE;EACA,WAAW,YAAY;EACvB,SAAS;EAC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AGF,IAAIC;AAEJ,MAAI,aAgBF;OAbE,cAAc,YACd,cAAc,UACb,MAAM,wBAAwB;IAC7B,OAAO,CACL;KACE,MAAM,cAAc;KACpB,IAAI,cAAc;KAClB,OAAO;KACR,CACF;IACD;IACD,CAAC,CAIF,WAAU;IACR,aAAa;IACb,qBAAqB;IACrB,cAAc;IACd,WAAW;IACZ;YACQ,qBAAqB,cAAc,CAE5C,WAAU,6BAA6B;IACrC,qBAAqB,SAAS,WAAW;IACzC;IACA,mBAAmB;KACjB,cAAc,cAAc;KAC5B,cAAc,cAAc;KAC5B,oBAAoB,cAAc;KAClC,sBAAsB,cAAc;KACrC;IACF,CAAC;;AAKN,SAAO;GACL,gBAAgB,SAAS;GACzB;GACA,UAAU,SAAS,YAAY,EAAE;GACjC,WAAW,SAAS,aAAa,EAAE;GACnC,WAAW,SAAS;GACpB,eAAe,SAAS;GACxB,YAAY,SAAS,aACjB;IACE,aAAa,SAAS,WAAW;IACjC,QAAQ,SAAS,WAAW;IAC5B,QAAQ,SAAS,WAAW;IAI7B,GACD;GACL;UACM,OAAO;AAEd,MAAI,iBAAiBC,kDACnB,OAAM;AAGR,QAAM,IAAIC,+CAAsB;GAC9B,OAAO,iBAAiB,QAAQ,QAAQ;GACxC,SAAS;GACV,CAAC;;;;;;mEClMeC,4BAAMC,8BAAQ"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["WalletProviderEnum","ZERODEV_METADATA","networkData: NetworkData | undefined","getZerodevRpc","createKernelAccount","getPaymasterConfig","shouldUseEIP7702","InvalidParamError","ERC20_TRANSFER_ABI","chain: Chain","WalletProviderEnum","ZERODEV_METADATA","signMessage","InvalidParamError","signMessageUtils","getZerodevChainProviderForNetworkId","UnrecognizedNetworkError","WalletProviderPriority","getSignerForSmartWalletAccount","networkData: NetworkData | undefined","constants","ZERODEV_METADATA","FeeEstimationFailedError","InvalidParamError","feeData: EvmSimulationResult['feeData']","FeeEstimationFailedError","SimulationFailedError","name","version"],"sources":["../src/utils/getAllUserZerodevAddresses/getAllUserZerodevAddresses.ts","../src/createKernelClientForWalletAccount/createKernelClientForWalletAccount.ts","../src/utils/shouldSignWithEoa/shouldSignWithEoa.ts","../src/utils/signMessage/signMessage.ts","../src/isGasSponsorshipError/isGasSponsorshipError.ts","../src/utils/zerodevTransferAmount/zerodevTransferAmount.ts","../src/utils/createZerodevWalletProvider/createZerodevWalletProvider.ts","../src/addZerodevExtension/addZerodevExtension.ts","../src/utils/prepareUserOperationFromCalls/prepareUserOperationFromCalls.ts","../src/canSponsorUserOperation/canSponsorUserOperation.ts","../src/utils/calculateGasForUserOperation/calculateGasForUserOperation.ts","../src/estimateUserOperationGas/estimateUserOperationGas.ts","../src/sendUserOperation/sendUserOperation.ts","../src/signEip7702Authorization/signEip7702Authorization.ts","../src/isZerodevWalletAccount/isZerodevWalletAccount.ts","../src/utils/calculateFeeForUserOperation/calculateFeeForUserOperation.ts","../src/utils/hasRequiredGasFields/hasRequiredGasFields.ts","../src/simulateZerodevUserOperation/simulateZerodevUserOperation.ts","../src/exports/index.ts"],"sourcesContent":["import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getChainFromVerifiedCredentialChain } from '@dynamic-labs-sdk/client/core';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { ZERODEV_METADATA } from '../../constants';\n\n/** @notInstrumented */\nexport const getAllUserZerodevAddresses = (client: DynamicClient): string[] => {\n const zerodevWalletCredentials =\n client.user?.verifiedCredentials.filter(\n (credential) =>\n credential.walletProvider === WalletProviderEnum.SmartContractWallet &&\n credential.walletName\n ?.toLowerCase()\n .startsWith(ZERODEV_METADATA.normalizedWalletName) &&\n credential.address &&\n credential.chain &&\n getChainFromVerifiedCredentialChain(credential.chain) === 'EVM'\n ) ?? [];\n\n const zerodevAddresses: string[] = zerodevWalletCredentials.map(\n // casting because we're already filtering out credentials without an address\n (credential) => credential.address as string\n );\n\n return zerodevAddresses;\n};\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { getActiveNetworkData } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getDefaultClient,\n getNetworkDataForNetworkId,\n} from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport { mapNetworkDataToViemChain } from '@dynamic-labs-sdk/evm/viem';\nimport {\n createKernelAccountClient,\n getUserOperationGasPrice,\n} from '@zerodev/sdk';\nimport type { Hex } from 'viem';\nimport { createPublicClient, http } from 'viem';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\n\nimport type { KernelClient } from '../KernelClient.types';\nimport type { ZerodevBundlerProvider } from '../constants';\nimport { createKernelAccount } from '../utils/createKernelAccount';\nimport { getPaymasterConfig } from '../utils/getPaymasterConfig';\nimport { getZerodevRpc } from '../utils/getZerodevRpc';\n\nexport type Eip7702Authorization = SignAuthorizationReturnType;\n\ntype CreateKernelClientForWalletAccountParams = {\n bundlerProvider?: ZerodevBundlerProvider;\n bundlerRpc?: string;\n eip7702Auth?: SignAuthorizationReturnType;\n gasTokenAddress?: Hex;\n networkId?: string;\n paymasterRpc?: string;\n smartWalletAccount: EvmWalletAccount;\n withSponsorship?: boolean;\n};\n\n/**\n * Creates a KernelClient instance for a given smart wallet account.\n *\n * @example\n * ```ts\n * const kernelClient = await createKernelClientForWalletAccount({\n * smartWalletAccount: evmSmartWallet,\n * });\n * ```\n *\n * @param params.smartWalletAccount - The smart wallet account to create the KernelClient for.\n * @param [params.bundlerProvider] - A custom bundler provider to use.\n * @param [params.bundlerRpc] - A custom bundler RPC to use.\n * @param [params.networkId] - The network ID to use for the KernelClient.\n * @param [params.paymasterRpc] - A custom paymaster RPC to use.\n * @param [params.gasTokenAddress] - The address of a custom ERC20 token to use as a gas token.\n * @param [params.withSponsorship] - Whether to use sponsorship for the KernelClient or not (default is true).\n * @param [params.eip7702Auth] - A pre-signed EIP-7702 authorization for singleUse MFA flows.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to a KernelClient instance.\n * @throws {ValueMustBeDefinedError} If network data or a required wallet value is unavailable.\n * @see sendUserOperation\n * @see getSignerForSmartWalletAccount\n * @notInstrumented\n */\nexport const createKernelClientForWalletAccount = async (\n {\n smartWalletAccount,\n withSponsorship = true,\n bundlerProvider,\n networkId,\n bundlerRpc: bundlerRpcOverride,\n paymasterRpc: paymasterRpcOverride,\n gasTokenAddress,\n eip7702Auth,\n }: CreateKernelClientForWalletAccountParams,\n client = getDefaultClient()\n): Promise<KernelClient> => {\n let networkData: NetworkData | undefined;\n\n if (networkId) {\n networkData = getNetworkDataForNetworkId(\n { chain: 'EVM', networkId },\n client\n );\n\n assertDefined(\n networkData,\n `No network data found for specified network ID: ${networkId}. Make sure the network is enabled for your project.`\n );\n } else {\n const activeNetworkData = await getActiveNetworkData(\n { walletAccount: smartWalletAccount },\n client\n );\n\n networkData = activeNetworkData.networkData;\n\n assertDefined(\n networkData,\n `No active network data found for this wallet account.`\n );\n }\n\n const viemChain = mapNetworkDataToViemChain(networkData);\n\n const bundlerRpc =\n bundlerRpcOverride ??\n getZerodevRpc(\n {\n bundlerProvider,\n networkId: networkData.networkId,\n rpcType: 'bundler',\n },\n client\n );\n\n const bundlerTransport = http(bundlerRpc);\n\n const publicClient = createPublicClient({\n chain: viemChain,\n transport: bundlerTransport,\n });\n\n const account = await createKernelAccount(\n {\n eip7702Auth,\n publicClient,\n smartWalletAccount,\n },\n client\n );\n\n const paymasterRpc =\n paymasterRpcOverride ??\n getZerodevRpc(\n {\n bundlerProvider,\n networkId: networkData.networkId,\n rpcType: 'paymaster',\n },\n client\n );\n\n const paymasterConfig = withSponsorship\n ? getPaymasterConfig({\n chain: viemChain,\n gasTokenAddress,\n paymasterRpc,\n })\n : {};\n\n return createKernelAccountClient({\n account,\n bundlerTransport,\n chain: viemChain,\n client: publicClient,\n userOperation: {\n estimateFeesPerGas: async ({ bundlerClient }) =>\n getUserOperationGasPrice(bundlerClient),\n },\n ...paymasterConfig,\n });\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\n\nimport type { KernelClient } from '../../KernelClient.types';\nimport { shouldUseEIP7702 } from '../shouldUseEIP7702';\n\ntype ShouldSignWithEoaParams = {\n kernelClient: KernelClient;\n smartWalletAccount: EvmWalletAccount;\n};\n\n/** @notInstrumented */\nexport const shouldSignWithEoa = async (\n { kernelClient, smartWalletAccount }: ShouldSignWithEoaParams,\n client: DynamicClient\n): Promise<boolean> => {\n const useEIP7702 = shouldUseEIP7702({ smartWalletAccount }, client);\n\n if (!useEIP7702) {\n return false;\n }\n\n const isDeployed = await kernelClient.account.isDeployed();\n\n return !isDeployed;\n};\n","import {\n type DynamicClient,\n getOwnerWalletAccountForSmartWalletAccount,\n signMessage as signMessageWithWalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\n\nimport { createKernelClientForWalletAccount } from '../../createKernelClientForWalletAccount';\nimport { shouldSignWithEoa } from '../shouldSignWithEoa';\n\ntype SignMessageParams = {\n message: string;\n walletAccount: EvmWalletAccount;\n};\n\ntype SignMessageResult = { signature: string };\n\n/** @notInstrumented */\nexport const signMessage = async (\n { walletAccount, message }: SignMessageParams,\n client: DynamicClient\n): Promise<SignMessageResult> => {\n const kernelClient = await createKernelClientForWalletAccount(\n { smartWalletAccount: walletAccount },\n client\n );\n\n const shouldUseEoa = await shouldSignWithEoa(\n {\n kernelClient,\n smartWalletAccount: walletAccount,\n },\n client\n );\n\n if (shouldUseEoa) {\n const eoaWalletAccount = getOwnerWalletAccountForSmartWalletAccount(\n { smartWalletAccount: walletAccount },\n client\n );\n\n assertDefined(eoaWalletAccount, 'Eoa wallet account not found');\n\n const { signature } = await signMessageWithWalletAccount({\n message,\n walletAccount: eoaWalletAccount,\n });\n\n return { signature };\n }\n\n const signature = await kernelClient.signMessage({ message });\n return { signature };\n};\n","/**\n * Checks if an error is a ZeroDev gas sponsorship error, indicating the\n * user operation did not match any gas sponsoring policies.\n *\n * @example\n * ```ts\n * try {\n * await sendUserOperation({ walletAccount, calls });\n * } catch (err) {\n * if (isGasSponsorshipError(err)) {\n * // Handle missing sponsorship\n * }\n * }\n * ```\n *\n * @param err - The error to check.\n * @returns True if the error is a gas sponsorship policy mismatch, false otherwise.\n * @see canSponsorUserOperation\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const isGasSponsorshipError = (err: unknown): boolean => {\n const errorWithMessage = err as { message?: string } | undefined;\n\n return (\n errorWithMessage?.message?.includes(\n 'userOp did not match any gas sponsoring policies'\n ) || false\n );\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { InvalidParamError } from '@dynamic-labs-sdk/client';\nimport {\n type TransferAmountParams,\n parseAmountToSmallestUnit,\n} from '@dynamic-labs-sdk/client/core';\nimport { isEvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport type { Hex } from 'viem';\nimport { encodeFunctionData } from 'viem';\n\nimport { ERC20_TRANSFER_ABI } from '../../constants';\nimport { createKernelClientForWalletAccount } from '../../createKernelClientForWalletAccount';\nimport { isGasSponsorshipError } from '../../isGasSponsorshipError';\n\nconst EVM_NATIVE_DECIMALS = 18;\n\ntype ZerodevTransferAmountResult = { transactionHash: string };\n\n/**\n * Transfers native ETH or an ERC-20 token via a ZeroDev smart wallet.\n *\n * Attempts with gas sponsorship first, then falls back to unsponsored\n * if the paymaster rejects.\n * @notInstrumented\n */\nexport const zerodevTransferAmount = async (\n { amount, recipient, token, walletAccount }: TransferAmountParams,\n client: DynamicClient\n): Promise<ZerodevTransferAmountResult> => {\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account is not an EVM wallet account');\n }\n\n // eslint-disable-next-line custom-rules/require-single-object-param\n const sendTransaction = async (withSponsorship: boolean) => {\n const kernelClient = await createKernelClientForWalletAccount(\n { smartWalletAccount: walletAccount, withSponsorship },\n client\n );\n\n if (token?.address) {\n const smallestUnit = parseAmountToSmallestUnit({\n amount,\n decimals: token.decimals,\n });\n\n const data = encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n args: [recipient as Hex, smallestUnit],\n functionName: 'transfer',\n });\n\n return kernelClient.sendTransaction({\n data,\n to: token.address as Hex,\n });\n }\n\n const value = parseAmountToSmallestUnit({\n amount,\n decimals: EVM_NATIVE_DECIMALS,\n });\n\n return kernelClient.sendTransaction({\n to: recipient as Hex,\n value,\n });\n };\n\n try {\n const hash = await sendTransaction(true);\n\n return { transactionHash: hash };\n } catch (error) {\n if (!isGasSponsorshipError(error)) {\n throw error;\n }\n\n const hash = await sendTransaction(false);\n\n return { transactionHash: hash };\n }\n};\n","import {\n type Chain,\n type DynamicClient,\n InvalidParamError,\n UnrecognizedNetworkError,\n type WalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n formatWalletProviderGroupKey,\n formatWalletProviderKey,\n getActiveNetworkIdFromLastKnownRegistry,\n switchActiveNetworkInLastKnownRegistry,\n} from '@dynamic-labs-sdk/client/core';\nimport {\n type EvmWalletProvider,\n isEvmWalletAccount,\n} from '@dynamic-labs-sdk/evm';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { ZERODEV_METADATA } from '../../constants';\nimport { getAllUserZerodevAddresses } from '../getAllUserZerodevAddresses';\nimport { getZerodevChainProviderForNetworkId } from '../getZerodevChainProviderForNetworkId';\nimport { signMessage as signMessageUtils } from '../signMessage';\nimport { zerodevTransferAmount } from '../zerodevTransferAmount';\n\n/** @notInstrumented */\nexport const createZerodevWalletProvider = (\n client: DynamicClient\n): EvmWalletProvider => {\n const chain: Chain = 'EVM';\n const walletProviderType = WalletProviderEnum.SmartContractWallet;\n const key = formatWalletProviderKey({\n chain,\n displayName: ZERODEV_METADATA.displayName,\n walletProviderType,\n });\n\n const getActiveNetworkId = async () =>\n getActiveNetworkIdFromLastKnownRegistry({\n client,\n walletProviderKey: key,\n });\n\n const getConnectedAddresses = async () => {\n const zerodevAddresses = getAllUserZerodevAddresses(client);\n\n return {\n addresses: zerodevAddresses,\n };\n };\n\n const signMessage = async ({\n walletAccount,\n message,\n }: {\n message: string;\n walletAccount?: WalletAccount;\n }) => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError(`walletAccount is not an EVM wallet account`);\n }\n\n return signMessageUtils({ message, walletAccount }, client);\n };\n\n const switchActiveNetwork = async ({ networkId }: { networkId: string }) => {\n const isNetworkEnabled = getZerodevChainProviderForNetworkId(\n { networkId },\n client\n );\n\n if (!isNetworkEnabled) {\n throw new UnrecognizedNetworkError({\n networkId,\n originalError: null,\n walletProviderKey: key,\n });\n }\n\n return switchActiveNetworkInLastKnownRegistry({\n client,\n networkId,\n walletProviderKey: key,\n });\n };\n\n return {\n chain,\n getActiveNetworkId,\n getConnectedAddresses,\n groupKey: formatWalletProviderGroupKey(ZERODEV_METADATA.displayName),\n key,\n metadata: {\n displayName: ZERODEV_METADATA.displayName,\n icon: ZERODEV_METADATA.icon,\n },\n signMessage,\n switchActiveNetwork,\n transferAmount: (args) => zerodevTransferAmount(args, client),\n walletProviderType,\n };\n};\n","import {\n WalletProviderPriority,\n getDefaultClient,\n getWalletProviderRegistry,\n hasExtension,\n registerExtension,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { createZerodevWalletProvider } from '../utils/createZerodevWalletProvider';\n\nexport const ZERODEV_EXTENSION_KEY = 'zerodev';\n\n/**\n * Adds the ZeroDev extension to the Dynamic client.\n *\n * This extension enables Account Abstraction integration with ZeroDev.\n *\n * @example\n * ```ts\n * const client = createDynamicClient({ environmentId: 'env-123' });\n * addZerodevExtension(client);\n * ```\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns void\n * @see createKernelClientForWalletAccount\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const addZerodevExtension = (client = getDefaultClient()): void => {\n if (hasExtension({ extensionKey: ZERODEV_EXTENSION_KEY }, client)) {\n return;\n }\n\n registerExtension({ extensionKey: ZERODEV_EXTENSION_KEY }, client);\n\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n const walletProvider = createZerodevWalletProvider(client);\n\n walletProviderRegistry.register({\n priority: WalletProviderPriority.WALLET_SDK,\n walletProvider,\n });\n};\n","import type { BatchCall } from '../../BatchCall.types';\nimport type { KernelClient } from '../../KernelClient.types';\n\nexport type PrepareUserOperationFromCallsParams = {\n calls: BatchCall[];\n kernelClient: KernelClient;\n};\n\ntype PreparedUserOperation = Awaited<\n ReturnType<KernelClient['prepareUserOperation']>\n>;\n\n/**\n * Prepares a user operation from an array of calls, handling both single and\n * batch transactions\n *\n * @param params.kernelClient - The kernel client to use for preparing the user operation\n * @param params.calls - Array of calls (can be single call or multiple calls)\n * @returns Promise resolving to the prepared user operation\n * @notInstrumented\n */\nexport const prepareUserOperationFromCalls = async ({\n kernelClient,\n calls,\n}: PrepareUserOperationFromCallsParams): Promise<PreparedUserOperation> => {\n // Normalize calls to ensure data field exists\n const normalizedCalls = calls.map((call) => ({\n data: call.data ?? '0x',\n to: call.to,\n value: call.value,\n }));\n\n const callData = await kernelClient.account.encodeCalls(normalizedCalls);\n\n return kernelClient.prepareUserOperation({\n callData,\n });\n};\n","import { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\n\nimport type { BatchCall } from '../BatchCall.types';\nimport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nimport type { KernelClient } from '../KernelClient.types';\nimport { prepareUserOperationFromCalls } from '../utils/prepareUserOperationFromCalls';\n\ntype CanSponsorUserOperationBaseParams = {\n calls: BatchCall[];\n};\n\ntype CanSponsorUserOperationWithWalletParams =\n CanSponsorUserOperationBaseParams & {\n kernelClient?: never;\n walletAccount: EvmWalletAccount;\n };\n\ntype CanSponsorUserOperationWithClientParams =\n CanSponsorUserOperationBaseParams & {\n kernelClient: KernelClient;\n walletAccount?: never;\n };\n\nexport type CanSponsorUserOperationParams =\n | CanSponsorUserOperationWithWalletParams\n | CanSponsorUserOperationWithClientParams;\n\n/**\n * Checks if a user operation can be sponsored by the paymaster.\n * Handles both single transactions and batch transactions.\n *\n * @example\n * ```ts\n * const canSponsor = await canSponsorUserOperation({\n * walletAccount: smartWallet,\n * calls: [{ to: '0x...', value: 0n, data: '0x' }],\n * });\n * ```\n *\n * @param params.calls - Array of calls (single call or multiple calls).\n * @param params.kernelClient - Optional kernel client with sponsorship configured.\n * @param params.walletAccount - The wallet account to use (required if kernelClient not provided).\n * @returns True if the user operation can be sponsored, false otherwise.\n * @throws {ValueMustBeDefinedError} If neither a wallet account nor kernel client is provided.\n * @see sendUserOperation\n * @see estimateUserOperationGas\n * @notInstrumented\n */\nexport const canSponsorUserOperation = async ({\n walletAccount,\n calls,\n kernelClient,\n}: CanSponsorUserOperationParams): Promise<boolean> => {\n let kernelClientToUse = kernelClient;\n\n if (!kernelClientToUse) {\n assertDefined(\n walletAccount,\n 'Please provide either a wallet account or a kernel client in the parameters'\n );\n\n kernelClientToUse = await createKernelClientForWalletAccount({\n smartWalletAccount: walletAccount,\n });\n }\n\n try {\n const sponsorResult = await prepareUserOperationFromCalls({\n calls,\n kernelClient: kernelClientToUse,\n });\n\n const hasPaymaster = sponsorResult.paymasterAndData !== '0x';\n\n return hasPaymaster;\n } catch {\n return false;\n }\n};\n","import type { UserOperation } from 'viem/account-abstraction';\n\ntype CalculateGasForUserOperationParams = {\n userOperationData: Pick<\n UserOperation,\n | 'callGasLimit'\n | 'verificationGasLimit'\n | 'preVerificationGas'\n | 'maxFeePerGas'\n >;\n};\n\n/** @notInstrumented */\nexport const calculateGasForUserOperation = ({\n userOperationData,\n}: CalculateGasForUserOperationParams): bigint => {\n // Sum all gas units\n const totalGasUnits =\n userOperationData.callGasLimit +\n userOperationData.verificationGasLimit +\n userOperationData.preVerificationGas;\n\n // Multiply by maxFeePerGas to get the total gas cost in wei\n const gasCost = totalGasUnits * userOperationData.maxFeePerGas;\n\n return gasCost;\n};\n","import type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\n\nimport type { BatchCall } from '../BatchCall.types';\nimport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nimport { calculateGasForUserOperation } from '../utils/calculateGasForUserOperation';\nimport { prepareUserOperationFromCalls } from '../utils/prepareUserOperationFromCalls';\n\nexport type EstimateUserOperationGasParams = {\n calls: BatchCall[];\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Estimates the total gas cost for a user operation with one or more calls.\n * Handles both single transactions and batch transactions.\n *\n * @example\n * ```ts\n * const gasEstimate = await estimateUserOperationGas({\n * walletAccount: smartWallet,\n * calls: [{ to: '0x...', value: 0n, data: '0x' }],\n * });\n * ```\n *\n * @param params.calls - Array of calls (single call or multiple calls).\n * @param params.walletAccount - The wallet account that will execute the user operation.\n * @returns The estimated gas cost in wei, or null if estimation fails.\n * @see sendUserOperation\n * @see canSponsorUserOperation\n * @notInstrumented\n */\nexport const estimateUserOperationGas = async ({\n walletAccount,\n calls,\n}: EstimateUserOperationGasParams): Promise<bigint | null> => {\n try {\n const kernelClientWithoutSponsorship =\n await createKernelClientForWalletAccount({\n smartWalletAccount: walletAccount,\n withSponsorship: false,\n });\n\n const unsponsoredUserOperation = await prepareUserOperationFromCalls({\n calls,\n kernelClient: kernelClientWithoutSponsorship,\n });\n\n return calculateGasForUserOperation({\n userOperationData: unsponsoredUserOperation,\n });\n } catch {\n return null;\n }\n};\n","import { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport type { UserOperationReceipt } from 'viem/account-abstraction';\n\nimport type { BatchCall } from '../BatchCall.types';\nimport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nimport type { KernelClient } from '../KernelClient.types';\nimport { prepareUserOperationFromCalls } from '../utils/prepareUserOperationFromCalls';\n\ntype SendUserOperationBaseParams = {\n calls: BatchCall[];\n};\n\ntype SendUserOperationWithWalletParams = SendUserOperationBaseParams & {\n kernelClient?: never;\n walletAccount: EvmWalletAccount;\n withSponsorship?: boolean;\n};\n\ntype SendUserOperationWithClientParams = SendUserOperationBaseParams & {\n kernelClient: KernelClient;\n walletAccount?: never;\n withSponsorship?: never;\n};\n\nexport type SendUserOperationParams =\n | SendUserOperationWithWalletParams\n | SendUserOperationWithClientParams;\n\n/**\n * Sends a user operation with one or more calls.\n * Handles both single transactions and batch transactions.\n *\n * @example\n * ```ts\n * const receipt = await sendUserOperation({\n * walletAccount: smartWallet,\n * calls: [{ to: '0x...', value: 0n, data: '0x' }],\n * });\n * ```\n *\n * @param params.calls - Array of calls (single call or multiple calls).\n * @param params.kernelClient - Optional pre-configured kernel client.\n * @param params.walletAccount - The wallet account to use (required if kernelClient not provided).\n * @param params.withSponsorship - Whether to use sponsorship (default: true, only used with walletAccount).\n * @returns Promise resolving to the UserOperation receipt.\n * @throws {ValueMustBeDefinedError} If neither a wallet account nor kernel client is provided.\n * @see createKernelClientForWalletAccount\n * @see canSponsorUserOperation\n * @notInstrumented\n */\nexport const sendUserOperation = async ({\n walletAccount,\n calls,\n kernelClient,\n withSponsorship = true,\n}: SendUserOperationParams): Promise<UserOperationReceipt> => {\n let kernelClientToUse = kernelClient;\n\n if (!kernelClientToUse) {\n assertDefined(\n walletAccount,\n 'Please provide either a wallet account or a kernel client in the parameters'\n );\n\n kernelClientToUse = await createKernelClientForWalletAccount({\n smartWalletAccount: walletAccount,\n withSponsorship,\n });\n }\n\n const userOperation = await prepareUserOperationFromCalls({\n calls,\n kernelClient: kernelClientToUse,\n });\n\n // Type cast needed: prepareUserOperation returns a fully prepared UserOperation with all fields,\n // but sendUserOperation's discriminated union types expect specific field combinations.\n // This is safe as the prepared operation is compatible at runtime.\n const userOperationHash = await kernelClientToUse.sendUserOperation(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n userOperation as any\n );\n\n return kernelClientToUse.waitForUserOperationReceipt({\n hash: userOperationHash,\n });\n};\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { getActiveNetworkData } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getDefaultClient,\n getNetworkDataForNetworkId,\n} from '@dynamic-labs-sdk/client/core';\nimport type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport { mapNetworkDataToViemChain } from '@dynamic-labs-sdk/evm/viem';\nimport { constants } from '@zerodev/sdk';\nimport type { SignAuthorizationReturnType } from 'viem/accounts';\nimport { signAuthorization } from 'viem/actions';\n\nimport { getSignerForSmartWalletAccount } from '../getSignerForSmartWalletAccount';\n\nexport type SignEip7702AuthorizationParams = {\n networkId?: string;\n smartWalletAccount: EvmWalletAccount;\n};\n\n/**\n * Signs an EIP-7702 authorization for ZeroDev kernel delegation.\n *\n * This function creates a signed authorization that allows a wallet to delegate\n * its execution to the ZeroDev kernel contract. The signed authorization can then\n * be passed to `createKernelClientForWalletAccount` via the `eip7702Auth` parameter.\n *\n * @example\n * ```ts\n * const auth = await signEip7702Authorization({\n * smartWalletAccount: evmSmartWallet,\n * });\n * const kernelClient = await createKernelClientForWalletAccount({\n * smartWalletAccount: evmSmartWallet,\n * eip7702Auth: auth,\n * });\n * ```\n *\n * @param params.smartWalletAccount - The EVM smart wallet account to sign the authorization for.\n * @param [params.networkId] - The network ID to use for signing. If not provided, uses the wallet's active network.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the signed EIP-7702 authorization.\n * @throws {ValueMustBeDefinedError} If network data is unavailable for the smart wallet account.\n * @see createKernelClientForWalletAccount\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const signEip7702Authorization = async (\n { smartWalletAccount, networkId }: SignEip7702AuthorizationParams,\n client = getDefaultClient()\n): Promise<SignAuthorizationReturnType> => {\n const walletClient = await getSignerForSmartWalletAccount(\n { smartWalletAccount },\n client\n );\n\n let networkData: NetworkData | undefined;\n\n if (networkId) {\n networkData = getNetworkDataForNetworkId(\n { chain: 'EVM', networkId },\n client\n );\n\n assertDefined(\n networkData,\n `No network data found for specified network ID: ${networkId}. Make sure the network is enabled for your project.`\n );\n } else {\n const activeNetworkData = await getActiveNetworkData(\n { walletAccount: smartWalletAccount },\n client\n );\n\n networkData = activeNetworkData.networkData;\n\n assertDefined(\n networkData,\n 'No active network data found for this wallet account.'\n );\n }\n\n const viemChain = mapNetworkDataToViemChain(networkData);\n\n return signAuthorization(walletClient, {\n chainId: viemChain.id,\n contractAddress: constants.KERNEL_7702_DELEGATION_ADDRESS,\n });\n};\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport { ZERODEV_METADATA } from '../constants';\n\n/**\n * Type guard function to check if a wallet account is a Zerodev wallet account.\n *\n * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is a Zerodev wallet account, false otherwise.\n * @notInstrumented\n */\nexport const isZerodevWalletAccount = (\n walletAccount: WalletAccount\n): boolean => {\n return walletAccount.walletProviderKey.startsWith(\n ZERODEV_METADATA.normalizedWalletName\n );\n};\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { FeeEstimationFailedError } from '@dynamic-labs-sdk/client';\nimport type { EvmTransactionFeeData } from '@dynamic-labs-sdk/evm';\nimport { formatEther } from 'viem';\nimport type { UserOperation } from 'viem/account-abstraction';\n\nimport { calculateGasForUserOperation } from '../calculateGasForUserOperation';\n\ntype CalculateFeeForUserOperationParams = {\n nativeTokenPriceUsd?: number;\n networkData: NetworkData;\n userOperationData: Pick<\n UserOperation,\n | 'callGasLimit'\n | 'verificationGasLimit'\n | 'preVerificationGas'\n | 'maxFeePerGas'\n >;\n};\n\n/**\n * Calculates the estimated fee for a ZeroDev user operation.\n *\n * This function estimates the total gas cost for a user operation by summing\n * all gas components (call, verification, pre-verification) and multiplying\n * by the maximum fee per gas unit.\n *\n * @example\n * ```ts\n * const fee = calculateFeeForUserOperation({\n * userOperationData: userOp,\n * networkData,\n * nativeTokenPriceUsd: 2500,\n * });\n * ```\n *\n * @param params.userOperationData - The user operation data containing gas limits and fees.\n * @param params.networkData - Network configuration (not currently used but kept for consistency).\n * @param params.nativeTokenPriceUsd - Optional USD price of the native token for fee conversion.\n * @returns Fee data including gas estimates and human-readable amounts.\n * @throws {FeeEstimationFailedError} If fee calculation fails.\n * @see estimateUserOperationGas\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const calculateFeeForUserOperation = ({\n userOperationData,\n networkData: _networkData,\n nativeTokenPriceUsd,\n}: CalculateFeeForUserOperationParams): EvmTransactionFeeData => {\n try {\n // Calculate total gas cost in wei\n const nativeAmount = calculateGasForUserOperation({ userOperationData });\n\n // Calculate total gas units\n const gasEstimate =\n userOperationData.callGasLimit +\n userOperationData.verificationGasLimit +\n userOperationData.preVerificationGas;\n\n // Format to human-readable ETH\n const humanReadableAmount = formatEther(nativeAmount);\n\n // Calculate USD amount if price data available\n const usdAmount = nativeTokenPriceUsd\n ? (Number(humanReadableAmount) * nativeTokenPriceUsd).toFixed(2)\n : undefined;\n\n return {\n gasEstimate,\n humanReadableAmount,\n maxFeePerGas: userOperationData.maxFeePerGas,\n nativeAmount,\n usdAmount,\n };\n } catch (error) {\n throw new FeeEstimationFailedError({\n cause: error instanceof Error ? error : undefined,\n message: 'Failed to calculate user operation fee',\n });\n }\n};\n","import type { UserOperation } from 'viem/account-abstraction';\n\ntype UserOperationWithGasFields = Pick<\n UserOperation,\n | 'callGasLimit'\n | 'verificationGasLimit'\n | 'preVerificationGas'\n | 'maxFeePerGas'\n>;\n\n/**\n * Type guard to check if a partial user operation has all required gas fields.\n *\n * This function narrows the type of a Partial<UserOperation> to ensure it has\n * the required gas fields needed for fee calculation. Use this when you need to\n * validate that gas fields are present before performing fee calculations.\n *\n * @param userOperation - The partial user operation to check.\n * @returns True if all required gas fields are present, false otherwise.\n *\n * @example\n * ```typescript\n * if (hasRequiredGasFields(userOperation)) {\n * // TypeScript now knows these fields are defined\n * const fee = calculateFee({\n * callGasLimit: userOperation.callGasLimit,\n * maxFeePerGas: userOperation.maxFeePerGas,\n * preVerificationGas: userOperation.preVerificationGas,\n * verificationGasLimit: userOperation.verificationGasLimit,\n * });\n * }\n * ```\n * @notInstrumented\n */\nexport const hasRequiredGasFields = (\n userOperation: Partial<UserOperation>\n): userOperation is Partial<UserOperation> & UserOperationWithGasFields =>\n Boolean(\n userOperation.callGasLimit &&\n userOperation.verificationGasLimit &&\n userOperation.preVerificationGas &&\n userOperation.maxFeePerGas\n );\n","import {\n FeeEstimationFailedError,\n InvalidParamError,\n SimulationFailedError,\n getDefaultClient,\n getNetworksData,\n} from '@dynamic-labs-sdk/client';\nimport { createApiClient, getCore } from '@dynamic-labs-sdk/client/core';\nimport type {\n EvmSimulationResult,\n EvmWalletAccount,\n} from '@dynamic-labs-sdk/evm';\nimport { isEvmWalletAccount } from '@dynamic-labs-sdk/evm';\nimport type { UserOperation } from 'viem/account-abstraction';\n\nimport { canSponsorUserOperation } from '../canSponsorUserOperation';\nimport { isZerodevWalletAccount } from '../isZerodevWalletAccount';\nimport { calculateFeeForUserOperation } from '../utils/calculateFeeForUserOperation';\nimport { hasRequiredGasFields } from '../utils/hasRequiredGasFields';\n\ntype SimulateZerodevUserOperationParams = {\n entryPoint: string;\n includeFees?: boolean;\n networkId: string;\n userOperation: Partial<UserOperation>;\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Simulates a ZeroDev user operation to preview its effects before execution.\n *\n * This function uses the Blockaid API to analyze the user operation and returns\n * information about asset transfers, security validation, and optionally fee estimates.\n * For account abstraction wallets, it also checks if gas sponsorship is available.\n *\n * **Important**: A successful simulation does not guarantee the user operation will succeed.\n * The simulation may succeed but indicate the operation would fail (e.g., due to\n * insufficient balance, reverted contract call). Check the `validation` field in the\n * result for potential issues.\n *\n * @example\n * ```ts\n * const result = await simulateZerodevUserOperation({\n * walletAccount: smartWallet,\n * userOperation,\n * networkId: '137',\n * entryPoint: '0x5FF1...A000',\n * });\n * ```\n *\n * @param params.walletAccount - The EVM smart wallet account that will execute the operation.\n * @param params.userOperation - The user operation to simulate.\n * @param params.networkId - The network ID where the operation will be executed (e.g., '137' for Polygon).\n * @param params.entryPoint - The entry point contract address for the user operation.\n * @param params.includeFees - Whether to calculate transaction fees (default: false).\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns Simulation result with asset diffs, security validation, and optional fee data.\n * @throws {InvalidParamError} If wallet account is not an EVM ZeroDev account or network ID is not configured.\n * @throws {SimulationFailedError} If the simulation API call fails.\n * @throws {FeeEstimationFailedError} If includeFees is true and fee calculation fails.\n * @see sendUserOperation\n * @see canSponsorUserOperation\n * @notInstrumented\n */\nexport const simulateZerodevUserOperation = async (\n {\n walletAccount,\n userOperation,\n networkId,\n entryPoint,\n includeFees = false,\n }: SimulateZerodevUserOperationParams,\n client = getDefaultClient()\n): Promise<EvmSimulationResult> => {\n // Validate wallet account type\n if (!isEvmWalletAccount(walletAccount)) {\n throw new InvalidParamError('Wallet account must be an EVM wallet account');\n }\n\n if (!isZerodevWalletAccount(walletAccount)) {\n throw new InvalidParamError(\n 'Wallet account must be a ZeroDev wallet account'\n );\n }\n\n // Get network data for the specified network\n const networksData = getNetworksData(client);\n const networkData = networksData.find(\n (data) => data.networkId === networkId && data.chain === 'EVM'\n );\n\n if (!networkData) {\n throw new InvalidParamError(\n `Network with ID ${networkId} is not configured in project settings`\n );\n }\n\n try {\n // Create API client and call simulation endpoint\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n // Note: The API endpoint for user operations might be different\n // This implementation assumes simulateUserOp exists on the API client\n // If it doesn't exist, we may need to use simulateEVMTransaction instead\n const response = await apiClient.simulateUserOp({\n environmentId: core.environmentId,\n simulateUserOpRequest: {\n chainId: networkId,\n entryPoint,\n operation: {\n callData: userOperation.callData || '0x',\n callGasLimit: userOperation.callGasLimit?.toString() || '0',\n maxFeePerGas: userOperation.maxFeePerGas?.toString() || '0',\n maxPriorityFeePerGas:\n userOperation.maxPriorityFeePerGas?.toString() || '0',\n nonce: userOperation.nonce?.toString() || '0',\n preVerificationGas:\n userOperation.preVerificationGas?.toString() || '0',\n sender: userOperation.sender || '',\n signature: userOperation.signature || '0x',\n verificationGasLimit:\n userOperation.verificationGasLimit?.toString() || '0',\n },\n value: '0',\n },\n });\n\n // Calculate fees if requested\n let feeData: EvmSimulationResult['feeData'];\n\n if (includeFees) {\n // Check if the transaction can be sponsored\n const isSponsored =\n userOperation.callData &&\n userOperation.sender &&\n (await canSponsorUserOperation({\n calls: [\n {\n data: userOperation.callData,\n to: userOperation.sender as `0x${string}`,\n value: 0n,\n },\n ],\n walletAccount,\n }));\n\n if (isSponsored) {\n // Sponsored transaction - no fee for user\n feeData = {\n gasEstimate: 0n,\n humanReadableAmount: '0',\n nativeAmount: 0n,\n usdAmount: '0.00',\n };\n } else if (hasRequiredGasFields(userOperation)) {\n // User pays fee - calculate it\n feeData = calculateFeeForUserOperation({\n nativeTokenPriceUsd: response.priceData?.nativeTokenUsdPrice,\n networkData,\n userOperationData: {\n callGasLimit: userOperation.callGasLimit,\n maxFeePerGas: userOperation.maxFeePerGas,\n preVerificationGas: userOperation.preVerificationGas,\n verificationGasLimit: userOperation.verificationGasLimit,\n },\n });\n }\n }\n\n // Map API response to simulation result\n return {\n counterparties: response.counterparties,\n feeData,\n inAssets: response.inAssets || [],\n outAssets: response.outAssets || [],\n priceData: response.priceData,\n showTotalFiat: response.showTotalFiat,\n validation: response.validation\n ? {\n description: response.validation.description,\n reason: response.validation.reason,\n result: response.validation.result as\n | 'benign'\n | 'warning'\n | 'malicious',\n }\n : undefined,\n };\n } catch (error) {\n // Re-throw FeeEstimationFailedError as-is\n if (error instanceof FeeEstimationFailedError) {\n throw error;\n }\n\n throw new SimulationFailedError({\n cause: error instanceof Error ? error : undefined,\n message: 'Failed to simulate ZeroDev user operation',\n });\n }\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport { name, version } from '../../package.json';\n\nassertPackageVersion(name, version);\n\nexport { addZerodevExtension } from '../addZerodevExtension';\nexport type { BatchCall } from '../BatchCall.types';\nexport { canSponsorUserOperation } from '../canSponsorUserOperation';\nexport type { CanSponsorUserOperationParams } from '../canSponsorUserOperation';\nexport { ZerodevBundlerProvider } from '../constants';\nexport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nexport type { Eip7702Authorization } from '../createKernelClientForWalletAccount';\nexport { estimateUserOperationGas } from '../estimateUserOperationGas';\nexport type { EstimateUserOperationGasParams } from '../estimateUserOperationGas';\nexport { getSignerForSmartWalletAccount } from '../getSignerForSmartWalletAccount';\nexport { isGasSponsorshipError } from '../isGasSponsorshipError';\nexport type { KernelClient } from '../KernelClient.types';\nexport { sendUserOperation } from '../sendUserOperation';\nexport type { SendUserOperationParams } from '../sendUserOperation';\nexport { signEip7702Authorization } from '../signEip7702Authorization';\nexport { simulateZerodevUserOperation } from '../simulateZerodevUserOperation';\nexport { calculateFeeForUserOperation } from '../utils/calculateFeeForUserOperation';\n"],"mappings":";;;;;;;;;;;;;AAOA,MAAa,8BAA8B,WAAoC;AAkB7E,SAhBE,OAAO,MAAM,oBAAoB,QAC9B,eACC,WAAW,mBAAmBA,8CAAmB,uBACjD,WAAW,YACP,aAAa,CACd,WAAWC,uCAAiB,qBAAqB,IACpD,WAAW,WACX,WAAW,gFACyB,WAAW,MAAM,KAAK,MAC7D,IAAI,EAAE,EAEmD,KAEzD,eAAe,WAAW,QAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACsCH,MAAa,qCAAqC,OAChD,EACE,oBACA,kBAAkB,MAClB,iBACA,WACA,YAAY,oBACZ,cAAc,sBACd,iBACA,eAEF,8DAA2B,KACD;CAC1B,IAAIC;AAEJ,KAAI,WAAW;AACb,8EACE;GAAE,OAAO;GAAO;GAAW,EAC3B,OACD;AAED,mDACE,aACA,mDAAmD,UAAU,sDAC9D;QACI;AAML,iBAL0B,yDACxB,EAAE,eAAe,oBAAoB,EACrC,OACD,EAE+B;AAEhC,mDACE,aAC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_TRANSFER_ABI, f as ZERODEV_METADATA, i as shouldUseEIP7702, l as getZerodevChainProviderForNetworkId, m as
|
|
1
|
+
import { c as getSignerForSmartWalletAccount, d as ERC20_TRANSFER_ABI, f as ZERODEV_METADATA, h as version, i as shouldUseEIP7702, l as getZerodevChainProviderForNetworkId, m as name, n as getPaymasterConfig, p as ZerodevBundlerProvider, r as createKernelAccount$1, t as getZerodevRpc } from "./getZerodevRpc-DvZw2j1r.esm.js";
|
|
2
2
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
3
3
|
import { WalletProviderPriority, assertDefined, createApiClient, formatWalletProviderGroupKey, formatWalletProviderKey, getActiveNetworkIdFromLastKnownRegistry, getChainFromVerifiedCredentialChain, getCore, getDefaultClient, getNetworkDataForNetworkId, getWalletProviderRegistry, hasExtension, parseAmountToSmallestUnit, registerExtension, switchActiveNetworkInLastKnownRegistry } from "@dynamic-labs-sdk/client/core";
|
|
4
4
|
import { FeeEstimationFailedError, InvalidParamError, SimulationFailedError, UnrecognizedNetworkError, getActiveNetworkData, getDefaultClient as getDefaultClient$1, getNetworksData, getOwnerWalletAccountForSmartWalletAccount, signMessage } from "@dynamic-labs-sdk/client";
|
|
@@ -280,8 +280,8 @@ const addZerodevExtension = (client = getDefaultClient()) => {
|
|
|
280
280
|
//#endregion
|
|
281
281
|
//#region src/utils/prepareUserOperationFromCalls/prepareUserOperationFromCalls.ts
|
|
282
282
|
/**
|
|
283
|
-
* Prepares a user operation from an array of calls
|
|
284
|
-
*
|
|
283
|
+
* Prepares a user operation from an array of calls, handling both single and
|
|
284
|
+
* batch transactions
|
|
285
285
|
*
|
|
286
286
|
* @param params.kernelClient - The kernel client to use for preparing the user operation
|
|
287
287
|
* @param params.calls - Array of calls (can be single call or multiple calls)
|
|
@@ -674,5 +674,5 @@ const simulateZerodevUserOperation = async ({ walletAccount, userOperation, netw
|
|
|
674
674
|
assertPackageVersion(name, version);
|
|
675
675
|
|
|
676
676
|
//#endregion
|
|
677
|
-
export { addZerodevExtension, calculateFeeForUserOperation, canSponsorUserOperation, createKernelClientForWalletAccount, estimateUserOperationGas, getSignerForSmartWalletAccount, isGasSponsorshipError, sendUserOperation, signEip7702Authorization, simulateZerodevUserOperation };
|
|
677
|
+
export { ZerodevBundlerProvider, addZerodevExtension, calculateFeeForUserOperation, canSponsorUserOperation, createKernelClientForWalletAccount, estimateUserOperationGas, getSignerForSmartWalletAccount, isGasSponsorshipError, sendUserOperation, signEip7702Authorization, simulateZerodevUserOperation };
|
|
678
678
|
//# sourceMappingURL=index.esm.js.map
|