brk-client 0.3.4 → 0.3.5
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/index.js +39 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -29,6 +29,18 @@
|
|
|
29
29
|
* @property {TypeIndex} typeIndex - Index of this address within its type on the blockchain
|
|
30
30
|
* @property {Dollars} realizedPrice - Realized price (average cost basis) in USD
|
|
31
31
|
*/
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {Object} AddrHashPrefixMatches
|
|
34
|
+
* @property {OutputType} addrType
|
|
35
|
+
* @property {string} prefix
|
|
36
|
+
* @property {boolean} truncated
|
|
37
|
+
* @property {Addr[]} addresses
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {Object} AddrHashPrefixParam
|
|
41
|
+
* @property {OutputType} addrType
|
|
42
|
+
* @property {string} prefix
|
|
43
|
+
*/
|
|
32
44
|
/**
|
|
33
45
|
* Address statistics in the mempool (unconfirmed transactions only)
|
|
34
46
|
*
|
|
@@ -1485,6 +1497,12 @@ const _openBrowserCache = (option) => {
|
|
|
1485
1497
|
return caches.open(name).catch(() => null);
|
|
1486
1498
|
};
|
|
1487
1499
|
|
|
1500
|
+
/**
|
|
1501
|
+
* @param {string} url
|
|
1502
|
+
* @returns {URL}
|
|
1503
|
+
*/
|
|
1504
|
+
const _parseBaseUrl = (url) => new URL(url, typeof location === 'undefined' ? undefined : location.href);
|
|
1505
|
+
|
|
1488
1506
|
/**
|
|
1489
1507
|
* Custom error class for BRK client errors
|
|
1490
1508
|
*/
|
|
@@ -1837,6 +1855,9 @@ class BrkClientBase {
|
|
|
1837
1855
|
const isString = typeof options === 'string';
|
|
1838
1856
|
const rawUrl = isString ? options : options.baseUrl;
|
|
1839
1857
|
this.baseUrl = rawUrl.endsWith('/') ? rawUrl.slice(0, -1) : rawUrl;
|
|
1858
|
+
const url = _parseBaseUrl(this.baseUrl);
|
|
1859
|
+
this.url = url.href.endsWith('/') ? url.href.slice(0, -1) : url.href;
|
|
1860
|
+
this.domain = url.hostname;
|
|
1840
1861
|
this.timeout = isString ? 5000 : (options.timeout ?? 5000);
|
|
1841
1862
|
/** @type {Promise<Cache | null>} */
|
|
1842
1863
|
this._browserCachePromise = _openBrowserCache(isString ? undefined : options.browserCache);
|
|
@@ -7872,7 +7893,7 @@ function createTransferPattern(client, acc) {
|
|
|
7872
7893
|
* @extends BrkClientBase
|
|
7873
7894
|
*/
|
|
7874
7895
|
class BrkClient extends BrkClientBase {
|
|
7875
|
-
VERSION = "v0.3.
|
|
7896
|
+
VERSION = "v0.3.5";
|
|
7876
7897
|
|
|
7877
7898
|
INDEXES = /** @type {const} */ ([
|
|
7878
7899
|
"minute10",
|
|
@@ -11476,6 +11497,23 @@ class BrkClient extends BrkClientBase {
|
|
|
11476
11497
|
return this.getJson(path, { signal, onValue, cache });
|
|
11477
11498
|
}
|
|
11478
11499
|
|
|
11500
|
+
/**
|
|
11501
|
+
* Address hash-prefix matches
|
|
11502
|
+
*
|
|
11503
|
+
* Find addresses by address type and address-payload hash prefix. Intended for privacy-preserving client-side wallet discovery without sending raw addresses or xpubs. Fetch metadata for the returned addresses through `/api/address/{address}`.
|
|
11504
|
+
*
|
|
11505
|
+
* Endpoint: `GET /api/address/hash-prefix/{addr_type}/{prefix}`
|
|
11506
|
+
*
|
|
11507
|
+
* @param {OutputType} addr_type
|
|
11508
|
+
* @param {string} prefix
|
|
11509
|
+
* @param {{ signal?: AbortSignal, onValue?: (value: AddrHashPrefixMatches) => void, cache?: boolean }} [options]
|
|
11510
|
+
* @returns {Promise<AddrHashPrefixMatches>}
|
|
11511
|
+
*/
|
|
11512
|
+
async getAddressHashPrefixMatches(addr_type, prefix, { signal, onValue, cache } = {}) {
|
|
11513
|
+
const path = `/api/address/hash-prefix/${addr_type}/${prefix}`;
|
|
11514
|
+
return this.getJson(path, { signal, onValue, cache });
|
|
11515
|
+
}
|
|
11516
|
+
|
|
11479
11517
|
/**
|
|
11480
11518
|
* Address information
|
|
11481
11519
|
*
|
package/package.json
CHANGED