PHP WebShell

Текущая директория: /opt/BitGoJS/node_modules/@hashgraph/sdk/lib/schedule

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

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _ScheduleId = _interopRequireDefault(require("./ScheduleId.cjs"));
var _AccountId = _interopRequireDefault(require("../account/AccountId.cjs"));
var _Timestamp = _interopRequireDefault(require("../Timestamp.cjs"));
var _Transaction = _interopRequireDefault(require("../transaction/Transaction.cjs"));
var HashgraphProto = _interopRequireWildcard(require("@hashgraph/proto"));
var _TransactionId = _interopRequireDefault(require("../transaction/TransactionId.cjs"));
var _Key = _interopRequireDefault(require("../Key.cjs"));
var _KeyList = _interopRequireDefault(require("../KeyList.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.
 * ‍
 */

const {
  proto
} = HashgraphProto;

/**
 * Response when the client sends the node ScheduleGetInfoQuery.
 */
class ScheduleInfo {
  /**
   * @private
   * @param {object} props
   * @param {ScheduleId} props.scheduleId;
   * @param {?AccountId} props.creatorAccountID;
   * @param {?AccountId} props.payerAccountID;
   * @param {?HashgraphProto.proto.ISchedulableTransactionBody} props.schedulableTransactionBody;
   * @param {?Key} props.adminKey
   * @param {?KeyList} props.signers;
   * @param {?string} props.scheduleMemo;
   * @param {?Timestamp} props.expirationTime;
   * @param {?Timestamp} props.executed;
   * @param {?Timestamp} props.deleted;
   * @param {?TransactionId} props.scheduledTransactionId;
   * @param {boolean} props.waitForExpiry;
   */
  constructor(props) {
    /**
     * @readonly
     */
    this.scheduleId = props.scheduleId;

    /**
     * @readonly
     */
    this.creatorAccountId = props.creatorAccountID;

    /**
     * @readonly
     */
    this.payerAccountId = props.payerAccountID;

    /**
     * @readonly
     */
    this.schedulableTransactionBody = props.schedulableTransactionBody;

    /**
     * @readonly
     */
    this.signers = props.signers;

    /**
     * @readonly
     */
    this.scheduleMemo = props.scheduleMemo;

    /**
     * @readonly
     */
    this.adminKey = props.adminKey != null ? props.adminKey : null;

    /**
     * @readonly
     */
    this.expirationTime = props.expirationTime;

    /**
     * @readonly
     */
    this.executed = props.executed;

    /**
     * @readonly
     */
    this.deleted = props.deleted;

    /**
     * @readonly
     */
    this.scheduledTransactionId = props.scheduledTransactionId;

    /**
     *
     * @readonly
     */
    this.waitForExpiry = props.waitForExpiry;
    Object.freeze(this);
  }

  /**
   * @internal
   * @param {HashgraphProto.proto.IScheduleInfo} info
   * @returns {ScheduleInfo}
   */
  static _fromProtobuf(info) {
    return new ScheduleInfo({
      scheduleId: _ScheduleId.default._fromProtobuf( /** @type {HashgraphProto.proto.IScheduleID} */
      info.scheduleID),
      creatorAccountID: info.creatorAccountID != null ? _AccountId.default._fromProtobuf( /** @type {HashgraphProto.proto.IAccountID} */
      info.creatorAccountID) : null,
      payerAccountID: info.payerAccountID != null ? _AccountId.default._fromProtobuf( /** @type {HashgraphProto.proto.IAccountID} */
      info.payerAccountID) : null,
      schedulableTransactionBody: info.scheduledTransactionBody != null ? info.scheduledTransactionBody : null,
      adminKey: info.adminKey != null ? _Key.default._fromProtobufKey(info.adminKey) : null,
      signers: info.signers != null ? _KeyList.default.__fromProtobufKeyList(info.signers) : null,
      scheduleMemo: info.memo != null ? info.memo : null,
      expirationTime: info.expirationTime != null ? _Timestamp.default._fromProtobuf( /** @type {HashgraphProto.proto.ITimestamp} */
      info.expirationTime) : null,
      executed: info.executionTime != null ? _Timestamp.default._fromProtobuf( /** @type {HashgraphProto.proto.ITimestamp} */
      info.executionTime) : null,
      deleted: info.deletionTime != null ? _Timestamp.default._fromProtobuf( /** @type {HashgraphProto.proto.ITimestamp} */
      info.deletionTime) : null,
      scheduledTransactionId: info.scheduledTransactionID != null ? _TransactionId.default._fromProtobuf(info.scheduledTransactionID) : null,
      waitForExpiry: info.waitForExpiry != null ? info.waitForExpiry : false
    });
  }

  /**
   * @returns {HashgraphProto.proto.IScheduleInfo}
   */
  _toProtobuf() {
    return {
      scheduleID: this.scheduleId != null ? this.scheduleId._toProtobuf() : null,
      creatorAccountID: this.creatorAccountId != null ? this.creatorAccountId._toProtobuf() : null,
      payerAccountID: this.payerAccountId != null ? this.payerAccountId._toProtobuf() : null,
      scheduledTransactionBody: this.schedulableTransactionBody != null ? this.schedulableTransactionBody : null,
      adminKey: this.adminKey != null ? this.adminKey._toProtobufKey() : null,
      signers: this.signers != null ? this.signers._toProtobufKey().keyList : null,
      memo: this.scheduleMemo != null ? this.scheduleMemo : "",
      expirationTime: this.expirationTime != null ? this.expirationTime._toProtobuf() : null,
      scheduledTransactionID: this.scheduledTransactionId != null ? this.scheduledTransactionId._toProtobuf() : null,
      waitForExpiry: this.waitForExpiry
    };
  }

  /**
   * @returns {Transaction}
   */
  get scheduledTransaction() {
    if (this.schedulableTransactionBody == null) {
      throw new Error("Scheduled transaction body is empty");
    }
    const scheduled = new proto.SchedulableTransactionBody(this.schedulableTransactionBody);
    const data = /** @type {NonNullable<HashgraphProto.proto.SchedulableTransactionBody["data"]>} */
    scheduled.data;
    return _Transaction.default.fromBytes(proto.TransactionList.encode({
      transactionList: [{
        signedTransactionBytes: proto.SignedTransaction.encode({
          bodyBytes: proto.TransactionBody.encode({
            transactionFee: this.schedulableTransactionBody.transactionFee,
            memo: this.schedulableTransactionBody.memo,
            [data]: scheduled[data]
          }).finish()
        }).finish()
      }]
    }).finish());
  }
}
exports.default = ScheduleInfo;

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


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