@hiero-ledger/sdk
Version:
171 lines (156 loc) • 6.03 kB
JavaScript
"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 _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
// 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);