@txnlab/use-wallet 1.2.2 → 1.2.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/dist/cjs/index.js CHANGED
@@ -2401,12 +2401,25 @@ const initializeProviders = (providers, nodeConfig, algosdkStatic) => {
2401
2401
  return initializedProviders;
2402
2402
  };
2403
2403
 
2404
+ const getActiveProviders = () => {
2405
+ const accounts = useWalletStore.getState().accounts;
2406
+ return [...new Set(accounts.map((acct) => acct.providerId))];
2407
+ };
2408
+ const isActiveProvider = (id) => {
2409
+ const activeProviders = getActiveProviders();
2410
+ return activeProviders.includes(id);
2411
+ };
2412
+
2404
2413
  const reconnectProviders = async (providers) => {
2405
2414
  try {
2406
2415
  const clients = Object.values(providers);
2407
2416
  for (const client of clients) {
2408
2417
  const c = await client;
2409
- c?.reconnect(() => clearAccounts(c?.metadata.id));
2418
+ const id = c?.metadata.id;
2419
+ // Only reconnect to active providers
2420
+ if (id && isActiveProvider(id)) {
2421
+ c.reconnect(() => clearAccounts(id));
2422
+ }
2410
2423
  }
2411
2424
  }
2412
2425
  catch (e) {