@1sat/wallet-toolbox 0.0.2 → 0.0.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/OneSatWallet.d.ts +97 -70
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3430 -405
- package/dist/indexers/types.d.ts +4 -0
- package/dist/services/OneSatServices.d.ts +7 -7
- package/dist/services/client/ArcadeClient.d.ts +1 -1
- package/dist/services/client/BeefClient.d.ts +1 -1
- package/dist/services/client/Bsv21Client.d.ts +1 -1
- package/dist/services/client/ChaintracksClient.d.ts +1 -1
- package/dist/services/client/OrdfsClient.d.ts +29 -14
- package/dist/services/client/OwnerClient.d.ts +5 -22
- package/dist/services/client/TxoClient.d.ts +8 -13
- package/dist/services/types.d.ts +50 -23
- package/dist/sync/IndexedDbSyncQueue.d.ts +30 -0
- package/dist/sync/SqliteSyncQueue.d.ts +54 -0
- package/dist/sync/index.d.ts +3 -0
- package/dist/sync/types.d.ts +129 -0
- package/package.json +1 -1
package/dist/OneSatWallet.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { Wallet, type WalletStorageManager } from "@bsv/wallet-toolbox/mobile";
|
|
|
3
3
|
import type { Chain } from "@bsv/wallet-toolbox/mobile/out/src/sdk/types";
|
|
4
4
|
import { Outpoint } from "./indexers/Outpoint";
|
|
5
5
|
import type { Indexer, ParseContext, Txo } from "./indexers/types";
|
|
6
|
-
import { OneSatServices
|
|
6
|
+
import { OneSatServices } from "./services/OneSatServices";
|
|
7
|
+
import type { SyncQueueStorage } from "./sync/types";
|
|
7
8
|
/**
|
|
8
9
|
* Result of ingestTransaction including parse context for debugging
|
|
9
10
|
*/
|
|
@@ -15,53 +16,21 @@ export interface IngestResult {
|
|
|
15
16
|
* Events emitted by OneSatWallet during sync operations
|
|
16
17
|
*/
|
|
17
18
|
export interface OneSatWalletEvents {
|
|
19
|
+
/** Sync started */
|
|
18
20
|
"sync:start": {
|
|
19
|
-
address: string;
|
|
20
|
-
fromScore: number;
|
|
21
|
-
};
|
|
22
|
-
"sync:output": {
|
|
23
|
-
address: string;
|
|
24
|
-
output: SyncOutput;
|
|
25
|
-
};
|
|
26
|
-
"sync:skipped": {
|
|
27
|
-
address: string;
|
|
28
|
-
outpoint: string;
|
|
29
|
-
reason: string;
|
|
30
|
-
};
|
|
31
|
-
"sync:parsed": {
|
|
32
|
-
address: string;
|
|
33
|
-
txid: string;
|
|
34
|
-
parseContext: ParseContext;
|
|
35
|
-
internalizedCount: number;
|
|
36
|
-
};
|
|
37
|
-
"sync:error": {
|
|
38
|
-
address: string;
|
|
39
|
-
error: Error;
|
|
40
|
-
};
|
|
41
|
-
"sync:complete": {
|
|
42
|
-
address: string;
|
|
43
|
-
};
|
|
44
|
-
"syncAll:start": {
|
|
45
21
|
addresses: string[];
|
|
46
|
-
fromScore: number;
|
|
47
|
-
};
|
|
48
|
-
"syncAll:output": {
|
|
49
|
-
output: SyncOutput;
|
|
50
|
-
};
|
|
51
|
-
"syncAll:skipped": {
|
|
52
|
-
outpoint: string;
|
|
53
|
-
reason: string;
|
|
54
|
-
};
|
|
55
|
-
"syncAll:parsed": {
|
|
56
|
-
txid: string;
|
|
57
|
-
parseContext: ParseContext;
|
|
58
|
-
internalizedCount: number;
|
|
59
22
|
};
|
|
60
|
-
|
|
61
|
-
|
|
23
|
+
/** Sync progress update */
|
|
24
|
+
"sync:progress": {
|
|
25
|
+
pending: number;
|
|
26
|
+
done: number;
|
|
27
|
+
failed: number;
|
|
62
28
|
};
|
|
63
|
-
|
|
64
|
-
|
|
29
|
+
/** Sync complete (queue empty and stream done) */
|
|
30
|
+
"sync:complete": Record<string, never>;
|
|
31
|
+
/** Sync error */
|
|
32
|
+
"sync:error": {
|
|
33
|
+
message: string;
|
|
65
34
|
};
|
|
66
35
|
}
|
|
67
36
|
type EventCallback<T> = (event: T) => void;
|
|
@@ -95,6 +64,15 @@ export interface OneSatWalletArgs {
|
|
|
95
64
|
* Automatically start syncing all owner addresses on construction.
|
|
96
65
|
*/
|
|
97
66
|
autoSync?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Sync queue storage for background processing.
|
|
69
|
+
* If provided, enables queue-based sync via sync() method.
|
|
70
|
+
*/
|
|
71
|
+
syncQueue?: SyncQueueStorage;
|
|
72
|
+
/**
|
|
73
|
+
* Batch size for queue processing (default: 20).
|
|
74
|
+
*/
|
|
75
|
+
syncBatchSize?: number;
|
|
98
76
|
}
|
|
99
77
|
/**
|
|
100
78
|
* OneSatWallet extends the BRC-100 Wallet with 1Sat-specific indexing and services.
|
|
@@ -109,8 +87,16 @@ export declare class OneSatWallet extends Wallet {
|
|
|
109
87
|
readonly services: OneSatServices;
|
|
110
88
|
private owners;
|
|
111
89
|
private listeners;
|
|
112
|
-
private
|
|
113
|
-
private
|
|
90
|
+
private syncQueue;
|
|
91
|
+
private syncBatchSize;
|
|
92
|
+
private syncRunning;
|
|
93
|
+
private syncStopRequested;
|
|
94
|
+
private activeQueueSync;
|
|
95
|
+
private sseStreamActive;
|
|
96
|
+
private sseUnsubscribe;
|
|
97
|
+
private processorActive;
|
|
98
|
+
private processorStopRequested;
|
|
99
|
+
private streamDone;
|
|
114
100
|
constructor(args: OneSatWalletArgs);
|
|
115
101
|
/**
|
|
116
102
|
* Returns true if this wallet was created with only a public key.
|
|
@@ -215,46 +201,87 @@ export declare class OneSatWallet extends Wallet {
|
|
|
215
201
|
*/
|
|
216
202
|
broadcast(tx: Transaction, description: string, labels?: string[]): Promise<IngestResult>;
|
|
217
203
|
/**
|
|
218
|
-
*
|
|
219
|
-
*
|
|
204
|
+
* Start queue-based sync for all owner addresses.
|
|
205
|
+
* Requires syncQueue to be provided in constructor args.
|
|
220
206
|
*
|
|
221
|
-
*
|
|
207
|
+
* This method:
|
|
208
|
+
* 1. Opens SSE stream and enqueues outputs
|
|
209
|
+
* 2. Processes queue in batches using Promise.all()
|
|
210
|
+
* 3. Continues until queue is empty and stream is done
|
|
211
|
+
*/
|
|
212
|
+
sync(): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Handle a single output from the SSE stream.
|
|
215
|
+
* Enqueues to the sync queue and updates lastQueuedScore with reorg protection.
|
|
222
216
|
*/
|
|
223
|
-
|
|
217
|
+
private handleSyncOutput;
|
|
224
218
|
/**
|
|
225
|
-
* Process
|
|
226
|
-
* Only marks our output as spent - doesn't ingest the spend tx.
|
|
227
|
-
* If the spend tx has outputs we own, they'll come through sync separately.
|
|
219
|
+
* Process queue in batches until empty or stopped.
|
|
228
220
|
*/
|
|
229
|
-
private
|
|
221
|
+
private processQueueLoop;
|
|
230
222
|
/**
|
|
231
|
-
*
|
|
223
|
+
* Group queue items by txid.
|
|
224
|
+
* @deprecated - claim() now returns items already grouped
|
|
232
225
|
*/
|
|
233
|
-
|
|
226
|
+
private groupItemsByTxid;
|
|
234
227
|
/**
|
|
235
|
-
*
|
|
228
|
+
* Process a single txid - ingest transaction and complete queue items.
|
|
229
|
+
* Items are already marked as "processing" by claim().
|
|
230
|
+
*/
|
|
231
|
+
private processTxid;
|
|
232
|
+
/**
|
|
233
|
+
* Ingest a transaction with knowledge of which outputs are already spent.
|
|
234
|
+
*/
|
|
235
|
+
private ingestWithSpendInfo;
|
|
236
|
+
/**
|
|
237
|
+
* Mark outputs as spent for spend-only queue items.
|
|
238
|
+
*/
|
|
239
|
+
private markOutputsSpent;
|
|
240
|
+
/**
|
|
241
|
+
* Stop the sync.
|
|
242
|
+
*/
|
|
243
|
+
stopSync(): void;
|
|
244
|
+
/**
|
|
245
|
+
* Close the wallet and cleanup all sync connections.
|
|
236
246
|
*/
|
|
237
247
|
close(): void;
|
|
238
248
|
/**
|
|
239
|
-
*
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
249
|
+
* Check if sync is currently running.
|
|
250
|
+
*/
|
|
251
|
+
isSyncing(): boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Get the sync queue instance (if provided).
|
|
254
|
+
*/
|
|
255
|
+
getQueue(): SyncQueueStorage | null;
|
|
256
|
+
/**
|
|
257
|
+
* Start only the SSE stream, enqueueing outputs without processing.
|
|
258
|
+
* Useful for testing to observe queue buildup.
|
|
259
|
+
*/
|
|
260
|
+
startStream(): Promise<void>;
|
|
261
|
+
/**
|
|
262
|
+
* Stop the SSE stream.
|
|
263
|
+
*/
|
|
264
|
+
stopStream(): void;
|
|
265
|
+
/**
|
|
266
|
+
* Check if SSE stream is active.
|
|
267
|
+
*/
|
|
268
|
+
isStreamActive(): boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Check if SSE stream has completed.
|
|
243
271
|
*/
|
|
244
|
-
|
|
272
|
+
isStreamDone(): boolean;
|
|
245
273
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
274
|
+
* Start only the queue processor, without starting a new SSE stream.
|
|
275
|
+
* Useful for testing to process queued items independently.
|
|
248
276
|
*/
|
|
249
|
-
|
|
277
|
+
startProcessor(): Promise<void>;
|
|
250
278
|
/**
|
|
251
|
-
* Stop the
|
|
279
|
+
* Stop the queue processor.
|
|
252
280
|
*/
|
|
253
|
-
|
|
281
|
+
stopProcessor(): void;
|
|
254
282
|
/**
|
|
255
|
-
*
|
|
256
|
-
* For most cases, use syncAll() instead which uses a single connection.
|
|
283
|
+
* Check if queue processor is active.
|
|
257
284
|
*/
|
|
258
|
-
|
|
285
|
+
isProcessorActive(): boolean;
|
|
259
286
|
}
|
|
260
287
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { OneSatWallet, type OneSatWalletArgs, type OneSatWalletEvents, type IngestResult, } from "./OneSatWallet";
|
|
2
2
|
export { OneSatServices, type SyncOutput } from "./services/OneSatServices";
|
|
3
|
-
export type { OrdfsMetadata, Capability } from "./services/types";
|
|
3
|
+
export type { OrdfsMetadata, OrdfsContentOptions, OrdfsContentResponse, OrdfsResponseHeaders, Capability, } from "./services/types";
|
|
4
4
|
export * from "./services/client";
|
|
5
5
|
export { ReadOnlySigner } from "./signers/ReadOnlySigner";
|
|
6
6
|
export * from "./indexers";
|
|
7
|
+
export * from "./sync";
|
|
8
|
+
export { WalletStorageManager, StorageProvider, } from "@bsv/wallet-toolbox/mobile";
|
|
9
|
+
export { StorageIdb } from "@bsv/wallet-toolbox/mobile/out/src/storage/StorageIdb";
|