UNPKG

@helium/http

Version:

HTTP library for interacting with the Helium blockchain API

86 lines 3.65 kB
"use strict"; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const camelcase_keys_1 = __importDefault(require("camelcase-keys")); const Transactions_1 = __importDefault(require("../resources/Transactions")); const DataModel_1 = __importDefault(require("./DataModel")); const Witnesses_1 = __importDefault(require("../resources/Witnesses")); const Rewards_1 = __importDefault(require("../resources/Rewards")); const Challenges_1 = __importDefault(require("../resources/Challenges")); const Roles_1 = __importDefault(require("../resources/Roles")); class Hotspot extends DataModel_1.default { constructor(client, hotspot) { var _a, _b, _c, _d; super(); this.client = client; this.scoreUpdateHeight = hotspot.score_update_height; this.score = hotspot.score; this.rewardScale = hotspot.reward_scale; this.owner = hotspot.owner; this.payer = hotspot.payer; this.name = hotspot.name; this.location = hotspot.location; this.locationHex = hotspot.location_hex; this.lng = hotspot.lng; this.lat = hotspot.lat; this.block = hotspot.block; this.status = { timestamp: (_a = hotspot.status) === null || _a === void 0 ? void 0 : _a.timestamp, height: ((_b = hotspot.status) === null || _b === void 0 ? void 0 : _b.height) || 0, online: ((_c = hotspot.status) === null || _c === void 0 ? void 0 : _c.online) || '', listenAddrs: ((_d = hotspot.status) === null || _d === void 0 ? void 0 : _d.listen_addrs) || [], }; this.nonce = hotspot.nonce; this.speculativeNonce = hotspot.speculative_nonce; this.blockAdded = hotspot.block_added; this.timestampAdded = hotspot.timestamp_added; this.lastPocChallenge = hotspot.last_poc_challenge; this.lastChangeBlock = hotspot.last_change_block; this.gain = hotspot.gain; this.elevation = hotspot.elevation; this.mode = hotspot.mode; if (hotspot.geocode) { this.geocode = (0, camelcase_keys_1.default)(hotspot.geocode); } this.address = hotspot.address; } get activity() { return new Transactions_1.default(this.client, this); } get roles() { return new Roles_1.default(this.client, this); } get witnesses() { return new Witnesses_1.default(this.client, this, 'witnesses'); } get witnessed() { return new Witnesses_1.default(this.client, this, 'witnessed'); } get rewards() { return new Rewards_1.default(this.client, this); } get challenges() { return new Challenges_1.default(this.client, this); } get data() { // eslint-disable-next-line @typescript-eslint/no-unused-vars const _a = this, { client } = _a, rest = __rest(_a, ["client"]); // @ts-ignore return Object.assign({}, rest); } } exports.default = Hotspot; //# sourceMappingURL=Hotspot.js.map