@dynamic-labs-sdk/zerodev 1.12.2 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addZerodevExtension/addZerodevExtension.d.ts +1 -1
- package/dist/canSponsorUserOperation/canSponsorUserOperation.d.ts +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.esm.js +1 -1
- package/dist/createKernelClientForWalletAccount/createKernelClientForWalletAccount.d.ts +1 -1
- package/dist/estimateUserOperationGas/estimateUserOperationGas.d.ts +1 -1
- package/dist/getSignerForSmartWalletAccount/getSignerForSmartWalletAccount.d.ts +1 -1
- package/dist/{getZerodevRpc-DLO46Gsl.esm.js → getZerodevRpc-BkKOvyYF.esm.js} +12 -12
- package/dist/getZerodevRpc-BkKOvyYF.esm.js.map +1 -0
- package/dist/{getZerodevRpc-C4vRIMfD.cjs → getZerodevRpc-E-_0au56.cjs} +12 -12
- package/dist/getZerodevRpc-E-_0au56.cjs.map +1 -0
- package/dist/index.cjs +19 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +19 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/isGasSponsorshipError/isGasSponsorshipError.d.ts +1 -1
- package/dist/isGasSponsorshipError/isGasSponsorshipError.d.ts.map +1 -1
- package/dist/isZerodevWalletAccount/isZerodevWalletAccount.d.ts +1 -1
- package/dist/sendUserOperation/sendUserOperation.d.ts +1 -1
- package/dist/signEip7702Authorization/signEip7702Authorization.d.ts +1 -1
- package/dist/simulateZerodevUserOperation/simulateZerodevUserOperation.d.ts +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/calculateFeeForUserOperation/calculateFeeForUserOperation.d.ts +1 -1
- package/dist/utils/calculateGasForUserOperation/calculateGasForUserOperation.d.ts +1 -1
- package/dist/utils/calculateGasForUserOperation/calculateGasForUserOperation.d.ts.map +1 -1
- package/dist/utils/createKernelAccount/createKernelAccount.d.ts +1 -1
- package/dist/utils/createZerodevWalletProvider/createZerodevWalletProvider.d.ts +1 -1
- package/dist/utils/createZerodevWalletProvider/createZerodevWalletProvider.d.ts.map +1 -1
- package/dist/utils/getAllUserZerodevAddresses/getAllUserZerodevAddresses.d.ts +1 -1
- package/dist/utils/getAllUserZerodevAddresses/getAllUserZerodevAddresses.d.ts.map +1 -1
- package/dist/utils/getEcdsaValidator/getEcdsaValidator.d.ts +1 -1
- package/dist/utils/getEcdsaValidator/getEcdsaValidator.d.ts.map +1 -1
- package/dist/utils/getEntryPoint/getEntryPoint.d.ts +1 -1
- package/dist/utils/getEntryPoint/getEntryPoint.d.ts.map +1 -1
- package/dist/utils/getKernelVersion/getKernelVersion.d.ts +1 -1
- package/dist/utils/getKernelVersion/getKernelVersion.d.ts.map +1 -1
- package/dist/utils/getPaymasterConfig/getPaymasterConfig.d.ts +1 -1
- package/dist/utils/getPaymasterConfig/getPaymasterConfig.d.ts.map +1 -1
- package/dist/utils/getZerodevChainProviderForNetworkId/getZerodevChainProviderForNetworkId.d.ts +1 -1
- package/dist/utils/getZerodevChainProviderForNetworkId/getZerodevChainProviderForNetworkId.d.ts.map +1 -1
- package/dist/utils/getZerodevProviderFromSettings/getZerodevProviderFromSettings.d.ts +1 -1
- package/dist/utils/getZerodevProviderFromSettings/getZerodevProviderFromSettings.d.ts.map +1 -1
- package/dist/utils/getZerodevRpc/getZerodevRpc.d.ts +1 -1
- package/dist/utils/getZerodevRpc/getZerodevRpc.d.ts.map +1 -1
- package/dist/utils/hasRequiredGasFields/hasRequiredGasFields.d.ts +1 -1
- package/dist/utils/prepareUserOperationFromCalls/prepareUserOperationFromCalls.d.ts +1 -1
- package/dist/utils/shouldSignWithEoa/shouldSignWithEoa.d.ts +1 -1
- package/dist/utils/shouldSignWithEoa/shouldSignWithEoa.d.ts.map +1 -1
- package/dist/utils/shouldUseEIP7702/shouldUseEIP7702.d.ts +1 -1
- package/dist/utils/shouldUseEIP7702/shouldUseEIP7702.d.ts.map +1 -1
- package/dist/utils/signMessage/signMessage.d.ts +1 -1
- package/dist/utils/signMessage/signMessage.d.ts.map +1 -1
- package/dist/utils/zerodevTransferAmount/zerodevTransferAmount.d.ts +1 -1
- package/package.json +4 -4
- package/dist/getZerodevRpc-C4vRIMfD.cjs.map +0 -1
- package/dist/getZerodevRpc-DLO46Gsl.esm.js.map +0 -1
|
@@ -5,7 +5,7 @@ export declare const ZERODEV_EXTENSION_KEY = "zerodev";
|
|
|
5
5
|
* This extension enables Account Abstraction integration with ZeroDev
|
|
6
6
|
*
|
|
7
7
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
8
|
-
* @
|
|
8
|
+
* @notInstrumented
|
|
9
9
|
*/
|
|
10
10
|
export declare const addZerodevExtension: (client?: import("@dynamic-labs-sdk/client").DynamicClient) => void;
|
|
11
11
|
//# sourceMappingURL=addZerodevExtension.d.ts.map
|
|
@@ -21,7 +21,7 @@ export type CanSponsorUserOperationParams = CanSponsorUserOperationWithWalletPar
|
|
|
21
21
|
* @param params.kernelClient - Optional kernel client with sponsorship configured
|
|
22
22
|
* @param params.walletAccount - The wallet account to use (required if kernelClient not provided)
|
|
23
23
|
* @returns True if the user operation can be sponsored, false otherwise
|
|
24
|
-
* @
|
|
24
|
+
* @notInstrumented
|
|
25
25
|
*/
|
|
26
26
|
export declare const canSponsorUserOperation: ({ walletAccount, calls, kernelClient, }: CanSponsorUserOperationParams) => Promise<boolean>;
|
|
27
27
|
export {};
|
package/dist/core.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_getZerodevRpc = require('./getZerodevRpc-
|
|
1
|
+
const require_getZerodevRpc = require('./getZerodevRpc-E-_0au56.cjs');
|
|
2
2
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
3
3
|
|
|
4
4
|
//#region src/exports/core.ts
|
package/dist/core.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getKernelVersion, i as shouldUseEIP7702, l as getZerodevChainProviderForNetworkId, m as version, n as getPaymasterConfig, o as getEntryPoint, p as name, r as createKernelAccount, s as getEcdsaValidator, t as getZerodevRpc, u as getZerodevProviderFromSettings } from "./getZerodevRpc-
|
|
1
|
+
import { a as getKernelVersion, i as shouldUseEIP7702, l as getZerodevChainProviderForNetworkId, m as version, n as getPaymasterConfig, o as getEntryPoint, p as name, r as createKernelAccount, s as getEcdsaValidator, t as getZerodevRpc, u as getZerodevProviderFromSettings } from "./getZerodevRpc-BkKOvyYF.esm.js";
|
|
2
2
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
3
3
|
|
|
4
4
|
//#region src/exports/core.ts
|
|
@@ -30,7 +30,7 @@ type CreateKernelClientForWalletAccountParams = {
|
|
|
30
30
|
* to separate the authorization signing step from the transaction step.
|
|
31
31
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
32
32
|
* @returns A promise that resolves to a KernelClient instance.
|
|
33
|
-
* @
|
|
33
|
+
* @notInstrumented
|
|
34
34
|
*/
|
|
35
35
|
export declare const createKernelClientForWalletAccount: ({ smartWalletAccount, withSponsorship, bundlerProvider, networkId, bundlerRpc: bundlerRpcOverride, paymasterRpc: paymasterRpcOverride, gasTokenAddress, eip7702Auth, }: CreateKernelClientForWalletAccountParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<KernelClient>;
|
|
36
36
|
export {};
|
|
@@ -11,7 +11,7 @@ export type EstimateUserOperationGasParams = {
|
|
|
11
11
|
* @param params.calls - Array of calls (single call or multiple calls)
|
|
12
12
|
* @param params.walletAccount - The wallet account that will execute the user operation
|
|
13
13
|
* @returns The estimated gas cost in wei, or null if estimation fails
|
|
14
|
-
* @
|
|
14
|
+
* @notInstrumented
|
|
15
15
|
*/
|
|
16
16
|
export declare const estimateUserOperationGas: ({ walletAccount, calls, }: EstimateUserOperationGasParams) => Promise<bigint | null>;
|
|
17
17
|
//# sourceMappingURL=estimateUserOperationGas.d.ts.map
|
|
@@ -11,7 +11,7 @@ type GetSignerForSmartWalletAccountParams = {
|
|
|
11
11
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
12
12
|
* @returns A promise that resolves to an WalletClient instance.
|
|
13
13
|
* @throws NoSmartWalletAccountSignerFoundError When the signer wallet account is not found for the given smart wallet account.
|
|
14
|
-
* @
|
|
14
|
+
* @notInstrumented
|
|
15
15
|
*/
|
|
16
16
|
export declare const getSignerForSmartWalletAccount: ({ smartWalletAccount }: GetSignerForSmartWalletAccountParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<WalletClient<Transport, Chain, Account>>;
|
|
17
17
|
export {};
|
|
@@ -10,7 +10,7 @@ import { toMultiChainECDSAValidator } from "@zerodev/multi-chain-ecdsa-validator
|
|
|
10
10
|
|
|
11
11
|
//#region package.json
|
|
12
12
|
var name = "@dynamic-labs-sdk/zerodev";
|
|
13
|
-
var version = "1.
|
|
13
|
+
var version = "1.13.0";
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/constants.ts
|
|
@@ -51,7 +51,7 @@ const ERC20_TRANSFER_ABI = [{
|
|
|
51
51
|
|
|
52
52
|
//#endregion
|
|
53
53
|
//#region src/utils/getZerodevProviderFromSettings/getZerodevProviderFromSettings.ts
|
|
54
|
-
/** @
|
|
54
|
+
/** @notInstrumented */
|
|
55
55
|
const getZerodevProviderFromSettings = (client) => {
|
|
56
56
|
const projectSettings = client.projectSettings;
|
|
57
57
|
assertDefined(projectSettings, "Project settings are not available");
|
|
@@ -62,7 +62,7 @@ const getZerodevProviderFromSettings = (client) => {
|
|
|
62
62
|
|
|
63
63
|
//#endregion
|
|
64
64
|
//#region src/utils/getZerodevChainProviderForNetworkId/getZerodevChainProviderForNetworkId.ts
|
|
65
|
-
/** @
|
|
65
|
+
/** @notInstrumented */
|
|
66
66
|
const getZerodevChainProviderForNetworkId = ({ networkId }, client) => {
|
|
67
67
|
return getZerodevProviderFromSettings(client).multichainAccountAbstractionProviders?.find((provider) => provider.chain === networkId);
|
|
68
68
|
};
|
|
@@ -77,7 +77,7 @@ const getZerodevChainProviderForNetworkId = ({ networkId }, client) => {
|
|
|
77
77
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
78
78
|
* @returns A promise that resolves to an WalletClient instance.
|
|
79
79
|
* @throws NoSmartWalletAccountSignerFoundError When the signer wallet account is not found for the given smart wallet account.
|
|
80
|
-
* @
|
|
80
|
+
* @notInstrumented
|
|
81
81
|
*/
|
|
82
82
|
const getSignerForSmartWalletAccount = ({ smartWalletAccount }, client = getDefaultClient()) => {
|
|
83
83
|
const signerWalletAccount = getOwnerWalletAccountForSmartWalletAccount({ smartWalletAccount }, client);
|
|
@@ -87,7 +87,7 @@ const getSignerForSmartWalletAccount = ({ smartWalletAccount }, client = getDefa
|
|
|
87
87
|
|
|
88
88
|
//#endregion
|
|
89
89
|
//#region src/utils/getEcdsaValidator/getEcdsaValidator.ts
|
|
90
|
-
/** @
|
|
90
|
+
/** @notInstrumented */
|
|
91
91
|
const getEcdsaValidator = ({ ecdsaProviderType, publicClient, signer, entryPoint, kernelVersion }) => {
|
|
92
92
|
const params = {
|
|
93
93
|
entryPoint,
|
|
@@ -100,7 +100,7 @@ const getEcdsaValidator = ({ ecdsaProviderType, publicClient, signer, entryPoint
|
|
|
100
100
|
|
|
101
101
|
//#endregion
|
|
102
102
|
//#region src/utils/getEntryPoint/getEntryPoint.ts
|
|
103
|
-
/** @
|
|
103
|
+
/** @notInstrumented */
|
|
104
104
|
const getEntryPoint = (entryPoint) => {
|
|
105
105
|
if (entryPoint === ProviderEntryPointVersionEnum.V6) return constants.getEntryPoint("0.6");
|
|
106
106
|
return constants.getEntryPoint("0.7");
|
|
@@ -108,7 +108,7 @@ const getEntryPoint = (entryPoint) => {
|
|
|
108
108
|
|
|
109
109
|
//#endregion
|
|
110
110
|
//#region src/utils/getKernelVersion/getKernelVersion.ts
|
|
111
|
-
/** @
|
|
111
|
+
/** @notInstrumented */
|
|
112
112
|
const getKernelVersion = ({ kernelVersion, entryPoint }) => {
|
|
113
113
|
if (kernelVersion && kernelVersion in KERNEL_VERSION_MAP) return KERNEL_VERSION_MAP[kernelVersion];
|
|
114
114
|
const entryPointVersion = entryPoint.version;
|
|
@@ -118,7 +118,7 @@ const getKernelVersion = ({ kernelVersion, entryPoint }) => {
|
|
|
118
118
|
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/utils/shouldUseEIP7702/shouldUseEIP7702.ts
|
|
121
|
-
/** @
|
|
121
|
+
/** @notInstrumented */
|
|
122
122
|
const shouldUseEIP7702 = ({ smartWalletAccount }, client) => {
|
|
123
123
|
const zerodevProvider = getZerodevProviderFromSettings(client);
|
|
124
124
|
assertDefined(zerodevProvider, "Zerodev provider is not enabled in project settings");
|
|
@@ -139,7 +139,7 @@ const shouldUseEIP7702 = ({ smartWalletAccount }, client) => {
|
|
|
139
139
|
* @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.
|
|
140
140
|
* @param client - The Dynamic client instance.
|
|
141
141
|
* @returns A promise that resolves to a ZeroDev kernel account.
|
|
142
|
-
* @
|
|
142
|
+
* @notInstrumented
|
|
143
143
|
*/
|
|
144
144
|
const createKernelAccount$1 = async ({ publicClient, smartWalletAccount, eip7702Auth }, client) => {
|
|
145
145
|
const zerodevProvider = getZerodevProviderFromSettings(client);
|
|
@@ -183,7 +183,7 @@ const createKernelAccount$1 = async ({ publicClient, smartWalletAccount, eip7702
|
|
|
183
183
|
|
|
184
184
|
//#endregion
|
|
185
185
|
//#region src/utils/getPaymasterConfig/getPaymasterConfig.ts
|
|
186
|
-
/** @
|
|
186
|
+
/** @notInstrumented */
|
|
187
187
|
const getPaymasterConfig = ({ chain, gasTokenAddress, paymasterRpc }) => {
|
|
188
188
|
const getPaymasterData = (params) => {
|
|
189
189
|
return createZeroDevPaymasterClient({
|
|
@@ -199,7 +199,7 @@ const getPaymasterConfig = ({ chain, gasTokenAddress, paymasterRpc }) => {
|
|
|
199
199
|
|
|
200
200
|
//#endregion
|
|
201
201
|
//#region src/utils/getZerodevRpc/getZerodevRpc.ts
|
|
202
|
-
/** @
|
|
202
|
+
/** @notInstrumented */
|
|
203
203
|
const getZerodevRpc = ({ networkId, bundlerProvider, rpcType }, client) => {
|
|
204
204
|
const zerodevProvider = getZerodevProviderFromSettings(client);
|
|
205
205
|
if (zerodevProvider?.zerodevPaymasterRpcUrl) return zerodevProvider.zerodevPaymasterRpcUrl;
|
|
@@ -212,4 +212,4 @@ const getZerodevRpc = ({ networkId, bundlerProvider, rpcType }, client) => {
|
|
|
212
212
|
|
|
213
213
|
//#endregion
|
|
214
214
|
export { getKernelVersion as a, getSignerForSmartWalletAccount as c, ERC20_TRANSFER_ABI as d, ZERODEV_METADATA as f, shouldUseEIP7702 as i, getZerodevChainProviderForNetworkId as l, version as m, getPaymasterConfig as n, getEntryPoint as o, name as p, createKernelAccount$1 as r, getEcdsaValidator as s, getZerodevRpc as t, getZerodevProviderFromSettings as u };
|
|
215
|
-
//# sourceMappingURL=getZerodevRpc-
|
|
215
|
+
//# sourceMappingURL=getZerodevRpc-BkKOvyYF.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getZerodevRpc-BkKOvyYF.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\nexport const ERC20_TRANSFER_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const;\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport { ProviderEnum } from '@dynamic-labs/sdk-api-core';\n\n/** @notInstrumented */\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\n/** @notInstrumented */\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 * @notInstrumented\n */\nexport const getSignerForSmartWalletAccount = (\n { smartWalletAccount }: GetSignerForSmartWalletAccountParams,\n client = getDefaultClient()\n): Promise<WalletClient<Transport, Chain, Account>> => {\n const signerWalletAccount = getOwnerWalletAccountForSmartWalletAccount(\n { smartWalletAccount },\n client\n );\n\n if (!signerWalletAccount || !isEvmWalletAccount(signerWalletAccount)) {\n throw new NoSmartWalletAccountSignerFoundError(smartWalletAccount.address);\n }\n\n return createWalletClientForWalletAccount(\n {\n walletAccount: signerWalletAccount,\n },\n client\n );\n};\n","import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator';\nimport { toMultiChainECDSAValidator } from '@zerodev/multi-chain-ecdsa-validator';\nimport type {\n EntryPointType,\n GetKernelVersion,\n Signer,\n} from '@zerodev/sdk/types';\nimport type { Client } from 'viem';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\n\ntype GetEcdsaValidatorParams = {\n ecdsaProviderType?: string;\n entryPoint: EntryPointType<EntryPointVersion>;\n kernelVersion: GetKernelVersion<EntryPointVersion>;\n publicClient: Client;\n signer: Signer;\n};\n\n/** @notInstrumented */\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\n/** @notInstrumented */\n// eslint-disable-next-line custom-rules/require-single-object-param\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\n/** @notInstrumented */\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\n/** @notInstrumented */\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 * @notInstrumented\n */\nexport const createKernelAccount = async (\n { publicClient, smartWalletAccount, eip7702Auth }: CreateKernelAccountParams,\n client: DynamicClient\n): Promise<CreateKernelAccountReturnType<EntryPointVersion>> => {\n const zerodevProvider = getZerodevProviderFromSettings(client);\n\n assertDefined(\n zerodevProvider,\n 'Zerodev provider is not enabled in project settings'\n );\n\n const signer = await getSignerForSmartWalletAccount(\n {\n smartWalletAccount,\n },\n client\n );\n\n const walletProperties = getVerifiedCredentialForWalletAccount(\n { walletAccount: smartWalletAccount },\n client\n )?.walletProperties;\n\n const entryPointVersion =\n walletProperties?.entryPointVersion ?? zerodevProvider.entryPointVersion;\n const entryPoint = getEntryPoint(entryPointVersion);\n\n const useEIP7702 = shouldUseEIP7702({ smartWalletAccount }, client);\n\n if (useEIP7702) {\n return createZerodevKernelAccount(publicClient, {\n eip7702Account: signer,\n eip7702Auth,\n entryPoint,\n kernelVersion: constants.KERNEL_V3_3,\n });\n }\n\n const kernelVersionValue =\n walletProperties?.kernelVersion ?? zerodevProvider.kernelVersion;\n\n const kernelVersion = getKernelVersion({\n entryPoint,\n kernelVersion: kernelVersionValue,\n });\n\n const kernelV3MigrationEnabled =\n zerodevProvider.enableKernelV3Migration ?? false;\n\n if (kernelV3MigrationEnabled) {\n const apiKernelVersion = getKernelVersion({\n entryPoint,\n kernelVersion: zerodevProvider.kernelVersion,\n });\n\n return createEcdsaKernelMigrationAccount(publicClient, {\n entryPoint,\n migrationVersion: {\n from: kernelVersion,\n to: apiKernelVersion,\n },\n signer,\n });\n }\n\n const validator = await getEcdsaValidator({\n ecdsaProviderType:\n walletProperties?.ecdsaProviderType ?? zerodevProvider.ecdsaProviderType,\n entryPoint,\n kernelVersion,\n publicClient,\n signer,\n });\n\n return createZerodevKernelAccount(publicClient, {\n entryPoint,\n kernelVersion,\n plugins: {\n sudo: validator,\n },\n });\n};\n","import { 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\n/** @notInstrumented */\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\n/** @notInstrumented */\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,UA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;;;;ACzGJ,MAAa,sBAAsB,EACjC,OACA,iBACA,mBAC6B;CAC7B,MAAM,oBAAoB,WAAuC;AAM/D,SALyB,6BAA6B;GACpD;GACA,WAAW,KAAK,aAAa;GAC9B,CAAC,CAEsB,qBAAqB;GAC3C,UAAU;GACV,eAAe;GAChB,CAAC;;AAGJ,QAAO,EACL,WAAW,EACT,kBACD,EACF;;;;;;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"}
|
|
@@ -10,7 +10,7 @@ let _zerodev_multi_chain_ecdsa_validator = require("@zerodev/multi-chain-ecdsa-v
|
|
|
10
10
|
|
|
11
11
|
//#region package.json
|
|
12
12
|
var name = "@dynamic-labs-sdk/zerodev";
|
|
13
|
-
var version = "1.
|
|
13
|
+
var version = "1.13.0";
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/constants.ts
|
|
@@ -51,7 +51,7 @@ const ERC20_TRANSFER_ABI = [{
|
|
|
51
51
|
|
|
52
52
|
//#endregion
|
|
53
53
|
//#region src/utils/getZerodevProviderFromSettings/getZerodevProviderFromSettings.ts
|
|
54
|
-
/** @
|
|
54
|
+
/** @notInstrumented */
|
|
55
55
|
const getZerodevProviderFromSettings = (client) => {
|
|
56
56
|
const projectSettings = client.projectSettings;
|
|
57
57
|
(0, _dynamic_labs_sdk_client_core.assertDefined)(projectSettings, "Project settings are not available");
|
|
@@ -62,7 +62,7 @@ const getZerodevProviderFromSettings = (client) => {
|
|
|
62
62
|
|
|
63
63
|
//#endregion
|
|
64
64
|
//#region src/utils/getZerodevChainProviderForNetworkId/getZerodevChainProviderForNetworkId.ts
|
|
65
|
-
/** @
|
|
65
|
+
/** @notInstrumented */
|
|
66
66
|
const getZerodevChainProviderForNetworkId = ({ networkId }, client) => {
|
|
67
67
|
return getZerodevProviderFromSettings(client).multichainAccountAbstractionProviders?.find((provider) => provider.chain === networkId);
|
|
68
68
|
};
|
|
@@ -77,7 +77,7 @@ const getZerodevChainProviderForNetworkId = ({ networkId }, client) => {
|
|
|
77
77
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
78
78
|
* @returns A promise that resolves to an WalletClient instance.
|
|
79
79
|
* @throws NoSmartWalletAccountSignerFoundError When the signer wallet account is not found for the given smart wallet account.
|
|
80
|
-
* @
|
|
80
|
+
* @notInstrumented
|
|
81
81
|
*/
|
|
82
82
|
const getSignerForSmartWalletAccount = ({ smartWalletAccount }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
83
83
|
const signerWalletAccount = (0, _dynamic_labs_sdk_client.getOwnerWalletAccountForSmartWalletAccount)({ smartWalletAccount }, client);
|
|
@@ -87,7 +87,7 @@ const getSignerForSmartWalletAccount = ({ smartWalletAccount }, client = (0, _dy
|
|
|
87
87
|
|
|
88
88
|
//#endregion
|
|
89
89
|
//#region src/utils/getEcdsaValidator/getEcdsaValidator.ts
|
|
90
|
-
/** @
|
|
90
|
+
/** @notInstrumented */
|
|
91
91
|
const getEcdsaValidator = ({ ecdsaProviderType, publicClient, signer, entryPoint, kernelVersion }) => {
|
|
92
92
|
const params = {
|
|
93
93
|
entryPoint,
|
|
@@ -100,7 +100,7 @@ const getEcdsaValidator = ({ ecdsaProviderType, publicClient, signer, entryPoint
|
|
|
100
100
|
|
|
101
101
|
//#endregion
|
|
102
102
|
//#region src/utils/getEntryPoint/getEntryPoint.ts
|
|
103
|
-
/** @
|
|
103
|
+
/** @notInstrumented */
|
|
104
104
|
const getEntryPoint = (entryPoint) => {
|
|
105
105
|
if (entryPoint === _dynamic_labs_sdk_api_core.ProviderEntryPointVersionEnum.V6) return _zerodev_sdk.constants.getEntryPoint("0.6");
|
|
106
106
|
return _zerodev_sdk.constants.getEntryPoint("0.7");
|
|
@@ -108,7 +108,7 @@ const getEntryPoint = (entryPoint) => {
|
|
|
108
108
|
|
|
109
109
|
//#endregion
|
|
110
110
|
//#region src/utils/getKernelVersion/getKernelVersion.ts
|
|
111
|
-
/** @
|
|
111
|
+
/** @notInstrumented */
|
|
112
112
|
const getKernelVersion = ({ kernelVersion, entryPoint }) => {
|
|
113
113
|
if (kernelVersion && kernelVersion in KERNEL_VERSION_MAP) return KERNEL_VERSION_MAP[kernelVersion];
|
|
114
114
|
const entryPointVersion = entryPoint.version;
|
|
@@ -118,7 +118,7 @@ const getKernelVersion = ({ kernelVersion, entryPoint }) => {
|
|
|
118
118
|
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/utils/shouldUseEIP7702/shouldUseEIP7702.ts
|
|
121
|
-
/** @
|
|
121
|
+
/** @notInstrumented */
|
|
122
122
|
const shouldUseEIP7702 = ({ smartWalletAccount }, client) => {
|
|
123
123
|
const zerodevProvider = getZerodevProviderFromSettings(client);
|
|
124
124
|
(0, _dynamic_labs_sdk_client_core.assertDefined)(zerodevProvider, "Zerodev provider is not enabled in project settings");
|
|
@@ -139,7 +139,7 @@ const shouldUseEIP7702 = ({ smartWalletAccount }, client) => {
|
|
|
139
139
|
* @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.
|
|
140
140
|
* @param client - The Dynamic client instance.
|
|
141
141
|
* @returns A promise that resolves to a ZeroDev kernel account.
|
|
142
|
-
* @
|
|
142
|
+
* @notInstrumented
|
|
143
143
|
*/
|
|
144
144
|
const createKernelAccount = async ({ publicClient, smartWalletAccount, eip7702Auth }, client) => {
|
|
145
145
|
const zerodevProvider = getZerodevProviderFromSettings(client);
|
|
@@ -183,7 +183,7 @@ const createKernelAccount = async ({ publicClient, smartWalletAccount, eip7702Au
|
|
|
183
183
|
|
|
184
184
|
//#endregion
|
|
185
185
|
//#region src/utils/getPaymasterConfig/getPaymasterConfig.ts
|
|
186
|
-
/** @
|
|
186
|
+
/** @notInstrumented */
|
|
187
187
|
const getPaymasterConfig = ({ chain, gasTokenAddress, paymasterRpc }) => {
|
|
188
188
|
const getPaymasterData = (params) => {
|
|
189
189
|
return (0, _zerodev_sdk.createZeroDevPaymasterClient)({
|
|
@@ -199,7 +199,7 @@ const getPaymasterConfig = ({ chain, gasTokenAddress, paymasterRpc }) => {
|
|
|
199
199
|
|
|
200
200
|
//#endregion
|
|
201
201
|
//#region src/utils/getZerodevRpc/getZerodevRpc.ts
|
|
202
|
-
/** @
|
|
202
|
+
/** @notInstrumented */
|
|
203
203
|
const getZerodevRpc = ({ networkId, bundlerProvider, rpcType }, client) => {
|
|
204
204
|
const zerodevProvider = getZerodevProviderFromSettings(client);
|
|
205
205
|
if (zerodevProvider?.zerodevPaymasterRpcUrl) return zerodevProvider.zerodevPaymasterRpcUrl;
|
|
@@ -295,4 +295,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
295
295
|
return version;
|
|
296
296
|
}
|
|
297
297
|
});
|
|
298
|
-
//# sourceMappingURL=getZerodevRpc-
|
|
298
|
+
//# sourceMappingURL=getZerodevRpc-E-_0au56.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getZerodevRpc-E-_0au56.cjs","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\nexport const ERC20_TRANSFER_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const;\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined } from '@dynamic-labs-sdk/client/core';\nimport { ProviderEnum } from '@dynamic-labs/sdk-api-core';\n\n/** @notInstrumented */\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\n/** @notInstrumented */\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 * @notInstrumented\n */\nexport const getSignerForSmartWalletAccount = (\n { smartWalletAccount }: GetSignerForSmartWalletAccountParams,\n client = getDefaultClient()\n): Promise<WalletClient<Transport, Chain, Account>> => {\n const signerWalletAccount = getOwnerWalletAccountForSmartWalletAccount(\n { smartWalletAccount },\n client\n );\n\n if (!signerWalletAccount || !isEvmWalletAccount(signerWalletAccount)) {\n throw new NoSmartWalletAccountSignerFoundError(smartWalletAccount.address);\n }\n\n return createWalletClientForWalletAccount(\n {\n walletAccount: signerWalletAccount,\n },\n client\n );\n};\n","import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator';\nimport { toMultiChainECDSAValidator } from '@zerodev/multi-chain-ecdsa-validator';\nimport type {\n EntryPointType,\n GetKernelVersion,\n Signer,\n} from '@zerodev/sdk/types';\nimport type { Client } from 'viem';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\n\ntype GetEcdsaValidatorParams = {\n ecdsaProviderType?: string;\n entryPoint: EntryPointType<EntryPointVersion>;\n kernelVersion: GetKernelVersion<EntryPointVersion>;\n publicClient: Client;\n signer: Signer;\n};\n\n/** @notInstrumented */\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\n/** @notInstrumented */\n// eslint-disable-next-line custom-rules/require-single-object-param\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\n/** @notInstrumented */\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\n/** @notInstrumented */\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 * @notInstrumented\n */\nexport const createKernelAccount = async (\n { publicClient, smartWalletAccount, eip7702Auth }: CreateKernelAccountParams,\n client: DynamicClient\n): Promise<CreateKernelAccountReturnType<EntryPointVersion>> => {\n const zerodevProvider = getZerodevProviderFromSettings(client);\n\n assertDefined(\n zerodevProvider,\n 'Zerodev provider is not enabled in project settings'\n );\n\n const signer = await getSignerForSmartWalletAccount(\n {\n smartWalletAccount,\n },\n client\n );\n\n const walletProperties = getVerifiedCredentialForWalletAccount(\n { walletAccount: smartWalletAccount },\n client\n )?.walletProperties;\n\n const entryPointVersion =\n walletProperties?.entryPointVersion ?? zerodevProvider.entryPointVersion;\n const entryPoint = getEntryPoint(entryPointVersion);\n\n const useEIP7702 = shouldUseEIP7702({ smartWalletAccount }, client);\n\n if (useEIP7702) {\n return createZerodevKernelAccount(publicClient, {\n eip7702Account: signer,\n eip7702Auth,\n entryPoint,\n kernelVersion: constants.KERNEL_V3_3,\n });\n }\n\n const kernelVersionValue =\n walletProperties?.kernelVersion ?? zerodevProvider.kernelVersion;\n\n const kernelVersion = getKernelVersion({\n entryPoint,\n kernelVersion: kernelVersionValue,\n });\n\n const kernelV3MigrationEnabled =\n zerodevProvider.enableKernelV3Migration ?? false;\n\n if (kernelV3MigrationEnabled) {\n const apiKernelVersion = getKernelVersion({\n entryPoint,\n kernelVersion: zerodevProvider.kernelVersion,\n });\n\n return createEcdsaKernelMigrationAccount(publicClient, {\n entryPoint,\n migrationVersion: {\n from: kernelVersion,\n to: apiKernelVersion,\n },\n signer,\n });\n }\n\n const validator = await getEcdsaValidator({\n ecdsaProviderType:\n walletProperties?.ecdsaProviderType ?? zerodevProvider.ecdsaProviderType,\n entryPoint,\n kernelVersion,\n publicClient,\n signer,\n });\n\n return createZerodevKernelAccount(publicClient, {\n entryPoint,\n kernelVersion,\n plugins: {\n sudo: validator,\n },\n });\n};\n","import { 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\n/** @notInstrumented */\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\n/** @notInstrumented */\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;CAC9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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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_getZerodevRpc = require('./getZerodevRpc-
|
|
1
|
+
const require_getZerodevRpc = require('./getZerodevRpc-E-_0au56.cjs');
|
|
2
2
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
3
3
|
let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
|
|
4
4
|
let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
@@ -10,7 +10,7 @@ let viem = require("viem");
|
|
|
10
10
|
let viem_actions = require("viem/actions");
|
|
11
11
|
|
|
12
12
|
//#region src/utils/getAllUserZerodevAddresses/getAllUserZerodevAddresses.ts
|
|
13
|
-
/** @
|
|
13
|
+
/** @notInstrumented */
|
|
14
14
|
const getAllUserZerodevAddresses = (client) => {
|
|
15
15
|
return (client.user?.verifiedCredentials.filter((credential) => credential.walletProvider === _dynamic_labs_sdk_api_core.WalletProviderEnum.SmartContractWallet && credential.walletName?.toLowerCase().startsWith(require_getZerodevRpc.ZERODEV_METADATA.normalizedWalletName) && credential.address && credential.chain && (0, _dynamic_labs_sdk_client_core.getChainFromVerifiedCredentialChain)(credential.chain) === "EVM") ?? []).map((credential) => credential.address);
|
|
16
16
|
};
|
|
@@ -33,7 +33,7 @@ const getAllUserZerodevAddresses = (client) => {
|
|
|
33
33
|
* to separate the authorization signing step from the transaction step.
|
|
34
34
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
35
35
|
* @returns A promise that resolves to a KernelClient instance.
|
|
36
|
-
* @
|
|
36
|
+
* @notInstrumented
|
|
37
37
|
*/
|
|
38
38
|
const createKernelClientForWalletAccount = async ({ smartWalletAccount, withSponsorship = true, bundlerProvider, networkId, bundlerRpc: bundlerRpcOverride, paymasterRpc: paymasterRpcOverride, gasTokenAddress, eip7702Auth }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
39
39
|
let networkData;
|
|
@@ -83,7 +83,7 @@ const createKernelClientForWalletAccount = async ({ smartWalletAccount, withSpon
|
|
|
83
83
|
|
|
84
84
|
//#endregion
|
|
85
85
|
//#region src/utils/shouldSignWithEoa/shouldSignWithEoa.ts
|
|
86
|
-
/** @
|
|
86
|
+
/** @notInstrumented */
|
|
87
87
|
const shouldSignWithEoa = async ({ kernelClient, smartWalletAccount }, client) => {
|
|
88
88
|
if (!require_getZerodevRpc.shouldUseEIP7702({ smartWalletAccount }, client)) return false;
|
|
89
89
|
return !await kernelClient.account.isDeployed();
|
|
@@ -91,7 +91,7 @@ const shouldSignWithEoa = async ({ kernelClient, smartWalletAccount }, client) =
|
|
|
91
91
|
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/utils/signMessage/signMessage.ts
|
|
94
|
-
/** @
|
|
94
|
+
/** @notInstrumented */
|
|
95
95
|
const signMessage = async ({ walletAccount, message }, client) => {
|
|
96
96
|
const kernelClient = await createKernelClientForWalletAccount({ smartWalletAccount: walletAccount }, client);
|
|
97
97
|
if (await shouldSignWithEoa({
|
|
@@ -111,7 +111,7 @@ const signMessage = async ({ walletAccount, message }, client) => {
|
|
|
111
111
|
|
|
112
112
|
//#endregion
|
|
113
113
|
//#region src/isGasSponsorshipError/isGasSponsorshipError.ts
|
|
114
|
-
/** @
|
|
114
|
+
/** @notInstrumented */
|
|
115
115
|
const isGasSponsorshipError = (err) => {
|
|
116
116
|
return err?.message?.includes("userOp did not match any gas sponsoring policies") || false;
|
|
117
117
|
};
|
|
@@ -124,7 +124,7 @@ const EVM_NATIVE_DECIMALS = 18;
|
|
|
124
124
|
*
|
|
125
125
|
* Attempts with gas sponsorship first, then falls back to unsponsored
|
|
126
126
|
* if the paymaster rejects.
|
|
127
|
-
* @
|
|
127
|
+
* @notInstrumented
|
|
128
128
|
*/
|
|
129
129
|
const zerodevTransferAmount = async ({ amount, recipient, token, walletAccount }, client) => {
|
|
130
130
|
if (!(0, _dynamic_labs_sdk_evm.isEvmWalletAccount)(walletAccount)) throw new _dynamic_labs_sdk_client.InvalidParamError("Wallet account is not an EVM wallet account");
|
|
@@ -166,7 +166,7 @@ const zerodevTransferAmount = async ({ amount, recipient, token, walletAccount }
|
|
|
166
166
|
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region src/utils/createZerodevWalletProvider/createZerodevWalletProvider.ts
|
|
169
|
-
/** @
|
|
169
|
+
/** @notInstrumented */
|
|
170
170
|
const createZerodevWalletProvider = (client) => {
|
|
171
171
|
const chain = "EVM";
|
|
172
172
|
const walletProviderType = _dynamic_labs_sdk_api_core.WalletProviderEnum.SmartContractWallet;
|
|
@@ -228,7 +228,7 @@ const ZERODEV_EXTENSION_KEY = "zerodev";
|
|
|
228
228
|
* This extension enables Account Abstraction integration with ZeroDev
|
|
229
229
|
*
|
|
230
230
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
231
|
-
* @
|
|
231
|
+
* @notInstrumented
|
|
232
232
|
*/
|
|
233
233
|
const addZerodevExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
234
234
|
if ((0, _dynamic_labs_sdk_client_core.hasExtension)({ extensionKey: ZERODEV_EXTENSION_KEY }, client)) return;
|
|
@@ -250,7 +250,7 @@ const addZerodevExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefau
|
|
|
250
250
|
* @param params.kernelClient - The kernel client to use for preparing the user operation
|
|
251
251
|
* @param params.calls - Array of calls (can be single call or multiple calls)
|
|
252
252
|
* @returns Promise resolving to the prepared user operation
|
|
253
|
-
* @
|
|
253
|
+
* @notInstrumented
|
|
254
254
|
*/
|
|
255
255
|
const prepareUserOperationFromCalls = async ({ kernelClient, calls }) => {
|
|
256
256
|
const normalizedCalls = calls.map((call) => ({
|
|
@@ -272,7 +272,7 @@ const prepareUserOperationFromCalls = async ({ kernelClient, calls }) => {
|
|
|
272
272
|
* @param params.kernelClient - Optional kernel client with sponsorship configured
|
|
273
273
|
* @param params.walletAccount - The wallet account to use (required if kernelClient not provided)
|
|
274
274
|
* @returns True if the user operation can be sponsored, false otherwise
|
|
275
|
-
* @
|
|
275
|
+
* @notInstrumented
|
|
276
276
|
*/
|
|
277
277
|
const canSponsorUserOperation = async ({ walletAccount, calls, kernelClient }) => {
|
|
278
278
|
let kernelClientToUse = kernelClient;
|
|
@@ -292,7 +292,7 @@ const canSponsorUserOperation = async ({ walletAccount, calls, kernelClient }) =
|
|
|
292
292
|
|
|
293
293
|
//#endregion
|
|
294
294
|
//#region src/utils/calculateGasForUserOperation/calculateGasForUserOperation.ts
|
|
295
|
-
/** @
|
|
295
|
+
/** @notInstrumented */
|
|
296
296
|
const calculateGasForUserOperation = ({ userOperationData }) => {
|
|
297
297
|
return (userOperationData.callGasLimit + userOperationData.verificationGasLimit + userOperationData.preVerificationGas) * userOperationData.maxFeePerGas;
|
|
298
298
|
};
|
|
@@ -306,7 +306,7 @@ const calculateGasForUserOperation = ({ userOperationData }) => {
|
|
|
306
306
|
* @param params.calls - Array of calls (single call or multiple calls)
|
|
307
307
|
* @param params.walletAccount - The wallet account that will execute the user operation
|
|
308
308
|
* @returns The estimated gas cost in wei, or null if estimation fails
|
|
309
|
-
* @
|
|
309
|
+
* @notInstrumented
|
|
310
310
|
*/
|
|
311
311
|
const estimateUserOperationGas = async ({ walletAccount, calls }) => {
|
|
312
312
|
try {
|
|
@@ -333,7 +333,7 @@ const estimateUserOperationGas = async ({ walletAccount, calls }) => {
|
|
|
333
333
|
* @param params.walletAccount - The wallet account to use (required if kernelClient not provided)
|
|
334
334
|
* @param params.withSponsorship - Whether to use sponsorship (default: true, only used with walletAccount)
|
|
335
335
|
* @returns Promise resolving to the UserOperation receipt
|
|
336
|
-
* @
|
|
336
|
+
* @notInstrumented
|
|
337
337
|
*/
|
|
338
338
|
const sendUserOperation = async ({ walletAccount, calls, kernelClient, withSponsorship = true }) => {
|
|
339
339
|
let kernelClientToUse = kernelClient;
|
|
@@ -366,7 +366,7 @@ const sendUserOperation = async ({ walletAccount, calls, kernelClient, withSpons
|
|
|
366
366
|
* @param [params.networkId] - The network ID to use for signing. If not provided, uses the wallet's active network.
|
|
367
367
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
368
368
|
* @returns A promise that resolves to the signed EIP-7702 authorization.
|
|
369
|
-
* @
|
|
369
|
+
* @notInstrumented
|
|
370
370
|
*/
|
|
371
371
|
const signEip7702Authorization = async ({ smartWalletAccount, networkId }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
372
372
|
const walletClient = await require_getZerodevRpc.getSignerForSmartWalletAccount({ smartWalletAccount }, client);
|
|
@@ -394,7 +394,7 @@ const signEip7702Authorization = async ({ smartWalletAccount, networkId }, clien
|
|
|
394
394
|
*
|
|
395
395
|
* @param walletAccount - The wallet account to check.
|
|
396
396
|
* @returns True if the wallet account is a Zerodev wallet account, false otherwise.
|
|
397
|
-
* @
|
|
397
|
+
* @notInstrumented
|
|
398
398
|
*/
|
|
399
399
|
const isZerodevWalletAccount = (walletAccount) => {
|
|
400
400
|
return walletAccount.walletProviderKey.startsWith(require_getZerodevRpc.ZERODEV_METADATA.normalizedWalletName);
|
|
@@ -414,7 +414,7 @@ const isZerodevWalletAccount = (walletAccount) => {
|
|
|
414
414
|
* @param params.nativeTokenPriceUsd - Optional USD price of the native token for fee conversion.
|
|
415
415
|
* @returns Fee data including gas estimates and human-readable amounts.
|
|
416
416
|
* @throws {FeeEstimationFailedError} If fee calculation fails.
|
|
417
|
-
* @
|
|
417
|
+
* @notInstrumented
|
|
418
418
|
*/
|
|
419
419
|
const calculateFeeForUserOperation = ({ userOperationData, networkData: _networkData, nativeTokenPriceUsd }) => {
|
|
420
420
|
try {
|
|
@@ -461,7 +461,7 @@ const calculateFeeForUserOperation = ({ userOperationData, networkData: _network
|
|
|
461
461
|
* });
|
|
462
462
|
* }
|
|
463
463
|
* ```
|
|
464
|
-
* @
|
|
464
|
+
* @notInstrumented
|
|
465
465
|
*/
|
|
466
466
|
const hasRequiredGasFields = (userOperation) => Boolean(userOperation.callGasLimit && userOperation.verificationGasLimit && userOperation.preVerificationGas && userOperation.maxFeePerGas);
|
|
467
467
|
|
|
@@ -489,7 +489,7 @@ const hasRequiredGasFields = (userOperation) => Boolean(userOperation.callGasLim
|
|
|
489
489
|
* @throws {InvalidParamError} If wallet account is not an EVM ZeroDev account or network ID is not configured.
|
|
490
490
|
* @throws {SimulationFailedError} If the simulation API call fails.
|
|
491
491
|
* @throws {FeeEstimationFailedError} If includeFees is true and fee calculation fails.
|
|
492
|
-
* @
|
|
492
|
+
* @notInstrumented
|
|
493
493
|
*/
|
|
494
494
|
const simulateZerodevUserOperation = async ({ walletAccount, userOperation, networkId, entryPoint, includeFees = false }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
495
495
|
if (!(0, _dynamic_labs_sdk_evm.isEvmWalletAccount)(walletAccount)) throw new _dynamic_labs_sdk_client.InvalidParamError("Wallet account must be an EVM wallet account");
|