@1sat/wallet-toolbox 0.0.45 → 0.0.46
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/fullSync.d.ts +4 -0
- package/dist/wallet/fullSync.js +3 -53
- package/package.json +4 -4
|
@@ -17,6 +17,10 @@ export interface FullSyncOptions {
|
|
|
17
17
|
identityKey: string;
|
|
18
18
|
/** Optional progress callback */
|
|
19
19
|
onProgress?: (stage: FullSyncStage, message: string) => void;
|
|
20
|
+
/** Max rough size per chunk in bytes (default: 1MB) */
|
|
21
|
+
maxRoughSize?: number;
|
|
22
|
+
/** Max items per chunk (default: 100) */
|
|
23
|
+
maxItems?: number;
|
|
20
24
|
}
|
|
21
25
|
export interface FullSyncResult {
|
|
22
26
|
pushed: {
|
package/dist/wallet/fullSync.js
CHANGED
|
@@ -28,7 +28,8 @@ import { EntitySyncState } from "@bsv/wallet-toolbox-mobile/out/src/storage/sche
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
export async function fullSync(options) {
|
|
31
|
-
const { storage, remoteStorage, identityKey, onProgress
|
|
31
|
+
const { storage, remoteStorage, identityKey, onProgress, maxRoughSize = 1000000, // 1 MB default
|
|
32
|
+
maxItems = 100, } = options;
|
|
32
33
|
// Step 1: Push ALL local data to remote (bypassing timestamp filter)
|
|
33
34
|
onProgress?.("pushing", "Pushing local data to remote...");
|
|
34
35
|
const localSettings = storage.getSettings();
|
|
@@ -39,40 +40,13 @@ export async function fullSync(options) {
|
|
|
39
40
|
for (;;) {
|
|
40
41
|
// Get sync state from remote for proper offsets
|
|
41
42
|
const ss = await EntitySyncState.fromStorage(remoteStorage, identityKey, localSettings);
|
|
42
|
-
const args = ss.makeRequestSyncChunkArgs(identityKey, remoteSettings.storageIdentityKey);
|
|
43
|
+
const args = ss.makeRequestSyncChunkArgs(identityKey, remoteSettings.storageIdentityKey, maxRoughSize, maxItems);
|
|
43
44
|
// KEY: Override since to undefined - includes ALL data regardless of timestamp
|
|
44
45
|
args.since = undefined;
|
|
45
46
|
// Get chunk from local storage
|
|
46
47
|
const chunk = await storage.runAsSync(async (sync) => sync.getSyncChunk(args));
|
|
47
|
-
// DEBUG CHECKPOINT 2: Log PUSH chunk contents
|
|
48
|
-
const pushBaskets = chunk.outputBaskets || [];
|
|
49
|
-
const pushOutputs = chunk.outputs || [];
|
|
50
|
-
const pushTransactions = chunk.transactions || [];
|
|
51
|
-
const push1SatOutputs = pushOutputs.filter((o) => o.satoshis === 1);
|
|
52
|
-
console.log("=== CHECKPOINT 2: PUSH CHUNK ===");
|
|
53
|
-
console.log("[PUSH] Chunk #:", chunkCount + 1);
|
|
54
|
-
console.log("[PUSH] Transactions:", pushTransactions.length);
|
|
55
|
-
for (const t of pushTransactions) {
|
|
56
|
-
console.log(` Tx: transactionId=${t.transactionId}, txid=${t.txid?.slice(0, 16) ?? "null"}..., status=${t.status}`);
|
|
57
|
-
}
|
|
58
|
-
console.log("[PUSH] Output Baskets:", pushBaskets.length);
|
|
59
|
-
for (const b of pushBaskets) {
|
|
60
|
-
console.log(` Basket: id=${b.basketId}, name="${b.name}"`);
|
|
61
|
-
}
|
|
62
|
-
console.log("[PUSH] Total Outputs:", pushOutputs.length);
|
|
63
|
-
console.log("[PUSH] Outputs with basketId:", pushOutputs.filter((o) => o.basketId != null).length);
|
|
64
|
-
console.log("[PUSH] 1-sat Outputs:", push1SatOutputs.length);
|
|
65
|
-
console.log("[PUSH] 1-sat with basketId:", push1SatOutputs.filter((o) => o.basketId != null).length);
|
|
66
|
-
for (const o of push1SatOutputs) {
|
|
67
|
-
console.log(` 1sat Output: outputId=${o.outputId}, basketId=${o.basketId}, txid=${o.txid?.slice(0, 16)}...${o.vout}`);
|
|
68
|
-
}
|
|
69
|
-
console.log("=== END CHECKPOINT 2 ===");
|
|
70
48
|
// Send chunk to remote
|
|
71
|
-
const chunkJson = JSON.stringify(chunk);
|
|
72
|
-
console.log(`[PUSH] Chunk size: ${(chunkJson.length / 1024).toFixed(1)} KB`);
|
|
73
|
-
console.log("[PUSH] Sending chunk to remote...");
|
|
74
49
|
const result = await remoteStorage.processSyncChunk(args, chunk);
|
|
75
|
-
console.log(`[PUSH] Server response: inserts=${result.inserts}, updates=${result.updates}, done=${result.done}`);
|
|
76
50
|
pushInserts += result.inserts;
|
|
77
51
|
pushUpdates += result.updates;
|
|
78
52
|
chunkCount++;
|
|
@@ -106,30 +80,6 @@ export async function fullSync(options) {
|
|
|
106
80
|
});
|
|
107
81
|
// Step 3: Pull from remote (full pull due to reset state)
|
|
108
82
|
onProgress?.("pulling", "Pulling all data from remote...");
|
|
109
|
-
// DEBUG CHECKPOINT 3: Intercept PULL chunks from remote
|
|
110
|
-
const originalGetSyncChunk = remoteStorage.getSyncChunk?.bind(remoteStorage);
|
|
111
|
-
if (originalGetSyncChunk) {
|
|
112
|
-
remoteStorage.getSyncChunk = async function (args) {
|
|
113
|
-
const chunk = (await originalGetSyncChunk(args));
|
|
114
|
-
const pullBaskets = chunk.outputBaskets || [];
|
|
115
|
-
const pullOutputs = chunk.outputs || [];
|
|
116
|
-
const pull1SatOutputs = pullOutputs.filter((o) => o.satoshis === 1);
|
|
117
|
-
console.log("=== CHECKPOINT 3: PULL CHUNK ===");
|
|
118
|
-
console.log("[PULL] Output Baskets:", pullBaskets.length);
|
|
119
|
-
for (const b of pullBaskets) {
|
|
120
|
-
console.log(` Basket: id=${b.basketId}, name="${b.name}"`);
|
|
121
|
-
}
|
|
122
|
-
console.log("[PULL] Total Outputs:", pullOutputs.length);
|
|
123
|
-
console.log("[PULL] Outputs with basketId:", pullOutputs.filter((o) => o.basketId != null).length);
|
|
124
|
-
console.log("[PULL] 1-sat Outputs:", pull1SatOutputs.length);
|
|
125
|
-
console.log("[PULL] 1-sat with basketId:", pull1SatOutputs.filter((o) => o.basketId != null).length);
|
|
126
|
-
for (const o of pull1SatOutputs) {
|
|
127
|
-
console.log(` 1sat Output: outputId=${o.outputId}, basketId=${o.basketId}, txid=${o.txid?.slice(0, 16)}...${o.vout}`);
|
|
128
|
-
}
|
|
129
|
-
console.log("=== END CHECKPOINT 3 ===");
|
|
130
|
-
return chunk;
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
83
|
const pullResult = await storage.syncFromReader(identityKey, remoteStorage);
|
|
134
84
|
onProgress?.("pulling", `Pulled ${pullResult.inserts} inserts, ${pullResult.updates} updates`);
|
|
135
85
|
// Step 4: Complete
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1sat/wallet-toolbox",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
|
|
5
5
|
"author": "1Sat Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"fflate": "^0.8.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.
|
|
47
|
+
"@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.21"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
50
50
|
"@bsv/wallet-toolbox-mobile": {
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@biomejs/biome": "^1.9.4",
|
|
56
|
-
"@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@^1.7.20-idb-fix.
|
|
57
|
-
"@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.
|
|
56
|
+
"@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@^1.7.20-idb-fix.21",
|
|
57
|
+
"@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.21",
|
|
58
58
|
"@types/bun": "^1.3.4",
|
|
59
59
|
"@types/chrome": "^0.1.32",
|
|
60
60
|
"typescript": "^5.9.3"
|