PHP WebShell
Текущая директория: /usr/lib/node_modules/bitgo/node_modules/@bitgo/sdk-coin-hbar/node_modules/@hashgraph/sdk/lib
Просмотр файла: StakingInfo.cjs
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _AccountId = _interopRequireDefault(require("./account/AccountId.cjs"));
var _Hbar = _interopRequireDefault(require("./Hbar.cjs"));
var _Timestamp = _interopRequireDefault(require("./Timestamp.cjs"));
var HashgraphProto = _interopRequireWildcard(require("@hashgraph/proto"));
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.
*
*/
/**
* @typedef {import("long").Long} Long
*/
/**
* @typedef {object} StakingInfoJson
* @property {boolean} declineStakingReward
* @property {?string} stakePeriodStart
* @property {?string} pendingReward
* @property {?string} stakedToMe
* @property {?string} stakedAccountId
* @property {?string} stakedNodeId
*/
/**
* Staking metadata for an account or a contract returned in CryptoGetInfo or ContractGetInfo queries
*/
class StakingInfo {
/**
* @private
* @param {object} props
* @param {boolean} props.declineStakingReward
* @param {?Timestamp} props.stakePeriodStart
* @param {?Hbar} props.pendingReward
* @param {?Hbar} props.stakedToMe
* @param {?AccountId} props.stakedAccountId
* @param {?Long} props.stakedNodeId
*/
constructor(props) {
/**
* If true, this account or contract declined to receive a staking reward.
*
* @readonly
*/
this.declineStakingReward = props.declineStakingReward;
/**
* The staking period during which either the staking settings for this
* account or contract changed (such as starting staking or changing
* staked_node_id) or the most recent reward was earned, whichever is
* later. If this account or contract is not currently staked to a
* node, then this field is not set.
*
* @readonly
*/
this.stakePeriodStart = props.stakePeriodStart;
/**
* The amount in tinybars that will be received in the next reward
* situation.
*
* @readonly
*/
this.pendingReward = props.pendingReward;
/**
* The total of balance of all accounts staked to this account or contract.
*
* @readonly
*/
this.stakedToMe = props.stakedToMe;
/**
* The account to which this account or contract is staking.
*
* @readonly
*/
this.stakedAccountId = props.stakedAccountId;
/**
* The ID of the node this account or contract is staked to.
*
* @readonly
*/
this.stakedNodeId = props.stakedNodeId;
Object.freeze(this);
}
/**
* @internal
* @param {HashgraphProto.proto.IStakingInfo} info
* @returns {StakingInfo}
*/
static _fromProtobuf(info) {
return new StakingInfo({
declineStakingReward: info.declineReward == true,
stakePeriodStart: info.stakePeriodStart != null ? _Timestamp.default._fromProtobuf(info.stakePeriodStart) : null,
pendingReward: info.pendingReward != null ? _Hbar.default.fromTinybars(info.pendingReward) : null,
stakedToMe: info.stakedToMe != null ? _Hbar.default.fromTinybars(info.stakedToMe) : null,
stakedAccountId: info.stakedAccountId != null ? _AccountId.default._fromProtobuf(info.stakedAccountId) : null,
stakedNodeId: info.stakedNodeId != null ? info.stakedNodeId : null
});
}
/**
* @returns {HashgraphProto.proto.IStakingInfo}
*/
_toProtobuf() {
return {
declineReward: this.declineStakingReward,
stakePeriodStart: this.stakePeriodStart != null ? this.stakePeriodStart._toProtobuf() : null,
pendingReward: this.pendingReward != null ? this.pendingReward.toTinybars() : null,
stakedToMe: this.stakedToMe != null ? this.stakedToMe.toTinybars() : null,
stakedAccountId: this.stakedAccountId != null ? this.stakedAccountId._toProtobuf() : null,
stakedNodeId: this.stakedNodeId
};
}
/**
* @param {Uint8Array} bytes
* @returns {StakingInfo}
*/
static fromBytes(bytes) {
return StakingInfo._fromProtobuf(HashgraphProto.proto.StakingInfo.decode(bytes));
}
/**
* @returns {Uint8Array}
*/
toBytes() {
return HashgraphProto.proto.StakingInfo.encode(this._toProtobuf()).finish();
}
/**
* @returns {string}
*/
toString() {
return JSON.stringify(this.toJSON());
}
/**
* @returns {StakingInfoJson}
*/
toJSON() {
return {
declineStakingReward: this.declineStakingReward,
stakePeriodStart: this.stakePeriodStart != null ? this.stakePeriodStart.toString() : null,
pendingReward: this.pendingReward != null ? this.pendingReward.toString() : null,
stakedToMe: this.stakedToMe != null ? this.stakedToMe.toString() : null,
stakedAccountId: this.stakedAccountId != null ? this.stakedAccountId.toString() : null,
stakedNodeId: this.stakedNodeId != null ? this.stakedNodeId.toString() : null
};
}
}
exports.default = StakingInfo;Выполнить команду
Для локальной разработки. Не используйте в интернете!