PHP WebShell

Текущая директория: /usr/lib/node_modules/bitgo/node_modules/@bitgo/sdk-coin-hbar/node_modules/@hashgraph/sdk/lib/topic

Просмотр файла: TopicCreateTransaction.cjs

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _AccountId = _interopRequireDefault(require("../account/AccountId.cjs"));
var _Transaction = _interopRequireWildcard(require("../transaction/Transaction.cjs"));
var _Duration = _interopRequireDefault(require("../Duration.cjs"));
var _Key = _interopRequireDefault(require("../Key.cjs"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*-
 * ‌
 * 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.
 * ‍
 */

/**
 * @namespace proto
 * @typedef {import("@hashgraph/proto").proto.IConsensusCreateTopicTransactionBody} HashgraphProto.proto.IConsensusCreateTopicTransactionBody
 * @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("../transaction/TransactionId.js").default} TransactionId
 */
/**
 * Create a topic to be used for consensus.
 */
class TopicCreateTransaction extends _Transaction.default {
  /**
   * @param {object} props
   * @param {Key} [props.adminKey]
   * @param {Key} [props.submitKey]
   * @param {Duration | Long | number} [props.autoRenewPeriod]
   * @param {AccountId | string} [props.autoRenewAccountId]
   * @param {string} [props.topicMemo]
   */
  constructor(props = {}) {
    super();

    /**
     * @private
     * @type {?Key}
     */
    this._adminKey = null;

    /**
     * @private
     * @type {?Key}
     */
    this._submitKey = null;

    /**
     * @private
     * @type {?AccountId}
     */
    this._autoRenewAccountId = null;

    /**
     * @private
     * @type {Duration}
     */
    this._autoRenewPeriod = new _Duration.default(_Transaction.DEFAULT_AUTO_RENEW_PERIOD);

    /**
     * @private
     * @type {?string}
     */
    this._topicMemo = null;
    if (props.adminKey != null) {
      this.setAdminKey(props.adminKey);
    }
    if (props.submitKey != null) {
      this.setSubmitKey(props.submitKey);
    }
    if (props.autoRenewAccountId != null) {
      this.setAutoRenewAccountId(props.autoRenewAccountId);
    }
    if (props.autoRenewPeriod != null) {
      this.setAutoRenewPeriod(props.autoRenewPeriod);
    }
    if (props.topicMemo != null) {
      this.setTopicMemo(props.topicMemo);
    }
  }

  /**
   * @internal
   * @param {HashgraphProto.proto.ITransaction[]} transactions
   * @param {HashgraphProto.proto.ISignedTransaction[]} signedTransactions
   * @param {TransactionId[]} transactionIds
   * @param {AccountId[]} nodeIds
   * @param {HashgraphProto.proto.ITransactionBody[]} bodies
   * @returns {TopicCreateTransaction}
   */
  static _fromProtobuf(transactions, signedTransactions, transactionIds, nodeIds, bodies) {
    const body = bodies[0];
    const create = /** @type {HashgraphProto.proto.IConsensusCreateTopicTransactionBody} */
    body.consensusCreateTopic;
    return _Transaction.default._fromProtobufTransactions(new TopicCreateTransaction({
      adminKey: create.adminKey != null ? _Key.default._fromProtobufKey(create.adminKey) : undefined,
      submitKey: create.submitKey != null ? _Key.default._fromProtobufKey(create.submitKey) : undefined,
      autoRenewAccountId: create.autoRenewAccount != null ? _AccountId.default._fromProtobuf(create.autoRenewAccount) : undefined,
      autoRenewPeriod: create.autoRenewPeriod != null ? create.autoRenewPeriod.seconds != null ? create.autoRenewPeriod.seconds : undefined : undefined,
      topicMemo: create.memo != null ? create.memo : undefined
    }), transactions, signedTransactions, transactionIds, nodeIds, bodies);
  }

  /**
   * @deprecated  - Use `getTopicMemo()` instead
   * @returns {?string}
   */
  get topicMemo() {
    return this._topicMemo;
  }

  /**
   * @returns {?string}
   */
  getTopicMemo() {
    return this._topicMemo;
  }

  /**
   * @param {string} topicMemo
   * @returns {this}
   */
  setTopicMemo(topicMemo) {
    this._requireNotFrozen();
    this._topicMemo = topicMemo;
    return this;
  }

  /**
   * @deprecated  - Use `getAdminKey()` instead
   * @returns {?Key}
   */
  get adminKey() {
    return this._adminKey;
  }

  /**
   * @returns {?Key}
   */
  getAdminKey() {
    return this._adminKey;
  }

  /**
   * @param {Key} adminKey
   * @returns {this}
   */
  setAdminKey(adminKey) {
    this._requireNotFrozen();
    this._adminKey = adminKey;
    return this;
  }

  /**
   * @deprecated  - Use `getSubmitKey()` instead
   * @returns {?Key}
   */
  get submitKey() {
    return this._submitKey;
  }

  /**
   * @returns {?Key}
   */
  getSubmitKey() {
    return this._submitKey;
  }

  /**
   * @param {Key} submitKey
   * @returns {this}
   */
  setSubmitKey(submitKey) {
    this._requireNotFrozen();
    this._submitKey = submitKey;
    return this;
  }

  /**
   * @deprecated  - Use `getAutoRenewAccountId()` instead
   * @returns {?AccountId}
   */
  get autoRenewAccountId() {
    return this._autoRenewAccountId;
  }

  /**
   * @returns {?AccountId}
   */
  getAutoRenewAccountId() {
    return this._autoRenewAccountId;
  }

  /**
   * @param {AccountId | string} autoRenewAccountId
   * @returns {this}
   */
  setAutoRenewAccountId(autoRenewAccountId) {
    this._requireNotFrozen();
    this._autoRenewAccountId = autoRenewAccountId instanceof _AccountId.default ? autoRenewAccountId : _AccountId.default.fromString(autoRenewAccountId);
    return this;
  }

  /**
   * @deprecated  - Use `getAutoRenewPeriod()` instead
   * @returns {Duration}
   */
  get autoRenewPeriod() {
    return this._autoRenewPeriod;
  }

  /**
   * @returns {Duration}
   */
  getAutoRenewPeriod() {
    return this._autoRenewPeriod;
  }

  /**
   * Set the auto renew period for this account.
   *
   * @param {Duration | Long | number} autoRenewPeriod
   * @returns {this}
   */
  setAutoRenewPeriod(autoRenewPeriod) {
    this._requireNotFrozen();
    this._autoRenewPeriod = autoRenewPeriod instanceof _Duration.default ? autoRenewPeriod : new _Duration.default(autoRenewPeriod);
    return this;
  }

  /**
   * @param {Client} client
   */
  _validateChecksums(client) {
    if (this._autoRenewAccountId != null) {
      this._autoRenewAccountId.validateChecksum(client);
    }
  }

  /**
   * @override
   * @internal
   * @param {Channel} channel
   * @param {HashgraphProto.proto.ITransaction} request
   * @returns {Promise<HashgraphProto.proto.ITransactionResponse>}
   */
  _execute(channel, request) {
    return channel.consensus.createTopic(request);
  }

  /**
   * @override
   * @protected
   * @returns {NonNullable<HashgraphProto.proto.TransactionBody["data"]>}
   */
  _getTransactionDataCase() {
    return "consensusCreateTopic";
  }

  /**
   * @override
   * @protected
   * @returns {HashgraphProto.proto.IConsensusCreateTopicTransactionBody}
   */
  _makeTransactionData() {
    return {
      adminKey: this._adminKey != null ? this._adminKey._toProtobufKey() : null,
      submitKey: this._submitKey != null ? this._submitKey._toProtobufKey() : null,
      autoRenewAccount: this._autoRenewAccountId != null ? this._autoRenewAccountId._toProtobuf() : null,
      autoRenewPeriod: this._autoRenewPeriod._toProtobuf(),
      memo: this._topicMemo
    };
  }

  /**
   * @returns {string}
   */
  _getLogId() {
    const timestamp = /** @type {import("../Timestamp.js").default} */
    this._transactionIds.current.validStart;
    return `TopicCreateTransaction:${timestamp.toString()}`;
  }
}
exports.default = TopicCreateTransaction;
_Transaction.TRANSACTION_REGISTRY.set("consensusCreateTopic",
// eslint-disable-next-line @typescript-eslint/unbound-method
TopicCreateTransaction._fromProtobuf);

Выполнить команду


Для локальной разработки. Не используйте в интернете!