@dynamic-labs/ethereum-aa 4.16.0 → 4.17.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 +15 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/ZeroDevConnector.cjs +30 -9
- package/src/ZeroDevConnector.d.ts +12 -4
- package/src/ZeroDevConnector.js +31 -10
- package/src/utils/hasSmartAccount.cjs +20 -0
- package/src/utils/hasSmartAccount.d.ts +2 -0
- package/src/utils/hasSmartAccount.js +16 -0
- package/src/utils/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.17.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.16.0...v4.17.0) (2025-05-06)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add chain id option to create kernel client in react-native ([#8650](https://github.com/dynamic-labs/dynamic-auth/issues/8650)) ([1450bea](https://github.com/dynamic-labs/dynamic-auth/commit/1450bea6f979a82ed4880700aff14fa1ead9dc60))
|
|
8
|
+
* add sendCalls method to EthereumWallet ([#8634](https://github.com/dynamic-labs/dynamic-auth/issues/8634)) ([7c9aef9](https://github.com/dynamic-labs/dynamic-auth/commit/7c9aef95382b4823a40279bebfb084de32c25610))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* 7702 do not override existing old aa ([#8630](https://github.com/dynamic-labs/dynamic-auth/issues/8630)) ([a731d9e](https://github.com/dynamic-labs/dynamic-auth/commit/a731d9e77ecd9e1dec3a7704a63989b5f2741a57))
|
|
14
|
+
* improve error message when email login fails ([#8649](https://github.com/dynamic-labs/dynamic-auth/issues/8649)) ([e1c03ac](https://github.com/dynamic-labs/dynamic-auth/commit/e1c03ac6dc83386c63d63db59d31355bc4fe2959))
|
|
15
|
+
* improve react-native stability on android ([#8652](https://github.com/dynamic-labs/dynamic-auth/issues/8652)) ([1617546](https://github.com/dynamic-labs/dynamic-auth/commit/1617546e6053c2ab32f7d385336c47df185d077f))
|
|
16
|
+
|
|
2
17
|
## [4.16.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.15.0...v4.16.0) (2025-05-03)
|
|
3
18
|
|
|
4
19
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum-aa",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.0",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@dynamic-labs/sdk-api-core": "0.0.660",
|
|
22
|
-
"@zerodev/ecdsa-validator": "5.4.
|
|
23
|
-
"@zerodev/multi-chain-ecdsa-validator": "5.4.
|
|
24
|
-
"@zerodev/sdk": "5.4.
|
|
25
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
26
|
-
"@dynamic-labs/ethereum-aa-core": "4.
|
|
27
|
-
"@dynamic-labs/ethereum-core": "4.
|
|
28
|
-
"@dynamic-labs/logger": "4.
|
|
29
|
-
"@dynamic-labs/types": "4.
|
|
30
|
-
"@dynamic-labs/utils": "4.
|
|
31
|
-
"@dynamic-labs/wallet-book": "4.
|
|
32
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
22
|
+
"@zerodev/ecdsa-validator": "5.4.8",
|
|
23
|
+
"@zerodev/multi-chain-ecdsa-validator": "5.4.5",
|
|
24
|
+
"@zerodev/sdk": "5.4.34",
|
|
25
|
+
"@dynamic-labs/assert-package-version": "4.17.0",
|
|
26
|
+
"@dynamic-labs/ethereum-aa-core": "4.17.0",
|
|
27
|
+
"@dynamic-labs/ethereum-core": "4.17.0",
|
|
28
|
+
"@dynamic-labs/logger": "4.17.0",
|
|
29
|
+
"@dynamic-labs/types": "4.17.0",
|
|
30
|
+
"@dynamic-labs/utils": "4.17.0",
|
|
31
|
+
"@dynamic-labs/wallet-book": "4.17.0",
|
|
32
|
+
"@dynamic-labs/wallet-connector-core": "4.17.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"viem": "^2.21.60"
|
package/src/ZeroDevConnector.cjs
CHANGED
|
@@ -8,6 +8,7 @@ var viem = require('viem');
|
|
|
8
8
|
var accounts = require('viem/accounts');
|
|
9
9
|
var constants$1 = require('@zerodev/sdk/constants');
|
|
10
10
|
var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
11
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
11
12
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
12
13
|
var utils = require('@dynamic-labs/utils');
|
|
13
14
|
var ethereumAaCore = require('@dynamic-labs/ethereum-aa-core');
|
|
@@ -18,6 +19,7 @@ var getEcdsaValidator = require('./utils/getEcdsaValidator.cjs');
|
|
|
18
19
|
var getEntryPoint = require('./utils/getEntryPoint.cjs');
|
|
19
20
|
var getKernelVersion = require('./utils/getKernelVersion.cjs');
|
|
20
21
|
var isEVMAuthorizationCapable = require('./utils/isEVMAuthorizationCapable.cjs');
|
|
22
|
+
var hasSmartAccount = require('./utils/hasSmartAccount.cjs');
|
|
21
23
|
|
|
22
24
|
class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
23
25
|
constructor(opts) {
|
|
@@ -41,9 +43,15 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
41
43
|
},
|
|
42
44
|
name: 'ZeroDev',
|
|
43
45
|
};
|
|
46
|
+
this.hasExistingSmartAccount = false;
|
|
47
|
+
/**
|
|
48
|
+
* Flag for EIP-7702 mode, enabled when EIP-7702 is enabled and no smart account exists
|
|
49
|
+
*/
|
|
50
|
+
this.shouldUseEIP7702Mode = false;
|
|
44
51
|
this._walletUiUtils = opts.walletUiUtils;
|
|
45
52
|
this.providersConfig = (_a = opts.providersConfig) !== null && _a !== void 0 ? _a : {};
|
|
46
|
-
this.
|
|
53
|
+
this.is7702EnabledOnDashboard =
|
|
54
|
+
(_c = (_b = opts.apiProviders.zerodev) === null || _b === void 0 ? void 0 : _b.enableEIP7702) !== null && _c !== void 0 ? _c : false;
|
|
47
55
|
this.entryPoint = getEntryPoint.getEntryPoint((_d = opts.apiProviders.zerodev) === null || _d === void 0 ? void 0 : _d.entryPointVersion);
|
|
48
56
|
this.kernelVersion = getKernelVersion.getKernelVersion((_e = opts.apiProviders.zerodev) === null || _e === void 0 ? void 0 : _e.kernelVersion, this.entryPoint);
|
|
49
57
|
this.enableKernelV3Migration =
|
|
@@ -120,17 +128,22 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
120
128
|
});
|
|
121
129
|
}
|
|
122
130
|
initialize(_a) {
|
|
123
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ smartWalletAddress, eoaAddress, eoaConnector, properties, shouldSetEoaConnector, }) {
|
|
131
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ smartWalletAddress, eoaAddress, eoaConnector, properties, shouldSetEoaConnector, verifiedCredentials, }) {
|
|
124
132
|
yield this.registerEoa(Object.assign({ eoaAddress,
|
|
125
133
|
eoaConnector,
|
|
126
134
|
shouldSetEoaConnector,
|
|
127
|
-
smartWalletAddress
|
|
135
|
+
smartWalletAddress,
|
|
136
|
+
verifiedCredentials }, properties));
|
|
128
137
|
});
|
|
129
138
|
}
|
|
130
139
|
registerEoa(_a) {
|
|
131
140
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
var { smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector = false } = _a, properties = _tslib.__rest(_a, ["smartWalletAddress", "eoaAddress", "eoaConnector", "shouldSetEoaConnector"]);
|
|
133
|
-
if (
|
|
141
|
+
var { smartWalletAddress, eoaAddress, eoaConnector, verifiedCredentials, shouldSetEoaConnector = false } = _a, properties = _tslib.__rest(_a, ["smartWalletAddress", "eoaAddress", "eoaConnector", "verifiedCredentials", "shouldSetEoaConnector"]);
|
|
142
|
+
if (!eoaConnector) {
|
|
143
|
+
throw new utils.DynamicError('No EOA connector');
|
|
144
|
+
}
|
|
145
|
+
this.determineSmartAccountStatus(eoaConnector, verifiedCredentials);
|
|
146
|
+
if (this.shouldUseEIP7702Mode) {
|
|
134
147
|
// In EIP-7702, addresses must match
|
|
135
148
|
if (smartWalletAddress !== eoaAddress) {
|
|
136
149
|
throw new Error('In EIP-7702 mode, smart wallet and EOA addresses must be the same');
|
|
@@ -158,6 +171,14 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
158
171
|
}
|
|
159
172
|
});
|
|
160
173
|
}
|
|
174
|
+
determineSmartAccountStatus(eoaConnector, verifiedCredentials) {
|
|
175
|
+
if (walletConnectorCore.getWalletProvider(eoaConnector) !== sdkApiCore.WalletProviderEnum.EmbeddedWallet) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
this.hasExistingSmartAccount = hasSmartAccount.hasSmartAccount(verifiedCredentials);
|
|
179
|
+
this.shouldUseEIP7702Mode =
|
|
180
|
+
this.is7702EnabledOnDashboard && !this.hasExistingSmartAccount;
|
|
181
|
+
}
|
|
161
182
|
getOrCreateAuthorization() {
|
|
162
183
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
163
184
|
var _a;
|
|
@@ -231,7 +252,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
231
252
|
}
|
|
232
253
|
const signer = yield this.eoaConnector.getSigner();
|
|
233
254
|
signer.account = accounts.toAccount(eoaAddress);
|
|
234
|
-
if (this.
|
|
255
|
+
if (this.shouldUseEIP7702Mode) {
|
|
235
256
|
this.authorization = yield this.getOrCreateAuthorization();
|
|
236
257
|
}
|
|
237
258
|
yield this.generateProviderMap(signer);
|
|
@@ -309,7 +330,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
309
330
|
const network = this.evmNetworks.find((network) => network.chainId === utils.parseChainId(chainId));
|
|
310
331
|
const publicClientRpc = (_b = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _b === void 0 ? void 0 : _b[0];
|
|
311
332
|
let kernelClient;
|
|
312
|
-
if (this.
|
|
333
|
+
if (this.shouldUseEIP7702Mode) {
|
|
313
334
|
kernelClient = yield createEcdsaKernelAccountClient.createEcdsaKernelAccountClientWith7702({
|
|
314
335
|
authorization,
|
|
315
336
|
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
@@ -352,7 +373,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
352
373
|
getAddress() {
|
|
353
374
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
354
375
|
var _a, _b, _c;
|
|
355
|
-
if (this.
|
|
376
|
+
if (this.shouldUseEIP7702Mode) {
|
|
356
377
|
return this.eoaAddress;
|
|
357
378
|
}
|
|
358
379
|
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
@@ -573,7 +594,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
573
594
|
}
|
|
574
595
|
validateActiveWallet(expectedAddress) {
|
|
575
596
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
576
|
-
if (this.
|
|
597
|
+
if (this.shouldUseEIP7702Mode) {
|
|
577
598
|
const currentAddress = yield this.getAddress();
|
|
578
599
|
if (currentAddress !== expectedAddress) {
|
|
579
600
|
throw new utils.DynamicError('Invalid active wallet');
|
|
@@ -5,7 +5,7 @@ import { SignAuthorizationReturnType } from 'viem/accounts';
|
|
|
5
5
|
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
|
-
import { EcdsaValidatorOptions, Provider, ProviderEntryPointVersionEnum, ProviderEnum, ProviderKernelVersionEnum, ProviderMultichainAccountAbstractionProviders, SmartWalletProperties } from '@dynamic-labs/sdk-api-core';
|
|
8
|
+
import { EcdsaValidatorOptions, Provider, ProviderEntryPointVersionEnum, ProviderEnum, ProviderKernelVersionEnum, ProviderMultichainAccountAbstractionProviders, SmartWalletProperties, JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
|
|
9
9
|
import { Chain, InternalWalletConnector, IZeroDevConnector } from '@dynamic-labs/wallet-connector-core';
|
|
10
10
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
11
11
|
import { GenericNetwork, TransactionReceipt, WalletUiUtils } from '@dynamic-labs/types';
|
|
@@ -60,8 +60,13 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
|
|
|
60
60
|
};
|
|
61
61
|
name: string;
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
is7702EnabledOnDashboard: boolean;
|
|
64
64
|
private authorization?;
|
|
65
|
+
private hasExistingSmartAccount;
|
|
66
|
+
/**
|
|
67
|
+
* Flag for EIP-7702 mode, enabled when EIP-7702 is enabled and no smart account exists
|
|
68
|
+
*/
|
|
69
|
+
private shouldUseEIP7702Mode;
|
|
65
70
|
constructor(opts: ZeroDevConnectorProps);
|
|
66
71
|
confirmTransactionStatus(): Promise<TransactionReceipt>;
|
|
67
72
|
get currentNetworkProvider(): {
|
|
@@ -79,22 +84,25 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
|
|
|
79
84
|
withSponsorship?: boolean;
|
|
80
85
|
}): T;
|
|
81
86
|
endSession(): Promise<void>;
|
|
82
|
-
initialize({ smartWalletAddress, eoaAddress, eoaConnector, properties, shouldSetEoaConnector, }: {
|
|
87
|
+
initialize({ smartWalletAddress, eoaAddress, eoaConnector, properties, shouldSetEoaConnector, verifiedCredentials, }: {
|
|
83
88
|
smartWalletAddress: string;
|
|
84
89
|
eoaAddress: string;
|
|
85
90
|
eoaConnector: InternalWalletConnector;
|
|
86
91
|
shouldSetEoaConnector: boolean;
|
|
87
92
|
properties?: SmartWalletProperties;
|
|
93
|
+
verifiedCredentials: JwtVerifiedCredential[];
|
|
88
94
|
}): Promise<void>;
|
|
89
|
-
registerEoa({ smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector, ...properties }: {
|
|
95
|
+
registerEoa({ smartWalletAddress, eoaAddress, eoaConnector, verifiedCredentials, shouldSetEoaConnector, ...properties }: {
|
|
90
96
|
smartWalletAddress: string;
|
|
91
97
|
eoaAddress: string;
|
|
92
98
|
eoaConnector: InternalWalletConnector;
|
|
99
|
+
verifiedCredentials: JwtVerifiedCredential[];
|
|
93
100
|
shouldSetEoaConnector: boolean;
|
|
94
101
|
ecdsaProviderType?: EcdsaValidatorOptions;
|
|
95
102
|
kernelVersion?: ProviderKernelVersionEnum;
|
|
96
103
|
entryPointVersion?: ProviderEntryPointVersionEnum;
|
|
97
104
|
}): Promise<void>;
|
|
105
|
+
private determineSmartAccountStatus;
|
|
98
106
|
private getOrCreateAuthorization;
|
|
99
107
|
private setEoaConnector;
|
|
100
108
|
private warnIfProjectChainNotEnabled;
|
package/src/ZeroDevConnector.js
CHANGED
|
@@ -4,7 +4,8 @@ import { publicActions, custom, createWalletClient, toHex, formatEther } from 'v
|
|
|
4
4
|
import { toAccount } from 'viem/accounts';
|
|
5
5
|
import { KERNEL_V3_3_BETA, KernelVersionToAddressesMap, getEntryPoint as getEntryPoint$1 } from '@zerodev/sdk/constants';
|
|
6
6
|
import { EthereumWallet, isEthWalletConnector, chainsMap, confirmationTransport, unFormatTransaction } from '@dynamic-labs/ethereum-core';
|
|
7
|
-
import {
|
|
7
|
+
import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
8
|
+
import { eventListenerHandlers, getWalletProvider } from '@dynamic-labs/wallet-connector-core';
|
|
8
9
|
import { parseEvmNetworks, StorageService, DynamicError, DeferredPromise, parseChainId, wrapMethodWithCallback, TransactionGasCannotBeSponsoredError, InsufficientFundsError } from '@dynamic-labs/utils';
|
|
9
10
|
import { AccountAbstractionBaseConnector } from '@dynamic-labs/ethereum-aa-core';
|
|
10
11
|
import { ZERO_DEV_LAST_USED_CHAIN_ID_KEY } from './constants.js';
|
|
@@ -14,6 +15,7 @@ import { getEcdsaValidator } from './utils/getEcdsaValidator.js';
|
|
|
14
15
|
import { getEntryPoint } from './utils/getEntryPoint.js';
|
|
15
16
|
import { getKernelVersion } from './utils/getKernelVersion.js';
|
|
16
17
|
import { isEVMAuthorizationCapable } from './utils/isEVMAuthorizationCapable.js';
|
|
18
|
+
import { hasSmartAccount } from './utils/hasSmartAccount.js';
|
|
17
19
|
|
|
18
20
|
class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
19
21
|
constructor(opts) {
|
|
@@ -37,9 +39,15 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
37
39
|
},
|
|
38
40
|
name: 'ZeroDev',
|
|
39
41
|
};
|
|
42
|
+
this.hasExistingSmartAccount = false;
|
|
43
|
+
/**
|
|
44
|
+
* Flag for EIP-7702 mode, enabled when EIP-7702 is enabled and no smart account exists
|
|
45
|
+
*/
|
|
46
|
+
this.shouldUseEIP7702Mode = false;
|
|
40
47
|
this._walletUiUtils = opts.walletUiUtils;
|
|
41
48
|
this.providersConfig = (_a = opts.providersConfig) !== null && _a !== void 0 ? _a : {};
|
|
42
|
-
this.
|
|
49
|
+
this.is7702EnabledOnDashboard =
|
|
50
|
+
(_c = (_b = opts.apiProviders.zerodev) === null || _b === void 0 ? void 0 : _b.enableEIP7702) !== null && _c !== void 0 ? _c : false;
|
|
43
51
|
this.entryPoint = getEntryPoint((_d = opts.apiProviders.zerodev) === null || _d === void 0 ? void 0 : _d.entryPointVersion);
|
|
44
52
|
this.kernelVersion = getKernelVersion((_e = opts.apiProviders.zerodev) === null || _e === void 0 ? void 0 : _e.kernelVersion, this.entryPoint);
|
|
45
53
|
this.enableKernelV3Migration =
|
|
@@ -116,17 +124,22 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
116
124
|
});
|
|
117
125
|
}
|
|
118
126
|
initialize(_a) {
|
|
119
|
-
return __awaiter(this, arguments, void 0, function* ({ smartWalletAddress, eoaAddress, eoaConnector, properties, shouldSetEoaConnector, }) {
|
|
127
|
+
return __awaiter(this, arguments, void 0, function* ({ smartWalletAddress, eoaAddress, eoaConnector, properties, shouldSetEoaConnector, verifiedCredentials, }) {
|
|
120
128
|
yield this.registerEoa(Object.assign({ eoaAddress,
|
|
121
129
|
eoaConnector,
|
|
122
130
|
shouldSetEoaConnector,
|
|
123
|
-
smartWalletAddress
|
|
131
|
+
smartWalletAddress,
|
|
132
|
+
verifiedCredentials }, properties));
|
|
124
133
|
});
|
|
125
134
|
}
|
|
126
135
|
registerEoa(_a) {
|
|
127
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
var { smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector = false } = _a, properties = __rest(_a, ["smartWalletAddress", "eoaAddress", "eoaConnector", "shouldSetEoaConnector"]);
|
|
129
|
-
if (
|
|
137
|
+
var { smartWalletAddress, eoaAddress, eoaConnector, verifiedCredentials, shouldSetEoaConnector = false } = _a, properties = __rest(_a, ["smartWalletAddress", "eoaAddress", "eoaConnector", "verifiedCredentials", "shouldSetEoaConnector"]);
|
|
138
|
+
if (!eoaConnector) {
|
|
139
|
+
throw new DynamicError('No EOA connector');
|
|
140
|
+
}
|
|
141
|
+
this.determineSmartAccountStatus(eoaConnector, verifiedCredentials);
|
|
142
|
+
if (this.shouldUseEIP7702Mode) {
|
|
130
143
|
// In EIP-7702, addresses must match
|
|
131
144
|
if (smartWalletAddress !== eoaAddress) {
|
|
132
145
|
throw new Error('In EIP-7702 mode, smart wallet and EOA addresses must be the same');
|
|
@@ -154,6 +167,14 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
154
167
|
}
|
|
155
168
|
});
|
|
156
169
|
}
|
|
170
|
+
determineSmartAccountStatus(eoaConnector, verifiedCredentials) {
|
|
171
|
+
if (getWalletProvider(eoaConnector) !== WalletProviderEnum.EmbeddedWallet) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
this.hasExistingSmartAccount = hasSmartAccount(verifiedCredentials);
|
|
175
|
+
this.shouldUseEIP7702Mode =
|
|
176
|
+
this.is7702EnabledOnDashboard && !this.hasExistingSmartAccount;
|
|
177
|
+
}
|
|
157
178
|
getOrCreateAuthorization() {
|
|
158
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
180
|
var _a;
|
|
@@ -227,7 +248,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
227
248
|
}
|
|
228
249
|
const signer = yield this.eoaConnector.getSigner();
|
|
229
250
|
signer.account = toAccount(eoaAddress);
|
|
230
|
-
if (this.
|
|
251
|
+
if (this.shouldUseEIP7702Mode) {
|
|
231
252
|
this.authorization = yield this.getOrCreateAuthorization();
|
|
232
253
|
}
|
|
233
254
|
yield this.generateProviderMap(signer);
|
|
@@ -305,7 +326,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
305
326
|
const network = this.evmNetworks.find((network) => network.chainId === parseChainId(chainId));
|
|
306
327
|
const publicClientRpc = (_b = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _b === void 0 ? void 0 : _b[0];
|
|
307
328
|
let kernelClient;
|
|
308
|
-
if (this.
|
|
329
|
+
if (this.shouldUseEIP7702Mode) {
|
|
309
330
|
kernelClient = yield createEcdsaKernelAccountClientWith7702({
|
|
310
331
|
authorization,
|
|
311
332
|
bundlerRpc: ZeroDevConnector.bundlerRpc,
|
|
@@ -348,7 +369,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
348
369
|
getAddress() {
|
|
349
370
|
return __awaiter(this, void 0, void 0, function* () {
|
|
350
371
|
var _a, _b, _c;
|
|
351
|
-
if (this.
|
|
372
|
+
if (this.shouldUseEIP7702Mode) {
|
|
352
373
|
return this.eoaAddress;
|
|
353
374
|
}
|
|
354
375
|
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
@@ -569,7 +590,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
569
590
|
}
|
|
570
591
|
validateActiveWallet(expectedAddress) {
|
|
571
592
|
return __awaiter(this, void 0, void 0, function* () {
|
|
572
|
-
if (this.
|
|
593
|
+
if (this.shouldUseEIP7702Mode) {
|
|
573
594
|
const currentAddress = yield this.getAddress();
|
|
574
595
|
if (currentAddress !== expectedAddress) {
|
|
575
596
|
throw new DynamicError('Invalid active wallet');
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const hasSmartAccount = (verifiedCredentials) => {
|
|
7
|
+
const embeddedWallet = verifiedCredentials.find((vc) => vc.walletProvider === 'embeddedWallet' &&
|
|
8
|
+
(vc.walletName === 'dynamicwaas' ||
|
|
9
|
+
vc.walletName === 'turnkey' ||
|
|
10
|
+
vc.walletName === 'turnkeyhd'));
|
|
11
|
+
if (!embeddedWallet)
|
|
12
|
+
return false;
|
|
13
|
+
const hasSmartContractWallet = verifiedCredentials.find((vc) => vc.walletProvider === 'smartContractWallet' &&
|
|
14
|
+
vc.signerRefId === embeddedWallet.id);
|
|
15
|
+
if (!hasSmartContractWallet)
|
|
16
|
+
return false;
|
|
17
|
+
return !hasSmartContractWallet.id.includes('zerodev');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.hasSmartAccount = hasSmartAccount;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const hasSmartAccount = (verifiedCredentials) => {
|
|
3
|
+
const embeddedWallet = verifiedCredentials.find((vc) => vc.walletProvider === 'embeddedWallet' &&
|
|
4
|
+
(vc.walletName === 'dynamicwaas' ||
|
|
5
|
+
vc.walletName === 'turnkey' ||
|
|
6
|
+
vc.walletName === 'turnkeyhd'));
|
|
7
|
+
if (!embeddedWallet)
|
|
8
|
+
return false;
|
|
9
|
+
const hasSmartContractWallet = verifiedCredentials.find((vc) => vc.walletProvider === 'smartContractWallet' &&
|
|
10
|
+
vc.signerRefId === embeddedWallet.id);
|
|
11
|
+
if (!hasSmartContractWallet)
|
|
12
|
+
return false;
|
|
13
|
+
return !hasSmartContractWallet.id.includes('zerodev');
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { hasSmartAccount };
|
package/src/utils/index.d.ts
CHANGED