UNPKG

@pokt-network/pocket-js

Version:

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

44 lines 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProtoTxDecoder = void 0; var tx_signer_1 = require("../models/proto/generated/tx-signer"); var ProtoTxDecoder = /** @class */ (function () { function ProtoTxDecoder() { } // Returns partially decoded transaction ProtoTxDecoder.prototype.unmarshalStdTx = function (encodedTxBytes, length) { if (length === void 0) { length = encodedTxBytes.length; } return tx_signer_1.ProtoStdTx.decode(encodedTxBytes.subarray(2), length - 2); }; // Returns decoded transaction message data ProtoTxDecoder.prototype.decodeStdTxData = function (protoStdTx) { var _a; switch ((_a = protoStdTx.msg) === null || _a === void 0 ? void 0 : _a.typeUrl) { case '/x.nodes.MsgSend': var msgSendData = tx_signer_1.MsgSend.decode(protoStdTx.msg.value); var decodedStdTxData = { memo: protoStdTx.memo, entropy: protoStdTx.entropy, fee: protoStdTx.fee, msg: { typeUrl: protoStdTx.msg.typeUrl, value: { amount: msgSendData.amount, FromAddress: Buffer.from(msgSendData.FromAddress).toString('hex'), ToAddress: Buffer.from(msgSendData.ToAddress).toString('hex') } }, signature: protoStdTx.signature ? { publicKey: Buffer.from(protoStdTx.signature.publicKey).toString('hex'), Signature: Buffer.from(protoStdTx.signature.Signature).toString('hex') } : protoStdTx.signature }; return decodedStdTxData; default: throw Error('Decoding for transaction type not supported yet.'); } }; return ProtoTxDecoder; }()); exports.ProtoTxDecoder = ProtoTxDecoder; //# sourceMappingURL=proto-tx-decoder.js.map