@dynamic-labs/ethereum-aa-zksync 4.20.1 → 4.20.3

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,21 @@
1
1
 
2
+ ### [4.20.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.2...v4.20.3) (2025-06-13)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * use minified jwt for waas wallet client auth ([#8938](https://github.com/dynamic-labs/dynamic-auth/issues/8938)) ([f7b9e14](https://github.com/dynamic-labs/dynamic-auth/commit/f7b9e1435e397a64fdf4f42f9b3ad354314e0191))
8
+
9
+ ### [4.20.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.1...v4.20.2) (2025-06-11)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * auto-creation for only missing v3 wallets ([#8928](https://github.com/dynamic-labs/dynamic-auth/issues/8928)) ([845a01b](https://github.com/dynamic-labs/dynamic-auth/commit/845a01b1c7661d4858913006b2dd303ded19b462))
15
+ * don't logout when unlinking last wallet ([#8932](https://github.com/dynamic-labs/dynamic-auth/issues/8932)) ([ae91d68](https://github.com/dynamic-labs/dynamic-auth/commit/ae91d682ac69a267be3b1f9ae4cf2bb46cae8c6b))
16
+ * fetch nonce before attempting zksync account upgrade to avoid nonce collision ([#8924](https://github.com/dynamic-labs/dynamic-auth/issues/8924)) ([12aa982](https://github.com/dynamic-labs/dynamic-auth/commit/12aa98224c30ded0f7b83f3eabc6fa9a923b72cd))
17
+ * remove max session expiration restraint for zksync sessions ([#8922](https://github.com/dynamic-labs/dynamic-auth/issues/8922)) ([abb92e0](https://github.com/dynamic-labs/dynamic-auth/commit/abb92e009ff9c5485e4856a39d03c4035b7a6ee2))
18
+
2
19
  ### [4.20.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.0...v4.20.1) (2025-06-09)
3
20
 
4
21
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.20.1";
6
+ var version = "4.20.3";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.20.1";
2
+ var version = "4.20.3";
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.20.1",
3
+ "version": "4.20.3",
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.681",
22
22
  "zksync-sso": "0.2.0",
23
- "@dynamic-labs/assert-package-version": "4.20.1",
24
- "@dynamic-labs/ethereum-aa-core": "4.20.1",
25
- "@dynamic-labs/ethereum-core": "4.20.1",
26
- "@dynamic-labs/types": "4.20.1",
27
- "@dynamic-labs/utils": "4.20.1",
28
- "@dynamic-labs/wallet-book": "4.20.1",
29
- "@dynamic-labs/wallet-connector-core": "4.20.1"
23
+ "@dynamic-labs/assert-package-version": "4.20.3",
24
+ "@dynamic-labs/ethereum-aa-core": "4.20.3",
25
+ "@dynamic-labs/ethereum-core": "4.20.3",
26
+ "@dynamic-labs/types": "4.20.3",
27
+ "@dynamic-labs/utils": "4.20.3",
28
+ "@dynamic-labs/wallet-book": "4.20.3",
29
+ "@dynamic-labs/wallet-connector-core": "4.20.3"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "viem": "^2.28.4"
@@ -630,7 +630,13 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
630
630
  };
631
631
  }
632
632
  this._walletUiUtils.disabledConfirmationOnce();
633
- yield this.smartAccount.revokeSession(params);
633
+ try {
634
+ yield this.smartAccount.revokeSession(params);
635
+ }
636
+ catch (error) {
637
+ walletConnectorCore.logger.error('[ZKsyncConnector] Error revoking session: ', error);
638
+ throw new Error('Failed to revoke session');
639
+ }
634
640
  this.deleteSession(sessionId);
635
641
  });
636
642
  }
@@ -698,7 +704,15 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
698
704
  sessionConfig: serializedSessionConfig,
699
705
  sessionKey: privateKey,
700
706
  });
701
- return { expiresAt: safeSessionConfig.expiresAt, sessionId: sessionHash };
707
+ return {
708
+ expiresAt: safeSessionConfig.expiresAt,
709
+ session: {
710
+ sessionConfiguration: serializedSessionConfig,
711
+ sessionKey: privateKey,
712
+ sessionKeyValidator: this.sessionKeyAddress,
713
+ },
714
+ sessionId: sessionHash,
715
+ };
702
716
  });
703
717
  }
704
718
  validateActiveWallet(expectedAddress) {
@@ -11,7 +11,7 @@ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
11
11
  import { Chain, IAccountAbstractionWalletConnector, InternalWalletConnector, WalletConnector } from '@dynamic-labs/wallet-connector-core';
12
12
  import { AccountAbstractionBaseConnector, AccountAbstractionConnectorProps } from '@dynamic-labs/ethereum-aa-core';
13
13
  import { DeploymentParams } from '../utils';
14
- import { SessionInformation, SessionConfigWithoutSigner } from '../types';
14
+ import { SessionInformation, SessionConfigWithoutSigner, SessionConfigJSON } from '../types';
15
15
  type ZKsyncConnectorProps = AccountAbstractionConnectorProps & {
16
16
  apiProviders: {
17
17
  [key in ProviderEnum]?: Provider;
@@ -17714,6 +17714,11 @@ export declare class ZKsyncConnector extends AccountAbstractionBaseConnector imp
17714
17714
  addModuleWithPaymaster?: boolean;
17715
17715
  }): Promise<{
17716
17716
  expiresAt: bigint;
17717
+ session: {
17718
+ sessionKeyValidator: `0x${string}`;
17719
+ sessionConfiguration: SessionConfigJSON;
17720
+ sessionKey: `0x${string}`;
17721
+ };
17717
17722
  sessionId: `0x${string}`;
17718
17723
  }>;
17719
17724
  validateActiveWallet(expectedAddress: string): Promise<void>;
@@ -626,7 +626,13 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
626
626
  };
627
627
  }
628
628
  this._walletUiUtils.disabledConfirmationOnce();
629
- yield this.smartAccount.revokeSession(params);
629
+ try {
630
+ yield this.smartAccount.revokeSession(params);
631
+ }
632
+ catch (error) {
633
+ logger.error('[ZKsyncConnector] Error revoking session: ', error);
634
+ throw new Error('Failed to revoke session');
635
+ }
630
636
  this.deleteSession(sessionId);
631
637
  });
632
638
  }
@@ -694,7 +700,15 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
694
700
  sessionConfig: serializedSessionConfig,
695
701
  sessionKey: privateKey,
696
702
  });
697
- return { expiresAt: safeSessionConfig.expiresAt, sessionId: sessionHash };
703
+ return {
704
+ expiresAt: safeSessionConfig.expiresAt,
705
+ session: {
706
+ sessionConfiguration: serializedSessionConfig,
707
+ sessionKey: privateKey,
708
+ sessionKeyValidator: this.sessionKeyAddress,
709
+ },
710
+ sessionId: sessionHash,
711
+ };
698
712
  });
699
713
  }
700
714
  validateActiveWallet(expectedAddress) {
package/src/index.cjs CHANGED
@@ -11,6 +11,7 @@ require('../_virtual/_tslib.cjs');
11
11
  require('zksync-sso/utils');
12
12
  require('@dynamic-labs/utils');
13
13
  var isZKsyncConnector = require('./utils/isZKsyncConnector.cjs');
14
+ var session = require('./utils/session.cjs');
14
15
  require('viem/zksync');
15
16
  require('zksync-sso/abi');
16
17
 
@@ -24,4 +25,7 @@ const ZKsyncSmartWalletConnectors = (props) => {
24
25
  };
25
26
 
26
27
  exports.isZKsyncConnector = isZKsyncConnector.isZKsyncConnector;
28
+ exports.createSessionClient = session.createSessionClient;
29
+ exports.parseSessionConfigJSON = session.parseSessionConfigJSON;
30
+ exports.stringifySessionConfig = session.stringifySessionConfig;
27
31
  exports.ZKsyncSmartWalletConnectors = ZKsyncSmartWalletConnectors;
package/src/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
2
- export { isZKsyncConnector } from './utils';
2
+ export { isZKsyncConnector, parseSessionConfigJSON, stringifySessionConfig, createSessionClient, } from './utils';
3
3
  export { type SessionInformation } from './types';
4
4
  export declare const ZKsyncSmartWalletConnectors: (props: any) => WalletConnectorConstructor[];
package/src/index.js CHANGED
@@ -7,6 +7,7 @@ import '../_virtual/_tslib.js';
7
7
  import 'zksync-sso/utils';
8
8
  import '@dynamic-labs/utils';
9
9
  export { isZKsyncConnector } from './utils/isZKsyncConnector.js';
10
+ export { createSessionClient, parseSessionConfigJSON, stringifySessionConfig } from './utils/session.js';
10
11
  import 'viem/zksync';
11
12
  import 'zksync-sso/abi';
12
13
 
@@ -21,7 +21,7 @@ const isModuleInstalled = (_a) => _tslib.__awaiter(void 0, [_a], void 0, functio
21
21
  return sessionValidatorInstalled;
22
22
  });
23
23
  const installModule = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ module, smartAddress, publicClient, ecdsaClient, paymaster, }) {
24
- var _c;
24
+ var _c, _d;
25
25
  const { address: moduleAddress, initData } = module;
26
26
  if (!paymaster) {
27
27
  const gasEstimate = yield publicClient.estimateContractGas({
@@ -40,12 +40,18 @@ const installModule = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* (
40
40
  throw new Error(`Insufficient balance to upgrade smart account, balance: ${balance} required: ${requiredBalance}`);
41
41
  }
42
42
  }
43
+ // In certain circumstances, the nonce is not updated before this call is made
44
+ const nonce = yield publicClient.getTransactionCount({
45
+ address: (_d = ecdsaClient.account) === null || _d === void 0 ? void 0 : _d.address,
46
+ blockTag: 'pending',
47
+ });
43
48
  const simulatedSessionModuleAddition = yield publicClient.simulateContract({
44
49
  abi: abi.SsoAccountAbi,
45
50
  account: ecdsaClient.account,
46
51
  address: smartAddress,
47
52
  args: [moduleAddress, initData],
48
53
  functionName: 'addModuleValidator',
54
+ nonce,
49
55
  });
50
56
  let request = Object.assign({}, simulatedSessionModuleAddition.request);
51
57
  if (paymaster) {
@@ -17,7 +17,7 @@ const isModuleInstalled = (_a) => __awaiter(void 0, [_a], void 0, function* ({ m
17
17
  return sessionValidatorInstalled;
18
18
  });
19
19
  const installModule = (_b) => __awaiter(void 0, [_b], void 0, function* ({ module, smartAddress, publicClient, ecdsaClient, paymaster, }) {
20
- var _c;
20
+ var _c, _d;
21
21
  const { address: moduleAddress, initData } = module;
22
22
  if (!paymaster) {
23
23
  const gasEstimate = yield publicClient.estimateContractGas({
@@ -36,12 +36,18 @@ const installModule = (_b) => __awaiter(void 0, [_b], void 0, function* ({ modul
36
36
  throw new Error(`Insufficient balance to upgrade smart account, balance: ${balance} required: ${requiredBalance}`);
37
37
  }
38
38
  }
39
+ // In certain circumstances, the nonce is not updated before this call is made
40
+ const nonce = yield publicClient.getTransactionCount({
41
+ address: (_d = ecdsaClient.account) === null || _d === void 0 ? void 0 : _d.address,
42
+ blockTag: 'pending',
43
+ });
39
44
  const simulatedSessionModuleAddition = yield publicClient.simulateContract({
40
45
  abi: SsoAccountAbi,
41
46
  account: ecdsaClient.account,
42
47
  address: smartAddress,
43
48
  args: [moduleAddress, initData],
44
49
  functionName: 'addModuleValidator',
50
+ nonce,
45
51
  });
46
52
  let request = Object.assign({}, simulatedSessionModuleAddition.request);
47
53
  if (paymaster) {
@@ -5,13 +5,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var viem = require('viem');
7
7
  var utils = require('zksync-sso/utils');
8
+ var client = require('zksync-sso/client');
9
+ var ethereumCore = require('@dynamic-labs/ethereum-core');
8
10
 
9
11
  const DEFAULT_EXPIRATION_TIME = 86400; // 1 day
10
12
  const enforceSessionConfigRestrictions = (sessionConfig) => {
11
13
  const now = Math.floor(Date.now() / 1000);
12
14
  const maxExpirationTime = now + DEFAULT_EXPIRATION_TIME;
13
- if (!sessionConfig.expiresAt ||
14
- Number(sessionConfig.expiresAt) > maxExpirationTime) {
15
+ if (!sessionConfig.expiresAt) {
15
16
  sessionConfig.expiresAt = BigInt(maxExpirationTime);
16
17
  }
17
18
  return sessionConfig;
@@ -36,7 +37,18 @@ const stringifySessionConfig = (sessionConfig) => {
36
37
  });
37
38
  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) }))) });
38
39
  };
40
+ const createSessionClient = ({ smartAccountAddress, sessionKeyValidator, sessionConfig, sessionKey, chainId, }) => client.createZksyncSessionClient({
41
+ address: smartAccountAddress,
42
+ chain: ethereumCore.getChain(chainId),
43
+ contracts: {
44
+ session: sessionKeyValidator,
45
+ },
46
+ sessionConfig,
47
+ sessionKey,
48
+ transport: viem.http(),
49
+ });
39
50
 
51
+ exports.createSessionClient = createSessionClient;
40
52
  exports.enforceSessionConfigRestrictions = enforceSessionConfigRestrictions;
41
53
  exports.getSessionHash = getSessionHash;
42
54
  exports.parseSessionConfigJSON = parseSessionConfigJSON;