@dynamic-labs/global-wallet-client 4.19.3 → 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.
Files changed (36) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +19 -7
  5. package/src/lib/ethereum/functions/eip1193Provider/createEIP1193Provider.cjs +3 -3
  6. package/src/lib/ethereum/functions/eip1193Provider/createEIP1193Provider.js +3 -3
  7. package/src/lib/functions/addWebWalletOpenerService/addWebWalletOpenerService.cjs +6 -6
  8. package/src/lib/functions/addWebWalletOpenerService/addWebWalletOpenerService.js +6 -6
  9. package/src/lib/functions/connect/connect.cjs +3 -3
  10. package/src/lib/functions/connect/connect.js +3 -3
  11. package/src/lib/functions/createWalletOpener/createWalletOpener.d.ts +2 -2
  12. package/src/lib/functions/createZksyncSession/createZksyncSession.cjs +55 -0
  13. package/src/lib/functions/createZksyncSession/createZksyncSession.d.ts +25 -0
  14. package/src/lib/functions/createZksyncSession/createZksyncSession.js +51 -0
  15. package/src/lib/functions/createZksyncSession/index.d.ts +1 -0
  16. package/src/lib/functions/listZksyncSessions/index.d.ts +1 -0
  17. package/src/lib/functions/listZksyncSessions/listZksyncSessions.cjs +54 -0
  18. package/src/lib/functions/listZksyncSessions/listZksyncSessions.d.ts +25 -0
  19. package/src/lib/functions/listZksyncSessions/listZksyncSessions.js +50 -0
  20. package/src/lib/functions/revokeZksyncSession/index.d.ts +1 -0
  21. package/src/lib/functions/revokeZksyncSession/revokeZksyncSession.cjs +54 -0
  22. package/src/lib/functions/revokeZksyncSession/revokeZksyncSession.d.ts +21 -0
  23. package/src/lib/functions/revokeZksyncSession/revokeZksyncSession.js +50 -0
  24. package/src/lib/functions/signEthereumMessage/signEthereumMessage.cjs +3 -3
  25. package/src/lib/functions/signEthereumMessage/signEthereumMessage.js +3 -3
  26. package/src/lib/functions/signSolanaMessage/signSolanaMessage.cjs +3 -3
  27. package/src/lib/functions/signSolanaMessage/signSolanaMessage.js +3 -3
  28. package/src/lib/solana/functions/createSolanaSignAndSendTransactionFeature/createSolanaSignAndSendTransactionFeature.cjs +3 -3
  29. package/src/lib/solana/functions/createSolanaSignAndSendTransactionFeature/createSolanaSignAndSendTransactionFeature.js +3 -3
  30. package/src/lib/solana/functions/createSolanaSignMessageFeature/createSolanaSignMessageFeature.cjs +3 -3
  31. package/src/lib/solana/functions/createSolanaSignMessageFeature/createSolanaSignMessageFeature.js +3 -3
  32. package/src/lib/solana/functions/createSolanaSignTransactionFeature/createSolanaSignTransactionFeature.cjs +3 -3
  33. package/src/lib/solana/functions/createSolanaSignTransactionFeature/createSolanaSignTransactionFeature.js +3 -3
  34. package/src/zksync.cjs +14 -0
  35. package/src/zksync.d.ts +3 -0
  36. package/src/zksync.js +4 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ ### [4.19.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.3...v4.19.4) (2025-05-31)
3
+
2
4
  ### [4.19.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.2...v4.19.3) (2025-05-28)
3
5
 
4
6
 
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.3";
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.3";
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/global-wallet-client",
3
- "version": "4.19.3",
3
+ "version": "4.19.4",
4
4
  "description": "Core package for building Dynamic's Global Wallet",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -19,6 +19,9 @@
19
19
  ],
20
20
  "features": [
21
21
  "./src/features.d.ts"
22
+ ],
23
+ "zksync": [
24
+ "./src/zksync.d.ts"
22
25
  ]
23
26
  }
24
27
  },
@@ -43,16 +46,21 @@
43
46
  "import": "./src/features.js",
44
47
  "default": "./src/features.cjs"
45
48
  },
49
+ "./zksync": {
50
+ "types": "./src/zksync.d.ts",
51
+ "import": "./src/zksync.js",
52
+ "default": "./src/zksync.cjs"
53
+ },
46
54
  "./package.json": "./package.json"
47
55
  },
48
56
  "homepage": "https://www.dynamic.xyz/",
49
57
  "dependencies": {
50
- "@dynamic-labs/assert-package-version": "4.19.3",
51
- "@dynamic-labs/logger": "4.19.3",
52
- "@dynamic-labs/message-transport": "4.19.3",
53
- "@dynamic-labs/store": "4.19.3",
54
- "@dynamic-labs/types": "4.19.3",
55
- "@dynamic-labs/utils": "4.19.3",
58
+ "@dynamic-labs/assert-package-version": "4.19.4",
59
+ "@dynamic-labs/logger": "4.19.4",
60
+ "@dynamic-labs/message-transport": "4.19.4",
61
+ "@dynamic-labs/store": "4.19.4",
62
+ "@dynamic-labs/types": "4.19.4",
63
+ "@dynamic-labs/utils": "4.19.4",
56
64
  "eventemitter3": "5.0.1"
57
65
  },
58
66
  "peerDependencies": {
@@ -61,12 +69,16 @@
61
69
  "@solana/wallet-standard-features": "^1.2.0",
62
70
  "@wallet-standard/features": "^1.0.3",
63
71
  "@wallet-standard/base": "^1.0.1",
72
+ "zksync-sso": "0.2.0",
64
73
  "@wallet-standard/wallet": "^1.1.0"
65
74
  },
66
75
  "peerDependenciesMeta": {
67
76
  "viem": {
68
77
  "optional": true
69
78
  },
79
+ "zksync-sso": {
80
+ "optional": true
81
+ },
70
82
  "@solana/web3.js": {
71
83
  "optional": true
72
84
  },
@@ -154,13 +154,13 @@ const handleMethodInPopup = (_a) => _tslib.__awaiter(void 0, [_a], void 0, funct
154
154
  }
155
155
  const { data } = yield getCore.getCore(client)
156
156
  .request({
157
- connection: getActiveConnection.getActiveConnection(client),
158
- params: {
157
+ args: {
159
158
  chainId: currentEthereumNetworkId,
160
159
  method,
161
160
  params,
162
161
  },
163
- pathname: 'eth-request',
162
+ connection: getActiveConnection.getActiveConnection(client),
163
+ name: 'eth-request',
164
164
  })
165
165
  .catch(mapErrorToStandard);
166
166
  return data;
@@ -150,13 +150,13 @@ const handleMethodInPopup = (_a) => __awaiter(void 0, [_a], void 0, function* ({
150
150
  }
151
151
  const { data } = yield getCore(client)
152
152
  .request({
153
- connection: getActiveConnection(client),
154
- params: {
153
+ args: {
155
154
  chainId: currentEthereumNetworkId,
156
155
  method,
157
156
  params,
158
157
  },
159
- pathname: 'eth-request',
158
+ connection: getActiveConnection(client),
159
+ name: 'eth-request',
160
160
  })
161
161
  .catch(mapErrorToStandard);
162
162
  return data;
@@ -49,10 +49,10 @@ const addWebWalletOpenerService = (client, globalWindow = global.window) => {
49
49
  if (typeof globalWindow !== 'undefined') {
50
50
  globalWindow.addEventListener('beforeunload', closePopup);
51
51
  }
52
- const popupOpener = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ params, pathname, connection, }) {
52
+ const popupOpener = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ args, name, connection, }) {
53
53
  logger.logVerboseTroubleshootingMessage('new popup action', {
54
- params,
55
- pathname,
54
+ args,
55
+ name,
56
56
  });
57
57
  // Used as a unique identifier for the action
58
58
  const actionId = new Date().getTime();
@@ -60,7 +60,7 @@ const addWebWalletOpenerService = (client, globalWindow = global.window) => {
60
60
  const popupFinalUrl = new URL(popupUrl);
61
61
  const resultDeferredPromise = new utils.DeferredPromise();
62
62
  // Setup popup URL and data
63
- popupFinalUrl.hash = `/${pathname}`;
63
+ popupFinalUrl.hash = `/${name}`;
64
64
  popupFinalUrl.searchParams.set('provider_env_id', environmentId);
65
65
  // TODO: use PlatformService
66
66
  popupFinalUrl.searchParams.set('requester_origin', globalWindow.location.origin);
@@ -73,8 +73,8 @@ const addWebWalletOpenerService = (client, globalWindow = global.window) => {
73
73
  popup = globalWindow.open('', '_blank', features);
74
74
  }
75
75
  // Encrypt params if active connection is present
76
- if (params) {
77
- yield mergeAndEncryptParams.mergeAndEncryptParams(popupFinalUrl, params, connection);
76
+ if (args) {
77
+ yield mergeAndEncryptParams.mergeAndEncryptParams(popupFinalUrl, args, connection);
78
78
  }
79
79
  if (popup === null) {
80
80
  throw new Error('Failed to open popup');
@@ -45,10 +45,10 @@ const addWebWalletOpenerService = (client, globalWindow = global.window) => {
45
45
  if (typeof globalWindow !== 'undefined') {
46
46
  globalWindow.addEventListener('beforeunload', closePopup);
47
47
  }
48
- const popupOpener = (_d) => __awaiter(void 0, [_d], void 0, function* ({ params, pathname, connection, }) {
48
+ const popupOpener = (_d) => __awaiter(void 0, [_d], void 0, function* ({ args, name, connection, }) {
49
49
  logger.logVerboseTroubleshootingMessage('new popup action', {
50
- params,
51
- pathname,
50
+ args,
51
+ name,
52
52
  });
53
53
  // Used as a unique identifier for the action
54
54
  const actionId = new Date().getTime();
@@ -56,7 +56,7 @@ const addWebWalletOpenerService = (client, globalWindow = global.window) => {
56
56
  const popupFinalUrl = new URL(popupUrl);
57
57
  const resultDeferredPromise = new DeferredPromise();
58
58
  // Setup popup URL and data
59
- popupFinalUrl.hash = `/${pathname}`;
59
+ popupFinalUrl.hash = `/${name}`;
60
60
  popupFinalUrl.searchParams.set('provider_env_id', environmentId);
61
61
  // TODO: use PlatformService
62
62
  popupFinalUrl.searchParams.set('requester_origin', globalWindow.location.origin);
@@ -69,8 +69,8 @@ const addWebWalletOpenerService = (client, globalWindow = global.window) => {
69
69
  popup = globalWindow.open('', '_blank', features);
70
70
  }
71
71
  // Encrypt params if active connection is present
72
- if (params) {
73
- yield mergeAndEncryptParams(popupFinalUrl, params, connection);
72
+ if (args) {
73
+ yield mergeAndEncryptParams(popupFinalUrl, args, connection);
74
74
  }
75
75
  if (popup === null) {
76
76
  throw new Error('Failed to open popup');
@@ -34,11 +34,11 @@ const connect = (client) => _tslib.__awaiter(void 0, void 0, void 0, function* (
34
34
  clearStore.clearStore(client);
35
35
  const keyPair = yield utils.createKeyPair();
36
36
  const data = yield core.request({
37
- connection: getActiveConnection.getActiveConnection(client),
38
- params: {
37
+ args: {
39
38
  receiver_public_key: yield utils.convertPublicKeyCryptoKeyToHex(keyPair.publicKey),
40
39
  },
41
- pathname: 'connect',
40
+ connection: getActiveConnection.getActiveConnection(client),
41
+ name: 'connect',
42
42
  });
43
43
  const { encryptedMessage, expiresAt, iv, providerPublicKey } = data;
44
44
  const sharedSecret = yield utils.deriveSharedSecret(keyPair.privateKey, yield utils.convertPublicKeyHexToCryptoKey(providerPublicKey));
@@ -30,11 +30,11 @@ const connect = (client) => __awaiter(void 0, void 0, void 0, function* () {
30
30
  clearStore(client);
31
31
  const keyPair = yield createKeyPair();
32
32
  const data = yield core.request({
33
- connection: getActiveConnection(client),
34
- params: {
33
+ args: {
35
34
  receiver_public_key: yield convertPublicKeyCryptoKeyToHex(keyPair.publicKey),
36
35
  },
37
- pathname: 'connect',
36
+ connection: getActiveConnection(client),
37
+ name: 'connect',
38
38
  });
39
39
  const { encryptedMessage, expiresAt, iv, providerPublicKey } = data;
40
40
  const sharedSecret = yield deriveSharedSecret(keyPair.privateKey, yield convertPublicKeyHexToCryptoKey(providerPublicKey));
@@ -1,8 +1,8 @@
1
1
  import { GetPopupActionFuncArgs, GetPopupActionName, GetPopupActionResult, GlobalWalletConnection, IPopupAction } from '@dynamic-labs/types';
2
2
  import { Registry } from '../createRegistry';
3
3
  export type OpenWalletProps<TAction extends IPopupAction> = {
4
- params: GetPopupActionFuncArgs<TAction>;
5
- pathname: GetPopupActionName<TAction>;
4
+ args: GetPopupActionFuncArgs<TAction>;
5
+ name: GetPopupActionName<TAction>;
6
6
  connection: GlobalWalletConnection | null;
7
7
  };
8
8
  export type WalletOpenerService = {
@@ -0,0 +1,55 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../_virtual/_tslib.cjs');
7
+ var isEthereumWallet = require('../isEthereumWallet/isEthereumWallet.cjs');
8
+ require('eventemitter3');
9
+ require('@dynamic-labs/logger');
10
+ require('@dynamic-labs/store');
11
+ var getActiveConnection = require('../getActiveConnection/getActiveConnection.cjs');
12
+ require('../../errors/DisconnectError.cjs');
13
+ require('@dynamic-labs/utils');
14
+ require('../../constants/logger.cjs');
15
+ var getCore = require('../../client/getCore/getCore.cjs');
16
+ var getClient = require('../../client/getClient/getClient.cjs');
17
+ var getCurrentEthereumNetworkId = require('../getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.cjs');
18
+
19
+ /**
20
+ * Creates a session with the wallet.
21
+ *
22
+ * @param wallet - The wallet to create the session with.
23
+ * @param sessionConfig - The session config to create the session with.
24
+ *
25
+ * @returns The signature and signed message.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { Wallet } from 'wallet';
30
+ *
31
+ * const { sessionId, expiresAt } = await createZksyncSession(Wallet, { sessionConfig });
32
+ * ```
33
+ */
34
+ const createZksyncSession = (wallet_1, _a) => _tslib.__awaiter(void 0, [wallet_1, _a], void 0, function* (wallet, { sessionConfig }) {
35
+ if (!isEthereumWallet.isEthereumWallet(wallet)) {
36
+ throw new Error('Wallet is not an Ethereum wallet');
37
+ }
38
+ const client = getClient.getClient(wallet);
39
+ const chainId = getCurrentEthereumNetworkId.getCurrentEthereumNetworkId(client);
40
+ if (!chainId) {
41
+ throw new Error('No chain id found');
42
+ }
43
+ const { data } = yield getCore.getCore(client).request({
44
+ args: {
45
+ chainId,
46
+ method: 'zksync_createSession',
47
+ params: [wallet.address, sessionConfig],
48
+ },
49
+ connection: getActiveConnection.getActiveConnection(client),
50
+ name: 'zksync-request',
51
+ });
52
+ return data;
53
+ });
54
+
55
+ exports.createZksyncSession = createZksyncSession;
@@ -0,0 +1,25 @@
1
+ import { SessionConfig } from 'zksync-sso/utils';
2
+ import { BaseWallet, ConvertBigIntToString } from '@dynamic-labs/types';
3
+ type createZksyncSessionParams = {
4
+ sessionConfig: Omit<ConvertBigIntToString<SessionConfig>, 'signer'>;
5
+ };
6
+ /**
7
+ * Creates a session with the wallet.
8
+ *
9
+ * @param wallet - The wallet to create the session with.
10
+ * @param sessionConfig - The session config to create the session with.
11
+ *
12
+ * @returns The signature and signed message.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { Wallet } from 'wallet';
17
+ *
18
+ * const { sessionId, expiresAt } = await createZksyncSession(Wallet, { sessionConfig });
19
+ * ```
20
+ */
21
+ export declare const createZksyncSession: (wallet: BaseWallet, { sessionConfig }: createZksyncSessionParams) => Promise<{
22
+ sessionId: string;
23
+ expiresAt: string;
24
+ }>;
25
+ export {};
@@ -0,0 +1,51 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../_virtual/_tslib.js';
3
+ import { isEthereumWallet } from '../isEthereumWallet/isEthereumWallet.js';
4
+ import 'eventemitter3';
5
+ import '@dynamic-labs/logger';
6
+ import '@dynamic-labs/store';
7
+ import { getActiveConnection } from '../getActiveConnection/getActiveConnection.js';
8
+ import '../../errors/DisconnectError.js';
9
+ import '@dynamic-labs/utils';
10
+ import '../../constants/logger.js';
11
+ import { getCore } from '../../client/getCore/getCore.js';
12
+ import { getClient } from '../../client/getClient/getClient.js';
13
+ import { getCurrentEthereumNetworkId } from '../getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.js';
14
+
15
+ /**
16
+ * Creates a session with the wallet.
17
+ *
18
+ * @param wallet - The wallet to create the session with.
19
+ * @param sessionConfig - The session config to create the session with.
20
+ *
21
+ * @returns The signature and signed message.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { Wallet } from 'wallet';
26
+ *
27
+ * const { sessionId, expiresAt } = await createZksyncSession(Wallet, { sessionConfig });
28
+ * ```
29
+ */
30
+ const createZksyncSession = (wallet_1, _a) => __awaiter(void 0, [wallet_1, _a], void 0, function* (wallet, { sessionConfig }) {
31
+ if (!isEthereumWallet(wallet)) {
32
+ throw new Error('Wallet is not an Ethereum wallet');
33
+ }
34
+ const client = getClient(wallet);
35
+ const chainId = getCurrentEthereumNetworkId(client);
36
+ if (!chainId) {
37
+ throw new Error('No chain id found');
38
+ }
39
+ const { data } = yield getCore(client).request({
40
+ args: {
41
+ chainId,
42
+ method: 'zksync_createSession',
43
+ params: [wallet.address, sessionConfig],
44
+ },
45
+ connection: getActiveConnection(client),
46
+ name: 'zksync-request',
47
+ });
48
+ return data;
49
+ });
50
+
51
+ export { createZksyncSession };
@@ -0,0 +1 @@
1
+ export * from './createZksyncSession';
@@ -0,0 +1 @@
1
+ export * from './listZksyncSessions';
@@ -0,0 +1,54 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../_virtual/_tslib.cjs');
7
+ var isEthereumWallet = require('../isEthereumWallet/isEthereumWallet.cjs');
8
+ require('eventemitter3');
9
+ require('@dynamic-labs/logger');
10
+ require('@dynamic-labs/store');
11
+ var getActiveConnection = require('../getActiveConnection/getActiveConnection.cjs');
12
+ require('../../errors/DisconnectError.cjs');
13
+ require('@dynamic-labs/utils');
14
+ require('../../constants/logger.cjs');
15
+ var getCore = require('../../client/getCore/getCore.cjs');
16
+ var getClient = require('../../client/getClient/getClient.cjs');
17
+ var getCurrentEthereumNetworkId = require('../getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.cjs');
18
+
19
+ /**
20
+ * Lists all sessions for the wallet.
21
+ *
22
+ * @param wallet - The wallet to list sessions for.
23
+ *
24
+ * @returns The sessions.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { Wallet } from 'wallet';
29
+ *
30
+ * const sessions = await listZksyncSessions(Wallet);
31
+ * ```
32
+ */
33
+ const listZksyncSessions = (wallet) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
34
+ if (!isEthereumWallet.isEthereumWallet(wallet)) {
35
+ throw new Error('Wallet is not an Ethereum wallet');
36
+ }
37
+ const client = getClient.getClient(wallet);
38
+ const chainId = getCurrentEthereumNetworkId.getCurrentEthereumNetworkId(client);
39
+ if (!chainId) {
40
+ throw new Error('No chain id found');
41
+ }
42
+ const { data } = yield getCore.getCore(client).request({
43
+ args: {
44
+ chainId,
45
+ method: 'zksync_listSessions',
46
+ params: [wallet.address],
47
+ },
48
+ connection: getActiveConnection.getActiveConnection(client),
49
+ name: 'zksync-request',
50
+ });
51
+ return data;
52
+ });
53
+
54
+ exports.listZksyncSessions = listZksyncSessions;
@@ -0,0 +1,25 @@
1
+ import { SessionConfig } from 'zksync-sso/utils';
2
+ import { BaseWallet, ConvertBigIntToString } from '@dynamic-labs/types';
3
+ export type SessionInformation = {
4
+ blockNumber: bigint | string;
5
+ session: SessionConfig | ConvertBigIntToString<SessionConfig>;
6
+ sessionId: string;
7
+ timestamp: number;
8
+ transactionHash: string;
9
+ origin?: string;
10
+ };
11
+ /**
12
+ * Lists all sessions for the wallet.
13
+ *
14
+ * @param wallet - The wallet to list sessions for.
15
+ *
16
+ * @returns The sessions.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { Wallet } from 'wallet';
21
+ *
22
+ * const sessions = await listZksyncSessions(Wallet);
23
+ * ```
24
+ */
25
+ export declare const listZksyncSessions: (wallet: BaseWallet) => Promise<SessionInformation[]>;
@@ -0,0 +1,50 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../_virtual/_tslib.js';
3
+ import { isEthereumWallet } from '../isEthereumWallet/isEthereumWallet.js';
4
+ import 'eventemitter3';
5
+ import '@dynamic-labs/logger';
6
+ import '@dynamic-labs/store';
7
+ import { getActiveConnection } from '../getActiveConnection/getActiveConnection.js';
8
+ import '../../errors/DisconnectError.js';
9
+ import '@dynamic-labs/utils';
10
+ import '../../constants/logger.js';
11
+ import { getCore } from '../../client/getCore/getCore.js';
12
+ import { getClient } from '../../client/getClient/getClient.js';
13
+ import { getCurrentEthereumNetworkId } from '../getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.js';
14
+
15
+ /**
16
+ * Lists all sessions for the wallet.
17
+ *
18
+ * @param wallet - The wallet to list sessions for.
19
+ *
20
+ * @returns The sessions.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { Wallet } from 'wallet';
25
+ *
26
+ * const sessions = await listZksyncSessions(Wallet);
27
+ * ```
28
+ */
29
+ const listZksyncSessions = (wallet) => __awaiter(void 0, void 0, void 0, function* () {
30
+ if (!isEthereumWallet(wallet)) {
31
+ throw new Error('Wallet is not an Ethereum wallet');
32
+ }
33
+ const client = getClient(wallet);
34
+ const chainId = getCurrentEthereumNetworkId(client);
35
+ if (!chainId) {
36
+ throw new Error('No chain id found');
37
+ }
38
+ const { data } = yield getCore(client).request({
39
+ args: {
40
+ chainId,
41
+ method: 'zksync_listSessions',
42
+ params: [wallet.address],
43
+ },
44
+ connection: getActiveConnection(client),
45
+ name: 'zksync-request',
46
+ });
47
+ return data;
48
+ });
49
+
50
+ export { listZksyncSessions };
@@ -0,0 +1 @@
1
+ export * from './revokeZksyncSession';
@@ -0,0 +1,54 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../_virtual/_tslib.cjs');
7
+ var isEthereumWallet = require('../isEthereumWallet/isEthereumWallet.cjs');
8
+ require('eventemitter3');
9
+ require('@dynamic-labs/logger');
10
+ require('@dynamic-labs/store');
11
+ var getActiveConnection = require('../getActiveConnection/getActiveConnection.cjs');
12
+ require('../../errors/DisconnectError.cjs');
13
+ require('@dynamic-labs/utils');
14
+ require('../../constants/logger.cjs');
15
+ var getCore = require('../../client/getCore/getCore.cjs');
16
+ var getClient = require('../../client/getClient/getClient.cjs');
17
+ var getCurrentEthereumNetworkId = require('../getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.cjs');
18
+
19
+ /**
20
+ * Revokes a session with the wallet.
21
+ *
22
+ * @param wallet - The wallet to revoke the session with.
23
+ * @param sessionId - The session id to revoke.
24
+ *
25
+ * @returns void
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { Wallet } from 'wallet';
30
+ *
31
+ * await revokeZksyncSession(Wallet, { sessionId });
32
+ * ```
33
+ */
34
+ const revokeZksyncSession = (wallet_1, _a) => _tslib.__awaiter(void 0, [wallet_1, _a], void 0, function* (wallet, { sessionId }) {
35
+ if (!isEthereumWallet.isEthereumWallet(wallet)) {
36
+ throw new Error('Wallet is not an Ethereum wallet');
37
+ }
38
+ const client = getClient.getClient(wallet);
39
+ const chainId = getCurrentEthereumNetworkId.getCurrentEthereumNetworkId(client);
40
+ if (!chainId) {
41
+ throw new Error('No chain id found');
42
+ }
43
+ yield getCore.getCore(client).request({
44
+ args: {
45
+ chainId,
46
+ method: 'zksync_revokeSession',
47
+ params: [wallet.address, sessionId],
48
+ },
49
+ connection: getActiveConnection.getActiveConnection(client),
50
+ name: 'zksync-request',
51
+ });
52
+ });
53
+
54
+ exports.revokeZksyncSession = revokeZksyncSession;
@@ -0,0 +1,21 @@
1
+ import { BaseWallet } from '@dynamic-labs/types';
2
+ type RevokeZksyncSessionParams = {
3
+ sessionId: string;
4
+ };
5
+ /**
6
+ * Revokes a session with the wallet.
7
+ *
8
+ * @param wallet - The wallet to revoke the session with.
9
+ * @param sessionId - The session id to revoke.
10
+ *
11
+ * @returns void
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { Wallet } from 'wallet';
16
+ *
17
+ * await revokeZksyncSession(Wallet, { sessionId });
18
+ * ```
19
+ */
20
+ export declare const revokeZksyncSession: (wallet: BaseWallet, { sessionId }: RevokeZksyncSessionParams) => Promise<void>;
21
+ export {};
@@ -0,0 +1,50 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../_virtual/_tslib.js';
3
+ import { isEthereumWallet } from '../isEthereumWallet/isEthereumWallet.js';
4
+ import 'eventemitter3';
5
+ import '@dynamic-labs/logger';
6
+ import '@dynamic-labs/store';
7
+ import { getActiveConnection } from '../getActiveConnection/getActiveConnection.js';
8
+ import '../../errors/DisconnectError.js';
9
+ import '@dynamic-labs/utils';
10
+ import '../../constants/logger.js';
11
+ import { getCore } from '../../client/getCore/getCore.js';
12
+ import { getClient } from '../../client/getClient/getClient.js';
13
+ import { getCurrentEthereumNetworkId } from '../getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.js';
14
+
15
+ /**
16
+ * Revokes a session with the wallet.
17
+ *
18
+ * @param wallet - The wallet to revoke the session with.
19
+ * @param sessionId - The session id to revoke.
20
+ *
21
+ * @returns void
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { Wallet } from 'wallet';
26
+ *
27
+ * await revokeZksyncSession(Wallet, { sessionId });
28
+ * ```
29
+ */
30
+ const revokeZksyncSession = (wallet_1, _a) => __awaiter(void 0, [wallet_1, _a], void 0, function* (wallet, { sessionId }) {
31
+ if (!isEthereumWallet(wallet)) {
32
+ throw new Error('Wallet is not an Ethereum wallet');
33
+ }
34
+ const client = getClient(wallet);
35
+ const chainId = getCurrentEthereumNetworkId(client);
36
+ if (!chainId) {
37
+ throw new Error('No chain id found');
38
+ }
39
+ yield getCore(client).request({
40
+ args: {
41
+ chainId,
42
+ method: 'zksync_revokeSession',
43
+ params: [wallet.address, sessionId],
44
+ },
45
+ connection: getActiveConnection(client),
46
+ name: 'zksync-request',
47
+ });
48
+ });
49
+
50
+ export { revokeZksyncSession };
@@ -26,13 +26,13 @@ const signEthereumMessage = (wallet_1, _a) => _tslib.__awaiter(void 0, [wallet_1
26
26
  throw new Error('No chain id found');
27
27
  }
28
28
  const { data } = yield getCore.getCore(client).request({
29
- connection: getActiveConnection.getActiveConnection(client),
30
- params: {
29
+ args: {
31
30
  chainId,
32
31
  method: 'personal_sign',
33
32
  params: [message, wallet.address],
34
33
  },
35
- pathname: 'eth-request',
34
+ connection: getActiveConnection.getActiveConnection(client),
35
+ name: 'eth-request',
36
36
  });
37
37
  return { signature: data, signedMessage: message };
38
38
  });
@@ -22,13 +22,13 @@ const signEthereumMessage = (wallet_1, _a) => __awaiter(void 0, [wallet_1, _a],
22
22
  throw new Error('No chain id found');
23
23
  }
24
24
  const { data } = yield getCore(client).request({
25
- connection: getActiveConnection(client),
26
- params: {
25
+ args: {
27
26
  chainId,
28
27
  method: 'personal_sign',
29
28
  params: [message, wallet.address],
30
29
  },
31
- pathname: 'eth-request',
30
+ connection: getActiveConnection(client),
31
+ name: 'eth-request',
32
32
  });
33
33
  return { signature: data, signedMessage: message };
34
34
  });
@@ -16,14 +16,14 @@ var getClient = require('../../client/getClient/getClient.cjs');
16
16
 
17
17
  const signSolanaMessage = (wallet_1, _a) => _tslib.__awaiter(void 0, [wallet_1, _a], void 0, function* (wallet, { message }) {
18
18
  const client = getClient.getClient(wallet);
19
- const params = {
19
+ const args = {
20
20
  address: wallet.address,
21
21
  message: utils.uint8ArrayToBase64(new TextEncoder().encode(message)),
22
22
  };
23
23
  const { signature, signedMessage } = yield getCore.getCore(client).request({
24
+ args,
24
25
  connection: getActiveConnection.getActiveConnection(client),
25
- params,
26
- pathname: 'solana_signMessage',
26
+ name: 'solana_signMessage',
27
27
  });
28
28
  return { signature, signedMessage };
29
29
  });
@@ -12,14 +12,14 @@ import { getClient } from '../../client/getClient/getClient.js';
12
12
 
13
13
  const signSolanaMessage = (wallet_1, _a) => __awaiter(void 0, [wallet_1, _a], void 0, function* (wallet, { message }) {
14
14
  const client = getClient(wallet);
15
- const params = {
15
+ const args = {
16
16
  address: wallet.address,
17
17
  message: uint8ArrayToBase64(new TextEncoder().encode(message)),
18
18
  };
19
19
  const { signature, signedMessage } = yield getCore(client).request({
20
+ args,
20
21
  connection: getActiveConnection(client),
21
- params,
22
- pathname: 'solana_signMessage',
22
+ name: 'solana_signMessage',
23
23
  });
24
24
  return { signature, signedMessage };
25
25
  });
@@ -18,13 +18,13 @@ const createSolanaSignAndSendTransactionFeature = (client) => ({
18
18
  signAndSendTransaction: (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ account, transaction, chain }) {
19
19
  const { signature } = yield getCore.getCore(client)
20
20
  .request({
21
- connection: getActiveConnection.getActiveConnection(client),
22
- params: {
21
+ args: {
23
22
  address: account.address,
24
23
  chain: chain,
25
24
  transaction: utils.uint8ArrayToBase64(transaction),
26
25
  },
27
- pathname: 'solana_signAndSendTransaction',
26
+ connection: getActiveConnection.getActiveConnection(client),
27
+ name: 'solana_signAndSendTransaction',
28
28
  })
29
29
  .catch(convertErrorToStandard.convertErrorToStandard);
30
30
  return [
@@ -14,13 +14,13 @@ const createSolanaSignAndSendTransactionFeature = (client) => ({
14
14
  signAndSendTransaction: (_a) => __awaiter(void 0, [_a], void 0, function* ({ account, transaction, chain }) {
15
15
  const { signature } = yield getCore(client)
16
16
  .request({
17
- connection: getActiveConnection(client),
18
- params: {
17
+ args: {
19
18
  address: account.address,
20
19
  chain: chain,
21
20
  transaction: uint8ArrayToBase64(transaction),
22
21
  },
23
- pathname: 'solana_signAndSendTransaction',
22
+ connection: getActiveConnection(client),
23
+ name: 'solana_signAndSendTransaction',
24
24
  })
25
25
  .catch(convertErrorToStandard);
26
26
  return [
@@ -16,15 +16,15 @@ var convertErrorToStandard = require('../convertErrorToStandard/convertErrorToSt
16
16
 
17
17
  const createSolanaSignMessageFeature = (client) => ({
18
18
  signMessage: (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ account, message }) {
19
- const params = {
19
+ const args = {
20
20
  address: account.address,
21
21
  message: utils.uint8ArrayToBase64(message),
22
22
  };
23
23
  const { signature, signedMessage } = yield getCore.getCore(client)
24
24
  .request({
25
+ args,
25
26
  connection: getActiveConnection.getActiveConnection(client),
26
- params,
27
- pathname: 'solana_signMessage',
27
+ name: 'solana_signMessage',
28
28
  })
29
29
  .catch(convertErrorToStandard.convertErrorToStandard);
30
30
  return [
@@ -12,15 +12,15 @@ import { convertErrorToStandard } from '../convertErrorToStandard/convertErrorTo
12
12
 
13
13
  const createSolanaSignMessageFeature = (client) => ({
14
14
  signMessage: (_a) => __awaiter(void 0, [_a], void 0, function* ({ account, message }) {
15
- const params = {
15
+ const args = {
16
16
  address: account.address,
17
17
  message: uint8ArrayToBase64(message),
18
18
  };
19
19
  const { signature, signedMessage } = yield getCore(client)
20
20
  .request({
21
+ args,
21
22
  connection: getActiveConnection(client),
22
- params,
23
- pathname: 'solana_signMessage',
23
+ name: 'solana_signMessage',
24
24
  })
25
25
  .catch(convertErrorToStandard);
26
26
  return [
@@ -18,13 +18,13 @@ const createSolanaSignTransactionFeature = (client) => ({
18
18
  signTransaction: (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ account, transaction, chain }) {
19
19
  const { signedTransaction } = yield getCore.getCore(client)
20
20
  .request({
21
- connection: getActiveConnection.getActiveConnection(client),
22
- params: {
21
+ args: {
23
22
  address: account.address,
24
23
  chain: chain,
25
24
  transaction: utils.uint8ArrayToBase64(transaction),
26
25
  },
27
- pathname: 'solana_signTransaction',
26
+ connection: getActiveConnection.getActiveConnection(client),
27
+ name: 'solana_signTransaction',
28
28
  })
29
29
  .catch(convertErrorToStandard.convertErrorToStandard);
30
30
  return [
@@ -14,13 +14,13 @@ const createSolanaSignTransactionFeature = (client) => ({
14
14
  signTransaction: (_a) => __awaiter(void 0, [_a], void 0, function* ({ account, transaction, chain }) {
15
15
  const { signedTransaction } = yield getCore(client)
16
16
  .request({
17
- connection: getActiveConnection(client),
18
- params: {
17
+ args: {
19
18
  address: account.address,
20
19
  chain: chain,
21
20
  transaction: uint8ArrayToBase64(transaction),
22
21
  },
23
- pathname: 'solana_signTransaction',
22
+ connection: getActiveConnection(client),
23
+ name: 'solana_signTransaction',
24
24
  })
25
25
  .catch(convertErrorToStandard);
26
26
  return [
package/src/zksync.cjs ADDED
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var createZksyncSession = require('./lib/functions/createZksyncSession/createZksyncSession.cjs');
7
+ var listZksyncSessions = require('./lib/functions/listZksyncSessions/listZksyncSessions.cjs');
8
+ var revokeZksyncSession = require('./lib/functions/revokeZksyncSession/revokeZksyncSession.cjs');
9
+
10
+
11
+
12
+ exports.createZksyncSession = createZksyncSession.createZksyncSession;
13
+ exports.listZksyncSessions = listZksyncSessions.listZksyncSessions;
14
+ exports.revokeZksyncSession = revokeZksyncSession.revokeZksyncSession;
@@ -0,0 +1,3 @@
1
+ export { createZksyncSession } from './lib/functions/createZksyncSession';
2
+ export { listZksyncSessions } from './lib/functions/listZksyncSessions';
3
+ export { revokeZksyncSession } from './lib/functions/revokeZksyncSession';
package/src/zksync.js ADDED
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ export { createZksyncSession } from './lib/functions/createZksyncSession/createZksyncSession.js';
3
+ export { listZksyncSessions } from './lib/functions/listZksyncSessions/listZksyncSessions.js';
4
+ export { revokeZksyncSession } from './lib/functions/revokeZksyncSession/revokeZksyncSession.js';