PHP WebShell

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

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

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _NftId = _interopRequireDefault(require("./NftId.cjs"));
var _AccountId = _interopRequireDefault(require("../account/AccountId.cjs"));
var _Timestamp = _interopRequireDefault(require("../Timestamp.cjs"));
var hex = _interopRequireWildcard(require("../encoding/hex.cjs"));
var _LedgerId = _interopRequireDefault(require("../LedgerId.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.TokenFreezeStatus} HashgraphProto.proto.TokenFreezeStatus
 * @typedef {import("@hashgraph/proto").proto.TokenKycStatus} HashgraphProto.proto.TokenKycStatus
 * @typedef {import("@hashgraph/proto").proto.TokenPauseStatus} HashgraphProto.proto.TokenPauseStatus
 * @typedef {import("@hashgraph/proto").proto.ITokenNftInfo} HashgraphProto.proto.ITokenNftInfo
 * @typedef {import("@hashgraph/proto").proto.INftID} HashgraphProto.proto.INftID
 * @typedef {import("@hashgraph/proto").proto.ITimestamp} HashgraphProto.proto.ITimestamp
 * @typedef {import("@hashgraph/proto").proto.ITokenID} HashgraphProto.proto.ITokenID
 * @typedef {import("@hashgraph/proto").proto.IAccountID} HashgraphProto.proto.IAccountID
 * @typedef {import("@hashgraph/proto").proto.IKey} HashgraphProto.proto.IKey
 * @typedef {import("@hashgraph/proto").proto.IDuration} HashgraphProto.proto.IDuration
 */

class TokenNftInfo {
  /**
   * @private
   * @param {object} props
   * @param {NftId} props.nftId
   * @param {AccountId} props.accountId
   * @param {Timestamp} props.creationTime
   * @param {Uint8Array | null} props.metadata
   * @param {LedgerId|null} props.ledgerId
   * @param {AccountId|null} props.spenderId
   */
  constructor(props) {
    /**
     * ID of the nft instance
     *
     * @readonly
     */
    this.nftId = props.nftId;

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

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

    /**
     * @readonly
     */
    this.metadata = props.metadata;
    this.ledgerId = props.ledgerId;
    this.spenderId = props.spenderId;
    Object.freeze(this);
  }

  /**
   * @internal
   * @param {HashgraphProto.proto.ITokenNftInfo} info
   * @returns {TokenNftInfo}
   */
  static _fromProtobuf(info) {
    return new TokenNftInfo({
      nftId: _NftId.default._fromProtobuf( /** @type {HashgraphProto.proto.INftID} */info.nftID),
      accountId: _AccountId.default._fromProtobuf( /** @type {HashgraphProto.proto.IAccountID} */info.accountID),
      creationTime: _Timestamp.default._fromProtobuf( /** @type {HashgraphProto.proto.ITimestamp} */
      info.creationTime),
      metadata: info.metadata !== undefined ? info.metadata : null,
      ledgerId: info.ledgerId != null ? _LedgerId.default.fromBytes(info.ledgerId) : null,
      spenderId: info.spenderId != null ? _AccountId.default._fromProtobuf(info.spenderId) : null
    });
  }

  /**
   * @returns {HashgraphProto.proto.ITokenNftInfo}
   */
  _toProtobuf() {
    return {
      nftID: this.nftId._toProtobuf(),
      accountID: this.accountId._toProtobuf(),
      creationTime: this.creationTime._toProtobuf(),
      metadata: this.metadata,
      ledgerId: this.ledgerId != null ? this.ledgerId.toBytes() : null,
      spenderId: this.spenderId != null ? this.spenderId._toProtobuf() : null
    };
  }

  /**
   * @typedef {object} TokenNftInfoJson
   * @property {string} nftId
   * @property {string} accountId
   * @property {string} creationTime
   * @property {string | null} metadata
   * @property {string | null} ledgerId
   * @property {string | null} spenderId
   * @returns {TokenNftInfoJson}
   */
  toJson() {
    return {
      nftId: this.nftId.toString(),
      accountId: this.accountId.toString(),
      creationTime: this.creationTime.toString(),
      metadata: this.metadata != null ? hex.encode(this.metadata) : null,
      ledgerId: this.ledgerId != null ? this.ledgerId.toString() : null,
      spenderId: this.spenderId != null ? this.spenderId.toString() : null
    };
  }

  /**
   * @returns {string}
   */
  toString() {
    return JSON.stringify(this.toJson());
  }
}
exports.default = TokenNftInfo;

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


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