UNPKG

@pokt-network/pocket-js

Version:

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

61 lines 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StdSignDoc = void 0; var coin_denom_1 = require("./coin-denom"); /** * Model to represent a StdSignDoc which produces the bytes to sign for a given Transaction */ var StdSignDoc = /** @class */ (function () { /** * Constructor for the StdSignDoc class * @throws {Error} Throws an error if the fee is not a number * @param {string} entropy - Random int64. * @param {string} chainId - The chainId of the network to be sent to * @param {string} fee - The amount to pay as a fee for executing this transaction * @param {CoinDenom | undefined} feeDenom - The denomination of the fee amount * @param {string | undefined} memo - The memo field for this account */ function StdSignDoc(entropy, chainID, msg, fee, feeDenom, memo) { this.AMINO_TYPE = "posmint/StdSignDoc"; this.entropy = entropy; this.chainID = chainID; this.msg = msg; this.fee = fee; this.feeDenom = feeDenom ? feeDenom : coin_denom_1.CoinDenom.Upokt; this.memo = memo ? memo : ""; // Number parsing var feeNumber = Number(this.fee) || -1; if (isNaN(feeNumber) || feeNumber < 0) { throw new Error("Invalid fee or < 0"); } else if (this.chainID.length === 0) { throw new Error("Empty chain id"); } } /** * Marshals using Amino * @returns {Buffer} - Buffer representation of the class properties * @memberof StdSignDoc */ StdSignDoc.prototype.marshalAmino = function () { var stdSignDocValue = { chain_id: this.chainID, entropy: this.entropy, fee: [{ amount: this.fee, denom: this.feeDenom.toLowerCase() }], memo: this.memo, msg: this.msg.toStdSignDocMsgObj() }; try { return Buffer.from(JSON.stringify(stdSignDocValue).replace(/\\/g, ""), "utf8"); } catch (err) { throw err; } }; return StdSignDoc; }()); exports.StdSignDoc = StdSignDoc; //# sourceMappingURL=std-sign-doc.js.map