@dynamic-labs-sdk/zerodev 0.3.0 → 0.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","names":["networkData: NetworkData | undefined","createKernelAccount","signMessage","signMessageWithWalletAccount","chain: Chain","signMessage","signMessageUtils"],"sources":["../src/utils/getAllUserZerodevAddresses/getAllUserZerodevAddresses.ts","../src/createKernelClientForWalletAccount/createKernelClientForWalletAccount.ts","../src/utils/shouldSignWithEoa/shouldSignWithEoa.ts","../src/utils/signMessage/signMessage.ts","../src/utils/createZerodevWalletProvider/createZerodevWalletProvider.ts","../src/addZerodevExtension/addZerodevExtension.ts","../src/utils/prepareUserOperationWithKernelClient/prepareUserOperationWithKernelClient.ts","../src/canSponsorTransaction/canSponsorTransaction.ts","../src/utils/calculateGasForUserOperation/calculateGasForUserOperation.ts","../src/estimateTransactionGas/estimateTransactionGas.ts","../src/isGasSponsorshipError/isGasSponsorshipError.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\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';\n\nimport type { KernelClient } from '../KernelClient.types';\nimport { createKernelAccount } from '../utils/createKernelAccount';\nimport { getPaymasterConfig } from '../utils/getPaymasterConfig';\nimport { getZerodevRpc } from '../utils/getZerodevRpc';\n\ntype CreateKernelClientForWalletAccountParams = {\n bundlerProvider?: ZerodevBundlerProvider;\n bundlerRpc?: string;\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 * @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 * If not provided, the network ID will be fetched from the active network data.\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 [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to a KernelClient instance.\n */\nexport const createKernelClientForWalletAccount = async (\n {\n smartWalletAccount,\n withSponsorship = true,\n bundlerProvider,\n networkId,\n bundlerRpc: bundlerRpcOverride,\n paymasterRpc: paymasterRpcOverride,\n gasTokenAddress,\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 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\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\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","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';\n\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 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 * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\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 { Hex } from 'viem';\n\nimport type { KernelClient } from '../../KernelClient.types';\n\ntype PrepareUserOperationWithKernelClientParams = {\n kernelClient: KernelClient;\n transaction: {\n data?: Hex;\n to: Hex;\n value: bigint;\n };\n};\n\nexport const prepareUserOperationWithKernelClient = async ({\n kernelClient,\n transaction,\n}: PrepareUserOperationWithKernelClientParams) => {\n const callData = await kernelClient.account.encodeCalls([\n {\n data: transaction.data ?? '0x',\n to: transaction.to,\n value: transaction.value,\n },\n ]);\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';\nimport type { Hex } from 'viem';\n\nimport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nimport type { KernelClient } from '../KernelClient.types';\nimport { prepareUserOperationWithKernelClient } from '../utils/prepareUserOperationWithKernelClient';\n\ntype CanSponsorTransactionBaseParams = {\n transaction: {\n data?: Hex;\n to: Hex;\n value: bigint;\n };\n};\n\ntype CanSponsorTransactionWithWalletParams = CanSponsorTransactionBaseParams & {\n kernelClient?: never;\n walletAccount: EvmWalletAccount;\n};\n\ntype CanSponsorTransactionWithClientParams = CanSponsorTransactionBaseParams & {\n kernelClient: KernelClient;\n walletAccount?: never;\n};\n\nexport type CanSponsorTransactionParams =\n | CanSponsorTransactionWithWalletParams\n | CanSponsorTransactionWithClientParams;\n\n/**\n * Checks if a transaction can be sponsored\n * @param params.transaction - The transaction to check if it can be sponsored\n * @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.\n * @param params.walletAccount - The wallet account that will be used to send the transaction, Only required if no kernel client is provided\n * @returns True if the transaction can be sponsored, false otherwise\n */\nexport const canSponsorTransaction = async ({\n walletAccount,\n transaction,\n kernelClient,\n}: CanSponsorTransactionParams): 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 prepareUserOperationWithKernelClient({\n kernelClient: kernelClientToUse,\n transaction,\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\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';\nimport type { Hex } from 'viem';\n\nimport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nimport { calculateGasForUserOperation } from '../utils/calculateGasForUserOperation';\nimport { prepareUserOperationWithKernelClient } from '../utils/prepareUserOperationWithKernelClient';\n\nexport type EstimateTransactionGasParams = {\n transaction: {\n data?: Hex;\n to: Hex;\n value: bigint;\n };\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Estimates the total gas for a transaction\n * @param params.transaction - The transaction to estimate the gas for\n * @param params.walletAccount - The wallet account that will be used to send the transaction\n * @returns The gas for the transaction in wei\n */\nexport const estimateTransactionGas = async ({\n walletAccount,\n transaction,\n}: EstimateTransactionGasParams): Promise<bigint | null> => {\n try {\n const kernelClientWithoutSponsorship =\n await createKernelClientForWalletAccount({\n smartWalletAccount: walletAccount,\n withSponsorship: false,\n });\n\n const unsponsoredUserOperation = await prepareUserOperationWithKernelClient(\n {\n kernelClient: kernelClientWithoutSponsorship,\n transaction,\n }\n );\n\n return calculateGasForUserOperation({\n userOperationData: unsponsoredUserOperation,\n });\n } catch {\n return null;\n }\n};\n","export 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 { 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 { canSponsorTransaction } from '../canSponsorTransaction';\nexport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nexport { estimateTransactionGas } from '../estimateTransactionGas';\nexport { getSignerForSmartWalletAccount } from '../getSignerForSmartWalletAccount';\nexport { isGasSponsorshipError } from '../isGasSponsorshipError';\nexport type { KernelClient } from '../KernelClient.types';\n"],"mappings":";;;;;;;;;;;AAMA,MAAa,8BAA8B,WAAoC;AAkB7E,SAhBE,OAAO,MAAM,oBAAoB,QAC9B,eACC,WAAW,mBAAmB,mBAAmB,uBACjD,WAAW,YACP,aAAa,CACd,WAAW,iBAAiB,qBAAqB,IACpD,WAAW,WACX,WAAW,SACX,oCAAoC,WAAW,MAAM,KAAK,MAC7D,IAAI,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Data | undefined","createKernelAccount","signMessage","signMessageWithWalletAccount","chain: Chain","signMessage","signMessageUtils"],"sources":["../src/utils/getAllUserZerodevAddresses/getAllUserZerodevAddresses.ts","../src/createKernelClientForWalletAccount/createKernelClientForWalletAccount.ts","../src/utils/shouldSignWithEoa/shouldSignWithEoa.ts","../src/utils/signMessage/signMessage.ts","../src/utils/createZerodevWalletProvider/createZerodevWalletProvider.ts","../src/addZerodevExtension/addZerodevExtension.ts","../src/utils/prepareUserOperationWithKernelClient/prepareUserOperationWithKernelClient.ts","../src/canSponsorTransaction/canSponsorTransaction.ts","../src/utils/calculateGasForUserOperation/calculateGasForUserOperation.ts","../src/estimateTransactionGas/estimateTransactionGas.ts","../src/isGasSponsorshipError/isGasSponsorshipError.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\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 * @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 * If not provided, the network ID will be fetched from the active network data.\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. When provided, the kernel client uses \n * this authorization instead of signing a new one internally. Useful for singleUse MFA flows where you need\n * to separate the authorization signing step from the transaction step.\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 */\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\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\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","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';\n\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 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 * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\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 { Hex } from 'viem';\n\nimport type { KernelClient } from '../../KernelClient.types';\n\ntype PrepareUserOperationWithKernelClientParams = {\n kernelClient: KernelClient;\n transaction: {\n data?: Hex;\n to: Hex;\n value: bigint;\n };\n};\n\nexport const prepareUserOperationWithKernelClient = async ({\n kernelClient,\n transaction,\n}: PrepareUserOperationWithKernelClientParams) => {\n const callData = await kernelClient.account.encodeCalls([\n {\n data: transaction.data ?? '0x',\n to: transaction.to,\n value: transaction.value,\n },\n ]);\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';\nimport type { Hex } from 'viem';\n\nimport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nimport type { KernelClient } from '../KernelClient.types';\nimport { prepareUserOperationWithKernelClient } from '../utils/prepareUserOperationWithKernelClient';\n\ntype CanSponsorTransactionBaseParams = {\n transaction: {\n data?: Hex;\n to: Hex;\n value: bigint;\n };\n};\n\ntype CanSponsorTransactionWithWalletParams = CanSponsorTransactionBaseParams & {\n kernelClient?: never;\n walletAccount: EvmWalletAccount;\n};\n\ntype CanSponsorTransactionWithClientParams = CanSponsorTransactionBaseParams & {\n kernelClient: KernelClient;\n walletAccount?: never;\n};\n\nexport type CanSponsorTransactionParams =\n | CanSponsorTransactionWithWalletParams\n | CanSponsorTransactionWithClientParams;\n\n/**\n * Checks if a transaction can be sponsored\n * @param params.transaction - The transaction to check if it can be sponsored\n * @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.\n * @param params.walletAccount - The wallet account that will be used to send the transaction, Only required if no kernel client is provided\n * @returns True if the transaction can be sponsored, false otherwise\n */\nexport const canSponsorTransaction = async ({\n walletAccount,\n transaction,\n kernelClient,\n}: CanSponsorTransactionParams): 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 prepareUserOperationWithKernelClient({\n kernelClient: kernelClientToUse,\n transaction,\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\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';\nimport type { Hex } from 'viem';\n\nimport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nimport { calculateGasForUserOperation } from '../utils/calculateGasForUserOperation';\nimport { prepareUserOperationWithKernelClient } from '../utils/prepareUserOperationWithKernelClient';\n\nexport type EstimateTransactionGasParams = {\n transaction: {\n data?: Hex;\n to: Hex;\n value: bigint;\n };\n walletAccount: EvmWalletAccount;\n};\n\n/**\n * Estimates the total gas for a transaction\n * @param params.transaction - The transaction to estimate the gas for\n * @param params.walletAccount - The wallet account that will be used to send the transaction\n * @returns The gas for the transaction in wei\n */\nexport const estimateTransactionGas = async ({\n walletAccount,\n transaction,\n}: EstimateTransactionGasParams): Promise<bigint | null> => {\n try {\n const kernelClientWithoutSponsorship =\n await createKernelClientForWalletAccount({\n smartWalletAccount: walletAccount,\n withSponsorship: false,\n });\n\n const unsponsoredUserOperation = await prepareUserOperationWithKernelClient(\n {\n kernelClient: kernelClientWithoutSponsorship,\n transaction,\n }\n );\n\n return calculateGasForUserOperation({\n userOperationData: unsponsoredUserOperation,\n });\n } catch {\n return null;\n }\n};\n","export 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 { 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 { canSponsorTransaction } from '../canSponsorTransaction';\nexport { createKernelClientForWalletAccount } from '../createKernelClientForWalletAccount';\nexport type { Eip7702Authorization } from '../createKernelClientForWalletAccount';\nexport { estimateTransactionGas } from '../estimateTransactionGas';\nexport { getSignerForSmartWalletAccount } from '../getSignerForSmartWalletAccount';\nexport { isGasSponsorshipError } from '../isGasSponsorshipError';\nexport type { KernelClient } from '../KernelClient.types';\n"],"mappings":";;;;;;;;;;;AAMA,MAAa,8BAA8B,WAAoC;AAkB7E,SAhBE,OAAO,MAAM,oBAAoB,QAC9B,eACC,WAAW,mBAAmB,mBAAmB,uBACjD,WA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