@dynamic-labs-sdk/zerodev 1.18.0 → 1.19.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 +11 -2
- package/dist/addZerodevExtension/addZerodevExtension.d.ts.map +1 -1
- package/dist/canSponsorUserOperation/canSponsorUserOperation.d.ts +17 -7
- package/dist/canSponsorUserOperation/canSponsorUserOperation.d.ts.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.esm.js +1 -1
- package/dist/createKernelClientForWalletAccount/createKernelClientForWalletAccount.d.ts +15 -9
- package/dist/createKernelClientForWalletAccount/createKernelClientForWalletAccount.d.ts.map +1 -1
- package/dist/estimateUserOperationGas/estimateUserOperationGas.d.ts +16 -6
- package/dist/estimateUserOperationGas/estimateUserOperationGas.d.ts.map +1 -1
- package/dist/getSignerForSmartWalletAccount/getSignerForSmartWalletAccount.d.ts +12 -3
- package/dist/getSignerForSmartWalletAccount/getSignerForSmartWalletAccount.d.ts.map +1 -1
- package/dist/{getZerodevRpc-BsPRopqm.cjs → getZerodevRpc-4WYiej6o.cjs} +13 -4
- package/dist/getZerodevRpc-4WYiej6o.cjs.map +1 -0
- package/dist/{getZerodevRpc-Cd6_IvH2.esm.js → getZerodevRpc-BWlvnCuL.esm.js} +13 -4
- package/dist/getZerodevRpc-BWlvnCuL.esm.js.map +1 -0
- package/dist/index.cjs +130 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +130 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/isGasSponsorshipError/isGasSponsorshipError.d.ts +21 -1
- package/dist/isGasSponsorshipError/isGasSponsorshipError.d.ts.map +1 -1
- package/dist/sendUserOperation/sendUserOperation.d.ts +18 -8
- package/dist/sendUserOperation/sendUserOperation.d.ts.map +1 -1
- package/dist/signEip7702Authorization/signEip7702Authorization.d.ts +14 -2
- package/dist/signEip7702Authorization/signEip7702Authorization.d.ts.map +1 -1
- package/dist/simulateZerodevUserOperation/simulateZerodevUserOperation.d.ts +13 -1
- package/dist/simulateZerodevUserOperation/simulateZerodevUserOperation.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/calculateFeeForUserOperation/calculateFeeForUserOperation.d.ts +12 -1
- package/dist/utils/calculateFeeForUserOperation/calculateFeeForUserOperation.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/getZerodevRpc-BsPRopqm.cjs.map +0 -1
- package/dist/getZerodevRpc-Cd6_IvH2.esm.js.map +0 -1
|
@@ -2,10 +2,19 @@ export declare const ZERODEV_EXTENSION_KEY = "zerodev";
|
|
|
2
2
|
/**
|
|
3
3
|
* Adds the ZeroDev extension to the Dynamic client.
|
|
4
4
|
*
|
|
5
|
-
* This extension enables Account Abstraction integration with ZeroDev
|
|
5
|
+
* This extension enables Account Abstraction integration with ZeroDev.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const client = createDynamicClient({ environmentId: 'env-123' });
|
|
10
|
+
* addZerodevExtension(client);
|
|
11
|
+
* ```
|
|
6
12
|
*
|
|
7
13
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
8
|
-
|
|
14
|
+
* @returns void
|
|
15
|
+
* @see createKernelClientForWalletAccount
|
|
16
|
+
* @see sendUserOperation
|
|
17
|
+
* @notInstrumented
|
|
9
18
|
*/
|
|
10
19
|
export declare const addZerodevExtension: (client?: import("@dynamic-labs-sdk/client").DynamicClient) => void;
|
|
11
20
|
//# sourceMappingURL=addZerodevExtension.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addZerodevExtension.d.ts","sourceRoot":"","sources":["../../src/addZerodevExtension/addZerodevExtension.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C
|
|
1
|
+
{"version":3,"file":"addZerodevExtension.d.ts","sourceRoot":"","sources":["../../src/addZerodevExtension/addZerodevExtension.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,qEAe/B,CAAC"}
|
|
@@ -14,14 +14,24 @@ type CanSponsorUserOperationWithClientParams = CanSponsorUserOperationBaseParams
|
|
|
14
14
|
};
|
|
15
15
|
export type CanSponsorUserOperationParams = CanSponsorUserOperationWithWalletParams | CanSponsorUserOperationWithClientParams;
|
|
16
16
|
/**
|
|
17
|
-
* Checks if a user operation can be sponsored by the paymaster
|
|
18
|
-
* Handles both single transactions and batch transactions
|
|
17
|
+
* Checks if a user operation can be sponsored by the paymaster.
|
|
18
|
+
* Handles both single transactions and batch transactions.
|
|
19
19
|
*
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const canSponsor = await canSponsorUserOperation({
|
|
23
|
+
* walletAccount: smartWallet,
|
|
24
|
+
* calls: [{ to: '0x...', value: 0n, data: '0x' }],
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param params.calls - Array of calls (single call or multiple calls).
|
|
29
|
+
* @param params.kernelClient - Optional kernel client with sponsorship configured.
|
|
30
|
+
* @param params.walletAccount - The wallet account to use (required if kernelClient not provided).
|
|
31
|
+
* @returns True if the user operation can be sponsored, false otherwise.
|
|
32
|
+
* @see sendUserOperation
|
|
33
|
+
* @see estimateUserOperationGas
|
|
34
|
+
* @notInstrumented
|
|
25
35
|
*/
|
|
26
36
|
export declare const canSponsorUserOperation: ({ walletAccount, calls, kernelClient, }: CanSponsorUserOperationParams) => Promise<boolean>;
|
|
27
37
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canSponsorUserOperation.d.ts","sourceRoot":"","sources":["../../src/canSponsorUserOperation/canSponsorUserOperation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,KAAK,iCAAiC,GAAG;IACvC,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CAAC;AAEF,KAAK,uCAAuC,GAC1C,iCAAiC,GAAG;IAClC,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEJ,KAAK,uCAAuC,GAC1C,iCAAiC,GAAG;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB,CAAC;AAEJ,MAAM,MAAM,6BAA6B,GACrC,uCAAuC,GACvC,uCAAuC,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"canSponsorUserOperation.d.ts","sourceRoot":"","sources":["../../src/canSponsorUserOperation/canSponsorUserOperation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,KAAK,iCAAiC,GAAG;IACvC,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CAAC;AAEF,KAAK,uCAAuC,GAC1C,iCAAiC,GAAG;IAClC,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEJ,KAAK,uCAAuC,GAC1C,iCAAiC,GAAG;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB,CAAC;AAEJ,MAAM,MAAM,6BAA6B,GACrC,uCAAuC,GACvC,uCAAuC,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,uBAAuB,4CAIjC,6BAA6B,KAAG,OAAO,CAAC,OAAO,CA0BjD,CAAC"}
|
package/dist/core.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_getZerodevRpc = require('./getZerodevRpc-
|
|
1
|
+
const require_getZerodevRpc = require('./getZerodevRpc-4WYiej6o.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-BWlvnCuL.esm.js";
|
|
2
2
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
3
3
|
|
|
4
4
|
//#region src/exports/core.ts
|
|
@@ -17,20 +17,26 @@ type CreateKernelClientForWalletAccountParams = {
|
|
|
17
17
|
/**
|
|
18
18
|
* Creates a KernelClient instance for a given smart wallet account.
|
|
19
19
|
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const kernelClient = await createKernelClientForWalletAccount({
|
|
23
|
+
* smartWalletAccount: evmSmartWallet,
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
20
27
|
* @param params.smartWalletAccount - The smart wallet account to create the KernelClient for.
|
|
21
|
-
* @param [params.bundlerProvider] - A custom bundler provider to use
|
|
22
|
-
* @param [params.bundlerRpc] - A custom bundler RPC to use
|
|
28
|
+
* @param [params.bundlerProvider] - A custom bundler provider to use.
|
|
29
|
+
* @param [params.bundlerRpc] - A custom bundler RPC to use.
|
|
23
30
|
* @param [params.networkId] - The network ID to use for the KernelClient.
|
|
24
|
-
*
|
|
25
|
-
* @param [params.
|
|
26
|
-
* @param [params.gasTokenAddress] - The address of a custom ERC20 token to use as a gas token
|
|
31
|
+
* @param [params.paymasterRpc] - A custom paymaster RPC to use.
|
|
32
|
+
* @param [params.gasTokenAddress] - The address of a custom ERC20 token to use as a gas token.
|
|
27
33
|
* @param [params.withSponsorship] - Whether to use sponsorship for the KernelClient or not (default is true).
|
|
28
|
-
* @param [params.eip7702Auth] - A pre-signed EIP-7702 authorization
|
|
29
|
-
* this authorization instead of signing a new one internally. Useful for singleUse MFA flows where you need
|
|
30
|
-
* to separate the authorization signing step from the transaction step.
|
|
34
|
+
* @param [params.eip7702Auth] - A pre-signed EIP-7702 authorization for singleUse MFA flows.
|
|
31
35
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
32
36
|
* @returns A promise that resolves to a KernelClient instance.
|
|
33
|
-
|
|
37
|
+
* @see sendUserOperation
|
|
38
|
+
* @see getSignerForSmartWalletAccount
|
|
39
|
+
* @notInstrumented
|
|
34
40
|
*/
|
|
35
41
|
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
42
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createKernelClientForWalletAccount.d.ts","sourceRoot":"","sources":["../../src/createKernelClientForWalletAccount/createKernelClientForWalletAccount.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAKzE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAK1D,MAAM,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAE/D,KAAK,wCAAwC,GAAG;IAC9C,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,2BAA2B,CAAC;IAC1C,eAAe,CAAC,EAAE,GAAG,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,gBAAgB,CAAC;IACrC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"createKernelClientForWalletAccount.d.ts","sourceRoot":"","sources":["../../src/createKernelClientForWalletAccount/createKernelClientForWalletAccount.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAKzE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAK1D,MAAM,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAE/D,KAAK,wCAAwC,GAAG;IAC9C,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,2BAA2B,CAAC;IAC1C,eAAe,CAAC,EAAE,GAAG,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,gBAAgB,CAAC;IACrC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,kCAAkC,2KAU1C,wCAAwC,gEAE1C,OAAO,CAAC,YAAY,CAsFtB,CAAC"}
|
|
@@ -5,13 +5,23 @@ export type EstimateUserOperationGasParams = {
|
|
|
5
5
|
walletAccount: EvmWalletAccount;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
* Estimates the total gas cost for a user operation with one or more calls
|
|
9
|
-
* Handles both single transactions and batch transactions
|
|
8
|
+
* Estimates the total gas cost for a user operation with one or more calls.
|
|
9
|
+
* Handles both single transactions and batch transactions.
|
|
10
10
|
*
|
|
11
|
-
* @
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const gasEstimate = await estimateUserOperationGas({
|
|
14
|
+
* walletAccount: smartWallet,
|
|
15
|
+
* calls: [{ to: '0x...', value: 0n, data: '0x' }],
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param params.calls - Array of calls (single call or multiple calls).
|
|
20
|
+
* @param params.walletAccount - The wallet account that will execute the user operation.
|
|
21
|
+
* @returns The estimated gas cost in wei, or null if estimation fails.
|
|
22
|
+
* @see sendUserOperation
|
|
23
|
+
* @see canSponsorUserOperation
|
|
24
|
+
* @notInstrumented
|
|
15
25
|
*/
|
|
16
26
|
export declare const estimateUserOperationGas: ({ walletAccount, calls, }: EstimateUserOperationGasParams) => Promise<bigint | null>;
|
|
17
27
|
//# sourceMappingURL=estimateUserOperationGas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateUserOperationGas.d.ts","sourceRoot":"","sources":["../../src/estimateUserOperationGas/estimateUserOperationGas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAKpD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"estimateUserOperationGas.d.ts","sourceRoot":"","sources":["../../src/estimateUserOperationGas/estimateUserOperationGas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAKpD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,wBAAwB,8BAGlC,8BAA8B,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAmBxD,CAAC"}
|
|
@@ -7,11 +7,20 @@ type GetSignerForSmartWalletAccountParams = {
|
|
|
7
7
|
* Gets a WalletClient instance for the EOA of the smart wallet account.
|
|
8
8
|
* You can use this signer to sign EVM transactions.
|
|
9
9
|
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const signer = await getSignerForSmartWalletAccount({
|
|
13
|
+
* smartWalletAccount: evmSmartWallet,
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
10
17
|
* @param params.smartWalletAccount - The EVM smart wallet account to get the signer for.
|
|
11
18
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
12
|
-
* @returns A promise that resolves to
|
|
13
|
-
* @throws NoSmartWalletAccountSignerFoundError When the signer wallet account is not found for the given smart wallet account.
|
|
14
|
-
|
|
19
|
+
* @returns A promise that resolves to a WalletClient instance.
|
|
20
|
+
* @throws {NoSmartWalletAccountSignerFoundError} When the signer wallet account is not found for the given smart wallet account.
|
|
21
|
+
* @see createKernelClientForWalletAccount
|
|
22
|
+
* @see sendUserOperation
|
|
23
|
+
* @notInstrumented
|
|
15
24
|
*/
|
|
16
25
|
export declare const getSignerForSmartWalletAccount: ({ smartWalletAccount }: GetSignerForSmartWalletAccountParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<WalletClient<Transport, Chain, Account>>;
|
|
17
26
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSignerForSmartWalletAccount.d.ts","sourceRoot":"","sources":["../../src/getSignerForSmartWalletAccount/getSignerForSmartWalletAccount.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpE,KAAK,oCAAoC,GAAG;IAC1C,kBAAkB,EAAE,gBAAgB,CAAC;CACtC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"getSignerForSmartWalletAccount.d.ts","sourceRoot":"","sources":["../../src/getSignerForSmartWalletAccount/getSignerForSmartWalletAccount.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpE,KAAK,oCAAoC,GAAG;IAC1C,kBAAkB,EAAE,gBAAgB,CAAC;CACtC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,8BAA8B,2BACjB,oCAAoC,gEAE3D,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAgBjD,CAAC"}
|
|
@@ -10,7 +10,7 @@ let _zerodev_multi_chain_ecdsa_validator = require("@zerodev/multi-chain-ecdsa-v
|
|
|
10
10
|
|
|
11
11
|
//#region package.json
|
|
12
12
|
var name = "@dynamic-labs-sdk/zerodev";
|
|
13
|
-
var version = "1.
|
|
13
|
+
var version = "1.19.0";
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/constants.ts
|
|
@@ -73,10 +73,19 @@ const getZerodevChainProviderForNetworkId = ({ networkId }, client) => {
|
|
|
73
73
|
* Gets a WalletClient instance for the EOA of the smart wallet account.
|
|
74
74
|
* You can use this signer to sign EVM transactions.
|
|
75
75
|
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const signer = await getSignerForSmartWalletAccount({
|
|
79
|
+
* smartWalletAccount: evmSmartWallet,
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
76
83
|
* @param params.smartWalletAccount - The EVM smart wallet account to get the signer for.
|
|
77
84
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
78
|
-
* @returns A promise that resolves to
|
|
79
|
-
* @throws NoSmartWalletAccountSignerFoundError When the signer wallet account is not found for the given smart wallet account.
|
|
85
|
+
* @returns A promise that resolves to a WalletClient instance.
|
|
86
|
+
* @throws {NoSmartWalletAccountSignerFoundError} When the signer wallet account is not found for the given smart wallet account.
|
|
87
|
+
* @see createKernelClientForWalletAccount
|
|
88
|
+
* @see sendUserOperation
|
|
80
89
|
* @notInstrumented
|
|
81
90
|
*/
|
|
82
91
|
const getSignerForSmartWalletAccount = ({ smartWalletAccount }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
@@ -295,4 +304,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
295
304
|
return version;
|
|
296
305
|
}
|
|
297
306
|
});
|
|
298
|
-
//# sourceMappingURL=getZerodevRpc-
|
|
307
|
+
//# sourceMappingURL=getZerodevRpc-4WYiej6o.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getZerodevRpc-4WYiej6o.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 * @example\n * ```ts\n * const signer = await getSignerForSmartWalletAccount({\n * smartWalletAccount: evmSmartWallet,\n * });\n * ```\n *\n * @param params.smartWalletAccount - The EVM smart wallet account to get the signer for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to a WalletClient instance.\n * @throws {NoSmartWalletAccountSignerFoundError} When the signer wallet account is not found for the given smart wallet account.\n * @see createKernelClientForWalletAccount\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const getSignerForSmartWalletAccount = (\n { smartWalletAccount }: GetSignerForSmartWalletAccountParams,\n client = getDefaultClient()\n): Promise<WalletClient<Transport, Chain, Account>> => {\n const signerWalletAccount = getOwnerWalletAccountForSmartWalletAccount(\n { smartWalletAccount },\n client\n );\n\n if (!signerWalletAccount || !isEvmWalletAccount(signerWalletAccount)) {\n throw new NoSmartWalletAccountSignerFoundError(smartWalletAccount.address);\n }\n\n return createWalletClientForWalletAccount(\n {\n walletAccount: signerWalletAccount,\n },\n client\n );\n};\n","import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator';\nimport { toMultiChainECDSAValidator } from '@zerodev/multi-chain-ecdsa-validator';\nimport type {\n EntryPointType,\n GetKernelVersion,\n Signer,\n} from '@zerodev/sdk/types';\nimport type { Client } from 'viem';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\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,GAAGA,wDAA0B;CACnC,sBAAsB;CACvB;AAED,MAAa,uBAAuB;AAEpC,MAAa,qBAAqB;EAC/BC,qDAA0B,MAAMC,uBAAU;EAC1CD,qDAA0B,MAAMC,uBAAU;EAC1CD,qDAA0B,MAAMC,uBAAU;EAC1CD,qDAA0B,MAAMC,uBAAU;EAC1CD,qDAA0B,MAAMC,uBAAU;CAC5C;AAED,MAAaC,0BAGT;CACF,IAAKD,uBAAU;CACf,IAAKA,uBAAU;CACf,IAAKA,uBAAU;CAChB;AAED,MAAa,qBAAqB,CAChC;CACE,QAAQ,CACN;EAAE,MAAM;EAAM,MAAM;EAAW,EAC/B;EAAE,MAAM;EAAU,MAAM;EAAW,CACpC;CACD,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAI,MAAM;EAAQ,CAAC;CACrC,iBAAiB;CACjB,MAAM;CACP,CACF;;;;;ACrCD,MAAa,kCAAkC,WAA0B;CACvE,MAAM,kBAAkB,OAAO;AAE/B,kDAAc,iBAAiB,qCAAqC;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C7C;CAED,MAAM,oBACJ,mBACA,gBAAgB,0BAChBC,kDAAuB;CAEzB,MAAM,YACJ,YAAY,YAAY,oBAAoB;AAE9C,QAAO,GAAG,qBAAqB,GAAG,QAAQ,GAAG,qBAAqB,SAAS,GAAG,UAAU,GAAG"}
|
|
@@ -10,7 +10,7 @@ import { toMultiChainECDSAValidator } from "@zerodev/multi-chain-ecdsa-validator
|
|
|
10
10
|
|
|
11
11
|
//#region package.json
|
|
12
12
|
var name = "@dynamic-labs-sdk/zerodev";
|
|
13
|
-
var version = "1.
|
|
13
|
+
var version = "1.19.0";
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/constants.ts
|
|
@@ -73,10 +73,19 @@ const getZerodevChainProviderForNetworkId = ({ networkId }, client) => {
|
|
|
73
73
|
* Gets a WalletClient instance for the EOA of the smart wallet account.
|
|
74
74
|
* You can use this signer to sign EVM transactions.
|
|
75
75
|
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const signer = await getSignerForSmartWalletAccount({
|
|
79
|
+
* smartWalletAccount: evmSmartWallet,
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
76
83
|
* @param params.smartWalletAccount - The EVM smart wallet account to get the signer for.
|
|
77
84
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
78
|
-
* @returns A promise that resolves to
|
|
79
|
-
* @throws NoSmartWalletAccountSignerFoundError When the signer wallet account is not found for the given smart wallet account.
|
|
85
|
+
* @returns A promise that resolves to a WalletClient instance.
|
|
86
|
+
* @throws {NoSmartWalletAccountSignerFoundError} When the signer wallet account is not found for the given smart wallet account.
|
|
87
|
+
* @see createKernelClientForWalletAccount
|
|
88
|
+
* @see sendUserOperation
|
|
80
89
|
* @notInstrumented
|
|
81
90
|
*/
|
|
82
91
|
const getSignerForSmartWalletAccount = ({ smartWalletAccount }, client = getDefaultClient()) => {
|
|
@@ -212,4 +221,4 @@ const getZerodevRpc = ({ networkId, bundlerProvider, rpcType }, client) => {
|
|
|
212
221
|
|
|
213
222
|
//#endregion
|
|
214
223
|
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-
|
|
224
|
+
//# sourceMappingURL=getZerodevRpc-BWlvnCuL.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getZerodevRpc-BWlvnCuL.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 * @example\n * ```ts\n * const signer = await getSignerForSmartWalletAccount({\n * smartWalletAccount: evmSmartWallet,\n * });\n * ```\n *\n * @param params.smartWalletAccount - The EVM smart wallet account to get the signer for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to a WalletClient instance.\n * @throws {NoSmartWalletAccountSignerFoundError} When the signer wallet account is not found for the given smart wallet account.\n * @see createKernelClientForWalletAccount\n * @see sendUserOperation\n * @notInstrumented\n */\nexport const getSignerForSmartWalletAccount = (\n { smartWalletAccount }: GetSignerForSmartWalletAccountParams,\n client = getDefaultClient()\n): Promise<WalletClient<Transport, Chain, Account>> => {\n const signerWalletAccount = getOwnerWalletAccountForSmartWalletAccount(\n { smartWalletAccount },\n client\n );\n\n if (!signerWalletAccount || !isEvmWalletAccount(signerWalletAccount)) {\n throw new NoSmartWalletAccountSignerFoundError(smartWalletAccount.address);\n }\n\n return createWalletClientForWalletAccount(\n {\n walletAccount: signerWalletAccount,\n },\n client\n );\n};\n","import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator';\nimport { toMultiChainECDSAValidator } from '@zerodev/multi-chain-ecdsa-validator';\nimport type {\n EntryPointType,\n GetKernelVersion,\n Signer,\n} from '@zerodev/sdk/types';\nimport type { Client } from 'viem';\nimport type { EntryPointVersion } from 'viem/account-abstraction';\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,UAAU;CAC5C;AAED,MAAaA,0BAGT;CACF,IAAK,UAAU;CACf,IAAK,UAAU;CACf,IAAK,UAAU;CAChB;AAED,MAAa,qBAAqB,CAChC;CACE,QAAQ,CACN;EAAE,MAAM;EAAM,MAAM;EAAW,EAC/B;EAAE,MAAM;EAAU,MAAM;EAAW,CACpC;CACD,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAI,MAAM;EAAQ,CAAC;CACrC,iB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AAE,WAAW,iBAAiB,WAC9B,WACG;CACH,MAAM,kBAAkB,+BAA+B,OAAO;AAE9D,KAAI,iBAAiB,uBACnB,QAAO,gBAAgB;CAGzB,MAAM,uBAAuB,oCAC3B,EAAE,WAAW,EACb,OACD;AAED,eACE,sBACA,4CAA4C,YAC7C;CAED,MAAM,oBACJ,mBACA,gBAAgB,0BAChB,uBAAuB;CAEzB,MAAM,YACJ,YAAY,YAAY,oBAAoB;AAE9C,QAAO,GAAG,qBAAqB,GAAG,QAAQ,GAAG,qBAAqB,SAAS,GAAG,UAAU,GAAG"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_getZerodevRpc = require('./getZerodevRpc-
|
|
1
|
+
const require_getZerodevRpc = require('./getZerodevRpc-4WYiej6o.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");
|
|
@@ -20,19 +20,25 @@ const getAllUserZerodevAddresses = (client) => {
|
|
|
20
20
|
/**
|
|
21
21
|
* Creates a KernelClient instance for a given smart wallet account.
|
|
22
22
|
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const kernelClient = await createKernelClientForWalletAccount({
|
|
26
|
+
* smartWalletAccount: evmSmartWallet,
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
23
30
|
* @param params.smartWalletAccount - The smart wallet account to create the KernelClient for.
|
|
24
|
-
* @param [params.bundlerProvider] - A custom bundler provider to use
|
|
25
|
-
* @param [params.bundlerRpc] - A custom bundler RPC to use
|
|
31
|
+
* @param [params.bundlerProvider] - A custom bundler provider to use.
|
|
32
|
+
* @param [params.bundlerRpc] - A custom bundler RPC to use.
|
|
26
33
|
* @param [params.networkId] - The network ID to use for the KernelClient.
|
|
27
|
-
*
|
|
28
|
-
* @param [params.
|
|
29
|
-
* @param [params.gasTokenAddress] - The address of a custom ERC20 token to use as a gas token
|
|
34
|
+
* @param [params.paymasterRpc] - A custom paymaster RPC to use.
|
|
35
|
+
* @param [params.gasTokenAddress] - The address of a custom ERC20 token to use as a gas token.
|
|
30
36
|
* @param [params.withSponsorship] - Whether to use sponsorship for the KernelClient or not (default is true).
|
|
31
|
-
* @param [params.eip7702Auth] - A pre-signed EIP-7702 authorization
|
|
32
|
-
* this authorization instead of signing a new one internally. Useful for singleUse MFA flows where you need
|
|
33
|
-
* to separate the authorization signing step from the transaction step.
|
|
37
|
+
* @param [params.eip7702Auth] - A pre-signed EIP-7702 authorization for singleUse MFA flows.
|
|
34
38
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
35
39
|
* @returns A promise that resolves to a KernelClient instance.
|
|
40
|
+
* @see sendUserOperation
|
|
41
|
+
* @see getSignerForSmartWalletAccount
|
|
36
42
|
* @notInstrumented
|
|
37
43
|
*/
|
|
38
44
|
const createKernelClientForWalletAccount = async ({ smartWalletAccount, withSponsorship = true, bundlerProvider, networkId, bundlerRpc: bundlerRpcOverride, paymasterRpc: paymasterRpcOverride, gasTokenAddress, eip7702Auth }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
@@ -111,7 +117,27 @@ const signMessage = async ({ walletAccount, message }, client) => {
|
|
|
111
117
|
|
|
112
118
|
//#endregion
|
|
113
119
|
//#region src/isGasSponsorshipError/isGasSponsorshipError.ts
|
|
114
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Checks if an error is a ZeroDev gas sponsorship error, indicating the
|
|
122
|
+
* user operation did not match any gas sponsoring policies.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* try {
|
|
127
|
+
* await sendUserOperation({ walletAccount, calls });
|
|
128
|
+
* } catch (err) {
|
|
129
|
+
* if (isGasSponsorshipError(err)) {
|
|
130
|
+
* // Handle missing sponsorship
|
|
131
|
+
* }
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @param err - The error to check.
|
|
136
|
+
* @returns True if the error is a gas sponsorship policy mismatch, false otherwise.
|
|
137
|
+
* @see canSponsorUserOperation
|
|
138
|
+
* @see sendUserOperation
|
|
139
|
+
* @notInstrumented
|
|
140
|
+
*/
|
|
115
141
|
const isGasSponsorshipError = (err) => {
|
|
116
142
|
return err?.message?.includes("userOp did not match any gas sponsoring policies") || false;
|
|
117
143
|
};
|
|
@@ -225,9 +251,18 @@ const ZERODEV_EXTENSION_KEY = "zerodev";
|
|
|
225
251
|
/**
|
|
226
252
|
* Adds the ZeroDev extension to the Dynamic client.
|
|
227
253
|
*
|
|
228
|
-
* This extension enables Account Abstraction integration with ZeroDev
|
|
254
|
+
* This extension enables Account Abstraction integration with ZeroDev.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* const client = createDynamicClient({ environmentId: 'env-123' });
|
|
259
|
+
* addZerodevExtension(client);
|
|
260
|
+
* ```
|
|
229
261
|
*
|
|
230
262
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
263
|
+
* @returns void
|
|
264
|
+
* @see createKernelClientForWalletAccount
|
|
265
|
+
* @see sendUserOperation
|
|
231
266
|
* @notInstrumented
|
|
232
267
|
*/
|
|
233
268
|
const addZerodevExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
@@ -265,13 +300,23 @@ const prepareUserOperationFromCalls = async ({ kernelClient, calls }) => {
|
|
|
265
300
|
//#endregion
|
|
266
301
|
//#region src/canSponsorUserOperation/canSponsorUserOperation.ts
|
|
267
302
|
/**
|
|
268
|
-
* Checks if a user operation can be sponsored by the paymaster
|
|
269
|
-
* Handles both single transactions and batch transactions
|
|
303
|
+
* Checks if a user operation can be sponsored by the paymaster.
|
|
304
|
+
* Handles both single transactions and batch transactions.
|
|
270
305
|
*
|
|
271
|
-
* @
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```ts
|
|
308
|
+
* const canSponsor = await canSponsorUserOperation({
|
|
309
|
+
* walletAccount: smartWallet,
|
|
310
|
+
* calls: [{ to: '0x...', value: 0n, data: '0x' }],
|
|
311
|
+
* });
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @param params.calls - Array of calls (single call or multiple calls).
|
|
315
|
+
* @param params.kernelClient - Optional kernel client with sponsorship configured.
|
|
316
|
+
* @param params.walletAccount - The wallet account to use (required if kernelClient not provided).
|
|
317
|
+
* @returns True if the user operation can be sponsored, false otherwise.
|
|
318
|
+
* @see sendUserOperation
|
|
319
|
+
* @see estimateUserOperationGas
|
|
275
320
|
* @notInstrumented
|
|
276
321
|
*/
|
|
277
322
|
const canSponsorUserOperation = async ({ walletAccount, calls, kernelClient }) => {
|
|
@@ -300,12 +345,22 @@ const calculateGasForUserOperation = ({ userOperationData }) => {
|
|
|
300
345
|
//#endregion
|
|
301
346
|
//#region src/estimateUserOperationGas/estimateUserOperationGas.ts
|
|
302
347
|
/**
|
|
303
|
-
* Estimates the total gas cost for a user operation with one or more calls
|
|
304
|
-
* Handles both single transactions and batch transactions
|
|
348
|
+
* Estimates the total gas cost for a user operation with one or more calls.
|
|
349
|
+
* Handles both single transactions and batch transactions.
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```ts
|
|
353
|
+
* const gasEstimate = await estimateUserOperationGas({
|
|
354
|
+
* walletAccount: smartWallet,
|
|
355
|
+
* calls: [{ to: '0x...', value: 0n, data: '0x' }],
|
|
356
|
+
* });
|
|
357
|
+
* ```
|
|
305
358
|
*
|
|
306
|
-
* @param params.calls - Array of calls (single call or multiple calls)
|
|
307
|
-
* @param params.walletAccount - The wallet account that will execute the user operation
|
|
308
|
-
* @returns The estimated gas cost in wei, or null if estimation fails
|
|
359
|
+
* @param params.calls - Array of calls (single call or multiple calls).
|
|
360
|
+
* @param params.walletAccount - The wallet account that will execute the user operation.
|
|
361
|
+
* @returns The estimated gas cost in wei, or null if estimation fails.
|
|
362
|
+
* @see sendUserOperation
|
|
363
|
+
* @see canSponsorUserOperation
|
|
309
364
|
* @notInstrumented
|
|
310
365
|
*/
|
|
311
366
|
const estimateUserOperationGas = async ({ walletAccount, calls }) => {
|
|
@@ -325,14 +380,24 @@ const estimateUserOperationGas = async ({ walletAccount, calls }) => {
|
|
|
325
380
|
//#endregion
|
|
326
381
|
//#region src/sendUserOperation/sendUserOperation.ts
|
|
327
382
|
/**
|
|
328
|
-
* Sends a user operation with one or more calls
|
|
329
|
-
* Handles both single transactions and batch transactions
|
|
383
|
+
* Sends a user operation with one or more calls.
|
|
384
|
+
* Handles both single transactions and batch transactions.
|
|
330
385
|
*
|
|
331
|
-
* @
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```ts
|
|
388
|
+
* const receipt = await sendUserOperation({
|
|
389
|
+
* walletAccount: smartWallet,
|
|
390
|
+
* calls: [{ to: '0x...', value: 0n, data: '0x' }],
|
|
391
|
+
* });
|
|
392
|
+
* ```
|
|
393
|
+
*
|
|
394
|
+
* @param params.calls - Array of calls (single call or multiple calls).
|
|
395
|
+
* @param params.kernelClient - Optional pre-configured kernel client.
|
|
396
|
+
* @param params.walletAccount - The wallet account to use (required if kernelClient not provided).
|
|
397
|
+
* @param params.withSponsorship - Whether to use sponsorship (default: true, only used with walletAccount).
|
|
398
|
+
* @returns Promise resolving to the UserOperation receipt.
|
|
399
|
+
* @see createKernelClientForWalletAccount
|
|
400
|
+
* @see canSponsorUserOperation
|
|
336
401
|
* @notInstrumented
|
|
337
402
|
*/
|
|
338
403
|
const sendUserOperation = async ({ walletAccount, calls, kernelClient, withSponsorship = true }) => {
|
|
@@ -361,11 +426,23 @@ const sendUserOperation = async ({ walletAccount, calls, kernelClient, withSpons
|
|
|
361
426
|
* its execution to the ZeroDev kernel contract. The signed authorization can then
|
|
362
427
|
* be passed to `createKernelClientForWalletAccount` via the `eip7702Auth` parameter.
|
|
363
428
|
*
|
|
364
|
-
* @
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* const auth = await signEip7702Authorization({
|
|
432
|
+
* smartWalletAccount: evmSmartWallet,
|
|
433
|
+
* });
|
|
434
|
+
* const kernelClient = await createKernelClientForWalletAccount({
|
|
435
|
+
* smartWalletAccount: evmSmartWallet,
|
|
436
|
+
* eip7702Auth: auth,
|
|
437
|
+
* });
|
|
438
|
+
* ```
|
|
439
|
+
*
|
|
365
440
|
* @param params.smartWalletAccount - The EVM smart wallet account to sign the authorization for.
|
|
366
441
|
* @param [params.networkId] - The network ID to use for signing. If not provided, uses the wallet's active network.
|
|
367
442
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
368
443
|
* @returns A promise that resolves to the signed EIP-7702 authorization.
|
|
444
|
+
* @see createKernelClientForWalletAccount
|
|
445
|
+
* @see sendUserOperation
|
|
369
446
|
* @notInstrumented
|
|
370
447
|
*/
|
|
371
448
|
const signEip7702Authorization = async ({ smartWalletAccount, networkId }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
@@ -409,11 +486,22 @@ const isZerodevWalletAccount = (walletAccount) => {
|
|
|
409
486
|
* all gas components (call, verification, pre-verification) and multiplying
|
|
410
487
|
* by the maximum fee per gas unit.
|
|
411
488
|
*
|
|
489
|
+
* @example
|
|
490
|
+
* ```ts
|
|
491
|
+
* const fee = calculateFeeForUserOperation({
|
|
492
|
+
* userOperationData: userOp,
|
|
493
|
+
* networkData,
|
|
494
|
+
* nativeTokenPriceUsd: 2500,
|
|
495
|
+
* });
|
|
496
|
+
* ```
|
|
497
|
+
*
|
|
412
498
|
* @param params.userOperationData - The user operation data containing gas limits and fees.
|
|
413
499
|
* @param params.networkData - Network configuration (not currently used but kept for consistency).
|
|
414
500
|
* @param params.nativeTokenPriceUsd - Optional USD price of the native token for fee conversion.
|
|
415
501
|
* @returns Fee data including gas estimates and human-readable amounts.
|
|
416
502
|
* @throws {FeeEstimationFailedError} If fee calculation fails.
|
|
503
|
+
* @see estimateUserOperationGas
|
|
504
|
+
* @see sendUserOperation
|
|
417
505
|
* @notInstrumented
|
|
418
506
|
*/
|
|
419
507
|
const calculateFeeForUserOperation = ({ userOperationData, networkData: _networkData, nativeTokenPriceUsd }) => {
|
|
@@ -479,6 +567,16 @@ const hasRequiredGasFields = (userOperation) => Boolean(userOperation.callGasLim
|
|
|
479
567
|
* insufficient balance, reverted contract call). Check the `validation` field in the
|
|
480
568
|
* result for potential issues.
|
|
481
569
|
*
|
|
570
|
+
* @example
|
|
571
|
+
* ```ts
|
|
572
|
+
* const result = await simulateZerodevUserOperation({
|
|
573
|
+
* walletAccount: smartWallet,
|
|
574
|
+
* userOperation,
|
|
575
|
+
* networkId: '137',
|
|
576
|
+
* entryPoint: '0x5FF1...A000',
|
|
577
|
+
* });
|
|
578
|
+
* ```
|
|
579
|
+
*
|
|
482
580
|
* @param params.walletAccount - The EVM smart wallet account that will execute the operation.
|
|
483
581
|
* @param params.userOperation - The user operation to simulate.
|
|
484
582
|
* @param params.networkId - The network ID where the operation will be executed (e.g., '137' for Polygon).
|
|
@@ -489,6 +587,8 @@ const hasRequiredGasFields = (userOperation) => Boolean(userOperation.callGasLim
|
|
|
489
587
|
* @throws {InvalidParamError} If wallet account is not an EVM ZeroDev account or network ID is not configured.
|
|
490
588
|
* @throws {SimulationFailedError} If the simulation API call fails.
|
|
491
589
|
* @throws {FeeEstimationFailedError} If includeFees is true and fee calculation fails.
|
|
590
|
+
* @see sendUserOperation
|
|
591
|
+
* @see canSponsorUserOperation
|
|
492
592
|
* @notInstrumented
|
|
493
593
|
*/
|
|
494
594
|
const simulateZerodevUserOperation = async ({ walletAccount, userOperation, networkId, entryPoint, includeFees = false }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|