@1sat/wallet-toolbox 0.0.40 → 0.0.41

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.
@@ -5,6 +5,7 @@
5
5
  * This is a deliberate user action (not automatic) for recovering from sync issues.
6
6
  */
7
7
  import { createSyncMap } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema/entities/EntityBase.js";
8
+ import { EntitySyncState } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema/entities/EntitySyncState.js";
8
9
  /**
9
10
  * Perform a full sync with the remote backup server.
10
11
  *
@@ -28,14 +29,34 @@ import { createSyncMap } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema
28
29
  */
29
30
  export async function fullSync(options) {
30
31
  const { storage, remoteStorage, identityKey, onProgress } = options;
31
- // Step 1: Push local data to remote
32
+ // Step 1: Push ALL local data to remote (bypassing timestamp filter)
32
33
  onProgress?.("pushing", "Pushing local data to remote...");
33
- const auth = await storage.getAuth();
34
- const pushResult = await storage.syncToWriter(auth, remoteStorage);
35
- onProgress?.("pushing", `Pushed ${pushResult.inserts} inserts, ${pushResult.updates} updates`);
34
+ const localSettings = storage.getSettings();
35
+ const remoteSettings = await remoteStorage.makeAvailable();
36
+ let pushInserts = 0;
37
+ let pushUpdates = 0;
38
+ let chunkCount = 0;
39
+ for (;;) {
40
+ // Get sync state from remote for proper offsets
41
+ const ss = await EntitySyncState.fromStorage(remoteStorage, identityKey, localSettings);
42
+ const args = ss.makeRequestSyncChunkArgs(identityKey, remoteSettings.storageIdentityKey);
43
+ // KEY: Override since to undefined - includes ALL data regardless of timestamp
44
+ args.since = undefined;
45
+ // Get chunk from local storage
46
+ const chunk = await storage.runAsSync(async (sync) => sync.getSyncChunk(args));
47
+ // Send chunk to remote
48
+ const result = await remoteStorage.processSyncChunk(args, chunk);
49
+ pushInserts += result.inserts;
50
+ pushUpdates += result.updates;
51
+ chunkCount++;
52
+ onProgress?.("pushing", `Chunk ${chunkCount}: ${result.inserts} inserts, ${result.updates} updates`);
53
+ if (result.done)
54
+ break;
55
+ }
56
+ onProgress?.("pushing", `Pushed ${pushInserts} inserts, ${pushUpdates} updates`);
36
57
  // Step 2: Reset sync state to force full pull
37
58
  onProgress?.("resetting", "Resetting sync state...");
38
- const remoteSettings = remoteStorage.getSettings();
59
+ const auth = await storage.getAuth();
39
60
  await storage.runAsStorageProvider(async (active) => {
40
61
  const syncStates = await active.findSyncStates({
41
62
  partial: {
@@ -63,7 +84,7 @@ export async function fullSync(options) {
63
84
  // Step 4: Complete
64
85
  onProgress?.("complete", "Full sync complete");
65
86
  return {
66
- pushed: { inserts: pushResult.inserts, updates: pushResult.updates },
87
+ pushed: { inserts: pushInserts, updates: pushUpdates },
67
88
  pulled: { inserts: pullResult.inserts, updates: pullResult.updates },
68
89
  };
69
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/wallet-toolbox",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
5
5
  "author": "1Sat Team",
6
6
  "license": "MIT",