@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
@@ -1,5 +1,5 @@
1
- import { Indexer, type IndexData, type IndexSummary, type ParseContext } from "./types";
2
1
  import type { OneSatServices } from "../services/OneSatServices";
2
+ import { type IndexSummary, Indexer, type ParseContext, type ParseResult, type Txo } from "./types";
3
3
  export interface Bsv21 {
4
4
  id: string;
5
5
  op: string;
@@ -18,7 +18,7 @@ export interface Bsv21 {
18
18
  * Data structure: Bsv21 with id, op, amt, dec, status, etc.
19
19
  *
20
20
  * Basket: 'bsv21'
21
- * Events: address, id, status
21
+ * Events: id, id:status, bsv21:amt
22
22
  */
23
23
  export declare class Bsv21Indexer extends Indexer {
24
24
  owners: Set<string>;
@@ -26,9 +26,9 @@ export declare class Bsv21Indexer extends Indexer {
26
26
  services: OneSatServices;
27
27
  tag: string;
28
28
  name: string;
29
- constructor(owners: Set<string> | undefined, network: "mainnet" | "testnet" | undefined, services: OneSatServices);
30
- parse(ctx: ParseContext, vout: number, _isBroadcasted: boolean): Promise<IndexData | undefined>;
31
- summerize(ctx: ParseContext): Promise<IndexSummary | undefined>;
29
+ constructor(owners: Set<string>, network: "mainnet" | "testnet", services: OneSatServices);
30
+ parse(txo: Txo): Promise<ParseResult | undefined>;
31
+ summarize(ctx: ParseContext): Promise<IndexSummary | undefined>;
32
32
  serialize(bsv21: Bsv21): string;
33
33
  deserialize(str: string): Bsv21;
34
34
  }
@@ -1,5 +1,5 @@
1
- import { Indexer, type IndexData, type ParseContext } from "./types";
2
- export interface Cosign {
1
+ import { Indexer, type ParseResult, type Txo } from "./types";
2
+ export interface CosignData {
3
3
  address: string;
4
4
  cosigner: string;
5
5
  }
@@ -9,5 +9,5 @@ export declare class CosignIndexer extends Indexer {
9
9
  tag: string;
10
10
  name: string;
11
11
  constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
12
- parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
12
+ parse(txo: Txo): Promise<ParseResult | undefined>;
13
13
  }
@@ -1,4 +1,4 @@
1
- import { Indexer, type IndexData, type IndexSummary, type ParseContext } from "./types";
1
+ import { type IndexSummary, Indexer, type ParseContext, type ParseResult, type Txo } from "./types";
2
2
  /**
3
3
  * FundIndexer identifies P2PKH outputs to owned addresses.
4
4
  * These are standard "funding" UTXOs that can be spent normally.
@@ -14,6 +14,6 @@ export declare class FundIndexer extends Indexer {
14
14
  tag: string;
15
15
  name: string;
16
16
  constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
17
- parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
18
- summerize(ctx: ParseContext): Promise<IndexSummary | undefined>;
17
+ parse(txo: Txo): Promise<ParseResult | undefined>;
18
+ summarize(ctx: ParseContext): Promise<IndexSummary | undefined>;
19
19
  }
@@ -1,4 +1,4 @@
1
- import { Indexer, type IndexData, type ParseContext } from "./types";
1
+ import { type IndexSummary, Indexer, type ParseContext, type ParseResult, type Txo } from "./types";
2
2
  export interface File {
3
3
  hash: string;
4
4
  size: number;
@@ -27,5 +27,6 @@ export declare class InscriptionIndexer extends Indexer {
27
27
  tag: string;
28
28
  name: string;
29
29
  constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
30
- parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
30
+ parse(txo: Txo): Promise<ParseResult | undefined>;
31
+ summarize(ctx: ParseContext): Promise<IndexSummary | undefined>;
31
32
  }
@@ -1,10 +1,10 @@
1
- import { Indexer, type IndexData, type IndexSummary, type ParseContext } from "./types";
1
+ import { type IndexSummary, Indexer, type ParseContext, type ParseResult, type Txo } from "./types";
2
2
  export interface LockData {
3
3
  until: number;
4
4
  }
5
5
  export declare class LockIndexer extends Indexer {
6
6
  tag: string;
7
7
  name: string;
8
- parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
9
- summerize(ctx: ParseContext): Promise<IndexSummary | undefined>;
8
+ parse(txo: Txo): Promise<ParseResult | undefined>;
9
+ summarize(ctx: ParseContext): Promise<IndexSummary | undefined>;
10
10
  }
@@ -1,13 +1,12 @@
1
1
  import { Script } from "@bsv/sdk";
2
- import { Indexer, type IndexData, type ParseContext } from "./types";
3
- export declare const MAP_PROTO = "1PuQa7K62MiKCtssSLKy1kh56WWU7MtUR5";
2
+ import { Indexer, type ParseResult, type Txo } from "./types";
4
3
  export declare class MapIndexer extends Indexer {
5
4
  owners: Set<string>;
6
5
  network: "mainnet" | "testnet";
7
6
  tag: string;
8
7
  name: string;
9
8
  constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
10
- parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
9
+ parse(txo: Txo): Promise<ParseResult | undefined>;
11
10
  static parseMap(script: Script, mapPos: number): {
12
11
  [key: string]: unknown;
13
12
  } | undefined;
@@ -1,9 +1,9 @@
1
- import { Indexer, type IndexData, type ParseContext } from "./types";
1
+ import { Indexer, type ParseResult, type Txo } from "./types";
2
2
  export declare class OpNSIndexer extends Indexer {
3
3
  owners: Set<string>;
4
4
  network: "mainnet" | "testnet";
5
5
  tag: string;
6
6
  name: string;
7
7
  constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
8
- parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
8
+ parse(txo: Txo): Promise<ParseResult | undefined>;
9
9
  }
@@ -1,4 +1,4 @@
1
- import { Indexer, type IndexData, type ParseContext, type IndexSummary } from "./types";
1
+ import { type IndexSummary, Indexer, type ParseContext, type ParseResult, type Txo } from "./types";
2
2
  export declare class Listing {
3
3
  payout: number[];
4
4
  price: bigint;
@@ -10,8 +10,8 @@ export declare class OrdLockIndexer extends Indexer {
10
10
  tag: string;
11
11
  name: string;
12
12
  constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
13
- parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
14
- summerize(ctx: ParseContext): Promise<IndexSummary | undefined>;
13
+ parse(txo: Txo): Promise<ParseResult | undefined>;
14
+ summarize(ctx: ParseContext): Promise<IndexSummary | undefined>;
15
15
  serialize(listing: Listing): string;
16
16
  deserialize(str: string): Listing;
17
17
  }
@@ -1,7 +1,7 @@
1
- import { Indexer, type IndexData, type ParseContext, type IndexSummary } from "./types";
1
+ import type { OneSatServices } from "../services/OneSatServices";
2
2
  import type { Inscription } from "./InscriptionIndexer";
3
3
  import type { Sigma } from "./SigmaIndexer";
4
- import type { OneSatServices } from "../services/OneSatServices";
4
+ import { type IndexSummary, Indexer, type ParseContext, type ParseResult, type Txo } from "./types";
5
5
  export interface Origin {
6
6
  outpoint?: string;
7
7
  nonce?: number;
@@ -17,7 +17,21 @@ export declare class OriginIndexer extends Indexer {
17
17
  private services;
18
18
  tag: string;
19
19
  name: string;
20
- constructor(owners: Set<string> | undefined, network: "mainnet" | "testnet" | undefined, services: OneSatServices);
21
- parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
22
- summerize(ctx: ParseContext): Promise<IndexSummary | undefined>;
20
+ constructor(owners: Set<string>, network: "mainnet" | "testnet", services: OneSatServices);
21
+ /**
22
+ * Parse identifies 1-sat ordinal outputs and extracts basic data.
23
+ * Origin tracking (determining if transfer vs new) is done in summarize()
24
+ * since it requires cross-output and cross-input context.
25
+ */
26
+ parse(txo: Txo): Promise<ParseResult | undefined>;
27
+ /**
28
+ * Summarize determines origin tracking (transfer vs new origin) and
29
+ * fetches metadata from OrdFS for transfers.
30
+ */
31
+ summarize(ctx: ParseContext): Promise<IndexSummary | undefined>;
32
+ /**
33
+ * Resolve origins for all 1-sat outputs in the transaction.
34
+ * This determines whether each is a new origin or a transfer.
35
+ */
36
+ private resolveOrigins;
23
37
  }
@@ -1,4 +1,4 @@
1
- import { Indexer, type IndexData, type ParseContext } from "./types";
1
+ import { Indexer, type ParseContext, type ParseResult, type Txo } from "./types";
2
2
  export interface Sigma {
3
3
  algorithm: string;
4
4
  address: string;
@@ -12,5 +12,17 @@ export declare class SigmaIndexer extends Indexer {
12
12
  tag: string;
13
13
  name: string;
14
14
  constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
15
- parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
15
+ /**
16
+ * Parse extracts raw sigma protocol data without validation.
17
+ * Validation requires ctx.spends and is done in summarize().
18
+ */
19
+ parse(txo: Txo): Promise<ParseResult | undefined>;
20
+ /**
21
+ * Validate all sigma signatures against ctx.spends.
22
+ */
23
+ summarize(ctx: ParseContext, _isBroadcasted: boolean): Promise<undefined>;
24
+ /**
25
+ * Find the data position for a sigma in the script (position before the pipe separator).
26
+ */
27
+ private findSigmaDataPos;
16
28
  }
@@ -1,15 +1,14 @@
1
- export { Indexer, type IndexData, type IndexSummary, type ParseContext, type Txo } from "./types";
2
- export type { Bsv21TokenData, Bsv21OutputData, Bsv21TransactionData } from "./types";
1
+ export { Indexer, type IndexData, type IndexSummary, type ParseContext, type ParseResult, type Txo, } from "./types";
2
+ export type { Bsv21TokenData, Bsv21OutputData, Bsv21TransactionData, } from "./types";
3
3
  export { Outpoint } from "./Outpoint";
4
4
  export { parseAddress } from "./parseAddress";
5
5
  export { FundIndexer } from "./FundIndexer";
6
6
  export { LockIndexer } from "./LockIndexer";
7
- export { InscriptionIndexer, type File, type Inscription } from "./InscriptionIndexer";
7
+ export { InscriptionIndexer, type File, type Inscription, } from "./InscriptionIndexer";
8
8
  export { SigmaIndexer, type Sigma } from "./SigmaIndexer";
9
- export { MapIndexer, MAP_PROTO } from "./MapIndexer";
9
+ export { MapIndexer } from "./MapIndexer";
10
10
  export { OriginIndexer, type Origin } from "./OriginIndexer";
11
11
  export { Bsv21Indexer, deriveFundAddress, type Bsv21 } from "./Bsv21Indexer";
12
12
  export { OrdLockIndexer, Listing } from "./OrdLockIndexer";
13
13
  export { OpNSIndexer } from "./OpNSIndexer";
14
- export { CosignIndexer, type Cosign } from "./CosignIndexer";
15
- export { TransactionParser, type ParsedOutput, type ParseResult } from "./TransactionParser";
14
+ export { CosignIndexer, type CosignData } from "./CosignIndexer";
@@ -1,4 +1,4 @@
1
- import type { Transaction } from "@bsv/sdk";
1
+ import type { Transaction, TransactionOutput } from "@bsv/sdk";
2
2
  import type { Outpoint } from "./Outpoint";
3
3
  /**
4
4
  * BSV21 token data structure from overlay API
@@ -42,6 +42,8 @@ export interface Bsv21TransactionData {
42
42
  export interface IndexData {
43
43
  data: unknown;
44
44
  tags: string[];
45
+ /** Optional text content (e.g., from text inscriptions). */
46
+ content?: string;
45
47
  }
46
48
  /**
47
49
  * IndexSummary contains transaction-level summary information
@@ -53,17 +55,27 @@ export interface IndexSummary {
53
55
  data?: unknown;
54
56
  }
55
57
  /**
56
- * Minimal transaction output structure used during parsing
58
+ * Result from Indexer.parse() method
59
+ */
60
+ export interface ParseResult {
61
+ data: unknown;
62
+ tags: string[];
63
+ owner?: string;
64
+ basket?: string;
65
+ /** Optional text content (e.g., from text inscriptions). Truncated to 1000 chars when stored. */
66
+ content?: string;
67
+ }
68
+ /**
69
+ * Transaction output structure used during parsing
57
70
  */
58
71
  export interface Txo {
59
- satoshis: bigint;
60
- script: number[];
72
+ output: TransactionOutput;
73
+ outpoint: Outpoint;
61
74
  owner?: string;
62
75
  basket?: string;
63
76
  data: {
64
77
  [tag: string]: IndexData;
65
78
  };
66
- outpoint: Outpoint;
67
79
  }
68
80
  /**
69
81
  * Minimal context structure for indexer parsing
@@ -88,12 +100,14 @@ export declare abstract class Indexer {
88
100
  abstract name: string;
89
101
  constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
90
102
  /**
91
- * Parses an output and returns the index data if it is relevant to this indexer.
92
- * If the output is not relevant, it returns undefined.
103
+ * Parses a single output in isolation and returns the parse result if relevant.
104
+ * Cannot access other outputs or inputs - only the single Txo.
105
+ * Cross-output/cross-input logic belongs in summarize().
93
106
  */
94
- abstract parse(ctx: ParseContext, vout: number, isBroadcasted: boolean): Promise<IndexData | undefined>;
107
+ abstract parse(txo: Txo): Promise<ParseResult | undefined>;
95
108
  /**
96
- * Evaluates the index data for the entire transaction and returns a summary.
109
+ * Post-parse phase with full transaction context.
110
+ * Used for cross-output/cross-input validation and transaction-level summarization.
97
111
  */
98
- summerize(_ctx: ParseContext, _isBroadcasted: boolean): Promise<IndexSummary | undefined>;
112
+ summarize(_ctx: ParseContext, _isBroadcasted: boolean): Promise<IndexSummary | undefined>;
99
113
  }
@@ -1,83 +1,61 @@
1
- import { Beef, ChainTracker, Transaction } from "@bsv/sdk";
1
+ import { Beef, Transaction } from "@bsv/sdk";
2
2
  import type { WalletStorageManager } from "@bsv/wallet-toolbox/mobile";
3
- import type { WalletServices, GetRawTxResult, GetMerklePathResult, PostBeefResult, GetUtxoStatusResult, GetStatusForTxidsResult, GetScriptHashHistoryResult, BlockHeader, GetUtxoStatusOutputFormat, ServicesCallHistory } from "@bsv/wallet-toolbox/mobile/out/src/sdk/WalletServices.interfaces";
3
+ import type { BlockHeader, GetMerklePathResult, GetRawTxResult, GetScriptHashHistoryResult, GetStatusForTxidsResult, GetUtxoStatusOutputFormat, GetUtxoStatusResult, PostBeefResult, ServicesCallHistory, WalletServices } from "@bsv/wallet-toolbox/mobile/out/src/sdk/WalletServices.interfaces";
4
4
  import type { Chain } from "@bsv/wallet-toolbox/mobile/out/src/sdk/types";
5
5
  import type { TableOutput } from "@bsv/wallet-toolbox/mobile/out/src/storage/schema/tables/TableOutput";
6
- import type { Bsv21TransactionData } from "../indexers/types";
7
- /**
8
- * OrdFS metadata response structure
9
- */
10
- export interface OrdfsMetadata {
11
- outpoint: string;
12
- origin?: string;
13
- sequence: number;
14
- contentType: string;
15
- contentLength: number;
16
- parent?: string;
17
- map?: {
18
- [key: string]: unknown;
19
- };
20
- }
21
- /**
22
- * BSV21 token details from the overlay
23
- */
24
- export interface Bsv21TokenDetails {
25
- id: string;
26
- txid: string;
27
- vout: number;
28
- op: string;
29
- amt: string;
30
- sym?: string;
31
- dec: number;
32
- icon?: string;
33
- }
6
+ import { ArcadeClient, BeefClient, Bsv21Client, ChaintracksClient, OrdfsClient, OwnerClient, TxoClient } from "./client";
7
+ import type { Capability, SyncOutput } from "./types";
8
+ export type { SyncOutput };
34
9
  /**
35
10
  * WalletServices implementation for 1Sat ecosystem.
36
11
  *
37
- * Data sources:
38
- * - ordfs-server - Block headers, merkle proofs, raw transactions
39
- * - OneSat API - Transaction broadcasting
12
+ * Provides access to 1Sat API clients and implements the WalletServices
13
+ * interface required by wallet-toolbox.
14
+ *
15
+ * API Routes:
16
+ * - /api/chaintracks/* - Block headers and chain tracking
17
+ * - /api/beef/* - Raw transactions and proofs
18
+ * - /api/arcade/* - Transaction broadcasting
19
+ * - /api/bsv21/* - BSV21 token data
20
+ * - /api/txo/* - Transaction outputs
21
+ * - /api/owner/* - Address queries and sync
22
+ * - /api/ordfs/* - Content/inscription serving
40
23
  */
41
24
  export declare class OneSatServices implements WalletServices {
42
25
  chain: Chain;
43
- private ordfsBaseUrl;
44
- readonly onesatBaseUrl: string;
45
- private bsv21TokenCache;
46
- private chainTracker;
26
+ readonly baseUrl: string;
47
27
  private storage?;
48
- constructor(chain: Chain, ordfsUrl?: string, onesatUrl?: string, storage?: WalletStorageManager);
49
- getChainTracker(): Promise<ChainTracker>;
28
+ readonly chaintracks: ChaintracksClient;
29
+ readonly beef: BeefClient;
30
+ readonly arcade: ArcadeClient;
31
+ readonly txo: TxoClient;
32
+ readonly owner: OwnerClient;
33
+ readonly ordfs: OrdfsClient;
34
+ readonly bsv21: Bsv21Client;
35
+ constructor(chain: Chain, baseUrl?: string, storage?: WalletStorageManager);
36
+ /**
37
+ * Get list of enabled capabilities from the server
38
+ */
39
+ getCapabilities(): Promise<Capability[]>;
40
+ /**
41
+ * Close all client connections
42
+ */
43
+ close(): void;
44
+ getRawTx(txid: string, _useNext?: boolean): Promise<GetRawTxResult>;
45
+ getChainTracker(): Promise<ChaintracksClient>;
50
46
  getHeaderForHeight(height: number): Promise<number[]>;
51
47
  getHeight(): Promise<number>;
52
- getBsvExchangeRate(): Promise<number>;
53
- getFiatExchangeRate(_currency: "USD" | "GBP" | "EUR", _base?: "USD" | "GBP" | "EUR"): Promise<number>;
54
- getRawTx(txid: string, _useNext?: boolean): Promise<GetRawTxResult>;
55
48
  getMerklePath(txid: string, _useNext?: boolean): Promise<GetMerklePathResult>;
56
49
  postBeef(beef: Beef, txids: string[]): Promise<PostBeefResult[]>;
50
+ getBeefForTxid(txid: string): Promise<Beef>;
57
51
  hashOutputScript(script: string): string;
52
+ getServicesCallHistory(_reset?: boolean): ServicesCallHistory;
53
+ getBsvExchangeRate(): Promise<number>;
54
+ getFiatExchangeRate(_currency: "USD" | "GBP" | "EUR", _base?: "USD" | "GBP" | "EUR"): Promise<number>;
58
55
  getStatusForTxids(_txids: string[], _useNext?: boolean): Promise<GetStatusForTxidsResult>;
59
56
  isUtxo(_output: TableOutput): Promise<boolean>;
60
57
  getUtxoStatus(_output: string, _outputFormat?: GetUtxoStatusOutputFormat, _outpoint?: string, _useNext?: boolean): Promise<GetUtxoStatusResult>;
61
58
  getScriptHashHistory(_hash: string, _useNext?: boolean): Promise<GetScriptHashHistoryResult>;
62
59
  hashToHeader(_hash: string): Promise<BlockHeader>;
63
60
  nLockTimeIsFinal(_txOrLockTime: string | number[] | Transaction | number): Promise<boolean>;
64
- getBeefBytes(txid: string): Promise<number[]>;
65
- getBeefForTxid(txid: string): Promise<Beef>;
66
- /**
67
- * Get OrdFS metadata for an outpoint
68
- * @throws {HttpError} on HTTP errors (check status for specifics)
69
- */
70
- getOrdfsMetadata(outpoint: string): Promise<OrdfsMetadata>;
71
- /**
72
- * Get BSV21 token data by txid from the overlay
73
- * @throws {HttpError} on HTTP errors (check status for specifics)
74
- */
75
- getBsv21TokenByTxid(_tokenId: string, txid: string): Promise<Bsv21TransactionData>;
76
- /**
77
- * Get BSV21 token details (metadata) by token ID
78
- * Results are cached since token details are immutable
79
- * @throws {HttpError} on HTTP errors (check status for specifics)
80
- */
81
- getBsv21TokenDetails(tokenId: string): Promise<Bsv21TokenDetails>;
82
- getServicesCallHistory(_reset?: boolean): ServicesCallHistory;
83
61
  }
@@ -0,0 +1,45 @@
1
+ import type { ClientOptions, Policy, SubmitOptions, TransactionStatus } from "../types";
2
+ import { BaseClient } from "./BaseClient";
3
+ /**
4
+ * Client for /api/arcade/* routes.
5
+ * Provides transaction broadcast and status checking.
6
+ *
7
+ * Routes:
8
+ * - POST /tx - Submit single transaction
9
+ * - POST /txs - Submit multiple transactions
10
+ * - GET /tx/:txid - Get transaction status
11
+ * - GET /policy - Get mining policy
12
+ * - GET /events - SSE stream of transaction events
13
+ */
14
+ export declare class ArcadeClient extends BaseClient {
15
+ constructor(baseUrl: string, options?: ClientOptions);
16
+ /**
17
+ * Submit a single transaction for broadcast
18
+ */
19
+ submitTransaction(rawTx: number[] | Uint8Array, options?: SubmitOptions): Promise<TransactionStatus>;
20
+ /**
21
+ * Submit a transaction as hex string
22
+ */
23
+ submitTransactionHex(rawTxHex: string, options?: SubmitOptions): Promise<TransactionStatus>;
24
+ /**
25
+ * Submit multiple transactions for broadcast
26
+ */
27
+ submitTransactions(rawTxs: (number[] | Uint8Array)[], options?: SubmitOptions): Promise<TransactionStatus[]>;
28
+ /**
29
+ * Get status of a submitted transaction
30
+ */
31
+ getStatus(txid: string): Promise<TransactionStatus>;
32
+ /**
33
+ * Get current mining policy
34
+ */
35
+ getPolicy(): Promise<Policy>;
36
+ /**
37
+ * Subscribe to transaction status events via SSE
38
+ * Returns unsubscribe function
39
+ */
40
+ subscribeEvents(callback: (status: TransactionStatus) => void, callbackToken?: string): () => void;
41
+ /**
42
+ * Build headers for submit requests
43
+ */
44
+ private buildSubmitHeaders;
45
+ }
@@ -0,0 +1,32 @@
1
+ import type { ClientOptions } from "../types";
2
+ /**
3
+ * Base client with shared HTTP utilities for all 1sat-stack API clients.
4
+ * Provides timeout handling, error parsing, and request helpers.
5
+ */
6
+ export declare class BaseClient {
7
+ protected readonly baseUrl: string;
8
+ protected readonly timeout: number;
9
+ protected readonly fetchFn: typeof fetch;
10
+ constructor(baseUrl: string, options?: ClientOptions);
11
+ /**
12
+ * Make a JSON request and parse the response
13
+ */
14
+ protected request<T>(path: string, init?: RequestInit): Promise<T>;
15
+ /**
16
+ * Make a request and return raw binary data
17
+ */
18
+ protected requestBinary(path: string, init?: RequestInit): Promise<Uint8Array>;
19
+ /**
20
+ * Make a request and return the raw Response object
21
+ * Useful for streaming responses
22
+ */
23
+ protected requestRaw(path: string, init?: RequestInit): Promise<Response>;
24
+ /**
25
+ * Parse error response into HttpError
26
+ */
27
+ private parseError;
28
+ /**
29
+ * Build query string from options object
30
+ */
31
+ protected buildQueryString(params: Record<string, string | number | boolean | string[] | undefined>): string;
32
+ }
@@ -0,0 +1,26 @@
1
+ import type { ClientOptions } from "../types";
2
+ import { BaseClient } from "./BaseClient";
3
+ /**
4
+ * Client for /api/beef/* routes.
5
+ * Provides BEEF data, raw transactions, and merkle proofs.
6
+ *
7
+ * Routes:
8
+ * - GET /:txid - Get BEEF for transaction
9
+ * - GET /:txid/raw - Get raw transaction bytes
10
+ * - GET /:txid/proof - Get merkle proof
11
+ */
12
+ export declare class BeefClient extends BaseClient {
13
+ constructor(baseUrl: string, options?: ClientOptions);
14
+ /**
15
+ * Get BEEF (Background Evaluation Extended Format) for a transaction
16
+ */
17
+ getBeef(txid: string): Promise<Uint8Array>;
18
+ /**
19
+ * Get raw transaction bytes
20
+ */
21
+ getRawTx(txid: string): Promise<Uint8Array>;
22
+ /**
23
+ * Get merkle proof bytes for a mined transaction
24
+ */
25
+ getProof(txid: string): Promise<Uint8Array>;
26
+ }
@@ -0,0 +1,46 @@
1
+ import type { Bsv21TokenDetails, Bsv21TransactionData, ClientOptions, IndexedOutput } from "../types";
2
+ import { BaseClient } from "./BaseClient";
3
+ /**
4
+ * Client for /api/bsv21/* routes.
5
+ * Provides BSV21 token queries.
6
+ *
7
+ * Routes:
8
+ * - GET /:tokenId - Get token details
9
+ * - GET /:tokenId/blk/:height - Get token data at block height
10
+ * - GET /:tokenId/tx/:txid - Get token data for transaction
11
+ * - GET /:tokenId/:lockType/:address/balance - Get token balance
12
+ * - GET /:tokenId/:lockType/:address/unspent - Get unspent token UTXOs
13
+ * - GET /:tokenId/:lockType/:address/history - Get token transaction history
14
+ */
15
+ export declare class Bsv21Client extends BaseClient {
16
+ private cache;
17
+ constructor(baseUrl: string, options?: ClientOptions);
18
+ /**
19
+ * Get token details (deploy data).
20
+ * Results are cached since token details are immutable.
21
+ */
22
+ getTokenDetails(tokenId: string): Promise<Bsv21TokenDetails>;
23
+ /**
24
+ * Get token transaction data for a specific txid
25
+ */
26
+ getTokenByTxid(tokenId: string, txid: string): Promise<Bsv21TransactionData>;
27
+ /**
28
+ * Get token balance for an address
29
+ * @param tokenId - Token ID (outpoint of deploy tx)
30
+ * @param lockType - Lock type (e.g., 'p2pkh', 'ordlock')
31
+ * @param address - Address to check
32
+ */
33
+ getBalance(tokenId: string, lockType: string, address: string): Promise<bigint>;
34
+ /**
35
+ * Get unspent token UTXOs for an address
36
+ */
37
+ getUnspent(tokenId: string, lockType: string, address: string): Promise<IndexedOutput[]>;
38
+ /**
39
+ * Get token transaction history for an address
40
+ */
41
+ getHistory(tokenId: string, lockType: string, address: string): Promise<IndexedOutput[]>;
42
+ /**
43
+ * Clear the token details cache
44
+ */
45
+ clearCache(): void;
46
+ }
@@ -0,0 +1,62 @@
1
+ import type { ChainTracker } from "@bsv/sdk";
2
+ import type { BlockHeader, ClientOptions } from "../types";
3
+ import { BaseClient } from "./BaseClient";
4
+ /**
5
+ * Client for /api/chaintracks/* routes.
6
+ * Provides block header data and implements ChainTracker interface.
7
+ *
8
+ * Routes:
9
+ * - GET /tip - Get chain tip
10
+ * - GET /tip/stream - SSE stream of new blocks
11
+ * - GET /height - Get current height
12
+ * - GET /network - Get network type
13
+ * - GET /headers?height=N&count=M - Get raw header bytes
14
+ * - GET /header/height/:height - Get header by height
15
+ * - GET /header/hash/:hash - Get header by hash
16
+ */
17
+ export declare class ChaintracksClient extends BaseClient implements ChainTracker {
18
+ private eventSource;
19
+ private subscribers;
20
+ constructor(baseUrl: string, options?: ClientOptions);
21
+ /**
22
+ * Get current blockchain height (ChainTracker interface)
23
+ */
24
+ currentHeight(): Promise<number>;
25
+ /**
26
+ * Validate merkle root for a given height (ChainTracker interface)
27
+ */
28
+ isValidRootForHeight(root: string, height: number): Promise<boolean>;
29
+ /**
30
+ * Get the network type (main or test)
31
+ */
32
+ getNetwork(): Promise<string>;
33
+ /**
34
+ * Get the current chain tip
35
+ */
36
+ getTip(): Promise<BlockHeader>;
37
+ /**
38
+ * Get block header by height
39
+ */
40
+ getHeaderByHeight(height: number): Promise<BlockHeader>;
41
+ /**
42
+ * Get block header by hash
43
+ */
44
+ getHeaderByHash(hash: string): Promise<BlockHeader>;
45
+ /**
46
+ * Get multiple headers as parsed BlockHeader objects
47
+ */
48
+ getHeaders(height: number, count: number): Promise<BlockHeader[]>;
49
+ /**
50
+ * Get raw header bytes for one or more headers
51
+ */
52
+ getHeaderBytes(height: number, count?: number): Promise<number[]>;
53
+ /**
54
+ * Subscribe to new block notifications via SSE
55
+ * Returns unsubscribe function
56
+ */
57
+ subscribe(callback: (header: BlockHeader) => void): () => void;
58
+ /**
59
+ * Close all connections
60
+ */
61
+ close(): void;
62
+ }