@dynamic-labs/aptos 4.44.3 → 4.44.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,17 @@
1
1
 
2
+ ### [4.44.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.44.3...v4.44.4) (2025-11-11)
3
+
4
+
5
+ ### Features
6
+
7
+ * **react-native:** add mfa modals ([5f79b6a](https://github.com/dynamic-labs/dynamic-auth/commit/5f79b6a1be5eb8fc3fbf37890ea5028003c38e93))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * allow aptos chain ids to be normalized to number ([#9860](https://github.com/dynamic-labs/dynamic-auth/issues/9860)) ([1dbaaec](https://github.com/dynamic-labs/dynamic-auth/commit/1dbaaecb74316ea1a33b587acebe27c1cdac663f))
13
+ * ensure even late announced aptos wallets are returned in wallet list ([#9855](https://github.com/dynamic-labs/dynamic-auth/issues/9855)) ([c807a5f](https://github.com/dynamic-labs/dynamic-auth/commit/c807a5f0c519948ae94a14055bddac9b679c98eb))
14
+
2
15
  ### [4.44.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.44.2...v4.44.3) (2025-11-10)
3
16
 
4
17
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.44.3";
6
+ var version = "4.44.4";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.44.3";
2
+ var version = "4.44.4";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/aptos",
3
- "version": "4.44.3",
3
+ "version": "4.44.4",
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",
@@ -20,14 +20,14 @@
20
20
  "dependencies": {
21
21
  "@aptos-labs/ts-sdk": "5.1.1",
22
22
  "@aptos-labs/wallet-standard": "0.5.2",
23
- "@dynamic-labs/assert-package-version": "4.44.3",
23
+ "@dynamic-labs/assert-package-version": "4.44.4",
24
24
  "@wallet-standard/core": "1.1.1",
25
25
  "@wallet-standard/features": "1.0.3",
26
- "@dynamic-labs/logger": "4.44.3",
27
- "@dynamic-labs/types": "4.44.3",
28
- "@dynamic-labs/utils": "4.44.3",
29
- "@dynamic-labs/wallet-book": "4.44.3",
30
- "@dynamic-labs/wallet-connector-core": "4.44.3"
26
+ "@dynamic-labs/logger": "4.44.4",
27
+ "@dynamic-labs/types": "4.44.4",
28
+ "@dynamic-labs/utils": "4.44.4",
29
+ "@dynamic-labs/wallet-book": "4.44.4",
30
+ "@dynamic-labs/wallet-connector-core": "4.44.4"
31
31
  },
32
32
  "peerDependencies": {}
33
33
  }
@@ -14,6 +14,7 @@ var parseConnectionResult = require('../../utils/parseConnectionResult/parseConn
14
14
  var parseTransactionResponse = require('../../utils/parseTransactionResponse/parseTransactionResponse.cjs');
15
15
  var AptosUiTransaction = require('../../utils/AptosUiTransaction/AptosUiTransaction.cjs');
16
16
  var AptosWallet = require('../../wallet/AptosWallet.cjs');
17
+ var normalizeAptosChainIds = require('../../utils/normalizeAptosChainIds/normalizeAptosChainIds.cjs');
17
18
 
18
19
  /**
19
20
  * Abstract base class for all Aptos wallet connectors.
@@ -46,7 +47,7 @@ class AptosWalletConnector extends walletConnectorCore.WalletConnectorBase {
46
47
  assertProvider.assertProvider(provider);
47
48
  const network = yield invokeWalletMethod.invokeWalletMethod(provider, 'aptos:network', 'network');
48
49
  if (network === null || network === void 0 ? void 0 : network.chainId) {
49
- return network.chainId.toString();
50
+ return normalizeAptosChainIds.normalizeAptosChainIds(network.chainId).toString();
50
51
  }
51
52
  // default to mainnet
52
53
  return '1';
@@ -10,6 +10,7 @@ import { parseConnectionResult } from '../../utils/parseConnectionResult/parseCo
10
10
  import { parseTransactionResponse } from '../../utils/parseTransactionResponse/parseTransactionResponse.js';
11
11
  import { AptosUiTransaction } from '../../utils/AptosUiTransaction/AptosUiTransaction.js';
12
12
  import { AptosWallet } from '../../wallet/AptosWallet.js';
13
+ import { normalizeAptosChainIds } from '../../utils/normalizeAptosChainIds/normalizeAptosChainIds.js';
13
14
 
14
15
  /**
15
16
  * Abstract base class for all Aptos wallet connectors.
@@ -42,7 +43,7 @@ class AptosWalletConnector extends WalletConnectorBase {
42
43
  assertProvider(provider);
43
44
  const network = yield invokeWalletMethod(provider, 'aptos:network', 'network');
44
45
  if (network === null || network === void 0 ? void 0 : network.chainId) {
45
- return network.chainId.toString();
46
+ return normalizeAptosChainIds(network.chainId).toString();
46
47
  }
47
48
  // default to mainnet
48
49
  return '1';
@@ -14,6 +14,7 @@ var getConnectorConstructorForWalletStandardWallet = require('../walletStandard/
14
14
  var InjectedWalletBase = require('./InjectedWalletBase.cjs');
15
15
 
16
16
  const logger = new logger$1.Logger('fetchInjectedWalletConnectors');
17
+ let removeAptosWalletStandardListener = null;
17
18
  /**
18
19
  * List of wallet keys that have custom connector implementations.
19
20
  * These wallets will not use the automatic wallet-standard connector.
@@ -73,6 +74,31 @@ const shouldAddWalletStandardConnector = (wallet, walletBook) => {
73
74
  });
74
75
  return !shouldHandleFromWalletBook && hasAllFeatures;
75
76
  };
77
+ const addAptosWalletStandardListener = (walletBook$1) => {
78
+ // check to ensure this method doesn't run with SSR
79
+ if (typeof window === 'undefined') {
80
+ return;
81
+ }
82
+ removeAptosWalletStandardListener === null || removeAptosWalletStandardListener === void 0 ? void 0 : removeAptosWalletStandardListener();
83
+ const { on } = getWalletStandardWallets.getWalletStandardWallets();
84
+ removeAptosWalletStandardListener = on('register', (wallet) => {
85
+ if (!shouldAddWalletStandardConnector(wallet, walletBook$1)) {
86
+ return;
87
+ }
88
+ logger.logVerboseTroubleshootingMessage('[APTOS fetchInjectedWalletConnectors] Wallet registered via wallet-standard', wallet.name);
89
+ const walletBookWallet = walletBook.findWalletBookWalletByNameAndChain(walletBook$1, wallet.name, 'aptos');
90
+ const walletBookMetadata = walletBookWallet &&
91
+ walletConnectorCore.getWalletMetadataFromWalletBook({
92
+ walletBook: walletBook$1,
93
+ walletBookWallet,
94
+ walletKey: `${utils.sanitizeName(wallet.name)}aptos`,
95
+ });
96
+ const injectedConnectorConstructor = getConnectorConstructorForWalletStandardWallet.getConnectorConstructorForWalletStandardWallet(wallet, walletBookMetadata);
97
+ walletConnectorCore.walletConnectorEvents.emit('providerInjected', {
98
+ injectedConnectorConstructor,
99
+ });
100
+ });
101
+ };
76
102
  /**
77
103
  * Fetches all available injected Aptos wallet connectors.
78
104
  *
@@ -108,6 +134,7 @@ const shouldAddWalletStandardConnector = (wallet, walletBook) => {
108
134
  */
109
135
  const fetchInjectedWalletConnectors = ({ walletBook: walletBook$1, }) => {
110
136
  var _a;
137
+ addAptosWalletStandardListener(walletBook$1);
111
138
  // Get wallet-standard wallets (only installed wallets are discovered)
112
139
  const { aptosWallets } = getWalletStandardWallets.getWalletStandardWallets();
113
140
  // Create a map of wallet-standard wallet names for quick lookup
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { findWalletBookWalletByNameAndChain } from '@dynamic-labs/wallet-book';
3
- import { getWalletMetadataFromWalletBook } from '@dynamic-labs/wallet-connector-core';
3
+ import { getWalletMetadataFromWalletBook, walletConnectorEvents } from '@dynamic-labs/wallet-connector-core';
4
4
  import { sanitizeName } from '@dynamic-labs/utils';
5
5
  import { Logger } from '@dynamic-labs/logger';
6
6
  import { getWalletStandardWallets } from '../utils/getWalletStandardWallets/getWalletStandardWallets.js';
@@ -10,6 +10,7 @@ import { getConnectorConstructorForWalletStandardWallet } from '../walletStandar
10
10
  import { InjectedWalletBase } from './InjectedWalletBase.js';
11
11
 
12
12
  const logger = new Logger('fetchInjectedWalletConnectors');
13
+ let removeAptosWalletStandardListener = null;
13
14
  /**
14
15
  * List of wallet keys that have custom connector implementations.
15
16
  * These wallets will not use the automatic wallet-standard connector.
@@ -69,6 +70,31 @@ const shouldAddWalletStandardConnector = (wallet, walletBook) => {
69
70
  });
70
71
  return !shouldHandleFromWalletBook && hasAllFeatures;
71
72
  };
73
+ const addAptosWalletStandardListener = (walletBook) => {
74
+ // check to ensure this method doesn't run with SSR
75
+ if (typeof window === 'undefined') {
76
+ return;
77
+ }
78
+ removeAptosWalletStandardListener === null || removeAptosWalletStandardListener === void 0 ? void 0 : removeAptosWalletStandardListener();
79
+ const { on } = getWalletStandardWallets();
80
+ removeAptosWalletStandardListener = on('register', (wallet) => {
81
+ if (!shouldAddWalletStandardConnector(wallet, walletBook)) {
82
+ return;
83
+ }
84
+ logger.logVerboseTroubleshootingMessage('[APTOS fetchInjectedWalletConnectors] Wallet registered via wallet-standard', wallet.name);
85
+ const walletBookWallet = findWalletBookWalletByNameAndChain(walletBook, wallet.name, 'aptos');
86
+ const walletBookMetadata = walletBookWallet &&
87
+ getWalletMetadataFromWalletBook({
88
+ walletBook,
89
+ walletBookWallet,
90
+ walletKey: `${sanitizeName(wallet.name)}aptos`,
91
+ });
92
+ const injectedConnectorConstructor = getConnectorConstructorForWalletStandardWallet(wallet, walletBookMetadata);
93
+ walletConnectorEvents.emit('providerInjected', {
94
+ injectedConnectorConstructor,
95
+ });
96
+ });
97
+ };
72
98
  /**
73
99
  * Fetches all available injected Aptos wallet connectors.
74
100
  *
@@ -104,6 +130,7 @@ const shouldAddWalletStandardConnector = (wallet, walletBook) => {
104
130
  */
105
131
  const fetchInjectedWalletConnectors = ({ walletBook, }) => {
106
132
  var _a;
133
+ addAptosWalletStandardListener(walletBook);
107
134
  // Get wallet-standard wallets (only installed wallets are discovered)
108
135
  const { aptosWallets } = getWalletStandardWallets();
109
136
  // Create a map of wallet-standard wallet names for quick lookup
@@ -7,12 +7,82 @@ var walletStandard = require('@aptos-labs/wallet-standard');
7
7
  var logger$1 = require('@dynamic-labs/logger');
8
8
 
9
9
  const logger = new logger$1.Logger('getWalletStandardWallets');
10
+ /**
11
+ * Module-level cache for storing the current list of Aptos wallets.
12
+ * This cache is updated automatically when wallets register/unregister.
13
+ */
14
+ let cachedAptosWallets = [];
15
+ /**
16
+ * Module-level flag to track if the subscription has been initialized.
17
+ */
18
+ let isSubscriptionInitialized = false;
19
+ /**
20
+ * Filters wallets to return only those that support the required Aptos feature set.
21
+ *
22
+ * @param wallets - Array of wallets to filter
23
+ * @returns Array of Aptos-compatible wallets
24
+ */
25
+ const filterAptosWallets = (wallets) => {
26
+ const foundAptosWallets = [];
27
+ wallets.forEach((wallet) => {
28
+ try {
29
+ const isAptos = walletStandard.isWalletWithRequiredFeatureSet(wallet);
30
+ if (isAptos) {
31
+ foundAptosWallets.push(wallet);
32
+ }
33
+ }
34
+ catch (error) {
35
+ // Log error for individual wallet but continue processing others
36
+ logger.debug('[getWalletStandardWallets] Error checking wallet features:', error);
37
+ }
38
+ });
39
+ return foundAptosWallets;
40
+ };
41
+ /**
42
+ * Initializes the wallet subscription to listen for wallet registration/unregistration events.
43
+ * This function sets up event listeners that automatically update the cached wallet list.
44
+ *
45
+ * @param on - The event listener function from the wallet standard API
46
+ */
47
+ const initializeSubscription = (on) => {
48
+ if (isSubscriptionInitialized) {
49
+ return;
50
+ }
51
+ logger.debug('[getWalletStandardWallets] Initializing wallet subscription');
52
+ // Subscribe to wallet registration events
53
+ on('register', (wallet) => {
54
+ logger.debug('[getWalletStandardWallets] Wallet registered:', wallet.name);
55
+ try {
56
+ const isAptos = walletStandard.isWalletWithRequiredFeatureSet(wallet);
57
+ if (isAptos) {
58
+ const existingWallet = cachedAptosWallets.find((w) => w.name === wallet.name);
59
+ if (!existingWallet) {
60
+ cachedAptosWallets = [...cachedAptosWallets, wallet];
61
+ logger.debug('[getWalletStandardWallets] Added wallet to cache:', wallet.name);
62
+ }
63
+ }
64
+ }
65
+ catch (error) {
66
+ logger.debug('[getWalletStandardWallets] Error processing registered wallet:', error);
67
+ }
68
+ });
69
+ // Subscribe to wallet unregistration events
70
+ on('unregister', (wallet) => {
71
+ logger.debug('[getWalletStandardWallets] Wallet unregistered:', wallet.name);
72
+ cachedAptosWallets = cachedAptosWallets.filter((w) => w.name !== wallet.name);
73
+ });
74
+ isSubscriptionInitialized = true;
75
+ };
10
76
  /**
11
77
  * Retrieves all available Aptos-compatible wallets from the wallet standard registry.
12
78
  *
13
- * This function fetches all registered wallets and filters them to return only those
14
- * that support the required Aptos feature set. It also provides an event listener
15
- * function to monitor wallet registration events.
79
+ * This function maintains an internal cache of wallets that is automatically updated
80
+ * when wallets register or unregister themselves. The subscription is initialized on
81
+ * the first call and persists across subsequent calls.
82
+ *
83
+ * This solves the problem where some wallets take several seconds to announce themselves
84
+ * after page load. Instead of only capturing wallets available at the moment of the call,
85
+ * this function continuously listens for new wallets and updates the cache automatically.
16
86
  *
17
87
  * @returns An object containing:
18
88
  * - `aptosWallets`: Array of Aptos-compatible wallets that support required features
@@ -22,10 +92,10 @@ const logger = new logger$1.Logger('getWalletStandardWallets');
22
92
  * ```typescript
23
93
  * const { aptosWallets, on } = getWalletStandardWallets();
24
94
  *
25
- * // Use the Aptos wallets
95
+ * // Use the Aptos wallets (this list will be updated automatically as wallets register)
26
96
  * console.log('Available Aptos wallets:', aptosWallets);
27
97
  *
28
- * // Listen for new wallet registrations
98
+ * // Optionally listen for new wallet registrations yourself
29
99
  * const unsubscribe = on('register', (wallet) => {
30
100
  * console.log('New wallet registered:', wallet);
31
101
  * });
@@ -36,23 +106,16 @@ const logger = new logger$1.Logger('getWalletStandardWallets');
36
106
  */
37
107
  const getWalletStandardWallets = () => {
38
108
  try {
39
- const { aptosWallets } = walletStandard.getAptosWallets();
40
- const foundAptosWallets = [];
41
- aptosWallets.map((wallet) => {
42
- try {
43
- const isAptos = walletStandard.isWalletWithRequiredFeatureSet(wallet);
44
- if (isAptos) {
45
- foundAptosWallets.push(wallet);
46
- }
47
- }
48
- catch (error) {
49
- // Log error for individual wallet but continue processing others
50
- logger.debug('[getWalletStandardWallets] Error checking wallet features:', error);
51
- }
52
- });
109
+ const { aptosWallets, on } = walletStandard.getAptosWallets();
110
+ if (!isSubscriptionInitialized) {
111
+ cachedAptosWallets = filterAptosWallets(aptosWallets);
112
+ logger.debug('[getWalletStandardWallets] Initial wallets cached:', cachedAptosWallets.map((w) => w.name));
113
+ // Set up subscription to listen for future wallet registrations
114
+ initializeSubscription(on);
115
+ }
53
116
  return {
54
- aptosWallets: foundAptosWallets,
55
- on: () => () => { },
117
+ aptosWallets: cachedAptosWallets,
118
+ on,
56
119
  };
57
120
  }
58
121
  catch (error) {
@@ -3,9 +3,13 @@ import { AptosWallet } from '@aptos-labs/wallet-standard';
3
3
  /**
4
4
  * Retrieves all available Aptos-compatible wallets from the wallet standard registry.
5
5
  *
6
- * This function fetches all registered wallets and filters them to return only those
7
- * that support the required Aptos feature set. It also provides an event listener
8
- * function to monitor wallet registration events.
6
+ * This function maintains an internal cache of wallets that is automatically updated
7
+ * when wallets register or unregister themselves. The subscription is initialized on
8
+ * the first call and persists across subsequent calls.
9
+ *
10
+ * This solves the problem where some wallets take several seconds to announce themselves
11
+ * after page load. Instead of only capturing wallets available at the moment of the call,
12
+ * this function continuously listens for new wallets and updates the cache automatically.
9
13
  *
10
14
  * @returns An object containing:
11
15
  * - `aptosWallets`: Array of Aptos-compatible wallets that support required features
@@ -15,10 +19,10 @@ import { AptosWallet } from '@aptos-labs/wallet-standard';
15
19
  * ```typescript
16
20
  * const { aptosWallets, on } = getWalletStandardWallets();
17
21
  *
18
- * // Use the Aptos wallets
22
+ * // Use the Aptos wallets (this list will be updated automatically as wallets register)
19
23
  * console.log('Available Aptos wallets:', aptosWallets);
20
24
  *
21
- * // Listen for new wallet registrations
25
+ * // Optionally listen for new wallet registrations yourself
22
26
  * const unsubscribe = on('register', (wallet) => {
23
27
  * console.log('New wallet registered:', wallet);
24
28
  * });
@@ -31,3 +35,10 @@ export declare const getWalletStandardWallets: () => {
31
35
  aptosWallets: AptosWallet[];
32
36
  on: <E extends keyof WalletsEventsListeners>(event: E, listener: WalletsEventsListeners[E]) => () => void;
33
37
  };
38
+ /**
39
+ * Cleans up the wallet subscription and resets the cache.
40
+ * This function is primarily useful for testing purposes.
41
+ *
42
+ * @internal
43
+ */
44
+ export declare const resetWalletCache: () => void;
@@ -3,12 +3,82 @@ import { getAptosWallets, isWalletWithRequiredFeatureSet } from '@aptos-labs/wal
3
3
  import { Logger } from '@dynamic-labs/logger';
4
4
 
5
5
  const logger = new Logger('getWalletStandardWallets');
6
+ /**
7
+ * Module-level cache for storing the current list of Aptos wallets.
8
+ * This cache is updated automatically when wallets register/unregister.
9
+ */
10
+ let cachedAptosWallets = [];
11
+ /**
12
+ * Module-level flag to track if the subscription has been initialized.
13
+ */
14
+ let isSubscriptionInitialized = false;
15
+ /**
16
+ * Filters wallets to return only those that support the required Aptos feature set.
17
+ *
18
+ * @param wallets - Array of wallets to filter
19
+ * @returns Array of Aptos-compatible wallets
20
+ */
21
+ const filterAptosWallets = (wallets) => {
22
+ const foundAptosWallets = [];
23
+ wallets.forEach((wallet) => {
24
+ try {
25
+ const isAptos = isWalletWithRequiredFeatureSet(wallet);
26
+ if (isAptos) {
27
+ foundAptosWallets.push(wallet);
28
+ }
29
+ }
30
+ catch (error) {
31
+ // Log error for individual wallet but continue processing others
32
+ logger.debug('[getWalletStandardWallets] Error checking wallet features:', error);
33
+ }
34
+ });
35
+ return foundAptosWallets;
36
+ };
37
+ /**
38
+ * Initializes the wallet subscription to listen for wallet registration/unregistration events.
39
+ * This function sets up event listeners that automatically update the cached wallet list.
40
+ *
41
+ * @param on - The event listener function from the wallet standard API
42
+ */
43
+ const initializeSubscription = (on) => {
44
+ if (isSubscriptionInitialized) {
45
+ return;
46
+ }
47
+ logger.debug('[getWalletStandardWallets] Initializing wallet subscription');
48
+ // Subscribe to wallet registration events
49
+ on('register', (wallet) => {
50
+ logger.debug('[getWalletStandardWallets] Wallet registered:', wallet.name);
51
+ try {
52
+ const isAptos = isWalletWithRequiredFeatureSet(wallet);
53
+ if (isAptos) {
54
+ const existingWallet = cachedAptosWallets.find((w) => w.name === wallet.name);
55
+ if (!existingWallet) {
56
+ cachedAptosWallets = [...cachedAptosWallets, wallet];
57
+ logger.debug('[getWalletStandardWallets] Added wallet to cache:', wallet.name);
58
+ }
59
+ }
60
+ }
61
+ catch (error) {
62
+ logger.debug('[getWalletStandardWallets] Error processing registered wallet:', error);
63
+ }
64
+ });
65
+ // Subscribe to wallet unregistration events
66
+ on('unregister', (wallet) => {
67
+ logger.debug('[getWalletStandardWallets] Wallet unregistered:', wallet.name);
68
+ cachedAptosWallets = cachedAptosWallets.filter((w) => w.name !== wallet.name);
69
+ });
70
+ isSubscriptionInitialized = true;
71
+ };
6
72
  /**
7
73
  * Retrieves all available Aptos-compatible wallets from the wallet standard registry.
8
74
  *
9
- * This function fetches all registered wallets and filters them to return only those
10
- * that support the required Aptos feature set. It also provides an event listener
11
- * function to monitor wallet registration events.
75
+ * This function maintains an internal cache of wallets that is automatically updated
76
+ * when wallets register or unregister themselves. The subscription is initialized on
77
+ * the first call and persists across subsequent calls.
78
+ *
79
+ * This solves the problem where some wallets take several seconds to announce themselves
80
+ * after page load. Instead of only capturing wallets available at the moment of the call,
81
+ * this function continuously listens for new wallets and updates the cache automatically.
12
82
  *
13
83
  * @returns An object containing:
14
84
  * - `aptosWallets`: Array of Aptos-compatible wallets that support required features
@@ -18,10 +88,10 @@ const logger = new Logger('getWalletStandardWallets');
18
88
  * ```typescript
19
89
  * const { aptosWallets, on } = getWalletStandardWallets();
20
90
  *
21
- * // Use the Aptos wallets
91
+ * // Use the Aptos wallets (this list will be updated automatically as wallets register)
22
92
  * console.log('Available Aptos wallets:', aptosWallets);
23
93
  *
24
- * // Listen for new wallet registrations
94
+ * // Optionally listen for new wallet registrations yourself
25
95
  * const unsubscribe = on('register', (wallet) => {
26
96
  * console.log('New wallet registered:', wallet);
27
97
  * });
@@ -32,23 +102,16 @@ const logger = new Logger('getWalletStandardWallets');
32
102
  */
33
103
  const getWalletStandardWallets = () => {
34
104
  try {
35
- const { aptosWallets } = getAptosWallets();
36
- const foundAptosWallets = [];
37
- aptosWallets.map((wallet) => {
38
- try {
39
- const isAptos = isWalletWithRequiredFeatureSet(wallet);
40
- if (isAptos) {
41
- foundAptosWallets.push(wallet);
42
- }
43
- }
44
- catch (error) {
45
- // Log error for individual wallet but continue processing others
46
- logger.debug('[getWalletStandardWallets] Error checking wallet features:', error);
47
- }
48
- });
105
+ const { aptosWallets, on } = getAptosWallets();
106
+ if (!isSubscriptionInitialized) {
107
+ cachedAptosWallets = filterAptosWallets(aptosWallets);
108
+ logger.debug('[getWalletStandardWallets] Initial wallets cached:', cachedAptosWallets.map((w) => w.name));
109
+ // Set up subscription to listen for future wallet registrations
110
+ initializeSubscription(on);
111
+ }
49
112
  return {
50
- aptosWallets: foundAptosWallets,
51
- on: () => () => { },
113
+ aptosWallets: cachedAptosWallets,
114
+ on,
52
115
  };
53
116
  }
54
117
  catch (error) {
@@ -0,0 +1 @@
1
+ export { normalizeAptosChainIds } from './normalizeAptosChainIds';
@@ -0,0 +1,33 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var walletStandard = require('@aptos-labs/wallet-standard');
7
+
8
+ /**
9
+ * Normalizes the chain ID to a number.
10
+ * For example, some wallets (backpack) return chain ID as a string (aptos:mainnet/devnet/testnet)
11
+ * but the wallet standard expects the chain ID to be a number.
12
+ * This function converts the string to a number.
13
+ * @param chainId - The chain ID to normalize.
14
+ * @returns The normalized chain ID.
15
+ */
16
+ const normalizeAptosChainIds = (chainId) => {
17
+ if (typeof chainId === 'number') {
18
+ return chainId;
19
+ }
20
+ switch (chainId) {
21
+ case walletStandard.APTOS_MAINNET_CHAIN:
22
+ return 1;
23
+ case walletStandard.APTOS_TESTNET_CHAIN:
24
+ return 2;
25
+ case walletStandard.APTOS_DEVNET_CHAIN:
26
+ return 3;
27
+ default:
28
+ // default to mainnet
29
+ return 1;
30
+ }
31
+ };
32
+
33
+ exports.normalizeAptosChainIds = normalizeAptosChainIds;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Normalizes the chain ID to a number.
3
+ * For example, some wallets (backpack) return chain ID as a string (aptos:mainnet/devnet/testnet)
4
+ * but the wallet standard expects the chain ID to be a number.
5
+ * This function converts the string to a number.
6
+ * @param chainId - The chain ID to normalize.
7
+ * @returns The normalized chain ID.
8
+ */
9
+ export declare const normalizeAptosChainIds: (chainId: number | string) => number;
@@ -0,0 +1,29 @@
1
+ 'use client'
2
+ import { APTOS_DEVNET_CHAIN, APTOS_TESTNET_CHAIN, APTOS_MAINNET_CHAIN } from '@aptos-labs/wallet-standard';
3
+
4
+ /**
5
+ * Normalizes the chain ID to a number.
6
+ * For example, some wallets (backpack) return chain ID as a string (aptos:mainnet/devnet/testnet)
7
+ * but the wallet standard expects the chain ID to be a number.
8
+ * This function converts the string to a number.
9
+ * @param chainId - The chain ID to normalize.
10
+ * @returns The normalized chain ID.
11
+ */
12
+ const normalizeAptosChainIds = (chainId) => {
13
+ if (typeof chainId === 'number') {
14
+ return chainId;
15
+ }
16
+ switch (chainId) {
17
+ case APTOS_MAINNET_CHAIN:
18
+ return 1;
19
+ case APTOS_TESTNET_CHAIN:
20
+ return 2;
21
+ case APTOS_DEVNET_CHAIN:
22
+ return 3;
23
+ default:
24
+ // default to mainnet
25
+ return 1;
26
+ }
27
+ };
28
+
29
+ export { normalizeAptosChainIds };