PHP WebShell
Текущая директория: /opt/BitGoJS/node_modules/@hashgraph/sdk/lib/address_book
Просмотр файла: NodeAddress.cjs
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _AccountId = _interopRequireDefault(require("../account/AccountId.cjs"));
var _Endpoint = _interopRequireDefault(require("./Endpoint.cjs"));
var utf8 = _interopRequireWildcard(require("../encoding/utf8.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.INodeAddress} HashgraphProto.proto.INodeAddress
*/
/**
* @typedef {import("./Endpoint.js").EndPointJson} EndpointJson
* @typedef {import("long").Long} Long
*/
/**
* @typedef {object} NodeAddressJson
* @property {string | null} publicKey
* @property {string | null} nodeId
* @property {string | null} accountId
* @property {string | null} certHash
* @property {EndpointJson[] | null} addresses
* @property {string | null} description
* @property {string | null} stake
*/
class NodeAddress {
/**
* @param {object} props
* @param {string} [props.publicKey]
* @param {Long} [props.nodeId]
* @param {AccountId | string} [props.accountId]
* @param {Uint8Array} [props.certHash]
* @param {Endpoint[]} [props.addresses]
* @param {string} [props.description]
* @param {Long} [props.stake]
*/
constructor(props = {}) {
/**
* @type {string | null}
*/
this._publicKey = null;
if (props.publicKey != null) {
this.setPublicKey(props.publicKey);
}
/**
* @type {Long |null}
*/
this._nodeId = null;
if (props.nodeId != null) {
this.setNodeId(props.nodeId);
}
/**
* @type {AccountId | null}
*/
this._accountId = null;
if (props.accountId != null) {
this.setAccountId(props.accountId);
}
/**
* @type {Uint8Array | null}
*/
this._certHash = null;
if (props.certHash != null) {
this.setCertHash(props.certHash);
}
/**
* @type {Endpoint[]}
*/
this._addresses = [];
if (props.addresses != null) {
this.setAddresses(props.addresses);
}
/**
* @type {string | null}
*/
this._description = null;
if (props.description != null) {
this.setDescription(props.description);
}
/**
* @type {Long | null}
*/
this._stake = null;
if (props.stake != null) {
this.setStake(props.stake);
}
}
/**
* @returns {?string}
*/
get publicKey() {
return this._publicKey;
}
/**
* @param {string} publicKey
* @returns {this}
*/
setPublicKey(publicKey) {
this._publicKey = publicKey;
return this;
}
/**
* @returns {?Long}
*/
get nodeId() {
return this._nodeId;
}
/**
* @param {Long} nodeId
* @returns {this}
*/
setNodeId(nodeId) {
this._nodeId = nodeId;
return this;
}
/**
* @returns {?AccountId}
*/
get accountId() {
return this._accountId;
}
/**
* @param {AccountId | string} accountId
* @returns {this}
*/
setAccountId(accountId) {
this._accountId = typeof accountId === "string" ? _AccountId.default.fromString(accountId) : accountId.clone();
return this;
}
/**
* @returns {?Uint8Array}
*/
get certHash() {
return this._certHash;
}
/**
* @param {Uint8Array} certHash
* @returns {this}
*/
setCertHash(certHash) {
this._certHash = certHash;
return this;
}
/**
* @returns {Endpoint[]}
*/
get addresses() {
return this._addresses;
}
/**
* @param {Endpoint[]} addresses
* @returns {this}
*/
setAddresses(addresses) {
this._addresses = addresses;
return this;
}
/**
* @returns {?string}
*/
get description() {
return this._description;
}
/**
* @param {string} description
* @returns {this}
*/
setDescription(description) {
this._description = description;
return this;
}
/**
* @returns {?Long}
*/
get stake() {
return this._stake;
}
/**
* @param {Long} stake
* @returns {this}
*/
setStake(stake) {
this._stake = stake;
return this;
}
/**
* @internal
* @param {HashgraphProto.proto.INodeAddress} nodeAddress
* @returns {NodeAddress}
*/
static _fromProtobuf(nodeAddress) {
return new NodeAddress({
publicKey: nodeAddress.RSA_PubKey != null ? nodeAddress.RSA_PubKey : undefined,
nodeId: nodeAddress.nodeId != null ? nodeAddress.nodeId : undefined,
accountId: nodeAddress.nodeAccountId != null ? _AccountId.default._fromProtobuf(nodeAddress.nodeAccountId) : undefined,
certHash: nodeAddress.nodeCertHash != null ? nodeAddress.nodeCertHash : undefined,
addresses: nodeAddress.serviceEndpoint != null ? nodeAddress.serviceEndpoint.map(address => _Endpoint.default._fromProtobuf(address)) : undefined,
description: nodeAddress.description != null ? nodeAddress.description : undefined,
stake: nodeAddress.stake != null ? nodeAddress.stake : undefined
});
}
/**
* @returns {HashgraphProto.proto.INodeAddress}
*/
_toProtobuf() {
return {
RSA_PubKey: this._publicKey,
nodeId: this._nodeId,
nodeAccountId: this._accountId != null ? this._accountId._toProtobuf() : null,
nodeCertHash: this._certHash,
serviceEndpoint: this._addresses.map(address => address._toProtobuf()),
description: this._description,
stake: this._stake
};
}
/**
* @returns {string}
*/
toString() {
return JSON.stringify(this.toJSON());
}
/**
* @returns {NodeAddressJson}
*/
toJSON() {
return {
publicKey: this._publicKey,
nodeId: this._nodeId != null ? this._nodeId.toString() : null,
accountId: this._accountId != null ? this._accountId.toString() : null,
certHash: this._certHash != null ? utf8.decode(this._certHash) : null,
addresses: this._addresses.map(address => address.toJSON()),
description: this._description,
stake: this._stake != null ? this._stake.toString() : null
};
}
}
exports.default = NodeAddress;Выполнить команду
Для локальной разработки. Не используйте в интернете!