minterjs-tx
Version:
A simple module for creating, manipulating and signing Minter transactions
58 lines (55 loc) • 2.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _signature = require("ethereumjs-util/dist/signature.js");
var _defineProperties2 = _interopRequireDefault(require("./define-properties.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
var TxSignature = /*#__PURE__*/function () {
function TxSignature(data) {
_classCallCheck(this, TxSignature);
data = data || {};
// Define Properties
var fields = [{
name: 'v',
"default": Buffer.from([0x1c])
}, {
name: 'r',
length: 32,
allowLess: true
}, {
name: 's',
length: 32,
allowLess: true
}];
/**
* Returns the rlp encoding of the transaction
* @method serialize
* @return {Buffer}
* @memberof Transaction
* @name serialize
*/
// attached serialize
(0, _defineProperties2["default"])(this, fields, data);
}
/**
* sign a transaction with a given a private key
* @param messageHash
* @param {Buffer} privateKey
*/
_createClass(TxSignature, [{
key: "sign",
value: function sign(messageHash, privateKey) {
var rsvSig = (0, _signature.ecsign)(messageHash, privateKey);
Object.assign(this, rsvSig);
return this;
}
}]);
return TxSignature;
}();
var _default = TxSignature;
exports["default"] = _default;