@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.js CHANGED
@@ -12738,14 +12738,17 @@ var Sphere = class _Sphere {
12738
12738
  if (!wasConnected) {
12739
12739
  await storage.connect();
12740
12740
  }
12741
- const mnemonic = await storage.get(STORAGE_KEYS_GLOBAL.MNEMONIC);
12742
- if (mnemonic) return true;
12743
- const masterKey = await storage.get(STORAGE_KEYS_GLOBAL.MASTER_KEY);
12744
- if (masterKey) return true;
12745
- if (!wasConnected) {
12746
- await storage.disconnect();
12741
+ try {
12742
+ const mnemonic = await storage.get(STORAGE_KEYS_GLOBAL.MNEMONIC);
12743
+ if (mnemonic) return true;
12744
+ const masterKey = await storage.get(STORAGE_KEYS_GLOBAL.MASTER_KEY);
12745
+ if (masterKey) return true;
12746
+ return false;
12747
+ } finally {
12748
+ if (!wasConnected) {
12749
+ await storage.disconnect();
12750
+ }
12747
12751
  }
12748
- return false;
12749
12752
  } catch {
12750
12753
  return false;
12751
12754
  }
@@ -12879,6 +12882,9 @@ var Sphere = class _Sphere {
12879
12882
  if (await _Sphere.exists(options.storage)) {
12880
12883
  throw new Error("Wallet already exists. Use Sphere.load() or Sphere.clear() first.");
12881
12884
  }
12885
+ if (!options.storage.isConnected()) {
12886
+ await options.storage.connect();
12887
+ }
12882
12888
  _Sphere.configureTokenRegistry(options.storage, options.network);
12883
12889
  const groupChatConfig = _Sphere.resolveGroupChatConfig(options.groupChat, options.network);
12884
12890
  const marketConfig = _Sphere.resolveMarketConfig(options.market);
@@ -12930,6 +12936,9 @@ var Sphere = class _Sphere {
12930
12936
  marketConfig
12931
12937
  );
12932
12938
  sphere._password = options.password ?? null;
12939
+ if (!options.storage.isConnected()) {
12940
+ await options.storage.connect();
12941
+ }
12933
12942
  await sphere.loadIdentityFromStorage();
12934
12943
  await sphere.initializeProviders();
12935
12944
  await sphere.initializeModules();