@1sat/wallet-toolbox 0.0.14 → 0.0.15
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/wallet/factory.js +13 -16
- package/package.json +1 -1
package/dist/wallet/factory.js
CHANGED
|
@@ -100,34 +100,31 @@ export async function createWebWallet(config) {
|
|
|
100
100
|
backups: storageAny._backups?.map(b => b.settings?.storageIdentityKey),
|
|
101
101
|
conflictingActives: storageAny._conflictingActives?.map(c => c.settings?.storageIdentityKey),
|
|
102
102
|
});
|
|
103
|
-
//
|
|
103
|
+
// Treat backups as conflicts to pull any data they have.
|
|
104
|
+
// Remote storage may have transactions that local doesn't know about
|
|
105
|
+
// (e.g., from sweep-ui syncing to remote).
|
|
106
|
+
if (storageAny._backups && storageAny._backups.length > 0) {
|
|
107
|
+
console.log("[createWebWallet] Reclassifying backups as conflicts to pull remote data...");
|
|
108
|
+
storageAny._conflictingActives = storageAny._conflictingActives || [];
|
|
109
|
+
storageAny._conflictingActives.push(...storageAny._backups);
|
|
110
|
+
storageAny._backups = [];
|
|
111
|
+
}
|
|
112
|
+
// If there are conflicting actives (including reclassified backups), resolve by merging into local
|
|
104
113
|
// Non-blocking to avoid IDB transaction timeout
|
|
105
114
|
if (storageAny._conflictingActives && storageAny._conflictingActives.length > 0) {
|
|
106
115
|
const localKey = storageAny._active?.settings?.storageIdentityKey;
|
|
107
116
|
if (localKey && storageAny.setActive) {
|
|
108
|
-
console.log("[createWebWallet]
|
|
117
|
+
console.log("[createWebWallet] Syncing with remote storage...");
|
|
109
118
|
storageAny.setActive(localKey, (msg) => {
|
|
110
119
|
console.log("[createWebWallet] Sync:", msg);
|
|
111
120
|
return msg;
|
|
112
121
|
}).then(() => {
|
|
113
|
-
console.log("[createWebWallet]
|
|
122
|
+
console.log("[createWebWallet] Remote sync complete");
|
|
114
123
|
}).catch((err) => {
|
|
115
|
-
console.log("[createWebWallet]
|
|
124
|
+
console.log("[createWebWallet] Remote sync failed:", err instanceof Error ? err.message : err);
|
|
116
125
|
});
|
|
117
126
|
}
|
|
118
127
|
}
|
|
119
|
-
else if (storageAny._backups && storageAny._backups.length > 0 && storageAny.updateBackups) {
|
|
120
|
-
// No conflicts - push local state to remote backup (non-blocking to avoid IDB timeout)
|
|
121
|
-
console.log("[createWebWallet] Starting background backup to remote...");
|
|
122
|
-
storageAny.updateBackups(undefined, (msg) => {
|
|
123
|
-
console.log("[createWebWallet] Backup:", msg);
|
|
124
|
-
return msg;
|
|
125
|
-
}).then(() => {
|
|
126
|
-
console.log("[createWebWallet] Background backup complete");
|
|
127
|
-
}).catch((err) => {
|
|
128
|
-
console.log("[createWebWallet] Background backup failed:", err instanceof Error ? err.message : err);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
128
|
// Update wallet's storage reference
|
|
132
129
|
underlyingWallet._storage = storage;
|
|
133
130
|
console.log("[createWebWallet] Remote storage connected successfully");
|