@hashgraph/sdk
Version:
74 lines (67 loc) • 2.43 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _ExchangeRate = _interopRequireDefault(require("./ExchangeRate.cjs"));
var HieroProto = _interopRequireWildcard(require("@hashgraph/proto"));
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); }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
// SPDX-License-Identifier: Apache-2.0
const {
proto
} = HieroProto;
/**
* Represents a pair of exchange rates for HBAR to USD cents conversion.
* Contains both the current exchange rate and the next exchange rate that will take effect.
*/
class ExchangeRates {
/**
* @private
* @param {object} props
* @param {ExchangeRate} props.currentRate
* @param {ExchangeRate} props.nextRate
*/
constructor(props) {
/**
* @readonly
*/
this.currentRate = props.currentRate;
/**
* @readonly
*/
this.nextRate = props.nextRate;
Object.freeze(this);
}
/**
* @internal
* @param {HieroProto.proto.IExchangeRateSet} rateSet
* @returns {ExchangeRates}
*/
static _fromProtobuf(rateSet) {
return new ExchangeRates({
currentRate: _ExchangeRate.default._fromProtobuf(/** @type {HieroProto.proto.IExchangeRate} */
rateSet.currentRate),
nextRate: _ExchangeRate.default._fromProtobuf(/** @type {HieroProto.proto.IExchangeRate} */
rateSet.nextRate)
});
}
/**
* @internal
* @returns {HieroProto.proto.IExchangeRateSet}
*/
_toProtobuf() {
return {
currentRate: this.currentRate._toProtobuf(),
nextRate: this.nextRate._toProtobuf()
};
}
/**
* @param {Uint8Array} bytes
* @returns {ExchangeRates}
*/
static fromBytes(bytes) {
return ExchangeRates._fromProtobuf(proto.ExchangeRateSet.decode(bytes));
}
}
exports.default = ExchangeRates;
;