Beispiel #1
0
        /// <summary>
        /// Retrieves the current USD to hBar exchange rate information from the
        /// network.
        /// </summary>
        /// <remarks>
        /// NOTE: this method incours a charge to retrieve the file from the network.
        /// </remarks>
        /// <param name="client">Client Object</param>
        /// <param name="configure">
        /// Optional callback method providing an opportunity to modify
        /// the execution configuration for just this method call.
        /// It is executed prior to submitting the request to the network.
        /// </param>
        /// <returns>
        /// An Exchange Rates object providing the current and next
        /// exchange rates.
        /// </returns>
        public static async Task <ExchangeRates> GetExchangeRatesAsync(this Client client, Action <IContext>?configure = null)
        {
            var file = await client.GetFileContentAsync(EXCHANGE_RATE_FILE_ADDRESS, configure);

            var set = Proto.ExchangeRateSet.Parser.ParseFrom(file.ToArray());

            return(new ExchangeRates(Protobuf.FromExchangeRate(set.CurrentRate), Protobuf.FromExchangeRate(set.NextRate)));
        }