@dynamic-labs/ethereum-aa 4.64.0 → 4.66.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 +29 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- package/src/ZeroDevConnector.cjs +73 -3
- package/src/ZeroDevConnector.d.ts +13 -0
- package/src/ZeroDevConnector.js +73 -3
- package/src/index.cjs +2 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +1 -0
- package/src/utils/createEcdsaKernelAccountClient.cjs +2 -1
- package/src/utils/createEcdsaKernelAccountClient.d.ts +4 -1
- package/src/utils/createEcdsaKernelAccountClient.js +2 -1
- package/src/utils/index.d.ts +1 -0
- package/src/utils/signEip7702Authorization/index.d.ts +1 -0
- package/src/utils/signEip7702Authorization/signEip7702Authorization.cjs +29 -0
- package/src/utils/signEip7702Authorization/signEip7702Authorization.d.ts +20 -0
- package/src/utils/signEip7702Authorization/signEip7702Authorization.js +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.66.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.65.0...v4.66.0) (2026-03-02)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **stellar:** send serialized XDR for transaction signing ([#10548](https://github.com/dynamic-labs/dynamic-auth/issues/10548)) ([3ff6438](https://github.com/dynamic-labs/dynamic-auth/commit/3ff64384e16d5fdb32cd6a3fd144757bf05f4456))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* prevent MFA backup codes screen from being dismissed before acknowledgement ([#10530](https://github.com/dynamic-labs/dynamic-auth/issues/10530)) ([67086f0](https://github.com/dynamic-labs/dynamic-auth/commit/67086f0b4a1302d39853eb2eedcb6f5b8bfca889))
|
|
13
|
+
* **react-native:** add retry when setting items to secure store ([#10576](https://github.com/dynamic-labs/dynamic-auth/issues/10576)) ([22ea162](https://github.com/dynamic-labs/dynamic-auth/commit/22ea162420806a4a67394c99f3691754982a7f1f))
|
|
14
|
+
|
|
15
|
+
## [4.65.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.64.0...v4.65.0) (2026-02-27)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add CSP nonce support for style and link tags ([#10514](https://github.com/dynamic-labs/dynamic-auth/issues/10514)) ([62128f5](https://github.com/dynamic-labs/dynamic-auth/commit/62128f5eddfd2a037c2ed6e9320b5009d350c0b5))
|
|
21
|
+
* add setPassword method for initial wallet password setup ([#10534](https://github.com/dynamic-labs/dynamic-auth/issues/10534)) ([87d1e5f](https://github.com/dynamic-labs/dynamic-auth/commit/87d1e5f3c41fe4417320f6971566526e8bf07e99))
|
|
22
|
+
* add step-up authentication and walletsVerify API ([#10482](https://github.com/dynamic-labs/dynamic-auth/issues/10482)) ([e762a63](https://github.com/dynamic-labs/dynamic-auth/commit/e762a634e9782c34926f5947db5446ad95617064))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **react-native:** ensure items are saved to storage successfully ([#10538](https://github.com/dynamic-labs/dynamic-auth/issues/10538)) ([60bfd5e](https://github.com/dynamic-labs/dynamic-auth/commit/60bfd5e4bf1e7265e754c222839662ff615495b2))
|
|
28
|
+
* **sdk-react-core:** add stellar to compareChains to prevent duplicate wallet creation ([#10526](https://github.com/dynamic-labs/dynamic-auth/issues/10526)) ([89f4498](https://github.com/dynamic-labs/dynamic-auth/commit/89f449892a5153dc8032e0e8ea61cf453e0a2b23))
|
|
29
|
+
* show password setup button for all WaaS wallets regardless of passcodeRequired ([#10532](https://github.com/dynamic-labs/dynamic-auth/issues/10532)) ([615cbf2](https://github.com/dynamic-labs/dynamic-auth/commit/615cbf25fcf95cb5b82a118a2d5d37285e8b5b83))
|
|
30
|
+
|
|
2
31
|
## [4.64.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.63.1...v4.64.0) (2026-02-25)
|
|
3
32
|
|
|
4
33
|
|
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.66.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",
|
|
@@ -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.
|
|
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.
|
|
25
|
+
"@dynamic-labs/assert-package-version": "4.66.0",
|
|
26
|
+
"@dynamic-labs/ethereum-aa-core": "4.66.0",
|
|
27
|
+
"@dynamic-labs/ethereum-core": "4.66.0",
|
|
28
|
+
"@dynamic-labs/logger": "4.66.0",
|
|
29
|
+
"@dynamic-labs/types": "4.66.0",
|
|
30
|
+
"@dynamic-labs/utils": "4.66.0",
|
|
31
|
+
"@dynamic-labs/wallet-book": "4.66.0",
|
|
32
|
+
"@dynamic-labs/wallet-connector-core": "4.66.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"viem": "^2.28.4"
|
package/src/ZeroDevConnector.cjs
CHANGED
|
@@ -19,6 +19,7 @@ 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 signEip7702Authorization = require('./utils/signEip7702Authorization/signEip7702Authorization.cjs');
|
|
22
23
|
|
|
23
24
|
class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
24
25
|
constructor(opts) {
|
|
@@ -208,6 +209,69 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
208
209
|
});
|
|
209
210
|
});
|
|
210
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Signs an EIP-7702 authorization for ZeroDev kernel delegation.
|
|
214
|
+
* Validates that the EOA connector supports authorization signing, resolves
|
|
215
|
+
* the chain ID, and delegates to signEip7702Authorization.
|
|
216
|
+
*/
|
|
217
|
+
signEip7702PreAuth(chainId) {
|
|
218
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
219
|
+
var _a, _b;
|
|
220
|
+
const { eoaConnector } = this;
|
|
221
|
+
if (!eoaConnector) {
|
|
222
|
+
throw new utils.DynamicError('The wallet connector must be an EVM wallet connector to sign EIP-7702 authorizations.');
|
|
223
|
+
}
|
|
224
|
+
if (!ethereumCore.isEthWalletConnector(eoaConnector)) {
|
|
225
|
+
throw new utils.DynamicError('The wallet connector must be an EVM wallet connector to sign EIP-7702 authorizations.');
|
|
226
|
+
}
|
|
227
|
+
if (!((_a = eoaConnector.isSignAuthorizationSupported) === null || _a === void 0 ? void 0 : _a.call(eoaConnector))) {
|
|
228
|
+
throw new utils.DynamicError(`The wallet connector (${eoaConnector.key}) does not support EIP-7702 authorization signing. Only embedded wallets (Turnkey, WaaS) support this feature.`);
|
|
229
|
+
}
|
|
230
|
+
let resolvedChainId = chainId;
|
|
231
|
+
if (!resolvedChainId) {
|
|
232
|
+
const networkId = yield ((_b = this.getNetwork) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
233
|
+
if (networkId) {
|
|
234
|
+
resolvedChainId = Number(networkId);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (!resolvedChainId) {
|
|
238
|
+
throw new utils.DynamicError('Chain ID is required but could not be determined from the wallet. Please provide a chainId parameter.');
|
|
239
|
+
}
|
|
240
|
+
const walletClient = eoaConnector.getWalletClient(String(resolvedChainId));
|
|
241
|
+
if (!walletClient) {
|
|
242
|
+
throw new utils.DynamicError(`Failed to get wallet client for chain ID ${resolvedChainId}. Ensure the wallet is connected to the correct network.`);
|
|
243
|
+
}
|
|
244
|
+
return signEip7702Authorization.signEip7702Authorization({
|
|
245
|
+
chainId: resolvedChainId,
|
|
246
|
+
signer: walletClient,
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Stores a pre-signed EIP-7702 authorization and recreates the kernel client
|
|
252
|
+
* to inject it. Call this after signing with useSignEip7702Authorization.
|
|
253
|
+
*/
|
|
254
|
+
setEip7702Auth(auth) {
|
|
255
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
256
|
+
const walletAddress = this.activeWalletAddress;
|
|
257
|
+
if (!walletAddress) {
|
|
258
|
+
throw new utils.DynamicError('No active wallet');
|
|
259
|
+
}
|
|
260
|
+
const walletInfo = this.eoaConnectorMap[walletAddress];
|
|
261
|
+
if (!(walletInfo === null || walletInfo === void 0 ? void 0 : walletInfo.is7702)) {
|
|
262
|
+
throw new utils.DynamicError('Active wallet is not an EIP-7702 wallet');
|
|
263
|
+
}
|
|
264
|
+
this.pendingEip7702Auth = auth;
|
|
265
|
+
// Clear the cached kernel clients so they get recreated with the new auth
|
|
266
|
+
delete this.providerMap[walletAddress];
|
|
267
|
+
const { eoaConnector, eoaAddress } = walletInfo;
|
|
268
|
+
if (walletConnectorCore.isDynamicWaasConnector(eoaConnector)) {
|
|
269
|
+
yield eoaConnector.validateActiveWallet(eoaAddress);
|
|
270
|
+
}
|
|
271
|
+
const signer = yield eoaConnector.getSigner();
|
|
272
|
+
yield this.generateProviderMap(signer, walletAddress, true);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
211
275
|
setEoaConnector(_a) {
|
|
212
276
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ eoaAddress, connector, is7702 = false, properties, smartWalletAddress, isPrimary = true, }) {
|
|
213
277
|
var _b, _c;
|
|
@@ -272,11 +336,14 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
272
336
|
generateProviderMap(signer_1, walletAddress_1) {
|
|
273
337
|
return _tslib.__awaiter(this, arguments, void 0, function* (signer, walletAddress, is7702 = false) {
|
|
274
338
|
const chainProviderMap = {};
|
|
339
|
+
// Capture once before concurrent creates so all calls share the same auth
|
|
340
|
+
const eip7702Auth = this.pendingEip7702Auth;
|
|
275
341
|
yield Promise.all(this.providersFromApi.map((provider) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
276
342
|
const { chain, clientId } = provider;
|
|
277
343
|
const [kernelClient, kernelClientWithSponsorship] = yield Promise.all([
|
|
278
344
|
this.getOrCreateKernelClient({
|
|
279
345
|
chainId: chain,
|
|
346
|
+
eip7702Auth,
|
|
280
347
|
is7702,
|
|
281
348
|
paymaster: createEcdsaKernelAccountClient.PaymasterTypeEnum.NONE,
|
|
282
349
|
projectId: clientId,
|
|
@@ -285,6 +352,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
285
352
|
}),
|
|
286
353
|
this.getOrCreateKernelClient({
|
|
287
354
|
chainId: chain,
|
|
355
|
+
eip7702Auth,
|
|
288
356
|
is7702,
|
|
289
357
|
paymaster: createEcdsaKernelAccountClient.PaymasterTypeEnum.SPONSOR,
|
|
290
358
|
projectId: clientId,
|
|
@@ -299,6 +367,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
299
367
|
};
|
|
300
368
|
yield this.warnIfProjectChainNotEnabled(utils.parseChainId(chain));
|
|
301
369
|
})));
|
|
370
|
+
this.pendingEip7702Auth = undefined;
|
|
302
371
|
// Filter out duplicate chains and store under the wallet address
|
|
303
372
|
const uniqueChainProviderMap = Object.entries(chainProviderMap).reduce((acc, [chain, providers]) => {
|
|
304
373
|
if (!acc[chain]) {
|
|
@@ -310,7 +379,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
310
379
|
});
|
|
311
380
|
}
|
|
312
381
|
createKernelClient(_a) {
|
|
313
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ chainId, is7702 = false, projectId, signer, paymaster, paymasterRpcOverride, bundlerRpcOverride, }) {
|
|
382
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ chainId, eip7702Auth, is7702 = false, projectId, signer, paymaster, paymasterRpcOverride, bundlerRpcOverride, }) {
|
|
314
383
|
if (!signer)
|
|
315
384
|
throw new utils.DynamicError('No signer provided');
|
|
316
385
|
const chain = ethereumCore.chainsMap[chainId];
|
|
@@ -330,7 +399,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
330
399
|
signer,
|
|
331
400
|
};
|
|
332
401
|
if (is7702) {
|
|
333
|
-
kernelClient = yield createEcdsaKernelAccountClient.createEcdsaKernelAccountClientWith7702(Object.assign(Object.assign({}, params), { kernelVersion: constants$1.KERNEL_V3_3 }));
|
|
402
|
+
kernelClient = yield createEcdsaKernelAccountClient.createEcdsaKernelAccountClientWith7702(Object.assign(Object.assign({}, params), { eip7702Auth, kernelVersion: constants$1.KERNEL_V3_3 }));
|
|
334
403
|
}
|
|
335
404
|
else {
|
|
336
405
|
kernelClient = yield createEcdsaKernelAccountClient.createEcdsaKernelAccountClient(Object.assign(Object.assign({}, params), { ecdsaValidator: getEcdsaValidator.getEcdsaValidator(this.ecdsaProviderType) }));
|
|
@@ -345,7 +414,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
345
414
|
});
|
|
346
415
|
}
|
|
347
416
|
getOrCreateKernelClient(_a) {
|
|
348
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ chainId, is7702 = false, projectId, signer, paymaster, walletAddress, }) {
|
|
417
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ chainId, eip7702Auth, is7702 = false, projectId, signer, paymaster, walletAddress, }) {
|
|
349
418
|
const walletProviders = this.providerMap[walletAddress];
|
|
350
419
|
if (chainId &&
|
|
351
420
|
(walletProviders === null || walletProviders === void 0 ? void 0 : walletProviders[chainId]) &&
|
|
@@ -356,6 +425,7 @@ class ZeroDevConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
356
425
|
}
|
|
357
426
|
return this.createKernelClient({
|
|
358
427
|
chainId,
|
|
428
|
+
eip7702Auth,
|
|
359
429
|
is7702,
|
|
360
430
|
paymaster,
|
|
361
431
|
projectId,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EntryPointType, KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';
|
|
2
2
|
import { Account, PublicClient, Transport, WalletClient } from 'viem';
|
|
3
3
|
import { EntryPointVersion } from 'viem/account-abstraction';
|
|
4
|
+
import { SignAuthorizationReturnType } from 'viem/accounts';
|
|
4
5
|
import { type Chain as ViemChain } from 'viem/chains';
|
|
5
6
|
import { AccountAbstractionBaseConnector } from '@dynamic-labs/ethereum-aa-core';
|
|
6
7
|
import { EthereumWallet, RegisterEvmProvidersConfig } from '@dynamic-labs/ethereum-core';
|
|
@@ -14,6 +15,7 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
|
|
|
14
15
|
eoaAddress: string | undefined;
|
|
15
16
|
private activeWalletAddress;
|
|
16
17
|
private providerMap;
|
|
18
|
+
private pendingEip7702Auth;
|
|
17
19
|
private eoaConnectorMap;
|
|
18
20
|
ChainWallet: typeof EthereumWallet;
|
|
19
21
|
connectedChain: Chain;
|
|
@@ -97,6 +99,17 @@ export declare class ZeroDevConnector extends AccountAbstractionBaseConnector im
|
|
|
97
99
|
kernelVersion?: ProviderKernelVersionEnum;
|
|
98
100
|
entryPointVersion?: ProviderEntryPointVersionEnum;
|
|
99
101
|
}): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Signs an EIP-7702 authorization for ZeroDev kernel delegation.
|
|
104
|
+
* Validates that the EOA connector supports authorization signing, resolves
|
|
105
|
+
* the chain ID, and delegates to signEip7702Authorization.
|
|
106
|
+
*/
|
|
107
|
+
signEip7702PreAuth(chainId?: number): Promise<SignAuthorizationReturnType>;
|
|
108
|
+
/**
|
|
109
|
+
* Stores a pre-signed EIP-7702 authorization and recreates the kernel client
|
|
110
|
+
* to inject it. Call this after signing with useSignEip7702Authorization.
|
|
111
|
+
*/
|
|
112
|
+
setEip7702Auth(auth: SignAuthorizationReturnType): Promise<void>;
|
|
100
113
|
private setEoaConnector;
|
|
101
114
|
private warnIfProjectChainNotEnabled;
|
|
102
115
|
/**
|
package/src/ZeroDevConnector.js
CHANGED
|
@@ -15,6 +15,7 @@ import { PaymasterTypeEnum, createEcdsaKernelAccountClientWith7702, createEcdsaK
|
|
|
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 { signEip7702Authorization } from './utils/signEip7702Authorization/signEip7702Authorization.js';
|
|
18
19
|
|
|
19
20
|
class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
20
21
|
constructor(opts) {
|
|
@@ -204,6 +205,69 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
204
205
|
});
|
|
205
206
|
});
|
|
206
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Signs an EIP-7702 authorization for ZeroDev kernel delegation.
|
|
210
|
+
* Validates that the EOA connector supports authorization signing, resolves
|
|
211
|
+
* the chain ID, and delegates to signEip7702Authorization.
|
|
212
|
+
*/
|
|
213
|
+
signEip7702PreAuth(chainId) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
var _a, _b;
|
|
216
|
+
const { eoaConnector } = this;
|
|
217
|
+
if (!eoaConnector) {
|
|
218
|
+
throw new DynamicError('The wallet connector must be an EVM wallet connector to sign EIP-7702 authorizations.');
|
|
219
|
+
}
|
|
220
|
+
if (!isEthWalletConnector(eoaConnector)) {
|
|
221
|
+
throw new DynamicError('The wallet connector must be an EVM wallet connector to sign EIP-7702 authorizations.');
|
|
222
|
+
}
|
|
223
|
+
if (!((_a = eoaConnector.isSignAuthorizationSupported) === null || _a === void 0 ? void 0 : _a.call(eoaConnector))) {
|
|
224
|
+
throw new DynamicError(`The wallet connector (${eoaConnector.key}) does not support EIP-7702 authorization signing. Only embedded wallets (Turnkey, WaaS) support this feature.`);
|
|
225
|
+
}
|
|
226
|
+
let resolvedChainId = chainId;
|
|
227
|
+
if (!resolvedChainId) {
|
|
228
|
+
const networkId = yield ((_b = this.getNetwork) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
229
|
+
if (networkId) {
|
|
230
|
+
resolvedChainId = Number(networkId);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (!resolvedChainId) {
|
|
234
|
+
throw new DynamicError('Chain ID is required but could not be determined from the wallet. Please provide a chainId parameter.');
|
|
235
|
+
}
|
|
236
|
+
const walletClient = eoaConnector.getWalletClient(String(resolvedChainId));
|
|
237
|
+
if (!walletClient) {
|
|
238
|
+
throw new DynamicError(`Failed to get wallet client for chain ID ${resolvedChainId}. Ensure the wallet is connected to the correct network.`);
|
|
239
|
+
}
|
|
240
|
+
return signEip7702Authorization({
|
|
241
|
+
chainId: resolvedChainId,
|
|
242
|
+
signer: walletClient,
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Stores a pre-signed EIP-7702 authorization and recreates the kernel client
|
|
248
|
+
* to inject it. Call this after signing with useSignEip7702Authorization.
|
|
249
|
+
*/
|
|
250
|
+
setEip7702Auth(auth) {
|
|
251
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
252
|
+
const walletAddress = this.activeWalletAddress;
|
|
253
|
+
if (!walletAddress) {
|
|
254
|
+
throw new DynamicError('No active wallet');
|
|
255
|
+
}
|
|
256
|
+
const walletInfo = this.eoaConnectorMap[walletAddress];
|
|
257
|
+
if (!(walletInfo === null || walletInfo === void 0 ? void 0 : walletInfo.is7702)) {
|
|
258
|
+
throw new DynamicError('Active wallet is not an EIP-7702 wallet');
|
|
259
|
+
}
|
|
260
|
+
this.pendingEip7702Auth = auth;
|
|
261
|
+
// Clear the cached kernel clients so they get recreated with the new auth
|
|
262
|
+
delete this.providerMap[walletAddress];
|
|
263
|
+
const { eoaConnector, eoaAddress } = walletInfo;
|
|
264
|
+
if (isDynamicWaasConnector(eoaConnector)) {
|
|
265
|
+
yield eoaConnector.validateActiveWallet(eoaAddress);
|
|
266
|
+
}
|
|
267
|
+
const signer = yield eoaConnector.getSigner();
|
|
268
|
+
yield this.generateProviderMap(signer, walletAddress, true);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
207
271
|
setEoaConnector(_a) {
|
|
208
272
|
return __awaiter(this, arguments, void 0, function* ({ eoaAddress, connector, is7702 = false, properties, smartWalletAddress, isPrimary = true, }) {
|
|
209
273
|
var _b, _c;
|
|
@@ -268,11 +332,14 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
268
332
|
generateProviderMap(signer_1, walletAddress_1) {
|
|
269
333
|
return __awaiter(this, arguments, void 0, function* (signer, walletAddress, is7702 = false) {
|
|
270
334
|
const chainProviderMap = {};
|
|
335
|
+
// Capture once before concurrent creates so all calls share the same auth
|
|
336
|
+
const eip7702Auth = this.pendingEip7702Auth;
|
|
271
337
|
yield Promise.all(this.providersFromApi.map((provider) => __awaiter(this, void 0, void 0, function* () {
|
|
272
338
|
const { chain, clientId } = provider;
|
|
273
339
|
const [kernelClient, kernelClientWithSponsorship] = yield Promise.all([
|
|
274
340
|
this.getOrCreateKernelClient({
|
|
275
341
|
chainId: chain,
|
|
342
|
+
eip7702Auth,
|
|
276
343
|
is7702,
|
|
277
344
|
paymaster: PaymasterTypeEnum.NONE,
|
|
278
345
|
projectId: clientId,
|
|
@@ -281,6 +348,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
281
348
|
}),
|
|
282
349
|
this.getOrCreateKernelClient({
|
|
283
350
|
chainId: chain,
|
|
351
|
+
eip7702Auth,
|
|
284
352
|
is7702,
|
|
285
353
|
paymaster: PaymasterTypeEnum.SPONSOR,
|
|
286
354
|
projectId: clientId,
|
|
@@ -295,6 +363,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
295
363
|
};
|
|
296
364
|
yield this.warnIfProjectChainNotEnabled(parseChainId(chain));
|
|
297
365
|
})));
|
|
366
|
+
this.pendingEip7702Auth = undefined;
|
|
298
367
|
// Filter out duplicate chains and store under the wallet address
|
|
299
368
|
const uniqueChainProviderMap = Object.entries(chainProviderMap).reduce((acc, [chain, providers]) => {
|
|
300
369
|
if (!acc[chain]) {
|
|
@@ -306,7 +375,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
306
375
|
});
|
|
307
376
|
}
|
|
308
377
|
createKernelClient(_a) {
|
|
309
|
-
return __awaiter(this, arguments, void 0, function* ({ chainId, is7702 = false, projectId, signer, paymaster, paymasterRpcOverride, bundlerRpcOverride, }) {
|
|
378
|
+
return __awaiter(this, arguments, void 0, function* ({ chainId, eip7702Auth, is7702 = false, projectId, signer, paymaster, paymasterRpcOverride, bundlerRpcOverride, }) {
|
|
310
379
|
if (!signer)
|
|
311
380
|
throw new DynamicError('No signer provided');
|
|
312
381
|
const chain = chainsMap[chainId];
|
|
@@ -326,7 +395,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
326
395
|
signer,
|
|
327
396
|
};
|
|
328
397
|
if (is7702) {
|
|
329
|
-
kernelClient = yield createEcdsaKernelAccountClientWith7702(Object.assign(Object.assign({}, params), { kernelVersion: KERNEL_V3_3 }));
|
|
398
|
+
kernelClient = yield createEcdsaKernelAccountClientWith7702(Object.assign(Object.assign({}, params), { eip7702Auth, kernelVersion: KERNEL_V3_3 }));
|
|
330
399
|
}
|
|
331
400
|
else {
|
|
332
401
|
kernelClient = yield createEcdsaKernelAccountClient(Object.assign(Object.assign({}, params), { ecdsaValidator: getEcdsaValidator(this.ecdsaProviderType) }));
|
|
@@ -341,7 +410,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
341
410
|
});
|
|
342
411
|
}
|
|
343
412
|
getOrCreateKernelClient(_a) {
|
|
344
|
-
return __awaiter(this, arguments, void 0, function* ({ chainId, is7702 = false, projectId, signer, paymaster, walletAddress, }) {
|
|
413
|
+
return __awaiter(this, arguments, void 0, function* ({ chainId, eip7702Auth, is7702 = false, projectId, signer, paymaster, walletAddress, }) {
|
|
345
414
|
const walletProviders = this.providerMap[walletAddress];
|
|
346
415
|
if (chainId &&
|
|
347
416
|
(walletProviders === null || walletProviders === void 0 ? void 0 : walletProviders[chainId]) &&
|
|
@@ -352,6 +421,7 @@ class ZeroDevConnector extends AccountAbstractionBaseConnector {
|
|
|
352
421
|
}
|
|
353
422
|
return this.createKernelClient({
|
|
354
423
|
chainId,
|
|
424
|
+
eip7702Auth,
|
|
355
425
|
is7702,
|
|
356
426
|
paymaster,
|
|
357
427
|
projectId,
|
package/src/index.cjs
CHANGED
|
@@ -11,6 +11,7 @@ var fetchZeroDevChain = require('./utils/fetchZeroDevChain.cjs');
|
|
|
11
11
|
var getEcdsaValidator = require('./utils/getEcdsaValidator.cjs');
|
|
12
12
|
var getEntryPoint = require('./utils/getEntryPoint.cjs');
|
|
13
13
|
var getKernelVersion = require('./utils/getKernelVersion.cjs');
|
|
14
|
+
var signEip7702Authorization = require('./utils/signEip7702Authorization/signEip7702Authorization.cjs');
|
|
14
15
|
var isZeroDevConnector = require('./utils/isZeroDevConnector.cjs');
|
|
15
16
|
|
|
16
17
|
assertPackageVersion.assertPackageVersion('@dynamic-labs/ethereum-aa', _package.version);
|
|
@@ -45,6 +46,7 @@ exports.fetchZeroDevChain = fetchZeroDevChain.fetchZeroDevChain;
|
|
|
45
46
|
exports.getEcdsaValidator = getEcdsaValidator.getEcdsaValidator;
|
|
46
47
|
exports.getEntryPoint = getEntryPoint.getEntryPoint;
|
|
47
48
|
exports.getKernelVersion = getKernelVersion.getKernelVersion;
|
|
49
|
+
exports.signEip7702Authorization = signEip7702Authorization.signEip7702Authorization;
|
|
48
50
|
exports.isZeroDevConnector = isZeroDevConnector.isZeroDevConnector;
|
|
49
51
|
exports.ZeroDevSmartWalletConnectors = ZeroDevSmartWalletConnectors;
|
|
50
52
|
exports.ZeroDevSmartWalletConnectorsWithConfig = ZeroDevSmartWalletConnectorsWithConfig;
|
package/src/index.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ export { fetchZeroDevChain } from './utils/fetchZeroDevChain';
|
|
|
5
5
|
export { getEcdsaValidator } from './utils/getEcdsaValidator';
|
|
6
6
|
export { getEntryPoint } from './utils/getEntryPoint';
|
|
7
7
|
export { getKernelVersion } from './utils/getKernelVersion';
|
|
8
|
+
export { signEip7702Authorization, type SignEip7702AuthorizationParams, } from './utils/signEip7702Authorization';
|
|
8
9
|
export { isZeroDevConnector } from './utils/isZeroDevConnector';
|
|
10
|
+
export type { SignAuthorizationReturnType as Eip7702Authorization } from 'viem/accounts';
|
|
9
11
|
export type {
|
|
10
12
|
/** @deprecated Use ZerodevBundlerProvider from \@dynamic-labs/sdk-api-core instead */
|
|
11
13
|
ZerodevBundlerProvider as BundlerProvider, } from '@dynamic-labs/sdk-api-core';
|
package/src/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { fetchZeroDevChain } from './utils/fetchZeroDevChain.js';
|
|
|
7
7
|
export { getEcdsaValidator } from './utils/getEcdsaValidator.js';
|
|
8
8
|
export { getEntryPoint } from './utils/getEntryPoint.js';
|
|
9
9
|
export { getKernelVersion } from './utils/getKernelVersion.js';
|
|
10
|
+
export { signEip7702Authorization } from './utils/signEip7702Authorization/signEip7702Authorization.js';
|
|
10
11
|
export { isZeroDevConnector } from './utils/isZeroDevConnector.js';
|
|
11
12
|
|
|
12
13
|
assertPackageVersion('@dynamic-labs/ethereum-aa', version);
|
|
@@ -100,12 +100,13 @@ const createEcdsaKernelAccountClient = (_b) => _tslib.__awaiter(void 0, [_b], vo
|
|
|
100
100
|
const clientConfig = createKernelClientConfig(selectedAccount, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
|
|
101
101
|
return clients.createKernelAccountClient(clientConfig);
|
|
102
102
|
});
|
|
103
|
-
const createEcdsaKernelAccountClientWith7702 = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster = exports.PaymasterTypeEnum.SPONSOR, entryPoint, kernelVersion, publicClientRpc, }) {
|
|
103
|
+
const createEcdsaKernelAccountClientWith7702 = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster = exports.PaymasterTypeEnum.SPONSOR, entryPoint, kernelVersion, publicClientRpc, eip7702Auth, }) {
|
|
104
104
|
const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
|
|
105
105
|
const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
|
|
106
106
|
const { publicClient, zerodevPaymaster } = createPublicAndPaymasterClients(resolvedBundlerRpc, resolvedPaymasterRpc, chain, publicClientRpc);
|
|
107
107
|
const account = yield accounts.createKernelAccount(publicClient, {
|
|
108
108
|
eip7702Account: signer,
|
|
109
|
+
eip7702Auth,
|
|
109
110
|
entryPoint,
|
|
110
111
|
kernelVersion,
|
|
111
112
|
});
|
|
@@ -2,6 +2,7 @@ import { KernelAccountClient } from '@zerodev/sdk/clients';
|
|
|
2
2
|
import { EntryPointType, GetKernelVersion, KERNEL_VERSION_TYPE } from '@zerodev/sdk/types';
|
|
3
3
|
import { Account, Address, WalletClient, type Chain, type Client, type RpcSchema, type Transport } from 'viem';
|
|
4
4
|
import { EntryPointVersion, SmartAccount } from 'viem/account-abstraction';
|
|
5
|
+
import type { SignAuthorizationReturnType } from 'viem/accounts';
|
|
5
6
|
import { type Chain as ViemChain } from 'viem/chains';
|
|
6
7
|
import { ZerodevBundlerProvider } from '@dynamic-labs/sdk-api-core';
|
|
7
8
|
export type ERC20Paymaster = Address;
|
|
@@ -29,5 +30,7 @@ type CommonClientParams<TChain extends Chain | undefined = Chain | undefined> =
|
|
|
29
30
|
export declare const createEcdsaKernelAccountClient: <entryPoint extends EntryPointVersion, TChain extends Chain | undefined = Chain | undefined>({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster, entryPoint, kernelVersion, ecdsaValidator, enableKernelV3Migration, publicClientRpc, apiKernelVersion, }: CommonClientParams<TChain> & {
|
|
30
31
|
ecdsaValidator: any;
|
|
31
32
|
}) => Promise<KernelAccountClient<Transport, ViemChain, SmartAccount, Client, RpcSchema>>;
|
|
32
|
-
export declare const createEcdsaKernelAccountClientWith7702: <TChain extends Chain | undefined = Chain | undefined>({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster, entryPoint, kernelVersion, publicClientRpc, }: CommonClientParams<TChain>
|
|
33
|
+
export declare const createEcdsaKernelAccountClientWith7702: <TChain extends Chain | undefined = Chain | undefined>({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster, entryPoint, kernelVersion, publicClientRpc, eip7702Auth, }: CommonClientParams<TChain> & {
|
|
34
|
+
eip7702Auth?: SignAuthorizationReturnType;
|
|
35
|
+
}) => Promise<KernelAccountClient<Transport, ViemChain, SmartAccount, Client, RpcSchema>>;
|
|
33
36
|
export {};
|
|
@@ -96,12 +96,13 @@ const createEcdsaKernelAccountClient = (_b) => __awaiter(void 0, [_b], void 0, f
|
|
|
96
96
|
const clientConfig = createKernelClientConfig(selectedAccount, resolvedBundlerRpc, chain, publicClient, paymasterHandler);
|
|
97
97
|
return createKernelAccountClient(clientConfig);
|
|
98
98
|
});
|
|
99
|
-
const createEcdsaKernelAccountClientWith7702 = (_c) => __awaiter(void 0, [_c], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster = PaymasterTypeEnum.SPONSOR, entryPoint, kernelVersion, publicClientRpc, }) {
|
|
99
|
+
const createEcdsaKernelAccountClientWith7702 = (_c) => __awaiter(void 0, [_c], void 0, function* ({ bundlerRpc, chain, paymasterRpc, projectId, signer, provider, paymaster = PaymasterTypeEnum.SPONSOR, entryPoint, kernelVersion, publicClientRpc, eip7702Auth, }) {
|
|
100
100
|
const resolvedBundlerRpc = bundlerRpc !== null && bundlerRpc !== void 0 ? bundlerRpc : getZeroDevBundlerRPC(projectId, provider);
|
|
101
101
|
const resolvedPaymasterRpc = paymasterRpc !== null && paymasterRpc !== void 0 ? paymasterRpc : getZeroDevPaymasterRPC(projectId, provider);
|
|
102
102
|
const { publicClient, zerodevPaymaster } = createPublicAndPaymasterClients(resolvedBundlerRpc, resolvedPaymasterRpc, chain, publicClientRpc);
|
|
103
103
|
const account = yield createKernelAccount(publicClient, {
|
|
104
104
|
eip7702Account: signer,
|
|
105
|
+
eip7702Auth,
|
|
105
106
|
entryPoint,
|
|
106
107
|
kernelVersion,
|
|
107
108
|
});
|
package/src/utils/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { signEip7702Authorization, type SignEip7702AuthorizationParams, } from './signEip7702Authorization';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var constants = require('@zerodev/sdk/constants');
|
|
8
|
+
var actions = require('viem/actions');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Signs an EIP-7702 authorization for ZeroDev kernel delegation.
|
|
12
|
+
*
|
|
13
|
+
* This function creates a signed authorization that allows a wallet to delegate
|
|
14
|
+
* its execution to the ZeroDev kernel contract. The signed authorization can then
|
|
15
|
+
* be passed to `createEcdsaKernelAccountClientWith7702` via the `eip7702Auth` parameter.
|
|
16
|
+
*
|
|
17
|
+
* @param params - The parameters for signing the authorization.
|
|
18
|
+
* @param params.signer - The wallet client (signer) to sign the authorization with.
|
|
19
|
+
* @param params.chainId - The chain ID to use for signing.
|
|
20
|
+
* @returns A promise that resolves to the signed EIP-7702 authorization.
|
|
21
|
+
*/
|
|
22
|
+
const signEip7702Authorization = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ signer, chainId, }) {
|
|
23
|
+
return actions.signAuthorization(signer, {
|
|
24
|
+
chainId,
|
|
25
|
+
contractAddress: constants.KERNEL_7702_DELEGATION_ADDRESS,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
exports.signEip7702Authorization = signEip7702Authorization;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Account, WalletClient, Transport } from 'viem';
|
|
2
|
+
import type { SignAuthorizationReturnType } from 'viem/accounts';
|
|
3
|
+
import type { Chain as ViemChain } from 'viem/chains';
|
|
4
|
+
export type SignEip7702AuthorizationParams = {
|
|
5
|
+
chainId: number;
|
|
6
|
+
signer: WalletClient<Transport, ViemChain, Account>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Signs an EIP-7702 authorization for ZeroDev kernel delegation.
|
|
10
|
+
*
|
|
11
|
+
* This function creates a signed authorization that allows a wallet to delegate
|
|
12
|
+
* its execution to the ZeroDev kernel contract. The signed authorization can then
|
|
13
|
+
* be passed to `createEcdsaKernelAccountClientWith7702` via the `eip7702Auth` parameter.
|
|
14
|
+
*
|
|
15
|
+
* @param params - The parameters for signing the authorization.
|
|
16
|
+
* @param params.signer - The wallet client (signer) to sign the authorization with.
|
|
17
|
+
* @param params.chainId - The chain ID to use for signing.
|
|
18
|
+
* @returns A promise that resolves to the signed EIP-7702 authorization.
|
|
19
|
+
*/
|
|
20
|
+
export declare const signEip7702Authorization: ({ signer, chainId, }: SignEip7702AuthorizationParams) => Promise<SignAuthorizationReturnType>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { KERNEL_7702_DELEGATION_ADDRESS } from '@zerodev/sdk/constants';
|
|
4
|
+
import { signAuthorization } from 'viem/actions';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Signs an EIP-7702 authorization for ZeroDev kernel delegation.
|
|
8
|
+
*
|
|
9
|
+
* This function creates a signed authorization that allows a wallet to delegate
|
|
10
|
+
* its execution to the ZeroDev kernel contract. The signed authorization can then
|
|
11
|
+
* be passed to `createEcdsaKernelAccountClientWith7702` via the `eip7702Auth` parameter.
|
|
12
|
+
*
|
|
13
|
+
* @param params - The parameters for signing the authorization.
|
|
14
|
+
* @param params.signer - The wallet client (signer) to sign the authorization with.
|
|
15
|
+
* @param params.chainId - The chain ID to use for signing.
|
|
16
|
+
* @returns A promise that resolves to the signed EIP-7702 authorization.
|
|
17
|
+
*/
|
|
18
|
+
const signEip7702Authorization = (_a) => __awaiter(void 0, [_a], void 0, function* ({ signer, chainId, }) {
|
|
19
|
+
return signAuthorization(signer, {
|
|
20
|
+
chainId,
|
|
21
|
+
contractAddress: KERNEL_7702_DELEGATION_ADDRESS,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { signEip7702Authorization };
|