@unicitylabs/sphere-sdk 0.4.2 → 0.4.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.
@@ -12528,14 +12528,17 @@ var Sphere = class _Sphere {
12528
12528
  if (!wasConnected) {
12529
12529
  await storage.connect();
12530
12530
  }
12531
- const mnemonic = await storage.get(STORAGE_KEYS_GLOBAL.MNEMONIC);
12532
- if (mnemonic) return true;
12533
- const masterKey = await storage.get(STORAGE_KEYS_GLOBAL.MASTER_KEY);
12534
- if (masterKey) return true;
12535
- if (!wasConnected) {
12536
- await storage.disconnect();
12531
+ try {
12532
+ const mnemonic = await storage.get(STORAGE_KEYS_GLOBAL.MNEMONIC);
12533
+ if (mnemonic) return true;
12534
+ const masterKey = await storage.get(STORAGE_KEYS_GLOBAL.MASTER_KEY);
12535
+ if (masterKey) return true;
12536
+ return false;
12537
+ } finally {
12538
+ if (!wasConnected) {
12539
+ await storage.disconnect();
12540
+ }
12537
12541
  }
12538
- return false;
12539
12542
  } catch {
12540
12543
  return false;
12541
12544
  }
@@ -12669,6 +12672,9 @@ var Sphere = class _Sphere {
12669
12672
  if (await _Sphere.exists(options.storage)) {
12670
12673
  throw new Error("Wallet already exists. Use Sphere.load() or Sphere.clear() first.");
12671
12674
  }
12675
+ if (!options.storage.isConnected()) {
12676
+ await options.storage.connect();
12677
+ }
12672
12678
  _Sphere.configureTokenRegistry(options.storage, options.network);
12673
12679
  const groupChatConfig = _Sphere.resolveGroupChatConfig(options.groupChat, options.network);
12674
12680
  const marketConfig = _Sphere.resolveMarketConfig(options.market);
@@ -12720,6 +12726,9 @@ var Sphere = class _Sphere {
12720
12726
  marketConfig
12721
12727
  );
12722
12728
  sphere._password = options.password ?? null;
12729
+ if (!options.storage.isConnected()) {
12730
+ await options.storage.connect();
12731
+ }
12723
12732
  await sphere.loadIdentityFromStorage();
12724
12733
  await sphere.initializeProviders();
12725
12734
  await sphere.initializeModules();