@altangent/lib-blockbook
Advanced tools
Comparing version 0.12.5 to 0.12.6
@@ -12,2 +12,3 @@ import { AddressOptions } from "./AddressOptions"; | ||
block(heightOrHash: number | string, options?: BlockOptions): Promise<V2.Block>; | ||
get<T>(path: string): Promise<T>; | ||
} |
@@ -14,23 +14,29 @@ "use strict"; | ||
async status() { | ||
const url = `${this.url}/api/`; | ||
return (await (0, lib_http_1.request)({ url })); | ||
const path = `/api/v2`; | ||
return this.get(path); | ||
} | ||
async blockhash(height) { | ||
const url = `${this.url}/api/v2/block-index/${height}`; | ||
return (await (0, lib_http_1.request)({ url })); | ||
const path = `/api/v2/block-index/${height}`; | ||
return this.get(path); | ||
} | ||
async tx(txid) { | ||
const url = `${this.url}/api/v2/tx/${txid}`; | ||
return (await (0, lib_http_1.request)({ url })); | ||
const path = `/api/v2/tx/${txid}`; | ||
return this.get(path); | ||
} | ||
async address(address, options = {}) { | ||
const url = `${this.url}/api/v2/address/${address}?${querystring_1.default.encode(options)}`; | ||
return (await (0, lib_http_1.request)({ url })); | ||
const query = querystring_1.default.encode(options); | ||
const path = `/api/v2/address/${address}${query ? "?" + query : ""}`; | ||
return this.get(path); | ||
} | ||
async block(heightOrHash, options = {}) { | ||
const url = `${this.url}/api/v2/block/${heightOrHash}?${querystring_1.default.encode(options)}`; | ||
return (await (0, lib_http_1.request)({ url })); | ||
const query = querystring_1.default.encode(options); | ||
const path = `/api/v2/block/${heightOrHash}${query ? "?" + query : ""}`; | ||
return this.get(path); | ||
} | ||
async get(path) { | ||
const url = `${this.url}${path}`; | ||
return (await (0, lib_http_1.request)({ url, rejectUnauthorized: false })); | ||
} | ||
} | ||
exports.BlockbookClient = BlockbookClient; | ||
//# sourceMappingURL=BlockbookClient.js.map |
@@ -11,19 +11,20 @@ import { request } from "@altangent/lib-http"; | ||
public async status(): Promise<V2.Status> { | ||
const url = `${this.url}/api/`; | ||
return (await request({ url })) as V2.Status; | ||
const path = `/api/v2`; | ||
return this.get(path); | ||
} | ||
public async blockhash(height: number): Promise<V2.BlockHash> { | ||
const url = `${this.url}/api/v2/block-index/${height}`; | ||
return (await request({ url })) as V2.BlockHash; | ||
const path = `/api/v2/block-index/${height}`; | ||
return this.get(path); | ||
} | ||
public async tx(txid: string): Promise<V2.Tx> { | ||
const url = `${this.url}/api/v2/tx/${txid}`; | ||
return (await request({ url })) as V2.Tx; | ||
const path = `/api/v2/tx/${txid}`; | ||
return this.get(path); | ||
} | ||
public async address(address: string, options: AddressOptions = {}): Promise<V2.AddressResult> { | ||
const url = `${this.url}/api/v2/address/${address}?${qs.encode(options)}`; | ||
return (await request({ url })) as V2.AddressResult; | ||
const query = qs.encode(options); | ||
const path = `/api/v2/address/${address}${query ? "?" + query : ""}`; | ||
return this.get(path); | ||
} | ||
@@ -35,5 +36,11 @@ | ||
): Promise<V2.Block> { | ||
const url = `${this.url}/api/v2/block/${heightOrHash}?${qs.encode(options)}`; | ||
return (await request({ url })) as V2.Block; | ||
const query = qs.encode(options); | ||
const path = `/api/v2/block/${heightOrHash}${query ? "?" + query : ""}`; | ||
return this.get(path); | ||
} | ||
public async get<T>(path: string): Promise<T> { | ||
const url = `${this.url}${path}`; | ||
return (await request({ url, rejectUnauthorized: false })) as T; | ||
} | ||
} |
{ | ||
"name": "@altangent/lib-blockbook", | ||
"version": "0.12.5", | ||
"version": "0.12.6", | ||
"description": "Basic Blockbook API client", | ||
@@ -27,5 +27,5 @@ "author": "Brian Mancini <bmancini@gmail.com>", | ||
"dependencies": { | ||
"@altangent/lib-http": "^0.12.5" | ||
"@altangent/lib-http": "^0.12.6" | ||
}, | ||
"gitHead": "e10ac030ee0fe0768de607ff2c433b3ec978c288", | ||
"gitHead": "414dd618417fe0f78271cf262a1f7e6a18d98b9a", | ||
"publishConfig": { | ||
@@ -32,0 +32,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3049999
124539
Updated@altangent/lib-http@^0.12.6