@1sat/wallet-toolbox 0.0.1 → 0.0.3

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.
Files changed (34) hide show
  1. package/README.md +21 -21
  2. package/dist/OneSatWallet.d.ts +209 -54
  3. package/dist/index.d.ts +6 -4
  4. package/dist/index.js +34940 -32915
  5. package/dist/indexers/Bsv21Indexer.d.ts +5 -5
  6. package/dist/indexers/CosignIndexer.d.ts +3 -3
  7. package/dist/indexers/FundIndexer.d.ts +3 -3
  8. package/dist/indexers/InscriptionIndexer.d.ts +3 -2
  9. package/dist/indexers/LockIndexer.d.ts +3 -3
  10. package/dist/indexers/MapIndexer.d.ts +2 -3
  11. package/dist/indexers/OpNSIndexer.d.ts +2 -2
  12. package/dist/indexers/OrdLockIndexer.d.ts +3 -3
  13. package/dist/indexers/OriginIndexer.d.ts +19 -5
  14. package/dist/indexers/SigmaIndexer.d.ts +14 -2
  15. package/dist/indexers/index.d.ts +5 -6
  16. package/dist/indexers/types.d.ts +24 -10
  17. package/dist/services/OneSatServices.d.ts +39 -61
  18. package/dist/services/client/ArcadeClient.d.ts +45 -0
  19. package/dist/services/client/BaseClient.d.ts +32 -0
  20. package/dist/services/client/BeefClient.d.ts +26 -0
  21. package/dist/services/client/Bsv21Client.d.ts +46 -0
  22. package/dist/services/client/ChaintracksClient.d.ts +62 -0
  23. package/dist/services/client/OrdfsClient.d.ts +47 -0
  24. package/dist/services/client/OwnerClient.d.ts +41 -0
  25. package/dist/services/client/TxoClient.d.ts +41 -0
  26. package/dist/services/client/index.d.ts +8 -0
  27. package/dist/services/types.d.ts +253 -0
  28. package/dist/signers/ReadOnlySigner.d.ts +1 -1
  29. package/dist/sync/IndexedDbSyncQueue.d.ts +30 -0
  30. package/dist/sync/SqliteSyncQueue.d.ts +54 -0
  31. package/dist/sync/index.d.ts +3 -0
  32. package/dist/sync/types.d.ts +129 -0
  33. package/package.json +6 -3
  34. package/dist/indexers/TransactionParser.d.ts +0 -53
@@ -0,0 +1,47 @@
1
+ import type { ClientOptions, OrdfsContentOptions, OrdfsContentResponse, OrdfsMetadata } from "../types";
2
+ import { BaseClient } from "./BaseClient";
3
+ /**
4
+ * Client for ordfs routes.
5
+ * Provides inscription content and metadata.
6
+ *
7
+ * Content is served from baseUrl directly (e.g., https://api.1sat.app/:outpoint)
8
+ * API routes use /api/ordfs (e.g., https://api.1sat.app/api/ordfs/metadata/:outpoint)
9
+ */
10
+ export declare class OrdfsClient extends BaseClient {
11
+ private readonly contentBaseUrl;
12
+ constructor(baseUrl: string, options?: ClientOptions);
13
+ /**
14
+ * Get metadata for an inscription
15
+ * @param outpoint - Outpoint (txid_vout) or txid
16
+ * @param seq - Optional sequence number (-1 for latest)
17
+ */
18
+ getMetadata(outpoint: string, seq?: number): Promise<OrdfsMetadata>;
19
+ /**
20
+ * Get inscription content with full response headers
21
+ * @param outpoint - Outpoint (txid_vout) or txid
22
+ * @param options - Content request options
23
+ */
24
+ getContent(outpoint: string, options?: OrdfsContentOptions): Promise<OrdfsContentResponse>;
25
+ /**
26
+ * Preview base64-encoded HTML content
27
+ * @param b64HtmlData - Base64-encoded HTML
28
+ */
29
+ previewHtml(b64HtmlData: string): Promise<string>;
30
+ /**
31
+ * Preview content by posting it directly
32
+ * @param content - Content to preview
33
+ * @param contentType - Content type header
34
+ */
35
+ previewContent(content: Uint8Array, contentType: string): Promise<Uint8Array>;
36
+ /**
37
+ * Get the URL for fetching inscription content directly.
38
+ * Useful for displaying in img/video tags.
39
+ * @param outpoint - Outpoint (txid_vout) or txid
40
+ * @param options - Content request options
41
+ */
42
+ getContentUrl(outpoint: string, options?: OrdfsContentOptions): string;
43
+ /**
44
+ * Parse response headers into structured object
45
+ */
46
+ private parseResponseHeaders;
47
+ }
@@ -0,0 +1,41 @@
1
+ import type { BalanceResponse, ClientOptions, IndexedOutput, SyncOutput, TxoQueryOptions } from "../types";
2
+ import { BaseClient } from "./BaseClient";
3
+ /**
4
+ * Client for /api/owner/* routes.
5
+ * Provides owner (address) queries and sync.
6
+ *
7
+ * Routes:
8
+ * - GET /:owner/txos - Get TXOs for owner
9
+ * - GET /:owner/balance - Get balance
10
+ * - GET /sync?owner=... - SSE stream of outputs for sync (supports multiple owners)
11
+ */
12
+ export declare class OwnerClient extends BaseClient {
13
+ constructor(baseUrl: string, options?: ClientOptions);
14
+ /**
15
+ * Get TXOs owned by an address/owner
16
+ */
17
+ getTxos(owner: string, opts?: TxoQueryOptions & {
18
+ refresh?: boolean;
19
+ }): Promise<IndexedOutput[]>;
20
+ /**
21
+ * Get balance for an address/owner
22
+ */
23
+ getBalance(owner: string): Promise<BalanceResponse>;
24
+ /**
25
+ * Sync outputs for owner(s) via SSE stream.
26
+ * The server merges results from all owners in score order.
27
+ *
28
+ * @param owners - Array of addresses/owners to sync
29
+ * @param onOutput - Callback for each output
30
+ * @param from - Starting score (for pagination/resumption)
31
+ * @param onDone - Callback when sync completes (client should retry after delay)
32
+ * @param onError - Callback for errors
33
+ * @returns Unsubscribe function
34
+ */
35
+ sync(owners: string[], onOutput: (output: SyncOutput) => void, from?: number, onDone?: () => void, onError?: (error: Error) => void): () => void;
36
+ /**
37
+ * Sync outputs as an async iterator.
38
+ * Yields SyncOutput objects until the stream is done.
39
+ */
40
+ syncIterator(owners: string[], from?: number): AsyncGenerator<SyncOutput, void, unknown>;
41
+ }
@@ -0,0 +1,41 @@
1
+ import type { ClientOptions, IndexedOutput, TxoQueryOptions } from "../types";
2
+ import { BaseClient } from "./BaseClient";
3
+ /**
4
+ * Client for /api/txo/* routes.
5
+ * Provides TXO (transaction output) lookup and search.
6
+ *
7
+ * Routes:
8
+ * - GET /:outpoint - Get single TXO (outpoint pattern-matched)
9
+ * - GET /:outpoint/spend - Get spend info
10
+ * - POST /outpoints - Get multiple TXOs
11
+ * - POST /spends - Get multiple spends
12
+ * - GET /tx/:txid - Get all TXOs for a transaction
13
+ * - GET /search?key=... - Search by key(s)
14
+ */
15
+ export declare class TxoClient extends BaseClient {
16
+ constructor(baseUrl: string, options?: ClientOptions);
17
+ /**
18
+ * Get a single TXO by outpoint
19
+ */
20
+ get(outpoint: string, opts?: TxoQueryOptions): Promise<IndexedOutput>;
21
+ /**
22
+ * Get multiple TXOs by outpoints
23
+ */
24
+ getBatch(outpoints: string[], opts?: TxoQueryOptions): Promise<(IndexedOutput | null)[]>;
25
+ /**
26
+ * Get spend info for an outpoint
27
+ */
28
+ getSpend(outpoint: string): Promise<string | null>;
29
+ /**
30
+ * Get spend info for multiple outpoints
31
+ */
32
+ getSpends(outpoints: string[]): Promise<(string | null)[]>;
33
+ /**
34
+ * Get all TXOs for a transaction
35
+ */
36
+ getByTxid(txid: string, opts?: TxoQueryOptions): Promise<IndexedOutput[]>;
37
+ /**
38
+ * Search TXOs by key(s)
39
+ */
40
+ search(keys: string | string[], opts?: TxoQueryOptions): Promise<IndexedOutput[]>;
41
+ }
@@ -0,0 +1,8 @@
1
+ export { BaseClient } from "./BaseClient";
2
+ export { ChaintracksClient } from "./ChaintracksClient";
3
+ export { BeefClient } from "./BeefClient";
4
+ export { ArcadeClient } from "./ArcadeClient";
5
+ export { TxoClient } from "./TxoClient";
6
+ export { OwnerClient } from "./OwnerClient";
7
+ export { OrdfsClient } from "./OrdfsClient";
8
+ export { Bsv21Client } from "./Bsv21Client";
@@ -0,0 +1,253 @@
1
+ /**
2
+ * Consolidated type definitions for 1sat-stack API clients.
3
+ * These types mirror the structures returned by the 1sat-stack server.
4
+ */
5
+ /**
6
+ * Options for configuring API clients
7
+ */
8
+ export interface ClientOptions {
9
+ /** Request timeout in milliseconds (default: 30000) */
10
+ timeout?: number;
11
+ /** Custom fetch implementation */
12
+ fetch?: typeof fetch;
13
+ }
14
+ /**
15
+ * Server capabilities returned by /api/capabilities endpoint.
16
+ * These match the actual capability names from 1sat-stack.
17
+ */
18
+ export type Capability = "beef" | "pubsub" | "txo" | "owner" | "indexer" | "bsv21" | "ordfs" | "chaintracks" | "arcade" | "overlay";
19
+ /**
20
+ * Block header data returned by chaintracks endpoints
21
+ */
22
+ export interface BlockHeader {
23
+ height: number;
24
+ hash: string;
25
+ version: number;
26
+ prevHash: string;
27
+ merkleRoot: string;
28
+ time: number;
29
+ bits: number;
30
+ nonce: number;
31
+ }
32
+ /**
33
+ * Transaction status values from arcade
34
+ */
35
+ export type TxStatus = "UNKNOWN" | "RECEIVED" | "SENT_TO_NETWORK" | "ACCEPTED_BY_NETWORK" | "SEEN_ON_NETWORK" | "DOUBLE_SPEND_ATTEMPTED" | "REJECTED" | "MINED" | "IMMUTABLE";
36
+ /**
37
+ * Transaction status response from arcade
38
+ */
39
+ export interface TransactionStatus {
40
+ txid: string;
41
+ txStatus: TxStatus;
42
+ timestamp: string;
43
+ blockHash?: string;
44
+ blockHeight?: number;
45
+ merklePath?: string;
46
+ extraInfo?: string;
47
+ competingTxs?: string[];
48
+ }
49
+ /**
50
+ * Options for submitting transactions to arcade
51
+ */
52
+ export interface SubmitOptions {
53
+ /** URL for status callbacks */
54
+ callbackUrl?: string;
55
+ /** Token for authenticating callbacks */
56
+ callbackToken?: string;
57
+ /** Receive all status updates, not just final */
58
+ fullStatusUpdates?: boolean;
59
+ /** Skip fee validation */
60
+ skipFeeValidation?: boolean;
61
+ /** Skip script validation */
62
+ skipScriptValidation?: boolean;
63
+ }
64
+ /**
65
+ * Mining policy from arcade
66
+ */
67
+ export interface Policy {
68
+ maxscriptsizepolicy: number;
69
+ maxtxsigopscountspolicy: number;
70
+ maxtxsizepolicy: number;
71
+ miningFee: {
72
+ satoshis: number;
73
+ bytes: number;
74
+ };
75
+ }
76
+ /**
77
+ * Indexed transaction output.
78
+ * Base fields (outpoint, score) are always present.
79
+ * Other fields are present based on query options.
80
+ */
81
+ export interface IndexedOutput {
82
+ outpoint: string;
83
+ score: number;
84
+ satoshis?: number;
85
+ blockHeight?: number;
86
+ blockIdx?: number;
87
+ spend?: string;
88
+ events?: string[];
89
+ data?: Record<string, unknown>;
90
+ }
91
+ /**
92
+ * Spend information response
93
+ */
94
+ export interface SpendResponse {
95
+ spendTxid: string | null;
96
+ }
97
+ /**
98
+ * Options for querying TXOs
99
+ */
100
+ export interface TxoQueryOptions {
101
+ /** Starting score for pagination */
102
+ from?: number;
103
+ /** Maximum results to return */
104
+ limit?: number;
105
+ /** Reverse order */
106
+ rev?: boolean;
107
+ /** Filter for unspent only */
108
+ unspent?: boolean;
109
+ /** Include satoshis in response */
110
+ sats?: boolean;
111
+ /** Include spend txid in response */
112
+ spend?: boolean;
113
+ /** Include events array in response */
114
+ events?: boolean;
115
+ /** Include blockHeight and blockIdx in response */
116
+ block?: boolean;
117
+ /** Data tags to include in response */
118
+ tags?: string[];
119
+ }
120
+ /**
121
+ * Balance response from owner endpoint
122
+ */
123
+ export interface BalanceResponse {
124
+ balance: number;
125
+ count: number;
126
+ }
127
+ /**
128
+ * Sync output streamed via SSE
129
+ */
130
+ export interface SyncOutput {
131
+ outpoint: string;
132
+ score: number;
133
+ spendTxid?: string;
134
+ }
135
+ /**
136
+ * Indexed output from parse/ingest operations
137
+ */
138
+ export interface IndexedTxo {
139
+ outpoint: string;
140
+ satoshis: number;
141
+ script?: string;
142
+ owners?: string[];
143
+ events?: string[];
144
+ data?: Record<string, unknown>;
145
+ }
146
+ /**
147
+ * Index context returned by parse/ingest
148
+ */
149
+ export interface IndexContext {
150
+ txid: string;
151
+ score: number;
152
+ outputs: IndexedTxo[];
153
+ }
154
+ /**
155
+ * OrdFS metadata for an inscription
156
+ */
157
+ export interface OrdfsMetadata {
158
+ outpoint: string;
159
+ origin?: string;
160
+ sequence: number;
161
+ contentType: string;
162
+ contentLength: number;
163
+ parent?: string;
164
+ map?: Record<string, unknown>;
165
+ }
166
+ /**
167
+ * Options for OrdFS content requests
168
+ */
169
+ export interface OrdfsContentOptions {
170
+ /** Sequence number (-1 for latest, 0+ for specific sequence) */
171
+ seq?: number;
172
+ /** Include MAP data in X-Map header */
173
+ map?: boolean;
174
+ /** Include parent outpoint in X-Parent header */
175
+ parent?: boolean;
176
+ /** Return raw directory JSON instead of resolving */
177
+ raw?: boolean;
178
+ }
179
+ /**
180
+ * Headers returned from OrdFS content responses
181
+ */
182
+ export interface OrdfsResponseHeaders {
183
+ contentType: string;
184
+ outpoint?: string;
185
+ origin?: string;
186
+ sequence?: number;
187
+ cacheControl?: string;
188
+ map?: Record<string, unknown>;
189
+ parent?: string;
190
+ }
191
+ /**
192
+ * Full content response from OrdFS including headers
193
+ */
194
+ export interface OrdfsContentResponse {
195
+ data: Uint8Array;
196
+ headers: OrdfsResponseHeaders;
197
+ }
198
+ /**
199
+ * BSV21 token details (deploy data)
200
+ */
201
+ export interface Bsv21TokenDetails {
202
+ id: string;
203
+ txid: string;
204
+ vout: number;
205
+ op: string;
206
+ amt: string;
207
+ sym?: string;
208
+ dec: number;
209
+ icon?: string;
210
+ }
211
+ /**
212
+ * BSV21 token data structure from overlay API
213
+ */
214
+ export interface Bsv21TokenData {
215
+ id: string;
216
+ op: string;
217
+ amt: string;
218
+ sym?: string;
219
+ dec?: number;
220
+ icon?: string;
221
+ address?: string;
222
+ }
223
+ /**
224
+ * BSV21 output data from overlay API
225
+ */
226
+ export interface Bsv21OutputData {
227
+ txid: string;
228
+ vout: number;
229
+ data: {
230
+ bsv21: Bsv21TokenData;
231
+ };
232
+ script: string;
233
+ satoshis: number;
234
+ spend: string | null;
235
+ score: number;
236
+ }
237
+ /**
238
+ * BSV21 transaction data from overlay API
239
+ */
240
+ export interface Bsv21TransactionData {
241
+ txid: string;
242
+ inputs: Bsv21OutputData[];
243
+ outputs: Bsv21OutputData[];
244
+ beef?: string;
245
+ }
246
+ /**
247
+ * Event from SSE subscription
248
+ */
249
+ export interface SseEvent {
250
+ topic: string;
251
+ data: string;
252
+ score?: number;
253
+ }
@@ -1,4 +1,4 @@
1
- import { type KeyDeriverApi, type PrivateKey, type WalletProtocol, type Counterparty } from "@bsv/sdk";
1
+ import { type Counterparty, type KeyDeriverApi, type PrivateKey, type WalletProtocol } from "@bsv/sdk";
2
2
  /**
3
3
  * A read-only KeyDeriver that exposes an identity key but throws on any signing/derivation operation.
4
4
  * Used when the wallet is instantiated with only a public key.
@@ -0,0 +1,30 @@
1
+ import type { SyncQueueInput, SyncQueueItem, SyncQueueStats, SyncQueueStorage, SyncState } from "./types";
2
+ /**
3
+ * IndexedDB implementation of SyncQueueStorage for browser environments.
4
+ */
5
+ export declare class IndexedDbSyncQueue implements SyncQueueStorage {
6
+ private dbName;
7
+ private db;
8
+ private dbPromise;
9
+ /**
10
+ * Create a new IndexedDB sync queue.
11
+ * @param accountId - Unique identifier for the account (e.g., address, pubkey hash)
12
+ */
13
+ constructor(accountId: string);
14
+ private getDb;
15
+ enqueue(items: SyncQueueInput[]): Promise<void>;
16
+ claim(count?: number): Promise<Map<string, SyncQueueItem[]>>;
17
+ private getPendingByTxid;
18
+ private markProcessing;
19
+ complete(id: string): Promise<void>;
20
+ completeMany(ids: string[]): Promise<void>;
21
+ fail(id: string, error: string): Promise<void>;
22
+ getByTxid(txid: string): Promise<SyncQueueItem[]>;
23
+ getByStatus(status: SyncQueueItem["status"], limit?: number): Promise<SyncQueueItem[]>;
24
+ getStats(): Promise<SyncQueueStats>;
25
+ getState(): Promise<SyncState>;
26
+ setState(state: Partial<SyncState>): Promise<void>;
27
+ resetProcessing(): Promise<number>;
28
+ clear(): Promise<void>;
29
+ close(): Promise<void>;
30
+ }
@@ -0,0 +1,54 @@
1
+ import type { SyncQueueInput, SyncQueueItem, SyncQueueItemStatus, SyncQueueStats, SyncQueueStorage, SyncState } from "./types";
2
+ /**
3
+ * Generic interface for SQLite database (works with better-sqlite3 and bun:sqlite)
4
+ */
5
+ interface SqliteDatabase {
6
+ exec(sql: string): void;
7
+ prepare(sql: string): SqliteStatement;
8
+ close(): void;
9
+ }
10
+ interface SqliteStatement {
11
+ run(...params: unknown[]): {
12
+ changes: number;
13
+ };
14
+ get(...params: unknown[]): unknown;
15
+ all(...params: unknown[]): unknown[];
16
+ }
17
+ /**
18
+ * SQLite implementation of SyncQueueStorage for Node/Bun environments.
19
+ *
20
+ * Works with both `better-sqlite3` (Node) and `bun:sqlite` (Bun).
21
+ */
22
+ export declare class SqliteSyncQueue implements SyncQueueStorage {
23
+ private db;
24
+ /**
25
+ * Create a new SQLite sync queue.
26
+ * @param db - SQLite database instance (from better-sqlite3 or bun:sqlite)
27
+ */
28
+ constructor(db: SqliteDatabase);
29
+ /**
30
+ * Create and open a SQLite database for an account.
31
+ * Helper for common use case.
32
+ *
33
+ * @param accountId - Unique identifier for the account (e.g., address, pubkey hash)
34
+ * @param dataDir - Directory for database files
35
+ * @param Database - SQLite Database constructor (e.g., from better-sqlite3 or bun:sqlite)
36
+ */
37
+ static create(accountId: string, dataDir: string, Database: new (path: string) => any): SqliteSyncQueue;
38
+ private initialize;
39
+ enqueue(items: SyncQueueInput[]): Promise<void>;
40
+ claim(count?: number): Promise<Map<string, SyncQueueItem[]>>;
41
+ complete(id: string): Promise<void>;
42
+ completeMany(ids: string[]): Promise<void>;
43
+ fail(id: string, error: string): Promise<void>;
44
+ getByTxid(txid: string): Promise<SyncQueueItem[]>;
45
+ getByStatus(status: SyncQueueItemStatus, limit?: number): Promise<SyncQueueItem[]>;
46
+ getStats(): Promise<SyncQueueStats>;
47
+ getState(): Promise<SyncState>;
48
+ setState(state: Partial<SyncState>): Promise<void>;
49
+ resetProcessing(): Promise<number>;
50
+ clear(): Promise<void>;
51
+ close(): Promise<void>;
52
+ private rowToItem;
53
+ }
54
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from "./types";
2
+ export { IndexedDbSyncQueue } from "./IndexedDbSyncQueue";
3
+ export { SqliteSyncQueue } from "./SqliteSyncQueue";
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Sync queue types for background transaction processing.
3
+ */
4
+ /**
5
+ * Sync state tracks SSE stream progress.
6
+ */
7
+ export interface SyncState {
8
+ /** Highest score received from SSE, used to resume stream */
9
+ lastQueuedScore: number;
10
+ /** Timestamp of last sync activity */
11
+ lastSyncedAt?: number;
12
+ }
13
+ /**
14
+ * Status of a queue item.
15
+ */
16
+ export type SyncQueueItemStatus = "pending" | "processing" | "done" | "failed";
17
+ /**
18
+ * A single item in the sync queue.
19
+ */
20
+ export interface SyncQueueItem {
21
+ /** Unique per record: `${outpoint}:${score}` */
22
+ id: string;
23
+ /** Outpoint in txid_vout format */
24
+ outpoint: string;
25
+ /** Score from SSE stream (ordering) */
26
+ score: number;
27
+ /** If this is a spend event, the txid that spent it */
28
+ spendTxid?: string;
29
+ /** Current processing status */
30
+ status: SyncQueueItemStatus;
31
+ /** Number of processing attempts */
32
+ attempts: number;
33
+ /** Last error message if failed */
34
+ lastError?: string;
35
+ /** Timestamp when item was queued */
36
+ createdAt: number;
37
+ /** Timestamp of last status update */
38
+ updatedAt: number;
39
+ }
40
+ /**
41
+ * Input for enqueueing new items (fields auto-populated by enqueue).
42
+ */
43
+ export interface SyncQueueInput {
44
+ outpoint: string;
45
+ score: number;
46
+ spendTxid?: string;
47
+ }
48
+ /**
49
+ * Queue statistics (transaction-level counts).
50
+ */
51
+ export interface SyncQueueStats {
52
+ pending: number;
53
+ processing: number;
54
+ done: number;
55
+ failed: number;
56
+ }
57
+ /**
58
+ * Storage interface for the sync queue.
59
+ * Implementations: IndexedDB (browser), SQLite (Node/Bun).
60
+ */
61
+ export interface SyncQueueStorage {
62
+ /**
63
+ * Add items to the queue.
64
+ * Items are created with status 'pending'.
65
+ */
66
+ enqueue(items: SyncQueueInput[]): Promise<void>;
67
+ /**
68
+ * Claim items for processing.
69
+ * Finds pending items, gathers all related items by txid, marks them all
70
+ * as 'processing', and returns them grouped by txid.
71
+ * @param count - Maximum number of seed items to start from (default: 1)
72
+ * @returns Map of txid -> items for that txid
73
+ */
74
+ claim(count?: number): Promise<Map<string, SyncQueueItem[]>>;
75
+ /**
76
+ * Mark an item as complete.
77
+ * @param id - Queue item ID
78
+ */
79
+ complete(id: string): Promise<void>;
80
+ /**
81
+ * Mark multiple items as complete.
82
+ * @param ids - Queue item IDs
83
+ */
84
+ completeMany(ids: string[]): Promise<void>;
85
+ /**
86
+ * Mark an item as failed.
87
+ * @param id - Queue item ID
88
+ * @param error - Error message
89
+ */
90
+ fail(id: string, error: string): Promise<void>;
91
+ /**
92
+ * Get all queue items for a given txid.
93
+ * Used to gather spend info before ingesting a transaction.
94
+ * @param txid - Transaction ID (first 64 chars of outpoint)
95
+ */
96
+ getByTxid(txid: string): Promise<SyncQueueItem[]>;
97
+ /**
98
+ * Get queue items by status.
99
+ * @param status - Status to filter by
100
+ * @param limit - Maximum number of items to return (default: 100)
101
+ */
102
+ getByStatus(status: SyncQueueItemStatus, limit?: number): Promise<SyncQueueItem[]>;
103
+ /**
104
+ * Get queue statistics.
105
+ */
106
+ getStats(): Promise<SyncQueueStats>;
107
+ /**
108
+ * Get sync state.
109
+ */
110
+ getState(): Promise<SyncState>;
111
+ /**
112
+ * Update sync state.
113
+ */
114
+ setState(state: Partial<SyncState>): Promise<void>;
115
+ /**
116
+ * Reset any items stuck in "processing" back to "pending".
117
+ * Called at sync start to recover from crashed sessions.
118
+ */
119
+ resetProcessing(): Promise<number>;
120
+ /**
121
+ * Clear all queue items and reset state.
122
+ * Next sync will start from score 0.
123
+ */
124
+ clear(): Promise<void>;
125
+ /**
126
+ * Close the storage connection.
127
+ */
128
+ close(): Promise<void>;
129
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/wallet-toolbox",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
5
5
  "author": "1Sat Team",
6
6
  "license": "MIT",
@@ -32,10 +32,13 @@
32
32
  "dev": "tsc --watch",
33
33
  "lint": "biome check src",
34
34
  "lint:fix": "biome check --write src",
35
- "test": "bun test"
35
+ "test": "bun test",
36
+ "tester:build": "bun build ./tester/src/entry.ts --outdir ./tester/dist --target browser --splitting --define 'process.env={}' --define 'global=globalThis' --sourcemap=inline",
37
+ "tester": "bun run build && bun run tester:build && bun ./tester/server.ts"
36
38
  },
37
39
  "dependencies": {
38
- "@bsv/sdk": "^1.9.24",
40
+ "@bopen-io/ts-templates": "^1.1.0",
41
+ "@bsv/sdk": "1.9.24",
39
42
  "@bsv/wallet-toolbox": "^1.7.14",
40
43
  "buffer": "^6.0.3"
41
44
  },