dpos-offline
Version:
Offline Signing Transactions for DPOS Blockchains
62 lines (61 loc) • 2.29 kB
JavaScript
;
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 __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
Object.defineProperty(exports, "__esModule", { value: true });
var base_lisk_1 = require("./base_lisk");
var LiskVoteTxCodec = /** @class */ (function (_super) {
__extends(LiskVoteTxCodec, _super);
function LiskVoteTxCodec() {
return _super.call(this, 3, 'vote') || this;
}
LiskVoteTxCodec.prototype.calcFees = function (tx) {
return 100000000;
};
LiskVoteTxCodec.prototype.transform = function (from) {
var e_1, _a;
var s = _super.prototype.transform.call(this, from);
s.recipientId = s.senderId;
var votes = [];
try {
for (var _b = __values(from.preferences), _c = _b.next(); !_c.done; _c = _b.next()) {
var pref = _c.value;
votes.push("" + pref.action + pref.delegateIdentifier.toString('hex'));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
s.asset = { votes: votes };
return s;
};
LiskVoteTxCodec.prototype.assetBytes = function (tx) {
return Buffer.from(tx.asset.votes.join(''), 'utf8');
};
return LiskVoteTxCodec;
}(base_lisk_1.BaseLiskCodec));
exports.LiskVoteTxCodec = LiskVoteTxCodec;