@dynamic-labs/ethereum-aa 4.10.2 → 4.10.4-preview.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.
@@ -0,0 +1,498 @@
1
+ 'use client'
2
+ import { __awaiter } from '../_virtual/_tslib.js';
3
+ import { createPublicClient, http, publicActions, custom, createWalletClient, walletActions, toBytes, keccak256, toHex } from 'viem';
4
+ import { getGeneralPaymasterInput, eip712WalletActions } from 'viem/zksync';
5
+ import { createZksyncPasskeyClient, registerNewPasskey } from 'zksync-sso/client/passkey';
6
+ import { getPublicKeyBytesFromPasskeySignature, encodePasskeyModuleParameters, encodeModuleData } from 'zksync-sso/utils';
7
+ import { EthereumWallet, getOrMapViemChain, confirmationTransport, createViemUiTransaction } from '@dynamic-labs/ethereum-core';
8
+ import { parseEvmNetworks, DeferredPromise, StorageService, DynamicError } from '@dynamic-labs/utils';
9
+ import { AccountAbstractionConnector } from './AccountAbstractionConnector.js';
10
+ import { AAFactoryABI } from './utils/abi.js';
11
+ import { createZksyncEcdsaClient } from './ZKsync/client.js';
12
+ import { zksyncSsoEcdsaWalletActions } from './ZKsync/walletActions.js';
13
+
14
+ class ZKsyncConnector extends AccountAbstractionConnector {
15
+ constructor(props) {
16
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
17
+ super(props);
18
+ // Core wallet properties
19
+ this.ChainWallet = EthereumWallet;
20
+ this.name = 'ZKsync';
21
+ this.overrideKey = 'zksync';
22
+ // Chain configuration
23
+ this.connectedChain = 'EVM';
24
+ this.evmNetworks = [];
25
+ this.supportedChains = ['ETH', 'EVM'];
26
+ this._isSmartAccountDeployed = false;
27
+ this.enablePasskeys = true;
28
+ this.enableEIP7702Mode = false;
29
+ this.walletFallback = {
30
+ brand: {
31
+ alt: 'Smart Wallet',
32
+ spriteId: 'smartwallet',
33
+ },
34
+ name: 'ZKsync',
35
+ };
36
+ this._walletUiUtils = props.walletUiUtils;
37
+ this.providersConfig = (_a = props.providersConfig) !== null && _a !== void 0 ? _a : {};
38
+ this.chainId = (_b = props.apiProviders.zksync) === null || _b === void 0 ? void 0 : _b.defaultChainId;
39
+ this.evmNetworks = parseEvmNetworks(props.evmNetworks).filter((network) => network.chainId === this.chainId);
40
+ this.factoryAddress = ((_d = (_c = props.apiProviders.zksync) === null || _c === void 0 ? void 0 : _c.factoryAddress) !== null && _d !== void 0 ? _d : '0xa980E4B20354d4944de93F2a51f0a14c6E8e481d'); // Fallback if not provided
41
+ this.paymasterAddress = ((_f = (_e = props.apiProviders.zksync) === null || _e === void 0 ? void 0 : _e.paymasterAddress) !== null && _f !== void 0 ? _f : '0xD681ef8eD603F8F3b1CF9c1ef93548e698F60F0a'); // Fallback if not provided
42
+ this.passkeyAddress = ((_h = (_g = props.apiProviders.zksync) === null || _g === void 0 ? void 0 : _g.passkeyAddress) !== null && _h !== void 0 ? _h : '0x271546A4a3d8050610367e68040d41ee56E4BB31'); // Fallback if not provided
43
+ this.sessionKeyAddress = ((_k = (_j = props.apiProviders.zksync) === null || _j === void 0 ? void 0 : _j.sessionAddress) !== null && _k !== void 0 ? _k : '0xA8CC0A6bD462B44A8830bBbfB54Ce19F32815Fb7'); // Fallback if not provided
44
+ this.enablePasskeys =
45
+ (_m = (_l = props.settings.sdk.accountAbstraction) === null || _l === void 0 ? void 0 : _l.enablePasskeys) !== null && _m !== void 0 ? _m : false;
46
+ }
47
+ getEnabledNetworks() {
48
+ return this.evmNetworks;
49
+ }
50
+ getConnectedAccounts() {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ var _a;
53
+ yield ((_a = this.initializedDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
54
+ if (!this.smartAccountAddress) {
55
+ throw new Error('Smart account address is not initialized');
56
+ }
57
+ return [this.smartAccountAddress];
58
+ });
59
+ }
60
+ getNetwork() {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ var _a;
63
+ yield ((_a = this.initializedDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
64
+ if (!this.smartAccountAddress) {
65
+ throw new Error('Smart account address is not initialized');
66
+ }
67
+ return this.chainId;
68
+ });
69
+ }
70
+ getPublicClient() {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ return createPublicClient({
73
+ chain: getOrMapViemChain(this.evmNetworks[0]),
74
+ transport: http(),
75
+ });
76
+ });
77
+ }
78
+ canSponsorTransactionGas() {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ return false;
81
+ });
82
+ }
83
+ getAccountAbstractionProvider() {
84
+ return this.smartAccount;
85
+ }
86
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
87
+ getWalletClient() {
88
+ if (!this.smartAccount) {
89
+ return undefined;
90
+ }
91
+ return this.smartAccount;
92
+ }
93
+ getTransport(provider) {
94
+ const transport = confirmationTransport({
95
+ getAccounts: () => __awaiter(this, void 0, void 0, function* () { return [provider.account.address]; }),
96
+ onPersonalSign: (_a) => __awaiter(this, [_a], void 0, function* ({ message }) {
97
+ this._walletUiUtils.disabledConfirmationOnce();
98
+ if (!this._isSmartAccountDeployed) {
99
+ yield this.deploySmartAccountWithPaymaster();
100
+ }
101
+ this._walletUiUtils.disabledConfirmationOnce();
102
+ return provider.signMessage({
103
+ message,
104
+ });
105
+ }),
106
+ onSignTypedData: (_b) => __awaiter(this, [_b], void 0, function* ({ message }) {
107
+ this._walletUiUtils.disabledConfirmationOnce();
108
+ const signTypedData = JSON.parse(message);
109
+ if (!this._isSmartAccountDeployed) {
110
+ yield this.deploySmartAccountWithPaymaster();
111
+ }
112
+ this._walletUiUtils.disabledConfirmationOnce();
113
+ return provider.signTypedData({
114
+ domain: signTypedData.domain,
115
+ message: signTypedData.message,
116
+ primaryType: signTypedData.primaryType,
117
+ types: signTypedData.types,
118
+ });
119
+ }),
120
+ provider: provider.extend(publicActions),
121
+ transport: custom(provider, this.providersConfig.httpTransportConfig),
122
+ // TODO: remove this. We should not be passing references to wallet connectors
123
+ walletConnector: this,
124
+ walletUiUtils: this._walletUiUtils,
125
+ });
126
+ return transport;
127
+ }
128
+ getSigner() {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ return this.getWalletClient();
131
+ });
132
+ }
133
+ createEcdsaClient(eoaConnector) {
134
+ return __awaiter(this, void 0, void 0, function* () {
135
+ const eoaSigner = yield (eoaConnector === null || eoaConnector === void 0 ? void 0 : eoaConnector.getSigner());
136
+ if (!eoaSigner) {
137
+ throw new Error('EOA wallet client not found');
138
+ }
139
+ const transport = this.getTransport(eoaSigner);
140
+ const ownerWithTransport = createWalletClient(Object.assign(Object.assign({}, eoaSigner), { transport }));
141
+ const walletClient = yield createZksyncEcdsaClient({
142
+ address: this.smartAccountAddress,
143
+ chain: getOrMapViemChain(this.evmNetworks[0]),
144
+ contracts: {
145
+ accountFactory: this.factoryAddress,
146
+ session: this.sessionKeyAddress,
147
+ },
148
+ owner: ownerWithTransport,
149
+ transport: http(),
150
+ });
151
+ return walletClient;
152
+ });
153
+ }
154
+ /**
155
+ * Implementation of the interface method required by IAccountAbstractionWalletConnector
156
+ * @param eoaConnector - The EOA connector to use for signing transactions
157
+ * @param smartAccountAddress - The address of the smart account
158
+ */
159
+ initializeZksyncConnector(_a) {
160
+ return __awaiter(this, arguments, void 0, function* ({ eoaConnector, smartAccountAddress, }) {
161
+ this.initializedDeferredPromise = this.initializedDeferredPromise
162
+ ? this.initializedDeferredPromise
163
+ : new DeferredPromise();
164
+ this.eoaConnector = eoaConnector;
165
+ this.eoaAddress = yield eoaConnector.getAddress();
166
+ this.smartAccountAddress = smartAccountAddress;
167
+ this.smartAccount = (yield this.createEcdsaClient(eoaConnector));
168
+ yield this.checkIsDeployed();
169
+ this.initializedDeferredPromise.resolve();
170
+ });
171
+ }
172
+ /**
173
+ * Creates a passkey client for ZKsync authentication
174
+ *
175
+ * This method initializes a passkey client using stored credentials and
176
+ * configures it with the necessary contract addresses and chain information.
177
+ *
178
+ */
179
+ createPasskeyClient() {
180
+ return __awaiter(this, void 0, void 0, function* () {
181
+ if (!this.smartAccountAddress) {
182
+ throw new Error('Smart account address is not initialized');
183
+ }
184
+ const storedCredentialPublicKey = StorageService.getItem('credentialPublicKey');
185
+ if (!storedCredentialPublicKey) {
186
+ throw new Error('Credential public key not found');
187
+ }
188
+ const credentialPublicKey = new Uint8Array(Object.values(storedCredentialPublicKey));
189
+ const publicClient = yield this.getTypedPublicClient();
190
+ const { chain } = publicClient;
191
+ if (!chain) {
192
+ throw new Error('Chain information not available');
193
+ }
194
+ const contractAddresses = {
195
+ accountFactory: this.factoryAddress,
196
+ passkey: this.passkeyAddress,
197
+ session: this.sessionKeyAddress,
198
+ };
199
+ this.passkeyClient = createZksyncPasskeyClient({
200
+ address: this.smartAccountAddress,
201
+ chain,
202
+ contracts: contractAddresses,
203
+ credentialPublicKey,
204
+ transport: http(),
205
+ userDisplayName: this.smartAccountAddress,
206
+ userName: this.smartAccountAddress,
207
+ });
208
+ });
209
+ }
210
+ registerPasskeyAndDeploy() {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ const { credentialPublicKey, credentialId } = yield registerNewPasskey({
213
+ attestationType: 'none',
214
+ authenticatorSelection: {
215
+ authenticatorAttachment: 'platform',
216
+ requireResidentKey: false,
217
+ userVerification: 'required',
218
+ },
219
+ userDisplayName: this.smartAccountAddress,
220
+ userName: this.smartAccountAddress,
221
+ });
222
+ StorageService.setItem('credentialPublicKey', credentialPublicKey);
223
+ StorageService.setItem('credentialId', credentialId);
224
+ yield this.deploySmartAccount({
225
+ withPaymaster: true,
226
+ });
227
+ });
228
+ }
229
+ deploySmartAccount(_a) {
230
+ return __awaiter(this, arguments, void 0, function* ({ withPaymaster, }) {
231
+ if (withPaymaster) {
232
+ yield this.deploySmartAccountWithPaymaster();
233
+ }
234
+ else {
235
+ yield this.deploySmartAccountWithoutPaymaster();
236
+ }
237
+ });
238
+ }
239
+ deploySmartAccountWithPaymaster() {
240
+ return __awaiter(this, void 0, void 0, function* () {
241
+ const paymaster = this.paymasterAddress;
242
+ const publicClient = yield this.getTypedPublicClient();
243
+ const walletClient = yield this.getTypedWalletClient();
244
+ const deploymentParams = yield this.getDeploymentParameters();
245
+ const { request } = yield this.simulateAccountDeployment(publicClient, walletClient, deploymentParams, false);
246
+ const paymasterInput = getGeneralPaymasterInput({
247
+ innerInput: new Uint8Array(),
248
+ });
249
+ const requestWithPaymaster = Object.assign(Object.assign({}, request), { paymaster,
250
+ paymasterInput });
251
+ yield this.executeAccountDeployment(walletClient, requestWithPaymaster);
252
+ });
253
+ }
254
+ /**
255
+ * Deploys a new smart account contract
256
+ * @throws {ZkSyncConnectorError} If deployment fails
257
+ * @testable This method can be mocked in tests
258
+ */
259
+ deploySmartAccountWithoutPaymaster() {
260
+ return __awaiter(this, void 0, void 0, function* () {
261
+ if (!this.eoaConnector) {
262
+ throw new Error('EOA connector is not initialized');
263
+ }
264
+ const walletClient = yield this.getTypedWalletClient();
265
+ const publicClient = yield this.getTypedPublicClient();
266
+ const deploymentParams = yield this.getDeploymentParameters();
267
+ // Simulate the contract deployment first
268
+ const { request } = yield this.simulateAccountDeployment(publicClient, walletClient, deploymentParams, false);
269
+ // Execute the deployment transaction
270
+ yield this.executeAccountDeployment(walletClient, request);
271
+ });
272
+ }
273
+ /**
274
+ * Gets typed public client from EOA connector
275
+ * @throws {ZkSyncConnectorError} If public client cannot be obtained
276
+ * @testable This method can be mocked in tests
277
+ */
278
+ getTypedPublicClient() {
279
+ return __awaiter(this, void 0, void 0, function* () {
280
+ if (!this.eoaConnector) {
281
+ throw new Error('EOA connector is not initialized');
282
+ }
283
+ const publicClient = yield this.eoaConnector.getPublicClient();
284
+ if (!publicClient) {
285
+ throw new Error('Failed to get public client from EOA connector');
286
+ }
287
+ return publicClient;
288
+ });
289
+ }
290
+ /**
291
+ * Gets typed wallet client from EOA connector
292
+ * @throws {ZkSyncConnectorError} If wallet client cannot be obtained
293
+ * @testable This method can be mocked in tests
294
+ */
295
+ getTypedWalletClient() {
296
+ return __awaiter(this, void 0, void 0, function* () {
297
+ if (!this.eoaConnector) {
298
+ throw new Error('EOA connector is not initialized');
299
+ }
300
+ const walletClient = yield this.eoaConnector.getWalletClient();
301
+ if (!walletClient) {
302
+ throw new Error('Failed to get wallet client from EOA connector');
303
+ }
304
+ return walletClient
305
+ .extend(publicActions)
306
+ .extend(walletActions)
307
+ .extend(eip712WalletActions())
308
+ .extend(zksyncSsoEcdsaWalletActions);
309
+ });
310
+ }
311
+ /**
312
+ * Returns the parameters needed for deploying the smart account
313
+ * @returns Deployment parameters object
314
+ * @testable This method can be overridden in tests
315
+ */
316
+ getDeploymentParameters() {
317
+ return __awaiter(this, void 0, void 0, function* () {
318
+ const salt = `0x${Buffer.from(toBytes('DynamicLabs', { size: 32 })).toString('hex')}`;
319
+ const initialValidators = [];
320
+ const initialK1Owners = [this.eoaAddress];
321
+ if (this.enablePasskeys) {
322
+ const encodedPasskeyModuleData = yield this.getEncodedPasskeyModuleData();
323
+ initialValidators.push(encodedPasskeyModuleData);
324
+ }
325
+ return {
326
+ initialK1Owners,
327
+ initialValidators,
328
+ salt,
329
+ };
330
+ });
331
+ }
332
+ /**
333
+ * Retrieves and encodes passkey module data for smart account deployment
334
+ * @returns Encoded passkey module data as a hex string
335
+ * @throws {Error} If credential public key or ID is not found
336
+ * @private
337
+ */
338
+ getEncodedPasskeyModuleData() {
339
+ return __awaiter(this, void 0, void 0, function* () {
340
+ const storedCredentialPublicKey = StorageService.getItem('credentialPublicKey');
341
+ if (!storedCredentialPublicKey) {
342
+ throw new Error('Credential public key not found');
343
+ }
344
+ const credentialPublicKey = new Uint8Array(Object.values(storedCredentialPublicKey));
345
+ const credentialId = StorageService.getItem('credentialId');
346
+ if (!credentialId) {
347
+ throw new Error('Credential ID not found');
348
+ }
349
+ const passkeyPublicKey = getPublicKeyBytesFromPasskeySignature(credentialPublicKey);
350
+ const encodedPasskeyParameters = encodePasskeyModuleParameters({
351
+ credentialId: credentialId,
352
+ expectedOrigin: window.location.origin, // TODO: how is this going to be set?
353
+ passkeyPublicKey,
354
+ });
355
+ return encodeModuleData({
356
+ address: this.passkeyAddress,
357
+ parameters: encodedPasskeyParameters,
358
+ });
359
+ });
360
+ }
361
+ /**
362
+ * Simulates the smart account deployment
363
+ * @param publicClient - The public client to use for simulation
364
+ * @param walletClient - The wallet client to use for account information
365
+ * @param params - The deployment parameters
366
+ * @returns The simulation result
367
+ * @throws {ZkSyncConnectorError} If simulation fails
368
+ * @testable This method can be mocked in tests
369
+ */
370
+ simulateAccountDeployment(publicClient_1, walletClient_1, params_1) {
371
+ return __awaiter(this, arguments, void 0, function* (publicClient, walletClient, params, checkBalance = true) {
372
+ var _a, _b, _c;
373
+ // this is to keep the same salt as calculated on zksync sso package
374
+ const salt = keccak256(toHex(params.salt));
375
+ const gasEstimate = yield publicClient.estimateContractGas({
376
+ abi: AAFactoryABI,
377
+ account: (_a = walletClient.account) === null || _a === void 0 ? void 0 : _a.address,
378
+ address: this.factoryAddress,
379
+ args: [salt, params.initialValidators, params.initialK1Owners],
380
+ functionName: 'deployProxySsoAccount',
381
+ });
382
+ if (checkBalance) {
383
+ const balance = yield publicClient.getBalance({
384
+ address: (_b = walletClient.account) === null || _b === void 0 ? void 0 : _b.address,
385
+ });
386
+ if (balance < gasEstimate) {
387
+ throw new Error('Insufficient balance to deploy account');
388
+ }
389
+ }
390
+ // Simulate the contract call
391
+ return publicClient.simulateContract({
392
+ abi: AAFactoryABI,
393
+ account: (_c = walletClient.account) === null || _c === void 0 ? void 0 : _c.address,
394
+ address: this.factoryAddress,
395
+ args: [salt, params.initialValidators, params.initialK1Owners],
396
+ functionName: 'deployProxySsoAccount',
397
+ });
398
+ });
399
+ }
400
+ /**
401
+ * Executes the smart account deployment transaction
402
+ * @param walletClient - The wallet client to use for transaction execution
403
+ * @param request - The deployment request object containing transaction parameters
404
+ * @returns Promise that resolves when the deployment transaction is confirmed
405
+ * @throws {DynamicError} If the smart account address is not initialized
406
+ * @throws {Error} If transaction execution or confirmation fails
407
+ */
408
+ executeAccountDeployment(walletClient, request) {
409
+ return __awaiter(this, void 0, void 0, function* () {
410
+ if (!this.smartAccountAddress) {
411
+ throw new Error('Smart account address is not initialized');
412
+ }
413
+ const tx = yield walletClient.writeContract(request);
414
+ const publicClient = yield this.getPublicClient();
415
+ yield publicClient.waitForTransactionReceipt({ hash: tx });
416
+ this._isSmartAccountDeployed = true;
417
+ });
418
+ }
419
+ signMessage(message) {
420
+ return __awaiter(this, void 0, void 0, function* () {
421
+ const walletClient = this.getWalletClient();
422
+ if (!walletClient) {
423
+ throw new Error('Wallet client not found');
424
+ }
425
+ return yield walletClient.signMessage({
426
+ account: walletClient.account,
427
+ message,
428
+ });
429
+ });
430
+ }
431
+ /**
432
+ * Checks if a smart account is deployed
433
+ * @throws {ZkSyncConnectorError} If the check fails
434
+ * @returns Promise that resolves when the check is complete
435
+ */
436
+ checkIsDeployed() {
437
+ return __awaiter(this, void 0, void 0, function* () {
438
+ const client = yield this.getPublicClient();
439
+ if (!client) {
440
+ throw new Error('Failed to get public client from EOA connector');
441
+ }
442
+ const code = yield client.getCode({
443
+ address: this.smartAccountAddress,
444
+ });
445
+ const isDeployed = Boolean(code);
446
+ this._isSmartAccountDeployed = isDeployed;
447
+ });
448
+ }
449
+ getAddress() {
450
+ return __awaiter(this, void 0, void 0, function* () {
451
+ var _a;
452
+ yield ((_a = this.initializedDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
453
+ if (!this.smartAccount) {
454
+ throw new Error('Smart account is not initialized');
455
+ }
456
+ return this.smartAccountAddress;
457
+ });
458
+ }
459
+ validateActiveWallet(expectedAddress) {
460
+ return __awaiter(this, void 0, void 0, function* () {
461
+ const currentAddress = yield this.getAddress();
462
+ if (currentAddress !== expectedAddress) {
463
+ throw new DynamicError('Invalid active wallet');
464
+ }
465
+ return;
466
+ });
467
+ }
468
+ createUiTransaction(from) {
469
+ return __awaiter(this, void 0, void 0, function* () {
470
+ yield this.validateActiveWallet(from);
471
+ const walletClient = this.getWalletClient();
472
+ const publicClient = yield this.getPublicClient();
473
+ if (!publicClient || !walletClient) {
474
+ throw new DynamicError('No public client available');
475
+ }
476
+ return createViemUiTransaction({
477
+ from: from,
478
+ publicClient: publicClient,
479
+ walletClient: walletClient,
480
+ });
481
+ });
482
+ }
483
+ isSmartAccountDeployed() {
484
+ return __awaiter(this, arguments, void 0, function* (refetch = false) {
485
+ if (refetch) {
486
+ yield this.checkIsDeployed();
487
+ }
488
+ return this._isSmartAccountDeployed;
489
+ });
490
+ }
491
+ registerEoa(_a) {
492
+ return __awaiter(this, arguments, void 0, function* ({ smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector, }) {
493
+ throw new Error('Not implemented');
494
+ });
495
+ }
496
+ }
497
+
498
+ export { ZKsyncConnector };
@@ -16,8 +16,9 @@ var createEcsdaKernelAccountClient = require('./utils/createEcsdaKernelAccountCl
16
16
  var getEcdsaValidator = require('./utils/getEcdsaValidator.cjs');
17
17
  var getEntryPoint = require('./utils/getEntryPoint.cjs');
18
18
  var getKernelVersion = require('./utils/getKernelVersion.cjs');
19
+ var AccountAbstractionConnector = require('./AccountAbstractionConnector.cjs');
19
20
 
20
- class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
21
+ class ZeroDevConnector extends AccountAbstractionConnector.AccountAbstractionConnector {
21
22
  constructor(opts) {
22
23
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
23
24
  super(opts);
@@ -28,7 +29,6 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
28
29
  this.ChainWallet = ethereumCore.EthereumWallet;
29
30
  this.connectedChain = 'EVM';
30
31
  this.supportedChains = ['ETH', 'EVM'];
31
- this.isGasSponsorshipDisabled = false;
32
32
  this.isEmbeddedWallet = true;
33
33
  this.providersFromApi = [];
34
34
  this.name = 'ZeroDev';
@@ -60,6 +60,9 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
60
60
  this.defaultChainId = defaultProvider === null || defaultProvider === void 0 ? void 0 : defaultProvider.chain;
61
61
  this.ecdsaProviderType = (_j = opts.apiProviders.zerodev) === null || _j === void 0 ? void 0 : _j.ecdsaProviderType;
62
62
  }
63
+ confirmTransactionStatus() {
64
+ throw new Error('confirmTransactionStatus not implemented in ZeroDevConnector');
65
+ }
63
66
  get currentNetworkProvider() {
64
67
  // check if the last used chain id is in the provider map
65
68
  if (this.providerMap[this.lastUsedChainId]) {
@@ -104,13 +107,6 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
104
107
  handleChainChange(chainId);
105
108
  });
106
109
  }
107
- /**
108
- * @deprecated You should get the EOA connector by passing the SCW to getEOAConnector,
109
- * from the useSmartWallet hook
110
- */
111
- getEOAConnector() {
112
- return this.eoaConnector;
113
- }
114
110
  getAccountAbstractionProvider({ withSponsorship, } = {}) {
115
111
  if (withSponsorship && this.kernelClientWithSponsorship) {
116
112
  return this.kernelClientWithSponsorship;
@@ -122,6 +118,14 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
122
118
  utils.StorageService.removeItem(constants.ZERO_DEV_LAST_USED_CHAIN_ID_KEY);
123
119
  });
124
120
  }
121
+ initialize(_a) {
122
+ return _tslib.__awaiter(this, arguments, void 0, function* ({ smartWalletAddress, eoaAddress, eoaConnector, properties, shouldSetEoaConnector, }) {
123
+ yield this.registerEoa(Object.assign({ eoaAddress,
124
+ eoaConnector,
125
+ shouldSetEoaConnector,
126
+ smartWalletAddress }, properties));
127
+ });
128
+ }
125
129
  registerEoa(_a) {
126
130
  return _tslib.__awaiter(this, void 0, void 0, function* () {
127
131
  var { smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector = false } = _a, properties = _tslib.__rest(_a, ["smartWalletAddress", "eoaAddress", "eoaConnector", "shouldSetEoaConnector"]);
@@ -369,7 +373,7 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
369
373
  onSendTransaction: (_b) => _tslib.__awaiter(this, [_b], void 0, function* ({ transaction }) {
370
374
  try {
371
375
  this._walletUiUtils.disabledConfirmationOnce();
372
- const effectiveProvider = this.isGasSponsorshipDisabled
376
+ const effectiveProvider = this.isGasSponsorshipDisabled()
373
377
  ? provider
374
378
  : this.kernelClientWithSponsorship;
375
379
  if (!effectiveProvider) {
@@ -540,9 +544,6 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
540
544
  return sponsored;
541
545
  });
542
546
  }
543
- disableGasSponsorshipOnce() {
544
- this.isGasSponsorshipDisabled = true;
545
- }
546
547
  getBalance(address) {
547
548
  return _tslib.__awaiter(this, void 0, void 0, function* () {
548
549
  var _a;
@@ -604,6 +605,9 @@ class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
604
605
  getEnabledNetworks() {
605
606
  return this.evmNetworks;
606
607
  }
608
+ initializeZksyncConnector() {
609
+ throw new Error('Not implemented');
610
+ }
607
611
  }
608
612
 
609
613
  exports.ZeroDevConnector = ZeroDevConnector;
@@ -6,11 +6,12 @@ import { type Chain as ViemChain } from 'viem/chains';
6
6
  import { EntryPointType, KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';
7
7
  import { EthereumWallet, RegisterEvmProvidersConfig } from '@dynamic-labs/ethereum-core';
8
8
  import { EcdsaValidatorOptions, Provider, ProviderEntryPointVersionEnum, ProviderEnum, ProviderKernelVersionEnum, ProviderMultichainAccountAbstractionProviders } from '@dynamic-labs/sdk-api-core';
9
- import { Chain, IZeroDevConnector, InternalWalletConnector, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
9
+ import { Chain, InternalWalletConnector, IZeroDevConnector } from '@dynamic-labs/wallet-connector-core';
10
10
  import { WalletBookSchema } from '@dynamic-labs/wallet-book';
11
- import { EvmNetwork, GenericNetwork, IUITransaction, WalletUiUtils } from '@dynamic-labs/types';
11
+ import { GenericNetwork, IUITransaction, TransactionReceipt, WalletUiUtils } from '@dynamic-labs/types';
12
12
  import { BundlerProvider } from './utils';
13
- type ZeroDevConnectorProps = {
13
+ import { AccountAbstractionConnector, AccountAbstractionConnectorProps } from './AccountAbstractionConnector';
14
+ type ZeroDevConnectorProps = AccountAbstractionConnectorProps & {
14
15
  apiProviders: {
15
16
  [key in ProviderEnum]?: Provider;
16
17
  };
@@ -23,7 +24,7 @@ type ZeroDevConnectorProps = {
23
24
  providersConfig?: RegisterEvmProvidersConfig;
24
25
  };
25
26
  type KernelClient = KernelAccountClient<Transport, ViemChain, SmartAccount, Client, RpcSchema>;
26
- export declare class ZeroDevConnector extends WalletConnectorBase<typeof EthereumWallet> implements IZeroDevConnector {
27
+ export declare class ZeroDevConnector extends AccountAbstractionConnector implements IZeroDevConnector {
27
28
  clientId: string;
28
29
  eoaConnector: InternalWalletConnector | undefined;
29
30
  eoaAddress: string | undefined;
@@ -32,9 +33,7 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
32
33
  ChainWallet: typeof EthereumWallet;
33
34
  connectedChain: Chain;
34
35
  supportedChains: Chain[];
35
- evmNetworks: EvmNetwork[];
36
36
  providersConfig: RegisterEvmProvidersConfig;
37
- private isGasSponsorshipDisabled;
38
37
  isEmbeddedWallet: boolean;
39
38
  entryPoint: EntryPointType<EntryPointVersion>;
40
39
  kernelVersion: KERNEL_VERSION_TYPE;
@@ -62,9 +61,9 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
62
61
  name: string;
63
62
  };
64
63
  enableEIP7702Mode: boolean;
65
- private _walletUiUtils;
66
64
  private authorization?;
67
65
  constructor(opts: ZeroDevConnectorProps);
66
+ confirmTransactionStatus(): Promise<TransactionReceipt>;
68
67
  get currentNetworkProvider(): {
69
68
  kernelClient: KernelClient;
70
69
  kernelClientWithSponsorship: KernelClient;
@@ -76,15 +75,22 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
76
75
  switchNetwork({ networkChainId, }: {
77
76
  networkChainId?: number | string;
78
77
  }): Promise<void>;
79
- /**
80
- * @deprecated You should get the EOA connector by passing the SCW to getEOAConnector,
81
- * from the useSmartWallet hook
82
- */
83
- getEOAConnector(): InternalWalletConnector | undefined;
84
- getAccountAbstractionProvider({ withSponsorship, }?: {
78
+ getAccountAbstractionProvider<T = KernelClient | undefined>({ withSponsorship, }?: {
85
79
  withSponsorship?: boolean;
86
- }): KernelClient | undefined;
80
+ }): T;
87
81
  endSession(): Promise<void>;
82
+ initialize({ smartWalletAddress, eoaAddress, eoaConnector, properties, shouldSetEoaConnector, }: {
83
+ smartWalletAddress: string;
84
+ eoaAddress: string;
85
+ eoaConnector: InternalWalletConnector;
86
+ shouldSetEoaConnector: boolean;
87
+ properties?: {
88
+ ecdsaProviderType?: EcdsaValidatorOptions;
89
+ kernelVersion?: ProviderKernelVersionEnum;
90
+ entryPointVersion?: ProviderEntryPointVersionEnum;
91
+ enableKernelV3Migration?: boolean;
92
+ };
93
+ }): Promise<void>;
88
94
  registerEoa({ smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector, ...properties }: {
89
95
  smartWalletAddress: string;
90
96
  eoaAddress: string;
@@ -7812,12 +7818,12 @@ export declare class ZeroDevConnector extends WalletConnectorBase<typeof Ethereu
7812
7818
  value?: bigint;
7813
7819
  data?: string;
7814
7820
  }): Promise<boolean>;
7815
- disableGasSponsorshipOnce(): void;
7816
7821
  getBalance(address: string): Promise<string | undefined>;
7817
7822
  signMessage(messageToSign: string): Promise<string | undefined>;
7818
7823
  createUiTransaction(from: string): Promise<IUITransaction>;
7819
7824
  validateActiveWallet(expectedAddress: string): Promise<void>;
7820
7825
  getBlockExplorerUrlsForCurrentNetwork(): Promise<string[]>;
7821
7826
  getEnabledNetworks(): GenericNetwork[];
7827
+ initializeZksyncConnector(): Promise<void>;
7822
7828
  }
7823
7829
  export {};