UNPKG

@hashgraph/sdk

Version:
172 lines (157 loc) 6.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _Transaction = _interopRequireWildcard(require("../transaction/Transaction.cjs")); var _FileId = _interopRequireDefault(require("../file/FileId.cjs")); var _ContractId = _interopRequireDefault(require("../contract/ContractId.cjs")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } // SPDX-License-Identifier: Apache-2.0 /** * @namespace proto * @typedef {import("@hashgraph/proto").proto.ITransaction} HieroProto.proto.ITransaction * @typedef {import("@hashgraph/proto").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction * @typedef {import("@hashgraph/proto").proto.TransactionBody} HieroProto.proto.TransactionBody * @typedef {import("@hashgraph/proto").proto.ITransactionBody} HieroProto.proto.ITransactionBody * @typedef {import("@hashgraph/proto").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse * @typedef {import("@hashgraph/proto").proto.ISystemUndeleteTransactionBody} HieroProto.proto.ISystemUndeleteTransactionBody * @typedef {import("@hashgraph/proto").proto.IContractID} HieroProto.proto.IContractID * @typedef {import("@hashgraph/proto").proto.IFileID} HieroProto.proto.IFileID */ /** * @typedef {import("../channel/Channel.js").default} Channel * @typedef {import("../Timestamp.js").default} Timestamp * @typedef {import("../account/AccountId.js").default} AccountId * @typedef {import("../transaction/TransactionId.js").default} TransactionId */ /** * Deprecated: Do not use. * @deprecated */ class SystemUndeleteTransaction extends _Transaction.default { /** * @param {object} [props] * @param {FileId | string} [props.fileId] * @param {ContractId | string} [props.contractId] * @param {Timestamp} [props.expirationTime] */ constructor(props = {}) { super(); /** * @private * @type {?FileId} */ this._fileId = null; /** * @private * @type {?ContractId} */ this._contractId = null; if (props.fileId != null) { this.setFileId(props.fileId); } if (props.contractId != null) { this.setContractId(props.contractId); } } /** * @internal * @param {HieroProto.proto.ITransaction[]} transactions * @param {HieroProto.proto.ISignedTransaction[]} signedTransactions * @param {TransactionId[]} transactionIds * @param {AccountId[]} nodeIds * @param {HieroProto.proto.ITransactionBody[]} bodies * @returns {SystemUndeleteTransaction} */ static _fromProtobuf(transactions, signedTransactions, transactionIds, nodeIds, bodies) { const body = bodies[0]; const systemUndelete = /** @type {HieroProto.proto.ISystemUndeleteTransactionBody} */ body.systemUndelete; return _Transaction.default._fromProtobufTransactions( // eslint-disable-next-line deprecation/deprecation new SystemUndeleteTransaction({ fileId: systemUndelete.fileID != null ? _FileId.default._fromProtobuf(/** @type {HieroProto.proto.IFileID} */ systemUndelete.fileID) : undefined, contractId: systemUndelete.contractID != null ? _ContractId.default._fromProtobuf(/** @type {HieroProto.proto.IContractID} */ systemUndelete.contractID) : undefined }), transactions, signedTransactions, transactionIds, nodeIds, bodies); } /** * @returns {?FileId} */ get fileId() { return this._fileId; } /** * @param {FileId | string} fileId * @returns {this} */ setFileId(fileId) { this._requireNotFrozen(); this._fileId = fileId instanceof _FileId.default ? fileId : _FileId.default.fromString(fileId); return this; } /** * @returns {?ContractId} */ get contractId() { return this._contractId; } /** * @param {ContractId | string} contractId * @returns {this} */ setContractId(contractId) { this._requireNotFrozen(); this._contractId = contractId instanceof _ContractId.default ? contractId : _ContractId.default.fromString(contractId); return this; } /** * @override * @internal * @param {Channel} channel * @param {HieroProto.proto.ITransaction} request * @returns {Promise<HieroProto.proto.ITransactionResponse>} */ _execute(channel, request) { if (this._fileId != null) { return channel.file.systemUndelete(request); } else { return channel.smartContract.systemUndelete(request); } } /** * @override * @protected * @returns {NonNullable<HieroProto.proto.TransactionBody["data"]>} */ _getTransactionDataCase() { return "systemUndelete"; } /** * @override * @protected * @returns {HieroProto.proto.ISystemUndeleteTransactionBody} */ _makeTransactionData() { return { fileID: this._fileId != null ? this._fileId._toProtobuf() : null, contractID: this._contractId != null ? this._contractId._toProtobuf() : null }; } /** * @returns {string} */ _getLogId() { const timestamp = /** @type {import("../Timestamp.js").default} */ this._transactionIds.current.validStart; return `SystemUndeleteTransaction:${timestamp.toString()}`; } } exports.default = SystemUndeleteTransaction; _Transaction.TRANSACTION_REGISTRY.set("systemUndelete", // eslint-disable-next-line @typescript-eslint/unbound-method, deprecation/deprecation SystemUndeleteTransaction._fromProtobuf);