UNPKG

@roochnetwork/rooch-sdk

Version:
78 lines (77 loc) 2.2 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var transaction_exports = {}; __export(transaction_exports, { Transaction: () => Transaction }); module.exports = __toCommonJS(transaction_exports); var import_bcs = require("../bcs/index.js"); var import_transactionData = require("./transactionData.js"); class Transaction { callFunction(input) { this.info = input.info; this.data = new import_transactionData.TransactionData( import_transactionData.MoveAction.newCallFunction(input), input.maxGas ? BigInt(input.maxGas) : void 0 ); } getInfo() { return this.info; } getMaxGas() { return this.getData().maxGas; } setMaxGas(input) { this.getData().maxGas = BigInt(input); } setSender(input) { this.getData().sender = input; } setAuth(input) { this.auth = input; } setChainId(input) { this.getData().chainId = input; } setSeqNumber(input) { this.getData().sequenceNumber = input; } hashData() { return this.getData().hash(); } encodeData() { return this.data.encode(); } encode() { return import_bcs.bcs.RoochTransaction.serialize({ data: this.data.encode().toBytes(), auth: this.auth.encode() }); } getData() { this.isValid(); return this.data; } isValid() { if (!this.data) { throw new Error("Transaction data is not initialized. Call action first."); } } } //# sourceMappingURL=transaction.js.map