@pokt-network/pocket-js
Version:
Pocket-js core package with the main functionalities to interact with the Pocket Network.
63 lines • 1.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MinorityResponse = void 0;
/**
* @class MinorityResponse
*/
var validator_1 = require("../../../utils/validator");
var utils_1 = require("../../../utils");
var output_1 = require("../output");
var MinorityResponse = /** @class */ (function () {
/**
* Minority Response.
* @constructor
* @param {Relay} relay - Array of relays.
*/
function MinorityResponse(relay) {
this.relay = relay;
var valid = this.isValid();
if (utils_1.typeGuard(valid, Error)) {
throw valid;
}
}
/**
*
* Creates a MinorityResponse object using a JSON string
* @param {String} json - JSON string.
* @returns {MinorityResponse} - MinorityResponse object.
* @memberof MinorityResponse
*/
MinorityResponse.fromJSON = function (json) {
try {
var jsonObject = JSON.parse(json);
return new MinorityResponse(output_1.RelayResponse.fromJSON(JSON.stringify(jsonObject.relay)));
}
catch (error) {
throw error;
}
};
/**
*
* Creates a JSON object with the MinorityResponse properties
* @returns {JSON} - JSON Object.
* @memberof MinorityResponse
*/
MinorityResponse.prototype.toJSON = function () {
return this.relay.toJSON();
};
/**
*
* Check if the MinorityResponse object is valid
* @returns {boolean} - True or false.
* @memberof MinorityResponse
*/
MinorityResponse.prototype.isValid = function () {
if (validator_1.validateRelayResponse(this.relay) === undefined) {
return true;
}
return false;
};
return MinorityResponse;
}());
exports.MinorityResponse = MinorityResponse;
//# sourceMappingURL=minority-response.js.map