UNPKG

@logosnetwork/logos-webwallet-sdk

Version:

Create Logos wallets with or without a full Logos node

99 lines 3.79 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var Utils_1 = require("../Utils/Utils"); var TokenRequest_1 = __importDefault(require("./TokenRequest")); var Distribute = /** @class */ (function (_super) { __extends(Distribute, _super); function Distribute(options) { if (options === void 0) { options = { transaction: null }; } var _this = this; options.type = { text: 'distribute', value: 12 }; _this = _super.call(this, options) || this; /** * Transaction to distribute the token * @type {string} * @private */ if (options.transaction !== undefined) { _this._transaction = options.transaction; } else { _this._transaction = null; } return _this; } Object.defineProperty(Distribute.prototype, "transaction", { /** * Return the previous request as hash * @type {Transaction} */ get: function () { return this._transaction; }, set: function (transaction) { if (typeof transaction.destination === 'undefined') throw new Error('destination should be passed in transaction object'); if (typeof transaction.amount === 'undefined') throw new Error('amount should be passed in transaction object - pass this as the minor unit of your token (e.g. satoshi)'); this._transaction = transaction; }, enumerable: true, configurable: true }); Object.defineProperty(Distribute.prototype, "hash", { /** * Returns calculated hash or Builds the request and calculates the hash * * @throws An exception if missing parameters or invalid parameters * @type {string} * @readonly */ get: function () { if (this.transaction === null) throw new Error('transaction is not set.'); if (!this.transaction.destination) throw new Error('transaction destination is not set.'); if (!this.transaction.amount) throw new Error('transaction amount is not set.'); return _super.prototype.requestHash.call(this) .update(Utils_1.hexToUint8(Utils_1.keyFromAccount(this.transaction.destination))) .update(Utils_1.hexToUint8(Utils_1.decToHex(this.transaction.amount, 16))) .digest('hex'); }, enumerable: true, configurable: true }); /** * Returns the request JSON ready for broadcast to the Logos Network * @returns {DistributeJSON} JSON request */ Distribute.prototype.toJSON = function () { var obj = _super.prototype.toJSON.call(this); obj.transaction = this.transaction; return obj; }; return Distribute; }(TokenRequest_1.default)); exports.default = Distribute; //# sourceMappingURL=Distribute.js.map