/// <summary> /// Checks the gas price entered in the gas price field. /// </summary> /// <param name="gasPrice"> The entered gas price. </param> private void CheckGasPriceField(string gasPrice) { decimal price; decimal.TryParse(gasPriceField.Text, out price); enteredGasPrice = new GasPrice(GasUtils.GetFunctionalGasPrice(price)); gasPriceField.Error = string.IsNullOrEmpty(gasPriceField.Text) || price == 0; OnGasChanged?.Invoke(); }
/// <summary> /// Updates the newest gas price estimates. /// </summary> /// <param name="value"> The current value of the slider to use to estimate the gas price. </param> private void UpdateGasPriceEstimate(float value) { GasPrice gasPrice = EqualityComparer <GasPrice> .Default.Equals(StandardGasPrice, default(GasPrice)) ? new GasPrice(GasUtils.GetFunctionalGasPrice(10)) : StandardGasPrice; decimal multiplier = decimal.Round((decimal)Mathf.Lerp(0.65f, 1.4f, value) * (decimal)Mathf.Lerp(1f, 4f, value - 0.45f), 2, MidpointRounding.AwayFromZero); onGasPriceChanged?.Invoke(new GasPrice(new BigInteger(multiplier * (decimal)gasPrice.FunctionalGasPrice.Value))); }