@pokt-network/pocket-js
Version:
Pocket-js core package with the main functionalities to interact with the Pocket Network.
75 lines • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StdTxModel = void 0;
/**
*
*
* @class StdTxModel
*/
var StdTxModel = /** @class */ (function () {
/**
* StdTxModel.
* @constructor
* @param {number} entropy - Entropy.
* @param {Fee} fee - Fee.
* @param {Msg} msg - Msg.
* @param {Signature} signature - signature.
*/
function StdTxModel(entropy, fee, memo, msg, signature) {
this.entropy = entropy;
this.fee = fee;
this.memo = memo;
this.msg = msg;
this.signature = signature;
if (!this.isValid()) {
throw new TypeError("Invalid StdTxModel properties.");
}
}
/**
*
* Creates a StdTxModel object using a JSON string
* @param {string} json - JSON string.
* @returns {StdTxModel} - StdTxModel object.
* @memberof StdTxModel
*/
StdTxModel.fromJSON = function (json) {
var _a, _b;
try {
var jsonObject = JSON.parse(json);
var fee = { amount: (_a = jsonObject.fee[0]) === null || _a === void 0 ? void 0 : _a.amount, denom: (_b = jsonObject.fee[0]) === null || _b === void 0 ? void 0 : _b.denom };
var msg = jsonObject.msg || {};
var signature = { pub_key: jsonObject.signature.pub_key, signature: jsonObject.signature.signature };
return new StdTxModel(jsonObject.entropy, fee, jsonObject.memo, msg, signature);
}
catch (error) {
throw error;
}
};
/**
*
* Creates a JSON object with the StdTxModel properties
* @returns {JSON} - JSON Object.
* @memberof StdTxModel
*/
StdTxModel.prototype.toJSON = function () {
return {
entropy: this.entropy,
fee: this.fee,
memo: this.memo,
msg: this.msg,
signature: this.signature
};
};
/**
*
* Check if the StdTxModel object is valid
* @returns {boolean} - True or false.
* @memberof StdTxModel
*/
StdTxModel.prototype.isValid = function () {
return true;
};
return StdTxModel;
}());
exports.StdTxModel = StdTxModel;
//# sourceMappingURL=stdtx.js.map