PHP WebShell
Текущая директория: /usr/lib/node_modules/bitgo/node_modules/@bitgo/sdk-coin-hbar/node_modules/@hashgraph/sdk/src/topic
Просмотр файла: TopicDeleteTransaction.js
/*-
*
* Hedera JavaScript SDK
*
* Copyright (C) 2020 - 2022 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import Transaction, {
TRANSACTION_REGISTRY,
} from "../transaction/Transaction.js";
import TopicId from "./TopicId.js";
/**
* @namespace proto
* @typedef {import("@hashgraph/proto").proto.IConsensusDeleteTopicTransactionBody} HashgraphProto.proto.IConsensusDeleteTopicTransactionBody
* @typedef {import("@hashgraph/proto").proto.ITransaction} HashgraphProto.proto.ITransaction
* @typedef {import("@hashgraph/proto").proto.ISignedTransaction} HashgraphProto.proto.ISignedTransaction
* @typedef {import("@hashgraph/proto").proto.TransactionBody} HashgraphProto.proto.TransactionBody
* @typedef {import("@hashgraph/proto").proto.ITransactionBody} HashgraphProto.proto.ITransactionBody
* @typedef {import("@hashgraph/proto").proto.ITransactionResponse} HashgraphProto.proto.ITransactionResponse
*/
/**
* @typedef {import("../channel/Channel.js").default} Channel
* @typedef {import("../client/Client.js").default<*, *>} Client
* @typedef {import("../account/AccountId.js").default} AccountId
* @typedef {import("../transaction/TransactionId.js").default} TransactionId
*/
/**
* Delete a topic.
*
* No more transactions or queries on the topic will succeed.
*
* If an adminKey is set, this transaction must be signed by that key.
* If there is no adminKey, this transaction will fail with Status#Unautorized.
*/
export default class TopicDeleteTransaction extends Transaction {
/**
* @param {object} props
* @param {TopicId | string} [props.topicId]
*/
constructor(props = {}) {
super();
/**
* @private
* @type {?TopicId}
*/
this._topicId = null;
if (props.topicId != null) {
this.setTopicId(props.topicId);
}
}
/**
* @internal
* @param {HashgraphProto.proto.ITransaction[]} transactions
* @param {HashgraphProto.proto.ISignedTransaction[]} signedTransactions
* @param {TransactionId[]} transactionIds
* @param {AccountId[]} nodeIds
* @param {HashgraphProto.proto.ITransactionBody[]} bodies
* @returns {TopicDeleteTransaction}
*/
static _fromProtobuf(
transactions,
signedTransactions,
transactionIds,
nodeIds,
bodies
) {
const body = bodies[0];
const topicDelete =
/** @type {HashgraphProto.proto.IConsensusDeleteTopicTransactionBody} */ (
body.consensusDeleteTopic
);
return Transaction._fromProtobufTransactions(
new TopicDeleteTransaction({
topicId:
topicDelete.topicID != null
? TopicId._fromProtobuf(topicDelete.topicID)
: undefined,
}),
transactions,
signedTransactions,
transactionIds,
nodeIds,
bodies
);
}
/**
* @returns {?TopicId}
*/
get topicId() {
return this._topicId;
}
/**
* Set the topic ID which is being deleted in this transaction.
*
* @param {TopicId | string} topicId
* @returns {TopicDeleteTransaction}
*/
setTopicId(topicId) {
this._requireNotFrozen();
this._topicId =
typeof topicId === "string"
? TopicId.fromString(topicId)
: topicId.clone();
return this;
}
/**
* @param {Client} client
*/
_validateChecksums(client) {
if (this._topicId != null) {
this._topicId.validateChecksum(client);
}
}
/**
* @override
* @internal
* @param {Channel} channel
* @param {HashgraphProto.proto.ITransaction} request
* @returns {Promise<HashgraphProto.proto.ITransactionResponse>}
*/
_execute(channel, request) {
return channel.consensus.deleteTopic(request);
}
/**
* @override
* @protected
* @returns {NonNullable<HashgraphProto.proto.TransactionBody["data"]>}
*/
_getTransactionDataCase() {
return "consensusDeleteTopic";
}
/**
* @override
* @protected
* @returns {HashgraphProto.proto.IConsensusDeleteTopicTransactionBody}
*/
_makeTransactionData() {
return {
topicID: this._topicId != null ? this._topicId._toProtobuf() : null,
};
}
/**
* @returns {string}
*/
_getLogId() {
const timestamp = /** @type {import("../Timestamp.js").default} */ (
this._transactionIds.current.validStart
);
return `TopicDeleteTransaction:${timestamp.toString()}`;
}
}
TRANSACTION_REGISTRY.set(
"consensusDeleteTopic",
// eslint-disable-next-line @typescript-eslint/unbound-method
TopicDeleteTransaction._fromProtobuf
);
Выполнить команду
Для локальной разработки. Не используйте в интернете!