@dynamic-labs/ethereum-aa 4.17.0 → 4.18.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/CHANGELOG.md CHANGED
@@ -1,4 +1,16 @@
1
1
 
2
+ ## [4.18.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.17.0...v4.18.0) (2025-05-07)
3
+
4
+
5
+ ### Features
6
+
7
+ * 7702 authorization now happens on the first transaction and could use sponsored user operation if paymaster provided (IMPORTANT: viem need to be upgraded to at least 2.28.4)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * inline email submit button color when active ([#8663](https://github.com/dynamic-labs/dynamic-auth/issues/8663)) ([ea556e9](https://github.com/dynamic-labs/dynamic-auth/commit/ea556e9116e876fb2180870e74b6c8c6a13faecb))
13
+
2
14
  ## [4.17.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.16.0...v4.17.0) (2025-05-06)
3
15
 
4
16
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.17.0";
6
+ var version = "4.18.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.17.0";
2
+ var version = "4.18.0";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum-aa",
3
- "version": "4.17.0",
3
+ "version": "4.18.0",
4
4
  "description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -22,14 +22,14 @@
22
22
  "@zerodev/ecdsa-validator": "5.4.8",
23
23
  "@zerodev/multi-chain-ecdsa-validator": "5.4.5",
24
24
  "@zerodev/sdk": "5.4.34",
25
- "@dynamic-labs/assert-package-version": "4.17.0",
26
- "@dynamic-labs/ethereum-aa-core": "4.17.0",
27
- "@dynamic-labs/ethereum-core": "4.17.0",
28
- "@dynamic-labs/logger": "4.17.0",
29
- "@dynamic-labs/types": "4.17.0",
30
- "@dynamic-labs/utils": "4.17.0",
31
- "@dynamic-labs/wallet-book": "4.17.0",
32
- "@dynamic-labs/wallet-connector-core": "4.17.0"
25
+ "@dynamic-labs/assert-package-version": "4.18.0",
26
+ "@dynamic-labs/ethereum-aa-core": "4.18.0",
27
+ "@dynamic-labs/ethereum-core": "4.18.0",
28
+ "@dynamic-labs/logger": "4.18.0",
29
+ "@dynamic-labs/types": "4.18.0",
30
+ "@dynamic-labs/utils": "4.18.0",
31
+ "@dynamic-labs/wallet-book": "4.18.0",
32
+ "@dynamic-labs/wallet-connector-core": "4.18.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "viem": "^2.21.60"
@@ -18,7 +18,6 @@ var createEcdsaKernelAccountClient = require('./utils/createEcdsaKernelAccountCl
18
18
  var getEcdsaValidator = require('./utils/getEcdsaValidator.cjs');
19
19
  var getEntryPoint = require('./utils/getEntryPoint.cjs');
20
20
  var getKernelVersion = require('./utils/getKernelVersion.cjs');
21
- var isEVMAuthorizationCapable = require('./utils/isEVMAuthorizationCapable.cjs');
22
21
  var hasSmartAccount = require('./utils/hasSmartAccount.cjs');
23
22
 
24
23
  class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
@@ -34,6 +33,12 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
34
33
  this.supportedChains = ['ETH', 'EVM'];
35
34
  this.isEmbeddedWallet = true;
36
35
  this.providersFromApi = [];
36
+ /**
37
+ * Cache for prepared user operations indexed by transaction details.
38
+ * The key is a concatenation of from-to-data to uniquely identify transactions.
39
+ * Used to avoid re-preparing the same user operation multiple times.
40
+ */
41
+ this.userOperationCache = {};
37
42
  this.name = 'ZeroDev';
38
43
  this.overrideKey = 'zerodev';
39
44
  this.walletFallback = {
@@ -179,49 +184,6 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
179
184
  this.shouldUseEIP7702Mode =
180
185
  this.is7702EnabledOnDashboard && !this.hasExistingSmartAccount;
181
186
  }
182
- getOrCreateAuthorization() {
183
- return _tslib.__awaiter(this, void 0, void 0, function* () {
184
- var _a;
185
- if (!this.eoaConnector)
186
- throw new utils.DynamicError('No EOA connector');
187
- if (!isEVMAuthorizationCapable.isEVMAuthorizationCapable(this.eoaConnector)) {
188
- throw new utils.DynamicError('Connector does not support EVM authorization');
189
- }
190
- const ZERODEV_AUTHORIZATION = 'zerodev_authorization';
191
- try {
192
- const storedAuthorization = utils.StorageService.getItem(ZERODEV_AUTHORIZATION);
193
- if (storedAuthorization) {
194
- return storedAuthorization;
195
- }
196
- const kernelVersion = constants$1.KERNEL_V3_3_BETA;
197
- const authorization = yield this.eoaConnector.experimental_signAuthorization({
198
- contractAddress: (_a = ZeroDevConnector.kernelDelegationAddress) !== null && _a !== void 0 ? _a : constants$1.KernelVersionToAddressesMap[kernelVersion]
199
- .accountImplementationAddress,
200
- });
201
- if (authorization) {
202
- const serializedAuth = Object.entries(authorization).reduce((acc, [key, value]) => {
203
- acc[key] = typeof value === 'bigint' ? value.toString() : value;
204
- return acc;
205
- }, {});
206
- utils.StorageService.setItem(ZERODEV_AUTHORIZATION, serializedAuth);
207
- }
208
- return {
209
- address: authorization.contractAddress,
210
- chainId: authorization.chainId,
211
- nonce: authorization.nonce,
212
- r: authorization.r,
213
- s: authorization.s,
214
- v: authorization.v,
215
- yParity: authorization.yParity,
216
- };
217
- }
218
- catch (error) {
219
- logger.logger.error('Failed to get/set authorization:', error);
220
- utils.StorageService.removeItem(ZERODEV_AUTHORIZATION);
221
- return undefined;
222
- }
223
- });
224
- }
225
187
  setEoaConnector(_a) {
226
188
  return _tslib.__awaiter(this, arguments, void 0, function* ({ eoaAddress, connector, properties, }) {
227
189
  var _b, _c;
@@ -251,10 +213,6 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
251
213
  yield this.eoaConnector.getConnectedAccounts();
252
214
  }
253
215
  const signer = yield this.eoaConnector.getSigner();
254
- signer.account = accounts.toAccount(eoaAddress);
255
- if (this.shouldUseEIP7702Mode) {
256
- this.authorization = yield this.getOrCreateAuthorization();
257
- }
258
216
  yield this.generateProviderMap(signer);
259
217
  this.kernelClientDeferredPromise.resolve();
260
218
  });
@@ -292,7 +250,6 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
292
250
  signer,
293
251
  }),
294
252
  this.createKernelClient({
295
- authorization: this.authorization,
296
253
  chainId: chain,
297
254
  paymaster: 'SPONSOR',
298
255
  projectId: clientId,
@@ -316,7 +273,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
316
273
  });
317
274
  }
318
275
  createKernelClient(_a) {
319
- return _tslib.__awaiter(this, arguments, void 0, function* ({ chainId, projectId, signer, paymaster, authorization, }) {
276
+ return _tslib.__awaiter(this, arguments, void 0, function* ({ chainId, projectId, signer, paymaster, }) {
320
277
  var _b;
321
278
  if (chainId && this.providerMap[chainId]) {
322
279
  return paymaster === 'SPONSOR'
@@ -330,38 +287,24 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
330
287
  const network = this.evmNetworks.find((network) => network.chainId === utils.parseChainId(chainId));
331
288
  const publicClientRpc = (_b = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _b === void 0 ? void 0 : _b[0];
332
289
  let kernelClient;
290
+ const params = {
291
+ bundlerRpc: ZeroDevConnector.bundlerRpc,
292
+ chain,
293
+ enableKernelV3Migration: this.enableKernelV3Migration,
294
+ entryPoint: this.entryPoint,
295
+ kernelVersion: this.kernelVersion,
296
+ paymaster,
297
+ paymasterRpc: ZeroDevConnector.paymasterRpc,
298
+ projectId,
299
+ provider: ZeroDevConnector.bundlerProvider,
300
+ publicClientRpc,
301
+ signer,
302
+ };
333
303
  if (this.shouldUseEIP7702Mode) {
334
- kernelClient = yield createEcdsaKernelAccountClient.createEcdsaKernelAccountClientWith7702({
335
- authorization,
336
- bundlerRpc: ZeroDevConnector.bundlerRpc,
337
- chain,
338
- ecdsaValidator: getEcdsaValidator.getEcdsaValidator(this.ecdsaProviderType),
339
- enableKernelV3Migration: this.enableKernelV3Migration,
340
- entryPoint: this.entryPoint,
341
- kernelVersion: constants$1.KERNEL_V3_3_BETA,
342
- paymaster,
343
- paymasterRpc: ZeroDevConnector.paymasterRpc,
344
- projectId,
345
- provider: ZeroDevConnector.bundlerProvider,
346
- publicClientRpc,
347
- signer,
348
- });
304
+ kernelClient = yield createEcdsaKernelAccountClient.createEcdsaKernelAccountClientWith7702(Object.assign(Object.assign({}, params), { kernelVersion: constants$1.KERNEL_V3_3 }));
349
305
  }
350
306
  else {
351
- kernelClient = yield createEcdsaKernelAccountClient.createEcdsaKernelAccountClient({
352
- bundlerRpc: ZeroDevConnector.bundlerRpc,
353
- chain,
354
- ecdsaValidator: getEcdsaValidator.getEcdsaValidator(this.ecdsaProviderType),
355
- enableKernelV3Migration: this.enableKernelV3Migration,
356
- entryPoint: this.entryPoint,
357
- kernelVersion: this.kernelVersion,
358
- paymaster,
359
- paymasterRpc: ZeroDevConnector.paymasterRpc,
360
- projectId,
361
- provider: ZeroDevConnector.bundlerProvider,
362
- publicClientRpc,
363
- signer,
364
- });
307
+ kernelClient = yield createEcdsaKernelAccountClient.createEcdsaKernelAccountClient(Object.assign(Object.assign({}, params), { ecdsaValidator: getEcdsaValidator.getEcdsaValidator(this.ecdsaProviderType) }));
365
308
  }
366
309
  utils.wrapMethodWithCallback(kernelClient, 'sendUserOperation', (original, ...args) => {
367
310
  this._walletUiUtils.disabledConfirmationOnce();
@@ -414,7 +357,14 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
414
357
  if (!effectiveProvider) {
415
358
  throw new utils.DynamicError('No provider');
416
359
  }
417
- const response = yield effectiveProvider.sendTransaction(ethereumCore.unFormatTransaction(transaction));
360
+ const unformattedTransaction = ethereumCore.unFormatTransaction(transaction);
361
+ const key = `${unformattedTransaction.from}-${unformattedTransaction.to}-${unformattedTransaction.data}`;
362
+ const cachedTransaction = this.userOperationCache[key];
363
+ if (cachedTransaction) {
364
+ const signedTransaction = yield effectiveProvider.signUserOperation(cachedTransaction.userOperation);
365
+ return effectiveProvider.sendUserOperation(signedTransaction);
366
+ }
367
+ const response = yield effectiveProvider.sendTransaction(unformattedTransaction);
418
368
  return response;
419
369
  }
420
370
  catch (err) {
@@ -527,6 +477,10 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
527
477
  getCurrentUserOperation(transaction) {
528
478
  return _tslib.__awaiter(this, void 0, void 0, function* () {
529
479
  var _a, _b;
480
+ const key = `${transaction.from}-${transaction.to}-${transaction.data}`;
481
+ if (this.userOperationCache[key]) {
482
+ return this.userOperationCache[key];
483
+ }
530
484
  try {
531
485
  const { kernelClientWithSponsorship } = this;
532
486
  if (!kernelClientWithSponsorship) {
@@ -553,6 +507,11 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
553
507
  callData,
554
508
  }));
555
509
  }
510
+ // Cache the result
511
+ this.userOperationCache[key] = {
512
+ sponsored: (sponsorResult === null || sponsorResult === void 0 ? void 0 : sponsorResult.paymasterAndData) !== '0x',
513
+ userOperation: sponsorResult !== null && sponsorResult !== void 0 ? sponsorResult : unsponsoredResult,
514
+ };
556
515
  if ((sponsorResult === null || sponsorResult === void 0 ? void 0 : sponsorResult.paymasterAndData) === '0x')
557
516
  return { sponsored: false, userOperation: sponsorResult };
558
517
  return sponsorResult
@@ -615,6 +574,23 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
615
574
  });
616
575
  });
617
576
  }
577
+ isAtomicSupported(chainId) {
578
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
579
+ logger.logger.debug('[ZeroDevConnector] isAtomicSupported - is supported', {
580
+ chainId,
581
+ });
582
+ return true;
583
+ });
584
+ }
585
+ isPaymasterServiceSupported(chainId) {
586
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
587
+ logger.logger.debug('[ZeroDevConnector] isPaymasterServiceSupported - not supported', {
588
+ chainId,
589
+ });
590
+ // TODO: update this to return true once we add support for paymaster url
591
+ return false;
592
+ });
593
+ }
618
594
  }
619
595
 
620
596
  exports.ZeroDevConnector = ZeroDevConnector;
@@ -1,7 +1,6 @@
1
1
  import { KernelAccountClient } from '@zerodev/sdk/clients';
2
2
  import { SmartAccount, EntryPointVersion } from 'viem/account-abstraction';
3
3
  import { Account, Client, PublicClient, RpcSchema, Transport, WalletClient } from 'viem';
4
- import { SignAuthorizationReturnType } from 'viem/accounts';
5
4
  import { type Chain as ViemChain } from 'viem/chains';
6
5
  import { EntryPointType, KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';
7
6
  import { EthereumWallet, RegisterEvmProvidersConfig } from '@dynamic-labs/ethereum-core';
@@ -20,7 +19,6 @@ type ZeroDevConnectorProps = AccountAbstractionConnectorProps & {
20
19
  walletUiUtils: WalletUiUtils<InternalWalletConnector>;
21
20
  bundlerProvider: BundlerProvider | undefined;
22
21
  enableEIP7702?: boolean;
23
- authorization?: SignAuthorizationReturnType;
24
22
  providersConfig?: RegisterEvmProvidersConfig;
25
23
  };
26
24
  type KernelClient = KernelAccountClient<Transport, ViemChain, SmartAccount, Client, RpcSchema>;
@@ -51,6 +49,12 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
51
49
  * This is needed because the provider is set asynchronously.
52
50
  */
53
51
  private kernelClientDeferredPromise;
52
+ /**
53
+ * Cache for prepared user operations indexed by transaction details.
54
+ * The key is a concatenation of from-to-data to uniquely identify transactions.
55
+ * Used to avoid re-preparing the same user operation multiple times.
56
+ */
57
+ private userOperationCache;
54
58
  name: string;
55
59
  overrideKey: string;
56
60
  walletFallback: {
@@ -61,7 +65,6 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
61
65
  name: string;
62
66
  };
63
67
  is7702EnabledOnDashboard: boolean;
64
- private authorization?;
65
68
  private hasExistingSmartAccount;
66
69
  /**
67
70
  * Flag for EIP-7702 mode, enabled when EIP-7702 is enabled and no smart account exists
@@ -103,7 +106,6 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
103
106
  entryPointVersion?: ProviderEntryPointVersionEnum;
104
107
  }): Promise<void>;
105
108
  private determineSmartAccountStatus;
106
- private getOrCreateAuthorization;
107
109
  private setEoaConnector;
108
110
  private warnIfProjectChainNotEnabled;
109
111
  /**
@@ -167,5 +169,7 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
167
169
  getBalance(address: string): Promise<string | undefined>;
168
170
  signMessage(messageToSign: string): Promise<string | undefined>;
169
171
  validateActiveWallet(expectedAddress: string): Promise<void>;
172
+ isAtomicSupported(chainId?: number): Promise<boolean>;
173
+ isPaymasterServiceSupported(chainId?: number): Promise<boolean>;
170
174
  }
171
175
  export {};
@@ -2,7 +2,7 @@
2
2
  import { __awaiter, __rest } from '../_virtual/_tslib.js';
3
3
  import { publicActions, custom, createWalletClient, toHex, formatEther } from 'viem';
4
4
  import { toAccount } from 'viem/accounts';
5
- import { KERNEL_V3_3_BETA, KernelVersionToAddressesMap, getEntryPoint as getEntryPoint$1 } from '@zerodev/sdk/constants';
5
+ import { KERNEL_V3_3, getEntryPoint as getEntryPoint$1 } from '@zerodev/sdk/constants';
6
6
  import { EthereumWallet, isEthWalletConnector, chainsMap, confirmationTransport, unFormatTransaction } from '@dynamic-labs/ethereum-core';
7
7
  import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
8
8
  import { eventListenerHandlers, getWalletProvider } from '@dynamic-labs/wallet-connector-core';
@@ -14,7 +14,6 @@ import { createEcdsaKernelAccountClientWith7702, createEcdsaKernelAccountClient
14
14
  import { getEcdsaValidator } from './utils/getEcdsaValidator.js';
15
15
  import { getEntryPoint } from './utils/getEntryPoint.js';
16
16
  import { getKernelVersion } from './utils/getKernelVersion.js';
17
- import { isEVMAuthorizationCapable } from './utils/isEVMAuthorizationCapable.js';
18
17
  import { hasSmartAccount } from './utils/hasSmartAccount.js';
19
18
 
20
19
  class ZeroDevConnector extends AccountAbstractionBaseConnector {
@@ -30,6 +29,12 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
30
29
  this.supportedChains = ['ETH', 'EVM'];
31
30
  this.isEmbeddedWallet = true;
32
31
  this.providersFromApi = [];
32
+ /**
33
+ * Cache for prepared user operations indexed by transaction details.
34
+ * The key is a concatenation of from-to-data to uniquely identify transactions.
35
+ * Used to avoid re-preparing the same user operation multiple times.
36
+ */
37
+ this.userOperationCache = {};
33
38
  this.name = 'ZeroDev';
34
39
  this.overrideKey = 'zerodev';
35
40
  this.walletFallback = {
@@ -175,49 +180,6 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
175
180
  this.shouldUseEIP7702Mode =
176
181
  this.is7702EnabledOnDashboard && !this.hasExistingSmartAccount;
177
182
  }
178
- getOrCreateAuthorization() {
179
- return __awaiter(this, void 0, void 0, function* () {
180
- var _a;
181
- if (!this.eoaConnector)
182
- throw new DynamicError('No EOA connector');
183
- if (!isEVMAuthorizationCapable(this.eoaConnector)) {
184
- throw new DynamicError('Connector does not support EVM authorization');
185
- }
186
- const ZERODEV_AUTHORIZATION = 'zerodev_authorization';
187
- try {
188
- const storedAuthorization = StorageService.getItem(ZERODEV_AUTHORIZATION);
189
- if (storedAuthorization) {
190
- return storedAuthorization;
191
- }
192
- const kernelVersion = KERNEL_V3_3_BETA;
193
- const authorization = yield this.eoaConnector.experimental_signAuthorization({
194
- contractAddress: (_a = ZeroDevConnector.kernelDelegationAddress) !== null && _a !== void 0 ? _a : KernelVersionToAddressesMap[kernelVersion]
195
- .accountImplementationAddress,
196
- });
197
- if (authorization) {
198
- const serializedAuth = Object.entries(authorization).reduce((acc, [key, value]) => {
199
- acc[key] = typeof value === 'bigint' ? value.toString() : value;
200
- return acc;
201
- }, {});
202
- StorageService.setItem(ZERODEV_AUTHORIZATION, serializedAuth);
203
- }
204
- return {
205
- address: authorization.contractAddress,
206
- chainId: authorization.chainId,
207
- nonce: authorization.nonce,
208
- r: authorization.r,
209
- s: authorization.s,
210
- v: authorization.v,
211
- yParity: authorization.yParity,
212
- };
213
- }
214
- catch (error) {
215
- logger.error('Failed to get/set authorization:', error);
216
- StorageService.removeItem(ZERODEV_AUTHORIZATION);
217
- return undefined;
218
- }
219
- });
220
- }
221
183
  setEoaConnector(_a) {
222
184
  return __awaiter(this, arguments, void 0, function* ({ eoaAddress, connector, properties, }) {
223
185
  var _b, _c;
@@ -247,10 +209,6 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
247
209
  yield this.eoaConnector.getConnectedAccounts();
248
210
  }
249
211
  const signer = yield this.eoaConnector.getSigner();
250
- signer.account = toAccount(eoaAddress);
251
- if (this.shouldUseEIP7702Mode) {
252
- this.authorization = yield this.getOrCreateAuthorization();
253
- }
254
212
  yield this.generateProviderMap(signer);
255
213
  this.kernelClientDeferredPromise.resolve();
256
214
  });
@@ -288,7 +246,6 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
288
246
  signer,
289
247
  }),
290
248
  this.createKernelClient({
291
- authorization: this.authorization,
292
249
  chainId: chain,
293
250
  paymaster: 'SPONSOR',
294
251
  projectId: clientId,
@@ -312,7 +269,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
312
269
  });
313
270
  }
314
271
  createKernelClient(_a) {
315
- return __awaiter(this, arguments, void 0, function* ({ chainId, projectId, signer, paymaster, authorization, }) {
272
+ return __awaiter(this, arguments, void 0, function* ({ chainId, projectId, signer, paymaster, }) {
316
273
  var _b;
317
274
  if (chainId && this.providerMap[chainId]) {
318
275
  return paymaster === 'SPONSOR'
@@ -326,38 +283,24 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
326
283
  const network = this.evmNetworks.find((network) => network.chainId === parseChainId(chainId));
327
284
  const publicClientRpc = (_b = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _b === void 0 ? void 0 : _b[0];
328
285
  let kernelClient;
286
+ const params = {
287
+ bundlerRpc: ZeroDevConnector.bundlerRpc,
288
+ chain,
289
+ enableKernelV3Migration: this.enableKernelV3Migration,
290
+ entryPoint: this.entryPoint,
291
+ kernelVersion: this.kernelVersion,
292
+ paymaster,
293
+ paymasterRpc: ZeroDevConnector.paymasterRpc,
294
+ projectId,
295
+ provider: ZeroDevConnector.bundlerProvider,
296
+ publicClientRpc,
297
+ signer,
298
+ };
329
299
  if (this.shouldUseEIP7702Mode) {
330
- kernelClient = yield createEcdsaKernelAccountClientWith7702({
331
- authorization,
332
- bundlerRpc: ZeroDevConnector.bundlerRpc,
333
- chain,
334
- ecdsaValidator: getEcdsaValidator(this.ecdsaProviderType),
335
- enableKernelV3Migration: this.enableKernelV3Migration,
336
- entryPoint: this.entryPoint,
337
- kernelVersion: KERNEL_V3_3_BETA,
338
- paymaster,
339
- paymasterRpc: ZeroDevConnector.paymasterRpc,
340
- projectId,
341
- provider: ZeroDevConnector.bundlerProvider,
342
- publicClientRpc,
343
- signer,
344
- });
300
+ kernelClient = yield createEcdsaKernelAccountClientWith7702(Object.assign(Object.assign({}, params), { kernelVersion: KERNEL_V3_3 }));
345
301
  }
346
302
  else {
347
- kernelClient = yield createEcdsaKernelAccountClient({
348
- bundlerRpc: ZeroDevConnector.bundlerRpc,
349
- chain,
350
- ecdsaValidator: getEcdsaValidator(this.ecdsaProviderType),
351
- enableKernelV3Migration: this.enableKernelV3Migration,
352
- entryPoint: this.entryPoint,
353
- kernelVersion: this.kernelVersion,
354
- paymaster,
355
- paymasterRpc: ZeroDevConnector.paymasterRpc,
356
- projectId,
357
- provider: ZeroDevConnector.bundlerProvider,
358
- publicClientRpc,
359
- signer,
360
- });
303
+ kernelClient = yield createEcdsaKernelAccountClient(Object.assign(Object.assign({}, params), { ecdsaValidator: getEcdsaValidator(this.ecdsaProviderType) }));
361
304
  }
362
305
  wrapMethodWithCallback(kernelClient, 'sendUserOperation', (original, ...args) => {
363
306
  this._walletUiUtils.disabledConfirmationOnce();
@@ -410,7 +353,14 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
410
353
  if (!effectiveProvider) {
411
354
  throw new DynamicError('No provider');
412
355
  }
413
- const response = yield effectiveProvider.sendTransaction(unFormatTransaction(transaction));
356
+ const unformattedTransaction = unFormatTransaction(transaction);
357
+ const key = `${unformattedTransaction.from}-${unformattedTransaction.to}-${unformattedTransaction.data}`;
358
+ const cachedTransaction = this.userOperationCache[key];
359
+ if (cachedTransaction) {
360
+ const signedTransaction = yield effectiveProvider.signUserOperation(cachedTransaction.userOperation);
361
+ return effectiveProvider.sendUserOperation(signedTransaction);
362
+ }
363
+ const response = yield effectiveProvider.sendTransaction(unformattedTransaction);
414
364
  return response;
415
365
  }
416
366
  catch (err) {
@@ -523,6 +473,10 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
523
473
  getCurrentUserOperation(transaction) {
524
474
  return __awaiter(this, void 0, void 0, function* () {
525
475
  var _a, _b;
476
+ const key = `${transaction.from}-${transaction.to}-${transaction.data}`;
477
+ if (this.userOperationCache[key]) {
478
+ return this.userOperationCache[key];
479
+ }
526
480
  try {
527
481
  const { kernelClientWithSponsorship } = this;
528
482
  if (!kernelClientWithSponsorship) {
@@ -549,6 +503,11 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
549
503
  callData,
550
504
  }));
551
505
  }
506
+ // Cache the result
507
+ this.userOperationCache[key] = {
508
+ sponsored: (sponsorResult === null || sponsorResult === void 0 ? void 0 : sponsorResult.paymasterAndData) !== '0x',
509
+ userOperation: sponsorResult !== null && sponsorResult !== void 0 ? sponsorResult : unsponsoredResult,
510
+ };
552
511
  if ((sponsorResult === null || sponsorResult === void 0 ? void 0 : sponsorResult.paymasterAndData) === '0x')
553
512
  return { sponsored: false, userOperation: sponsorResult };
554
513
  return sponsorResult
@@ -611,6 +570,23 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
611
570
  });
612
571
  });
613
572
  }
573
+ isAtomicSupported(chainId) {
574
+ return __awaiter(this, void 0, void 0, function* () {
575
+ logger.debug('[ZeroDevConnector] isAtomicSupported - is supported', {
576
+ chainId,
577
+ });
578
+ return true;
579
+ });
580
+ }
581
+ isPaymasterServiceSupported(chainId) {
582
+ return __awaiter(this, void 0, void 0, function* () {
583
+ logger.debug('[ZeroDevConnector] isPaymasterServiceSupported - not supported', {
584
+ chainId,
585
+ });
586
+ // TODO: update this to return true once we add support for paymaster url
587
+ return false;
588
+ });
589
+ }
614
590
  }
615
591
 
616
592
  export { ZeroDevConnector };
@@ -97,27 +97,27 @@ const createEcdsaKernelAccountClient = (_b) => _tslib.__awaiter(void 0, [_b], vo
97
97
  const clientConfig = createKernelClientConfig(selectedAccount, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
98
98
  return clients.createKernelAccountClient(clientConfig);
99
99
  });
100
- const createEcdsaKernelAccountClientWith7702 = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, authorization, paymaster = 'SPONSOR', entryPoint, kernelVersion, ecdsaValidator, publicClientRpc, }) {
100
+ const createEcdsaKernelAccountClientWith7702 = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster = 'SPONSOR', entryPoint, kernelVersion, publicClientRpc, }) {
101
101
  const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
102
102
  const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
103
103
  const { publicClient, zerodevPaymaster } = createPublicAndPaymasterClients(resolvedBundlerRpc, resolvedPaymasterRpc, chain, publicClientRpc);
104
- const validator = yield ecdsaValidator(publicClient, {
104
+ const account = yield ecdsaValidator.create7702KernelAccount(publicClient, {
105
105
  entryPoint,
106
106
  kernelVersion,
107
- signer,
107
+ signer: signer.account,
108
108
  });
109
- const account = yield accounts.createKernelAccount(publicClient, {
110
- address: signer.account.address,
111
- eip7702Auth: authorization,
112
- entryPoint,
113
- kernelVersion,
114
- plugins: {
115
- sudo: validator,
109
+ const paymasterHandler = createPaymasterHandler(paymaster, zerodevPaymaster);
110
+ const kernelClient = ecdsaValidator.create7702KernelAccountClient({
111
+ account: account, // TODO: check with zerodev team why this type is broken
112
+ bundlerTransport: viem.http(resolvedBundlerRpc),
113
+ chain,
114
+ client: publicClient,
115
+ paymaster: paymasterHandler,
116
+ userOperation: {
117
+ estimateFeesPerGas: (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ bundlerClient }) { return actions.getUserOperationGasPrice(bundlerClient); }),
116
118
  },
117
119
  });
118
- const paymasterHandler = createPaymasterHandler(paymaster, zerodevPaymaster);
119
- const clientConfig = createKernelClientConfig(account, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
120
- return clients.createKernelAccountClient(clientConfig);
120
+ return kernelClient;
121
121
  });
122
122
 
123
123
  exports.createEcdsaKernelAccountClient = createEcdsaKernelAccountClient;
@@ -3,7 +3,6 @@ import { KernelAccountClient } from '@zerodev/sdk/clients';
3
3
  import { type Chain as ViemChain } from 'viem/chains';
4
4
  import { Address, WalletClient, Account, type Chain, type Client, type RpcSchema, type Transport } from 'viem';
5
5
  import { EntryPointType, GetKernelVersion } from '@zerodev/sdk/types';
6
- import { SignAuthorizationReturnType } from 'viem/experimental';
7
6
  export type BundlerProvider = 'STACKUP' | 'PIMLICO' | 'ALCHEMY' | 'GELATO';
8
7
  export type ERC20Paymaster = Address;
9
8
  export type PaymasterType = 'NONE' | 'SPONSOR' | ERC20Paymaster;
@@ -19,12 +18,11 @@ type CommonClientParams<TChain extends Chain | undefined = Chain | undefined> =
19
18
  entryPoint: EntryPointType<EntryPointVersion>;
20
19
  provider?: BundlerProvider;
21
20
  kernelVersion: GetKernelVersion<EntryPointVersion>;
22
- ecdsaValidator: any;
23
21
  enableKernelV3Migration: boolean;
24
22
  publicClientRpc?: string;
25
23
  };
26
- export declare const createEcdsaKernelAccountClient: <entryPoint extends EntryPointVersion, TChain extends ViemChain | undefined = ViemChain | undefined>({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster, entryPoint, kernelVersion, ecdsaValidator, enableKernelV3Migration, publicClientRpc, }: CommonClientParams<TChain>) => Promise<KernelAccountClient<Transport, ViemChain, SmartAccount, Client, RpcSchema>>;
27
- export declare const createEcdsaKernelAccountClientWith7702: <TChain extends ViemChain | undefined = ViemChain | undefined>({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, authorization, paymaster, entryPoint, kernelVersion, ecdsaValidator, publicClientRpc, }: CommonClientParams<TChain> & {
28
- authorization?: SignAuthorizationReturnType;
24
+ export declare const createEcdsaKernelAccountClient: <entryPoint extends EntryPointVersion, TChain extends ViemChain | undefined = ViemChain | undefined>({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster, entryPoint, kernelVersion, ecdsaValidator, enableKernelV3Migration, publicClientRpc, }: CommonClientParams<TChain> & {
25
+ ecdsaValidator: any;
29
26
  }) => Promise<KernelAccountClient<Transport, ViemChain, SmartAccount, Client, RpcSchema>>;
27
+ export declare const createEcdsaKernelAccountClientWith7702: <TChain extends ViemChain | undefined = ViemChain | undefined>({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster, entryPoint, kernelVersion, publicClientRpc, }: CommonClientParams<TChain>) => Promise<KernelAccountClient<Transport, ViemChain, SmartAccount, Client, RpcSchema>>;
30
28
  export {};
@@ -4,7 +4,7 @@ import { createKernelAccount } from '@zerodev/sdk/accounts';
4
4
  import { createKernelAccountClient, createZeroDevPaymasterClient } from '@zerodev/sdk/clients';
5
5
  import { getUserOperationGasPrice } from '@zerodev/sdk/actions';
6
6
  import { createPublicClient, http, isAddress } from 'viem';
7
- import { createEcdsaKernelMigrationAccount } from '@zerodev/ecdsa-validator';
7
+ import { createEcdsaKernelMigrationAccount, create7702KernelAccount, create7702KernelAccountClient } from '@zerodev/ecdsa-validator';
8
8
  import { KERNEL_V3_1 } from '@zerodev/sdk/constants';
9
9
 
10
10
  const getZeroDevBundlerRPC = (projectId, provider) => {
@@ -93,27 +93,27 @@ const createEcdsaKernelAccountClient = (_b) => __awaiter(void 0, [_b], void 0, f
93
93
  const clientConfig = createKernelClientConfig(selectedAccount, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
94
94
  return createKernelAccountClient(clientConfig);
95
95
  });
96
- const createEcdsaKernelAccountClientWith7702 = (_c) => __awaiter(void 0, [_c], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, authorization, paymaster = 'SPONSOR', entryPoint, kernelVersion, ecdsaValidator, publicClientRpc, }) {
96
+ const createEcdsaKernelAccountClientWith7702 = (_c) => __awaiter(void 0, [_c], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster = 'SPONSOR', entryPoint, kernelVersion, publicClientRpc, }) {
97
97
  const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
98
98
  const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
99
99
  const { publicClient, zerodevPaymaster } = createPublicAndPaymasterClients(resolvedBundlerRpc, resolvedPaymasterRpc, chain, publicClientRpc);
100
- const validator = yield ecdsaValidator(publicClient, {
100
+ const account = yield create7702KernelAccount(publicClient, {
101
101
  entryPoint,
102
102
  kernelVersion,
103
- signer,
103
+ signer: signer.account,
104
104
  });
105
- const account = yield createKernelAccount(publicClient, {
106
- address: signer.account.address,
107
- eip7702Auth: authorization,
108
- entryPoint,
109
- kernelVersion,
110
- plugins: {
111
- sudo: validator,
105
+ const paymasterHandler = createPaymasterHandler(paymaster, zerodevPaymaster);
106
+ const kernelClient = create7702KernelAccountClient({
107
+ account: account, // TODO: check with zerodev team why this type is broken
108
+ bundlerTransport: http(resolvedBundlerRpc),
109
+ chain,
110
+ client: publicClient,
111
+ paymaster: paymasterHandler,
112
+ userOperation: {
113
+ estimateFeesPerGas: (_d) => __awaiter(void 0, [_d], void 0, function* ({ bundlerClient }) { return getUserOperationGasPrice(bundlerClient); }),
112
114
  },
113
115
  });
114
- const paymasterHandler = createPaymasterHandler(paymaster, zerodevPaymaster);
115
- const clientConfig = createKernelClientConfig(account, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
116
- return createKernelAccountClient(clientConfig);
116
+ return kernelClient;
117
117
  });
118
118
 
119
119
  export { createEcdsaKernelAccountClient, createEcdsaKernelAccountClientWith7702, getZeroDevBundlerRPC, getZeroDevPaymasterRPC };
@@ -5,5 +5,4 @@ export * from './createEcdsaKernelAccountClient';
5
5
  export * from './getEcdsaValidator';
6
6
  export * from './getEntryPoint';
7
7
  export * from './getKernelVersion';
8
- export * from './isEVMAuthorizationCapable';
9
8
  export * from './hasSmartAccount';
@@ -1,8 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- const isEVMAuthorizationCapable = (connector) => 'experimental_signAuthorization' in connector;
7
-
8
- exports.isEVMAuthorizationCapable = isEVMAuthorizationCapable;
@@ -1,6 +0,0 @@
1
- import { InternalWalletConnector, EVMAuthorizationParameters, EVMAuthorizationResult } from '@dynamic-labs/wallet-connector-core';
2
- type EVMAuthorizationCapableConnector = InternalWalletConnector & {
3
- experimental_signAuthorization: (params: EVMAuthorizationParameters) => Promise<EVMAuthorizationResult>;
4
- };
5
- export declare const isEVMAuthorizationCapable: (connector: InternalWalletConnector) => connector is EVMAuthorizationCapableConnector;
6
- export {};
@@ -1,4 +0,0 @@
1
- 'use client'
2
- const isEVMAuthorizationCapable = (connector) => 'experimental_signAuthorization' in connector;
3
-
4
- export { isEVMAuthorizationCapable };