UNPKG

@hashgraph/sdk

Version:
79 lines (72 loc) 3.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var HieroProto = _interopRequireWildcard(require("@hashgraph/proto")); var _TransactionFeeSchedule = _interopRequireDefault(require("./TransactionFeeSchedule.cjs")); var _Timestamp = _interopRequireDefault(require("./Timestamp.cjs")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } // SPDX-License-Identifier: Apache-2.0 /** * A set of fee schedules covering all transaction types and query types, along * with a specific time at which this fee schedule will expire. */ class FeeSchedule { /** * @param {object} [props] * @param {TransactionFeeSchedule[]} [props.transactionFeeSchedule] * @param {Timestamp} [props.expirationTime] */ constructor(props = {}) { /* * List of price coefficients for network resources * * @type {TransactionFeeSchedule} */ this.transactionFeeSchedule = props.transactionFeeSchedule; /* * FeeSchedule expiry time * * @type {Timestamp} */ this.expirationTime = props.expirationTime; } /** * @param {Uint8Array} bytes * @returns {FeeSchedule} */ static fromBytes(bytes) { return FeeSchedule._fromProtobuf(HieroProto.proto.FeeSchedule.decode(bytes)); } /** * @internal * @param {HieroProto.proto.IFeeSchedule} feeSchedule * @returns {FeeSchedule} */ static _fromProtobuf(feeSchedule) { return new FeeSchedule({ transactionFeeSchedule: feeSchedule.transactionFeeSchedule != null ? feeSchedule.transactionFeeSchedule.map(schedule => _TransactionFeeSchedule.default._fromProtobuf(schedule)) : undefined, expirationTime: feeSchedule.expiryTime != null ? _Timestamp.default._fromProtobuf(feeSchedule.expiryTime) : undefined }); } /** * @internal * @returns {HieroProto.proto.IFeeSchedule} */ _toProtobuf() { return { transactionFeeSchedule: this.transactionFeeSchedule != null ? this.transactionFeeSchedule.map(transaction => transaction._toProtobuf()) : undefined, expiryTime: this.expirationTime != null ? this.expirationTime._toProtobuf() : undefined }; } /** * @returns {Uint8Array} */ toBytes() { return HieroProto.proto.FeeSchedule.encode(this._toProtobuf()).finish(); } } exports.default = FeeSchedule;