@1sat/client 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 (53) hide show
  1. package/dist/errors.d.ts +8 -0
  2. package/dist/errors.d.ts.map +1 -0
  3. package/dist/errors.js +12 -0
  4. package/dist/errors.js.map +1 -0
  5. package/dist/index.d.ts +3 -12
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +3 -16
  8. package/dist/index.js.map +1 -1
  9. package/dist/services/ArcadeClient.d.ts +46 -0
  10. package/dist/services/ArcadeClient.d.ts.map +1 -0
  11. package/dist/services/ArcadeClient.js +108 -0
  12. package/dist/services/ArcadeClient.js.map +1 -0
  13. package/dist/services/BaseClient.d.ts +33 -0
  14. package/dist/services/BaseClient.d.ts.map +1 -0
  15. package/dist/services/BaseClient.js +126 -0
  16. package/dist/services/BaseClient.js.map +1 -0
  17. package/dist/services/BeefClient.d.ts +27 -0
  18. package/dist/services/BeefClient.d.ts.map +1 -0
  19. package/dist/services/BeefClient.js +34 -0
  20. package/dist/services/BeefClient.js.map +1 -0
  21. package/dist/services/Bsv21Client.d.ts +110 -0
  22. package/dist/services/Bsv21Client.d.ts.map +1 -0
  23. package/dist/services/Bsv21Client.js +155 -0
  24. package/dist/services/Bsv21Client.js.map +1 -0
  25. package/dist/services/ChaintracksClient.d.ts +105 -0
  26. package/dist/services/ChaintracksClient.d.ts.map +1 -0
  27. package/dist/services/ChaintracksClient.js +227 -0
  28. package/dist/services/ChaintracksClient.js.map +1 -0
  29. package/dist/services/OneSatServices.d.ts +81 -0
  30. package/dist/services/OneSatServices.d.ts.map +1 -0
  31. package/dist/services/OneSatServices.js +401 -0
  32. package/dist/services/OneSatServices.js.map +1 -0
  33. package/dist/services/OrdfsClient.d.ts +48 -0
  34. package/dist/services/OrdfsClient.d.ts.map +1 -0
  35. package/dist/services/OrdfsClient.js +124 -0
  36. package/dist/services/OrdfsClient.js.map +1 -0
  37. package/dist/services/OverlayClient.d.ts +50 -0
  38. package/dist/services/OverlayClient.d.ts.map +1 -0
  39. package/dist/services/OverlayClient.js +48 -0
  40. package/dist/services/OverlayClient.js.map +1 -0
  41. package/dist/services/OwnerClient.d.ts +42 -0
  42. package/dist/services/OwnerClient.d.ts.map +1 -0
  43. package/dist/services/OwnerClient.js +128 -0
  44. package/dist/services/OwnerClient.js.map +1 -0
  45. package/dist/services/TxoClient.d.ts +42 -0
  46. package/dist/services/TxoClient.d.ts.map +1 -0
  47. package/dist/services/TxoClient.js +95 -0
  48. package/dist/services/TxoClient.js.map +1 -0
  49. package/dist/services/index.d.ts +11 -0
  50. package/dist/services/index.d.ts.map +1 -0
  51. package/dist/services/index.js +11 -0
  52. package/dist/services/index.js.map +1 -0
  53. package/package.json +5 -6
@@ -0,0 +1,48 @@
1
+ import { BaseClient } from './BaseClient';
2
+ /**
3
+ * Client for overlay service routes.
4
+ * Handles topic manager queries and overlay lookups.
5
+ */
6
+ export class OverlayClient extends BaseClient {
7
+ constructor(baseUrl, options = {}) {
8
+ super(baseUrl, options);
9
+ }
10
+ /**
11
+ * List all registered topic managers.
12
+ */
13
+ async listTopicManagers() {
14
+ return this.request('/1sat/overlay/listTopicManagers');
15
+ }
16
+ /**
17
+ * List all registered lookup service providers.
18
+ */
19
+ async listLookupServiceProviders() {
20
+ return this.request('/1sat/overlay/listLookupServiceProviders');
21
+ }
22
+ /**
23
+ * Submit a transaction to the overlay service for indexing.
24
+ * @param beef - BEEF data as Uint8Array or number[]
25
+ * @param topics - Topic names to submit to (e.g., ["tm_tokenId"])
26
+ */
27
+ async submit(beef, topics) {
28
+ const beefArray = beef instanceof Uint8Array ? Array.from(beef) : beef;
29
+ return this.request('/1sat/overlay/submit', {
30
+ method: 'POST',
31
+ headers: {
32
+ 'Content-Type': 'application/octet-stream',
33
+ 'X-Topics': JSON.stringify(topics),
34
+ },
35
+ body: new Blob([new Uint8Array(beefArray)]),
36
+ });
37
+ }
38
+ /**
39
+ * Submit a BSV-21 token transaction to the overlay.
40
+ * Convenience method that formats the topic correctly.
41
+ * @param beef - BEEF data
42
+ * @param tokenId - Token ID (txid_vout format)
43
+ */
44
+ async submitBsv21(beef, tokenId) {
45
+ return this.submit(beef, [`tm_${tokenId}`]);
46
+ }
47
+ }
48
+ //# sourceMappingURL=OverlayClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverlayClient.js","sourceRoot":"","sources":["../../src/services/OverlayClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAezC;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;IAC5C,YAAY,OAAe,EAAE,UAAyB,EAAE;QACvD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACxB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB;QACtB,OAAO,IAAI,CAAC,OAAO,CAClB,iCAAiC,CACjC,CAAA;IACF,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,0BAA0B;QAG/B,OAAO,IAAI,CAAC,OAAO,CAClB,0CAA0C,CAC1C,CAAA;IACF,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CACX,IAA2B,EAC3B,MAAgB;QAEhB,MAAM,SAAS,GAAG,IAAI,YAAY,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAEtE,OAAO,IAAI,CAAC,OAAO,CAClB,sBAAsB,EACtB;YACC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACR,cAAc,EAAE,0BAA0B;gBAC1C,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;aAClC;YACD,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;SAC3C,CACD,CAAA;IACF,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAChB,IAA2B,EAC3B,OAAe;QAEf,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC,CAAA;IAC5C,CAAC;CACD"}
@@ -0,0 +1,42 @@
1
+ import type { BalanceResponse, ClientOptions, IndexedOutput, SyncOutput, TxoQueryOptions } from '@1sat/types';
2
+ import { BaseClient } from './BaseClient';
3
+ /**
4
+ * Client for /1sat/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
+ }
42
+ //# sourceMappingURL=OwnerClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OwnerClient.d.ts","sourceRoot":"","sources":["../../src/services/OwnerClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACb,UAAU,EACV,eAAe,EACf,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;;;GAQG;AACH,qBAAa,WAAY,SAAQ,UAAU;gBAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;IAIxD;;OAEG;IACG,OAAO,CACZ,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,eAAe,GAAG;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAC5C,OAAO,CAAC,aAAa,EAAE,CAAC;IAgB3B;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAIzD;;;;;;;;;;OAUG;IACH,IAAI,CACH,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,EACtC,IAAI,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,IAAI,EACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAC9B,MAAM,IAAI;IAoCb;;;OAGG;IACI,YAAY,CAClB,MAAM,EAAE,MAAM,EAAE,EAChB,IAAI,CAAC,EAAE,MAAM,GACX,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC;CAgD5C"}
@@ -0,0 +1,128 @@
1
+ import { BaseClient } from './BaseClient';
2
+ /**
3
+ * Client for /1sat/owner/* routes.
4
+ * Provides owner (address) queries and sync.
5
+ *
6
+ * Routes:
7
+ * - GET /:owner/txos - Get TXOs for owner
8
+ * - GET /:owner/balance - Get balance
9
+ * - GET /sync?owner=... - SSE stream of outputs for sync (supports multiple owners)
10
+ */
11
+ export class OwnerClient extends BaseClient {
12
+ constructor(baseUrl, options = {}) {
13
+ super(`${baseUrl}/1sat/owner`, options);
14
+ }
15
+ /**
16
+ * Get TXOs owned by an address/owner
17
+ */
18
+ async getTxos(owner, opts) {
19
+ const qs = this.buildQueryString({
20
+ tags: opts?.tags,
21
+ from: opts?.from,
22
+ limit: opts?.limit,
23
+ rev: opts?.rev,
24
+ unspent: opts?.unspent,
25
+ sats: opts?.sats,
26
+ spend: opts?.spend,
27
+ events: opts?.events,
28
+ block: opts?.block,
29
+ refresh: opts?.refresh,
30
+ });
31
+ return this.request(`/${owner}/txos${qs}`);
32
+ }
33
+ /**
34
+ * Get balance for an address/owner
35
+ */
36
+ async getBalance(owner) {
37
+ return this.request(`/${owner}/balance`);
38
+ }
39
+ /**
40
+ * Sync outputs for owner(s) via SSE stream.
41
+ * The server merges results from all owners in score order.
42
+ *
43
+ * @param owners - Array of addresses/owners to sync
44
+ * @param onOutput - Callback for each output
45
+ * @param from - Starting score (for pagination/resumption)
46
+ * @param onDone - Callback when sync completes (client should retry after delay)
47
+ * @param onError - Callback for errors
48
+ * @returns Unsubscribe function
49
+ */
50
+ sync(owners, onOutput, from, onDone, onError) {
51
+ const params = new URLSearchParams();
52
+ for (const owner of owners) {
53
+ params.append('owner', owner);
54
+ }
55
+ if (from !== undefined) {
56
+ params.set('from', String(from));
57
+ }
58
+ const url = `${this.baseUrl}/sync?${params.toString()}`;
59
+ const eventSource = new EventSource(url);
60
+ eventSource.onmessage = (event) => {
61
+ try {
62
+ const output = JSON.parse(event.data);
63
+ onOutput(output);
64
+ }
65
+ catch (e) {
66
+ onError?.(e instanceof Error ? e : new Error(String(e)));
67
+ }
68
+ };
69
+ eventSource.addEventListener('done', () => {
70
+ eventSource.close();
71
+ onDone?.();
72
+ });
73
+ eventSource.onerror = () => {
74
+ eventSource.close();
75
+ onError?.(new Error('SSE connection error'));
76
+ };
77
+ return () => {
78
+ eventSource.close();
79
+ };
80
+ }
81
+ /**
82
+ * Sync outputs as an async iterator.
83
+ * Yields SyncOutput objects until the stream is done.
84
+ */
85
+ async *syncIterator(owners, from) {
86
+ const outputs = [];
87
+ let done = false;
88
+ let error = null;
89
+ let resolve = null;
90
+ const unsubscribe = this.sync(owners, (output) => {
91
+ outputs.push(output);
92
+ resolve?.();
93
+ }, from, () => {
94
+ done = true;
95
+ resolve?.();
96
+ }, (e) => {
97
+ error = e;
98
+ resolve?.();
99
+ });
100
+ try {
101
+ while (!done && !error) {
102
+ if (outputs.length > 0) {
103
+ const output = outputs.shift();
104
+ if (output)
105
+ yield output;
106
+ }
107
+ else {
108
+ await new Promise((r) => {
109
+ resolve = r;
110
+ });
111
+ }
112
+ }
113
+ // Yield remaining outputs
114
+ while (outputs.length > 0) {
115
+ const output = outputs.shift();
116
+ if (output)
117
+ yield output;
118
+ }
119
+ if (error) {
120
+ throw error;
121
+ }
122
+ }
123
+ finally {
124
+ unsubscribe();
125
+ }
126
+ }
127
+ }
128
+ //# sourceMappingURL=OwnerClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OwnerClient.js","sourceRoot":"","sources":["../../src/services/OwnerClient.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;;;GAQG;AACH,MAAM,OAAO,WAAY,SAAQ,UAAU;IAC1C,YAAY,OAAe,EAAE,UAAyB,EAAE;QACvD,KAAK,CAAC,GAAG,OAAO,aAAa,EAAE,OAAO,CAAC,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CACZ,KAAa,EACb,IAA8C;QAE9C,MAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;YAChC,IAAI,EAAE,IAAI,EAAE,IAAI;YAChB,IAAI,EAAE,IAAI,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI,EAAE,KAAK;YAClB,GAAG,EAAE,IAAI,EAAE,GAAG;YACd,OAAO,EAAE,IAAI,EAAE,OAAO;YACtB,IAAI,EAAE,IAAI,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI,EAAE,KAAK;YAClB,M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EAAE,CAAA;oBAC9B,IAAI,MAAM;wBAAE,MAAM,MAAM,CAAA;gBACzB,CAAC;qBAAM,CAAC;oBACP,MAAM,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,EAAE;wBAC7B,OAAO,GAAG,CAAC,CAAA;oBACZ,CAAC,CAAC,CAAA;gBACH,CAAC;YACF,CAAC;YAED,0BAA0B;YAC1B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAA;gBAC9B,IAAI,MAAM;oBAAE,MAAM,MAAM,CAAA;YACzB,CAAC;YAED,IAAI,KAAK,EAAE,CAAC;gBACX,MAAM,KAAK,CAAA;YACZ,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,WAAW,EAAE,CAAA;QACd,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,42 @@
1
+ import type { ClientOptions, IndexedOutput, TxoQueryOptions } from '@1sat/types';
2
+ import { BaseClient } from './BaseClient';
3
+ /**
4
+ * Client for /1sat/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
+ }
42
+ //# sourceMappingURL=TxoClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TxoClient.d.ts","sourceRoot":"","sources":["../../src/services/TxoClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,aAAa,EAEb,eAAe,EACf,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;;;;;;GAWG;AACH,qBAAa,SAAU,SAAQ,UAAU;gBAC5B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;IAIxD;;OAEG;IACG,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAU3E;;OAEG;IACG,QAAQ,CACb,SAAS,EAAE,MAAM,EAAE,EACnB,IAAI,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,CAAC,aAAa,GAAG,IAAI,CAAC,EAAE,CAAC;IAcpC;;OAEG;IACG,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKxD;;OAEG;IACG,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAShE;;OAEG;IACG,SAAS,CACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,aAAa,EAAE,CAAC;IAU3B;;OAEG;IACG,MAAM,CACX,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,IAAI,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,aAAa,EAAE,CAAC;CAe3B"}
@@ -0,0 +1,95 @@
1
+ import { BaseClient } from './BaseClient';
2
+ /**
3
+ * Client for /1sat/txo/* routes.
4
+ * Provides TXO (transaction output) lookup and search.
5
+ *
6
+ * Routes:
7
+ * - GET /:outpoint - Get single TXO (outpoint pattern-matched)
8
+ * - GET /:outpoint/spend - Get spend info
9
+ * - POST /outpoints - Get multiple TXOs
10
+ * - POST /spends - Get multiple spends
11
+ * - GET /tx/:txid - Get all TXOs for a transaction
12
+ * - GET /search?key=... - Search by key(s)
13
+ */
14
+ export class TxoClient extends BaseClient {
15
+ constructor(baseUrl, options = {}) {
16
+ super(`${baseUrl}/1sat/txo`, options);
17
+ }
18
+ /**
19
+ * Get a single TXO by outpoint
20
+ */
21
+ async get(outpoint, opts) {
22
+ const qs = this.buildQueryString({
23
+ tags: opts?.tags,
24
+ sats: opts?.sats,
25
+ spend: opts?.spend,
26
+ block: opts?.block,
27
+ });
28
+ return this.request(`/${outpoint}${qs}`);
29
+ }
30
+ /**
31
+ * Get multiple TXOs by outpoints
32
+ */
33
+ async getBatch(outpoints, opts) {
34
+ const qs = this.buildQueryString({
35
+ tags: opts?.tags,
36
+ sats: opts?.sats,
37
+ spend: opts?.spend,
38
+ block: opts?.block,
39
+ });
40
+ return this.request(`/outpoints${qs}`, {
41
+ method: 'POST',
42
+ headers: { 'Content-Type': 'application/json' },
43
+ body: JSON.stringify(outpoints),
44
+ });
45
+ }
46
+ /**
47
+ * Get spend info for an outpoint
48
+ */
49
+ async getSpend(outpoint) {
50
+ const resp = await this.request(`/${outpoint}/spend`);
51
+ return resp.spendTxid;
52
+ }
53
+ /**
54
+ * Get spend info for multiple outpoints
55
+ */
56
+ async getSpends(outpoints) {
57
+ const resp = await this.request('/spends', {
58
+ method: 'POST',
59
+ headers: { 'Content-Type': 'application/json' },
60
+ body: JSON.stringify(outpoints),
61
+ });
62
+ return resp.map((r) => r.spendTxid);
63
+ }
64
+ /**
65
+ * Get all TXOs for a transaction
66
+ */
67
+ async getByTxid(txid, opts) {
68
+ const qs = this.buildQueryString({
69
+ tags: opts?.tags,
70
+ sats: opts?.sats,
71
+ spend: opts?.spend,
72
+ block: opts?.block,
73
+ });
74
+ return this.request(`/tx/${txid}${qs}`);
75
+ }
76
+ /**
77
+ * Search TXOs by key(s)
78
+ */
79
+ async search(keys, opts) {
80
+ const qs = this.buildQueryString({
81
+ key: Array.isArray(keys) ? keys : [keys],
82
+ tags: opts?.tags,
83
+ from: opts?.from,
84
+ limit: opts?.limit,
85
+ rev: opts?.rev,
86
+ unspent: opts?.unspent,
87
+ sats: opts?.sats,
88
+ spend: opts?.spend,
89
+ events: opts?.events,
90
+ block: opts?.block,
91
+ });
92
+ return this.request(`/search${qs}`);
93
+ }
94
+ }
95
+ //# sourceMappingURL=TxoClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TxoClient.js","sourceRoot":"","sources":["../../src/services/TxoClient.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,SAAU,SAAQ,UAAU;IACxC,YAAY,OAAe,EAAE,UAAyB,EAAE;QACvD,KAAK,CAAC,GAAG,OAAO,WAAW,EAAE,OAAO,CAAC,CAAA;IACtC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,QAAgB,EAAE,IAAsB;QACjD,MAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;YAChC,IAAI,EAAE,IAAI,EAAE,IAAI;YAChB,IAAI,EAAE,IAAI,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI,EAAE,KAAK;YAClB,KAAK,EAAE,IAAI,EAAE,KAAK;SAClB,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,OAAO,CAAgB,IAAI,QAAQ,GAAG,EAAE,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ChB,IAAI,EAAE,IAAI,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI,EAAE,KAAK;YAClB,KAAK,EAAE,IAAI,EAAE,KAAK;SAClB,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,OAAO,CAAkB,OAAO,IAAI,GAAG,EAAE,EAAE,CAAC,CAAA;IACzD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACX,IAAuB,EACvB,IAAsB;QAEtB,MAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;YAChC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACxC,IAAI,EAAE,IAAI,EAAE,IAAI;YAChB,IAAI,EAAE,IAAI,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI,EAAE,KAAK;YAClB,GAAG,EAAE,IAAI,EAAE,GAAG;YACd,OAAO,EAAE,IAAI,EAAE,OAAO;YACtB,IAAI,EAAE,IAAI,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI,EAAE,KAAK;YAClB,MAAM,EAAE,IAAI,EAAE,MAAM;YACpB,KAAK,EAAE,IAAI,EAAE,KAAK;SAClB,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,OAAO,CAAkB,UAAU,EAAE,EAAE,CAAC,CAAA;IACrD,CAAC;CACD"}
@@ -0,0 +1,11 @@
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, type OutputQueryOptions } from './Bsv21Client';
9
+ export { OverlayClient } from './OverlayClient';
10
+ export { OneSatServices } from './OneSatServices';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,11 @@
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';
9
+ export { OverlayClient } from './OverlayClient';
10
+ export { OneSatServices } from './OneSatServices';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAA2B,MAAM,eAAe,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/client",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "API client for 1Sat Ordinals SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,15 +20,14 @@
20
20
  "keywords": ["1sat", "bsv", "ordinals", "client", "api"],
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@1sat/types": "workspace:*",
24
- "@1sat/constants": "workspace:*",
25
- "satoshi-token": "^0.0.4"
23
+ "@1sat/types": "^0.0.3",
24
+ "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@1.7.24-idb-fix.1"
26
25
  },
27
26
  "peerDependencies": {
28
- "@bsv/sdk": "^1.9.0"
27
+ "@bsv/sdk": "^1.10.4"
29
28
  },
30
29
  "devDependencies": {
31
- "@bsv/sdk": "^1.9.24",
30
+ "@bsv/sdk": "^1.10.4",
32
31
  "typescript": "^5.9.3"
33
32
  }
34
33
  }