@pokt-network/pocket-js
Version:
Pocket-js core package with the main functionalities to interact with the Pocket Network.
33 lines • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProtoTransactionSigner = void 0;
var _1 = require(".");
var __1 = require("..");
var proto_1 = require("./models/proto");
var ProtoTransactionSigner = /** @class */ (function () {
function ProtoTransactionSigner() {
}
/**
* Sign an unsigned transaction with a valid ed25519 signature
* @param {string} encodedMsg - stxTxMsgObj stringified
* @param {string} bytesToSign - the unsigned transaction bytes
* @param {TxSignature} txSignature - valid ed25519 signature and public key
* @returns {Promise<RawTxRequest | RpcError>} - A Raw transaction Response object or Rpc error.
* @memberof ProtoTransactionSigner
*/
ProtoTransactionSigner.signTransaction = function (encodedMsg, bytesToSign, txSignature) {
try {
var stdSignDoc = JSON.parse(Buffer.from(bytesToSign, 'hex').toString('utf-8'));
var stdTxMsgObj = proto_1.Any.fromJSON(JSON.parse(encodedMsg));
var addressHex = __1.addressFromPublickey(txSignature.pubKey);
var encodedTxBytes = _1.ProtoTxEncoder.marshalStdTx(stdTxMsgObj, stdSignDoc, txSignature);
return new __1.RawTxRequest(addressHex.toString('hex'), encodedTxBytes.toString('hex'));
}
catch (error) {
return __1.RpcError.fromError(error);
}
};
return ProtoTransactionSigner;
}());
exports.ProtoTransactionSigner = ProtoTransactionSigner;
//# sourceMappingURL=transaction-signer.js.map