@dynamic-labs-sdk/zerodev 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/BatchCall.types.d.ts +19 -0
  2. package/dist/BatchCall.types.d.ts.map +1 -0
  3. package/dist/canSponsorUserOperation/canSponsorUserOperation.d.ts +27 -0
  4. package/dist/canSponsorUserOperation/canSponsorUserOperation.d.ts.map +1 -0
  5. package/dist/canSponsorUserOperation/index.d.ts +3 -0
  6. package/dist/canSponsorUserOperation/index.d.ts.map +1 -0
  7. package/dist/core.cjs.js +1 -1
  8. package/dist/core.esm.js +1 -1
  9. package/dist/estimateUserOperationGas/estimateUserOperationGas.d.ts +16 -0
  10. package/dist/estimateUserOperationGas/estimateUserOperationGas.d.ts.map +1 -0
  11. package/dist/estimateUserOperationGas/index.d.ts +3 -0
  12. package/dist/estimateUserOperationGas/index.d.ts.map +1 -0
  13. package/dist/exports/index.d.ts +7 -2
  14. package/dist/exports/index.d.ts.map +1 -1
  15. package/dist/{getZerodevRpc-CJeGDiIR.cjs.js → getZerodevRpc-BaEt21uP.cjs.js} +2 -2
  16. package/dist/{getZerodevRpc-CJeGDiIR.cjs.js.map → getZerodevRpc-BaEt21uP.cjs.js.map} +1 -1
  17. package/dist/{getZerodevRpc-DlpB-rlp.esm.js → getZerodevRpc-Buy6FN1e.esm.js} +2 -2
  18. package/dist/{getZerodevRpc-DlpB-rlp.esm.js.map → getZerodevRpc-Buy6FN1e.esm.js.map} +1 -1
  19. package/dist/index.cjs.js +72 -29
  20. package/dist/index.cjs.js.map +1 -1
  21. package/dist/index.esm.js +70 -28
  22. package/dist/index.esm.js.map +1 -1
  23. package/dist/sendUserOperation/index.d.ts +3 -0
  24. package/dist/sendUserOperation/index.d.ts.map +1 -0
  25. package/dist/sendUserOperation/sendUserOperation.d.ts +31 -0
  26. package/dist/sendUserOperation/sendUserOperation.d.ts.map +1 -0
  27. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  28. package/dist/utils/prepareUserOperationFromCalls/index.d.ts +3 -0
  29. package/dist/utils/prepareUserOperationFromCalls/index.d.ts.map +1 -0
  30. package/dist/utils/{prepareUserOperationWithKernelClient/prepareUserOperationWithKernelClient.d.ts → prepareUserOperationFromCalls/prepareUserOperationFromCalls.d.ts} +40 -37
  31. package/dist/utils/prepareUserOperationFromCalls/prepareUserOperationFromCalls.d.ts.map +1 -0
  32. package/package.json +4 -4
  33. package/dist/canSponsorTransaction/canSponsorTransaction.d.ts +0 -29
  34. package/dist/canSponsorTransaction/canSponsorTransaction.d.ts.map +0 -1
  35. package/dist/canSponsorTransaction/index.d.ts +0 -2
  36. package/dist/canSponsorTransaction/index.d.ts.map +0 -1
  37. package/dist/estimateTransactionGas/estimateTransactionGas.d.ts +0 -18
  38. package/dist/estimateTransactionGas/estimateTransactionGas.d.ts.map +0 -1
  39. package/dist/estimateTransactionGas/index.d.ts +0 -2
  40. package/dist/estimateTransactionGas/index.d.ts.map +0 -1
  41. package/dist/utils/prepareUserOperationWithKernelClient/index.d.ts +0 -2
  42. package/dist/utils/prepareUserOperationWithKernelClient/index.d.ts.map +0 -1
  43. package/dist/utils/prepareUserOperationWithKernelClient/prepareUserOperationWithKernelClient.d.ts.map +0 -1
@@ -0,0 +1,19 @@
1
+ import type { Hex } from 'viem';
2
+ /**
3
+ * Represents a single call in a batch transaction
4
+ */
5
+ export type BatchCall = {
6
+ /**
7
+ * Optional calldata to include with this call
8
+ */
9
+ data?: Hex;
10
+ /**
11
+ * The recipient address for this call
12
+ */
13
+ to: Hex;
14
+ /**
15
+ * The amount of wei to send with this call
16
+ */
17
+ value: bigint;
18
+ };
19
+ //# sourceMappingURL=BatchCall.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BatchCall.types.d.ts","sourceRoot":"","sources":["../src/BatchCall.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,GAAG,CAAC;IACX;;OAEG;IACH,EAAE,EAAE,GAAG,CAAC;IACR;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';
2
+ import type { BatchCall } from '../BatchCall.types';
3
+ import type { KernelClient } from '../KernelClient.types';
4
+ type CanSponsorUserOperationBaseParams = {
5
+ calls: BatchCall[];
6
+ };
7
+ type CanSponsorUserOperationWithWalletParams = CanSponsorUserOperationBaseParams & {
8
+ kernelClient?: never;
9
+ walletAccount: EvmWalletAccount;
10
+ };
11
+ type CanSponsorUserOperationWithClientParams = CanSponsorUserOperationBaseParams & {
12
+ kernelClient: KernelClient;
13
+ walletAccount?: never;
14
+ };
15
+ export type CanSponsorUserOperationParams = CanSponsorUserOperationWithWalletParams | CanSponsorUserOperationWithClientParams;
16
+ /**
17
+ * Checks if a user operation can be sponsored by the paymaster
18
+ * Handles both single transactions and batch transactions
19
+ *
20
+ * @param params.calls - Array of calls (single call or multiple calls)
21
+ * @param params.kernelClient - Optional kernel client with sponsorship configured
22
+ * @param params.walletAccount - The wallet account to use (required if kernelClient not provided)
23
+ * @returns True if the user operation can be sponsored, false otherwise
24
+ */
25
+ export declare const canSponsorUserOperation: ({ walletAccount, calls, kernelClient, }: CanSponsorUserOperationParams) => Promise<boolean>;
26
+ export {};
27
+ //# sourceMappingURL=canSponsorUserOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canSponsorUserOperation.d.ts","sourceRoot":"","sources":["../../src/canSponsorUserOperation/canSponsorUserOperation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,KAAK,iCAAiC,GAAG;IACvC,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CAAC;AAEF,KAAK,uCAAuC,GAC1C,iCAAiC,GAAG;IAClC,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEJ,KAAK,uCAAuC,GAC1C,iCAAiC,GAAG;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB,CAAC;AAEJ,MAAM,MAAM,6BAA6B,GACrC,uCAAuC,GACvC,uCAAuC,CAAC;AAE5C;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,4CAIjC,6BAA6B,KAAG,OAAO,CAAC,OAAO,CA0BjD,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { canSponsorUserOperation } from './canSponsorUserOperation';
2
+ export type { CanSponsorUserOperationParams } from './canSponsorUserOperation';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canSponsorUserOperation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,YAAY,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/core.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- const require_getZerodevRpc = require('./getZerodevRpc-CJeGDiIR.cjs.js');
1
+ const require_getZerodevRpc = require('./getZerodevRpc-BaEt21uP.cjs.js');
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, f as name, i as shouldUseEIP7702, l as getZerodevChainProviderForNetworkId, n as getPaymasterConfig, o as getEntryPoint, p as version, r as createKernelAccount, s as getEcdsaValidator, t as getZerodevRpc, u as getZerodevProviderFromSettings } from "./getZerodevRpc-DlpB-rlp.esm.js";
1
+ import { a as getKernelVersion, f as name, i as shouldUseEIP7702, l as getZerodevChainProviderForNetworkId, n as getPaymasterConfig, o as getEntryPoint, p as version, r as createKernelAccount, s as getEcdsaValidator, t as getZerodevRpc, u as getZerodevProviderFromSettings } from "./getZerodevRpc-Buy6FN1e.esm.js";
2
2
  import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
3
3
 
4
4
  //#region src/exports/core.ts
@@ -0,0 +1,16 @@
1
+ import type { EvmWalletAccount } from '@dynamic-labs-sdk/evm';
2
+ import type { BatchCall } from '../BatchCall.types';
3
+ export type EstimateUserOperationGasParams = {
4
+ calls: BatchCall[];
5
+ walletAccount: EvmWalletAccount;
6
+ };
7
+ /**
8
+ * Estimates the total gas cost for a user operation with one or more calls
9
+ * Handles both single transactions and batch transactions
10
+ *
11
+ * @param params.calls - Array of calls (single call or multiple calls)
12
+ * @param params.walletAccount - The wallet account that will execute the user operation
13
+ * @returns The estimated gas cost in wei, or null if estimation fails
14
+ */
15
+ export declare const estimateUserOperationGas: ({ walletAccount, calls, }: EstimateUserOperationGasParams) => Promise<bigint | null>;
16
+ //# sourceMappingURL=estimateUserOperationGas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimateUserOperationGas.d.ts","sourceRoot":"","sources":["../../src/estimateUserOperationGas/estimateUserOperationGas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAKpD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,8BAGlC,8BAA8B,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAmBxD,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { estimateUserOperationGas } from './estimateUserOperationGas';
2
+ export type { EstimateUserOperationGasParams } from './estimateUserOperationGas';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/estimateUserOperationGas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,YAAY,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC"}
@@ -1,10 +1,15 @@
1
1
  export { addZerodevExtension } from '../addZerodevExtension';
2
- export { canSponsorTransaction } from '../canSponsorTransaction';
2
+ export type { BatchCall } from '../BatchCall.types';
3
+ export { canSponsorUserOperation } from '../canSponsorUserOperation';
4
+ export type { CanSponsorUserOperationParams } from '../canSponsorUserOperation';
3
5
  export { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';
4
6
  export type { Eip7702Authorization } from '../createKernelClientForWalletAccount';
5
- export { estimateTransactionGas } from '../estimateTransactionGas';
7
+ export { estimateUserOperationGas } from '../estimateUserOperationGas';
8
+ export type { EstimateUserOperationGasParams } from '../estimateUserOperationGas';
6
9
  export { getSignerForSmartWalletAccount } from '../getSignerForSmartWalletAccount';
7
10
  export { isGasSponsorshipError } from '../isGasSponsorshipError';
8
11
  export type { KernelClient } from '../KernelClient.types';
12
+ export { sendUserOperation } from '../sendUserOperation';
13
+ export type { SendUserOperationParams } from '../sendUserOperation';
9
14
  export { signEip7702Authorization } from '../signEip7702Authorization';
10
15
  //# sourceMappingURL=index.d.ts.map
@@ -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,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kCAAkC,EAAE,MAAM,uCAAuC,CAAC;AAC3F,YAAY,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC"}
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,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,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 = "0.7.0";
13
+ var version = "0.9.0";
14
14
 
15
15
  //#endregion
16
16
  //#region src/constants.ts
@@ -263,4 +263,4 @@ Object.defineProperty(exports, 'version', {
263
263
  return version;
264
264
  }
265
265
  });
266
- //# sourceMappingURL=getZerodevRpc-CJeGDiIR.cjs.js.map
266
+ //# sourceMappingURL=getZerodevRpc-BaEt21uP.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getZerodevRpc-CJeGDiIR.cjs.js","names":["DYNAMIC_ICONIC_SPRITE_URL","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","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 { ProviderKernelVersionEnum } 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\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","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport { ProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nexport const getZerodevProviderFromSettings = (client: DynamicClient) => {\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';\n\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\n\ntype GetZerodevChainProviderForNetworkIdProps = {\n networkId: string;\n};\n\nexport const getZerodevChainProviderForNetworkId = (\n { networkId }: GetZerodevChainProviderForNetworkIdProps,\n client: DynamicClient\n) => {\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 * @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 an WalletClient instance.\n * @throws NoSmartWalletAccountSignerFoundError When the signer wallet account is not found for the given smart wallet account.\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';\n\ntype GetEcdsaValidatorParams = {\n ecdsaProviderType?: string;\n entryPoint: EntryPointType<EntryPointVersion>;\n kernelVersion: GetKernelVersion<EntryPointVersion>;\n publicClient: Client;\n signer: Signer;\n};\n\nexport const getEcdsaValidator = ({\n ecdsaProviderType,\n publicClient,\n signer,\n entryPoint,\n kernelVersion,\n}: GetEcdsaValidatorParams) => {\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\nexport const getEntryPoint = (entryPoint?: string) => {\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 } 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\nexport const getKernelVersion = ({\n kernelVersion,\n entryPoint,\n}: GetKernelVersionParams) => {\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\nexport const shouldUseEIP7702 = (\n { smartWalletAccount }: ShouldUseEIP7702Params,\n client: DynamicClient\n) => {\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 */\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 { createZeroDevPaymasterClient } 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\nexport const getPaymasterConfig = ({\n chain,\n gasTokenAddress,\n paymasterRpc,\n}: GetPaymasterConfigProps) => {\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';\nimport { ZerodevBundlerProvider } from '@dynamic-labs/sdk-api-core';\n\nimport { ZERODEV_RPC_BASE_URL } 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\nexport const getZerodevRpc = (\n { networkId, bundlerProvider, rpcType }: GetZerodevRpcParams,\n client: DynamicClient\n) => {\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":";;;;;;;;;;;;;;;;ACMA,MAAa,mBAAmB;CAC9B,aAAa;CACb,MAAM,GAAGA,wDAA0B;CACnC,sBAAsB;CACvB;AAED,MAAa,uBAAuB;AAEpC,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;;;;ACzBD,MAAa,kCAAkC,WAA0B;CACvE,MAAM,kBAAkB,OAAO;AAE/B,kDAAc,iBAAiB,qCAAqC;CAEpE,MAAM,kBAAkB,gBAAgB,WAAW,MAChD,aAAa,SAAS,aAAaE,wCAAa,QAClD;AAED,kDACE,iBACA,gDACD;AAED,QAAO;;;;;ACVT,MAAa,uCACX,EAAE,aACF,WACG;AAGH,QAFwB,+BAA+B,OAAO,CAEvC,uCAAuC,MAC3D,aAAa,SAAS,UAAU,UAClC;;;;;;;;;;;;;;ACSH,MAAa,kCACX,EAAE,sBACF,8DAA2B,KAC0B;CACrD,MAAM,+FACJ,EAAE,oBAAoB,EACtB,OACD;AAED,KAAI,CAAC,uBAAuB,+CAAoB,oBAAoB,CAClE,OAAM,IAAIC,8DAAqC,mBAAmB,QAAQ;AAG5E,2EACE,EACE,eAAe,qBAChB,EACD,OACD;;;;;ACzBH,MAAa,qBAAqB,EAChC,mBACA,cACA,QACA,YACA,oBAC6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A,kBAAkB;GAChB,MAAM;GACN,IATqB,iBAAiB;IACxC;IACA,eAAe,gBAAgB;IAChC,CAAC;GAOC;EACD;EACD,CAAC;AAYJ,8CAAkC,cAAc;EAC9C;EACA;EACA,SAAS,EACP,MAbc,MAAM,kBAAkB;GACxC,mBACE,kBAAkB,qBAAqB,gBAAgB;GACzD;GACA;GACA;GACA;GACD,CAAC,EAOC;EACF,CAAC;;;;;ACzGJ,MAAa,sBAAsB,EACjC,OACA,iBACA,mBAC6B;CAC7B,MAAM,oBAAoB,WAAuC;AAM/D,wDALsD;GACpD;GACA,0BAAgB,aAAa;GAC9B,CAAC,CAEsB,qBAAqB;GAC3C,UAAU;GACV,eAAe;GAChB,CAAC;;AAGJ,QAAO,EACL,WAAW,EACT,kBACD,EACF;;;;;ACtBH,MAAa,iBACX,EAAE,WAAW,iBAAiB,WAC9B,WACG;CACH,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,0BAChBC,kDAAuB;CAEzB,MAAM,YACJ,YAAY,YAAY,oBAAoB;AAE9C,QAAO,GAAG,qBAAqB,GAAG,QAAQ,GAAG,qBAAqB,SAAS,GAAG,UAAU,GAAG"}
1
+ {"version":3,"file":"getZerodevRpc-BaEt21uP.cjs.js","names":["DYNAMIC_ICONIC_SPRITE_URL","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","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 { ProviderKernelVersionEnum } 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\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","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport { ProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nexport const getZerodevProviderFromSettings = (client: DynamicClient) => {\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';\n\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\n\ntype GetZerodevChainProviderForNetworkIdProps = {\n networkId: string;\n};\n\nexport const getZerodevChainProviderForNetworkId = (\n { networkId }: GetZerodevChainProviderForNetworkIdProps,\n client: DynamicClient\n) => {\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 * @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 an WalletClient instance.\n * @throws NoSmartWalletAccountSignerFoundError When the signer wallet account is not found for the given smart wallet account.\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';\n\ntype GetEcdsaValidatorParams = {\n ecdsaProviderType?: string;\n entryPoint: EntryPointType<EntryPointVersion>;\n kernelVersion: GetKernelVersion<EntryPointVersion>;\n publicClient: Client;\n signer: Signer;\n};\n\nexport const getEcdsaValidator = ({\n ecdsaProviderType,\n publicClient,\n signer,\n entryPoint,\n kernelVersion,\n}: GetEcdsaValidatorParams) => {\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\nexport const getEntryPoint = (entryPoint?: string) => {\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 } 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\nexport const getKernelVersion = ({\n kernelVersion,\n entryPoint,\n}: GetKernelVersionParams) => {\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\nexport const shouldUseEIP7702 = (\n { smartWalletAccount }: ShouldUseEIP7702Params,\n client: DynamicClient\n) => {\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 */\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 { createZeroDevPaymasterClient } 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\nexport const getPaymasterConfig = ({\n chain,\n gasTokenAddress,\n paymasterRpc,\n}: GetPaymasterConfigProps) => {\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';\nimport { ZerodevBundlerProvider } from '@dynamic-labs/sdk-api-core';\n\nimport { ZERODEV_RPC_BASE_URL } 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\nexport const getZerodevRpc = (\n { networkId, bundlerProvider, rpcType }: GetZerodevRpcParams,\n client: DynamicClient\n) => {\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":";;;;;;;;;;;;;;;;ACMA,MAAa,mBAAmB;CAC9B,aAAa;CACb,MAAM,GAAGA,wDAA0B;CACnC,sBAAsB;CACvB;AAED,MAAa,uBAAuB;AAEpC,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;;;;ACzBD,MAAa,kCAAkC,WAA0B;CACvE,MAAM,kBAAkB,OAAO;AAE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C,YAC7C;CAED,MAAM,oBACJ,mBACA,gBAAgB,0BAChBC,kDAAuB;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 = "0.7.0";
13
+ var version = "0.9.0";
14
14
 
15
15
  //#endregion
16
16
  //#region src/constants.ts
@@ -186,4 +186,4 @@ const getZerodevRpc = ({ networkId, bundlerProvider, rpcType }, client) => {
186
186
 
187
187
  //#endregion
188
188
  export { getKernelVersion as a, getSignerForSmartWalletAccount as c, ZERODEV_METADATA as d, name as f, shouldUseEIP7702 as i, getZerodevChainProviderForNetworkId as l, getPaymasterConfig as n, getEntryPoint as o, version as p, createKernelAccount$1 as r, getEcdsaValidator as s, getZerodevRpc as t, getZerodevProviderFromSettings as u };
189
- //# sourceMappingURL=getZerodevRpc-DlpB-rlp.esm.js.map
189
+ //# sourceMappingURL=getZerodevRpc-Buy6FN1e.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getZerodevRpc-DlpB-rlp.esm.js","names":["ENTRY_POINT_VERSION_MAP: Record<\n EntryPointVersion,\n KERNEL_VERSION_TYPE\n>","entryPointVersion: keyof typeof ENTRY_POINT_VERSION_MAP","createKernelAccount","createZerodevKernelAccount"],"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 { ProviderKernelVersionEnum } 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\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","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport { ProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nexport const getZerodevProviderFromSettings = (client: DynamicClient) => {\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';\n\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\n\ntype GetZerodevChainProviderForNetworkIdProps = {\n networkId: string;\n};\n\nexport const getZerodevChainProviderForNetworkId = (\n { networkId }: GetZerodevChainProviderForNetworkIdProps,\n client: DynamicClient\n) => {\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 * @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 an WalletClient instance.\n * @throws NoSmartWalletAccountSignerFoundError When the signer wallet account is not found for the given smart wallet account.\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';\n\ntype GetEcdsaValidatorParams = {\n ecdsaProviderType?: string;\n entryPoint: EntryPointType<EntryPointVersion>;\n kernelVersion: GetKernelVersion<EntryPointVersion>;\n publicClient: Client;\n signer: Signer;\n};\n\nexport const getEcdsaValidator = ({\n ecdsaProviderType,\n publicClient,\n signer,\n entryPoint,\n kernelVersion,\n}: GetEcdsaValidatorParams) => {\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\nexport const getEntryPoint = (entryPoint?: string) => {\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 } 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\nexport const getKernelVersion = ({\n kernelVersion,\n entryPoint,\n}: GetKernelVersionParams) => {\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\nexport const shouldUseEIP7702 = (\n { smartWalletAccount }: ShouldUseEIP7702Params,\n client: DynamicClient\n) => {\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 */\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 { createZeroDevPaymasterClient } 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\nexport const getPaymasterConfig = ({\n chain,\n gasTokenAddress,\n paymasterRpc,\n}: GetPaymasterConfigProps) => {\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';\nimport { ZerodevBundlerProvider } from '@dynamic-labs/sdk-api-core';\n\nimport { ZERODEV_RPC_BASE_URL } 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\nexport const getZerodevRpc = (\n { networkId, bundlerProvider, rpcType }: GetZerodevRpcParams,\n client: DynamicClient\n) => {\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":";;;;;;;;;;;;;;;;ACMA,MAAa,mBAAmB;CAC9B,aAAa;CACb,MAAM,GAAG,0BAA0B;CACnC,sBAAsB;CACvB;AAED,MAAa,uBAAuB;AAEpC,MAAa,qBAAqB;EAC/B,0BAA0B,MAAM,UAAU;EAC1C,0BAA0B,MAAM,UAAU;EAC1C,0BAA0B,MAAM,UAAU;EAC1C,0BAA0B,MAAM,UAAU;EAC1C,0BAA0B,MAAM,UAAU;CAC5C;AAED,MAAaA,0BAGT;CACF,IAAK,UAAU;CACf,IAAK,UAAU;CACf,IAAK,UAAU;CAChB;;;;ACzBD,MAAa,kCAAkC,WAA0B;CACvE,MAAM,kBAAkB,OAAO;AAE/B,eAAc,iBAAiB,qCAAqC;CAEpE,MAAM,kBAAkB,gBAAgB,WAAW,MAChD,aAAa,SAAS,aAAa,aAAa,QAClD;AAED,eACE,iBACA,gDACD;AAED,QAAO;;;;;ACVT,MAAa,uCACX,EAAE,aACF,WACG;AAGH,QAFwB,+BAA+B,OAAO,CAEvC,uCAAuC,MAC3D,aAAa,SAAS,UAA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U,GAAG"}
1
+ {"version":3,"file":"getZerodevRpc-Buy6FN1e.esm.js","names":["ENTRY_POINT_VERSION_MAP: Record<\n EntryPointVersion,\n KERNEL_VERSION_TYPE\n>","entryPointVersion: keyof typeof ENTRY_POINT_VERSION_MAP","createKernelAccount","createZerodevKernelAccount"],"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 { ProviderKernelVersionEnum } 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\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","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport { ProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nexport const getZerodevProviderFromSettings = (client: DynamicClient) => {\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';\n\nimport { getZerodevProviderFromSettings } from '../getZerodevProviderFromSettings';\n\ntype GetZerodevChainProviderForNetworkIdProps = {\n networkId: string;\n};\n\nexport const getZerodevChainProviderForNetworkId = (\n { networkId }: GetZerodevChainProviderForNetworkIdProps,\n client: DynamicClient\n) => {\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 * @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 an WalletClient instance.\n * @throws NoSmartWalletAccountSignerFoundError When the signer wallet account is not found for the given smart wallet account.\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';\n\ntype GetEcdsaValidatorParams = {\n ecdsaProviderType?: string;\n entryPoint: EntryPointType<EntryPointVersion>;\n kernelVersion: GetKernelVersion<EntryPointVersion>;\n publicClient: Client;\n signer: Signer;\n};\n\nexport const getEcdsaValidator = ({\n ecdsaProviderType,\n publicClient,\n signer,\n entryPoint,\n kernelVersion,\n}: GetEcdsaValidatorParams) => {\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\nexport const getEntryPoint = (entryPoint?: string) => {\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 } 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\nexport const getKernelVersion = ({\n kernelVersion,\n entryPoint,\n}: GetKernelVersionParams) => {\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\nexport const shouldUseEIP7702 = (\n { smartWalletAccount }: ShouldUseEIP7702Params,\n client: DynamicClient\n) => {\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 */\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 { createZeroDevPaymasterClient } 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\nexport const getPaymasterConfig = ({\n chain,\n gasTokenAddress,\n paymasterRpc,\n}: GetPaymasterConfigProps) => {\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';\nimport { ZerodevBundlerProvider } from '@dynamic-labs/sdk-api-core';\n\nimport { ZERODEV_RPC_BASE_URL } 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\nexport const getZerodevRpc = (\n { networkId, bundlerProvider, rpcType }: GetZerodevRpcParams,\n client: DynamicClient\n) => {\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":";;;;;;;;;;;;;;;;ACMA,MAAa,mBAAmB;CAC9B,aAAa;CACb,MAAM,GAAG,0BAA0B;CACnC,sBAAsB;CACvB;AAED,MAAa,uBAAuB;AAEpC,MAAa,qBAAqB;EAC/B,0BAA0B,MAAM,UAAU;EAC1C,0BAA0B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9B,CAAC,CAEsB,qBAAqB;GAC3C,UAAU;GACV,eAAe;GAChB,CAAC;;AAGJ,QAAO,EACL,WAAW,EACT,kBACD,EACF;;;;;ACtBH,MAAa,iBACX,EAAE,WAAW,iBAAiB,WAC9B,WACG;CACH,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,0BAChB,uBAAuB;CAEzB,MAAM,YACJ,YAAY,YAAY,oBAAoB;AAE9C,QAAO,GAAG,qBAAqB,GAAG,QAAQ,GAAG,qBAAqB,SAAS,GAAG,UAAU,GAAG"}
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- const require_getZerodevRpc = require('./getZerodevRpc-CJeGDiIR.cjs.js');
1
+ const require_getZerodevRpc = require('./getZerodevRpc-BaEt21uP.cjs.js');
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");
@@ -180,35 +180,46 @@ const addZerodevExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefau
180
180
  };
181
181
 
182
182
  //#endregion
183
- //#region src/utils/prepareUserOperationWithKernelClient/prepareUserOperationWithKernelClient.ts
184
- const prepareUserOperationWithKernelClient = async ({ kernelClient, transaction }) => {
185
- const callData = await kernelClient.account.encodeCalls([{
186
- data: transaction.data ?? "0x",
187
- to: transaction.to,
188
- value: transaction.value
189
- }]);
183
+ //#region src/utils/prepareUserOperationFromCalls/prepareUserOperationFromCalls.ts
184
+ /**
185
+ * Prepares a user operation from an array of calls
186
+ * Replaces prepareUserOperationWithKernelClient to handle both single and batch transactions
187
+ *
188
+ * @param params.kernelClient - The kernel client to use for preparing the user operation
189
+ * @param params.calls - Array of calls (can be single call or multiple calls)
190
+ * @returns Promise resolving to the prepared user operation
191
+ */
192
+ const prepareUserOperationFromCalls = async ({ kernelClient, calls }) => {
193
+ const normalizedCalls = calls.map((call) => ({
194
+ data: call.data ?? "0x",
195
+ to: call.to,
196
+ value: call.value
197
+ }));
198
+ const callData = await kernelClient.account.encodeCalls(normalizedCalls);
190
199
  return kernelClient.prepareUserOperation({ callData });
191
200
  };
192
201
 
193
202
  //#endregion
194
- //#region src/canSponsorTransaction/canSponsorTransaction.ts
203
+ //#region src/canSponsorUserOperation/canSponsorUserOperation.ts
195
204
  /**
196
- * Checks if a transaction can be sponsored
197
- * @param params.transaction - The transaction to check if it can be sponsored
198
- * @param params.kernelClient - The kernel client to use to check if the transaction can be sponsored. If no provided, a walletAccount is required to create a kernel client with sponsorship.
199
- * @param params.walletAccount - The wallet account that will be used to send the transaction, Only required if no kernel client is provided
200
- * @returns True if the transaction can be sponsored, false otherwise
205
+ * Checks if a user operation can be sponsored by the paymaster
206
+ * Handles both single transactions and batch transactions
207
+ *
208
+ * @param params.calls - Array of calls (single call or multiple calls)
209
+ * @param params.kernelClient - Optional kernel client with sponsorship configured
210
+ * @param params.walletAccount - The wallet account to use (required if kernelClient not provided)
211
+ * @returns True if the user operation can be sponsored, false otherwise
201
212
  */
202
- const canSponsorTransaction = async ({ walletAccount, transaction, kernelClient }) => {
213
+ const canSponsorUserOperation = async ({ walletAccount, calls, kernelClient }) => {
203
214
  let kernelClientToUse = kernelClient;
204
215
  if (!kernelClientToUse) {
205
216
  (0, _dynamic_labs_sdk_client_core.assertDefined)(walletAccount, "Please provide either a wallet account or a kernel client in the parameters");
206
217
  kernelClientToUse = await createKernelClientForWalletAccount({ smartWalletAccount: walletAccount });
207
218
  }
208
219
  try {
209
- return (await prepareUserOperationWithKernelClient({
210
- kernelClient: kernelClientToUse,
211
- transaction
220
+ return (await prepareUserOperationFromCalls({
221
+ calls,
222
+ kernelClient: kernelClientToUse
212
223
  })).paymasterAndData !== "0x";
213
224
  } catch {
214
225
  return false;
@@ -222,21 +233,23 @@ const calculateGasForUserOperation = ({ userOperationData }) => {
222
233
  };
223
234
 
224
235
  //#endregion
225
- //#region src/estimateTransactionGas/estimateTransactionGas.ts
236
+ //#region src/estimateUserOperationGas/estimateUserOperationGas.ts
226
237
  /**
227
- * Estimates the total gas for a transaction
228
- * @param params.transaction - The transaction to estimate the gas for
229
- * @param params.walletAccount - The wallet account that will be used to send the transaction
230
- * @returns The gas for the transaction in wei
238
+ * Estimates the total gas cost for a user operation with one or more calls
239
+ * Handles both single transactions and batch transactions
240
+ *
241
+ * @param params.calls - Array of calls (single call or multiple calls)
242
+ * @param params.walletAccount - The wallet account that will execute the user operation
243
+ * @returns The estimated gas cost in wei, or null if estimation fails
231
244
  */
232
- const estimateTransactionGas = async ({ walletAccount, transaction }) => {
245
+ const estimateUserOperationGas = async ({ walletAccount, calls }) => {
233
246
  try {
234
- return calculateGasForUserOperation({ userOperationData: await prepareUserOperationWithKernelClient({
247
+ return calculateGasForUserOperation({ userOperationData: await prepareUserOperationFromCalls({
248
+ calls,
235
249
  kernelClient: await createKernelClientForWalletAccount({
236
250
  smartWalletAccount: walletAccount,
237
251
  withSponsorship: false
238
- }),
239
- transaction
252
+ })
240
253
  }) });
241
254
  } catch {
242
255
  return null;
@@ -249,6 +262,35 @@ const isGasSponsorshipError = (err) => {
249
262
  return err?.message?.includes("userOp did not match any gas sponsoring policies") || false;
250
263
  };
251
264
 
265
+ //#endregion
266
+ //#region src/sendUserOperation/sendUserOperation.ts
267
+ /**
268
+ * Sends a user operation with one or more calls
269
+ * Handles both single transactions and batch transactions
270
+ *
271
+ * @param params.calls - Array of calls (single call or multiple calls)
272
+ * @param params.kernelClient - Optional pre-configured kernel client
273
+ * @param params.walletAccount - The wallet account to use (required if kernelClient not provided)
274
+ * @param params.withSponsorship - Whether to use sponsorship (default: true, only used with walletAccount)
275
+ * @returns Promise resolving to the UserOperation receipt
276
+ */
277
+ const sendUserOperation = async ({ walletAccount, calls, kernelClient, withSponsorship = true }) => {
278
+ let kernelClientToUse = kernelClient;
279
+ if (!kernelClientToUse) {
280
+ (0, _dynamic_labs_sdk_client_core.assertDefined)(walletAccount, "Please provide either a wallet account or a kernel client in the parameters");
281
+ kernelClientToUse = await createKernelClientForWalletAccount({
282
+ smartWalletAccount: walletAccount,
283
+ withSponsorship
284
+ });
285
+ }
286
+ const userOperation = await prepareUserOperationFromCalls({
287
+ calls,
288
+ kernelClient: kernelClientToUse
289
+ });
290
+ const userOperationHash = await kernelClientToUse.sendUserOperation(userOperation);
291
+ return kernelClientToUse.waitForUserOperationReceipt({ hash: userOperationHash });
292
+ };
293
+
252
294
  //#endregion
253
295
  //#region src/signEip7702Authorization/signEip7702Authorization.ts
254
296
  /**
@@ -289,10 +331,11 @@ const signEip7702Authorization = async ({ smartWalletAccount, networkId }, clien
289
331
 
290
332
  //#endregion
291
333
  exports.addZerodevExtension = addZerodevExtension;
292
- exports.canSponsorTransaction = canSponsorTransaction;
334
+ exports.canSponsorUserOperation = canSponsorUserOperation;
293
335
  exports.createKernelClientForWalletAccount = createKernelClientForWalletAccount;
294
- exports.estimateTransactionGas = estimateTransactionGas;
336
+ exports.estimateUserOperationGas = estimateUserOperationGas;
295
337
  exports.getSignerForSmartWalletAccount = require_getZerodevRpc.getSignerForSmartWalletAccount;
296
338
  exports.isGasSponsorshipError = isGasSponsorshipError;
339
+ exports.sendUserOperation = sendUserOperation;
297
340
  exports.signEip7702Authorization = signEip7702Authorization;
298
341
  //# sourceMappingURL=index.cjs.js.map