mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-20 23:48:10 -07:00
website_next: move hash logic to clients
This commit is contained in:
@@ -8,17 +8,10 @@ const MAX_SCANNED_ADDRESSES = 1_000;
|
||||
|
||||
/**
|
||||
* @typedef {import("../derive/address.js").AddressScript} AddressScript
|
||||
* @typedef {import("../derive/index.js").AddressType} AddressType
|
||||
* @typedef {import("../lookup/index.js").AddressClient} AddressClient
|
||||
* @typedef {import("../lookup/index.js").WalletAddress} WalletAddress
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} AddressClient
|
||||
* @property {string} domain
|
||||
* @property {(address: string, options?: { cache?: boolean }) => Promise<unknown>} getAddress
|
||||
* @property {(addrType: AddressType, prefix: string, options?: { cache?: boolean }) => Promise<unknown>} getAddressHashPrefixMatches
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ScanProgress
|
||||
* @property {number} scannedCount
|
||||
|
||||
@@ -25,17 +25,10 @@ const descriptorBranches = /** @type {const} */ ([
|
||||
|
||||
/**
|
||||
* @typedef {import("../derive/address.js").AddressScript} AddressScript
|
||||
* @typedef {import("../derive/index.js").AddressType} AddressType
|
||||
* @typedef {import("../lookup/index.js").AddressClient} AddressClient
|
||||
* @typedef {import("./branch.js").WalletAddress} WalletAddress
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} AddressClient
|
||||
* @property {string} domain
|
||||
* @property {(address: string, options?: { cache?: boolean }) => Promise<unknown>} getAddress
|
||||
* @property {(addrType: AddressType, prefix: string, options?: { cache?: boolean }) => Promise<unknown>} getAddressHashPrefixMatches
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {WalletAddress & {
|
||||
* branchId: WalletBranchId,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { addressScripts } from "../derive/script.js";
|
||||
|
||||
/**
|
||||
* @typedef {import("../derive/address.js").AddressScript} AddressScript
|
||||
* @typedef {import("../derive/index.js").AddressType} AddressType
|
||||
* @typedef {import("../lookup/index.js").AddressClient} AddressClient
|
||||
* @typedef {Awaited<ReturnType<typeof scanBranches>>["addresses"][number]} WalletAddress
|
||||
* @typedef {Awaited<ReturnType<typeof scanBranches>>} ScriptScan
|
||||
*/
|
||||
@@ -18,11 +18,9 @@ import { addressScripts } from "../derive/script.js";
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} WalletScanClient
|
||||
* @property {string} domain
|
||||
* @property {(address: string, options?: { cache?: boolean }) => Promise<unknown>} getAddress
|
||||
* @property {(addrType: AddressType, prefix: string, options?: { cache?: boolean }) => Promise<unknown>} getAddressHashPrefixMatches
|
||||
* @property {(options?: { cache?: boolean }) => Promise<unknown>} getLivePrice
|
||||
* @typedef {AddressClient & {
|
||||
* getLivePrice(options?: { cache?: boolean }): Promise<number>,
|
||||
* }} WalletScanClient
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -135,9 +133,7 @@ export async function scanWalletAddresses({
|
||||
|
||||
const addresses = scans.flatMap((scan) => scan.addresses)
|
||||
.sort(compareWalletAddresses);
|
||||
const btcUsdPrice = /** @type {number} */ (
|
||||
await client.getLivePrice({ cache: false })
|
||||
);
|
||||
const btcUsdPrice = await client.getLivePrice({ cache: false });
|
||||
|
||||
return {
|
||||
addresses,
|
||||
|
||||
Reference in New Issue
Block a user