UNPKG

@pokt-network/pocket-js

Version:

Pocket-js core package with the main functionalities to interact with the Pocket Network.

60 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RelayMeta = void 0; /** * * * @class RelayMeta */ var RelayMeta = /** @class */ (function () { /** * Relay Meta. * @constructor * @param {number} blockHeight - Block Height. */ function RelayMeta(blockHeight) { this.blockHeight = blockHeight; if (!this.isValid()) { throw new TypeError("Invalid RelayMeta properties."); } } /** * * Creates a RelayMeta object using a JSON string * @param {string} json - JSON string. * @returns {RelayMeta} - RelayMeta object. * @memberof RelayMeta */ RelayMeta.fromJSON = function (json) { try { var jsonObject = JSON.parse(json); return new RelayMeta(BigInt(jsonObject.block_height)); } catch (error) { throw error; } }; /** * * Creates a JSON object with the RelayMeta properties * @returns {JSON} - JSON Object. * @memberof RelayMeta */ RelayMeta.prototype.toJSON = function () { return { block_height: Number(this.blockHeight.toString()) }; }; /** * * Check if the RelayMeta object is valid * @returns {boolean} - True or false. * @memberof RelayMeta */ RelayMeta.prototype.isValid = function () { return (Number(this.blockHeight) > 0); }; return RelayMeta; }()); exports.RelayMeta = RelayMeta; //# sourceMappingURL=relay-meta.js.map