@provenanceio/wallet-utils
Version:
Typescript Utilities for Provenance Blockchain Wallet
42 lines (38 loc) • 1.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.buildTxBody = void 0;
var _tx_pb = require("../../../proto/cosmos/tx/v1beta1/tx_pb");
/**
* Builds the body for a transaction
* @param msgAny: A list of messages to be executed
* @param memo: Optional arbitrary note/comment to be added to the transaction
* @param timeoutHeight: the block height after which this transaction will not
* be processed by the chain
* @param extensionOptionsList: arbitrary options that can be added by chains
* when the default options are not sufficient. If any of these are present
* and can't be handled, the transaction will be rejected
* @param nonCriticalExtensionOptionsList: extension_options are arbitrary
* options that can be added by chains when the default options are not
* sufficient. If any of these are present and can't be handled, they will be
* ignored
* @returns Body of a transaction that all signers sign over
* reference: https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/tx/v1beta1/tx.proto#L13-L26
*/
var buildTxBody = function buildTxBody(_ref) {
var msgAny = _ref.msgAny,
_ref$memo = _ref.memo,
memo = _ref$memo === void 0 ? '' : _ref$memo,
timeoutHeight = _ref.timeoutHeight,
extensionOptionsList = _ref.extensionOptionsList,
nonCriticalExtensionOptionsList = _ref.nonCriticalExtensionOptionsList;
var txBody = new _tx_pb.TxBody();
if (Array.isArray(msgAny)) txBody.setMessagesList(msgAny);else txBody.addMessages(msgAny);
txBody.setMemo(memo);
if (timeoutHeight) txBody.setTimeoutHeight(timeoutHeight);
if (extensionOptionsList) txBody.setExtensionOptionsList(extensionOptionsList);
if (nonCriticalExtensionOptionsList) txBody.setNonCriticalExtensionOptionsList(nonCriticalExtensionOptionsList);
return txBody;
};
exports.buildTxBody = buildTxBody;