@dynamic-labs/ethereum-aa 4.10.3 → 4.10.4-preview.1

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