UNPKG

@altangent/lib-blockbook

Version:
41 lines 1.44 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BlockbookClient = void 0; const lib_http_1 = require("@altangent/lib-http"); const querystring_1 = __importDefault(require("querystring")); class BlockbookClient { constructor(url) { this.url = url; } async status() { const path = `/api/v2`; return this.get(path); } async blockhash(height) { const path = `/api/v2/block-index/${height}`; return this.get(path); } async tx(txid) { const path = `/api/v2/tx/${txid}`; return this.get(path); } async address(address, options = {}) { const query = querystring_1.default.encode(options); const path = `/api/v2/address/${address}${query ? "?" + query : ""}`; return this.get(path); } async block(heightOrHash, options = {}) { 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