@dynamic-labs/ethereum-aa 4.11.1 → 4.12.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.
@@ -3,8 +3,8 @@ 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
5
  import { KERNEL_V3_3_BETA, KernelVersionToAddressesMap, getEntryPoint as getEntryPoint$1 } from '@zerodev/sdk/constants';
6
- import { EthereumWallet, isEthWalletConnector, chainsMap, confirmationTransport, unFormatTransaction, createViemUiTransaction } from '@dynamic-labs/ethereum-core';
7
- import { WalletConnectorBase, eventListenerHandlers, isTurnkeyWalletConnector } from '@dynamic-labs/wallet-connector-core';
6
+ import { EthereumWallet, isEthWalletConnector, chainsMap, confirmationTransport, unFormatTransaction } from '@dynamic-labs/ethereum-core';
7
+ import { eventListenerHandlers, isTurnkeyWalletConnector } from '@dynamic-labs/wallet-connector-core';
8
8
  import { parseEvmNetworks, StorageService, DynamicError, DeferredPromise, parseChainId, wrapMethodWithCallback, TransactionGasCannotBeSponsoredError, InsufficientFundsError } from '@dynamic-labs/utils';
9
9
  import { ZERO_DEV_LAST_USED_CHAIN_ID_KEY } from './constants.js';
10
10
  import { logger } from './utils/logger.js';
@@ -12,8 +12,10 @@ import { createEcdsaKernelAccountClientWith7702, createEcdsaKernelAccountClient
12
12
  import { getEcdsaValidator } from './utils/getEcdsaValidator.js';
13
13
  import { getEntryPoint } from './utils/getEntryPoint.js';
14
14
  import { getKernelVersion } from './utils/getKernelVersion.js';
15
+ import 'zksync-sso/utils';
16
+ import { AccountAbstractionConnector } from './AccountAbstractionConnector.js';
15
17
 
16
- class ZeroDevConnector extends WalletConnectorBase {
18
+ class ZeroDevConnector extends AccountAbstractionConnector {
17
19
  constructor(opts) {
18
20
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
19
21
  super(opts);
@@ -24,7 +26,6 @@ class ZeroDevConnector extends WalletConnectorBase {
24
26
  this.ChainWallet = EthereumWallet;
25
27
  this.connectedChain = 'EVM';
26
28
  this.supportedChains = ['ETH', 'EVM'];
27
- this.isGasSponsorshipDisabled = false;
28
29
  this.isEmbeddedWallet = true;
29
30
  this.providersFromApi = [];
30
31
  this.name = 'ZeroDev';
@@ -56,6 +57,9 @@ class ZeroDevConnector extends WalletConnectorBase {
56
57
  this.defaultChainId = defaultProvider === null || defaultProvider === void 0 ? void 0 : defaultProvider.chain;
57
58
  this.ecdsaProviderType = (_j = opts.apiProviders.zerodev) === null || _j === void 0 ? void 0 : _j.ecdsaProviderType;
58
59
  }
60
+ confirmTransactionStatus() {
61
+ throw new Error('confirmTransactionStatus not implemented in ZeroDevConnector');
62
+ }
59
63
  get currentNetworkProvider() {
60
64
  // check if the last used chain id is in the provider map
61
65
  if (this.providerMap[this.lastUsedChainId]) {
@@ -100,13 +104,6 @@ class ZeroDevConnector extends WalletConnectorBase {
100
104
  handleChainChange(chainId);
101
105
  });
102
106
  }
103
- /**
104
- * @deprecated You should get the EOA connector by passing the SCW to getEOAConnector,
105
- * from the useSmartWallet hook
106
- */
107
- getEOAConnector() {
108
- return this.eoaConnector;
109
- }
110
107
  getAccountAbstractionProvider({ withSponsorship, } = {}) {
111
108
  if (withSponsorship && this.kernelClientWithSponsorship) {
112
109
  return this.kernelClientWithSponsorship;
@@ -118,6 +115,14 @@ class ZeroDevConnector extends WalletConnectorBase {
118
115
  StorageService.removeItem(ZERO_DEV_LAST_USED_CHAIN_ID_KEY);
119
116
  });
120
117
  }
118
+ initialize(_a) {
119
+ return __awaiter(this, arguments, void 0, function* ({ smartWalletAddress, eoaAddress, eoaConnector, properties, shouldSetEoaConnector, }) {
120
+ yield this.registerEoa(Object.assign({ eoaAddress,
121
+ eoaConnector,
122
+ shouldSetEoaConnector,
123
+ smartWalletAddress }, properties));
124
+ });
125
+ }
121
126
  registerEoa(_a) {
122
127
  return __awaiter(this, void 0, void 0, function* () {
123
128
  var { smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector = false } = _a, properties = __rest(_a, ["smartWalletAddress", "eoaAddress", "eoaConnector", "shouldSetEoaConnector"]);
@@ -365,7 +370,7 @@ class ZeroDevConnector extends WalletConnectorBase {
365
370
  onSendTransaction: (_b) => __awaiter(this, [_b], void 0, function* ({ transaction }) {
366
371
  try {
367
372
  this._walletUiUtils.disabledConfirmationOnce();
368
- const effectiveProvider = this.isGasSponsorshipDisabled
373
+ const effectiveProvider = this.isGasSponsorshipDisabled()
369
374
  ? provider
370
375
  : this.kernelClientWithSponsorship;
371
376
  if (!effectiveProvider) {
@@ -424,11 +429,6 @@ class ZeroDevConnector extends WalletConnectorBase {
424
429
  return provider;
425
430
  });
426
431
  }
427
- getSigner() {
428
- return __awaiter(this, void 0, void 0, function* () {
429
- return this.getWalletClient();
430
- });
431
- }
432
432
  formatUserOperation(params) {
433
433
  return __awaiter(this, void 0, void 0, function* () {
434
434
  var _a;
@@ -536,9 +536,6 @@ class ZeroDevConnector extends WalletConnectorBase {
536
536
  return sponsored;
537
537
  });
538
538
  }
539
- disableGasSponsorshipOnce() {
540
- this.isGasSponsorshipDisabled = true;
541
- }
542
539
  getBalance(address) {
543
540
  return __awaiter(this, void 0, void 0, function* () {
544
541
  var _a;
@@ -557,17 +554,6 @@ class ZeroDevConnector extends WalletConnectorBase {
557
554
  return client.signMessage({ message: messageToSign });
558
555
  });
559
556
  }
560
- createUiTransaction(from) {
561
- return __awaiter(this, void 0, void 0, function* () {
562
- yield this.validateActiveWallet(from);
563
- const walletClient = this.getWalletClient();
564
- const publicClient = yield this.getPublicClient();
565
- if (!publicClient || !walletClient) {
566
- throw new DynamicError('No public client available');
567
- }
568
- return createViemUiTransaction({ from, publicClient, walletClient });
569
- });
570
- }
571
557
  validateActiveWallet(expectedAddress) {
572
558
  return __awaiter(this, void 0, void 0, function* () {
573
559
  if (this.enableEIP7702Mode) {
@@ -591,15 +577,6 @@ class ZeroDevConnector extends WalletConnectorBase {
591
577
  });
592
578
  });
593
579
  }
594
- getBlockExplorerUrlsForCurrentNetwork() {
595
- return __awaiter(this, void 0, void 0, function* () {
596
- var _a, _b;
597
- return (_b = (_a = this.eoaConnector) === null || _a === void 0 ? void 0 : _a.getBlockExplorerUrlsForCurrentNetwork()) !== null && _b !== void 0 ? _b : [];
598
- });
599
- }
600
- getEnabledNetworks() {
601
- return this.evmNetworks;
602
- }
603
580
  }
604
581
 
605
582
  export { ZeroDevConnector };
package/src/index.cjs CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var assertPackageVersion = require('@dynamic-labs/assert-package-version');
7
7
  var _package = require('../package.cjs');
8
8
  var ZeroDevConnector = require('./ZeroDevConnector.cjs');
9
+ var ZKsyncConnector = require('./ZKsyncConnector.cjs');
9
10
  var createEcsdaKernelAccountClient = require('./utils/createEcsdaKernelAccountClient.cjs');
10
11
  var fetchZeroDevChain = require('./utils/fetchZeroDevChain.cjs');
11
12
  var getEcdsaValidator = require('./utils/getEcdsaValidator.cjs');
@@ -13,6 +14,7 @@ var getEntryPoint = require('./utils/getEntryPoint.cjs');
13
14
  var getKernelVersion = require('./utils/getKernelVersion.cjs');
14
15
  var ethereumAa = require('./ethereum-aa.cjs');
15
16
  var isZeroDevConnector = require('./utils/isZeroDevConnector.cjs');
17
+ var isZKsyncConnector = require('./utils/isZKsyncConnector.cjs');
16
18
 
17
19
  assertPackageVersion.assertPackageVersion('@dynamic-labs/ethereum-aa', _package.version);
18
20
  const ZeroDevSmartWalletConnectorsWithConfig = ({ bundlerProvider, bundlerRpc, paymasterRpc, kernelDelegationAddress, } = {}) => {
@@ -29,6 +31,13 @@ const ZeroDevSmartWalletConnectors = (props) => {
29
31
  }
30
32
  return [];
31
33
  };
34
+ const ZKsyncSmartWalletConnectors = (props) => {
35
+ var _a;
36
+ if ((_a = props.apiProviders) === null || _a === void 0 ? void 0 : _a.zksync) {
37
+ return [ZKsyncConnector.ZKsyncConnector];
38
+ }
39
+ return [];
40
+ };
32
41
 
33
42
  exports.createEcdsaKernelAccountClient = createEcsdaKernelAccountClient.createEcdsaKernelAccountClient;
34
43
  exports.fetchZeroDevChain = fetchZeroDevChain.fetchZeroDevChain;
@@ -37,5 +46,7 @@ exports.getEntryPoint = getEntryPoint.getEntryPoint;
37
46
  exports.getKernelVersion = getKernelVersion.getKernelVersion;
38
47
  exports.EthereumAaConnector = ethereumAa.EthereumAaConnector;
39
48
  exports.isZeroDevConnector = isZeroDevConnector.isZeroDevConnector;
49
+ exports.isZKsyncConnector = isZKsyncConnector.isZKsyncConnector;
50
+ exports.ZKsyncSmartWalletConnectors = ZKsyncSmartWalletConnectors;
40
51
  exports.ZeroDevSmartWalletConnectors = ZeroDevSmartWalletConnectors;
41
52
  exports.ZeroDevSmartWalletConnectorsWithConfig = ZeroDevSmartWalletConnectorsWithConfig;
package/src/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export { getEntryPoint } from './utils/getEntryPoint';
7
7
  export { getKernelVersion } from './utils/getKernelVersion';
8
8
  export * from './ethereum-aa';
9
9
  export { isZeroDevConnector } from './utils/isZeroDevConnector';
10
+ export { isZKsyncConnector } from './utils/isZKsyncConnector';
10
11
  export declare const ZeroDevSmartWalletConnectorsWithConfig: ({ bundlerProvider, bundlerRpc, paymasterRpc, kernelDelegationAddress, }?: {
11
12
  bundlerProvider?: BundlerProvider;
12
13
  bundlerRpc?: string;
@@ -14,3 +15,4 @@ export declare const ZeroDevSmartWalletConnectorsWithConfig: ({ bundlerProvider,
14
15
  kernelDelegationAddress?: `0x${string}`;
15
16
  }) => (props: any) => WalletConnectorConstructor[];
16
17
  export declare const ZeroDevSmartWalletConnectors: (props: any) => WalletConnectorConstructor[];
18
+ export declare const ZKsyncSmartWalletConnectors: (props: any) => WalletConnectorConstructor[];
package/src/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
3
3
  import { version } from '../package.js';
4
4
  import { ZeroDevConnector } from './ZeroDevConnector.js';
5
+ import { ZKsyncConnector } from './ZKsyncConnector.js';
5
6
  export { createEcdsaKernelAccountClient } from './utils/createEcsdaKernelAccountClient.js';
6
7
  export { fetchZeroDevChain } from './utils/fetchZeroDevChain.js';
7
8
  export { getEcdsaValidator } from './utils/getEcdsaValidator.js';
@@ -9,6 +10,7 @@ export { getEntryPoint } from './utils/getEntryPoint.js';
9
10
  export { getKernelVersion } from './utils/getKernelVersion.js';
10
11
  export { EthereumAaConnector } from './ethereum-aa.js';
11
12
  export { isZeroDevConnector } from './utils/isZeroDevConnector.js';
13
+ export { isZKsyncConnector } from './utils/isZKsyncConnector.js';
12
14
 
13
15
  assertPackageVersion('@dynamic-labs/ethereum-aa', version);
14
16
  const ZeroDevSmartWalletConnectorsWithConfig = ({ bundlerProvider, bundlerRpc, paymasterRpc, kernelDelegationAddress, } = {}) => {
@@ -25,5 +27,12 @@ const ZeroDevSmartWalletConnectors = (props) => {
25
27
  }
26
28
  return [];
27
29
  };
30
+ const ZKsyncSmartWalletConnectors = (props) => {
31
+ var _a;
32
+ if ((_a = props.apiProviders) === null || _a === void 0 ? void 0 : _a.zksync) {
33
+ return [ZKsyncConnector];
34
+ }
35
+ return [];
36
+ };
28
37
 
29
- export { ZeroDevSmartWalletConnectors, ZeroDevSmartWalletConnectorsWithConfig };
38
+ export { ZKsyncSmartWalletConnectors, ZeroDevSmartWalletConnectors, ZeroDevSmartWalletConnectorsWithConfig };
@@ -0,0 +1,88 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const AAFactoryABI = [
7
+ {
8
+ inputs: [
9
+ {
10
+ internalType: 'bytes32',
11
+ name: '_beaconProxyBytecodeHash',
12
+ type: 'bytes32',
13
+ },
14
+ { internalType: 'address', name: '_beacon', type: 'address' },
15
+ ],
16
+ stateMutability: 'nonpayable',
17
+ type: 'constructor',
18
+ },
19
+ {
20
+ inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
21
+ name: 'ACCOUNT_ALREADY_EXISTS',
22
+ type: 'error',
23
+ },
24
+ {
25
+ anonymous: false,
26
+ inputs: [
27
+ {
28
+ indexed: true,
29
+ internalType: 'address',
30
+ name: 'accountAddress',
31
+ type: 'address',
32
+ },
33
+ {
34
+ indexed: false,
35
+ internalType: 'bytes32',
36
+ name: 'uniqueAccountId',
37
+ type: 'bytes32',
38
+ },
39
+ ],
40
+ name: 'AccountCreated',
41
+ type: 'event',
42
+ },
43
+ {
44
+ inputs: [{ internalType: 'bytes32', name: 'accountId', type: 'bytes32' }],
45
+ name: 'accountMappings',
46
+ outputs: [
47
+ { internalType: 'address', name: 'deployedAccount', type: 'address' },
48
+ ],
49
+ stateMutability: 'view',
50
+ type: 'function',
51
+ },
52
+ {
53
+ inputs: [],
54
+ name: 'beacon',
55
+ outputs: [{ internalType: 'address', name: '', type: 'address' }],
56
+ stateMutability: 'view',
57
+ type: 'function',
58
+ },
59
+ {
60
+ inputs: [],
61
+ name: 'beaconProxyBytecodeHash',
62
+ outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }],
63
+ stateMutability: 'view',
64
+ type: 'function',
65
+ },
66
+ {
67
+ inputs: [
68
+ { internalType: 'bytes32', name: 'uniqueId', type: 'bytes32' },
69
+ { internalType: 'bytes[]', name: 'initialValidators', type: 'bytes[]' },
70
+ { internalType: 'address[]', name: 'initialK1Owners', type: 'address[]' },
71
+ ],
72
+ name: 'deployProxySsoAccount',
73
+ outputs: [
74
+ { internalType: 'address', name: 'accountAddress', type: 'address' },
75
+ ],
76
+ stateMutability: 'nonpayable',
77
+ type: 'function',
78
+ },
79
+ {
80
+ inputs: [],
81
+ name: 'getEncodedBeacon',
82
+ outputs: [{ internalType: 'bytes', name: '', type: 'bytes' }],
83
+ stateMutability: 'view',
84
+ type: 'function',
85
+ },
86
+ ];
87
+
88
+ exports.AAFactoryABI = AAFactoryABI;
@@ -0,0 +1,102 @@
1
+ export declare const AAFactoryABI: readonly [{
2
+ readonly inputs: readonly [{
3
+ readonly internalType: "bytes32";
4
+ readonly name: "_beaconProxyBytecodeHash";
5
+ readonly type: "bytes32";
6
+ }, {
7
+ readonly internalType: "address";
8
+ readonly name: "_beacon";
9
+ readonly type: "address";
10
+ }];
11
+ readonly stateMutability: "nonpayable";
12
+ readonly type: "constructor";
13
+ }, {
14
+ readonly inputs: readonly [{
15
+ readonly internalType: "address";
16
+ readonly name: "account";
17
+ readonly type: "address";
18
+ }];
19
+ readonly name: "ACCOUNT_ALREADY_EXISTS";
20
+ readonly type: "error";
21
+ }, {
22
+ readonly anonymous: false;
23
+ readonly inputs: readonly [{
24
+ readonly indexed: true;
25
+ readonly internalType: "address";
26
+ readonly name: "accountAddress";
27
+ readonly type: "address";
28
+ }, {
29
+ readonly indexed: false;
30
+ readonly internalType: "bytes32";
31
+ readonly name: "uniqueAccountId";
32
+ readonly type: "bytes32";
33
+ }];
34
+ readonly name: "AccountCreated";
35
+ readonly type: "event";
36
+ }, {
37
+ readonly inputs: readonly [{
38
+ readonly internalType: "bytes32";
39
+ readonly name: "accountId";
40
+ readonly type: "bytes32";
41
+ }];
42
+ readonly name: "accountMappings";
43
+ readonly outputs: readonly [{
44
+ readonly internalType: "address";
45
+ readonly name: "deployedAccount";
46
+ readonly type: "address";
47
+ }];
48
+ readonly stateMutability: "view";
49
+ readonly type: "function";
50
+ }, {
51
+ readonly inputs: readonly [];
52
+ readonly name: "beacon";
53
+ readonly outputs: readonly [{
54
+ readonly internalType: "address";
55
+ readonly name: "";
56
+ readonly type: "address";
57
+ }];
58
+ readonly stateMutability: "view";
59
+ readonly type: "function";
60
+ }, {
61
+ readonly inputs: readonly [];
62
+ readonly name: "beaconProxyBytecodeHash";
63
+ readonly outputs: readonly [{
64
+ readonly internalType: "bytes32";
65
+ readonly name: "";
66
+ readonly type: "bytes32";
67
+ }];
68
+ readonly stateMutability: "view";
69
+ readonly type: "function";
70
+ }, {
71
+ readonly inputs: readonly [{
72
+ readonly internalType: "bytes32";
73
+ readonly name: "uniqueId";
74
+ readonly type: "bytes32";
75
+ }, {
76
+ readonly internalType: "bytes[]";
77
+ readonly name: "initialValidators";
78
+ readonly type: "bytes[]";
79
+ }, {
80
+ readonly internalType: "address[]";
81
+ readonly name: "initialK1Owners";
82
+ readonly type: "address[]";
83
+ }];
84
+ readonly name: "deployProxySsoAccount";
85
+ readonly outputs: readonly [{
86
+ readonly internalType: "address";
87
+ readonly name: "accountAddress";
88
+ readonly type: "address";
89
+ }];
90
+ readonly stateMutability: "nonpayable";
91
+ readonly type: "function";
92
+ }, {
93
+ readonly inputs: readonly [];
94
+ readonly name: "getEncodedBeacon";
95
+ readonly outputs: readonly [{
96
+ readonly internalType: "bytes";
97
+ readonly name: "";
98
+ readonly type: "bytes";
99
+ }];
100
+ readonly stateMutability: "view";
101
+ readonly type: "function";
102
+ }];
@@ -0,0 +1,84 @@
1
+ 'use client'
2
+ const AAFactoryABI = [
3
+ {
4
+ inputs: [
5
+ {
6
+ internalType: 'bytes32',
7
+ name: '_beaconProxyBytecodeHash',
8
+ type: 'bytes32',
9
+ },
10
+ { internalType: 'address', name: '_beacon', type: 'address' },
11
+ ],
12
+ stateMutability: 'nonpayable',
13
+ type: 'constructor',
14
+ },
15
+ {
16
+ inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
17
+ name: 'ACCOUNT_ALREADY_EXISTS',
18
+ type: 'error',
19
+ },
20
+ {
21
+ anonymous: false,
22
+ inputs: [
23
+ {
24
+ indexed: true,
25
+ internalType: 'address',
26
+ name: 'accountAddress',
27
+ type: 'address',
28
+ },
29
+ {
30
+ indexed: false,
31
+ internalType: 'bytes32',
32
+ name: 'uniqueAccountId',
33
+ type: 'bytes32',
34
+ },
35
+ ],
36
+ name: 'AccountCreated',
37
+ type: 'event',
38
+ },
39
+ {
40
+ inputs: [{ internalType: 'bytes32', name: 'accountId', type: 'bytes32' }],
41
+ name: 'accountMappings',
42
+ outputs: [
43
+ { internalType: 'address', name: 'deployedAccount', type: 'address' },
44
+ ],
45
+ stateMutability: 'view',
46
+ type: 'function',
47
+ },
48
+ {
49
+ inputs: [],
50
+ name: 'beacon',
51
+ outputs: [{ internalType: 'address', name: '', type: 'address' }],
52
+ stateMutability: 'view',
53
+ type: 'function',
54
+ },
55
+ {
56
+ inputs: [],
57
+ name: 'beaconProxyBytecodeHash',
58
+ outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }],
59
+ stateMutability: 'view',
60
+ type: 'function',
61
+ },
62
+ {
63
+ inputs: [
64
+ { internalType: 'bytes32', name: 'uniqueId', type: 'bytes32' },
65
+ { internalType: 'bytes[]', name: 'initialValidators', type: 'bytes[]' },
66
+ { internalType: 'address[]', name: 'initialK1Owners', type: 'address[]' },
67
+ ],
68
+ name: 'deployProxySsoAccount',
69
+ outputs: [
70
+ { internalType: 'address', name: 'accountAddress', type: 'address' },
71
+ ],
72
+ stateMutability: 'nonpayable',
73
+ type: 'function',
74
+ },
75
+ {
76
+ inputs: [],
77
+ name: 'getEncodedBeacon',
78
+ outputs: [{ internalType: 'bytes', name: '', type: 'bytes' }],
79
+ stateMutability: 'view',
80
+ type: 'function',
81
+ },
82
+ ];
83
+
84
+ export { AAFactoryABI };
@@ -5,3 +5,4 @@ export * from './createEcsdaKernelAccountClient';
5
5
  export * from './getEcdsaValidator';
6
6
  export * from './getEntryPoint';
7
7
  export * from './getKernelVersion';
8
+ export * from './zksync';
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const isZKsyncConnector = (connector) => (connector === null || connector === void 0 ? void 0 : connector.key) === 'zksync';
7
+
8
+ exports.isZKsyncConnector = isZKsyncConnector;
@@ -0,0 +1,3 @@
1
+ import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
2
+ import { ZKsyncConnector } from '../ZKsyncConnector';
3
+ export declare const isZKsyncConnector: (connector: ZKsyncConnector | WalletConnector) => connector is ZKsyncConnector;
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ const isZKsyncConnector = (connector) => (connector === null || connector === void 0 ? void 0 : connector.key) === 'zksync';
3
+
4
+ export { isZKsyncConnector };
@@ -0,0 +1,97 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../_virtual/_tslib.cjs');
7
+ var utils = require('zksync-sso/utils');
8
+ var viem = require('viem');
9
+ var abi = require('../abi.cjs');
10
+ var passkeys = require('./passkeys.cjs');
11
+ var getSalt = require('./getSalt.cjs');
12
+
13
+ /**
14
+ * Returns the parameters needed for deploying the smart account
15
+ * @returns Deployment parameters object
16
+ * @testable This method can be overridden in tests
17
+ */
18
+ const getDeploymentParameters = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ eoaAddress, enablePasskeys, passkeyAddress, sessionKeyAddress, saltText, }) {
19
+ const initialValidators = [];
20
+ const initialK1Owners = [eoaAddress];
21
+ // TODO: revisit this logic, maybe we should always add the passkey module data,
22
+ // otherwise if people active passkeys later, old accounts will not be able to use passkey module
23
+ if (enablePasskeys && passkeyAddress) {
24
+ const encodedPasskeyModuleData = yield passkeys.getEncodedPasskeyModuleData({
25
+ passkeyAddress,
26
+ });
27
+ initialValidators.push(encodedPasskeyModuleData);
28
+ }
29
+ if (sessionKeyAddress) {
30
+ const encodedSessionKeyModuleData = utils.encodeModuleData({
31
+ address: sessionKeyAddress,
32
+ parameters: '0x',
33
+ });
34
+ initialValidators.push(encodedSessionKeyModuleData);
35
+ }
36
+ return {
37
+ initialK1Owners,
38
+ initialValidators,
39
+ salt: getSalt.getSalt(saltText),
40
+ };
41
+ });
42
+ /**
43
+ * Simulates the smart account deployment
44
+ * @param publicClient - The public client to use for simulation
45
+ * @param walletClient - The wallet client to use for account information
46
+ * @param params - The deployment parameters
47
+ * @returns The simulation result
48
+ * @throws {ZkSyncConnectorError} If simulation fails
49
+ * @testable This method can be mocked in tests
50
+ */
51
+ const simulateAccountDeployment = (publicClient_1, walletClient_1, params_1, factoryAddress_1, ...args_1) => _tslib.__awaiter(void 0, [publicClient_1, walletClient_1, params_1, factoryAddress_1, ...args_1], void 0, function* (publicClient, walletClient, params, factoryAddress, checkBalance = true) {
52
+ var _b, _c, _d;
53
+ // this is to keep the same salt as calculated on zksync sso package
54
+ const salt = viem.keccak256(viem.toHex(params.salt));
55
+ const gasEstimate = yield publicClient.estimateContractGas({
56
+ abi: abi.AAFactoryABI,
57
+ account: (_b = walletClient.account) === null || _b === void 0 ? void 0 : _b.address,
58
+ address: factoryAddress,
59
+ args: [salt, params.initialValidators, params.initialK1Owners],
60
+ functionName: 'deployProxySsoAccount',
61
+ });
62
+ if (checkBalance) {
63
+ const balance = yield publicClient.getBalance({
64
+ address: (_c = walletClient.account) === null || _c === void 0 ? void 0 : _c.address,
65
+ });
66
+ if (balance < gasEstimate) {
67
+ throw new Error('Insufficient balance to deploy account');
68
+ }
69
+ }
70
+ // Simulate the contract call
71
+ return publicClient.simulateContract({
72
+ abi: abi.AAFactoryABI,
73
+ account: (_d = walletClient.account) === null || _d === void 0 ? void 0 : _d.address,
74
+ address: factoryAddress,
75
+ args: [salt, params.initialValidators, params.initialK1Owners],
76
+ functionName: 'deployProxySsoAccount',
77
+ });
78
+ });
79
+ /**
80
+ * Executes the smart account deployment transaction
81
+ * @param walletClient - The wallet client to use for transaction execution
82
+ * @param request - The deployment request object containing transaction parameters
83
+ * @returns Promise that resolves when the deployment transaction is confirmed
84
+ * @throws {DynamicError} If the smart account address is not initialized
85
+ * @throws {Error} If transaction execution or confirmation fails
86
+ */
87
+ const executeAccountDeployment = (walletClient, publicClient, request, smartAccountAddress) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
88
+ if (!smartAccountAddress) {
89
+ throw new Error('Smart account address is not initialized');
90
+ }
91
+ const tx = yield walletClient.writeContract(request);
92
+ yield publicClient.waitForTransactionReceipt({ hash: tx });
93
+ });
94
+
95
+ exports.executeAccountDeployment = executeAccountDeployment;
96
+ exports.getDeploymentParameters = getDeploymentParameters;
97
+ exports.simulateAccountDeployment = simulateAccountDeployment;
@@ -0,0 +1,37 @@
1
+ import { PublicClient, WalletClient } from 'viem';
2
+ export interface DeploymentParams {
3
+ initialK1Owners: `0x${string}`[];
4
+ initialValidators: `0x${string}`[];
5
+ salt: `0x${string}`;
6
+ }
7
+ /**
8
+ * Returns the parameters needed for deploying the smart account
9
+ * @returns Deployment parameters object
10
+ * @testable This method can be overridden in tests
11
+ */
12
+ export declare const getDeploymentParameters: ({ eoaAddress, enablePasskeys, passkeyAddress, sessionKeyAddress, saltText, }: {
13
+ eoaAddress: `0x${string}`;
14
+ enablePasskeys: boolean;
15
+ passkeyAddress: `0x${string}`;
16
+ sessionKeyAddress: `0x${string}`;
17
+ saltText?: string;
18
+ }) => Promise<DeploymentParams>;
19
+ /**
20
+ * Simulates the smart account deployment
21
+ * @param publicClient - The public client to use for simulation
22
+ * @param walletClient - The wallet client to use for account information
23
+ * @param params - The deployment parameters
24
+ * @returns The simulation result
25
+ * @throws {ZkSyncConnectorError} If simulation fails
26
+ * @testable This method can be mocked in tests
27
+ */
28
+ export declare const simulateAccountDeployment: (publicClient: PublicClient, walletClient: WalletClient, params: DeploymentParams, factoryAddress: `0x${string}`, checkBalance?: boolean) => Promise<any>;
29
+ /**
30
+ * Executes the smart account deployment transaction
31
+ * @param walletClient - The wallet client to use for transaction execution
32
+ * @param request - The deployment request object containing transaction parameters
33
+ * @returns Promise that resolves when the deployment transaction is confirmed
34
+ * @throws {DynamicError} If the smart account address is not initialized
35
+ * @throws {Error} If transaction execution or confirmation fails
36
+ */
37
+ export declare const executeAccountDeployment: (walletClient: WalletClient, publicClient: PublicClient, request: any, smartAccountAddress: `0x${string}`) => Promise<void>;