@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.
@@ -12618,14 +12618,17 @@ var Sphere = class _Sphere {
12618
12618
  if (!wasConnected) {
12619
12619
  await storage.connect();
12620
12620
  }
12621
- const mnemonic = await storage.get(STORAGE_KEYS_GLOBAL.MNEMONIC);
12622
- if (mnemonic) return true;
12623
- const masterKey = await storage.get(STORAGE_KEYS_GLOBAL.MASTER_KEY);
12624
- if (masterKey) return true;
12625
- if (!wasConnected) {
12626
- await storage.disconnect();
12621
+ try {
12622
+ const mnemonic = await storage.get(STORAGE_KEYS_GLOBAL.MNEMONIC);
12623
+ if (mnemonic) return true;
12624
+ const masterKey = await storage.get(STORAGE_KEYS_GLOBAL.MASTER_KEY);
12625
+ if (masterKey) return true;
12626
+ return false;
12627
+ } finally {
12628
+ if (!wasConnected) {
12629
+ await storage.disconnect();
12630
+ }
12627
12631
  }
12628
- return false;
12629
12632
  } catch {
12630
12633
  return false;
12631
12634
  }
@@ -12759,6 +12762,9 @@ var Sphere = class _Sphere {
12759
12762
  if (await _Sphere.exists(options.storage)) {
12760
12763
  throw new Error("Wallet already exists. Use Sphere.load() or Sphere.clear() first.");
12761
12764
  }
12765
+ if (!options.storage.isConnected()) {
12766
+ await options.storage.connect();
12767
+ }
12762
12768
  _Sphere.configureTokenRegistry(options.storage, options.network);
12763
12769
  const groupChatConfig = _Sphere.resolveGroupChatConfig(options.groupChat, options.network);
12764
12770
  const marketConfig = _Sphere.resolveMarketConfig(options.market);
@@ -12810,6 +12816,9 @@ var Sphere = class _Sphere {
12810
12816
  marketConfig
12811
12817
  );
12812
12818
  sphere._password = options.password ?? null;
12819
+ if (!options.storage.isConnected()) {
12820
+ await options.storage.connect();
12821
+ }
12813
12822
  await sphere.loadIdentityFromStorage();
12814
12823
  await sphere.initializeProviders();
12815
12824
  await sphere.initializeModules();