@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.
package/dist/index.cjs CHANGED
@@ -12895,14 +12895,17 @@ var Sphere = class _Sphere {
12895
12895
  if (!wasConnected) {
12896
12896
  await storage.connect();
12897
12897
  }
12898
- const mnemonic = await storage.get(STORAGE_KEYS_GLOBAL.MNEMONIC);
12899
- if (mnemonic) return true;
12900
- const masterKey = await storage.get(STORAGE_KEYS_GLOBAL.MASTER_KEY);
12901
- if (masterKey) return true;
12902
- if (!wasConnected) {
12903
- await storage.disconnect();
12898
+ try {
12899
+ const mnemonic = await storage.get(STORAGE_KEYS_GLOBAL.MNEMONIC);
12900
+ if (mnemonic) return true;
12901
+ const masterKey = await storage.get(STORAGE_KEYS_GLOBAL.MASTER_KEY);
12902
+ if (masterKey) return true;
12903
+ return false;
12904
+ } finally {
12905
+ if (!wasConnected) {
12906
+ await storage.disconnect();
12907
+ }
12904
12908
  }
12905
- return false;
12906
12909
  } catch {
12907
12910
  return false;
12908
12911
  }
@@ -13036,6 +13039,9 @@ var Sphere = class _Sphere {
13036
13039
  if (await _Sphere.exists(options.storage)) {
13037
13040
  throw new Error("Wallet already exists. Use Sphere.load() or Sphere.clear() first.");
13038
13041
  }
13042
+ if (!options.storage.isConnected()) {
13043
+ await options.storage.connect();
13044
+ }
13039
13045
  _Sphere.configureTokenRegistry(options.storage, options.network);
13040
13046
  const groupChatConfig = _Sphere.resolveGroupChatConfig(options.groupChat, options.network);
13041
13047
  const marketConfig = _Sphere.resolveMarketConfig(options.market);
@@ -13087,6 +13093,9 @@ var Sphere = class _Sphere {
13087
13093
  marketConfig
13088
13094
  );
13089
13095
  sphere._password = options.password ?? null;
13096
+ if (!options.storage.isConnected()) {
13097
+ await options.storage.connect();
13098
+ }
13090
13099
  await sphere.loadIdentityFromStorage();
13091
13100
  await sphere.initializeProviders();
13092
13101
  await sphere.initializeModules();