@dynamic-labs/ethereum-aa-zksync 4.19.2 → 4.19.4

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,13 @@
1
1
 
2
+ ### [4.19.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.3...v4.19.4) (2025-05-31)
3
+
4
+ ### [4.19.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.2...v4.19.3) (2025-05-28)
5
+
6
+
7
+ ### Bug Fixes
8
+
9
+ * rerender issue with Slush wallet pop up appearing multiple times ([#8817](https://github.com/dynamic-labs/dynamic-auth/issues/8817)) ([bea0da6](https://github.com/dynamic-labs/dynamic-auth/commit/bea0da647bab983610ebbf18a6ca66ba0ac569bf))
10
+
2
11
  ### [4.19.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.1...v4.19.2) (2025-05-27)
3
12
 
4
13
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.19.2";
6
+ var version = "4.19.4";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.19.2";
2
+ var version = "4.19.4";
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.19.2",
3
+ "version": "4.19.4",
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.2.0",
23
- "@dynamic-labs/assert-package-version": "4.19.2",
24
- "@dynamic-labs/ethereum-aa-core": "4.19.2",
25
- "@dynamic-labs/ethereum-core": "4.19.2",
26
- "@dynamic-labs/types": "4.19.2",
27
- "@dynamic-labs/utils": "4.19.2",
28
- "@dynamic-labs/wallet-book": "4.19.2",
29
- "@dynamic-labs/wallet-connector-core": "4.19.2"
23
+ "@dynamic-labs/assert-package-version": "4.19.4",
24
+ "@dynamic-labs/ethereum-aa-core": "4.19.4",
25
+ "@dynamic-labs/ethereum-core": "4.19.4",
26
+ "@dynamic-labs/types": "4.19.4",
27
+ "@dynamic-labs/utils": "4.19.4",
28
+ "@dynamic-labs/wallet-book": "4.19.4",
29
+ "@dynamic-labs/wallet-connector-core": "4.19.4"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "viem": "^2.21.60"
@@ -22,6 +22,7 @@ var deployment = require('../utils/deployment.cjs');
22
22
  var network = require('../utils/network.cjs');
23
23
  var session = require('../utils/session.cjs');
24
24
  var storage = require('../utils/storage.cjs');
25
+ var module$1 = require('../utils/module.cjs');
25
26
 
26
27
  class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
27
28
  constructor(props) {
@@ -527,7 +528,7 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
527
528
  });
528
529
  }
529
530
  listSessions() {
530
- return _tslib.__awaiter(this, void 0, void 0, function* () {
531
+ return _tslib.__awaiter(this, arguments, void 0, function* ({ asJson = false, } = {}) {
531
532
  if (!this.smartAccount) {
532
533
  throw new Error('Smart account is not initialized');
533
534
  }
@@ -566,8 +567,10 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
566
567
  // filter out the sessions that have been revoked
567
568
  !revokedSessionHashes.includes(log.args.sessionHash))
568
569
  .map((log) => ({
569
- blockNumber: log.blockNumber,
570
- session: log.args.sessionSpec,
570
+ blockNumber: asJson ? log.blockNumber.toString() : log.blockNumber,
571
+ session: asJson
572
+ ? session.stringifySessionConfig(log.args.sessionSpec)
573
+ : log.args.sessionSpec,
571
574
  sessionId: log.args.sessionHash,
572
575
  timestamp: new Date(
573
576
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -623,7 +626,7 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
623
626
  });
624
627
  }
625
628
  createSession(_a) {
626
- return _tslib.__awaiter(this, arguments, void 0, function* ({ sessionConfig, origin, }) {
629
+ return _tslib.__awaiter(this, arguments, void 0, function* ({ sessionConfig, origin, addModuleWithPaymaster = false, }) {
627
630
  if (!this.smartAccount) {
628
631
  throw new Error('Smart account is not initialized');
629
632
  }
@@ -641,6 +644,25 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
641
644
  }),
642
645
  };
643
646
  }
647
+ const publicClient = yield this.getPublicClient();
648
+ if (!(yield module$1.isModuleInstalled({
649
+ moduleAddress: this.sessionKeyAddress,
650
+ publicClient,
651
+ smartAddress: this.smartAccountAddress,
652
+ }))) {
653
+ yield module$1.installModule({
654
+ ecdsaClient: this.getAccountAbstractionProvider(),
655
+ module: {
656
+ address: this.sessionKeyAddress,
657
+ initData: '0x',
658
+ },
659
+ paymaster: addModuleWithPaymaster && this.paymasterAddress
660
+ ? this.paymasterAddress
661
+ : undefined,
662
+ publicClient,
663
+ smartAddress: this.smartAccountAddress,
664
+ });
665
+ }
644
666
  yield this.smartAccount.createSession(params);
645
667
  const sessionHash = session.getSessionHash(params.sessionConfig);
646
668
  const serializedSessionConfig = session.stringifySessionConfig(params.sessionConfig);
@@ -17702,12 +17702,15 @@ export declare class ZKsyncConnector extends AccountAbstractionBaseConnector imp
17702
17702
  */
17703
17703
  protected checkIsDeployed(): Promise<boolean>;
17704
17704
  private getSmartAccountCreationBlock;
17705
- listSessions(): Promise<SessionInformation[]>;
17705
+ listSessions({ asJson, }?: {
17706
+ asJson?: boolean;
17707
+ }): Promise<SessionInformation[]>;
17706
17708
  getAddress(): Promise<string | undefined>;
17707
17709
  revokeSession(sessionId: `0x${string}`): Promise<void>;
17708
- createSession({ sessionConfig, origin, }: {
17710
+ createSession({ sessionConfig, origin, addModuleWithPaymaster, }: {
17709
17711
  sessionConfig: SessionConfigWithoutSigner;
17710
17712
  origin?: string;
17713
+ addModuleWithPaymaster?: boolean;
17711
17714
  }): Promise<{
17712
17715
  expiresAt: bigint;
17713
17716
  sessionId: `0x${string}`;
@@ -16,8 +16,9 @@ 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 { enforceSessionConfigRestrictions, getSessionHash, stringifySessionConfig } from '../utils/session.js';
19
+ import { stringifySessionConfig, enforceSessionConfigRestrictions, getSessionHash } from '../utils/session.js';
20
20
  import { retrieveSessionFromStorage, saveSessionToStorage, deleteSessionFromStorage } from '../utils/storage.js';
21
+ import { isModuleInstalled, installModule } from '../utils/module.js';
21
22
 
22
23
  class ZKsyncConnector extends AccountAbstractionBaseConnector {
23
24
  constructor(props) {
@@ -523,7 +524,7 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
523
524
  });
524
525
  }
525
526
  listSessions() {
526
- return __awaiter(this, void 0, void 0, function* () {
527
+ return __awaiter(this, arguments, void 0, function* ({ asJson = false, } = {}) {
527
528
  if (!this.smartAccount) {
528
529
  throw new Error('Smart account is not initialized');
529
530
  }
@@ -562,8 +563,10 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
562
563
  // filter out the sessions that have been revoked
563
564
  !revokedSessionHashes.includes(log.args.sessionHash))
564
565
  .map((log) => ({
565
- blockNumber: log.blockNumber,
566
- session: log.args.sessionSpec,
566
+ blockNumber: asJson ? log.blockNumber.toString() : log.blockNumber,
567
+ session: asJson
568
+ ? stringifySessionConfig(log.args.sessionSpec)
569
+ : log.args.sessionSpec,
567
570
  sessionId: log.args.sessionHash,
568
571
  timestamp: new Date(
569
572
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -619,7 +622,7 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
619
622
  });
620
623
  }
621
624
  createSession(_a) {
622
- return __awaiter(this, arguments, void 0, function* ({ sessionConfig, origin, }) {
625
+ return __awaiter(this, arguments, void 0, function* ({ sessionConfig, origin, addModuleWithPaymaster = false, }) {
623
626
  if (!this.smartAccount) {
624
627
  throw new Error('Smart account is not initialized');
625
628
  }
@@ -637,6 +640,25 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
637
640
  }),
638
641
  };
639
642
  }
643
+ const publicClient = yield this.getPublicClient();
644
+ if (!(yield isModuleInstalled({
645
+ moduleAddress: this.sessionKeyAddress,
646
+ publicClient,
647
+ smartAddress: this.smartAccountAddress,
648
+ }))) {
649
+ yield installModule({
650
+ ecdsaClient: this.getAccountAbstractionProvider(),
651
+ module: {
652
+ address: this.sessionKeyAddress,
653
+ initData: '0x',
654
+ },
655
+ paymaster: addModuleWithPaymaster && this.paymasterAddress
656
+ ? this.paymasterAddress
657
+ : undefined,
658
+ publicClient,
659
+ smartAddress: this.smartAccountAddress,
660
+ });
661
+ }
640
662
  yield this.smartAccount.createSession(params);
641
663
  const sessionHash = getSessionHash(params.sessionConfig);
642
664
  const serializedSessionConfig = stringifySessionConfig(params.sessionConfig);
package/src/index.cjs CHANGED
@@ -11,6 +11,8 @@ 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
+ require('viem/zksync');
15
+ require('zksync-sso/abi');
14
16
 
15
17
  assertPackageVersion.assertPackageVersion('@dynamic-labs/ethereum-aa-zksync', _package.version);
16
18
  const ZKsyncSmartWalletConnectors = (props) => {
package/src/index.js CHANGED
@@ -7,6 +7,8 @@ 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
+ import 'viem/zksync';
11
+ import 'zksync-sso/abi';
10
12
 
11
13
  assertPackageVersion('@dynamic-labs/ethereum-aa-zksync', version);
12
14
  const ZKsyncSmartWalletConnectors = (props) => {
@@ -1,11 +1,8 @@
1
1
  import { SessionConfig } from 'zksync-sso/utils';
2
- import { GenericNetwork, WalletUiUtils } from '@dynamic-labs/types';
2
+ import { ConvertBigIntToString, GenericNetwork, WalletUiUtils } from '@dynamic-labs/types';
3
3
  import { WalletBookSchema } from '@dynamic-labs/wallet-book';
4
4
  import { InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
5
5
  export type SessionConfigWithoutSigner = Omit<SessionConfig, 'signer'>;
6
- export type ConvertBigIntToString<T> = T extends bigint ? string : T extends Array<infer U> ? Array<ConvertBigIntToString<U>> : T extends object ? {
7
- [K in keyof T]: ConvertBigIntToString<T[K]>;
8
- } : T;
9
6
  export type SessionConfigJSON = ConvertBigIntToString<SessionConfig>;
10
7
  export type AccountAbstractionConnectorProps = {
11
8
  walletUiUtils: WalletUiUtils<InternalWalletConnector>;
@@ -13,8 +10,8 @@ export type AccountAbstractionConnectorProps = {
13
10
  evmNetworks: GenericNetwork[];
14
11
  };
15
12
  export type SessionInformation = {
16
- blockNumber: bigint;
17
- session: SessionConfig;
13
+ blockNumber: bigint | string;
14
+ session: SessionConfig | SessionConfigJSON;
18
15
  sessionId: string;
19
16
  timestamp: number;
20
17
  transactionHash: string;
@@ -5,3 +5,4 @@ export * from './network';
5
5
  export * from './isZKsyncConnector';
6
6
  export * from './session';
7
7
  export * from './storage';
8
+ export * from './module';
@@ -0,0 +1,43 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../_virtual/_tslib.cjs');
7
+ var viem = require('viem');
8
+ var zksync = require('viem/zksync');
9
+ var abi = require('zksync-sso/abi');
10
+
11
+ const isModuleInstalled = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ moduleAddress, smartAddress, publicClient, }) {
12
+ const ssoAccountContract = viem.getContract({
13
+ abi: abi.SsoAccountAbi,
14
+ address: smartAddress,
15
+ client: publicClient,
16
+ });
17
+ if (!ssoAccountContract) {
18
+ return false;
19
+ }
20
+ const sessionValidatorInstalled = yield ssoAccountContract.read.isModuleValidator([moduleAddress]);
21
+ return sessionValidatorInstalled;
22
+ });
23
+ const installModule = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ module, smartAddress, publicClient, ecdsaClient, paymaster, }) {
24
+ const { address: moduleAddress, initData } = module;
25
+ const simulatedSessionModuleAddition = yield publicClient.simulateContract({
26
+ abi: abi.SsoAccountAbi,
27
+ account: ecdsaClient.account,
28
+ address: smartAddress,
29
+ args: [moduleAddress, initData],
30
+ functionName: 'addModuleValidator',
31
+ });
32
+ let request = Object.assign({}, simulatedSessionModuleAddition.request);
33
+ if (paymaster) {
34
+ request = Object.assign(Object.assign({}, request), { paymaster, paymasterInput: zksync.getGeneralPaymasterInput({
35
+ innerInput: new Uint8Array(),
36
+ }) });
37
+ }
38
+ const tx = yield ecdsaClient.writeContract(request);
39
+ yield publicClient.waitForTransactionReceipt({ hash: tx });
40
+ });
41
+
42
+ exports.installModule = installModule;
43
+ exports.isModuleInstalled = isModuleInstalled;
@@ -0,0 +1,17 @@
1
+ import { Address, PublicClient, RpcSchema, Transport, type Chain as ViemChain } from 'viem';
2
+ import { ZksyncSsoEcdsaClient } from 'zksync-sso/client/ecdsa';
3
+ export declare const isModuleInstalled: ({ moduleAddress, smartAddress, publicClient, }: {
4
+ moduleAddress: Address;
5
+ smartAddress: Address;
6
+ publicClient: PublicClient;
7
+ }) => Promise<boolean>;
8
+ export declare const installModule: ({ module, smartAddress, publicClient, ecdsaClient, paymaster, }: {
9
+ module: {
10
+ address: Address;
11
+ initData: `0x${string}`;
12
+ };
13
+ smartAddress: Address;
14
+ paymaster?: Address;
15
+ publicClient: PublicClient;
16
+ ecdsaClient: ZksyncSsoEcdsaClient<Transport, ViemChain, RpcSchema>;
17
+ }) => Promise<void>;
@@ -0,0 +1,38 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../_virtual/_tslib.js';
3
+ import { getContract } from 'viem';
4
+ import { getGeneralPaymasterInput } from 'viem/zksync';
5
+ import { SsoAccountAbi } from 'zksync-sso/abi';
6
+
7
+ const isModuleInstalled = (_a) => __awaiter(void 0, [_a], void 0, function* ({ moduleAddress, smartAddress, publicClient, }) {
8
+ const ssoAccountContract = getContract({
9
+ abi: SsoAccountAbi,
10
+ address: smartAddress,
11
+ client: publicClient,
12
+ });
13
+ if (!ssoAccountContract) {
14
+ return false;
15
+ }
16
+ const sessionValidatorInstalled = yield ssoAccountContract.read.isModuleValidator([moduleAddress]);
17
+ return sessionValidatorInstalled;
18
+ });
19
+ const installModule = (_b) => __awaiter(void 0, [_b], void 0, function* ({ module, smartAddress, publicClient, ecdsaClient, paymaster, }) {
20
+ const { address: moduleAddress, initData } = module;
21
+ const simulatedSessionModuleAddition = yield publicClient.simulateContract({
22
+ abi: SsoAccountAbi,
23
+ account: ecdsaClient.account,
24
+ address: smartAddress,
25
+ args: [moduleAddress, initData],
26
+ functionName: 'addModuleValidator',
27
+ });
28
+ let request = Object.assign({}, simulatedSessionModuleAddition.request);
29
+ if (paymaster) {
30
+ request = Object.assign(Object.assign({}, request), { paymaster, paymasterInput: getGeneralPaymasterInput({
31
+ innerInput: new Uint8Array(),
32
+ }) });
33
+ }
34
+ const tx = yield ecdsaClient.writeContract(request);
35
+ yield publicClient.waitForTransactionReceipt({ hash: tx });
36
+ });
37
+
38
+ export { installModule, isModuleInstalled };