@dynamic-labs/ethereum-aa-zksync 4.18.8 → 4.19.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 CHANGED
@@ -1,4 +1,20 @@
1
1
 
2
+ ## [4.19.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.18.8...v4.19.0) (2025-05-23)
3
+
4
+
5
+ ### Features
6
+
7
+ * expose 7702 kernel and add viem controller ([#8786](https://github.com/dynamic-labs/dynamic-auth/issues/8786)) ([eea710e](https://github.com/dynamic-labs/dynamic-auth/commit/eea710e238ccbc36e6be37d8f7493954b99858ef))
8
+ * use browser wallet client & iframe for waas operations ([#8697](https://github.com/dynamic-labs/dynamic-auth/issues/8697)) ([13a47b1](https://github.com/dynamic-labs/dynamic-auth/commit/13a47b1c9a2984f08682e833ca8c87605a3a872f))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **global-wallet:** close popup when page unloads to prevent orphaned popup windows ([#8787](https://github.com/dynamic-labs/dynamic-auth/issues/8787)) ([441b04c](https://github.com/dynamic-labs/dynamic-auth/commit/441b04ca04a02feb37473e43bca0e66c5d772ce2))
14
+ * override network when requesting BTC networks in useTokenBalances ([#8773](https://github.com/dynamic-labs/dynamic-auth/issues/8773)) ([fd07d09](https://github.com/dynamic-labs/dynamic-auth/commit/fd07d09de970c7e6f85b251a88854e8eca57e249))
15
+ * remove libmpc executor dependency global wallet ([#8792](https://github.com/dynamic-labs/dynamic-auth/issues/8792)) ([7502585](https://github.com/dynamic-labs/dynamic-auth/commit/75025859d2f952915322cf65504117ec2506152b))
16
+ * standardize font on headers ([#8734](https://github.com/dynamic-labs/dynamic-auth/issues/8734)) ([9f0900c](https://github.com/dynamic-labs/dynamic-auth/commit/9f0900cb7c4294201cc952ae7538648bdea83ff5))
17
+
2
18
  ### [4.18.8](https://github.com/dynamic-labs/dynamic-auth/compare/v4.18.7...v4.18.8) (2025-05-22)
3
19
 
4
20
  ### Bug Fixes
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.18.8";
6
+ var version = "4.19.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.18.8";
2
+ var version = "4.19.0";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum-aa-zksync",
3
- "version": "4.18.8",
3
+ "version": "4.19.0",
4
4
  "description": "Core package for Ethereum Account Abstraction utilities and types",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -20,13 +20,13 @@
20
20
  "dependencies": {
21
21
  "@dynamic-labs/sdk-api-core": "0.0.672",
22
22
  "zksync-sso": "0.1.0",
23
- "@dynamic-labs/assert-package-version": "4.18.8",
24
- "@dynamic-labs/ethereum-aa-core": "4.18.8",
25
- "@dynamic-labs/ethereum-core": "4.18.8",
26
- "@dynamic-labs/types": "4.18.8",
27
- "@dynamic-labs/utils": "4.18.8",
28
- "@dynamic-labs/wallet-book": "4.18.8",
29
- "@dynamic-labs/wallet-connector-core": "4.18.8"
23
+ "@dynamic-labs/assert-package-version": "4.19.0",
24
+ "@dynamic-labs/ethereum-aa-core": "4.19.0",
25
+ "@dynamic-labs/ethereum-core": "4.19.0",
26
+ "@dynamic-labs/types": "4.19.0",
27
+ "@dynamic-labs/utils": "4.19.0",
28
+ "@dynamic-labs/wallet-book": "4.19.0",
29
+ "@dynamic-labs/wallet-connector-core": "4.19.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "viem": "^2.21.60"
@@ -21,6 +21,7 @@ var passkeys = require('../utils/passkeys.cjs');
21
21
  var deployment = require('../utils/deployment.cjs');
22
22
  var network = require('../utils/network.cjs');
23
23
  var session = require('../utils/session.cjs');
24
+ var storage = require('../utils/storage.cjs');
24
25
 
25
26
  class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
26
27
  constructor(props) {
@@ -92,7 +93,33 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
92
93
  return false;
93
94
  });
94
95
  }
95
- getAccountAbstractionProvider() {
96
+ getSessionFromStorage(sessionId) {
97
+ return storage.retrieveSessionFromStorage(sessionId);
98
+ }
99
+ setSession(sessionId, session) {
100
+ return storage.saveSessionToStorage(sessionId, session);
101
+ }
102
+ deleteSession(sessionId) {
103
+ return storage.deleteSessionFromStorage(sessionId);
104
+ }
105
+ getAccountAbstractionProvider({ sessionId } = {}) {
106
+ if (sessionId && this.sessionKeyAddress) {
107
+ const session = this.getSessionFromStorage(sessionId);
108
+ const isSessionRequestValid = session &&
109
+ (!session.origin || utils.PlatformService.getHostname() === session.origin);
110
+ if (isSessionRequestValid) {
111
+ return client.createZksyncSessionClient({
112
+ address: this.smartAccountAddress,
113
+ chain: ethereumCore.getOrMapViemChain(this.evmNetworks[0]),
114
+ contracts: {
115
+ session: this.sessionKeyAddress,
116
+ },
117
+ sessionConfig: session.sessionConfig,
118
+ sessionKey: session.sessionKey,
119
+ transport: viem.http(),
120
+ });
121
+ }
122
+ }
96
123
  return this.smartAccount;
97
124
  }
98
125
  getWalletClient(chainId) {
@@ -554,9 +581,9 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
554
581
  return -1;
555
582
  return 0;
556
583
  });
557
- return activeSessions.map((session$1) => {
584
+ return activeSessions.map((session) => {
558
585
  var _a;
559
- return (Object.assign(Object.assign({}, session$1), { origin: (_a = session.retrieveSessionFromStorage(session$1.sessionId)) === null || _a === void 0 ? void 0 : _a.origin }));
586
+ return (Object.assign(Object.assign({}, session), { origin: (_a = this.getSessionFromStorage(session.sessionId)) === null || _a === void 0 ? void 0 : _a.origin }));
560
587
  });
561
588
  }
562
589
  catch (error) {
@@ -592,7 +619,7 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
592
619
  };
593
620
  }
594
621
  yield this.smartAccount.revokeSession(params);
595
- utils.StorageService.removeItem(`zksync-session-${sessionId}`);
622
+ this.deleteSession(sessionId);
596
623
  });
597
624
  }
598
625
  createSession(_a) {
@@ -620,7 +647,7 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
620
647
  const originURI = origin
621
648
  ? new URL(origin).hostname
622
649
  : utils.PlatformService.getHostname();
623
- utils.StorageService.setItem(`zksync-session-${sessionHash}`, {
650
+ this.setSession(sessionHash, {
624
651
  origin: originURI,
625
652
  sessionConfig: serializedSessionConfig,
626
653
  sessionKey: privateKey,
@@ -65,7 +65,13 @@ export declare class ZKsyncConnector extends AccountAbstractionBaseConnector imp
65
65
  getNetwork(): Promise<number | undefined>;
66
66
  getPublicClient(): Promise<PublicClient>;
67
67
  canSponsorTransactionGas(): Promise<boolean>;
68
- getAccountAbstractionProvider<T = ZksyncSsoEcdsaClient<Transport, ViemChain, RpcSchema>>(): T;
68
+ private getSessionFromStorage;
69
+ private setSession;
70
+ private deleteSession;
71
+ getAccountAbstractionProvider<T = ZksyncSsoEcdsaClient<Transport, ViemChain, RpcSchema> | ZksyncSsoSessionClient<Transport, ViemChain, RpcSchema>>({ sessionId }?: {
72
+ sessionId?: string;
73
+ withSponsorship?: boolean;
74
+ }): T;
69
75
  getWalletClient(chainId?: string): WalletClient<Transport, ViemChain, Account> | undefined;
70
76
  private getWalletClientTransport;
71
77
  private getTransport;
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
- import { createWalletClient, custom, publicActions, createPublicClient, http, walletActions, toHex } from 'viem';
3
+ import { http, createWalletClient, custom, publicActions, createPublicClient, walletActions, toHex } from 'viem';
4
4
  import { getGeneralPaymasterInput, eip712WalletActions } from 'viem/zksync';
5
5
  import { AAFactoryAbi, SessionKeyValidatorAbi } from 'zksync-sso/abi';
6
6
  import { createZksyncPasskeyClient, registerNewPasskey } from 'zksync-sso/client/passkey';
@@ -8,15 +8,16 @@ import { encodeModuleData } from 'zksync-sso/utils';
8
8
  import { createZksyncSessionClient } from 'zksync-sso/client';
9
9
  import { createZksyncEcdsaClient, zksyncSsoEcdsaWalletActions } from 'zksync-sso/client/ecdsa';
10
10
  import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
11
- import { EthereumWallet, chainsMap, confirmationTransport, getOrMapViemChain } from '@dynamic-labs/ethereum-core';
12
- import { parseEvmNetworks, DeferredPromise, StorageService, PlatformService, DynamicError } from '@dynamic-labs/utils';
11
+ import { EthereumWallet, getOrMapViemChain, chainsMap, confirmationTransport } from '@dynamic-labs/ethereum-core';
12
+ import { parseEvmNetworks, PlatformService, DeferredPromise, StorageService, DynamicError } from '@dynamic-labs/utils';
13
13
  import { logger } from '@dynamic-labs/wallet-connector-core';
14
14
  import { AccountAbstractionBaseConnector } from '@dynamic-labs/ethereum-aa-core';
15
15
  import { getSalt } from '../utils/getSalt.js';
16
16
  import { getEncodedPasskeyModuleData } from '../utils/passkeys.js';
17
17
  import { getDeploymentParameters, simulateAccountDeployment, executeAccountDeployment } from '../utils/deployment.js';
18
18
  import { ensureEoaConnectorNetwork } from '../utils/network.js';
19
- import { retrieveSessionFromStorage, enforceSessionConfigRestrictions, getSessionHash, stringifySessionConfig } from '../utils/session.js';
19
+ import { enforceSessionConfigRestrictions, getSessionHash, stringifySessionConfig } from '../utils/session.js';
20
+ import { retrieveSessionFromStorage, saveSessionToStorage, deleteSessionFromStorage } from '../utils/storage.js';
20
21
 
21
22
  class ZKsyncConnector extends AccountAbstractionBaseConnector {
22
23
  constructor(props) {
@@ -88,7 +89,33 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
88
89
  return false;
89
90
  });
90
91
  }
91
- getAccountAbstractionProvider() {
92
+ getSessionFromStorage(sessionId) {
93
+ return retrieveSessionFromStorage(sessionId);
94
+ }
95
+ setSession(sessionId, session) {
96
+ return saveSessionToStorage(sessionId, session);
97
+ }
98
+ deleteSession(sessionId) {
99
+ return deleteSessionFromStorage(sessionId);
100
+ }
101
+ getAccountAbstractionProvider({ sessionId } = {}) {
102
+ if (sessionId && this.sessionKeyAddress) {
103
+ const session = this.getSessionFromStorage(sessionId);
104
+ const isSessionRequestValid = session &&
105
+ (!session.origin || PlatformService.getHostname() === session.origin);
106
+ if (isSessionRequestValid) {
107
+ return createZksyncSessionClient({
108
+ address: this.smartAccountAddress,
109
+ chain: getOrMapViemChain(this.evmNetworks[0]),
110
+ contracts: {
111
+ session: this.sessionKeyAddress,
112
+ },
113
+ sessionConfig: session.sessionConfig,
114
+ sessionKey: session.sessionKey,
115
+ transport: http(),
116
+ });
117
+ }
118
+ }
92
119
  return this.smartAccount;
93
120
  }
94
121
  getWalletClient(chainId) {
@@ -552,7 +579,7 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
552
579
  });
553
580
  return activeSessions.map((session) => {
554
581
  var _a;
555
- return (Object.assign(Object.assign({}, session), { origin: (_a = retrieveSessionFromStorage(session.sessionId)) === null || _a === void 0 ? void 0 : _a.origin }));
582
+ return (Object.assign(Object.assign({}, session), { origin: (_a = this.getSessionFromStorage(session.sessionId)) === null || _a === void 0 ? void 0 : _a.origin }));
556
583
  });
557
584
  }
558
585
  catch (error) {
@@ -588,7 +615,7 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
588
615
  };
589
616
  }
590
617
  yield this.smartAccount.revokeSession(params);
591
- StorageService.removeItem(`zksync-session-${sessionId}`);
618
+ this.deleteSession(sessionId);
592
619
  });
593
620
  }
594
621
  createSession(_a) {
@@ -616,7 +643,7 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
616
643
  const originURI = origin
617
644
  ? new URL(origin).hostname
618
645
  : PlatformService.getHostname();
619
- StorageService.setItem(`zksync-session-${sessionHash}`, {
646
+ this.setSession(sessionHash, {
620
647
  origin: originURI,
621
648
  sessionConfig: serializedSessionConfig,
622
649
  sessionKey: privateKey,
@@ -4,3 +4,4 @@ export * from './deployment';
4
4
  export * from './network';
5
5
  export * from './isZKsyncConnector';
6
6
  export * from './session';
7
+ export * from './storage';
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var viem = require('viem');
7
7
  var utils = require('zksync-sso/utils');
8
- var utils$1 = require('@dynamic-labs/utils');
9
8
 
10
9
  const DEFAULT_EXPIRATION_TIME = 86400; // 1 day
11
10
  const enforceSessionConfigRestrictions = (sessionConfig) => {
@@ -37,16 +36,8 @@ const stringifySessionConfig = (sessionConfig) => {
37
36
  });
38
37
  return Object.assign(Object.assign({}, sessionConfig), { callPolicies: sessionConfig.callPolicies.map((policy) => (Object.assign(Object.assign({}, policy), { constraints: policy.constraints.map((constraint) => (Object.assign(Object.assign({}, constraint), { index: constraint.index.toString(), limit: stringifyLimit(constraint.limit) }))), maxValuePerUse: policy.maxValuePerUse.toString(), valueLimit: stringifyLimit(policy.valueLimit) }))), expiresAt: sessionConfig.expiresAt.toString(), feeLimit: stringifyLimit(sessionConfig.feeLimit), transferPolicies: sessionConfig.transferPolicies.map((policy) => (Object.assign(Object.assign({}, policy), { maxValuePerUse: policy.maxValuePerUse.toString(), valueLimit: stringifyLimit(policy.valueLimit) }))) });
39
38
  };
40
- const retrieveSessionFromStorage = (sessionId) => {
41
- const session = utils$1.StorageService.getItem(`zksync-session-${sessionId}`);
42
- if (!session) {
43
- return undefined;
44
- }
45
- return Object.assign(Object.assign({}, session), { sessionConfig: parseSessionConfigJSON(session.sessionConfig) });
46
- };
47
39
 
48
40
  exports.enforceSessionConfigRestrictions = enforceSessionConfigRestrictions;
49
41
  exports.getSessionHash = getSessionHash;
50
42
  exports.parseSessionConfigJSON = parseSessionConfigJSON;
51
- exports.retrieveSessionFromStorage = retrieveSessionFromStorage;
52
43
  exports.stringifySessionConfig = stringifySessionConfig;
@@ -4,8 +4,3 @@ export declare const enforceSessionConfigRestrictions: (sessionConfig: SessionCo
4
4
  export declare const getSessionHash: (sessionConfig: SessionConfig) => `0x${string}`;
5
5
  export declare const parseSessionConfigJSON: (sessionConfig: SessionConfigJSON) => SessionConfig;
6
6
  export declare const stringifySessionConfig: (sessionConfig: SessionConfig) => SessionConfigJSON;
7
- export declare const retrieveSessionFromStorage: (sessionId: string) => {
8
- sessionConfig: SessionConfig;
9
- origin?: string | undefined;
10
- sessionKey: string;
11
- } | undefined;
@@ -1,7 +1,6 @@
1
1
  'use client'
2
2
  import { keccak256 } from 'viem';
3
3
  import { encodeSession } from 'zksync-sso/utils';
4
- import { StorageService } from '@dynamic-labs/utils';
5
4
 
6
5
  const DEFAULT_EXPIRATION_TIME = 86400; // 1 day
7
6
  const enforceSessionConfigRestrictions = (sessionConfig) => {
@@ -33,12 +32,5 @@ const stringifySessionConfig = (sessionConfig) => {
33
32
  });
34
33
  return Object.assign(Object.assign({}, sessionConfig), { callPolicies: sessionConfig.callPolicies.map((policy) => (Object.assign(Object.assign({}, policy), { constraints: policy.constraints.map((constraint) => (Object.assign(Object.assign({}, constraint), { index: constraint.index.toString(), limit: stringifyLimit(constraint.limit) }))), maxValuePerUse: policy.maxValuePerUse.toString(), valueLimit: stringifyLimit(policy.valueLimit) }))), expiresAt: sessionConfig.expiresAt.toString(), feeLimit: stringifyLimit(sessionConfig.feeLimit), transferPolicies: sessionConfig.transferPolicies.map((policy) => (Object.assign(Object.assign({}, policy), { maxValuePerUse: policy.maxValuePerUse.toString(), valueLimit: stringifyLimit(policy.valueLimit) }))) });
35
34
  };
36
- const retrieveSessionFromStorage = (sessionId) => {
37
- const session = StorageService.getItem(`zksync-session-${sessionId}`);
38
- if (!session) {
39
- return undefined;
40
- }
41
- return Object.assign(Object.assign({}, session), { sessionConfig: parseSessionConfigJSON(session.sessionConfig) });
42
- };
43
35
 
44
- export { enforceSessionConfigRestrictions, getSessionHash, parseSessionConfigJSON, retrieveSessionFromStorage, stringifySessionConfig };
36
+ export { enforceSessionConfigRestrictions, getSessionHash, parseSessionConfigJSON, stringifySessionConfig };
@@ -0,0 +1,27 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var utils = require('@dynamic-labs/utils');
7
+ var session = require('./session.cjs');
8
+
9
+ const getZksyncSessionStorageKey = (sessionId) => `zksync-session-${sessionId}`;
10
+ const retrieveSessionFromStorage = (sessionId) => {
11
+ const session$1 = utils.StorageService.getItem(getZksyncSessionStorageKey(sessionId));
12
+ if (!session$1) {
13
+ return undefined;
14
+ }
15
+ return Object.assign(Object.assign({}, session$1), { sessionConfig: session.parseSessionConfigJSON(session$1.sessionConfig) });
16
+ };
17
+ const saveSessionToStorage = (sessionId, session) => {
18
+ utils.StorageService.setItem(getZksyncSessionStorageKey(sessionId), session);
19
+ };
20
+ const deleteSessionFromStorage = (sessionId) => {
21
+ utils.StorageService.removeItem(getZksyncSessionStorageKey(sessionId));
22
+ };
23
+
24
+ exports.deleteSessionFromStorage = deleteSessionFromStorage;
25
+ exports.getZksyncSessionStorageKey = getZksyncSessionStorageKey;
26
+ exports.retrieveSessionFromStorage = retrieveSessionFromStorage;
27
+ exports.saveSessionToStorage = saveSessionToStorage;
@@ -0,0 +1,9 @@
1
+ import { SessionStorageItem } from '../types';
2
+ export declare const getZksyncSessionStorageKey: (sessionId: string) => string;
3
+ export declare const retrieveSessionFromStorage: (sessionId: string) => {
4
+ sessionConfig: import("zksync-sso/utils").SessionConfig;
5
+ origin?: string | undefined;
6
+ sessionKey: string;
7
+ } | undefined;
8
+ export declare const saveSessionToStorage: (sessionId: string, session: SessionStorageItem) => void;
9
+ export declare const deleteSessionFromStorage: (sessionId: string) => void;
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ import { StorageService } from '@dynamic-labs/utils';
3
+ import { parseSessionConfigJSON } from './session.js';
4
+
5
+ const getZksyncSessionStorageKey = (sessionId) => `zksync-session-${sessionId}`;
6
+ const retrieveSessionFromStorage = (sessionId) => {
7
+ const session = StorageService.getItem(getZksyncSessionStorageKey(sessionId));
8
+ if (!session) {
9
+ return undefined;
10
+ }
11
+ return Object.assign(Object.assign({}, session), { sessionConfig: parseSessionConfigJSON(session.sessionConfig) });
12
+ };
13
+ const saveSessionToStorage = (sessionId, session) => {
14
+ StorageService.setItem(getZksyncSessionStorageKey(sessionId), session);
15
+ };
16
+ const deleteSessionFromStorage = (sessionId) => {
17
+ StorageService.removeItem(getZksyncSessionStorageKey(sessionId));
18
+ };
19
+
20
+ export { deleteSessionFromStorage, getZksyncSessionStorageKey, retrieveSessionFromStorage, saveSessionToStorage };