@dynamic-labs/ethereum-aa 4.11.2 → 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.
- package/CHANGELOG.md +13 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -9
- package/src/AccountAbstractionConnector.cjs +29 -0
- package/src/AccountAbstractionConnector.d.ts +6 -2
- package/src/AccountAbstractionConnector.js +30 -1
- package/src/ZKsyncConnector.cjs +526 -0
- package/src/ZKsyncConnector.d.ts +17228 -0
- package/src/ZKsyncConnector.js +522 -0
- package/src/ZeroDevConnector.cjs +1 -25
- package/src/ZeroDevConnector.d.ts +2 -7662
- package/src/ZeroDevConnector.js +2 -26
- package/src/index.cjs +11 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +10 -1
- package/src/utils/abi.cjs +88 -0
- package/src/utils/abi.d.ts +102 -0
- package/src/utils/abi.js +84 -0
- package/src/utils/index.d.ts +1 -0
- package/src/utils/isZKsyncConnector.cjs +8 -0
- package/src/utils/isZKsyncConnector.d.ts +3 -0
- package/src/utils/isZKsyncConnector.js +4 -0
- package/src/utils/zksync/deployment.cjs +97 -0
- package/src/utils/zksync/deployment.d.ts +37 -0
- package/src/utils/zksync/deployment.js +91 -0
- package/src/utils/zksync/getSalt.cjs +10 -0
- package/src/utils/zksync/getSalt.d.ts +1 -0
- package/src/utils/zksync/getSalt.js +6 -0
- package/src/utils/zksync/index.d.ts +4 -0
- package/src/utils/zksync/network.cjs +17 -0
- package/src/utils/zksync/network.d.ts +2 -0
- package/src/utils/zksync/network.js +13 -0
- package/src/utils/zksync/passkeys.cjs +41 -0
- package/src/utils/zksync/passkeys.d.ts +9 -0
- package/src/utils/zksync/passkeys.js +37 -0
package/src/ZeroDevConnector.js
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
|
6
|
+
import { EthereumWallet, isEthWalletConnector, chainsMap, confirmationTransport, unFormatTransaction } from '@dynamic-labs/ethereum-core';
|
|
7
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';
|
|
@@ -12,6 +12,7 @@ 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';
|
|
15
16
|
import { AccountAbstractionConnector } from './AccountAbstractionConnector.js';
|
|
16
17
|
|
|
17
18
|
class ZeroDevConnector extends AccountAbstractionConnector {
|
|
@@ -428,11 +429,6 @@ class ZeroDevConnector extends AccountAbstractionConnector {
|
|
|
428
429
|
return provider;
|
|
429
430
|
});
|
|
430
431
|
}
|
|
431
|
-
getSigner() {
|
|
432
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
433
|
-
return this.getWalletClient();
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
432
|
formatUserOperation(params) {
|
|
437
433
|
return __awaiter(this, void 0, void 0, function* () {
|
|
438
434
|
var _a;
|
|
@@ -558,17 +554,6 @@ class ZeroDevConnector extends AccountAbstractionConnector {
|
|
|
558
554
|
return client.signMessage({ message: messageToSign });
|
|
559
555
|
});
|
|
560
556
|
}
|
|
561
|
-
createUiTransaction(from) {
|
|
562
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
563
|
-
yield this.validateActiveWallet(from);
|
|
564
|
-
const walletClient = this.getWalletClient();
|
|
565
|
-
const publicClient = yield this.getPublicClient();
|
|
566
|
-
if (!publicClient || !walletClient) {
|
|
567
|
-
throw new DynamicError('No public client available');
|
|
568
|
-
}
|
|
569
|
-
return createViemUiTransaction({ from, publicClient, walletClient });
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
557
|
validateActiveWallet(expectedAddress) {
|
|
573
558
|
return __awaiter(this, void 0, void 0, function* () {
|
|
574
559
|
if (this.enableEIP7702Mode) {
|
|
@@ -592,15 +577,6 @@ class ZeroDevConnector extends AccountAbstractionConnector {
|
|
|
592
577
|
});
|
|
593
578
|
});
|
|
594
579
|
}
|
|
595
|
-
getBlockExplorerUrlsForCurrentNetwork() {
|
|
596
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
597
|
-
var _a, _b;
|
|
598
|
-
return (_b = (_a = this.eoaConnector) === null || _a === void 0 ? void 0 : _a.getBlockExplorerUrlsForCurrentNetwork()) !== null && _b !== void 0 ? _b : [];
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
getEnabledNetworks() {
|
|
602
|
-
return this.evmNetworks;
|
|
603
|
-
}
|
|
604
580
|
}
|
|
605
581
|
|
|
606
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
|
+
}];
|
package/src/utils/abi.js
ADDED
|
@@ -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 };
|
package/src/utils/index.d.ts
CHANGED
|
@@ -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,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>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { encodeModuleData } from 'zksync-sso/utils';
|
|
4
|
+
import { keccak256, toHex } from 'viem';
|
|
5
|
+
import { AAFactoryABI } from '../abi.js';
|
|
6
|
+
import { getEncodedPasskeyModuleData } from './passkeys.js';
|
|
7
|
+
import { getSalt } from './getSalt.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns the parameters needed for deploying the smart account
|
|
11
|
+
* @returns Deployment parameters object
|
|
12
|
+
* @testable This method can be overridden in tests
|
|
13
|
+
*/
|
|
14
|
+
const getDeploymentParameters = (_a) => __awaiter(void 0, [_a], void 0, function* ({ eoaAddress, enablePasskeys, passkeyAddress, sessionKeyAddress, saltText, }) {
|
|
15
|
+
const initialValidators = [];
|
|
16
|
+
const initialK1Owners = [eoaAddress];
|
|
17
|
+
// TODO: revisit this logic, maybe we should always add the passkey module data,
|
|
18
|
+
// otherwise if people active passkeys later, old accounts will not be able to use passkey module
|
|
19
|
+
if (enablePasskeys && passkeyAddress) {
|
|
20
|
+
const encodedPasskeyModuleData = yield getEncodedPasskeyModuleData({
|
|
21
|
+
passkeyAddress,
|
|
22
|
+
});
|
|
23
|
+
initialValidators.push(encodedPasskeyModuleData);
|
|
24
|
+
}
|
|
25
|
+
if (sessionKeyAddress) {
|
|
26
|
+
const encodedSessionKeyModuleData = encodeModuleData({
|
|
27
|
+
address: sessionKeyAddress,
|
|
28
|
+
parameters: '0x',
|
|
29
|
+
});
|
|
30
|
+
initialValidators.push(encodedSessionKeyModuleData);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
initialK1Owners,
|
|
34
|
+
initialValidators,
|
|
35
|
+
salt: getSalt(saltText),
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Simulates the smart account deployment
|
|
40
|
+
* @param publicClient - The public client to use for simulation
|
|
41
|
+
* @param walletClient - The wallet client to use for account information
|
|
42
|
+
* @param params - The deployment parameters
|
|
43
|
+
* @returns The simulation result
|
|
44
|
+
* @throws {ZkSyncConnectorError} If simulation fails
|
|
45
|
+
* @testable This method can be mocked in tests
|
|
46
|
+
*/
|
|
47
|
+
const simulateAccountDeployment = (publicClient_1, walletClient_1, params_1, factoryAddress_1, ...args_1) => __awaiter(void 0, [publicClient_1, walletClient_1, params_1, factoryAddress_1, ...args_1], void 0, function* (publicClient, walletClient, params, factoryAddress, checkBalance = true) {
|
|
48
|
+
var _b, _c, _d;
|
|
49
|
+
// this is to keep the same salt as calculated on zksync sso package
|
|
50
|
+
const salt = keccak256(toHex(params.salt));
|
|
51
|
+
const gasEstimate = yield publicClient.estimateContractGas({
|
|
52
|
+
abi: AAFactoryABI,
|
|
53
|
+
account: (_b = walletClient.account) === null || _b === void 0 ? void 0 : _b.address,
|
|
54
|
+
address: factoryAddress,
|
|
55
|
+
args: [salt, params.initialValidators, params.initialK1Owners],
|
|
56
|
+
functionName: 'deployProxySsoAccount',
|
|
57
|
+
});
|
|
58
|
+
if (checkBalance) {
|
|
59
|
+
const balance = yield publicClient.getBalance({
|
|
60
|
+
address: (_c = walletClient.account) === null || _c === void 0 ? void 0 : _c.address,
|
|
61
|
+
});
|
|
62
|
+
if (balance < gasEstimate) {
|
|
63
|
+
throw new Error('Insufficient balance to deploy account');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Simulate the contract call
|
|
67
|
+
return publicClient.simulateContract({
|
|
68
|
+
abi: AAFactoryABI,
|
|
69
|
+
account: (_d = walletClient.account) === null || _d === void 0 ? void 0 : _d.address,
|
|
70
|
+
address: factoryAddress,
|
|
71
|
+
args: [salt, params.initialValidators, params.initialK1Owners],
|
|
72
|
+
functionName: 'deployProxySsoAccount',
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Executes the smart account deployment transaction
|
|
77
|
+
* @param walletClient - The wallet client to use for transaction execution
|
|
78
|
+
* @param request - The deployment request object containing transaction parameters
|
|
79
|
+
* @returns Promise that resolves when the deployment transaction is confirmed
|
|
80
|
+
* @throws {DynamicError} If the smart account address is not initialized
|
|
81
|
+
* @throws {Error} If transaction execution or confirmation fails
|
|
82
|
+
*/
|
|
83
|
+
const executeAccountDeployment = (walletClient, publicClient, request, smartAccountAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
if (!smartAccountAddress) {
|
|
85
|
+
throw new Error('Smart account address is not initialized');
|
|
86
|
+
}
|
|
87
|
+
const tx = yield walletClient.writeContract(request);
|
|
88
|
+
yield publicClient.waitForTransactionReceipt({ hash: tx });
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export { executeAccountDeployment, getDeploymentParameters, simulateAccountDeployment };
|