@hiero-ledger/sdk
Version:
78 lines (71 loc) • 2.98 kB
JavaScript
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 _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
// 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;
;