@1sat/client 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/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +12 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +3 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -16
- package/dist/index.js.map +1 -1
- package/dist/services/ArcadeClient.d.ts +46 -0
- package/dist/services/ArcadeClient.d.ts.map +1 -0
- package/dist/services/ArcadeClient.js +108 -0
- package/dist/services/ArcadeClient.js.map +1 -0
- package/dist/services/BaseClient.d.ts +33 -0
- package/dist/services/BaseClient.d.ts.map +1 -0
- package/dist/services/BaseClient.js +126 -0
- package/dist/services/BaseClient.js.map +1 -0
- package/dist/services/BeefClient.d.ts +27 -0
- package/dist/services/BeefClient.d.ts.map +1 -0
- package/dist/services/BeefClient.js +34 -0
- package/dist/services/BeefClient.js.map +1 -0
- package/dist/services/Bsv21Client.d.ts +110 -0
- package/dist/services/Bsv21Client.d.ts.map +1 -0
- package/dist/services/Bsv21Client.js +155 -0
- package/dist/services/Bsv21Client.js.map +1 -0
- package/dist/services/ChaintracksClient.d.ts +105 -0
- package/dist/services/ChaintracksClient.d.ts.map +1 -0
- package/dist/services/ChaintracksClient.js +227 -0
- package/dist/services/ChaintracksClient.js.map +1 -0
- package/dist/services/OneSatServices.d.ts +81 -0
- package/dist/services/OneSatServices.d.ts.map +1 -0
- package/dist/services/OneSatServices.js +401 -0
- package/dist/services/OneSatServices.js.map +1 -0
- package/dist/services/OrdfsClient.d.ts +48 -0
- package/dist/services/OrdfsClient.d.ts.map +1 -0
- package/dist/services/OrdfsClient.js +124 -0
- package/dist/services/OrdfsClient.js.map +1 -0
- package/dist/services/OverlayClient.d.ts +50 -0
- package/dist/services/OverlayClient.d.ts.map +1 -0
- package/dist/services/OverlayClient.js +48 -0
- package/dist/services/OverlayClient.js.map +1 -0
- package/dist/services/OwnerClient.d.ts +84 -0
- package/dist/services/OwnerClient.d.ts.map +1 -0
- package/dist/services/OwnerClient.js +241 -0
- package/dist/services/OwnerClient.js.map +1 -0
- package/dist/services/TxoClient.d.ts +42 -0
- package/dist/services/TxoClient.d.ts.map +1 -0
- package/dist/services/TxoClient.js +95 -0
- package/dist/services/TxoClient.js.map +1 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +11 -0
- package/dist/services/index.js.map +1 -0
- package/package.json +5 -6
- package/dist/broadcast/index.d.ts +0 -41
- package/dist/broadcast/index.d.ts.map +0 -1
- package/dist/broadcast/index.js +0 -78
- package/dist/broadcast/index.js.map +0 -1
- package/dist/http/index.d.ts +0 -32
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/index.js +0 -63
- package/dist/http/index.js.map +0 -1
- package/dist/indexer/index.d.ts +0 -65
- package/dist/indexer/index.d.ts.map +0 -1
- package/dist/indexer/index.js +0 -202
- package/dist/indexer/index.js.map +0 -1
- package/dist/input.d.ts +0 -30
- package/dist/input.d.ts.map +0 -1
- package/dist/input.js +0 -46
- package/dist/input.js.map +0 -1
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAE3B,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKhB"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP error with status code for granular error handling
|
|
3
|
+
*/
|
|
4
|
+
export class HttpError extends Error {
|
|
5
|
+
status;
|
|
6
|
+
constructor(status, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.name = 'HttpError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAE3B;IADR,YACQ,MAAc,EACrB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAA;QAHP,WAAM,GAAN,MAAM,CAAQ;QAIrB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA;IACxB,CAAC;CACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @1sat/client - API
|
|
3
|
-
*
|
|
4
|
-
* This package provides:
|
|
5
|
-
* - HTTP client abstraction (browser/Node.js compatible)
|
|
6
|
-
* - UTXO fetching (payment, NFT, token)
|
|
7
|
-
* - Token selection utilities
|
|
8
|
-
* - Transaction broadcasting
|
|
9
|
-
* - Input conversion utilities
|
|
2
|
+
* @1sat/client - API clients for 1Sat services
|
|
10
3
|
*/
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export { createBroadcaster, OneSatBroadcaster, type BroadcasterConfig, } from './broadcast';
|
|
14
|
-
export { inputFromUtxo, inputsFromUtxos, type UnlockTemplate, } from './input';
|
|
4
|
+
export { HttpError } from './errors';
|
|
5
|
+
export { ArcadeClient, BaseClient, BeefClient, Bsv21Client, ChaintracksClient, OneSatServices, OrdfsClient, OwnerClient, OverlayClient, TxoClient, type OutputQueryOptions, } from './services';
|
|
15
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EACN,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,EACT,KAAK,kBAAkB,GACvB,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @1sat/client - API
|
|
3
|
-
*
|
|
4
|
-
* This package provides:
|
|
5
|
-
* - HTTP client abstraction (browser/Node.js compatible)
|
|
6
|
-
* - UTXO fetching (payment, NFT, token)
|
|
7
|
-
* - Token selection utilities
|
|
8
|
-
* - Transaction broadcasting
|
|
9
|
-
* - Input conversion utilities
|
|
2
|
+
* @1sat/client - API clients for 1Sat services
|
|
10
3
|
*/
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
// Indexer (UTXO fetching)
|
|
14
|
-
export { fetchNftUtxos, fetchPayUtxos, fetchTokenUtxos, selectTokenUtxos, } from './indexer';
|
|
15
|
-
// Broadcasting
|
|
16
|
-
export { createBroadcaster, OneSatBroadcaster, } from './broadcast';
|
|
17
|
-
// Input utilities
|
|
18
|
-
export { inputFromUtxo, inputsFromUtxos, } from './input';
|
|
4
|
+
export { HttpError } from './errors';
|
|
5
|
+
export { ArcadeClient, BaseClient, BeefClient, Bsv21Client, ChaintracksClient, OneSatServices, OrdfsClient, OwnerClient, OverlayClient, TxoClient, } from './services';
|
|
19
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EACN,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,GAET,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ClientOptions, Policy, SubmitOptions, TransactionStatus } from '@1sat/types';
|
|
2
|
+
import { BaseClient } from './BaseClient';
|
|
3
|
+
/**
|
|
4
|
+
* Client for /1sat/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
|
+
}
|
|
46
|
+
//# sourceMappingURL=ArcadeClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArcadeClient.d.ts","sourceRoot":"","sources":["../../src/services/ArcadeClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;;;;;GAUG;AACH,qBAAa,YAAa,SAAQ,UAAU;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;IAIxD;;OAEG;IACG,iBAAiB,CACtB,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,EAC5B,OAAO,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,iBAAiB,CAAC;IAY7B;;OAEG;IACG,oBAAoB,CACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,iBAAiB,CAAC;IAI7B;;OAEG;IACG,kBAAkB,CACvB,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,EAAE,EACjC,OAAO,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAe/B;;OAEG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIzD;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAIlC;;;OAGG;IACH,eAAe,CACd,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,EAC7C,aAAa,CAAC,EAAE,MAAM,GACpB,MAAM,IAAI;IAyBb;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAW1B"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Utils } from '@bsv/sdk';
|
|
2
|
+
import { BaseClient } from './BaseClient';
|
|
3
|
+
/**
|
|
4
|
+
* Client for /1sat/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 class ArcadeClient extends BaseClient {
|
|
15
|
+
constructor(baseUrl, options = {}) {
|
|
16
|
+
super(`${baseUrl}/1sat/arcade`, options);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Submit a single transaction for broadcast
|
|
20
|
+
*/
|
|
21
|
+
async submitTransaction(rawTx, options) {
|
|
22
|
+
const bytes = rawTx instanceof Uint8Array ? rawTx : new Uint8Array(rawTx);
|
|
23
|
+
return this.request('/tx', {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/octet-stream',
|
|
27
|
+
...this.buildSubmitHeaders(options),
|
|
28
|
+
},
|
|
29
|
+
body: bytes,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Submit a transaction as hex string
|
|
34
|
+
*/
|
|
35
|
+
async submitTransactionHex(rawTxHex, options) {
|
|
36
|
+
return this.submitTransaction(Utils.toArray(rawTxHex, 'hex'), options);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Submit multiple transactions for broadcast
|
|
40
|
+
*/
|
|
41
|
+
async submitTransactions(rawTxs, options) {
|
|
42
|
+
return this.request('/txs', {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': 'application/json',
|
|
46
|
+
...this.buildSubmitHeaders(options),
|
|
47
|
+
},
|
|
48
|
+
body: JSON.stringify(rawTxs.map((tx) => ({
|
|
49
|
+
rawTx: Utils.toHex(tx instanceof Uint8Array ? Array.from(tx) : tx),
|
|
50
|
+
}))),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get status of a submitted transaction
|
|
55
|
+
*/
|
|
56
|
+
async getStatus(txid) {
|
|
57
|
+
return this.request(`/tx/${txid}`);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get current mining policy
|
|
61
|
+
*/
|
|
62
|
+
async getPolicy() {
|
|
63
|
+
return this.request('/policy');
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Subscribe to transaction status events via SSE
|
|
67
|
+
* Returns unsubscribe function
|
|
68
|
+
*/
|
|
69
|
+
subscribeEvents(callback, callbackToken) {
|
|
70
|
+
const url = callbackToken
|
|
71
|
+
? `${this.baseUrl}/events?token=${encodeURIComponent(callbackToken)}`
|
|
72
|
+
: `${this.baseUrl}/events`;
|
|
73
|
+
const eventSource = new EventSource(url);
|
|
74
|
+
eventSource.onmessage = (event) => {
|
|
75
|
+
try {
|
|
76
|
+
const status = JSON.parse(event.data);
|
|
77
|
+
callback(status);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Ignore parse errors
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
eventSource.onerror = () => {
|
|
84
|
+
eventSource.close();
|
|
85
|
+
};
|
|
86
|
+
return () => {
|
|
87
|
+
eventSource.close();
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Build headers for submit requests
|
|
92
|
+
*/
|
|
93
|
+
buildSubmitHeaders(options) {
|
|
94
|
+
const headers = {};
|
|
95
|
+
if (options?.callbackUrl)
|
|
96
|
+
headers['X-CallbackUrl'] = options.callbackUrl;
|
|
97
|
+
if (options?.callbackToken)
|
|
98
|
+
headers['X-CallbackToken'] = options.callbackToken;
|
|
99
|
+
if (options?.fullStatusUpdates)
|
|
100
|
+
headers['X-FullStatusUpdates'] = 'true';
|
|
101
|
+
if (options?.skipFeeValidation)
|
|
102
|
+
headers['X-SkipFeeValidation'] = 'true';
|
|
103
|
+
if (options?.skipScriptValidation)
|
|
104
|
+
headers['X-SkipScriptValidation'] = 'true';
|
|
105
|
+
return headers;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=ArcadeClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArcadeClient.js","sourceRoot":"","sources":["../../src/services/ArcadeClient.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,YAAa,SAAQ,UAAU;IAC3C,YAAY,OAAe,EAAE,UAAyB,EAAE;QACvD,KAAK,CAAC,GAAG,OAAO,cAAc,EAAE,OAAO,CAAC,CAAA;IACzC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB,CACtB,KAA4B,EAC5B,OAAuB;QAEvB,MAAM,KAAK,GAAG,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA;QACzE,OAAO,IAAI,CAAC,OAAO,CAAoB,KAAK,EAAE;YAC7C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACR,cAAc,EAAE,0BAA0B;gBAC1C,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;aACnC;YACD,IAAI,EAAE,KAA4B;SAClC,CAAC,CAAA;IACH,CAAC;IAED;;OAEG;IACH,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C,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE;YACjC,IAAI,CAAC;gBACJ,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAsB,CAAA;gBAC1D,QAAQ,CAAC,MAAM,CAAC,CAAA;YACjB,CAAC;YAAC,MAAM,CAAC;gBACR,sBAAsB;YACvB,CAAC;QACF,CAAC,CAAA;QAED,WAAW,CAAC,OAAO,GAAG,GAAG,EAAE;YAC1B,WAAW,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC,CAAA;QAED,OAAO,GAAG,EAAE;YACX,WAAW,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC,CAAA;IACF,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,OAAuB;QACjD,MAAM,OAAO,GAA2B,EAAE,CAAA;QAC1C,IAAI,OAAO,EAAE,WAAW;YAAE,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,WAAW,CAAA;QACxE,IAAI,OAAO,EAAE,aAAa;YACzB,OAAO,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,aAAa,CAAA;QACnD,IAAI,OAAO,EAAE,iBAAiB;YAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,MAAM,CAAA;QACvE,IAAI,OAAO,EAAE,iBAAiB;YAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,MAAM,CAAA;QACvE,IAAI,OAAO,EAAE,oBAAoB;YAChC,OAAO,CAAC,wBAAwB,CAAC,GAAG,MAAM,CAAA;QAC3C,OAAO,OAAO,CAAA;IACf,CAAC;CACD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ClientOptions } from '@1sat/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
|
+
}
|
|
33
|
+
//# sourceMappingURL=BaseClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../../src/services/BaseClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGhD;;;GAGG;AACH,qBAAa,UAAU;IACtB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAClC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAClC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,KAAK,CAAA;gBAE5B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;IAMxD;;OAEG;cACa,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IA0BxE;;OAEG;cACa,aAAa,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,WAAW,GAChB,OAAO,CAAC,UAAU,CAAC;IAqBtB;;;OAGG;cACa,UAAU,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,WAAW,GAChB,OAAO,CAAC,QAAQ,CAAC;IAoBpB;;OAEG;YACW,UAAU;IAgBxB;;OAEG;IACH,SAAS,CAAC,gBAAgB,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GACtE,MAAM;CAqBT"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { HttpError } from '../errors';
|
|
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 class BaseClient {
|
|
7
|
+
baseUrl;
|
|
8
|
+
timeout;
|
|
9
|
+
fetchFn;
|
|
10
|
+
constructor(baseUrl, options = {}) {
|
|
11
|
+
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
12
|
+
this.timeout = options.timeout ?? 30000;
|
|
13
|
+
this.fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Make a JSON request and parse the response
|
|
17
|
+
*/
|
|
18
|
+
async request(path, init) {
|
|
19
|
+
const controller = new AbortController();
|
|
20
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
21
|
+
try {
|
|
22
|
+
const response = await this.fetchFn(`${this.baseUrl}${path}`, {
|
|
23
|
+
...init,
|
|
24
|
+
signal: controller.signal,
|
|
25
|
+
});
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw await this.parseError(response);
|
|
28
|
+
}
|
|
29
|
+
// Handle empty responses
|
|
30
|
+
const text = await response.text();
|
|
31
|
+
if (!text) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return JSON.parse(text);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
clearTimeout(timeoutId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Make a request and return raw binary data
|
|
42
|
+
*/
|
|
43
|
+
async requestBinary(path, init) {
|
|
44
|
+
const controller = new AbortController();
|
|
45
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
46
|
+
try {
|
|
47
|
+
const response = await this.fetchFn(`${this.baseUrl}${path}`, {
|
|
48
|
+
...init,
|
|
49
|
+
signal: controller.signal,
|
|
50
|
+
});
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
throw await this.parseError(response);
|
|
53
|
+
}
|
|
54
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
55
|
+
return new Uint8Array(arrayBuffer);
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
clearTimeout(timeoutId);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Make a request and return the raw Response object
|
|
63
|
+
* Useful for streaming responses
|
|
64
|
+
*/
|
|
65
|
+
async requestRaw(path, init) {
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
68
|
+
try {
|
|
69
|
+
const response = await this.fetchFn(`${this.baseUrl}${path}`, {
|
|
70
|
+
...init,
|
|
71
|
+
signal: controller.signal,
|
|
72
|
+
});
|
|
73
|
+
if (!response.ok) {
|
|
74
|
+
throw await this.parseError(response);
|
|
75
|
+
}
|
|
76
|
+
return response;
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
clearTimeout(timeoutId);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Parse error response into HttpError
|
|
84
|
+
*/
|
|
85
|
+
async parseError(response) {
|
|
86
|
+
try {
|
|
87
|
+
const data = await response.json();
|
|
88
|
+
const message = data.message || data.error || data.detail || response.statusText;
|
|
89
|
+
return new HttpError(response.status, message);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
try {
|
|
93
|
+
const text = await response.text();
|
|
94
|
+
return new HttpError(response.status, text || response.statusText);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return new HttpError(response.status, response.statusText);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Build query string from options object
|
|
103
|
+
*/
|
|
104
|
+
buildQueryString(params) {
|
|
105
|
+
const entries = [];
|
|
106
|
+
for (const [key, value] of Object.entries(params)) {
|
|
107
|
+
if (value === undefined)
|
|
108
|
+
continue;
|
|
109
|
+
if (Array.isArray(value)) {
|
|
110
|
+
if (value.length > 0) {
|
|
111
|
+
entries.push(`${key}=${encodeURIComponent(value.join(','))}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (typeof value === 'boolean') {
|
|
115
|
+
if (value) {
|
|
116
|
+
entries.push(`${key}=true`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
entries.push(`${key}=${encodeURIComponent(String(value))}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return entries.length > 0 ? `?${entries.join('&')}` : '';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=BaseClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseClient.js","sourceRoot":"","sources":["../../src/services/BaseClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC;;;GAGG;AACH,MAAM,OAAO,UAAU;IACH,OAAO,CAAQ;IACf,OAAO,CAAQ;IACf,OAAO,CAAc;IAExC,YAAY,OAAe,EAAE,UAAyB,EAAE;QACvD,IAAI,CAAC,OAAO,GA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AI,KAAK,EAAE,CAAC;oBACX,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,CAAA;gBAC5B,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAA;YAC5D,CAAC;QACF,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IACzD,CAAC;CACD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ClientOptions } from '@1sat/types';
|
|
2
|
+
import { BaseClient } from './BaseClient';
|
|
3
|
+
/**
|
|
4
|
+
* Client for /1sat/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
|
+
}
|
|
27
|
+
//# sourceMappingURL=BeefClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeefClient.d.ts","sourceRoot":"","sources":["../../src/services/BeefClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;;;GAQG;AACH,qBAAa,UAAW,SAAQ,UAAU;gBAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;IAIxD;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAIhD;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAIjD;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAGjD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseClient } from './BaseClient';
|
|
2
|
+
/**
|
|
3
|
+
* Client for /1sat/beef/* routes.
|
|
4
|
+
* Provides BEEF data, raw transactions, and merkle proofs.
|
|
5
|
+
*
|
|
6
|
+
* Routes:
|
|
7
|
+
* - GET /:txid - Get BEEF for transaction
|
|
8
|
+
* - GET /:txid/raw - Get raw transaction bytes
|
|
9
|
+
* - GET /:txid/proof - Get merkle proof
|
|
10
|
+
*/
|
|
11
|
+
export class BeefClient extends BaseClient {
|
|
12
|
+
constructor(baseUrl, options = {}) {
|
|
13
|
+
super(`${baseUrl}/1sat/beef`, options);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get BEEF (Background Evaluation Extended Format) for a transaction
|
|
17
|
+
*/
|
|
18
|
+
async getBeef(txid) {
|
|
19
|
+
return this.requestBinary(`/${txid}`);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get raw transaction bytes
|
|
23
|
+
*/
|
|
24
|
+
async getRawTx(txid) {
|
|
25
|
+
return this.requestBinary(`/${txid}/tx`);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get merkle proof bytes for a mined transaction
|
|
29
|
+
*/
|
|
30
|
+
async getProof(txid) {
|
|
31
|
+
return this.requestBinary(`/${txid}/proof`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=BeefClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeefClient.js","sourceRoot":"","sources":["../../src/services/BeefClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;;;GAQG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IACzC,YAAY,OAAe,EAAE,UAAyB,EAAE;QACvD,KAAK,CAAC,GAAG,OAAO,YAAY,EAAE,OAAO,CAAC,CAAA;IACvC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;IACtC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,KAAK,CAAC,CAAA;IACzC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,QAAQ,CAAC,CAAA;IAC5C,CAAC;CACD"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Bsv21TransactionData, ClientOptions, IndexedOutput, TokenDetailResponse } from '@1sat/types';
|
|
2
|
+
import { BaseClient } from './BaseClient';
|
|
3
|
+
/**
|
|
4
|
+
* Query options for /outputs validation endpoints.
|
|
5
|
+
* All flags default to false on the server.
|
|
6
|
+
*/
|
|
7
|
+
export interface OutputQueryOptions {
|
|
8
|
+
/** Filter for unspent outputs only */
|
|
9
|
+
unspent?: boolean;
|
|
10
|
+
/** Include spend txid */
|
|
11
|
+
spend?: boolean;
|
|
12
|
+
/** Include satoshis */
|
|
13
|
+
sats?: boolean;
|
|
14
|
+
/** Include events array */
|
|
15
|
+
events?: boolean;
|
|
16
|
+
/** Include block info */
|
|
17
|
+
block?: boolean;
|
|
18
|
+
/** Comma-separated data tags to include (e.g. 'bsv21') */
|
|
19
|
+
tags?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Client for /1sat/bsv21/* routes.
|
|
23
|
+
* Provides BSV21 token queries.
|
|
24
|
+
*
|
|
25
|
+
* Routes:
|
|
26
|
+
* - POST /lookup - Bulk lookup token details with funding status
|
|
27
|
+
* - GET /:tokenId - Get token details with funding status
|
|
28
|
+
* - GET /:tokenId/tx/:txid - Get token transaction data
|
|
29
|
+
* - GET /:tokenId/:lockType/:address/balance - Get token balance
|
|
30
|
+
* - GET /:tokenId/:lockType/:address/unspent - Get unspent token UTXOs
|
|
31
|
+
* - GET /:tokenId/:lockType/:address/history - Get token transaction history
|
|
32
|
+
* - POST /:tokenId/:lockType/balance - Multi-address token balance
|
|
33
|
+
* - POST /:tokenId/:lockType/unspent - Multi-address unspent token UTXOs
|
|
34
|
+
* - POST /:tokenId/:lockType/history - Multi-address token transaction history
|
|
35
|
+
*/
|
|
36
|
+
export declare class Bsv21Client extends BaseClient {
|
|
37
|
+
private cache;
|
|
38
|
+
constructor(baseUrl: string, options?: ClientOptions);
|
|
39
|
+
/**
|
|
40
|
+
* Bulk lookup token details with funding status.
|
|
41
|
+
* Returns details and active status for multiple tokens in one request.
|
|
42
|
+
* @param tokenIds - Array of token IDs (max 100)
|
|
43
|
+
*/
|
|
44
|
+
lookupTokens(tokenIds: string[]): Promise<TokenDetailResponse[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Get token details with funding status.
|
|
47
|
+
* Results are cached since token deploy data is immutable.
|
|
48
|
+
*/
|
|
49
|
+
getTokenDetails(tokenId: string): Promise<TokenDetailResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Get token transaction data for a specific txid
|
|
52
|
+
*/
|
|
53
|
+
getTokenByTxid(tokenId: string, txid: string): Promise<Bsv21TransactionData>;
|
|
54
|
+
/**
|
|
55
|
+
* Get token balance for an address
|
|
56
|
+
*/
|
|
57
|
+
getBalance(tokenId: string, lockType: string, address: string): Promise<{
|
|
58
|
+
balance: number;
|
|
59
|
+
utxoCount: number;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Get unspent token UTXOs for an address
|
|
63
|
+
*/
|
|
64
|
+
getUnspent(tokenId: string, lockType: string, address: string): Promise<IndexedOutput[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Get token transaction history for an address
|
|
67
|
+
*/
|
|
68
|
+
getHistory(tokenId: string, lockType: string, address: string): Promise<IndexedOutput[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Get token balance for multiple addresses
|
|
71
|
+
* @param addresses - Array of addresses (max 100)
|
|
72
|
+
*/
|
|
73
|
+
getBalanceMulti(tokenId: string, lockType: string, addresses: string[]): Promise<{
|
|
74
|
+
balance: number;
|
|
75
|
+
utxoCount: number;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Get unspent token UTXOs for multiple addresses
|
|
79
|
+
* @param addresses - Array of addresses (max 100)
|
|
80
|
+
*/
|
|
81
|
+
getUnspentMulti(tokenId: string, lockType: string, addresses: string[]): Promise<IndexedOutput[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Get token transaction history for multiple addresses
|
|
84
|
+
* @param addresses - Array of addresses (max 100)
|
|
85
|
+
*/
|
|
86
|
+
getHistoryMulti(tokenId: string, lockType: string, addresses: string[]): Promise<IndexedOutput[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Validate specific outpoints against the token's overlay topic.
|
|
89
|
+
* Returns only those found in the overlay. By default returns minimal data
|
|
90
|
+
* (outpoint + score). Use opts to include additional fields.
|
|
91
|
+
* @param tokenId - Token ID (txid_vout format)
|
|
92
|
+
* @param outpoints - Array of outpoints to validate (max 1000)
|
|
93
|
+
* @param opts - Optional query flags for additional data
|
|
94
|
+
*/
|
|
95
|
+
validateOutputs(tokenId: string, outpoints: string[], opts?: OutputQueryOptions): Promise<IndexedOutput[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Validate a single outpoint against the token's overlay topic.
|
|
98
|
+
* Returns 404 if not found. By default returns minimal data (outpoint + score).
|
|
99
|
+
* @param tokenId - Token ID (txid_vout format)
|
|
100
|
+
* @param outpoint - Outpoint to validate (txid_vout or txid:vout)
|
|
101
|
+
* @param opts - Optional query flags for additional data
|
|
102
|
+
*/
|
|
103
|
+
validateOutput(tokenId: string, outpoint: string, opts?: OutputQueryOptions): Promise<IndexedOutput>;
|
|
104
|
+
private buildOutputQuery;
|
|
105
|
+
/**
|
|
106
|
+
* Clear the token details cache
|
|
107
|
+
*/
|
|
108
|
+
clearCache(): void;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=Bsv21Client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bsv21Client.d.ts","sourceRoot":"","sources":["../../src/services/Bsv21Client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAClC,sCAAsC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,yBAAyB;IACzB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,uBAAuB;IACvB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,2BAA2B;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,yBAAyB;IACzB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;;;;;;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