@dynamic-labs/ethereum-aa 4.61.5 → 4.61.6
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 +7 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- package/src/ZeroDevConnector.cjs +29 -32
- package/src/ZeroDevConnector.d.ts +2 -7
- package/src/ZeroDevConnector.js +31 -34
- package/src/utils/hasSmartAccount.d.ts +1 -1
- package/src/utils/hasSmartAccount.cjs +0 -20
- package/src/utils/hasSmartAccount.js +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.61.6](https://github.com/dynamic-labs/dynamic-auth/compare/v4.61.5...v4.61.6) (2026-02-19)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* support legacy 4337 + 7702 wallet coexistence ([#10459](https://github.com/dynamic-labs/dynamic-auth/issues/10459)) ([a1e1577](https://github.com/dynamic-labs/dynamic-auth/commit/a1e1577c037059c177c6d5b010746a45610c223b))
|
|
8
|
+
|
|
2
9
|
### [4.61.5](https://github.com/dynamic-labs/dynamic-auth/compare/v4.61.4...v4.61.5) (2026-02-19)
|
|
3
10
|
|
|
4
11
|
|
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.61.
|
|
3
|
+
"version": "4.61.6",
|
|
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",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"@zerodev/ecdsa-validator": "5.4.9",
|
|
23
23
|
"@zerodev/multi-chain-ecdsa-validator": "5.4.5",
|
|
24
24
|
"@zerodev/sdk": "5.5.7",
|
|
25
|
-
"@dynamic-labs/assert-package-version": "4.61.
|
|
26
|
-
"@dynamic-labs/ethereum-aa-core": "4.61.
|
|
27
|
-
"@dynamic-labs/ethereum-core": "4.61.
|
|
28
|
-
"@dynamic-labs/logger": "4.61.
|
|
29
|
-
"@dynamic-labs/types": "4.61.
|
|
30
|
-
"@dynamic-labs/utils": "4.61.
|
|
31
|
-
"@dynamic-labs/wallet-book": "4.61.
|
|
32
|
-
"@dynamic-labs/wallet-connector-core": "4.61.
|
|
25
|
+
"@dynamic-labs/assert-package-version": "4.61.6",
|
|
26
|
+
"@dynamic-labs/ethereum-aa-core": "4.61.6",
|
|
27
|
+
"@dynamic-labs/ethereum-core": "4.61.6",
|
|
28
|
+
"@dynamic-labs/logger": "4.61.6",
|
|
29
|
+
"@dynamic-labs/types": "4.61.6",
|
|
30
|
+
"@dynamic-labs/utils": "4.61.6",
|
|
31
|
+
"@dynamic-labs/wallet-book": "4.61.6",
|
|
32
|
+
"@dynamic-labs/wallet-connector-core": "4.61.6"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"viem": "^2.28.4"
|
package/src/ZeroDevConnector.cjs
CHANGED
|
@@ -19,7 +19,6 @@ var createEcdsaKernelAccountClient = require('./utils/createEcdsaKernelAccountCl
|
|
|
19
19
|
var getEcdsaValidator = require('./utils/getEcdsaValidator.cjs');
|
|
20
20
|
var getEntryPoint = require('./utils/getEntryPoint.cjs');
|
|
21
21
|
var getKernelVersion = require('./utils/getKernelVersion.cjs');
|
|
22
|
-
var hasSmartAccount = require('./utils/hasSmartAccount.cjs');
|
|
23
22
|
|
|
24
23
|
class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
25
24
|
constructor(opts) {
|
|
@@ -50,11 +49,6 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
50
49
|
},
|
|
51
50
|
name: 'ZeroDev',
|
|
52
51
|
};
|
|
53
|
-
this.hasExistingSmartAccount = false;
|
|
54
|
-
/**
|
|
55
|
-
* Flag for EIP-7702 mode, enabled when EIP-7702 is enabled and no smart account exists
|
|
56
|
-
*/
|
|
57
|
-
this.shouldUseEIP7702Mode = false;
|
|
58
52
|
// Avoid double-disabling confirmation UI when sendUserOperation is invoked within onSendTransaction
|
|
59
53
|
this.isInOnSendTransactionFlow = false;
|
|
60
54
|
this._walletUiUtils = opts.walletUiUtils;
|
|
@@ -122,6 +116,12 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
122
116
|
var _a;
|
|
123
117
|
return (_a = this.currentNetworkProvider) === null || _a === void 0 ? void 0 : _a.kernelClientWithSponsorship;
|
|
124
118
|
}
|
|
119
|
+
get isActiveWallet7702() {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
if (!this.activeWalletAddress)
|
|
122
|
+
return false;
|
|
123
|
+
return (_b = (_a = this.eoaConnectorMap[this.activeWalletAddress]) === null || _a === void 0 ? void 0 : _a.is7702) !== null && _b !== void 0 ? _b : false;
|
|
124
|
+
}
|
|
125
125
|
supportsNetworkSwitching() {
|
|
126
126
|
if (!this.activeWalletAddress) {
|
|
127
127
|
return false;
|
|
@@ -180,43 +180,36 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
180
180
|
}
|
|
181
181
|
registerEoa(_a) {
|
|
182
182
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
var { smartWalletAddress, eoaAddress, eoaConnector,
|
|
183
|
+
var { smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector = false,
|
|
184
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
185
|
+
verifiedCredentials } = _a, properties = _tslib.__rest(_a, ["smartWalletAddress", "eoaAddress", "eoaConnector", "shouldSetEoaConnector", "verifiedCredentials"]);
|
|
184
186
|
if (!eoaConnector) {
|
|
185
187
|
throw new utils.DynamicError('No EOA connector');
|
|
186
188
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
throw new Error('In EIP-7702 mode, smart wallet and EOA addresses must be the same');
|
|
192
|
-
}
|
|
193
|
-
}
|
|
189
|
+
// Determine per-wallet 7702 mode: address equality is the defining property of EIP-7702
|
|
190
|
+
// (the EOA itself IS the smart wallet). A 4337 wallet always has a different counterfactual address.
|
|
191
|
+
const is7702 = this.is7702EnabledOnDashboard &&
|
|
192
|
+
smartWalletAddress.toLowerCase() === eoaAddress.toLowerCase();
|
|
194
193
|
// Register the EOA connector mapping
|
|
195
194
|
this.eoaConnectorMap[smartWalletAddress] = {
|
|
196
195
|
eoaAddress,
|
|
197
196
|
eoaConnector,
|
|
197
|
+
is7702,
|
|
198
198
|
properties,
|
|
199
199
|
};
|
|
200
200
|
// Always generate providers for all wallets, but only set active state for primary
|
|
201
201
|
yield this.setEoaConnector({
|
|
202
202
|
connector: eoaConnector,
|
|
203
203
|
eoaAddress,
|
|
204
|
+
is7702,
|
|
204
205
|
isPrimary: shouldSetEoaConnector,
|
|
205
206
|
properties,
|
|
206
207
|
smartWalletAddress,
|
|
207
208
|
});
|
|
208
209
|
});
|
|
209
210
|
}
|
|
210
|
-
determineSmartAccountStatus(eoaConnector, verifiedCredentials) {
|
|
211
|
-
if (walletConnectorCore.getWalletProvider(eoaConnector) !== sdkApiCore.WalletProviderEnum.EmbeddedWallet) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
this.hasExistingSmartAccount = hasSmartAccount.hasSmartAccount(verifiedCredentials);
|
|
215
|
-
this.shouldUseEIP7702Mode =
|
|
216
|
-
this.is7702EnabledOnDashboard && !this.hasExistingSmartAccount;
|
|
217
|
-
}
|
|
218
211
|
setEoaConnector(_a) {
|
|
219
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ eoaAddress, connector, properties, smartWalletAddress, isPrimary = true, }) {
|
|
212
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ eoaAddress, connector, is7702 = false, properties, smartWalletAddress, isPrimary = true, }) {
|
|
220
213
|
var _b, _c;
|
|
221
214
|
if (!connector) {
|
|
222
215
|
logger.logger.error('No EOA connector provided');
|
|
@@ -251,7 +244,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
251
244
|
yield connector.getConnectedAccounts();
|
|
252
245
|
}
|
|
253
246
|
const signer = yield connector.getSigner();
|
|
254
|
-
yield this.generateProviderMap(signer, smartWalletAddress);
|
|
247
|
+
yield this.generateProviderMap(signer, smartWalletAddress, is7702);
|
|
255
248
|
this.kernelClientDeferredPromise.resolve();
|
|
256
249
|
});
|
|
257
250
|
}
|
|
@@ -276,14 +269,15 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
276
269
|
* @param signer - The wallet client to use for signing transactions
|
|
277
270
|
* @param walletAddress - The smart wallet address to store the providers under
|
|
278
271
|
*/
|
|
279
|
-
generateProviderMap(
|
|
280
|
-
return _tslib.__awaiter(this,
|
|
272
|
+
generateProviderMap(signer_1, walletAddress_1) {
|
|
273
|
+
return _tslib.__awaiter(this, arguments, void 0, function* (signer, walletAddress, is7702 = false) {
|
|
281
274
|
const chainProviderMap = {};
|
|
282
275
|
yield Promise.all(this.providersFromApi.map((provider) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
283
276
|
const { chain, clientId } = provider;
|
|
284
277
|
const [kernelClient, kernelClientWithSponsorship] = yield Promise.all([
|
|
285
278
|
this.getOrCreateKernelClient({
|
|
286
279
|
chainId: chain,
|
|
280
|
+
is7702,
|
|
287
281
|
paymaster: createEcdsaKernelAccountClient.PaymasterTypeEnum.NONE,
|
|
288
282
|
projectId: clientId,
|
|
289
283
|
signer,
|
|
@@ -291,6 +285,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
291
285
|
}),
|
|
292
286
|
this.getOrCreateKernelClient({
|
|
293
287
|
chainId: chain,
|
|
288
|
+
is7702,
|
|
294
289
|
paymaster: createEcdsaKernelAccountClient.PaymasterTypeEnum.SPONSOR,
|
|
295
290
|
projectId: clientId,
|
|
296
291
|
signer,
|
|
@@ -315,7 +310,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
315
310
|
});
|
|
316
311
|
}
|
|
317
312
|
createKernelClient(_a) {
|
|
318
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ chainId, projectId, signer, paymaster, paymasterRpcOverride, bundlerRpcOverride, }) {
|
|
313
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ chainId, is7702 = false, projectId, signer, paymaster, paymasterRpcOverride, bundlerRpcOverride, }) {
|
|
319
314
|
if (!signer)
|
|
320
315
|
throw new utils.DynamicError('No signer provided');
|
|
321
316
|
const chain = ethereumCore.chainsMap[chainId];
|
|
@@ -334,7 +329,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
334
329
|
publicClientRpc: this.getPublicRpcForChain(chainId),
|
|
335
330
|
signer,
|
|
336
331
|
};
|
|
337
|
-
if (
|
|
332
|
+
if (is7702) {
|
|
338
333
|
kernelClient = yield createEcdsaKernelAccountClient.createEcdsaKernelAccountClientWith7702(Object.assign(Object.assign({}, params), { kernelVersion: constants$1.KERNEL_V3_3 }));
|
|
339
334
|
}
|
|
340
335
|
else {
|
|
@@ -350,7 +345,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
350
345
|
});
|
|
351
346
|
}
|
|
352
347
|
getOrCreateKernelClient(_a) {
|
|
353
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ chainId, projectId, signer, paymaster, walletAddress, }) {
|
|
348
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ chainId, is7702 = false, projectId, signer, paymaster, walletAddress, }) {
|
|
354
349
|
const walletProviders = this.providerMap[walletAddress];
|
|
355
350
|
if (chainId &&
|
|
356
351
|
(walletProviders === null || walletProviders === void 0 ? void 0 : walletProviders[chainId]) &&
|
|
@@ -361,6 +356,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
361
356
|
}
|
|
362
357
|
return this.createKernelClient({
|
|
363
358
|
chainId,
|
|
359
|
+
is7702,
|
|
364
360
|
paymaster,
|
|
365
361
|
projectId,
|
|
366
362
|
signer,
|
|
@@ -370,7 +366,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
370
366
|
getAddress() {
|
|
371
367
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
372
368
|
var _a, _b, _c;
|
|
373
|
-
if (this.
|
|
369
|
+
if (this.isActiveWallet7702) {
|
|
374
370
|
return this.eoaAddress;
|
|
375
371
|
}
|
|
376
372
|
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
@@ -738,7 +734,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
738
734
|
if (!this.kernelClient) {
|
|
739
735
|
throw new utils.DynamicError('Error fetching signer');
|
|
740
736
|
}
|
|
741
|
-
if (!this.
|
|
737
|
+
if (!this.isActiveWallet7702) {
|
|
742
738
|
return this.kernelClient.signMessage({ message: messageToSign });
|
|
743
739
|
}
|
|
744
740
|
const isDeployed = yield ((_a = this.kernelClient.account) === null || _a === void 0 ? void 0 : _a.isDeployed());
|
|
@@ -760,7 +756,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
760
756
|
if (!eoa) {
|
|
761
757
|
throw new utils.DynamicError('No EOA connector');
|
|
762
758
|
}
|
|
763
|
-
const { eoaAddress, eoaConnector, properties } = eoa;
|
|
759
|
+
const { eoaAddress, eoaConnector, is7702, properties } = eoa;
|
|
764
760
|
// Validate the underlying EOA connector
|
|
765
761
|
yield eoaConnector.validateActiveWallet(eoaAddress);
|
|
766
762
|
// Check if we have providers for this wallet with the correct kernel account address
|
|
@@ -785,6 +781,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
785
781
|
yield this.setEoaConnector({
|
|
786
782
|
connector: eoaConnector,
|
|
787
783
|
eoaAddress,
|
|
784
|
+
is7702,
|
|
788
785
|
properties,
|
|
789
786
|
smartWalletAddress: expectedAddress,
|
|
790
787
|
});
|
|
@@ -58,11 +58,6 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
|
|
|
58
58
|
name: string;
|
|
59
59
|
};
|
|
60
60
|
is7702EnabledOnDashboard: boolean;
|
|
61
|
-
private hasExistingSmartAccount;
|
|
62
|
-
/**
|
|
63
|
-
* Flag for EIP-7702 mode, enabled when EIP-7702 is enabled and no smart account exists
|
|
64
|
-
*/
|
|
65
|
-
private shouldUseEIP7702Mode;
|
|
66
61
|
private isInOnSendTransactionFlow;
|
|
67
62
|
constructor(opts: ZeroDevConnectorProps);
|
|
68
63
|
confirmTransactionStatus(): Promise<TransactionReceipt>;
|
|
@@ -74,6 +69,7 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
|
|
|
74
69
|
get lastUsedChainId(): string;
|
|
75
70
|
get kernelClient(): KernelClient | undefined;
|
|
76
71
|
get kernelClientWithSponsorship(): KernelClient | undefined;
|
|
72
|
+
private get isActiveWallet7702();
|
|
77
73
|
supportsNetworkSwitching(): boolean;
|
|
78
74
|
private getPublicRpcForChain;
|
|
79
75
|
switchNetwork({ networkChainId, }: {
|
|
@@ -91,7 +87,7 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
|
|
|
91
87
|
properties?: SmartWalletProperties;
|
|
92
88
|
verifiedCredentials: JwtVerifiedCredential[];
|
|
93
89
|
}): Promise<void>;
|
|
94
|
-
registerEoa({ smartWalletAddress, eoaAddress, eoaConnector,
|
|
90
|
+
registerEoa({ smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector, verifiedCredentials, ...properties }: {
|
|
95
91
|
smartWalletAddress: string;
|
|
96
92
|
eoaAddress: string;
|
|
97
93
|
eoaConnector: InternalWalletConnector;
|
|
@@ -101,7 +97,6 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
|
|
|
101
97
|
kernelVersion?: ProviderKernelVersionEnum;
|
|
102
98
|
entryPointVersion?: ProviderEntryPointVersionEnum;
|
|
103
99
|
}): Promise<void>;
|
|
104
|
-
private determineSmartAccountStatus;
|
|
105
100
|
private setEoaConnector;
|
|
106
101
|
private warnIfProjectChainNotEnabled;
|
|
107
102
|
/**
|
package/src/ZeroDevConnector.js
CHANGED
|
@@ -6,16 +6,15 @@ import { getUserOperationHash } from 'viem/account-abstraction';
|
|
|
6
6
|
import { toAccount } from 'viem/accounts';
|
|
7
7
|
import { AccountAbstractionBaseConnector } from '@dynamic-labs/ethereum-aa-core';
|
|
8
8
|
import { EthereumWallet, isEthWalletConnector, chainsMap, confirmationTransport, unFormatTransaction, interceptTransport } from '@dynamic-labs/ethereum-core';
|
|
9
|
-
import { ZerodevBundlerProvider
|
|
9
|
+
import { ZerodevBundlerProvider } from '@dynamic-labs/sdk-api-core';
|
|
10
10
|
import { parseEvmNetworks, StorageService, DynamicError, DeferredPromise, parseChainId, wrapMethodWithCallback, TransactionGasCannotBeSponsoredError, InsufficientFundsError } from '@dynamic-labs/utils';
|
|
11
|
-
import { eventListenerHandlers,
|
|
11
|
+
import { eventListenerHandlers, isDynamicWaasConnector, isTurnkeyWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
12
12
|
import { ZERO_DEV_LAST_USED_CHAIN_ID_KEY } from './constants.js';
|
|
13
13
|
import { logger } from './utils/logger.js';
|
|
14
14
|
import { PaymasterTypeEnum, createEcdsaKernelAccountClientWith7702, createEcdsaKernelAccountClient } from './utils/createEcdsaKernelAccountClient.js';
|
|
15
15
|
import { getEcdsaValidator } from './utils/getEcdsaValidator.js';
|
|
16
16
|
import { getEntryPoint } from './utils/getEntryPoint.js';
|
|
17
17
|
import { getKernelVersion } from './utils/getKernelVersion.js';
|
|
18
|
-
import { hasSmartAccount } from './utils/hasSmartAccount.js';
|
|
19
18
|
|
|
20
19
|
class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
21
20
|
constructor(opts) {
|
|
@@ -46,11 +45,6 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
46
45
|
},
|
|
47
46
|
name: 'ZeroDev',
|
|
48
47
|
};
|
|
49
|
-
this.hasExistingSmartAccount = false;
|
|
50
|
-
/**
|
|
51
|
-
* Flag for EIP-7702 mode, enabled when EIP-7702 is enabled and no smart account exists
|
|
52
|
-
*/
|
|
53
|
-
this.shouldUseEIP7702Mode = false;
|
|
54
48
|
// Avoid double-disabling confirmation UI when sendUserOperation is invoked within onSendTransaction
|
|
55
49
|
this.isInOnSendTransactionFlow = false;
|
|
56
50
|
this._walletUiUtils = opts.walletUiUtils;
|
|
@@ -118,6 +112,12 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
118
112
|
var _a;
|
|
119
113
|
return (_a = this.currentNetworkProvider) === null || _a === void 0 ? void 0 : _a.kernelClientWithSponsorship;
|
|
120
114
|
}
|
|
115
|
+
get isActiveWallet7702() {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
if (!this.activeWalletAddress)
|
|
118
|
+
return false;
|
|
119
|
+
return (_b = (_a = this.eoaConnectorMap[this.activeWalletAddress]) === null || _a === void 0 ? void 0 : _a.is7702) !== null && _b !== void 0 ? _b : false;
|
|
120
|
+
}
|
|
121
121
|
supportsNetworkSwitching() {
|
|
122
122
|
if (!this.activeWalletAddress) {
|
|
123
123
|
return false;
|
|
@@ -176,43 +176,36 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
176
176
|
}
|
|
177
177
|
registerEoa(_a) {
|
|
178
178
|
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
-
var { smartWalletAddress, eoaAddress, eoaConnector,
|
|
179
|
+
var { smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector = false,
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
181
|
+
verifiedCredentials } = _a, properties = __rest(_a, ["smartWalletAddress", "eoaAddress", "eoaConnector", "shouldSetEoaConnector", "verifiedCredentials"]);
|
|
180
182
|
if (!eoaConnector) {
|
|
181
183
|
throw new DynamicError('No EOA connector');
|
|
182
184
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
throw new Error('In EIP-7702 mode, smart wallet and EOA addresses must be the same');
|
|
188
|
-
}
|
|
189
|
-
}
|
|
185
|
+
// Determine per-wallet 7702 mode: address equality is the defining property of EIP-7702
|
|
186
|
+
// (the EOA itself IS the smart wallet). A 4337 wallet always has a different counterfactual address.
|
|
187
|
+
const is7702 = this.is7702EnabledOnDashboard &&
|
|
188
|
+
smartWalletAddress.toLowerCase() === eoaAddress.toLowerCase();
|
|
190
189
|
// Register the EOA connector mapping
|
|
191
190
|
this.eoaConnectorMap[smartWalletAddress] = {
|
|
192
191
|
eoaAddress,
|
|
193
192
|
eoaConnector,
|
|
193
|
+
is7702,
|
|
194
194
|
properties,
|
|
195
195
|
};
|
|
196
196
|
// Always generate providers for all wallets, but only set active state for primary
|
|
197
197
|
yield this.setEoaConnector({
|
|
198
198
|
connector: eoaConnector,
|
|
199
199
|
eoaAddress,
|
|
200
|
+
is7702,
|
|
200
201
|
isPrimary: shouldSetEoaConnector,
|
|
201
202
|
properties,
|
|
202
203
|
smartWalletAddress,
|
|
203
204
|
});
|
|
204
205
|
});
|
|
205
206
|
}
|
|
206
|
-
determineSmartAccountStatus(eoaConnector, verifiedCredentials) {
|
|
207
|
-
if (getWalletProvider(eoaConnector) !== WalletProviderEnum.EmbeddedWallet) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
this.hasExistingSmartAccount = hasSmartAccount(verifiedCredentials);
|
|
211
|
-
this.shouldUseEIP7702Mode =
|
|
212
|
-
this.is7702EnabledOnDashboard && !this.hasExistingSmartAccount;
|
|
213
|
-
}
|
|
214
207
|
setEoaConnector(_a) {
|
|
215
|
-
return __awaiter(this, arguments, void 0, function* ({ eoaAddress, connector, properties, smartWalletAddress, isPrimary = true, }) {
|
|
208
|
+
return __awaiter(this, arguments, void 0, function* ({ eoaAddress, connector, is7702 = false, properties, smartWalletAddress, isPrimary = true, }) {
|
|
216
209
|
var _b, _c;
|
|
217
210
|
if (!connector) {
|
|
218
211
|
logger.error('No EOA connector provided');
|
|
@@ -247,7 +240,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
247
240
|
yield connector.getConnectedAccounts();
|
|
248
241
|
}
|
|
249
242
|
const signer = yield connector.getSigner();
|
|
250
|
-
yield this.generateProviderMap(signer, smartWalletAddress);
|
|
243
|
+
yield this.generateProviderMap(signer, smartWalletAddress, is7702);
|
|
251
244
|
this.kernelClientDeferredPromise.resolve();
|
|
252
245
|
});
|
|
253
246
|
}
|
|
@@ -272,14 +265,15 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
272
265
|
* @param signer - The wallet client to use for signing transactions
|
|
273
266
|
* @param walletAddress - The smart wallet address to store the providers under
|
|
274
267
|
*/
|
|
275
|
-
generateProviderMap(
|
|
276
|
-
return __awaiter(this,
|
|
268
|
+
generateProviderMap(signer_1, walletAddress_1) {
|
|
269
|
+
return __awaiter(this, arguments, void 0, function* (signer, walletAddress, is7702 = false) {
|
|
277
270
|
const chainProviderMap = {};
|
|
278
271
|
yield Promise.all(this.providersFromApi.map((provider) => __awaiter(this, void 0, void 0, function* () {
|
|
279
272
|
const { chain, clientId } = provider;
|
|
280
273
|
const [kernelClient, kernelClientWithSponsorship] = yield Promise.all([
|
|
281
274
|
this.getOrCreateKernelClient({
|
|
282
275
|
chainId: chain,
|
|
276
|
+
is7702,
|
|
283
277
|
paymaster: PaymasterTypeEnum.NONE,
|
|
284
278
|
projectId: clientId,
|
|
285
279
|
signer,
|
|
@@ -287,6 +281,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
287
281
|
}),
|
|
288
282
|
this.getOrCreateKernelClient({
|
|
289
283
|
chainId: chain,
|
|
284
|
+
is7702,
|
|
290
285
|
paymaster: PaymasterTypeEnum.SPONSOR,
|
|
291
286
|
projectId: clientId,
|
|
292
287
|
signer,
|
|
@@ -311,7 +306,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
311
306
|
});
|
|
312
307
|
}
|
|
313
308
|
createKernelClient(_a) {
|
|
314
|
-
return __awaiter(this, arguments, void 0, function* ({ chainId, projectId, signer, paymaster, paymasterRpcOverride, bundlerRpcOverride, }) {
|
|
309
|
+
return __awaiter(this, arguments, void 0, function* ({ chainId, is7702 = false, projectId, signer, paymaster, paymasterRpcOverride, bundlerRpcOverride, }) {
|
|
315
310
|
if (!signer)
|
|
316
311
|
throw new DynamicError('No signer provided');
|
|
317
312
|
const chain = chainsMap[chainId];
|
|
@@ -330,7 +325,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
330
325
|
publicClientRpc: this.getPublicRpcForChain(chainId),
|
|
331
326
|
signer,
|
|
332
327
|
};
|
|
333
|
-
if (
|
|
328
|
+
if (is7702) {
|
|
334
329
|
kernelClient = yield createEcdsaKernelAccountClientWith7702(Object.assign(Object.assign({}, params), { kernelVersion: KERNEL_V3_3 }));
|
|
335
330
|
}
|
|
336
331
|
else {
|
|
@@ -346,7 +341,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
346
341
|
});
|
|
347
342
|
}
|
|
348
343
|
getOrCreateKernelClient(_a) {
|
|
349
|
-
return __awaiter(this, arguments, void 0, function* ({ chainId, projectId, signer, paymaster, walletAddress, }) {
|
|
344
|
+
return __awaiter(this, arguments, void 0, function* ({ chainId, is7702 = false, projectId, signer, paymaster, walletAddress, }) {
|
|
350
345
|
const walletProviders = this.providerMap[walletAddress];
|
|
351
346
|
if (chainId &&
|
|
352
347
|
(walletProviders === null || walletProviders === void 0 ? void 0 : walletProviders[chainId]) &&
|
|
@@ -357,6 +352,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
357
352
|
}
|
|
358
353
|
return this.createKernelClient({
|
|
359
354
|
chainId,
|
|
355
|
+
is7702,
|
|
360
356
|
paymaster,
|
|
361
357
|
projectId,
|
|
362
358
|
signer,
|
|
@@ -366,7 +362,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
366
362
|
getAddress() {
|
|
367
363
|
return __awaiter(this, void 0, void 0, function* () {
|
|
368
364
|
var _a, _b, _c;
|
|
369
|
-
if (this.
|
|
365
|
+
if (this.isActiveWallet7702) {
|
|
370
366
|
return this.eoaAddress;
|
|
371
367
|
}
|
|
372
368
|
yield ((_a = this.kernelClientDeferredPromise) === null || _a === void 0 ? void 0 : _a.promise);
|
|
@@ -734,7 +730,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
734
730
|
if (!this.kernelClient) {
|
|
735
731
|
throw new DynamicError('Error fetching signer');
|
|
736
732
|
}
|
|
737
|
-
if (!this.
|
|
733
|
+
if (!this.isActiveWallet7702) {
|
|
738
734
|
return this.kernelClient.signMessage({ message: messageToSign });
|
|
739
735
|
}
|
|
740
736
|
const isDeployed = yield ((_a = this.kernelClient.account) === null || _a === void 0 ? void 0 : _a.isDeployed());
|
|
@@ -756,7 +752,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
756
752
|
if (!eoa) {
|
|
757
753
|
throw new DynamicError('No EOA connector');
|
|
758
754
|
}
|
|
759
|
-
const { eoaAddress, eoaConnector, properties } = eoa;
|
|
755
|
+
const { eoaAddress, eoaConnector, is7702, properties } = eoa;
|
|
760
756
|
// Validate the underlying EOA connector
|
|
761
757
|
yield eoaConnector.validateActiveWallet(eoaAddress);
|
|
762
758
|
// Check if we have providers for this wallet with the correct kernel account address
|
|
@@ -781,6 +777,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
781
777
|
yield this.setEoaConnector({
|
|
782
778
|
connector: eoaConnector,
|
|
783
779
|
eoaAddress,
|
|
780
|
+
is7702,
|
|
784
781
|
properties,
|
|
785
782
|
smartWalletAddress: expectedAddress,
|
|
786
783
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
|
|
2
|
-
export declare const hasSmartAccount: (verifiedCredentials: JwtVerifiedCredential[]) => boolean;
|
|
2
|
+
export declare const hasSmartAccount: (verifiedCredentials: readonly JwtVerifiedCredential[]) => boolean;
|
|
@@ -1,20 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
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 };
|