@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/index.js
CHANGED
|
@@ -850,6 +850,12 @@ var VestingClassifier = class {
|
|
|
850
850
|
};
|
|
851
851
|
request.onsuccess = (event) => {
|
|
852
852
|
this.db = event.target.result;
|
|
853
|
+
this.db.onversionchange = () => {
|
|
854
|
+
if (this.db) {
|
|
855
|
+
this.db.close();
|
|
856
|
+
this.db = null;
|
|
857
|
+
}
|
|
858
|
+
};
|
|
853
859
|
resolve();
|
|
854
860
|
};
|
|
855
861
|
request.onerror = () => reject(request.error);
|
|
@@ -1058,9 +1064,21 @@ var VestingClassifier = class {
|
|
|
1058
1064
|
if (typeof indexedDB !== "undefined") {
|
|
1059
1065
|
await new Promise((resolve) => {
|
|
1060
1066
|
const req = indexedDB.deleteDatabase(this.dbName);
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1067
|
+
const timer = setTimeout(() => {
|
|
1068
|
+
console.warn(`[VestingClassifier] destroy: deleteDatabase timed out for ${this.dbName}`);
|
|
1069
|
+
resolve();
|
|
1070
|
+
}, 3e3);
|
|
1071
|
+
req.onsuccess = () => {
|
|
1072
|
+
clearTimeout(timer);
|
|
1073
|
+
resolve();
|
|
1074
|
+
};
|
|
1075
|
+
req.onerror = () => {
|
|
1076
|
+
clearTimeout(timer);
|
|
1077
|
+
resolve();
|
|
1078
|
+
};
|
|
1079
|
+
req.onblocked = () => {
|
|
1080
|
+
console.warn(`[VestingClassifier] destroy: deleteDatabase blocked for ${this.dbName}, waiting...`);
|
|
1081
|
+
};
|
|
1064
1082
|
});
|
|
1065
1083
|
}
|
|
1066
1084
|
}
|
|
@@ -12738,14 +12756,17 @@ var Sphere = class _Sphere {
|
|
|
12738
12756
|
if (!wasConnected) {
|
|
12739
12757
|
await storage.connect();
|
|
12740
12758
|
}
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12759
|
+
try {
|
|
12760
|
+
const mnemonic = await storage.get(STORAGE_KEYS_GLOBAL.MNEMONIC);
|
|
12761
|
+
if (mnemonic) return true;
|
|
12762
|
+
const masterKey = await storage.get(STORAGE_KEYS_GLOBAL.MASTER_KEY);
|
|
12763
|
+
if (masterKey) return true;
|
|
12764
|
+
return false;
|
|
12765
|
+
} finally {
|
|
12766
|
+
if (!wasConnected) {
|
|
12767
|
+
await storage.disconnect();
|
|
12768
|
+
}
|
|
12747
12769
|
}
|
|
12748
|
-
return false;
|
|
12749
12770
|
} catch {
|
|
12750
12771
|
return false;
|
|
12751
12772
|
}
|
|
@@ -12879,6 +12900,9 @@ var Sphere = class _Sphere {
|
|
|
12879
12900
|
if (await _Sphere.exists(options.storage)) {
|
|
12880
12901
|
throw new Error("Wallet already exists. Use Sphere.load() or Sphere.clear() first.");
|
|
12881
12902
|
}
|
|
12903
|
+
if (!options.storage.isConnected()) {
|
|
12904
|
+
await options.storage.connect();
|
|
12905
|
+
}
|
|
12882
12906
|
_Sphere.configureTokenRegistry(options.storage, options.network);
|
|
12883
12907
|
const groupChatConfig = _Sphere.resolveGroupChatConfig(options.groupChat, options.network);
|
|
12884
12908
|
const marketConfig = _Sphere.resolveMarketConfig(options.market);
|
|
@@ -12930,6 +12954,9 @@ var Sphere = class _Sphere {
|
|
|
12930
12954
|
marketConfig
|
|
12931
12955
|
);
|
|
12932
12956
|
sphere._password = options.password ?? null;
|
|
12957
|
+
if (!options.storage.isConnected()) {
|
|
12958
|
+
await options.storage.connect();
|
|
12959
|
+
}
|
|
12933
12960
|
await sphere.loadIdentityFromStorage();
|
|
12934
12961
|
await sphere.initializeProviders();
|
|
12935
12962
|
await sphere.initializeModules();
|