@unicitylabs/sphere-sdk 0.4.2 → 0.4.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/core/index.cjs +37 -10
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +37 -10
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +183 -104
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +183 -104
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/index.cjs +37 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -10
- package/dist/index.js.map +1 -1
- package/dist/l1/index.cjs +21 -3
- package/dist/l1/index.cjs.map +1 -1
- package/dist/l1/index.js +21 -3
- package/dist/l1/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.js
CHANGED
|
@@ -699,6 +699,12 @@ var VestingClassifier = class {
|
|
|
699
699
|
};
|
|
700
700
|
request.onsuccess = (event) => {
|
|
701
701
|
this.db = event.target.result;
|
|
702
|
+
this.db.onversionchange = () => {
|
|
703
|
+
if (this.db) {
|
|
704
|
+
this.db.close();
|
|
705
|
+
this.db = null;
|
|
706
|
+
}
|
|
707
|
+
};
|
|
702
708
|
resolve();
|
|
703
709
|
};
|
|
704
710
|
request.onerror = () => reject(request.error);
|
|
@@ -907,9 +913,21 @@ var VestingClassifier = class {
|
|
|
907
913
|
if (typeof indexedDB !== "undefined") {
|
|
908
914
|
await new Promise((resolve) => {
|
|
909
915
|
const req = indexedDB.deleteDatabase(this.dbName);
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
916
|
+
const timer = setTimeout(() => {
|
|
917
|
+
console.warn(`[VestingClassifier] destroy: deleteDatabase timed out for ${this.dbName}`);
|
|
918
|
+
resolve();
|
|
919
|
+
}, 3e3);
|
|
920
|
+
req.onsuccess = () => {
|
|
921
|
+
clearTimeout(timer);
|
|
922
|
+
resolve();
|
|
923
|
+
};
|
|
924
|
+
req.onerror = () => {
|
|
925
|
+
clearTimeout(timer);
|
|
926
|
+
resolve();
|
|
927
|
+
};
|
|
928
|
+
req.onblocked = () => {
|
|
929
|
+
console.warn(`[VestingClassifier] destroy: deleteDatabase blocked for ${this.dbName}, waiting...`);
|
|
930
|
+
};
|
|
913
931
|
});
|
|
914
932
|
}
|
|
915
933
|
}
|
|
@@ -12528,14 +12546,17 @@ var Sphere = class _Sphere {
|
|
|
12528
12546
|
if (!wasConnected) {
|
|
12529
12547
|
await storage.connect();
|
|
12530
12548
|
}
|
|
12531
|
-
|
|
12532
|
-
|
|
12533
|
-
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
|
|
12549
|
+
try {
|
|
12550
|
+
const mnemonic = await storage.get(STORAGE_KEYS_GLOBAL.MNEMONIC);
|
|
12551
|
+
if (mnemonic) return true;
|
|
12552
|
+
const masterKey = await storage.get(STORAGE_KEYS_GLOBAL.MASTER_KEY);
|
|
12553
|
+
if (masterKey) return true;
|
|
12554
|
+
return false;
|
|
12555
|
+
} finally {
|
|
12556
|
+
if (!wasConnected) {
|
|
12557
|
+
await storage.disconnect();
|
|
12558
|
+
}
|
|
12537
12559
|
}
|
|
12538
|
-
return false;
|
|
12539
12560
|
} catch {
|
|
12540
12561
|
return false;
|
|
12541
12562
|
}
|
|
@@ -12669,6 +12690,9 @@ var Sphere = class _Sphere {
|
|
|
12669
12690
|
if (await _Sphere.exists(options.storage)) {
|
|
12670
12691
|
throw new Error("Wallet already exists. Use Sphere.load() or Sphere.clear() first.");
|
|
12671
12692
|
}
|
|
12693
|
+
if (!options.storage.isConnected()) {
|
|
12694
|
+
await options.storage.connect();
|
|
12695
|
+
}
|
|
12672
12696
|
_Sphere.configureTokenRegistry(options.storage, options.network);
|
|
12673
12697
|
const groupChatConfig = _Sphere.resolveGroupChatConfig(options.groupChat, options.network);
|
|
12674
12698
|
const marketConfig = _Sphere.resolveMarketConfig(options.market);
|
|
@@ -12720,6 +12744,9 @@ var Sphere = class _Sphere {
|
|
|
12720
12744
|
marketConfig
|
|
12721
12745
|
);
|
|
12722
12746
|
sphere._password = options.password ?? null;
|
|
12747
|
+
if (!options.storage.isConnected()) {
|
|
12748
|
+
await options.storage.connect();
|
|
12749
|
+
}
|
|
12723
12750
|
await sphere.loadIdentityFromStorage();
|
|
12724
12751
|
await sphere.initializeProviders();
|
|
12725
12752
|
await sphere.initializeModules();
|