@1sat/wallet-toolbox 0.0.14 → 0.0.16

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.
@@ -100,34 +100,33 @@ 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
- // If there are conflicting actives, resolve by setting local as active (merges remote data)
104
- // Non-blocking to avoid IDB transaction timeout
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
113
+ // This is now blocking since setActive no longer holds IDB transactions during network calls
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] Resolving conflicts by merging into local storage...");
109
- storageAny.setActive(localKey, (msg) => {
110
- console.log("[createWebWallet] Sync:", msg);
111
- return msg;
112
- }).then(() => {
113
- console.log("[createWebWallet] Conflict resolution complete");
114
- }).catch((err) => {
115
- console.log("[createWebWallet] Conflict resolution failed:", err instanceof Error ? err.message : err);
116
- });
117
+ console.log("[createWebWallet] Syncing with remote storage...");
118
+ try {
119
+ await storageAny.setActive(localKey, (msg) => {
120
+ console.log("[createWebWallet] Sync:", msg);
121
+ return msg;
122
+ });
123
+ console.log("[createWebWallet] Remote sync complete");
124
+ }
125
+ catch (err) {
126
+ console.log("[createWebWallet] Remote sync failed:", err instanceof Error ? err.message : err);
127
+ }
117
128
  }
118
129
  }
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
130
  // Update wallet's storage reference
132
131
  underlyingWallet._storage = storage;
133
132
  console.log("[createWebWallet] Remote storage connected successfully");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/wallet-toolbox",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
5
5
  "author": "1Sat Team",
6
6
  "license": "MIT",